Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

codemirror

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codemirror - npm Package Compare versions

Comparing version 4.12.0 to 4.13.0

doc/yinyang.png

10

addon/edit/closebrackets.js

@@ -13,2 +13,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

var DEFAULT_BRACKETS = "()[]{}''\"\"";
var DEFAULT_TRIPLES = "'\"";
var DEFAULT_EXPLODE_ON_ENTER = "[]{}";

@@ -23,9 +24,10 @@ var SPACE_CHAR_REGEX = /\s/;

if (!val) return;
var pairs = DEFAULT_BRACKETS, explode = DEFAULT_EXPLODE_ON_ENTER;
var pairs = DEFAULT_BRACKETS, triples = DEFAULT_TRIPLES, explode = DEFAULT_EXPLODE_ON_ENTER;
if (typeof val == "string") pairs = val;
else if (typeof val == "object") {
if (val.pairs != null) pairs = val.pairs;
if (val.triples != null) triples = val.triples;
if (val.explode != null) explode = val.explode;
}
var map = buildKeymap(pairs);
var map = buildKeymap(pairs, triples);
if (explode) map.Enter = buildExplodeHandler(explode);

@@ -57,3 +59,3 @@ cm.addKeyMap(map);

function buildKeymap(pairs) {
function buildKeymap(pairs, triples) {
var map = {

@@ -91,3 +93,3 @@ name : "autoCloseBrackets",

curType = "skip";
} else if (left == right && cur.ch > 1 &&
} else if (left == right && cur.ch > 1 && triples.indexOf(left) >= 0 &&
cm.getRange(Pos(cur.line, cur.ch - 2), cur) == left + left &&

@@ -94,0 +96,0 @@ (cur.ch <= 2 || cm.getRange(Pos(cur.line, cur.ch - 3), Pos(cur.line, cur.ch - 2)) != left)) {

2

addon/edit/closetag.js

@@ -134,3 +134,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

if (cm.getOption("disableInput")) return CodeMirror.Pass;
autoCloseCurrent(cm, true);
return autoCloseCurrent(cm, true);
}

@@ -137,0 +137,0 @@

@@ -97,3 +97,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

function onGutterClick(cm, line, gutter) {
var opts = cm.state.foldGutter.options;
var state = cm.state.foldGutter;
if (!state) return;
var opts = state.options;
if (gutter != opts.gutter) return;

@@ -104,3 +106,5 @@ cm.foldCode(Pos(line, 0), opts.rangeFinder);

function onChange(cm) {
var state = cm.state.foldGutter, opts = cm.state.foldGutter.options;
var state = cm.state.foldGutter;
if (!state) return;
var opts = state.options;
state.from = state.to = 0;

@@ -112,3 +116,5 @@ clearTimeout(state.changeUpdate);

function onViewportChange(cm) {
var state = cm.state.foldGutter, opts = cm.state.foldGutter.options;
var state = cm.state.foldGutter;
if (!state) return;
var opts = state.options;
clearTimeout(state.changeUpdate);

@@ -135,3 +141,5 @@ state.changeUpdate = setTimeout(function() {

function onFold(cm, from) {
var state = cm.state.foldGutter, line = from.line;
var state = cm.state.foldGutter;
if (!state) return;
var line = from.line;
if (line >= state.from && line < state.to)

@@ -138,0 +146,0 @@ updateFoldInfo(cm, line, line + 1);

@@ -27,2 +27,14 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

var asyncRunID = 0;
function retrieveHints(getter, cm, options, then) {
if (getter.async) {
var id = ++asyncRunID;
getter(cm, function(hints) {
if (asyncRunID == id) then(hints);
}, options);
} else {
then(getter(cm, options));
}
}
CodeMirror.defineExtension("showHint", function(options) {

@@ -38,6 +50,3 @@ // We want a single cursor position.

CodeMirror.signal(this, "startCompletion", this);
if (getHints.async)
getHints(this, function(hints) { completion.showHints(hints); }, completion.options);
else
return completion.showHints(getHints(this, completion.options));
return retrieveHints(getHints, this, completion.options, function(hints) { completion.showHints(hints); });
});

@@ -107,7 +116,3 @@

CodeMirror.signal(data, "update");
var getHints = completion.options.hint;
if (getHints.async)
getHints(completion.cm, finishUpdate, completion.options);
else
finishUpdate(getHints(completion.cm, completion.options));
retrieveHints(completion.options.hint, completion.cm, completion.options, finishUpdate);
}

@@ -114,0 +119,0 @@ function finishUpdate(data_) {

@@ -29,5 +29,22 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

function getText(item) {
return typeof item == "string" ? item : item.text;
}
function getItem(list, item) {
if (!list.slice) return list[item];
for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
return list[i];
}
function shallowClone(object) {
var result = {};
for (var key in object) if (object.hasOwnProperty(key))
result[key] = object[key];
return result;
}
function match(string, word) {
var len = string.length;
var sub = word.substr(0, len);
var sub = getText(word).substr(0, len);
return string.toUpperCase() === sub.toUpperCase();

@@ -48,49 +65,77 @@ }

function cleanName(name) {
// Get rid name from backticks(`) and preceding dot(.)
if (name.charAt(0) == ".") {
name = name.substr(1);
}
return name.replace(/`/g, "");
}
function insertBackticks(name) {
var nameParts = getText(name).split(".");
for (var i = 0; i < nameParts.length; i++)
nameParts[i] = "`" + nameParts[i] + "`";
var escaped = nameParts.join(".");
if (typeof name == "string") return escaped;
name = shallowClone(name);
name.text = escaped;
return name;
}
function nameCompletion(cur, token, result, editor) {
var useBacktick = (token.string.charAt(0) == "`");
var string = token.string.substr(1);
var prevToken = editor.getTokenAt(Pos(cur.line, token.start));
if (token.string.charAt(0) == "." || prevToken.string == "."){
//Suggest colunm names
if (prevToken.string == ".") {
var prevToken = editor.getTokenAt(Pos(cur.line, token.start - 1));
}
var table = prevToken.string;
//Check if backtick is used in table name. If yes, use it for columns too.
var useBacktickTable = false;
if (table.match(/`/g)) {
useBacktickTable = true;
table = table.replace(/`/g, "");
}
//Check if table is available. If not, find table by Alias
if (!tables.hasOwnProperty(table))
table = findTableByAlias(table, editor);
var columns = tables[table];
if (!columns) return;
// Try to complete table, colunm names and return start position of completion
var useBacktick = false;
var nameParts = [];
var start = token.start;
var cont = true;
while (cont) {
cont = (token.string.charAt(0) == ".");
useBacktick = useBacktick || (token.string.charAt(0) == "`");
if (useBacktick) {
addMatches(result, string, columns, function(w) {return "`" + w + "`";});
start = token.start;
nameParts.unshift(cleanName(token.string));
token = editor.getTokenAt(Pos(cur.line, token.start));
if (token.string == ".") {
cont = true;
token = editor.getTokenAt(Pos(cur.line, token.start));
}
else if(useBacktickTable) {
addMatches(result, string, columns, function(w) {return ".`" + w + "`";});
}
else {
addMatches(result, string, columns, function(w) {return "." + w;});
}
}
else {
//Suggest table names or colums in defaultTable
while (token.start && string.charAt(0) == ".") {
token = editor.getTokenAt(Pos(cur.line, token.start - 1));
string = token.string + string;
}
if (useBacktick) {
addMatches(result, string, tables, function(w) {return "`" + w + "`";});
addMatches(result, string, defaultTable, function(w) {return "`" + w + "`";});
}
else {
addMatches(result, string, tables, function(w) {return w;});
addMatches(result, string, defaultTable, function(w) {return w;});
}
// Try to complete table names
var string = nameParts.join(".");
addMatches(result, string, tables, function(w) {
return useBacktick ? insertBackticks(w) : w;
});
// Try to complete columns from defaultTable
addMatches(result, string, defaultTable, function(w) {
return useBacktick ? insertBackticks(w) : w;
});
// Try to complete columns
string = nameParts.pop();
var table = nameParts.join(".");
// Check if table is available. If not, find table by Alias
if (!getItem(tables, table))
table = findTableByAlias(table, editor);
var columns = getItem(tables, table);
if (columns && Array.isArray(tables) && columns.columns)
columns = columns.columns;
if (columns) {
addMatches(result, string, columns, function(w) {
if (typeof w == "string") {
w = table + "." + w;
} else {
w = shallowClone(w);
w.text = table + "." + w.text;
}
return useBacktick ? insertBackticks(w) : w;
});
}
return start;
}

@@ -155,8 +200,6 @@

var wordUpperCase = word.toUpperCase();
if (wordUpperCase === aliasUpperCase && tables.hasOwnProperty(previousWord)) {
table = previousWord;
}
if (wordUpperCase !== CONS.ALIAS_KEYWORD) {
if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
table = previousWord;
if (wordUpperCase !== CONS.ALIAS_KEYWORD)
previousWord = word;
}
});

@@ -171,3 +214,3 @@ if (table) break;

var defaultTableName = options && options.defaultTable;
defaultTable = (defaultTableName && tables[defaultTableName] || []);
defaultTable = (defaultTableName && getItem(tables, defaultTableName)) || [];
keywords = keywords || getKeywords(editor);

@@ -192,3 +235,3 @@

if (search.charAt(0) == "." || search.charAt(0) == "`") {
nameCompletion(cur, token, result, editor);
start = nameCompletion(cur, token, result, editor);
} else {

@@ -195,0 +238,0 @@ addMatches(result, search, tables, function(w) {return w;});

@@ -49,2 +49,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

if (tooltip) for (var n = node;; n = n.parentNode) {
if (n && n.nodeType == 11) n = n.host;
if (n == document.body) return;

@@ -123,3 +124,3 @@ if (!n) { hide(); break; }

var passOptions = options.options || options; // Support deprecated passing of `options` property in options
if (options.async)
if (options.async || options.getAnnotations.async)
options.getAnnotations(cm.getValue(), updateLinting, passOptions, cm);

@@ -126,0 +127,0 @@ else

@@ -34,4 +34,2 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

connect: "CodeMirror-merge-r-connect"};
if (mv.options.connect == "align")
this.aligners = [];
}

@@ -46,3 +44,4 @@

this.diff = getDiff(asString(orig), asString(options.value));
this.diffOutOfDate = false;
this.chunks = getChunks(this.diff);
this.diffOutOfDate = this.dealigned = false;

@@ -66,2 +65,3 @@ this.showDifferences = options.showDifferences !== false;

dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
dv.chunks = getChunks(dv.diff);
dv.diffOutOfDate = false;

@@ -72,7 +72,10 @@ CodeMirror.signal(dv.edit, "updateDiff", dv.diff);

var updating = false;
function registerUpdate(dv) {
var edit = {from: 0, to: 0, marked: []};
var orig = {from: 0, to: 0, marked: []};
var debounceChange;
var debounceChange, updatingFast = false;
function update(mode) {
updating = true;
updatingFast = false;
if (mode == "full") {

@@ -91,8 +94,19 @@ if (dv.svg) clear(dv.svg);

makeConnections(dv);
if (dv.mv.options.connect == "align")
alignChunks(dv);
updating = false;
}
function set(slow) {
function setDealign(fast) {
if (updating) return;
dv.dealigned = true;
set(fast);
}
function set(fast) {
if (updating || updatingFast) return;
clearTimeout(debounceChange);
debounceChange = setTimeout(update, slow == true ? 250 : 100);
if (fast === true) updatingFast = true;
debounceChange = setTimeout(update, fast === true ? 20 : 250);
}
function change() {
function change(_cm, change) {
if (!dv.diffOutOfDate) {

@@ -102,12 +116,13 @@ dv.diffOutOfDate = true;

}
set(true);
// Update faster when a line was added/removed
setDealign(change.text.length - 1 != change.to.line - change.from.line);
}
dv.edit.on("change", change);
dv.orig.on("change", change);
dv.edit.on("markerAdded", set);
dv.edit.on("markerCleared", set);
dv.orig.on("markerAdded", set);
dv.orig.on("markerCleared", set);
dv.edit.on("viewportChange", set);
dv.orig.on("viewportChange", set);
dv.edit.on("markerAdded", setDealign);
dv.edit.on("markerCleared", setDealign);
dv.orig.on("markerAdded", setDealign);
dv.orig.on("markerCleared", setDealign);
dv.edit.on("viewportChange", function() { set(false); });
dv.orig.on("viewportChange", function() { set(false); });
update();

@@ -143,3 +158,3 @@ return update;

var mid = editor.lineAtHeight(midY, "local");
var around = chunkBoundariesAround(dv.diff, mid, type == DIFF_INSERT);
var around = chunkBoundariesAround(dv.chunks, mid, type == DIFF_INSERT);
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig);

@@ -269,15 +284,2 @@ var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit);

var align = dv.mv.options.connect == "align", oldScrollEdit, oldScrollOrig;
if (align) {
if (!dv.orig.curOp) return dv.orig.operation(function() {
makeConnections(dv);
});
oldScrollEdit = dv.edit.getScrollInfo().top;
oldScrollOrig = dv.orig.getScrollInfo().top;
for (var i = 0; i < dv.aligners.length; i++)
dv.aligners[i].clear();
dv.aligners.length = 0;
var extraSpaceAbove = {edit: 0, orig: 0};
}
if (dv.svg) {

@@ -292,30 +294,114 @@ clear(dv.svg);

var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top;
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) {
if (topEdit <= vpEdit.to && botEdit >= vpEdit.from &&
topOrig <= vpOrig.to && botOrig >= vpOrig.from)
drawConnectorsForChunk(dv, topOrig, botOrig, topEdit, botEdit, sTopOrig, sTopEdit, w);
if (align && (topEdit <= vpEdit.to || topOrig <= vpOrig.to)) {
var above = (botEdit < vpEdit.from && botOrig < vpOrig.from);
alignChunks(dv, topOrig, botOrig, topEdit, botEdit, above && extraSpaceAbove);
for (var i = 0; i < dv.chunks.length; i++) {
var ch = dv.chunks[i];
if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from &&
ch.origFrom <= vpOrig.to && ch.origTo >= vpOrig.from)
drawConnectorsForChunk(dv, ch, sTopOrig, sTopEdit, w);
}
}
function getMatchingOrigLine(editLine, chunks) {
var editStart = 0, origStart = 0;
for (var i = 0; i < chunks.length; i++) {
var chunk = chunks[i];
if (chunk.editTo > editLine && chunk.editFrom <= editLine) return null;
if (chunk.editFrom > editLine) break;
editStart = chunk.editTo;
origStart = chunk.origTo;
}
return origStart + (editLine - editStart);
}
function findAlignedLines(dv, other) {
var linesToAlign = [];
for (var i = 0; i < dv.chunks.length; i++) {
var chunk = dv.chunks[i];
linesToAlign.push([chunk.origTo, chunk.editTo, other ? getMatchingOrigLine(chunk.editTo, other.chunks) : null]);
}
if (other) {
for (var i = 0; i < other.chunks.length; i++) {
var chunk = other.chunks[i];
for (var j = 0; j < linesToAlign.length; j++) {
var align = linesToAlign[j];
if (align[1] == chunk.editTo) {
j = -1;
break;
} else if (align[1] > chunk.editTo) {
break;
}
}
if (j > -1)
linesToAlign.splice(j - 1, 0, [getMatchingOrigLine(chunk.editTo, dv.chunks), chunk.editTo, chunk.origTo]);
}
}
return linesToAlign;
}
function alignChunks(dv, force) {
if (!dv.dealigned && !force) return;
if (!dv.orig.curOp) return dv.orig.operation(function() {
alignChunks(dv, force);
});
if (align) {
if (extraSpaceAbove.edit)
dv.aligners.push(padBelow(dv.edit, 0, extraSpaceAbove.edit));
if (extraSpaceAbove.orig)
dv.aligners.push(padBelow(dv.orig, 0, extraSpaceAbove.orig));
dv.edit.scrollTo(null, oldScrollEdit);
dv.orig.scrollTo(null, oldScrollOrig);
dv.dealigned = false;
var other = dv.mv.left == dv ? dv.mv.right : dv.mv.left;
if (other) {
ensureDiff(other);
other.dealigned = false;
}
var linesToAlign = findAlignedLines(dv, other);
// Clear old aligners
var aligners = dv.mv.aligners;
for (var i = 0; i < aligners.length; i++)
aligners[i].clear();
aligners.length = 0;
var cm = [dv.orig, dv.edit], scroll = [];
if (other) cm.push(other.orig);
for (var i = 0; i < cm.length; i++)
scroll.push(cm[i].getScrollInfo().top);
for (var ln = 0; ln < linesToAlign.length; ln++)
alignLines(cm, linesToAlign[ln], aligners);
for (var i = 0; i < cm.length; i++)
cm[i].scrollTo(null, scroll[i]);
}
function drawConnectorsForChunk(dv, topOrig, botOrig, topEdit, botEdit, sTopOrig, sTopEdit, w) {
function alignLines(cm, lines, aligners) {
var maxOffset = 0, offset = [];
for (var i = 0; i < cm.length; i++) if (lines[i] != null) {
var off = cm[i].heightAtLine(lines[i], "local");
offset[i] = off;
maxOffset = Math.max(maxOffset, off);
}
for (var i = 0; i < cm.length; i++) if (lines[i] != null) {
var diff = maxOffset - offset[i];
if (diff > 1)
aligners.push(padAbove(cm[i], lines[i], diff));
}
}
function padAbove(cm, line, size) {
var above = true;
if (line > cm.lastLine()) {
line--;
above = false;
}
var elt = document.createElement("div");
elt.className = "CodeMirror-merge-spacer";
elt.style.height = size + "px"; elt.style.minWidth = "1px";
return cm.addLineWidget(line, elt, {height: size, above: above});
}
function drawConnectorsForChunk(dv, chunk, sTopOrig, sTopEdit, w) {
var flip = dv.type == "left";
var top = dv.orig.heightAtLine(topOrig, "local") - sTopOrig;
var top = dv.orig.heightAtLine(chunk.origFrom, "local") - sTopOrig;
if (dv.svg) {
var topLpx = top;
var topRpx = dv.edit.heightAtLine(topEdit, "local") - sTopEdit;
var topRpx = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit;
if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; }
var botLpx = dv.orig.heightAtLine(botOrig, "local") - sTopOrig;
var botRpx = dv.edit.heightAtLine(botEdit, "local") - sTopEdit;
var botLpx = dv.orig.heightAtLine(chunk.origTo, "local") - sTopOrig;
var botRpx = dv.edit.heightAtLine(chunk.editTo, "local") - sTopEdit;
if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; }

@@ -333,11 +419,12 @@ var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx;

copy.title = editOriginals ? "Push to left" : "Revert chunk";
copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig};
copy.chunk = chunk;
copy.style.top = top + "px";
if (editOriginals) {
var topReverse = dv.orig.heightAtLine(topEdit, "local") - sTopEdit;
var topReverse = dv.orig.heightAtLine(chunk.editFrom, "local") - sTopEdit;
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
"CodeMirror-merge-copy-reverse"));
copyReverse.title = "Push to right";
copyReverse.chunk = {topEdit: topOrig, botEdit: botOrig, topOrig: topEdit, botOrig: botEdit};
copyReverse.chunk = {editFrom: chunk.origFrom, editTo: chunk.origTo,
origFrom: chunk.editFrom, origTo: chunk.editTo};
copyReverse.style.top = topReverse + "px";

@@ -349,29 +436,6 @@ dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px";

function alignChunks(dv, topOrig, botOrig, topEdit, botEdit, aboveViewport) {
var topOrigPx = dv.orig.heightAtLine(topOrig, "local");
var botOrigPx = dv.orig.heightAtLine(botOrig, "local");
var topEditPx = dv.edit.heightAtLine(topEdit, "local");
var botEditPx = dv.edit.heightAtLine(botEdit, "local");
var origH = botOrigPx -topOrigPx, editH = botEditPx - topEditPx;
var diff = editH - origH;
if (diff > 1) {
if (aboveViewport) aboveViewport.orig += diff;
else dv.aligners.push(padBelow(dv.orig, botOrig - 1, diff));
} else if (diff < -1) {
if (aboveViewport) aboveViewport.edit -= diff;
else dv.aligners.push(padBelow(dv.edit, botEdit - 1, -diff));
}
return 0;
}
function padBelow(cm, line, size) {
var elt = document.createElement("div");
elt.style.height = size + "px"; elt.style.minWidth = "1px";
return cm.addLineWidget(line, elt, {height: size});
}
function copyChunk(dv, to, from, chunk) {
if (dv.diffOutOfDate) return;
to.replaceRange(from.getRange(Pos(chunk.topOrig, 0), Pos(chunk.botOrig, 0)),
Pos(chunk.topEdit, 0), Pos(chunk.botEdit, 0));
to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
Pos(chunk.editFrom, 0), Pos(chunk.editTo, 0));
}

@@ -386,8 +450,2 @@

var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight;
if (origLeft && origRight) {
if (options.connect == "align")
throw new Error("connect: \"align\" is not supported for three-way merge views");
if (options.collapseIdentical)
throw new Error("collapseIdentical option is not supported for three-way merge views");
}

@@ -397,2 +455,3 @@ var hasLeft = origLeft != null, hasRight = origRight != null;

var wrap = [], left = this.left = null, right = this.right = null;
var self = this;

@@ -426,4 +485,13 @@ if (hasLeft) {

if (options.collapseIdentical)
collapseIdenticalStretches(left || right, options.collapseIdentical);
if (options.collapseIdentical) {
updating = true;
this.editor().operation(function() {
collapseIdenticalStretches(self, options.collapseIdentical);
});
updating = false;
}
if (options.connect == "align") {
this.aligners = [];
alignChunks(this.left || this.right, true);
}

@@ -480,6 +548,6 @@ var onResize = function() {

rightChunks: function() {
return this.right && getChunks(this.right);
if (this.right) { ensureDiff(this.right); return this.right.chunks; }
},
leftChunks: function() {
return this.left && getChunks(this.left);
if (this.left) { ensureDiff(this.left); return this.left.chunks; }
}

@@ -512,3 +580,4 @@ };

function iterateChunks(diff, f) {
function getChunks(diff) {
var chunks = [];
var startEdit = 0, startOrig = 0;

@@ -525,3 +594,4 @@ var edit = Pos(0, 0), orig = Pos(0, 0);

if (cleanToEdit > cleanFromEdit) {
if (i) f(startOrig, cleanFromOrig, startEdit, cleanFromEdit);
if (i) chunks.push({origFrom: startOrig, origTo: cleanFromOrig,
editFrom: startEdit, editTo: cleanFromEdit});
startEdit = cleanToEdit; startOrig = cleanToOrig;

@@ -534,15 +604,7 @@ }

if (startEdit <= edit.line || startOrig <= orig.line)
f(startOrig, orig.line + 1, startEdit, edit.line + 1);
chunks.push({origFrom: startOrig, origTo: orig.line + 1,
editFrom: startEdit, editTo: edit.line + 1});
return chunks;
}
function getChunks(dv) {
ensureDiff(dv);
var collect = [];
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) {
collect.push({origFrom: topOrig, origTo: botOrig,
editFrom: topEdit, editTo: botEdit});
});
return collect;
}
function endOfLineClean(diff, i) {

@@ -566,14 +628,15 @@ if (i == diff.length - 1) return true;

function chunkBoundariesAround(diff, n, nInEdit) {
function chunkBoundariesAround(chunks, n, nInEdit) {
var beforeE, afterE, beforeO, afterO;
iterateChunks(diff, function(fromOrig, toOrig, fromEdit, toEdit) {
var fromLocal = nInEdit ? fromEdit : fromOrig;
var toLocal = nInEdit ? toEdit : toOrig;
for (var i = 0; i < chunks.length; i++) {
var chunk = chunks[i];
var fromLocal = nInEdit ? chunk.editFrom : chunk.origFrom;
var toLocal = nInEdit ? chunk.editTo : chunk.origTo;
if (afterE == null) {
if (fromLocal > n) { afterE = fromEdit; afterO = fromOrig; }
else if (toLocal > n) { afterE = toEdit; afterO = toOrig; }
if (fromLocal > n) { afterE = chunk.editFrom; afterO = chunk.origFrom; }
else if (toLocal > n) { afterE = chunk.editTo; afterO = chunk.origTo; }
}
if (toLocal <= n) { beforeE = toEdit; beforeO = toOrig; }
else if (fromLocal <= n) { beforeE = fromEdit; beforeO = fromOrig; }
});
if (toLocal <= n) { beforeE = chunk.editTo; beforeO = chunk.origTo; }
else if (fromLocal <= n) { beforeE = chunk.editFrom; beforeO = chunk.origFrom; }
}
return {edit: {before: beforeE, after: afterE}, orig: {before: beforeO, after: afterO}};

@@ -601,21 +664,46 @@ }

function collapseStretch(dv, origStart, editStart, size) {
var mOrig = collapseSingle(dv.orig, origStart, origStart + size);
var mEdit = collapseSingle(dv.edit, editStart, editStart + size);
mOrig.mark.on("clear", function() { mEdit.clear(); });
mEdit.mark.on("clear", function() { mOrig.clear(); });
function collapseStretch(size, editors) {
var marks = [];
function clear() {
for (var i = 0; i < marks.length; i++) marks[i].clear();
}
for (var i = 0; i < editors.length; i++) {
var editor = editors[i];
var mark = collapseSingle(editor.cm, editor.line, editor.line + size);
marks.push(mark);
mark.mark.on("clear", clear);
}
return marks[0].mark;
}
function collapseIdenticalStretches(dv, margin) {
function unclearNearChunks(dv, margin, off, clear) {
for (var i = 0; i < dv.chunks.length; i++) {
var chunk = dv.chunks[i];
for (var l = chunk.editFrom - margin; l < chunk.editTo + margin; l++) {
var pos = l + off;
if (pos >= 0 && pos < clear.length) clear[pos] = false;
}
}
}
function collapseIdenticalStretches(mv, margin) {
if (typeof margin != "number") margin = 2;
var lastOrig = dv.orig.firstLine(), lastEdit = dv.edit.firstLine();
iterateChunks(dv.diff, function(topOrig, botOrig, _topEdit, botEdit) {
var identicalSize = topOrig - margin - lastOrig;
if (identicalSize > margin)
collapseStretch(dv, lastOrig, lastEdit, identicalSize);
lastOrig = botOrig + margin; lastEdit = botEdit + margin;
});
var bottomSize = dv.orig.lastLine() + 1 - lastOrig;
if (bottomSize > margin)
collapseStretch(dv, lastOrig, lastEdit, bottomSize);
var clear = [], edit = mv.editor(), off = edit.firstLine();
for (var l = off, e = edit.lastLine(); l <= e; l++) clear.push(true);
if (mv.left) unclearNearChunks(mv.left, margin, off, clear);
if (mv.right) unclearNearChunks(mv.right, margin, off, clear);
for (var i = 0; i < clear.length; i++) {
if (clear[i]) {
var line = i + off;
for (var size = 1; i < clear.length - 1 && clear[i + 1]; i++, size++) {}
if (size > margin) {
var editors = [{line: line, cm: edit}];
if (mv.left) editors.push({line: getMatchingOrigLine(line, mv.left.chunks), cm: mv.left.orig});
if (mv.right) editors.push({line: getMatchingOrigLine(line, mv.right.chunks), cm: mv.right.orig});
var mark = collapseStretch(size, editors);
if (mv.options.onCollapse) mv.options.onCollapse(mv, line, size, mark);
}
}
}
}

@@ -622,0 +710,0 @@

@@ -14,10 +14,15 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

CodeMirror.defineExtension("annotateScrollbar", function(className) {
return new Annotation(this, className);
CodeMirror.defineExtension("annotateScrollbar", function(options) {
if (typeof options == "string") options = {className: options};
return new Annotation(this, options);
});
function Annotation(cm, className) {
CodeMirror.defineOption("scrollButtonHeight", 0);
function Annotation(cm, options) {
this.cm = cm;
this.className = className;
this.options = options;
this.buttonHeight = options.scrollButtonHeight || cm.getOption("scrollButtonHeight");
this.annotations = [];
this.doRedraw = this.doUpdate = null;
this.div = cm.getWrapperElement().appendChild(document.createElement("div"));

@@ -27,6 +32,20 @@ this.div.style.cssText = "position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none";

function scheduleRedraw(delay) {
clearTimeout(self.doRedraw);
self.doRedraw = setTimeout(function() { self.redraw(); }, delay);
}
var self = this;
cm.on("refresh", this.resizeHandler = function(){
if (self.computeScale()) self.redraw();
cm.on("refresh", this.resizeHandler = function() {
clearTimeout(self.doUpdate);
self.doUpdate = setTimeout(function() {
if (self.computeScale()) scheduleRedraw(20);
}, 100);
});
cm.on("markerAdded", this.resizeHandler);
cm.on("markerCleared", this.resizeHandler);
if (options.listenForChanges !== false)
cm.on("change", this.changeHandler = function() {
scheduleRedraw(250);
});
}

@@ -36,3 +55,3 @@

var cm = this.cm;
var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight) /
var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
cm.heightAtLine(cm.lastLine() + 1, "local");

@@ -50,8 +69,8 @@ if (hScale != this.hScale) {

Annotation.prototype.redraw = function() {
Annotation.prototype.redraw = function(compute) {
if (compute !== false) this.computeScale();
var cm = this.cm, hScale = this.hScale;
if (!cm.display.barWidth) return;
var frag = document.createDocumentFragment(), anns = this.annotations;
for (var i = 0, nextTop; i < anns.length; i++) {
if (cm.display.barWidth) for (var i = 0, nextTop; i < anns.length; i++) {
var ann = anns[i];

@@ -66,7 +85,9 @@ var top = nextTop || cm.charCoords(ann.from, "local").top * hScale;

}
if (bottom == top) continue;
var height = Math.max(bottom - top, 3);
var elt = frag.appendChild(document.createElement("div"));
elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: " + top + "px; height: " + height + "px";
elt.className = this.className;
elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
+ (top + this.buttonHeight) + "px; height: " + height + "px";
elt.className = this.options.className;
}

@@ -79,4 +100,7 @@ this.div.textContent = "";

this.cm.off("refresh", this.resizeHandler);
this.cm.off("markerAdded", this.resizeHandler);
this.cm.off("markerCleared", this.resizeHandler);
if (this.changeHandler) this.cm.off("change", this.changeHandler);
this.div.parentNode.removeChild(this.div);
};
});

@@ -14,9 +14,14 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, className) {
return new SearchAnnotation(this, query, caseFold, className);
CodeMirror.defineExtension("showMatchesOnScrollbar", function(query, caseFold, options) {
if (typeof options == "string") options = {className: options};
if (!options) options = {};
return new SearchAnnotation(this, query, caseFold, options);
});
function SearchAnnotation(cm, query, caseFold, className) {
function SearchAnnotation(cm, query, caseFold, options) {
this.cm = cm;
this.annotation = cm.annotateScrollbar(className || "CodeMirror-search-match");
var annotateOptions = {listenForChanges: false};
for (var prop in options) annotateOptions[prop] = options[prop];
if (!annotateOptions.className) annotateOptions.className = "CodeMirror-search-match";
this.annotation = cm.annotateScrollbar(annotateOptions);
this.query = query;

@@ -23,0 +28,0 @@ this.caseFold = caseFold;

@@ -19,2 +19,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout);
CodeMirror.off(window, "scroll", data.windowScroll);
cm.off("cursorActivity", reset);

@@ -30,2 +31,3 @@ cm.off("scroll", reset);

mouseout: function(event) { mouseout(cm, event); },
windowScroll: function() { reset(cm); },
rects: null,

@@ -37,2 +39,3 @@ mouseX: null, mouseY: null,

CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout);
CodeMirror.on(window, "scroll", data.windowScroll);
cm.on("cursorActivity", reset);

@@ -39,0 +42,0 @@ cm.on("scroll", reset);

@@ -133,2 +133,9 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

});
},
destroy: function () {
if (this.worker) {
this.worker.terminate();
this.worker = null;
}
}

@@ -256,3 +263,5 @@ };

tip.appendChild(document.createTextNode(" "));
tip.appendChild(elt("a", null, "[docs]")).href = data.url;
var child = tip.appendChild(elt("a", null, "[docs]"));
child.href = data.url;
child.target = "_blank";
}

@@ -587,11 +596,29 @@ }

function tempTooltip(cm, content) {
if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
var where = cm.cursorCoords();
var tip = makeTooltip(where.right + 1, where.bottom, content);
var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
function maybeClear() {
old = true;
if (!mouseOnTip) clear();
}
function clear() {
cm.state.ternTooltip = null;
if (!tip.parentNode) return;
cm.off("cursorActivity", clear);
cm.off('blur', clear);
cm.off('scroll', clear);
fadeOut(tip);
}
setTimeout(clear, 1700);
var mouseOnTip = false, old = false;
CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; });
CodeMirror.on(tip, "mouseout", function(e) {
if (!CodeMirror.contains(tip, e.relatedTarget || e.toElement)) {
if (old) clear();
else mouseOnTip = false;
}
});
setTimeout(maybeClear, 1700);
cm.on("cursorActivity", clear);
cm.on('blur', clear);
cm.on('scroll', clear);
}

@@ -637,3 +664,3 @@

function WorkerServer(ts) {
var worker = new Worker(ts.options.workerScript);
var worker = ts.worker = new Worker(ts.options.workerScript);
worker.postMessage({type: "init",

@@ -640,0 +667,0 @@ defs: ts.options.defs,

{
"name": "codemirror",
"version":"4.12.0",
"version":"4.13.0",
"main": ["lib/codemirror.js", "lib/codemirror.css"],

@@ -5,0 +5,0 @@ "ignore": [

@@ -357,3 +357,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

}
escaped = stream.next() != "\\" && !escaped;
escaped = stream.next() == "\\" && !escaped;
}

@@ -402,2 +402,6 @@ return "string";

return state.tokenize(stream, state);
},
"'": function(stream) {
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
return "atom";
}

@@ -404,0 +408,0 @@ }

@@ -19,2 +19,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

tokenHooks = parserConfig.tokenHooks,
documentTypes = parserConfig.documentTypes || {},
mediaTypes = parserConfig.mediaTypes || {},

@@ -24,5 +25,6 @@ mediaFeatures = parserConfig.mediaFeatures || {},

nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
fontProperties = parserConfig.fontProperties || {},
counterDescriptors = parserConfig.counterDescriptors || {},
colorKeywords = parserConfig.colorKeywords || {},
valueKeywords = parserConfig.valueKeywords || {},
fontProperties = parserConfig.fontProperties || {},
allowNested = parserConfig.allowNested;

@@ -62,2 +64,7 @@

return ret("number", "unit");
} else if (stream.match(/^-[\w\\\-]+/)) {
stream.eatWhile(/[\w\\\-]/);
if (stream.match(/^\s*:/, false))
return ret("variable-2", "variable-definition");
return ret("variable-2", "variable");
} else if (stream.match(/^\w+-/)) {

@@ -72,3 +79,5 @@ return ret("meta", "meta");

return ret(null, ch);
} else if (ch == "u" && stream.match("rl(")) {
} else if ((ch == "u" && stream.match(/rl(-prefix)?\(/)) ||
(ch == "d" && stream.match("omain(")) ||
(ch == "r" && stream.match("egexp("))) {
stream.backUp(1);

@@ -155,6 +164,7 @@ state.tokenize = tokenParenthesized;

return popContext(state);
} else if (type == "@media") {
return pushContext(state, stream, "media");
} else if (type == "@font-face") {
return "font_face_before";
} else if (/@(media|supports|(-moz-)?document)/.test(type)) {
return pushContext(state, stream, "atBlock");
} else if (/@(font-face|counter-style)/.test(type)) {
state.stateArg = type;
return "restricted_atBlock_before";
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {

@@ -249,4 +259,4 @@ return "keyframes";

states.media = function(type, stream, state) {
if (type == "(") return pushContext(state, stream, "media_parens");
states.atBlock = function(type, stream, state) {
if (type == "(") return pushContext(state, stream, "atBlock_parens");
if (type == "}") return popAndPass(type, stream, state);

@@ -257,4 +267,6 @@ if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");

var word = stream.current().toLowerCase();
if (word == "only" || word == "not" || word == "and")
if (word == "only" || word == "not" || word == "and" || word == "or")
override = "keyword";
else if (documentTypes.hasOwnProperty(word))
override = "tag";
else if (mediaTypes.hasOwnProperty(word))

@@ -264,2 +276,8 @@ override = "attribute";

override = "property";
else if (propertyKeywords.hasOwnProperty(word))
override = "property";
else if (nonStandardPropertyKeywords.hasOwnProperty(word))
override = "string-2";
else if (valueKeywords.hasOwnProperty(word))
override = "atom";
else

@@ -271,18 +289,26 @@ override = "error";

states.media_parens = function(type, stream, state) {
states.atBlock_parens = function(type, stream, state) {
if (type == ")") return popContext(state);
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
return states.media(type, stream, state);
return states.atBlock(type, stream, state);
};
states.font_face_before = function(type, stream, state) {
states.restricted_atBlock_before = function(type, stream, state) {
if (type == "{")
return pushContext(state, stream, "font_face");
return pushContext(state, stream, "restricted_atBlock");
if (type == "word" && state.stateArg == "@counter-style") {
override = "variable";
return "restricted_atBlock_before";
}
return pass(type, stream, state);
};
states.font_face = function(type, stream, state) {
if (type == "}") return popContext(state);
states.restricted_atBlock = function(type, stream, state) {
if (type == "}") {
state.stateArg = null;
return popContext(state);
}
if (type == "word") {
if (!fontProperties.hasOwnProperty(stream.current().toLowerCase()))
if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) ||
(state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase())))
override = "error";

@@ -293,3 +319,3 @@ else

}
return "font_face";
return "restricted_atBlock";
};

@@ -322,2 +348,3 @@

state: "top",
stateArg: null,
context: new Context("top", base || 0, null)};

@@ -343,5 +370,5 @@ },

if (cx.prev &&
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") ||
ch == ")" && (cx.type == "parens" || cx.type == "media_parens") ||
ch == "{" && (cx.type == "at" || cx.type == "media"))) {
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "restricted_atBlock") ||
ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") ||
ch == "{" && (cx.type == "at" || cx.type == "atBlock"))) {
indent = cx.indent - indentUnit;

@@ -368,2 +395,6 @@ cx = cx.prev;

var documentTypes_ = [
"domain", "regexp", "url", "url-prefix"
], documentTypes = keySet(documentTypes_);
var mediaTypes_ = [

@@ -485,2 +516,12 @@ "all", "aural", "braille", "handheld", "print", "projection", "screen",

var fontProperties_ = [
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
"font-stretch", "font-weight", "font-style"
], fontProperties = keySet(fontProperties_);
var counterDescriptors_ = [
"additive-symbols", "fallback", "negative", "pad", "prefix", "range",
"speak-as", "suffix", "symbols", "system"
], counterDescriptors = keySet(counterDescriptors_);
var colorKeywords_ = [

@@ -516,20 +557,21 @@ "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",

var valueKeywords_ = [
"above", "absolute", "activeborder", "activecaption", "afar",
"after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
"above", "absolute", "activeborder", "additive", "activecaption", "afar",
"after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
"arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
"arabic-indic", "armenian", "asterisks", "attr", "auto", "avoid", "avoid-column", "avoid-page",
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
"both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian",
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
"cell", "center", "checkbox", "circle", "cjk-earthly-branch",
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
"col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
"content-box", "context-menu", "continuous", "copy", "cover", "crop",
"cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
"content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
"cross", "crosshair", "currentcolor", "cursive", "cyclic", "dashed", "decimal",
"decimal-leading-zero", "default", "default-button", "destination-atop",
"destination-in", "destination-out", "destination-over", "devanagari",
"disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
"double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
"disc", "discard", "disclosure-closed", "disclosure-open", "document",
"dot-dash", "dot-dot-dash",
"dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",

@@ -541,4 +583,4 @@ "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",

"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
"ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig",
"ethiopic-numeric", "ew-resize", "expanded", "extends", "extra-condensed",
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "flex", "footnotes",

@@ -552,8 +594,10 @@ "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",

"inline-block", "inline-flex", "inline-table", "inset", "inside", "intrinsic", "invert",
"italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
"italic", "japanese-formal", "japanese-informal", "justify", "kannada",
"katakana", "katakana-iroha", "keep-all", "khmer",
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal",
"landscape", "lao", "large", "larger", "left", "level", "lighter",
"line-through", "linear", "lines", "list-item", "listbox", "listitem",
"line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem",
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
"lower-roman", "lowercase", "ltr", "malayalam", "match",
"lower-roman", "lowercase", "ltr", "malayalam", "match", "matrix", "matrix3d",
"media-controls-background", "media-current-time-display",

@@ -570,22 +614,28 @@ "media-fullscreen-button", "media-mute-button", "media-play-button",

"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
"ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
"painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer",
"polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
"radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
"relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
"ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
"s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
"painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
"pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d",
"progress", "push-button", "radial-gradient", "radio", "read-only",
"read-write", "read-write-plaintext-only", "rectangle", "region",
"relative", "repeat", "repeating-linear-gradient",
"repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
"rotateZ", "round", "row-resize", "rtl", "run-in", "running",
"s-resize", "sans-serif", "scale", "scale3d", "scaleX", "scaleY", "scaleZ",
"scroll", "scrollbar", "se-resize", "searchfield",
"searchfield-cancel-button", "searchfield-decoration",
"searchfield-results-button", "searchfield-results-decoration",
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
"single", "skip-white-space", "slide", "slider-horizontal",
"simp-chinese-formal", "simp-chinese-informal", "single",
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
"small", "small-caps", "small-caption", "smaller", "solid", "somali",
"source-atop", "source-in", "source-out", "source-over", "space", "square",
"square-button", "start", "static", "status-bar", "stretch", "stroke",
"sub", "subpixel-antialiased", "super", "sw-resize", "table",
"source-atop", "source-in", "source-out", "source-over", "space", "spell-out", "square",
"square-button", "start", "static", "status-bar", "stretch", "stroke", "sub",
"subpixel-antialiased", "super", "sw-resize", "symbolic", "symbols", "table",
"table-caption", "table-cell", "table-column", "table-column-group",
"table-footer-group", "table-header-group", "table-row", "table-row-group",
"tamil",
"telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",

@@ -595,17 +645,14 @@ "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",

"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
"trad-chinese-formal", "trad-chinese-informal",
"translate", "translate3d", "translateX", "translateY", "translateZ",
"transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
"vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
"var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
"window", "windowframe", "windowtext", "x-large", "x-small", "xor",
"window", "windowframe", "windowtext", "words", "x-large", "x-small", "xor",
"xx-large", "xx-small"
], valueKeywords = keySet(valueKeywords_);
var fontProperties_ = [
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
"font-stretch", "font-weight", "font-style"
], fontProperties = keySet(fontProperties_);
var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_)
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(propertyKeywords_)
.concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);

@@ -637,2 +684,3 @@ CodeMirror.registerHelper("hintWords", "css", allWords);

CodeMirror.defineMIME("text/css", {
documentTypes: documentTypes,
mediaTypes: mediaTypes,

@@ -642,5 +690,6 @@ mediaFeatures: mediaFeatures,

nonStandardPropertyKeywords: nonStandardPropertyKeywords,
fontProperties: fontProperties,
counterDescriptors: counterDescriptors,
colorKeywords: colorKeywords,
valueKeywords: valueKeywords,
fontProperties: fontProperties,
tokenHooks: {

@@ -647,0 +696,0 @@ "<": function(stream, state) {

@@ -129,3 +129,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

" [property background-image]: [variable fade]([atom #000], [number 20%]);",
" [property border-image]: [variable linear-gradient](",
" [property border-image]: [atom linear-gradient](",
" [atom to] [atom bottom],",

@@ -136,2 +136,62 @@ " [variable fade]([atom #000], [number 20%]) [number 0%],",

"}");
MT("css_variable",
":[variable-3 root] {",
" [variable-2 --main-color]: [atom #06c];",
"}",
"[tag h1][builtin #foo] {",
" [property color]: [atom var]([variable-2 --main-color]);",
"}");
MT("supports",
"[def @supports] ([keyword not] (([property text-align-last]: [atom justify]) [keyword or] ([meta -moz-][property text-align-last]: [atom justify])) {",
" [property text-align-last]: [atom justify];",
"}");
MT("document",
"[def @document] [tag url]([string http://blah]),",
" [tag url-prefix]([string https://]),",
" [tag domain]([string blah.com]),",
" [tag regexp]([string \".*blah.+\"]) {",
" [builtin #id] {",
" [property background-color]: [keyword white];",
" }",
" [tag foo] {",
" [property font-family]: [variable Verdana], [atom sans-serif];",
" }",
" }");
MT("document_url",
"[def @document] [tag url]([string http://blah]) { [qualifier .class] { } }");
MT("document_urlPrefix",
"[def @document] [tag url-prefix]([string https://]) { [builtin #id] { } }");
MT("document_domain",
"[def @document] [tag domain]([string blah.com]) { [tag foo] { } }");
MT("document_regexp",
"[def @document] [tag regexp]([string \".*blah.+\"]) { [builtin #id] { } }");
MT("counter-style",
"[def @counter-style] [variable binary] {",
" [property system]: [atom numeric];",
" [property symbols]: [number 0] [number 1];",
" [property suffix]: [string \".\"];",
" [property range]: [atom infinite];",
" [property speak-as]: [atom numeric];",
"}");
MT("counter-style-additive-symbols",
"[def @counter-style] [variable simple-roman] {",
" [property system]: [atom additive];",
" [property additive-symbols]: [number 10] [variable X], [number 5] [variable V], [number 1] [variable I];",
" [property range]: [number 1] [number 49];",
"}");
MT("counter-style-use",
"[tag ol][qualifier .roman] { [property list-style]: [variable simple-roman]; }");
MT("counter-style-symbols",
"[tag ol] { [property list-style]: [atom symbols]([atom cyclic] [string \"*\"] [string \"\\2020\"] [string \"\\2021\"] [string \"\\A7\"]); }");
})();

@@ -63,3 +63,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

var curPunc;
var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "right", "round", "rtrim", "shortestPath", "sign", "sin", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "trim", "type", "upper"]);
var funcs = wordRegexp(["abs", "acos", "allShortestPaths", "asin", "atan", "atan2", "avg", "ceil", "coalesce", "collect", "cos", "cot", "count", "degrees", "e", "endnode", "exp", "extract", "filter", "floor", "haversin", "head", "id", "keys", "labels", "last", "left", "length", "log", "log10", "lower", "ltrim", "max", "min", "node", "nodes", "percentileCont", "percentileDisc", "pi", "radians", "rand", "range", "reduce", "rel", "relationship", "relationships", "replace", "right", "round", "rtrim", "shortestPath", "sign", "sin", "split", "sqrt", "startnode", "stdev", "stdevp", "str", "substring", "sum", "tail", "tan", "timestamp", "toFloat", "toInt", "trim", "type", "upper"]);
var preds = wordRegexp(["all", "and", "any", "has", "in", "none", "not", "or", "single", "xor"]);

@@ -66,0 +66,0 @@ var keywords = wordRegexp(["as", "asc", "ascending", "assert", "by", "case", "commit", "constraint", "create", "csv", "cypher", "delete", "desc", "descending", "distinct", "drop", "else", "end", "explain", "false", "fieldterminator", "foreach", "from", "headers", "in", "index", "is", "limit", "load", "match", "merge", "null", "on", "optional", "order", "periodic", "profile", "remove", "return", "scan", "set", "skip", "start", "then", "true", "union", "unique", "unwind", "using", "when", "where", "with"]);

@@ -120,2 +120,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

function popContext(state) {
if (!state.context.prev) return;
var t = state.context.type;

@@ -122,0 +123,0 @@ if (t == ")" || t == "]" || t == "}")

@@ -278,3 +278,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

stream.next();
return 'error';
return null;
};

@@ -281,0 +281,0 @@

@@ -121,3 +121,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

readRegexp(stream);
stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
return ret("regexp", "string-2");

@@ -124,0 +124,0 @@ } else {

@@ -41,2 +41,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

{name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
{name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},

@@ -43,0 +44,0 @@ {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},

@@ -193,3 +193,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

var cx = state.context;
if (!cx) return 0;
if (!cx) return CodeMirror.Pass;
var closing = textAfter.charAt(0) == cx.type;

@@ -196,0 +196,0 @@ if (cx.align) return cx.col + (closing ? 0 : 1);

@@ -20,3 +20,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

noIndentKeywords = parserConfig.noIndentKeywords || [],
multiLineStrings = parserConfig.multiLineStrings;
multiLineStrings = parserConfig.multiLineStrings,
hooks = parserConfig.hooks || {};

@@ -111,3 +112,7 @@ function words(str) {

function tokenBase(stream, state) {
var ch = stream.peek();
var ch = stream.peek(), style;
if (hooks[ch] && (style = hooks[ch](stream, state)) != false) return style;
if (hooks.tokenBase && (style = hooks.tokenBase(stream, state)) != false)
return style;
if (/[,;:\.]/.test(ch)) {

@@ -285,3 +290,3 @@ curPunc = stream.next();

startState: function(basecolumn) {
return {
var state = {
tokenize: null,

@@ -292,2 +297,4 @@ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),

};
if (hooks.startState) hooks.startState(state);
return state;
},

@@ -302,2 +309,3 @@

}
if (hooks.token) hooks.token(stream, state);
if (stream.eatSpace()) return null;

@@ -312,14 +320,16 @@ curPunc = null;

popContext(state);
}
else if ((curPunc == ";" && ctx.type == "statement") ||
} else if ((curPunc == ";" && ctx.type == "statement") ||
(ctx.type && isClosing(curKeyword, ctx.type))) {
ctx = popContext(state);
while (ctx && ctx.type == "statement") ctx = popContext(state);
}
else if (curPunc == "{") { pushContext(state, stream.column(), "}"); }
else if (curPunc == "[") { pushContext(state, stream.column(), "]"); }
else if (curPunc == "(") { pushContext(state, stream.column(), ")"); }
else if (ctx && ctx.type == "endcase" && curPunc == ":") { pushContext(state, stream.column(), "statement"); }
else if (curPunc == "newstatement") {
} else if (curPunc == "{") {
pushContext(state, stream.column(), "}");
} else if (curPunc == "[") {
pushContext(state, stream.column(), "]");
} else if (curPunc == "(") {
pushContext(state, stream.column(), ")");
} else if (ctx && ctx.type == "endcase" && curPunc == ":") {
pushContext(state, stream.column(), "statement");
} else if (curPunc == "newstatement") {
pushContext(state, stream.column(), "statement");
} else if (curPunc == "newblock") {

@@ -344,2 +354,6 @@ if (curKeyword == "function" && ctx && (ctx.type == "statement" || ctx.type == "endgroup")) {

if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
if (hooks.indent) {
var fromHook = hooks.indent(state);
if (fromHook >= 0) return fromHook;
}
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);

@@ -349,5 +363,4 @@ if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;

var possibleClosing = textAfter.match(closingBracketOrWord);
if (possibleClosing) {
if (possibleClosing)
closing = isClosing(possibleClosing[0], ctx.type);
}
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);

@@ -365,9 +378,169 @@ else if (closingBracket.test(ctx.type) && ctx.align && !dontAlignCalls) return ctx.column + (closing ? 0 : 1);

CodeMirror.defineMIME("text/x-verilog", {
name: "verilog"
});
CodeMirror.defineMIME("text/x-systemverilog", {
name: "systemverilog"
});
CodeMirror.defineMIME("text/x-verilog", {
name: "verilog"
});
CodeMirror.defineMIME("text/x-systemverilog", {
name: "verilog"
});
// SVXVerilog mode
var svxchScopePrefixes = {
">": "property", "->": "property", "-": "hr", "|": "link", "?$": "qualifier", "?*": "qualifier",
"@-": "variable-3", "@": "variable-3", "?": "qualifier"
};
function svxGenIndent(stream, state) {
var svxindentUnit = 2;
var rtnIndent = -1, indentUnitRq = 0, curIndent = stream.indentation();
switch (state.svxCurCtlFlowChar) {
case "\\":
curIndent = 0;
break;
case "|":
if (state.svxPrevPrevCtlFlowChar == "@") {
indentUnitRq = -2; //-2 new pipe rq after cur pipe
break;
}
if (svxchScopePrefixes[state.svxPrevCtlFlowChar])
indentUnitRq = 1; // +1 new scope
break;
case "M": // m4
if (state.svxPrevPrevCtlFlowChar == "@") {
indentUnitRq = -2; //-2 new inst rq after pipe
break;
}
if (svxchScopePrefixes[state.svxPrevCtlFlowChar])
indentUnitRq = 1; // +1 new scope
break;
case "@":
if (state.svxPrevCtlFlowChar == "S")
indentUnitRq = -1; // new pipe stage after stmts
if (state.svxPrevCtlFlowChar == "|")
indentUnitRq = 1; // 1st pipe stage
break;
case "S":
if (state.svxPrevCtlFlowChar == "@")
indentUnitRq = 1; // flow in pipe stage
if (svxchScopePrefixes[state.svxPrevCtlFlowChar])
indentUnitRq = 1; // +1 new scope
break;
}
var statementIndentUnit = svxindentUnit;
rtnIndent = curIndent + (indentUnitRq*statementIndentUnit);
return rtnIndent >= 0 ? rtnIndent : curIndent;
}
CodeMirror.defineMIME("text/x-svx", {
name: "verilog",
hooks: {
"\\": function(stream, state) {
var vxIndent = 0, style = false;
var curPunc = stream.string;
if ((stream.sol()) && (/\\SV/.test(stream.string))) {
curPunc = (/\\SVX_version/.test(stream.string))
? "\\SVX_version" : stream.string;
stream.skipToEnd();
if (curPunc == "\\SV" && state.vxCodeActive) {state.vxCodeActive = false;};
if ((/\\SVX/.test(curPunc) && !state.vxCodeActive)
|| (curPunc=="\\SVX_version" && state.vxCodeActive)) {state.vxCodeActive = true;};
style = "keyword";
state.svxCurCtlFlowChar = state.svxPrevPrevCtlFlowChar
= state.svxPrevCtlFlowChar = "";
if (state.vxCodeActive == true) {
state.svxCurCtlFlowChar = "\\";
vxIndent = svxGenIndent(stream, state);
}
state.vxIndentRq = vxIndent;
}
return style;
},
tokenBase: function(stream, state) {
var vxIndent = 0, style = false;
var svxisOperatorChar = /[\[\]=:]/;
var svxkpScopePrefixs = {
"**":"variable-2", "*":"variable-2", "$$":"variable", "$":"variable",
"^^":"attribute", "^":"attribute"};
var ch = stream.peek();
var vxCurCtlFlowCharValueAtStart = state.svxCurCtlFlowChar;
if (state.vxCodeActive == true) {
if (/[\[\]{}\(\);\:]/.test(ch)) {
// bypass nesting and 1 char punc
style = "meta";
stream.next();
} else if (ch == "/") {
stream.next();
if (stream.eat("/")) {
stream.skipToEnd();
style = "comment";
state.svxCurCtlFlowChar = "S";
} else {
stream.backUp(1);
}
} else if (ch == "@") {
// pipeline stage
style = svxchScopePrefixes[ch];
state.svxCurCtlFlowChar = "@";
stream.next();
stream.eatWhile(/[\w\$_]/);
} else if (stream.match(/\b[mM]4+/, true)) { // match: function(pattern, consume, caseInsensitive)
// m4 pre proc
stream.skipTo("(");
style = "def";
state.svxCurCtlFlowChar = "M";
} else if (ch == "!" && stream.sol()) {
// v stmt in svx region
// state.svxCurCtlFlowChar = "S";
style = "comment";
stream.next();
} else if (svxisOperatorChar.test(ch)) {
// operators
stream.eatWhile(svxisOperatorChar);
style = "operator";
} else if (ch == "#") {
// phy hier
state.svxCurCtlFlowChar = (state.svxCurCtlFlowChar == "")
? ch : state.svxCurCtlFlowChar;
stream.next();
stream.eatWhile(/[+-]\d/);
style = "tag";
} else if (svxkpScopePrefixs.propertyIsEnumerable(ch)) {
// special SVX operators
style = svxkpScopePrefixs[ch];
state.svxCurCtlFlowChar = state.svxCurCtlFlowChar == "" ? "S" : state.svxCurCtlFlowChar; // stmt
stream.next();
stream.match(/[a-zA-Z_0-9]+/);
} else if (style = svxchScopePrefixes[ch] || false) {
// special SVX operators
state.svxCurCtlFlowChar = state.svxCurCtlFlowChar == "" ? ch : state.svxCurCtlFlowChar;
stream.next();
stream.match(/[a-zA-Z_0-9]+/);
}
if (state.svxCurCtlFlowChar != vxCurCtlFlowCharValueAtStart) { // flow change
vxIndent = svxGenIndent(stream, state);
state.vxIndentRq = vxIndent;
}
}
return style;
},
token: function(stream, state) {
if (state.vxCodeActive == true && stream.sol() && state.svxCurCtlFlowChar != "") {
state.svxPrevPrevCtlFlowChar = state.svxPrevCtlFlowChar;
state.svxPrevCtlFlowChar = state.svxCurCtlFlowChar;
state.svxCurCtlFlowChar = "";
}
},
indent: function(state) {
return (state.vxCodeActive == true) ? state.vxIndentRq : -1;
},
startState: function(state) {
state.svxCurCtlFlowChar = "";
state.svxPrevCtlFlowChar = "";
state.svxPrevPrevCtlFlowChar = "";
state.vxCodeActive = true;
state.vxIndentRq = 0;
}
}
});
});
{
"name": "codemirror",
"version":"4.12.0",
"version":"4.13.0",
"main": "lib/codemirror.js",

@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable",

# CodeMirror
[![Build Status](https://travis-ci.org/codemirror/CodeMirror.svg)](https://travis-ci.org/codemirror/CodeMirror)
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
[Funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png)](https://marijnhaverbeke.nl/fund/)

@@ -5,0 +6,0 @@ CodeMirror is a JavaScript component that provides a code editor in

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc