update codemirror plugin files

This commit is contained in:
REJack 2020-11-25 09:00:43 +01:00
parent 4bbf746378
commit a2df402653
18 changed files with 148 additions and 72 deletions

View file

@ -15,7 +15,7 @@
cm.on("blur", onBlur);
cm.on("change", onChange);
cm.on("swapDoc", onChange);
CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = () => onComposition(cm))
CodeMirror.on(cm.getInputField(), "compositionupdate", cm.state.placeholderCompose = function() { onComposition(cm) })
onChange(cm);
} else if (!val && prev) {
cm.off("blur", onBlur);
@ -49,13 +49,16 @@
}
function onComposition(cm) {
var empty = true, input = cm.getInputField()
if (input.nodeName == "TEXTAREA")
empty = !input.value
else if (cm.lineCount() == 1)
empty = !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent)
if (empty) clearPlaceholder(cm)
else setPlaceholder(cm)
setTimeout(function() {
var empty = false
if (cm.lineCount() == 1) {
var input = cm.getInputField()
empty = input.nodeName == "TEXTAREA" ? !cm.getLine(0).length
: !/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent)
}
if (empty) setPlaceholder(cm)
else clearPlaceholder(cm)
}, 20)
}
function onBlur(cm) {

View file

@ -128,9 +128,10 @@
replacement = head + "style";
} else {
var context = inner.mode.xmlCurrentContext && inner.mode.xmlCurrentContext(state)
if (!context || (context.length && closingTagExists(cm, context, context[context.length - 1], pos)))
var top = context.length ? context[context.length - 1] : ""
if (!context || (context.length && closingTagExists(cm, context, top, pos)))
return CodeMirror.Pass;
replacement = head + context[context.length - 1]
replacement = head + top
}
if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
replacements[i] = replacement;

View file

@ -98,6 +98,7 @@
dfn: s,
dir: s,
div: s,
dialog: { attrs: { open: null } },
dl: s,
dt: s,
em: s,

View file

@ -187,7 +187,7 @@
function eachWord(lineText, f) {
var words = lineText.split(/\s+/)
for (var i = 0; i < words.length; i++)
if (words[i]) f(words[i].replace(/[,;]/g, ''))
if (words[i]) f(words[i].replace(/[`,;]/g, ''))
}
function findTableByAlias(alias, editor) {

View file

@ -101,12 +101,12 @@
}
replaceToken = true;
}
function returnHintsFromAtValues(atValues) {
var returnHintsFromAtValues = function(atValues) {
if (atValues)
for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle))
result.push(quote + atValues[i] + quote);
return returnHints();
}
};
if (atValues && atValues.then) return atValues.then(returnHintsFromAtValues);
return returnHintsFromAtValues(atValues);
} else { // An attribute name

View file

@ -1,6 +1,8 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// Depends on jshint.js from https://github.com/jshint/jshint
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));

View file

@ -3285,19 +3285,22 @@
}
function ensureFocus(cm) {
if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
if (!cm.hasFocus()) {
cm.display.input.focus();
if (!cm.state.focused) { onFocus(cm); }
}
}
function delayBlurEvent(cm) {
cm.state.delayingBlurEvent = true;
setTimeout(function () { if (cm.state.delayingBlurEvent) {
cm.state.delayingBlurEvent = false;
onBlur(cm);
if (cm.state.focused) { onBlur(cm); }
} }, 100);
}
function onFocus(cm, e) {
if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }
if (cm.state.delayingBlurEvent && !cm.state.draggingText) { cm.state.delayingBlurEvent = false; }
if (cm.options.readOnly == "nocursor") { return }
if (!cm.state.focused) {
@ -3479,14 +3482,15 @@
if (newTop != screentop) { result.scrollTop = newTop; }
}
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
var gutterSpace = cm.options.fixedGutter ? 0 : display.gutters.offsetWidth;
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft - gutterSpace;
var screenw = displayWidth(cm) - display.gutters.offsetWidth;
var tooWide = rect.right - rect.left > screenw;
if (tooWide) { rect.right = rect.left + screenw; }
if (rect.left < 10)
{ result.scrollLeft = 0; }
else if (rect.left < screenleft)
{ result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); }
{ result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)); }
else if (rect.right > screenw + screenleft - 3)
{ result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
return result
@ -5768,7 +5772,7 @@
changeLine(doc, handle, "widget", function (line) {
var widgets = line.widgets || (line.widgets = []);
if (widget.insertAt == null) { widgets.push(widget); }
else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }
else { widgets.splice(Math.min(widgets.length, Math.max(0, widget.insertAt)), 0, widget); }
widget.line = line;
if (cm && !lineIsHidden(doc, line)) {
var aboveVisible = heightAtLine(line) < doc.scrollTop;
@ -7377,6 +7381,10 @@
var dragEnd = operation(cm, function (e) {
if (webkit) { display.scroller.draggable = false; }
cm.state.draggingText = false;
if (cm.state.delayingBlurEvent) {
if (cm.hasFocus()) { cm.state.delayingBlurEvent = false; }
else { delayBlurEvent(cm); }
}
off(display.wrapper.ownerDocument, "mouseup", dragEnd);
off(display.wrapper.ownerDocument, "mousemove", mouseMove);
off(display.scroller, "dragstart", dragStart);
@ -7400,15 +7408,15 @@
if (webkit) { display.scroller.draggable = true; }
cm.state.draggingText = dragEnd;
dragEnd.copy = !behavior.moveOnDrag;
// IE's approach to draggable
if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
on(display.wrapper.ownerDocument, "mouseup", dragEnd);
on(display.wrapper.ownerDocument, "mousemove", mouseMove);
on(display.scroller, "dragstart", dragStart);
on(display.scroller, "drop", dragEnd);
delayBlurEvent(cm);
cm.state.delayingBlurEvent = true;
setTimeout(function () { return display.input.focus(); }, 20);
// IE's approach to draggable
if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
}
function rangeForUnit(cm, pos, unit) {
@ -7421,6 +7429,7 @@
// Normal selection, as opposed to text dragging.
function leftButtonSelect(cm, event, start, behavior) {
if (ie) { delayBlurEvent(cm); }
var display = cm.display, doc = cm.doc;
e_preventDefault(event);
@ -9781,7 +9790,7 @@
addLegacyProps(CodeMirror);
CodeMirror.version = "5.58.0";
CodeMirror.version = "5.58.3";
return CodeMirror;

View file

@ -82,15 +82,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
if (isPunctuationChar.test(ch)) {
curPunc = ch;
return null;
}
if (numberStart.test(ch)) {
stream.backUp(1)
if (stream.match(number)) return "number"
stream.next()
}
if (isPunctuationChar.test(ch)) {
curPunc = ch;
return null;
}
if (ch == "/") {
if (stream.eat("*")) {
state.tokenize = tokenComment;

View file

@ -29,7 +29,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
valueKeywords = parserConfig.valueKeywords || {},
allowNested = parserConfig.allowNested,
lineComment = parserConfig.lineComment,
supportsAtComponent = parserConfig.supportsAtComponent === true;
supportsAtComponent = parserConfig.supportsAtComponent === true,
highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false;
var type, override;
function ret(style, tp) { type = tp; return style; }
@ -197,7 +198,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
override = "property";
return "maybeprop";
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
override = "string-2";
override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
return "maybeprop";
} else if (allowNested) {
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag";
@ -291,7 +292,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
else if (propertyKeywords.hasOwnProperty(word))
override = "property";
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
override = "string-2";
override = highlightNonStandardPropertyKeywords ? "string-2" : "property";
else if (valueKeywords.hasOwnProperty(word))
override = "atom";
else if (colorKeywords.hasOwnProperty(word))

View file

@ -74,7 +74,8 @@
name: "xml",
htmlMode: true,
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag,
allowMissingTagName: parserConfig.allowMissingTagName,
});
var tags = {};

View file

@ -126,7 +126,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var kw = keywords[word]
return ret(kw.type, kw.style, word)
}
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false))
return ret("async", "keyword", word)
}
return ret("variable", "variable", word)
@ -868,7 +868,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
},
indent: function(state, textAfter) {
if (state.tokenize == tokenComment) return CodeMirror.Pass;
if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass;
if (state.tokenize != tokenBase) return 0;
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
// Kludge to prevent 'maybelse' from blocking lexical scope pops

View file

@ -255,41 +255,43 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
}
function tokenCallOrDef(stream, state) {
var match = stream.match(/^(\(\s*)/);
if (match) {
if (state.firstParenPos < 0)
state.firstParenPos = state.scopes.length;
state.scopes.push('(');
state.charsAdvanced += match[1].length;
}
if (currentScope(state) == '(' && stream.match(/^\)/)) {
state.scopes.pop();
state.charsAdvanced += 1;
if (state.scopes.length <= state.firstParenPos) {
var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false);
stream.backUp(state.charsAdvanced);
for (;;) {
var match = stream.match(/^(\(\s*)/), charsAdvanced = 0;
if (match) {
if (state.firstParenPos < 0)
state.firstParenPos = state.scopes.length;
state.scopes.push('(');
charsAdvanced += match[1].length;
}
if (currentScope(state) == '(' && stream.match(/^\)/)) {
state.scopes.pop();
charsAdvanced += 1;
if (state.scopes.length <= state.firstParenPos) {
var isDefinition = stream.match(/^(\s*where\s+[^\s=]+)*\s*?=(?!=)/, false);
stream.backUp(charsAdvanced);
state.firstParenPos = -1;
state.tokenize = tokenBase;
if (isDefinition)
return "def";
return "builtin";
}
}
// Unfortunately javascript does not support multiline strings, so we have
// to undo anything done upto here if a function call or definition splits
// over two or more lines.
if (stream.match(/^$/g, false)) {
stream.backUp(charsAdvanced);
while (state.scopes.length > state.firstParenPos)
state.scopes.pop();
state.firstParenPos = -1;
state.charsAdvanced = 0;
state.tokenize = tokenBase;
if (isDefinition)
return "def";
return "builtin";
}
if (!stream.match(/^[^()]+/)) {
stream.next()
return null
}
}
// Unfortunately javascript does not support multiline strings, so we have
// to undo anything done upto here if a function call or definition splits
// over two or more lines.
if (stream.match(/^$/g, false)) {
stream.backUp(state.charsAdvanced);
while (state.scopes.length > state.firstParenPos)
state.scopes.pop();
state.firstParenPos = -1;
state.charsAdvanced = 0;
state.tokenize = tokenBase;
return "builtin";
}
state.charsAdvanced += stream.match(/^([^()]*)/)[1].length;
return state.tokenize(stream, state);
}
function tokenAnnotation(stream, state) {
@ -383,7 +385,6 @@ CodeMirror.defineMode("julia", function(config, parserConf) {
nestedComments: 0,
nestedGenerators: 0,
nestedParameters: 0,
charsAdvanced: 0,
firstParenPos: -1
};
},

View file

@ -169,7 +169,8 @@
{name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
{name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
{name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
{name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
{name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]},
{name: "WebAssembly", mime: "text/webassembly", mode: "wast", ext: ["wat", "wast"]},
];
// Ensure all modes have a mime property for backwards compatibility
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {

View file

@ -70,6 +70,13 @@ CodeMirror.defineMode('shell', function() {
stream.eatWhile(/\w/);
return 'attribute';
}
if (ch == "<") {
var heredoc = stream.match(/^<-?\s+(.*)/)
if (heredoc) {
state.tokens.unshift(tokenHeredoc(heredoc[1]))
return 'string-2'
}
}
if (/\d/.test(ch)) {
stream.eatWhile(/\d/);
if(stream.eol() || !/\w/.test(stream.peek())) {
@ -129,6 +136,14 @@ CodeMirror.defineMode('shell', function() {
return 'def';
};
function tokenHeredoc(delim) {
return function(stream, state) {
if (stream.sol() && stream.string == delim) state.tokens.shift()
stream.skipToEnd()
return "string-2"
}
}
function tokenize(stream, state) {
return (state.tokens[0] || tokenBase) (stream, state);
};

View file

@ -16,6 +16,8 @@
"alias": { noEndTag: true },
"delpackage": { noEndTag: true },
"namespace": { noEndTag: true, soyState: "namespace-def" },
"@attribute": paramData,
"@attribute?": paramData,
"@param": paramData,
"@param?": paramData,
"@inject": paramData,
@ -53,7 +55,7 @@
CodeMirror.defineMode("soy", function(config) {
var textMode = CodeMirror.getMode(config, "text/plain");
var modes = {
html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false}),
html: CodeMirror.getMode(config, {name: "text/html", multilineTagIndentFactor: 2, multilineTagIndentPastTag: false, allowMissingTagName: true}),
attributes: textMode,
text: textMode,
uri: textMode,
@ -274,6 +276,11 @@
return null;
case "param-def":
if (match = stream.match(/^\*/)) {
state.soyState.pop();
state.soyState.push("param-type");
return "type";
}
if (match = stream.match(/^\w+/)) {
state.variables = prepend(state.variables, match[0]);
state.soyState.pop();
@ -491,6 +498,17 @@
}
return expression(stream, state);
case "template-call-expression":
if (stream.match(/^([\w-?]+)(?==)/)) {
return "attribute";
} else if (stream.eat('>')) {
state.soyState.pop();
return "keyword";
} else if (stream.eat('/>')) {
state.soyState.pop();
return "keyword";
}
return expression(stream, state);
case "literal":
if (stream.match(/^(?=\{\/literal})/)) {
state.soyState.pop();
@ -556,6 +574,15 @@
state.soyState.push("import");
state.indent += 2 * config.indentUnit;
return "keyword";
} else if (match = stream.match(/^<\{/)) {
state.soyState.push("template-call-expression");
state.tag = "print";
state.indent += 2 * config.indentUnit;
state.soyState.push("tag");
return "keyword";
} else if (match = stream.match(/^<\/>/)) {
state.indent -= 2 * config.indentUnit;
return "keyword";
}
return tokenUntil(stream, state, /\{|\s+\/\/|\/\*/);

View file

@ -60,12 +60,18 @@ CodeMirror.defineMode("sparql", function(config) {
stream.skipToEnd();
return "comment";
}
else if (ch === "^") {
ch = stream.peek();
if (ch === "^") stream.eat("^");
else stream.eatWhile(operatorChars);
return "operator";
}
else if (operatorChars.test(ch)) {
stream.eatWhile(operatorChars);
return "operator";
}
else if (ch == ":") {
stream.eatWhile(/[\w\d\._\-]/);
eatPnLocal(stream);
return "atom";
}
else if (ch == "@") {
@ -75,7 +81,7 @@ CodeMirror.defineMode("sparql", function(config) {
else {
stream.eatWhile(/[_\w\d]/);
if (stream.eat(":")) {
stream.eatWhile(/[\w\d_\-]/);
eatPnLocal(stream);
return "atom";
}
var word = stream.current();
@ -88,6 +94,10 @@ CodeMirror.defineMode("sparql", function(config) {
}
}
function eatPnLocal(stream) {
while (stream.match(/([:\w\d._-]|\\[-\\_~.!$&'()*+,;=/?#@%]|%[a-fA-F0-9][a-fA-F0-9])/));
}
function tokenLiteral(quote) {
return function(stream, state) {
var escaped = false, ch;

File diff suppressed because one or more lines are too long

View file

@ -189,7 +189,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
function Context(state, tagName, startOfLine) {
this.prev = state.context;
this.tagName = tagName;
this.tagName = tagName || "";
this.indent = state.indented;
this.startOfLine = startOfLine;
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
@ -399,7 +399,7 @@ CodeMirror.defineMode("xml", function(editorConf, config_) {
xmlCurrentContext: function(state) {
var context = []
for (var cx = state.context; cx; cx = cx.prev)
if (cx.tagName) context.push(cx.tagName)
context.push(cx.tagName)
return context.reverse()
}
};