Skip to content

Commit fb297d7

Browse files
author
Philipp
committed
CodeMirror wrapper fits code height
1 parent 4ab2368 commit fb297d7

File tree

6 files changed

+16
-43
lines changed

6 files changed

+16
-43
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ http://codemirror.net/
88

99
### Usage
1010

11+
In order to make CodeMirror work correctly, do not forget to start your HTML page with `<!doctype html>`
12+
1113
##### Initialize
1214

1315
`options` can be `null` or contain original CodeMirror settings

example.html

Lines changed: 0 additions & 33 deletions
This file was deleted.

index.html

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
1+
<!doctype html>
2+
13
<head>
24
<script src="bower_components/jquery/dist/jquery.min.js"></script>
35

46
<script src="bower_components/codemirror/lib/codemirror.js"></script>
57
<link rel="stylesheet" href="bower_components/codemirror/lib/codemirror.css">
68
<script src="bower_components/codemirror/mode/xml/xml.js"></script>
79

8-
<script src="philsweb.jquery-codemirror.js"></script>
10+
<script src="philsweb.jquery-codemirror.min.js"></script>
911
<link rel="stylesheet" href="philsweb.codemirror.css">
1012

1113
<style>
12-
.CodeMirror {
13-
height: inherit;
14-
}
15-
1614
.code-snippet-group-1 {
15+
vertical-align:top;
1716
margin: 10px;
1817
width: 250px;
19-
height: 150px;
2018
border: 1px solid black;
2119
display: inline-block;
2220
}
2321

2422
.code-snippet-group-2 {
2523
margin: 10px;
2624
width: 802px;
27-
height: 250px;
2825
border: 1px solid black;
2926
}
3027

@@ -38,7 +35,7 @@
3835

3936
<h3>'philsweb.jquery-codemirror' Demo</h3>
4037

41-
<div class="code-snippet-group-1" first></div>
38+
<div class="code-snippet-group-1" first style="min-height:50px;"></div>
4239

4340
<div class="code-snippet-group-1" second
4441
codemirror-config='{"cursorHeight": ".5", "autofocus": true, "value": " Hello world"}'></div>
@@ -74,6 +71,6 @@ <h3>'philsweb.jquery-codemirror' Demo</h3>
7471
$('.code-snippet-group-1[third]').codemirror().setOptions({readOnly: true, firstLineNumber: 3});
7572

7673

77-
$('.code-snippet-group-2').codemirrorInit({value: "<div> Hello world </div>"});
74+
$('.code-snippet-group-2').codemirrorInit({value: "<div> Hello world </div>\n\n\n"});
7875
});
7976
</script>

philsweb.codemirror.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.CodeMirror {
2+
height: auto;
3+
}
4+
15
.codemirror-buttons-wrapper {
26
position: relative;
37
z-index: 9999; /* @todo Should be configured */

philsweb.jquery-codemirror.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
buttons.addClass("codemirror-buttons").append(copyToClipboardButton.addClass("codemirror-button"))
8787
));
8888

89+
buttonsWrapper.css('pointer-events', 'none');
90+
copyToClipboardButton.css('pointer-events', 'auto');
91+
8992
$(this).mouseenter(function () {
9093
$(this).children('.codemirror-buttons-wrapper').first().show();
9194
});

philsweb.jquery-codemirror.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)