mirror of
https://github.com/documize/community.git
synced 2025-07-23 23:29:42 +02:00
CodeMirror dependency upgraded to v5.32.0
For handling Markdown and Code section types
This commit is contained in:
parent
3337db6b27
commit
0336f84a83
351 changed files with 3408 additions and 1945 deletions
26
gui/public/codemirror/addon/runmode/runmode.node.js
vendored
Executable file → Normal file
26
gui/public/codemirror/addon/runmode/runmode.node.js
vendored
Executable file → Normal file
|
@ -7,7 +7,7 @@ function splitLines(string){return string.split(/\r\n?|\n/);};
|
|||
|
||||
// Counts the column offset in a string, taking tabs into account.
|
||||
// Used mostly to find indentation.
|
||||
var countColumn = function(string, end, tabSize, startIndex, startValue) {
|
||||
var countColumn = exports.countColumn = function(string, end, tabSize, startIndex, startValue) {
|
||||
if (end == null) {
|
||||
end = string.search(/[^\s\u00a0]/);
|
||||
if (end == -1) end = string.length;
|
||||
|
@ -22,12 +22,13 @@ var countColumn = function(string, end, tabSize, startIndex, startValue) {
|
|||
}
|
||||
};
|
||||
|
||||
function StringStream(string, tabSize) {
|
||||
function StringStream(string, tabSize, context) {
|
||||
this.pos = this.start = 0;
|
||||
this.string = string;
|
||||
this.tabSize = tabSize || 8;
|
||||
this.lastColumnPos = this.lastColumnValue = 0;
|
||||
this.lineStart = 0;
|
||||
this.context = context
|
||||
};
|
||||
|
||||
StringStream.prototype = {
|
||||
|
@ -91,6 +92,10 @@ StringStream.prototype = {
|
|||
this.lineStart += n;
|
||||
try { return inner(); }
|
||||
finally { this.lineStart -= n; }
|
||||
},
|
||||
lookAhead: function(n) {
|
||||
var line = this.context.line + n
|
||||
return line >= this.context.lines.length ? null : this.context.lines[line]
|
||||
}
|
||||
};
|
||||
exports.StringStream = StringStream;
|
||||
|
@ -158,14 +163,27 @@ exports.getMode = function(options, spec) {
|
|||
|
||||
return modeObj;
|
||||
};
|
||||
|
||||
exports.innerMode = function(mode, state) {
|
||||
var info;
|
||||
while (mode.innerMode) {
|
||||
info = mode.innerMode(state);
|
||||
if (!info || info.mode == mode) break;
|
||||
state = info.state;
|
||||
mode = info.mode;
|
||||
}
|
||||
return info || {mode: mode, state: state};
|
||||
}
|
||||
|
||||
exports.registerHelper = exports.registerGlobalHelper = Math.min;
|
||||
|
||||
exports.runMode = function(string, modespec, callback, options) {
|
||||
var mode = exports.getMode({indentUnit: 2}, modespec);
|
||||
var lines = splitLines(string), state = (options && options.state) || exports.startState(mode);
|
||||
for (var i = 0, e = lines.length; i < e; ++i) {
|
||||
var context = {lines: lines, line: 0}
|
||||
for (var i = 0, e = lines.length; i < e; ++i, ++context.line) {
|
||||
if (i) callback("\n");
|
||||
var stream = new exports.StringStream(lines[i]);
|
||||
var stream = new exports.StringStream(lines[i], 4, context);
|
||||
if (!stream.string && mode.blankLine) mode.blankLine(state);
|
||||
while (!stream.eol()) {
|
||||
var style = mode.token(stream, state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue