diff --git a/libraries/codemirror/codemirror.css b/libraries/codemirror/codemirror.css index cdb74f6a5..ca6a0841b 100644 --- a/libraries/codemirror/codemirror.css +++ b/libraries/codemirror/codemirror.css @@ -13,7 +13,8 @@ .CodeMirror-lines { 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 */ } @@ -96,7 +97,7 @@ .CodeMirror-rulers { position: absolute; - left: 0; right: 0; top: -50px; bottom: -20px; + left: 0; right: 0; top: -50px; bottom: 0; overflow: hidden; } .CodeMirror-ruler { @@ -236,7 +237,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} cursor: text; 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 */ -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; border-width: 0; @@ -255,7 +257,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} -webkit-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; white-space: pre-wrap; word-break: normal; diff --git a/libraries/codemirror/codemirror.js b/libraries/codemirror/codemirror.js index 9ab04c682..076a0b89e 100644 --- a/libraries/codemirror/codemirror.js +++ b/libraries/codemirror/codemirror.js @@ -2284,7 +2284,7 @@ function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight} function paddingH(display) { 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 data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}; if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; } @@ -2678,7 +2678,7 @@ function PosWithInfo(line, ch, sticky, outside, xRel) { var pos = Pos(line, ch, sticky); pos.xRel = xRel; - if (outside) { pos.outside = true; } + if (outside) { pos.outside = outside; } return pos } @@ -2687,16 +2687,16 @@ function coordsChar(cm, x, y) { var doc = cm.doc; 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; 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; } var lineObj = getLine(doc, lineN); for (;;) { 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 } var rangeEnd = collapsed.find(1); if (rangeEnd.line == lineN) { return rangeEnd } @@ -2784,7 +2784,7 @@ // base X position var coords = cursorCoords(cm, Pos(lineNo$$1, ch, sticky), "line", lineObj, preparedMeasure); 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); @@ -2853,7 +2853,7 @@ function textHeight(display) { if (display.cachedTextHeight != null) { return display.cachedTextHeight } if (measureText == null) { - measureText = elt("pre"); + measureText = elt("pre", null, "CodeMirror-line-like"); // Measure a bunch of lines, for browsers that compute // fractional heights. for (var i = 0; i < 49; ++i) { @@ -2873,7 +2873,7 @@ function charWidth(display) { if (display.cachedCharWidth != null) { return display.cachedCharWidth } var anchor = elt("span", "xxxxxxxxxx"); - var pre = elt("pre", [anchor]); + var pre = elt("pre", [anchor], "CodeMirror-line-like"); removeChildrenAndAdd(display.measure, pre); var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; if (width > 2) { display.cachedCharWidth = width; } @@ -5147,8 +5147,15 @@ var line = getLine(doc, pos.line); if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) { 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) { signal(m, "beforeCursorEnter"); if (m.explicitlyCleared) { @@ -5160,14 +5167,14 @@ if (oldPos) { 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); } if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0)) { return skipAtomicInner(doc, near, pos, dir, mayClear) } } 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); } return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null } @@ -5396,6 +5403,9 @@ if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); } else { updateDoc(doc, change, spans); } 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 @@ -7700,7 +7710,7 @@ for (var i = newBreaks.length - 1; i >= 0; i--) { 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"); if (old != Init) { cm.refresh(); } }); @@ -9748,7 +9758,7 @@ addLegacyProps(CodeMirror); - CodeMirror.version = "5.47.0"; + CodeMirror.version = "5.48.4"; return CodeMirror; diff --git a/libraries/codemirror/mode/asterisk/asterisk.js b/libraries/codemirror/mode/asterisk/asterisk.js index 025a8b3ef..49a727019 100644 --- a/libraries/codemirror/mode/asterisk/asterisk.js +++ b/libraries/codemirror/mode/asterisk/asterisk.js @@ -9,7 +9,7 @@ * Description: CodeMirror mode for Asterisk dialplan * * 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), * Company: Modulis.ca Inc. @@ -67,7 +67,26 @@ CodeMirror.defineMode("asterisk", function() { var cur = ''; var ch = stream.next(); // 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 (stream.match("--", true)) { + if (!stream.match("-", false)) { // Except ;--- is not a block comment + state.blockComment = true; + return "comment"; + } + } stream.skipToEnd(); return "comment"; } @@ -124,6 +143,7 @@ CodeMirror.defineMode("asterisk", function() { return { startState: function() { return { + blockComment: false, extenStart: false, extenSame: false, extenInclude: false, @@ -187,7 +207,11 @@ CodeMirror.defineMode("asterisk", function() { } return null; - } + }, + + blockCommentStart: ";--", + blockCommentEnd: "--;", + lineComment: ";" }; }); diff --git a/libraries/codemirror/mode/clike/clike.js b/libraries/codemirror/mode/clike/clike.js index 1af35d7b0..4c8b9937d 100644 --- a/libraries/codemirror/mode/clike/clike.js +++ b/libraries/codemirror/mode/clike/clike.js @@ -467,7 +467,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { def("text/x-java", { name: "clike", 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 " + "return static strictfp super switch synchronized this throw throws transient " + "try volatile while @interface"), diff --git a/libraries/codemirror/mode/clike/test.js b/libraries/codemirror/mode/clike/test.js index 6cb7605ef..9441b9595 100644 --- a/libraries/codemirror/mode/clike/test.js +++ b/libraries/codemirror/mode/clike/test.js @@ -136,4 +136,30 @@ "[comment ///// let / me / show / you /////]", "[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];"); })(); diff --git a/libraries/codemirror/mode/dart/dart.js b/libraries/codemirror/mode/dart/dart.js index 0a66bf168..7b154c65c 100644 --- a/libraries/codemirror/mode/dart/dart.js +++ b/libraries/codemirror/mode/dart/dart.js @@ -78,6 +78,15 @@ if (!stream.eat("*")) return false state.tokenize = tokenNestedComment(1) 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'; + } + } } } }); diff --git a/libraries/codemirror/mode/groovy/groovy.js b/libraries/codemirror/mode/groovy/groovy.js index b76a03fa1..2b90d01c4 100644 --- a/libraries/codemirror/mode/groovy/groovy.js +++ b/libraries/codemirror/mode/groovy/groovy.js @@ -221,7 +221,10 @@ CodeMirror.defineMode("groovy", function(config) { electricChars: "{}", closeBrackets: {triples: "'\""}, - fold: "brace" + fold: "brace", + blockCommentStart: "/*", + blockCommentEnd: "*/", + lineComment: "//" }; }); diff --git a/libraries/codemirror/mode/handlebars/handlebars.js b/libraries/codemirror/mode/handlebars/handlebars.js index 93865b7a0..fe8b3b44e 100644 --- a/libraries/codemirror/mode/handlebars/handlebars.js +++ b/libraries/codemirror/mode/handlebars/handlebars.js @@ -13,10 +13,14 @@ CodeMirror.defineSimpleMode("handlebars-tags", { start: [ + { regex: /\{\{\{/, push: "handlebars_raw", token: "tag" }, { regex: /\{\{!--/, push: "dash_comment", token: "comment" }, { regex: /\{\{!/, push: "comment", token: "comment" }, { regex: /\{\{/, push: "handlebars", token: "tag" } ], + handlebars_raw: [ + { regex: /\}\}\}/, pop: true, token: "tag" }, + ], handlebars: [ { regex: /\}\}/, pop: true, token: "tag" }, diff --git a/libraries/codemirror/mode/handlebars/index.html b/libraries/codemirror/mode/handlebars/index.html index 13cfcf35a..e2da2e766 100644 --- a/libraries/codemirror/mode/handlebars/index.html +++ b/libraries/codemirror/mode/handlebars/index.html @@ -41,6 +41,8 @@ {{! one line comment }} +{{{propertyContainingRawHtml}}} + {{#each articles}} {{~title}}
{{excerpt body size=120 ellipsis=true}}
diff --git a/libraries/codemirror/mode/javascript/javascript.js b/libraries/codemirror/mode/javascript/javascript.js index 0f8366471..8055f1ba2 100644 --- a/libraries/codemirror/mode/javascript/javascript.js +++ b/libraries/codemirror/mode/javascript/javascript.js @@ -67,7 +67,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { if (ch == '"' || ch == "'") { state.tokenize = tokenString(ch); 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"); } else if (ch == "." && stream.match("..")) { return ret("spread", "meta"); @@ -75,10 +75,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return ret(ch); } else if (ch == "=" && stream.eat(">")) { 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"); } else if (/\d/.test(ch)) { - stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/); + stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/); return ret("number", "number"); } else if (ch == "/") { if (stream.eat("*")) { @@ -195,8 +195,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { ++depth; } else if (wordRE.test(ch)) { sawSomething = true; - } else if (/["'\/]/.test(ch)) { - return; + } else if (/["'\/`]/.test(ch)) { + 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) { ++pos; break; @@ -574,10 +578,13 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function maybetype(type, value) { if (isTS) { - if (type == ":" || value == "in") return cont(typeexpr); + if (type == ":") return cont(typeexpr); if (value == "?") return cont(maybetype); } } + function maybetypeOrIn(type, value) { + if (isTS && (type == ":" || value == "in")) return cont(typeexpr) + } function mayberettype(type) { if (isTS && type == ":") { 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 == ":") { return cont(typeexpr) } else if (type == "[") { - return cont(expect("variable"), maybetype, expect("]"), typeprop) + return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) } else if (type == "(") { return pass(functiondecl, typeprop) } diff --git a/libraries/codemirror/mode/javascript/test.js b/libraries/codemirror/mode/javascript/test.js index 04faeafa3..327eac76b 100644 --- a/libraries/codemirror/mode/javascript/test.js +++ b/libraries/codemirror/mode/javascript/test.js @@ -127,6 +127,9 @@ "[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];", "[variable c];"); + MT("fatArrow_stringDefault", + "([def a], [def b] [operator =] [string 'x\\'y']) [operator =>] [variable-2 a] [operator +] [variable-2 b]") + MT("spread", "[keyword function] [def f]([def a], [meta ...][def b]) {", " [variable something]([variable-2 a], [meta ...][variable-2 b]);", @@ -298,6 +301,22 @@ "[keyword return]", "{} [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") function TS(name) { test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1)) diff --git a/libraries/codemirror/mode/julia/julia.js b/libraries/codemirror/mode/julia/julia.js index 5873d8ca9..547669afb 100644 --- a/libraries/codemirror/mode/julia/julia.js +++ b/libraries/codemirror/mode/julia/julia.js @@ -187,15 +187,13 @@ CodeMirror.defineMode("julia", function(config, parserConf) { var imMatcher = RegExp(/^im\b/); var numberLiteral = false; // Floats - if (stream.match(/^\d*\.(?!\.)\d*([Eef][\+\-]?\d+)?/i)) { numberLiteral = true; } - if (stream.match(/^\d+\.(?!\.)\d*/)) { numberLiteral = true; } - if (stream.match(/^\.\d+/)) { numberLiteral = true; } - if (stream.match(/^0x\.[0-9a-f]+p[\+\-]?\d+/i)) { numberLiteral = true; } + if (stream.match(/^(?:(?:\d[_\d]*)?\.(?!\.)(?:\d[_\d]*)?|\d[_\d]*\.(?!\.)(?:\d[_\d]*))?([Eef][\+\-]?[_\d]+)?/i)) { numberLiteral = true; } + if (stream.match(/^0x\.[0-9a-f_]+p[\+\-]?[_\d]+/i)) { numberLiteral = true; } // Integers - if (stream.match(/^0x[0-9a-f]+/i)) { numberLiteral = true; } // Hex - if (stream.match(/^0b[01]+/i)) { numberLiteral = true; } // Binary - if (stream.match(/^0o[0-7]+/i)) { numberLiteral = true; } // Octal - if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal + if (stream.match(/^0x[0-9a-f_]+/i)) { numberLiteral = true; } // Hex + if (stream.match(/^0b[01_]+/i)) { numberLiteral = true; } // Binary + if (stream.match(/^0o[0-7_]+/i)) { numberLiteral = true; } // Octal + if (stream.match(/^[1-9][_\d]*(e[\+\-]?\d+)?/)) { numberLiteral = true; } // Decimal // Zero by itself with no other piece of number. if (stream.match(/^0(?![\dx])/i)) { numberLiteral = true; } if (numberLiteral) { diff --git a/libraries/codemirror/mode/meta.js b/libraries/codemirror/mode/meta.js index aa2b73cbe..95d473100 100644 --- a/libraries/codemirror/mode/meta.js +++ b/libraries/codemirror/mode/meta.js @@ -20,7 +20,7 @@ {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: "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: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]}, {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: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]}, {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"]}, {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"]}, @@ -105,6 +105,7 @@ {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: "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: "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"]}, diff --git a/libraries/codemirror/mode/soy/soy.js b/libraries/codemirror/mode/soy/soy.js index b42d0da10..c33a69cec 100644 --- a/libraries/codemirror/mode/soy/soy.js +++ b/libraries/codemirror/mode/soy/soy.js @@ -26,6 +26,8 @@ "literal": { }, "msg": {}, "fallbackmsg": { noEndTag: true, reduceIndent: true}, + "select": {}, + "plural": {}, "let": { soyState: "var-def" }, "if": {}, "elseif": { noEndTag: true, reduceIndent: true}, diff --git a/libraries/codemirror/mode/sparql/sparql.js b/libraries/codemirror/mode/sparql/sparql.js index f246776b1..bb79abff7 100644 --- a/libraries/codemirror/mode/sparql/sparql.js +++ b/libraries/codemirror/mode/sparql/sparql.js @@ -41,7 +41,7 @@ CodeMirror.defineMode("sparql", function(config) { if(ch == "?" && stream.match(/\s/, false)){ 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"; } else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) { diff --git a/src/public/javascripts/widgets/standard_widget.js b/src/public/javascripts/widgets/standard_widget.js index c14f207a8..98452d404 100644 --- a/src/public/javascripts/widgets/standard_widget.js +++ b/src/public/javascripts/widgets/standard_widget.js @@ -24,11 +24,10 @@ class StandardWidget { */ constructor(ctx, options, state) { this.ctx = ctx; - this.options = options; this.state = state; // construct in camelCase this.widgetName = this.constructor.name.substr(0, 1).toLowerCase() + this.constructor.name.substr(1); - + this.widgetOptions = options.getJson(this.widgetName) || {}; } getWidgetTitle() { return "Untitled widget"; } @@ -46,7 +45,7 @@ class StandardWidget { this.$bodyWrapper = this.$widget.find('.body-wrapper'); 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"); } @@ -86,9 +85,7 @@ class StandardWidget { async doRenderBody() {} async isEnabled() { - const option = this.options.getJson(this.widgetName + 'Widget'); - - return option ? option.enabled : true; + return this.widgetOptions.enabled; } isExpanded() {