mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
codemirro 5.48.4
This commit is contained in:
parent
1f092c2656
commit
4e4beb26c6
@ -13,7 +13,8 @@
|
|||||||
.CodeMirror-lines {
|
.CodeMirror-lines {
|
||||||
padding: 4px 0; /* Vertical padding around content */
|
padding: 4px 0; /* Vertical padding around content */
|
||||||
}
|
}
|
||||||
.CodeMirror pre {
|
.CodeMirror pre.CodeMirror-line,
|
||||||
|
.CodeMirror pre.CodeMirror-line-like {
|
||||||
padding: 0 4px; /* Horizontal padding of content */
|
padding: 0 4px; /* Horizontal padding of content */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +97,7 @@
|
|||||||
|
|
||||||
.CodeMirror-rulers {
|
.CodeMirror-rulers {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0; right: 0; top: -50px; bottom: -20px;
|
left: 0; right: 0; top: -50px; bottom: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.CodeMirror-ruler {
|
.CodeMirror-ruler {
|
||||||
@ -236,7 +237,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
|||||||
cursor: text;
|
cursor: text;
|
||||||
min-height: 1px; /* prevents collapsing before first draw */
|
min-height: 1px; /* prevents collapsing before first draw */
|
||||||
}
|
}
|
||||||
.CodeMirror pre {
|
.CodeMirror pre.CodeMirror-line,
|
||||||
|
.CodeMirror pre.CodeMirror-line-like {
|
||||||
/* Reset some styles that the rest of the page might have set */
|
/* Reset some styles that the rest of the page might have set */
|
||||||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
||||||
border-width: 0;
|
border-width: 0;
|
||||||
@ -255,7 +257,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
|||||||
-webkit-font-variant-ligatures: contextual;
|
-webkit-font-variant-ligatures: contextual;
|
||||||
font-variant-ligatures: contextual;
|
font-variant-ligatures: contextual;
|
||||||
}
|
}
|
||||||
.CodeMirror-wrap pre {
|
.CodeMirror-wrap pre.CodeMirror-line,
|
||||||
|
.CodeMirror-wrap pre.CodeMirror-line-like {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
|
@ -2284,7 +2284,7 @@
|
|||||||
function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
|
function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
|
||||||
function paddingH(display) {
|
function paddingH(display) {
|
||||||
if (display.cachedPaddingH) { return display.cachedPaddingH }
|
if (display.cachedPaddingH) { return display.cachedPaddingH }
|
||||||
var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
|
var e = removeChildrenAndAdd(display.measure, elt("pre", "x", "CodeMirror-line-like"));
|
||||||
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
|
var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
|
||||||
var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
|
var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
|
||||||
if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; }
|
if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; }
|
||||||
@ -2678,7 +2678,7 @@
|
|||||||
function PosWithInfo(line, ch, sticky, outside, xRel) {
|
function PosWithInfo(line, ch, sticky, outside, xRel) {
|
||||||
var pos = Pos(line, ch, sticky);
|
var pos = Pos(line, ch, sticky);
|
||||||
pos.xRel = xRel;
|
pos.xRel = xRel;
|
||||||
if (outside) { pos.outside = true; }
|
if (outside) { pos.outside = outside; }
|
||||||
return pos
|
return pos
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2687,16 +2687,16 @@
|
|||||||
function coordsChar(cm, x, y) {
|
function coordsChar(cm, x, y) {
|
||||||
var doc = cm.doc;
|
var doc = cm.doc;
|
||||||
y += cm.display.viewOffset;
|
y += cm.display.viewOffset;
|
||||||
if (y < 0) { return PosWithInfo(doc.first, 0, null, true, -1) }
|
if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) }
|
||||||
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
|
var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
|
||||||
if (lineN > last)
|
if (lineN > last)
|
||||||
{ return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, true, 1) }
|
{ return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) }
|
||||||
if (x < 0) { x = 0; }
|
if (x < 0) { x = 0; }
|
||||||
|
|
||||||
var lineObj = getLine(doc, lineN);
|
var lineObj = getLine(doc, lineN);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
var found = coordsCharInner(cm, lineObj, lineN, x, y);
|
var found = coordsCharInner(cm, lineObj, lineN, x, y);
|
||||||
var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 ? 1 : 0));
|
var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0));
|
||||||
if (!collapsed) { return found }
|
if (!collapsed) { return found }
|
||||||
var rangeEnd = collapsed.find(1);
|
var rangeEnd = collapsed.find(1);
|
||||||
if (rangeEnd.line == lineN) { return rangeEnd }
|
if (rangeEnd.line == lineN) { return rangeEnd }
|
||||||
@ -2784,7 +2784,7 @@
|
|||||||
// base X position
|
// base X position
|
||||||
var coords = cursorCoords(cm, Pos(lineNo$$1, ch, sticky), "line", lineObj, preparedMeasure);
|
var coords = cursorCoords(cm, Pos(lineNo$$1, ch, sticky), "line", lineObj, preparedMeasure);
|
||||||
baseX = coords.left;
|
baseX = coords.left;
|
||||||
outside = y < coords.top || y >= coords.bottom;
|
outside = y < coords.top ? -1 : y >= coords.bottom ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch = skipExtendingChars(lineObj.text, ch, 1);
|
ch = skipExtendingChars(lineObj.text, ch, 1);
|
||||||
@ -2853,7 +2853,7 @@
|
|||||||
function textHeight(display) {
|
function textHeight(display) {
|
||||||
if (display.cachedTextHeight != null) { return display.cachedTextHeight }
|
if (display.cachedTextHeight != null) { return display.cachedTextHeight }
|
||||||
if (measureText == null) {
|
if (measureText == null) {
|
||||||
measureText = elt("pre");
|
measureText = elt("pre", null, "CodeMirror-line-like");
|
||||||
// Measure a bunch of lines, for browsers that compute
|
// Measure a bunch of lines, for browsers that compute
|
||||||
// fractional heights.
|
// fractional heights.
|
||||||
for (var i = 0; i < 49; ++i) {
|
for (var i = 0; i < 49; ++i) {
|
||||||
@ -2873,7 +2873,7 @@
|
|||||||
function charWidth(display) {
|
function charWidth(display) {
|
||||||
if (display.cachedCharWidth != null) { return display.cachedCharWidth }
|
if (display.cachedCharWidth != null) { return display.cachedCharWidth }
|
||||||
var anchor = elt("span", "xxxxxxxxxx");
|
var anchor = elt("span", "xxxxxxxxxx");
|
||||||
var pre = elt("pre", [anchor]);
|
var pre = elt("pre", [anchor], "CodeMirror-line-like");
|
||||||
removeChildrenAndAdd(display.measure, pre);
|
removeChildrenAndAdd(display.measure, pre);
|
||||||
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
|
var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
|
||||||
if (width > 2) { display.cachedCharWidth = width; }
|
if (width > 2) { display.cachedCharWidth = width; }
|
||||||
@ -5147,8 +5147,15 @@
|
|||||||
var line = getLine(doc, pos.line);
|
var line = getLine(doc, pos.line);
|
||||||
if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
|
if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
|
||||||
var sp = line.markedSpans[i], m = sp.marker;
|
var sp = line.markedSpans[i], m = sp.marker;
|
||||||
if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
|
|
||||||
(sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
|
// Determine if we should prevent the cursor being placed to the left/right of an atomic marker
|
||||||
|
// Historically this was determined using the inclusiveLeft/Right option, but the new way to control it
|
||||||
|
// is with selectLeft/Right
|
||||||
|
var preventCursorLeft = ("selectLeft" in m) ? !m.selectLeft : m.inclusiveLeft;
|
||||||
|
var preventCursorRight = ("selectRight" in m) ? !m.selectRight : m.inclusiveRight;
|
||||||
|
|
||||||
|
if ((sp.from == null || (preventCursorLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
|
||||||
|
(sp.to == null || (preventCursorRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
|
||||||
if (mayClear) {
|
if (mayClear) {
|
||||||
signal(m, "beforeCursorEnter");
|
signal(m, "beforeCursorEnter");
|
||||||
if (m.explicitlyCleared) {
|
if (m.explicitlyCleared) {
|
||||||
@ -5160,14 +5167,14 @@
|
|||||||
|
|
||||||
if (oldPos) {
|
if (oldPos) {
|
||||||
var near = m.find(dir < 0 ? 1 : -1), diff = (void 0);
|
var near = m.find(dir < 0 ? 1 : -1), diff = (void 0);
|
||||||
if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
|
if (dir < 0 ? preventCursorRight : preventCursorLeft)
|
||||||
{ near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); }
|
{ near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); }
|
||||||
if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
|
if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
|
||||||
{ return skipAtomicInner(doc, near, pos, dir, mayClear) }
|
{ return skipAtomicInner(doc, near, pos, dir, mayClear) }
|
||||||
}
|
}
|
||||||
|
|
||||||
var far = m.find(dir < 0 ? -1 : 1);
|
var far = m.find(dir < 0 ? -1 : 1);
|
||||||
if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
|
if (dir < 0 ? preventCursorLeft : preventCursorRight)
|
||||||
{ far = movePos(doc, far, dir, far.line == pos.line ? line : null); }
|
{ far = movePos(doc, far, dir, far.line == pos.line ? line : null); }
|
||||||
return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
|
return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
|
||||||
}
|
}
|
||||||
@ -5396,6 +5403,9 @@
|
|||||||
if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }
|
if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }
|
||||||
else { updateDoc(doc, change, spans); }
|
else { updateDoc(doc, change, spans); }
|
||||||
setSelectionNoUndo(doc, selAfter, sel_dontScroll);
|
setSelectionNoUndo(doc, selAfter, sel_dontScroll);
|
||||||
|
|
||||||
|
if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0)))
|
||||||
|
{ doc.cantEdit = false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the interaction of a change to a document with the editor
|
// Handle the interaction of a change to a document with the editor
|
||||||
@ -7700,7 +7710,7 @@
|
|||||||
for (var i = newBreaks.length - 1; i >= 0; i--)
|
for (var i = newBreaks.length - 1; i >= 0; i--)
|
||||||
{ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
|
{ replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
|
||||||
});
|
});
|
||||||
option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
|
option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) {
|
||||||
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
|
cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
|
||||||
if (old != Init) { cm.refresh(); }
|
if (old != Init) { cm.refresh(); }
|
||||||
});
|
});
|
||||||
@ -9748,7 +9758,7 @@
|
|||||||
|
|
||||||
addLegacyProps(CodeMirror);
|
addLegacyProps(CodeMirror);
|
||||||
|
|
||||||
CodeMirror.version = "5.47.0";
|
CodeMirror.version = "5.48.4";
|
||||||
|
|
||||||
return CodeMirror;
|
return CodeMirror;
|
||||||
|
|
||||||
|
28
libraries/codemirror/mode/asterisk/asterisk.js
vendored
28
libraries/codemirror/mode/asterisk/asterisk.js
vendored
@ -9,7 +9,7 @@
|
|||||||
* Description: CodeMirror mode for Asterisk dialplan
|
* Description: CodeMirror mode for Asterisk dialplan
|
||||||
*
|
*
|
||||||
* Created: 05/17/2012 09:20:25 PM
|
* Created: 05/17/2012 09:20:25 PM
|
||||||
* Revision: none
|
* Revision: 08/05/2019 AstLinux Project: Support block-comments
|
||||||
*
|
*
|
||||||
* Author: Stas Kobzar (stas@modulis.ca),
|
* Author: Stas Kobzar (stas@modulis.ca),
|
||||||
* Company: Modulis.ca Inc.
|
* Company: Modulis.ca Inc.
|
||||||
@ -67,7 +67,26 @@ CodeMirror.defineMode("asterisk", function() {
|
|||||||
var cur = '';
|
var cur = '';
|
||||||
var ch = stream.next();
|
var ch = stream.next();
|
||||||
// comment
|
// comment
|
||||||
|
if (state.blockComment) {
|
||||||
|
if (ch == "-" && stream.match("-;", true)) {
|
||||||
|
state.blockComment = false;
|
||||||
|
} else if (stream.skipTo("--;")) {
|
||||||
|
stream.next();
|
||||||
|
stream.next();
|
||||||
|
stream.next();
|
||||||
|
state.blockComment = false;
|
||||||
|
} else {
|
||||||
|
stream.skipToEnd();
|
||||||
|
}
|
||||||
|
return "comment";
|
||||||
|
}
|
||||||
if(ch == ";") {
|
if(ch == ";") {
|
||||||
|
if (stream.match("--", true)) {
|
||||||
|
if (!stream.match("-", false)) { // Except ;--- is not a block comment
|
||||||
|
state.blockComment = true;
|
||||||
|
return "comment";
|
||||||
|
}
|
||||||
|
}
|
||||||
stream.skipToEnd();
|
stream.skipToEnd();
|
||||||
return "comment";
|
return "comment";
|
||||||
}
|
}
|
||||||
@ -124,6 +143,7 @@ CodeMirror.defineMode("asterisk", function() {
|
|||||||
return {
|
return {
|
||||||
startState: function() {
|
startState: function() {
|
||||||
return {
|
return {
|
||||||
|
blockComment: false,
|
||||||
extenStart: false,
|
extenStart: false,
|
||||||
extenSame: false,
|
extenSame: false,
|
||||||
extenInclude: false,
|
extenInclude: false,
|
||||||
@ -187,7 +207,11 @@ CodeMirror.defineMode("asterisk", function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
blockCommentStart: ";--",
|
||||||
|
blockCommentEnd: "--;",
|
||||||
|
lineComment: ";"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
2
libraries/codemirror/mode/clike/clike.js
vendored
2
libraries/codemirror/mode/clike/clike.js
vendored
@ -467,7 +467,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||||||
def("text/x-java", {
|
def("text/x-java", {
|
||||||
name: "clike",
|
name: "clike",
|
||||||
keywords: words("abstract assert break case catch class const continue default " +
|
keywords: words("abstract assert break case catch class const continue default " +
|
||||||
"do else enum extends final finally float for goto if implements import " +
|
"do else enum extends final finally for goto if implements import " +
|
||||||
"instanceof interface native new package private protected public " +
|
"instanceof interface native new package private protected public " +
|
||||||
"return static strictfp super switch synchronized this throw throws transient " +
|
"return static strictfp super switch synchronized this throw throws transient " +
|
||||||
"try volatile while @interface"),
|
"try volatile while @interface"),
|
||||||
|
26
libraries/codemirror/mode/clike/test.js
vendored
26
libraries/codemirror/mode/clike/test.js
vendored
@ -136,4 +136,30 @@
|
|||||||
"[comment ///// let / me / show / you /////]",
|
"[comment ///// let / me / show / you /////]",
|
||||||
"[comment */]");
|
"[comment */]");
|
||||||
|
|
||||||
|
var mode_java = CodeMirror.getMode({indentUnit: 2}, "text/x-java");
|
||||||
|
function MTJAVA(name) { test.mode("java_" + name, mode_java, Array.prototype.slice.call(arguments, 1)); }
|
||||||
|
MTJAVA("types",
|
||||||
|
"[type byte];",
|
||||||
|
"[type short];",
|
||||||
|
"[type int];",
|
||||||
|
"[type long];",
|
||||||
|
"[type float];",
|
||||||
|
"[type double];",
|
||||||
|
"[type boolean];",
|
||||||
|
"[type char];",
|
||||||
|
"[type void];",
|
||||||
|
"[type Boolean];",
|
||||||
|
"[type Byte];",
|
||||||
|
"[type Character];",
|
||||||
|
"[type Double];",
|
||||||
|
"[type Float];",
|
||||||
|
"[type Integer];",
|
||||||
|
"[type Long];",
|
||||||
|
"[type Number];",
|
||||||
|
"[type Object];",
|
||||||
|
"[type Short];",
|
||||||
|
"[type String];",
|
||||||
|
"[type StringBuffer];",
|
||||||
|
"[type StringBuilder];",
|
||||||
|
"[type Void];");
|
||||||
})();
|
})();
|
||||||
|
9
libraries/codemirror/mode/dart/dart.js
vendored
9
libraries/codemirror/mode/dart/dart.js
vendored
@ -78,6 +78,15 @@
|
|||||||
if (!stream.eat("*")) return false
|
if (!stream.eat("*")) return false
|
||||||
state.tokenize = tokenNestedComment(1)
|
state.tokenize = tokenNestedComment(1)
|
||||||
return state.tokenize(stream, state)
|
return state.tokenize(stream, state)
|
||||||
|
},
|
||||||
|
token: function(stream, _, style) {
|
||||||
|
if (style == "variable") {
|
||||||
|
// Assume uppercase symbols are classes using variable-2
|
||||||
|
var isUpper = RegExp('^[_$]*[A-Z][a-zA-Z0-9_$]*$','g');
|
||||||
|
if (isUpper.test(stream.current())) {
|
||||||
|
return 'variable-2';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
5
libraries/codemirror/mode/groovy/groovy.js
vendored
5
libraries/codemirror/mode/groovy/groovy.js
vendored
@ -221,7 +221,10 @@ CodeMirror.defineMode("groovy", function(config) {
|
|||||||
|
|
||||||
electricChars: "{}",
|
electricChars: "{}",
|
||||||
closeBrackets: {triples: "'\""},
|
closeBrackets: {triples: "'\""},
|
||||||
fold: "brace"
|
fold: "brace",
|
||||||
|
blockCommentStart: "/*",
|
||||||
|
blockCommentEnd: "*/",
|
||||||
|
lineComment: "//"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -13,10 +13,14 @@
|
|||||||
|
|
||||||
CodeMirror.defineSimpleMode("handlebars-tags", {
|
CodeMirror.defineSimpleMode("handlebars-tags", {
|
||||||
start: [
|
start: [
|
||||||
|
{ regex: /\{\{\{/, push: "handlebars_raw", token: "tag" },
|
||||||
{ regex: /\{\{!--/, push: "dash_comment", token: "comment" },
|
{ regex: /\{\{!--/, push: "dash_comment", token: "comment" },
|
||||||
{ regex: /\{\{!/, push: "comment", token: "comment" },
|
{ regex: /\{\{!/, push: "comment", token: "comment" },
|
||||||
{ regex: /\{\{/, push: "handlebars", token: "tag" }
|
{ regex: /\{\{/, push: "handlebars", token: "tag" }
|
||||||
],
|
],
|
||||||
|
handlebars_raw: [
|
||||||
|
{ regex: /\}\}\}/, pop: true, token: "tag" },
|
||||||
|
],
|
||||||
handlebars: [
|
handlebars: [
|
||||||
{ regex: /\}\}/, pop: true, token: "tag" },
|
{ regex: /\}\}/, pop: true, token: "tag" },
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
{{! one line comment }}
|
{{! one line comment }}
|
||||||
|
|
||||||
|
{{{propertyContainingRawHtml}}}
|
||||||
|
|
||||||
{{#each articles}}
|
{{#each articles}}
|
||||||
{{~title}}
|
{{~title}}
|
||||||
<p>{{excerpt body size=120 ellipsis=true}}</p>
|
<p>{{excerpt body size=120 ellipsis=true}}</p>
|
||||||
|
@ -67,7 +67,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||||||
if (ch == '"' || ch == "'") {
|
if (ch == '"' || ch == "'") {
|
||||||
state.tokenize = tokenString(ch);
|
state.tokenize = tokenString(ch);
|
||||||
return state.tokenize(stream, state);
|
return state.tokenize(stream, state);
|
||||||
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
|
} else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
|
||||||
return ret("number", "number");
|
return ret("number", "number");
|
||||||
} else if (ch == "." && stream.match("..")) {
|
} else if (ch == "." && stream.match("..")) {
|
||||||
return ret("spread", "meta");
|
return ret("spread", "meta");
|
||||||
@ -75,10 +75,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||||||
return ret(ch);
|
return ret(ch);
|
||||||
} else if (ch == "=" && stream.eat(">")) {
|
} else if (ch == "=" && stream.eat(">")) {
|
||||||
return ret("=>", "operator");
|
return ret("=>", "operator");
|
||||||
} else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) {
|
} else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
|
||||||
return ret("number", "number");
|
return ret("number", "number");
|
||||||
} else if (/\d/.test(ch)) {
|
} else if (/\d/.test(ch)) {
|
||||||
stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/);
|
stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
|
||||||
return ret("number", "number");
|
return ret("number", "number");
|
||||||
} else if (ch == "/") {
|
} else if (ch == "/") {
|
||||||
if (stream.eat("*")) {
|
if (stream.eat("*")) {
|
||||||
@ -195,8 +195,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||||||
++depth;
|
++depth;
|
||||||
} else if (wordRE.test(ch)) {
|
} else if (wordRE.test(ch)) {
|
||||||
sawSomething = true;
|
sawSomething = true;
|
||||||
} else if (/["'\/]/.test(ch)) {
|
} else if (/["'\/`]/.test(ch)) {
|
||||||
return;
|
for (;; --pos) {
|
||||||
|
if (pos == 0) return
|
||||||
|
var next = stream.string.charAt(pos - 1)
|
||||||
|
if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break }
|
||||||
|
}
|
||||||
} else if (sawSomething && !depth) {
|
} else if (sawSomething && !depth) {
|
||||||
++pos;
|
++pos;
|
||||||
break;
|
break;
|
||||||
@ -574,10 +578,13 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||||||
}
|
}
|
||||||
function maybetype(type, value) {
|
function maybetype(type, value) {
|
||||||
if (isTS) {
|
if (isTS) {
|
||||||
if (type == ":" || value == "in") return cont(typeexpr);
|
if (type == ":") return cont(typeexpr);
|
||||||
if (value == "?") return cont(maybetype);
|
if (value == "?") return cont(maybetype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function maybetypeOrIn(type, value) {
|
||||||
|
if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
|
||||||
|
}
|
||||||
function mayberettype(type) {
|
function mayberettype(type) {
|
||||||
if (isTS && type == ":") {
|
if (isTS && type == ":") {
|
||||||
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
|
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
|
||||||
@ -618,7 +625,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||||||
} else if (type == ":") {
|
} else if (type == ":") {
|
||||||
return cont(typeexpr)
|
return cont(typeexpr)
|
||||||
} else if (type == "[") {
|
} else if (type == "[") {
|
||||||
return cont(expect("variable"), maybetype, expect("]"), typeprop)
|
return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
|
||||||
} else if (type == "(") {
|
} else if (type == "(") {
|
||||||
return pass(functiondecl, typeprop)
|
return pass(functiondecl, typeprop)
|
||||||
}
|
}
|
||||||
|
19
libraries/codemirror/mode/javascript/test.js
vendored
19
libraries/codemirror/mode/javascript/test.js
vendored
@ -127,6 +127,9 @@
|
|||||||
"[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
|
"[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
|
||||||
"[variable c];");
|
"[variable c];");
|
||||||
|
|
||||||
|
MT("fatArrow_stringDefault",
|
||||||
|
"([def a], [def b] [operator =] [string 'x\\'y']) [operator =>] [variable-2 a] [operator +] [variable-2 b]")
|
||||||
|
|
||||||
MT("spread",
|
MT("spread",
|
||||||
"[keyword function] [def f]([def a], [meta ...][def b]) {",
|
"[keyword function] [def f]([def a], [meta ...][def b]) {",
|
||||||
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
|
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
|
||||||
@ -298,6 +301,22 @@
|
|||||||
"[keyword return]",
|
"[keyword return]",
|
||||||
"{} [string-2 /5/]")
|
"{} [string-2 /5/]")
|
||||||
|
|
||||||
|
MT("numeric separator",
|
||||||
|
"[number 123_456];",
|
||||||
|
"[number 0xdead_c0de];",
|
||||||
|
"[number 0o123_456];",
|
||||||
|
"[number 0b1101_1101];",
|
||||||
|
"[number .123_456e0_1];",
|
||||||
|
"[number 1E+123_456];",
|
||||||
|
"[number 12_34_56n];")
|
||||||
|
|
||||||
|
MT("underscore property",
|
||||||
|
"[variable something].[property _property];",
|
||||||
|
"[variable something].[property _123];",
|
||||||
|
"[variable something].[property _for];",
|
||||||
|
"[variable _for];",
|
||||||
|
"[variable _123];")
|
||||||
|
|
||||||
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
|
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
|
||||||
function TS(name) {
|
function TS(name) {
|
||||||
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
|
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
|
||||||
|
14
libraries/codemirror/mode/julia/julia.js
vendored
14
libraries/codemirror/mode/julia/julia.js
vendored
@ -187,15 +187,13 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
|
|||||||
var imMatcher = RegExp(/^im\b/);
|
var imMatcher = RegExp(/^im\b/);
|
||||||
var numberLiteral = false;
|
var numberLiteral = false;
|
||||||
// Floats
|
// Floats
|
||||||
if (stream.match(/^\d*\.(?!\.)\d*([Eef][\+\-]?\d+)?/i)) { numberLiteral = true; }
|
if (stream.match(/^(?:(?:\d[_\d]*)?\.(?!\.)(?:\d[_\d]*)?|\d[_\d]*\.(?!\.)(?:\d[_\d]*))?([Eef][\+\-]?[_\d]+)?/i)) { numberLiteral = true; }
|
||||||
if (stream.match(/^\d+\.(?!\.)\d*/)) { numberLiteral = true; }
|
if (stream.match(/^0x\.[0-9a-f_]+p[\+\-]?[_\d]+/i)) { numberLiteral = true; }
|
||||||
if (stream.match(/^\.\d+/)) { numberLiteral = true; }
|
|
||||||
if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { numberLiteral = true; }
|
|
||||||
// Integers
|
// Integers
|
||||||
if (stream.match(/^0x[0-9a-f]+/i)) { numberLiteral = true; } // Hex
|
if (stream.match(/^0x[0-9a-f_]+/i)) { numberLiteral = true; } // Hex
|
||||||
if (stream.match(/^0b[01]+/i)) { numberLiteral = true; } // Binary
|
if (stream.match(/^0b[01_]+/i)) { numberLiteral = true; } // Binary
|
||||||
if (stream.match(/^0o[0-7]+/i)) { numberLiteral = true; } // Octal
|
if (stream.match(/^0o[0-7_]+/i)) { numberLiteral = true; } // Octal
|
||||||
if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal
|
if (stream.match(/^[1-9][_\d]*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal
|
||||||
// Zero by itself with no other piece of number.
|
// Zero by itself with no other piece of number.
|
||||||
if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; }
|
if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; }
|
||||||
if (numberLiteral) {
|
if (numberLiteral) {
|
||||||
|
5
libraries/codemirror/mode/meta.js
vendored
5
libraries/codemirror/mode/meta.js
vendored
@ -20,7 +20,7 @@
|
|||||||
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]},
|
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]},
|
||||||
{name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
|
{name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
|
||||||
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
|
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
|
||||||
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
|
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp", "cs"]},
|
||||||
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
|
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
|
||||||
{name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
|
{name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
|
||||||
{name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
|
{name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
|
||||||
@ -70,7 +70,7 @@
|
|||||||
{name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
|
{name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
|
||||||
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
|
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
|
||||||
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
|
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
|
||||||
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript", "application/javascript;env=frontend", "application/javascript;env=backend"],
|
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
|
||||||
mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
|
mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
|
||||||
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
|
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
|
||||||
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
|
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
|
||||||
@ -105,6 +105,7 @@
|
|||||||
{name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
|
{name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
|
||||||
{name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
|
{name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
|
||||||
{name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
|
{name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
|
||||||
|
{name: "PostgreSQL", mime: "text/x-pgsql", mode: "sql"},
|
||||||
{name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
|
{name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
|
||||||
{name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
|
{name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
|
||||||
{name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
|
{name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
|
||||||
|
2
libraries/codemirror/mode/soy/soy.js
vendored
2
libraries/codemirror/mode/soy/soy.js
vendored
@ -26,6 +26,8 @@
|
|||||||
"literal": { },
|
"literal": { },
|
||||||
"msg": {},
|
"msg": {},
|
||||||
"fallbackmsg": { noEndTag: true, reduceIndent: true},
|
"fallbackmsg": { noEndTag: true, reduceIndent: true},
|
||||||
|
"select": {},
|
||||||
|
"plural": {},
|
||||||
"let": { soyState: "var-def" },
|
"let": { soyState: "var-def" },
|
||||||
"if": {},
|
"if": {},
|
||||||
"elseif": { noEndTag: true, reduceIndent: true},
|
"elseif": { noEndTag: true, reduceIndent: true},
|
||||||
|
2
libraries/codemirror/mode/sparql/sparql.js
vendored
2
libraries/codemirror/mode/sparql/sparql.js
vendored
@ -41,7 +41,7 @@ CodeMirror.defineMode("sparql", function(config) {
|
|||||||
if(ch == "?" && stream.match(/\s/, false)){
|
if(ch == "?" && stream.match(/\s/, false)){
|
||||||
return "operator";
|
return "operator";
|
||||||
}
|
}
|
||||||
stream.match(/^[\w\d]*/);
|
stream.match(/^[A-Za-z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][A-Za-z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]*/);
|
||||||
return "variable-2";
|
return "variable-2";
|
||||||
}
|
}
|
||||||
else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) {
|
else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) {
|
||||||
|
@ -24,11 +24,10 @@ class StandardWidget {
|
|||||||
*/
|
*/
|
||||||
constructor(ctx, options, state) {
|
constructor(ctx, options, state) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.options = options;
|
|
||||||
this.state = state;
|
this.state = state;
|
||||||
// construct in camelCase
|
// construct in camelCase
|
||||||
this.widgetName = this.constructor.name.substr(0, 1).toLowerCase() + this.constructor.name.substr(1);
|
this.widgetName = this.constructor.name.substr(0, 1).toLowerCase() + this.constructor.name.substr(1);
|
||||||
|
this.widgetOptions = options.getJson(this.widgetName) || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
getWidgetTitle() { return "Untitled widget"; }
|
getWidgetTitle() { return "Untitled widget"; }
|
||||||
@ -46,7 +45,7 @@ class StandardWidget {
|
|||||||
this.$bodyWrapper = this.$widget.find('.body-wrapper');
|
this.$bodyWrapper = this.$widget.find('.body-wrapper');
|
||||||
this.$bodyWrapper.attr('id', widgetId);
|
this.$bodyWrapper.attr('id', widgetId);
|
||||||
|
|
||||||
if (this.state && this.state.expanded) {
|
if ((this.state && this.state.expanded) || (!this.state && this.widgetOptions.expanded)) {
|
||||||
this.$bodyWrapper.collapse("show");
|
this.$bodyWrapper.collapse("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,9 +85,7 @@ class StandardWidget {
|
|||||||
async doRenderBody() {}
|
async doRenderBody() {}
|
||||||
|
|
||||||
async isEnabled() {
|
async isEnabled() {
|
||||||
const option = this.options.getJson(this.widgetName + 'Widget');
|
return this.widgetOptions.enabled;
|
||||||
|
|
||||||
return option ? option.enabled : true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isExpanded() {
|
isExpanded() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user