Skip to content

Commit eaa8cca

Browse files
committed
Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor
1 parent ce65e58 commit eaa8cca

File tree

381 files changed

+6754
-2664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+6754
-2664
lines changed

public/js/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ var version = '0.3.3';
66
var defaultTextHeight = 20;
77
var viewportMargin = 20;
88
var defaultExtraKeys = {
9+
"F11": function(cm) {
10+
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
11+
},
12+
"Esc": function(cm) {
13+
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
14+
},
915
"Cmd-S": function () {
1016
return CodeMirror.PASS
1117
},
@@ -237,6 +243,7 @@ var editor = CodeMirror.fromTextArea(textit, {
237243
flattenSpans: true,
238244
addModeClass: true,
239245
readOnly: true,
246+
autoRefresh: true,
240247
placeholder: "← Start by enter title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)"
241248
});
242249
var inlineAttach = inlineAttachment.editors.codemirror4.attach(editor);

public/vendor/codemirror/addon/comment/comment.js

100755100644
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@
2121
}
2222

2323
CodeMirror.commands.toggleComment = function(cm) {
24-
var minLine = Infinity, ranges = cm.listSelections(), mode = null;
24+
cm.toggleComment();
25+
};
26+
27+
CodeMirror.defineExtension("toggleComment", function(options) {
28+
if (!options) options = noOptions;
29+
var cm = this;
30+
var minLine = Infinity, ranges = this.listSelections(), mode = null;
2531
for (var i = ranges.length - 1; i >= 0; i--) {
2632
var from = ranges[i].from(), to = ranges[i].to();
2733
if (from.line >= minLine) continue;
2834
if (to.line >= minLine) to = Pos(minLine, 0);
2935
minLine = from.line;
3036
if (mode == null) {
31-
if (cm.uncomment(from, to)) mode = "un";
32-
else { cm.lineComment(from, to); mode = "line"; }
37+
if (cm.uncomment(from, to, options)) mode = "un";
38+
else { cm.lineComment(from, to, options); mode = "line"; }
3339
} else if (mode == "un") {
34-
cm.uncomment(from, to);
40+
cm.uncomment(from, to, options);
3541
} else {
36-
cm.lineComment(from, to);
42+
cm.lineComment(from, to, options);
3743
}
3844
}
39-
};
45+
});
4046

4147
CodeMirror.defineExtension("lineComment", function(from, to, options) {
4248
if (!options) options = noOptions;
@@ -57,7 +63,14 @@
5763

5864
self.operation(function() {
5965
if (options.indent) {
60-
var baseString = firstLine.slice(0, firstNonWS(firstLine));
66+
var baseString = null;
67+
for (var i = from.line; i < end; ++i) {
68+
var line = self.getLine(i);
69+
var whitespace = line.slice(0, firstNonWS(line));
70+
if (baseString == null || baseString.length > whitespace.length) {
71+
baseString = whitespace;
72+
}
73+
}
6174
for (var i = from.line; i < end; ++i) {
6275
var line = self.getLine(i), cut = baseString.length;
6376
if (!blankLines && !nonWS.test(line)) continue;

public/vendor/codemirror/addon/comment/continuecomment.js

100755100644
File mode changed.

public/vendor/codemirror/addon/dialog/dialog.js

100755100644
File mode changed.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2+
// Distributed under an MIT license: http://codemirror.net/LICENSE
3+
4+
(function(mod) {
5+
if (typeof exports == "object" && typeof module == "object") // CommonJS
6+
mod(require("../../lib/codemirror"))
7+
else if (typeof define == "function" && define.amd) // AMD
8+
define(["../../lib/codemirror"], mod)
9+
else // Plain browser env
10+
mod(CodeMirror)
11+
})(function(CodeMirror) {
12+
"use strict"
13+
14+
CodeMirror.defineOption("autoRefresh", false, function(cm, val) {
15+
if (cm.state.autoRefresh) {
16+
stopListening(cm, cm.state.autoRefresh)
17+
cm.state.autoRefresh = null
18+
}
19+
if (val && cm.display.wrapper.offsetHeight == 0)
20+
startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
21+
})
22+
23+
function startListening(cm, state) {
24+
function check() {
25+
if (cm.display.wrapper.offsetHeight) {
26+
stopListening(cm, state)
27+
if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
28+
cm.refresh()
29+
} else {
30+
state.timeout = setTimeout(check, state.delay)
31+
}
32+
}
33+
state.timeout = setTimeout(check, state.delay)
34+
state.hurry = function() {
35+
clearTimeout(state.timeout)
36+
state.timeout = setTimeout(check, 50)
37+
}
38+
CodeMirror.on(window, "mouseup", state.hurry)
39+
CodeMirror.on(window, "keyup", state.hurry)
40+
}
41+
42+
function stopListening(_cm, state) {
43+
clearTimeout(state.timeout)
44+
CodeMirror.off(window, "mouseup", state.hurry)
45+
CodeMirror.off(window, "keyup", state.hurry)
46+
}
47+
});

public/vendor/codemirror/addon/display/fullscreen.css

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
position: fixed;
33
top: 0; left: 0; right: 0; bottom: 0;
44
height: auto;
5-
z-index: 9;
5+
z-index: 2000;
66
}

public/vendor/codemirror/addon/display/fullscreen.js

100755100644
File mode changed.

public/vendor/codemirror/addon/display/panel.js

100755100644
File mode changed.

public/vendor/codemirror/addon/display/placeholder.js

100755100644
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
var elt = cm.state.placeholder = document.createElement("pre");
3838
elt.style.cssText = "height: 0; overflow: visible";
3939
elt.className = "CodeMirror-placeholder";
40-
elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
40+
var placeHolder = cm.getOption("placeholder")
41+
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
42+
elt.appendChild(placeHolder)
4143
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
4244
}
4345

public/vendor/codemirror/addon/display/rulers.js

100755100644
File mode changed.

0 commit comments

Comments
 (0)