codemirror
Advanced tools
Comparing version 3.12.0 to 3.13.0
@@ -22,5 +22,5 @@ (function() { | ||
function clearPlaceholder(cm) { | ||
if (cm._placeholder) { | ||
cm._placeholder.parentNode.removeChild(cm._placeholder); | ||
cm._placeholder = null; | ||
if (cm.state.placeholder) { | ||
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder); | ||
cm.state.placeholder = null; | ||
} | ||
@@ -30,3 +30,3 @@ } | ||
clearPlaceholder(cm); | ||
var elt = cm._placeholder = document.createElement("pre"); | ||
var elt = cm.state.placeholder = document.createElement("pre"); | ||
elt.style.cssText = "height: 0; overflow: visible"; | ||
@@ -33,0 +33,0 @@ elt.className = "CodeMirror-placeholder"; |
@@ -26,5 +26,5 @@ (function() { | ||
}; | ||
var closingBrackets = []; | ||
var closingBrackets = ""; | ||
for (var i = 0; i < pairs.length; i += 2) (function(left, right) { | ||
if (left != right) closingBrackets.push(right); | ||
if (left != right) closingBrackets += right; | ||
function surround(cm) { | ||
@@ -31,0 +31,0 @@ var selection = cm.getSelection(); |
@@ -6,3 +6,9 @@ CodeMirror.braceRangeFinder = function(cm, start) { | ||
var found = lineText.lastIndexOf("{", at); | ||
if (found < start.ch) break; | ||
var startToken = '{', endToken = '}'; | ||
if (found < start.ch) { | ||
found = lineText.lastIndexOf("[", at); | ||
if (found < start.ch) break; | ||
startToken = '['; endToken = ']'; | ||
} | ||
tokenType = cm.getTokenAt(CodeMirror.Pos(line, found + 1)).type; | ||
@@ -12,3 +18,3 @@ if (!/^(comment|string)/.test(tokenType)) { startChar = found; break; } | ||
} | ||
if (startChar == null || lineText.lastIndexOf("}") > startChar) return; | ||
if (startChar == null || lineText.lastIndexOf(startToken) > startChar) return; | ||
var count = 1, lastLine = cm.lineCount(), end, endCh; | ||
@@ -18,3 +24,3 @@ outer: for (var i = line + 1; i < lastLine; ++i) { | ||
for (;;) { | ||
var nextOpen = text.indexOf("{", pos), nextClose = text.indexOf("}", pos); | ||
var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos); | ||
if (nextOpen < 0) nextOpen = text.length; | ||
@@ -21,0 +27,0 @@ if (nextClose < 0) nextClose = text.length; |
@@ -62,3 +62,3 @@ CodeMirror.validate = (function() { | ||
function clearMarks(cm) { | ||
var state = cm._lintState; | ||
var state = cm.state.lint; | ||
if (state.hasGutter) cm.clearGutter(GUTTER_ID); | ||
@@ -109,7 +109,7 @@ for (var i = 0; i < state.marked.length; ++i) | ||
function startLinting(cm) { | ||
var state = cm._lintState, options = state.options; | ||
if (options.async) | ||
options.getAnnotations(cm, updateLinting, options); | ||
else | ||
updateLinting(cm, options.getAnnotations(cm.getValue())); | ||
var state = cm.state.lint, options = state.options; | ||
if (options.async) | ||
options.getAnnotations(cm, updateLinting, options); | ||
else | ||
updateLinting(cm, options.getAnnotations(cm.getValue())); | ||
} | ||
@@ -119,3 +119,3 @@ | ||
clearMarks(cm); | ||
var state = cm._lintState, options = state.options; | ||
var state = cm.state.lint, options = state.options; | ||
@@ -141,3 +141,3 @@ var annotations = groupByLine(annotationsNotSorted); | ||
if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, { | ||
className: "CodeMirror-lint-span-" + severity, | ||
className: "CodeMirror-lint-mark-" + severity, | ||
__annotation: ann | ||
@@ -155,3 +155,3 @@ })); | ||
function onChange(cm) { | ||
var state = cm._lintState; | ||
var state = cm.state.lint; | ||
clearTimeout(state.timeout); | ||
@@ -172,3 +172,3 @@ state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500); | ||
function onMouseOver(cm, e) { | ||
if (!/\bCodeMirror-lint-span-/.test((e.target || e.srcElement).className)) return; | ||
if (!/\bCodeMirror-lint-mark-/.test((e.target || e.srcElement).className)) return; | ||
for (var i = 0; i < nearby.length; i += 2) { | ||
@@ -188,4 +188,4 @@ var spans = cm.findMarksAt(cm.coordsChar({left: e.clientX + nearby[i], | ||
cm.off("change", onChange); | ||
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm._lintState.onMouseOver); | ||
delete cm._lintState; | ||
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver); | ||
delete cm.state.lint; | ||
} | ||
@@ -196,3 +196,3 @@ | ||
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true; | ||
var state = cm._lintState = new LintState(cm, parseOptions(val), hasLintGutter); | ||
var state = cm.state.lint = new LintState(cm, parseOptions(val), hasLintGutter); | ||
cm.on("change", onChange); | ||
@@ -199,0 +199,0 @@ if (state.options.tooltips != false) |
CodeMirror.runMode = function(string, modespec, callback, options) { | ||
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec); | ||
var ie = /MSIE \d/.test(navigator.userAgent); | ||
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9); | ||
@@ -10,3 +12,5 @@ if (callback.nodeType == 1) { | ||
if (text == "\n") { | ||
node.appendChild(document.createElement("br")); | ||
// Emitting LF or CRLF on IE8 or earlier results in an incorrect display. | ||
// Emitting a carriage return makes everything ok. | ||
node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text)); | ||
col = 0; | ||
@@ -13,0 +17,0 @@ return; |
@@ -63,4 +63,16 @@ /* Just enough of CodeMirror to run runMode under node.js */ | ||
var modes = exports.modes = {}, mimeModes = exports.mimeModes = {}; | ||
exports.defineMode = function(name, mode) { modes[name] = mode; }; | ||
exports.defineMode = function(name, mode) { | ||
if (arguments.length > 2) { | ||
mode.dependencies = []; | ||
for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]); | ||
} | ||
modes[name] = mode; | ||
}; | ||
exports.defineMIME = function(mime, spec) { mimeModes[mime] = spec; }; | ||
exports.defineMode("null", function() { | ||
return {token: function(stream) {stream.skipToEnd();}}; | ||
}); | ||
exports.defineMIME("text/plain", "null"); | ||
exports.getMode = function(options, spec) { | ||
@@ -67,0 +79,0 @@ if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) |
@@ -27,8 +27,8 @@ // Highlighting text that matches the selection | ||
if (val && !prev) { | ||
cm._matchHighlightState = new State(val); | ||
cm.state.matchHighlighter = new State(val); | ||
cm.on("cursorActivity", highlightMatches); | ||
} else if (!val && prev) { | ||
var over = cm._matchHighlightState.overlay; | ||
var over = cm.state.matchHighlighter.overlay; | ||
if (over) cm.removeOverlay(over); | ||
cm._matchHighlightState = null; | ||
cm.state.matchHighlighter = null; | ||
cm.off("cursorActivity", highlightMatches); | ||
@@ -40,3 +40,3 @@ } | ||
cm.operation(function() { | ||
var state = cm._matchHighlightState; | ||
var state = cm.state.matchHighlighter; | ||
if (state.overlay) { | ||
@@ -43,0 +43,0 @@ cm.removeOverlay(state.overlay); |
@@ -30,3 +30,3 @@ // Define search commands. Depends on dialog.js or another | ||
function getSearchState(cm) { | ||
return cm._searchState || (cm._searchState = new SearchState()); | ||
return cm.state.search || (cm.state.search = new SearchState()); | ||
} | ||
@@ -33,0 +33,0 @@ function getSearchCursor(cm, query, pos) { |
@@ -27,12 +27,22 @@ (function(){ | ||
start = match.index; | ||
cutOff = match.index + 1; | ||
cutOff = match.index + (match[0].length || 1); | ||
if (cutOff == line.length) break; | ||
} | ||
var matchLen = (match && match[0].length) || 0; | ||
if (!matchLen) { | ||
if (start == 0 && line.length == 0) {match = undefined;} | ||
else if (start != doc.getLine(pos.line).length) { | ||
matchLen++; | ||
} | ||
} | ||
} else { | ||
query.lastIndex = pos.ch; | ||
var line = doc.getLine(pos.line), match = query.exec(line), | ||
start = match && match.index; | ||
var line = doc.getLine(pos.line), match = query.exec(line); | ||
var matchLen = (match && match[0].length) || 0; | ||
var start = match && match.index; | ||
if (start + matchLen != line.length && !matchLen) matchLen = 1; | ||
} | ||
if (match && match[0]) | ||
if (match && matchLen) | ||
return {from: Pos(pos.line, start), | ||
to: Pos(pos.line, start + match[0].length), | ||
to: Pos(pos.line, start + matchLen), | ||
match: match}; | ||
@@ -39,0 +49,0 @@ }; |
@@ -20,3 +20,3 @@ // Because sometimes you need to style the cursor's line. | ||
clearActiveLine(cm); | ||
delete cm._activeLine; | ||
delete cm.state.activeLine; | ||
} | ||
@@ -26,5 +26,5 @@ }); | ||
function clearActiveLine(cm) { | ||
if ("_activeLine" in cm) { | ||
cm.removeLineClass(cm._activeLine, "wrap", WRAP_CLASS); | ||
cm.removeLineClass(cm._activeLine, "background", BACK_CLASS); | ||
if ("activeLine" in cm.state) { | ||
cm.removeLineClass(cm.state.activeLine, "wrap", WRAP_CLASS); | ||
cm.removeLineClass(cm.state.activeLine, "background", BACK_CLASS); | ||
} | ||
@@ -35,8 +35,8 @@ } | ||
var line = cm.getLineHandle(cm.getCursor().line); | ||
if (cm._activeLine == line) return; | ||
if (cm.state.activeLine == line) return; | ||
clearActiveLine(cm); | ||
cm.addLineClass(line, "wrap", WRAP_CLASS); | ||
cm.addLineClass(line, "background", BACK_CLASS); | ||
cm._activeLine = line; | ||
cm.state.activeLine = line; | ||
} | ||
})(); |
// Because sometimes you need to mark the selected *text*. | ||
// | ||
// Adds an option 'styleSelectedText' which, when enabled, gives | ||
// selected text the CSS class "CodeMirror-selectedtext". | ||
// selected text the CSS class given as option value, or | ||
// "CodeMirror-selectedtext" when the value is not a string. | ||
@@ -12,24 +13,97 @@ (function() { | ||
if (val && !prev) { | ||
updateSelectedText(cm); | ||
cm.on("cursorActivity", updateSelectedText); | ||
cm.state.markedSelection = []; | ||
cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext"; | ||
reset(cm); | ||
cm.on("cursorActivity", onCursorActivity); | ||
cm.on("change", onChange); | ||
} else if (!val && prev) { | ||
cm.off("cursorActivity", updateSelectedText); | ||
clearSelectedText(cm); | ||
delete cm._selectionMark; | ||
cm.off("cursorActivity", onCursorActivity); | ||
cm.off("change", onChange); | ||
clear(cm); | ||
cm.state.markedSelection = cm.state.markedSelectionStyle = null; | ||
} | ||
}); | ||
function clearSelectedText(cm) { | ||
if (cm._selectionMark) cm._selectionMark.clear(); | ||
function onCursorActivity(cm) { | ||
cm.operation(function() { update(cm); }); | ||
} | ||
function updateSelectedText(cm) { | ||
clearSelectedText(cm); | ||
function onChange(cm) { | ||
if (cm.state.markedSelection.length) | ||
cm.operation(function() { clear(cm); }); | ||
} | ||
if (cm.somethingSelected()) | ||
cm._selectionMark = cm.markText(cm.getCursor("start"), cm.getCursor("end"), | ||
{className: "CodeMirror-selectedtext"}); | ||
else | ||
cm._selectionMark = null; | ||
var CHUNK_SIZE = 8; | ||
var Pos = CodeMirror.Pos; | ||
function cmp(pos1, pos2) { | ||
return pos1.line - pos2.line || pos1.ch - pos2.ch; | ||
} | ||
function coverRange(cm, from, to, addAt) { | ||
if (cmp(from, to) == 0) return; | ||
var array = cm.state.markedSelection; | ||
var cls = cm.state.markedSelectionStyle; | ||
for (var line = from.line;;) { | ||
var start = line == from.line ? from : Pos(line, 0); | ||
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line; | ||
var end = atEnd ? to : Pos(endLine, 0); | ||
var mark = cm.markText(start, end, {className: cls}); | ||
if (addAt == null) array.push(mark); | ||
else array.splice(addAt++, 0, mark); | ||
if (atEnd) break; | ||
line = endLine; | ||
} | ||
} | ||
function clear(cm) { | ||
var array = cm.state.markedSelection; | ||
for (var i = 0; i < array.length; ++i) array[i].clear(); | ||
array.length = 0; | ||
} | ||
function reset(cm) { | ||
clear(cm); | ||
var from = cm.getCursor("start"), to = cm.getCursor("end"); | ||
coverRange(cm, from, to); | ||
} | ||
function update(cm) { | ||
var from = cm.getCursor("start"), to = cm.getCursor("end"); | ||
if (cmp(from, to) == 0) return clear(cm); | ||
var array = cm.state.markedSelection; | ||
if (!array.length) return coverRange(cm, from, to); | ||
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find(); | ||
if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE || | ||
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0) | ||
return reset(cm); | ||
while (cmp(from, coverStart.from) > 0) { | ||
array.shift().clear(); | ||
coverStart = array[0].find(); | ||
} | ||
if (cmp(from, coverStart.from) < 0) { | ||
if (coverStart.to.line - from.line < CHUNK_SIZE) { | ||
array.shift().clear(); | ||
coverRange(cm, from, coverStart.to, 0); | ||
} else { | ||
coverRange(cm, from, coverStart.from, 0); | ||
} | ||
} | ||
while (cmp(to, coverEnd.to) < 0) { | ||
array.pop().clear(); | ||
coverEnd = array[array.length - 1].find(); | ||
} | ||
if (cmp(to, coverEnd.to) > 0) { | ||
if (to.line - coverEnd.from.line < CHUNK_SIZE) { | ||
array.pop().clear(); | ||
coverRange(cm, coverEnd.from, to); | ||
} else { | ||
coverRange(cm, coverEnd.to, to); | ||
} | ||
} | ||
} | ||
})(); |
@@ -153,8 +153,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { | ||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit); | ||
else if (dontAlignCalls && ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit; | ||
else if (ctx.align) return ctx.column + (closing ? 0 : 1); | ||
else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1); | ||
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit; | ||
else return ctx.indented + (closing ? 0 : indentUnit); | ||
}, | ||
electricChars: "{}" | ||
electricChars: "{}", | ||
blockCommentStart: "/*", | ||
blockCommentEnd: "*/", | ||
lineComment: "//" | ||
}; | ||
@@ -161,0 +164,0 @@ }); |
@@ -218,3 +218,5 @@ /** | ||
return state.indentStack.indent; | ||
} | ||
}, | ||
lineComment: ";;" | ||
}; | ||
@@ -221,0 +223,0 @@ }); |
@@ -340,4 +340,5 @@ /** | ||
return state.scopes[0].offset; | ||
} | ||
}, | ||
lineComment: "#" | ||
}; | ||
@@ -344,0 +345,0 @@ return external; |
@@ -97,3 +97,7 @@ CodeMirror.defineMode("commonlisp", function (config) { | ||
return typeof i == "number" ? i : state.ctx.start + 1; | ||
} | ||
}, | ||
lineComment: ";;", | ||
blockCommentStart: "#|", | ||
blockCommentEnd: "|#" | ||
}; | ||
@@ -100,0 +104,0 @@ }); |
@@ -168,6 +168,7 @@ CodeMirror.defineMode("css", function(config) { | ||
} else if (style == "property") { | ||
if (context == "propertyValue"){ | ||
if (valueKeywords[stream.current()]) { | ||
var word = stream.current().toLowerCase(); | ||
if (context == "propertyValue") { | ||
if (valueKeywords.hasOwnProperty(word)) { | ||
style = "string-2"; | ||
} else if (colorKeywords[stream.current()]) { | ||
} else if (colorKeywords.hasOwnProperty(word)) { | ||
style = "keyword"; | ||
@@ -178,3 +179,3 @@ } else { | ||
} else if (context == "rule") { | ||
if (!propertyKeywords[stream.current()]) { | ||
if (!propertyKeywords.hasOwnProperty(word)) { | ||
style += " error"; | ||
@@ -185,7 +186,7 @@ } | ||
// of preference is property -> color -> value | ||
if (propertyKeywords[stream.current()]) { | ||
if (propertyKeywords.hasOwnProperty(word)) { | ||
style = "property"; | ||
} else if (colorKeywords[stream.current()]) { | ||
} else if (colorKeywords.hasOwnProperty(word)) { | ||
style = "keyword"; | ||
} else if (valueKeywords[stream.current()]) { | ||
} else if (valueKeywords.hasOwnProperty(word)) { | ||
style = "string-2"; | ||
@@ -200,7 +201,7 @@ } else { | ||
style = "attribute"; // Known attribute | ||
} else if (/^(only|not)$/i.test(stream.current())) { | ||
} else if (/^(only|not)$/.test(word)) { | ||
style = "keyword"; | ||
} else if (stream.current().toLowerCase() == "and") { | ||
} else if (word == "and") { | ||
style = "error"; // "and" is only allowed in @mediaType | ||
} else if (atMediaFeatures[stream.current()]) { | ||
} else if (atMediaFeatures.hasOwnProperty(word)) { | ||
style = "error"; // Known property, should be in @mediaType( | ||
@@ -212,10 +213,8 @@ } else { | ||
} else if (context == "@mediaType") { | ||
if (atMediaTypes[stream.current()]) { | ||
if (atMediaTypes.hasOwnProperty(word)) { | ||
style = "attribute"; | ||
} else if (stream.current().toLowerCase() == "and") { | ||
} else if (word == "and") { | ||
style = "operator"; | ||
} else if (/^(only|not)$/i.test(stream.current())) { | ||
} else if (/^(only|not)$/.test(word)) { | ||
style = "error"; // Only allowed in @media | ||
} else if (atMediaFeatures[stream.current()]) { | ||
style = "error"; // Known property, should be in parentheses | ||
} else { | ||
@@ -227,9 +226,9 @@ // Unknown attribute or property, but expecting property (preceded | ||
} else if (context == "@mediaType(") { | ||
if (propertyKeywords[stream.current()]) { | ||
if (propertyKeywords.hasOwnProperty(word)) { | ||
// do nothing, remains "property" | ||
} else if (atMediaTypes[stream.current()]) { | ||
} else if (atMediaTypes.hasOwnProperty(word)) { | ||
style = "error"; // Known property, should be in parentheses | ||
} else if (stream.current().toLowerCase() == "and") { | ||
} else if (word == "and") { | ||
style = "operator"; | ||
} else if (/^(only|not)$/i.test(stream.current())) { | ||
} else if (/^(only|not)$/.test(word)) { | ||
style = "error"; // Only allowed in @media | ||
@@ -239,2 +238,4 @@ } else { | ||
} | ||
} else if (context == "@import") { | ||
style = "tag"; | ||
} else { | ||
@@ -276,2 +277,3 @@ style = "error"; | ||
else if (type == "@media") state.stack.push("@media"); | ||
else if (type == "@import") state.stack.push("@import"); | ||
else if (context == "@media" && /\b(keyword|attribute)\b/.test(style)) | ||
@@ -284,2 +286,3 @@ state.stack.push("@mediaType"); | ||
else if (context == "propertyValue" && type == ";") state.stack.pop(); | ||
else if (context == "@import" && type == ";") state.stack.pop(); | ||
return style; | ||
@@ -295,3 +298,5 @@ }, | ||
electricChars: "}" | ||
electricChars: "}", | ||
blockCommentStart: "/*", | ||
blockCommentEnd: "*/" | ||
}; | ||
@@ -400,8 +405,42 @@ }); | ||
"voice-volume", "volume", "white-space", "widows", "width", "word-break", | ||
"word-spacing", "word-wrap", "z-index" | ||
"word-spacing", "word-wrap", "z-index", | ||
// SVG-specific | ||
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", | ||
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", | ||
"color-interpolation", "color-interpolation-filters", "color-profile", | ||
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", | ||
"marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke", | ||
"stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", | ||
"stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering", | ||
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", | ||
"glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode" | ||
]); | ||
var colorKeywords = keySet([ | ||
"black", "silver", "gray", "white", "maroon", "red", "purple", "fuchsia", | ||
"green", "lime", "olive", "yellow", "navy", "blue", "teal", "aqua" | ||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", | ||
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", | ||
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", | ||
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", | ||
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", | ||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", | ||
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet", | ||
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", | ||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", | ||
"gold", "goldenrod", "gray", "green", "greenyellow", "honeydew", | ||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", | ||
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", | ||
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", | ||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", | ||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", | ||
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", | ||
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", | ||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", | ||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", | ||
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", | ||
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", | ||
"purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", | ||
"sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", | ||
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", | ||
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", | ||
"whitesmoke", "yellow", "yellowgreen" | ||
]); | ||
@@ -489,3 +528,3 @@ | ||
"vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", | ||
"visibleStroke", "visual", "w-resize", "wait", "wave", "white", "wider", | ||
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider", | ||
"window", "windowframe", "windowtext", "x-large", "x-small", "xor", | ||
@@ -492,0 +531,0 @@ "xx-large", "xx-small" |
@@ -459,6 +459,7 @@ // block; "begin", "case", "fun", "if", "receive", "try": closed by "end" | ||
function(state, textAfter) { | ||
// console.log(state.tokenStack); | ||
return myIndent(state,textAfter); | ||
} | ||
}, | ||
lineComment: "%" | ||
}; | ||
}); |
@@ -324,4 +324,8 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) { | ||
} | ||
} | ||
}, | ||
lineComment: lineCommentStartSymbol, | ||
blockCommentStart: "/*", | ||
blockCommentEnd: "*/" | ||
}; | ||
}); |
@@ -161,3 +161,6 @@ CodeMirror.defineMode("go", function(config) { | ||
electricChars: "{}:" | ||
electricChars: "{}:", | ||
blockCommentStart: "/*", | ||
blockCommentEnd: "*/", | ||
lineComment: "//" | ||
}; | ||
@@ -164,0 +167,0 @@ }); |
@@ -237,3 +237,7 @@ CodeMirror.defineMode("haskell", function() { | ||
return (w in wellKnownWords) ? wellKnownWords[w] : t; | ||
} | ||
}, | ||
blockCommentStart: "{-", | ||
blockCommentEnd: "-}", | ||
lineComment: "--" | ||
}; | ||
@@ -240,0 +244,0 @@ |
@@ -294,3 +294,3 @@ // TODO actually recognize syntax of TypeScript constructs | ||
function maybeoperatorComma(type, value) { | ||
if (type == ",") return cont(expression); | ||
if (type == ",") return pass(); | ||
return maybeoperatorNoComma(type, value, maybeoperatorComma); | ||
@@ -457,2 +457,5 @@ } | ||
electricChars: ":{}", | ||
blockCommentStart: jsonMode ? null : "/*", | ||
blockCommentEnd: jsonMode ? null : "*/", | ||
lineComment: jsonMode ? null : "//", | ||
@@ -468,3 +471,4 @@ jsonMode: jsonMode | ||
CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); | ||
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true}); | ||
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); | ||
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); |
@@ -10,9 +10,3 @@ /* | ||
function ret(style, tp) {type = tp; return style;} | ||
//html tags | ||
var tags = "a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption cite code col colgroup command datalist dd del details dfn dir div dl dt em embed fieldset figcaption figure font footer form frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins keygen kbd label legend li link map mark menu meta meter nav noframes noscript object ol optgroup option output p param pre progress q rp rt ruby s samp script section select small source span strike strong style sub summary sup table tbody td textarea tfoot th thead time title tr track tt u ul var video wbr".split(' '); | ||
function inTagsArray(val){ | ||
for(var i=0; i<tags.length; i++)if(val === tags[i])return true; | ||
} | ||
var selectors = /(^\:root$|^\:nth\-child$|^\:nth\-last\-child$|^\:nth\-of\-type$|^\:nth\-last\-of\-type$|^\:first\-child$|^\:last\-child$|^\:first\-of\-type$|^\:last\-of\-type$|^\:only\-child$|^\:only\-of\-type$|^\:empty$|^\:link|^\:visited$|^\:active$|^\:hover$|^\:focus$|^\:target$|^\:lang$|^\:enabled^\:disabled$|^\:checked$|^\:first\-line$|^\:first\-letter$|^\:before$|^\:after$|^\:not$|^\:required$|^\:invalid$)/; | ||
@@ -139,4 +133,2 @@ | ||
return ret("number", "unit"); | ||
}else if( inTagsArray(stream.current().toLowerCase()) ){ // match html tags | ||
return ret("tag", "tag"); | ||
}else if( /\/|[\s\)]/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == "/")) && stream.current().indexOf(".") !== -1){ | ||
@@ -143,0 +135,0 @@ if(stream.current().substring(stream.current().length-1,stream.current().length) == "{"){ |
@@ -136,3 +136,7 @@ // LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's | ||
return state.basecol + indentUnit * (state.indentDepth - (closing ? 1 : 0)); | ||
} | ||
}, | ||
lineComment: "--", | ||
blockCommentStart: "--[[", | ||
blockCommentEnd: "]]" | ||
}; | ||
@@ -139,0 +143,0 @@ }); |
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { | ||
var htmlFound = CodeMirror.mimeModes.hasOwnProperty("text/html"); | ||
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? "text/html" : "text/plain"); | ||
var htmlFound = CodeMirror.modes.hasOwnProperty("xml"); | ||
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain"); | ||
var aliases = { | ||
@@ -6,0 +6,0 @@ html: "htmlmixed", |
@@ -6,2 +6,3 @@ CodeMirror.modeInfo = [ | ||
{name: 'C++', mime: 'text/x-c++src', mode: 'clike'}, | ||
{name: 'Cobol', mime: 'text/x-cobol', mode: 'cobol'}, | ||
{name: 'Java', mime: 'text/x-java', mode: 'clike'}, | ||
@@ -30,2 +31,3 @@ {name: 'C#', mime: 'text/x-csharp', mode: 'clike'}, | ||
{name: 'JavaScript', mime: 'text/javascript', mode: 'javascript'}, | ||
{name: 'JSON', mime: 'application/x-json', mode: 'javascript'}, | ||
{name: 'JSON', mime: 'application/json', mode: 'javascript'}, | ||
@@ -32,0 +34,0 @@ {name: 'TypeScript', mime: 'application/typescript', mode: 'javascript'}, |
@@ -109,3 +109,6 @@ CodeMirror.defineMode('ocaml', function() { | ||
return state.tokenize(stream, state); | ||
} | ||
}, | ||
blockCommentStart: "(*", | ||
blockCommentEnd: "*)" | ||
}; | ||
@@ -112,0 +115,0 @@ }); |
@@ -121,2 +121,5 @@ (function() { | ||
electricChars: "/{}:", | ||
blockCommentStart: "/*", | ||
blockCommentEnd: "*/", | ||
lineComment: "//", | ||
@@ -123,0 +126,0 @@ innerMode: function(state) { return {state: state.curState, mode: state.curMode}; } |
@@ -334,4 +334,5 @@ CodeMirror.defineMode("python", function(conf, parserConf) { | ||
return state.scopes[0].offset; | ||
} | ||
}, | ||
lineComment: "#" | ||
}; | ||
@@ -338,0 +339,0 @@ return external; |
@@ -189,4 +189,5 @@ CodeMirror.defineMode("ruby", function(config) { | ||
}, | ||
electricChars: "}de" // enD and rescuE | ||
electricChars: "}de", // enD and rescuE | ||
lineComment: "#" | ||
}; | ||
@@ -193,0 +194,0 @@ }); |
@@ -428,3 +428,6 @@ CodeMirror.defineMode("rust", function() { | ||
electricChars: "{}" | ||
electricChars: "{}", | ||
blockCommentStart: "/*", | ||
blockCommentEnd: "*/", | ||
lineComment: "//" | ||
}; | ||
@@ -431,0 +434,0 @@ }); |
@@ -6,3 +6,2 @@ CodeMirror.defineMode("sass", function(config) { | ||
var tags = ["&", "a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","keygen","kbd","label","legend","li","link","map","mark","menu","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr"]; | ||
var keywords = ["true", "false", "null", "auto"]; | ||
@@ -14,14 +13,4 @@ var keywordsRegexp = new RegExp("^" + keywords.join("|")); | ||
function htmlTag(val){ | ||
for(var i=0; i<tags.length; i++){ | ||
if(val === tags[i]){ | ||
return true; | ||
} | ||
} | ||
} | ||
var pseudoElementsRegexp = /^::?[\w\-]+/; | ||
var pseudoElements = [':first-line', ':hover', ':first-letter', ':active', ':visited', ':before', ':after', ':link', ':focus', ':first-child', ':lang']; | ||
var pseudoElementsRegexp = new RegExp("^(" + pseudoElements.join("\\b|") + ")"); | ||
var urlTokens = function(stream, state){ | ||
@@ -261,3 +250,3 @@ var ch = stream.peek(); | ||
// Pseudo element selectors | ||
if (stream.match(pseudoElementsRegexp)){ | ||
if (ch == ':' && stream.match(pseudoElementsRegexp)){ | ||
return "keyword"; | ||
@@ -268,15 +257,7 @@ } | ||
if (stream.eatWhile(/[\w-&]/)){ | ||
var current = stream.current(); | ||
// matches a property definition | ||
if (stream.peek() === ":"){ | ||
// if this is an html tag and it has a pseudo selector, then it's an atom | ||
if (htmlTag(current) && stream.match(pseudoElementsRegexp, false)){ | ||
return "atom"; | ||
}else{ | ||
stream.next(); | ||
return "property"; | ||
} | ||
} | ||
return "atom"; | ||
if (stream.peek() === ":" && !stream.match(pseudoElementsRegexp, false)) | ||
return "property"; | ||
else | ||
return "atom"; | ||
} | ||
@@ -305,3 +286,3 @@ | ||
if (style === "atom" && htmlTag(current)){ | ||
if (style === "atom"){ | ||
indent(state); | ||
@@ -320,3 +301,3 @@ } | ||
if (scope.offset <= withCurrentIndent){ | ||
newScopes.push(scope); | ||
newScopes.push(scope); | ||
} | ||
@@ -323,0 +304,0 @@ } |
@@ -226,3 +226,5 @@ /** | ||
return state.indentStack.indent; | ||
} | ||
}, | ||
lineComment: ";;" | ||
}; | ||
@@ -229,0 +231,0 @@ }); |
CodeMirror.defineMode('smalltalk', function(config) { | ||
var specialChars = /[+\-\/\\*~<>=@%|&?!.:;^]/; | ||
var specialChars = /[+\-\/\\*~<>=@%|&?!.,:;^]/; | ||
var keywords = /true|false|nil|self|super|thisContext/; | ||
@@ -39,7 +39,10 @@ | ||
} else if (aChar === '#') { | ||
stream.eatWhile(/[^ .]/); | ||
stream.eatWhile(/[^ .\[\]()]/); | ||
token.name = 'string-2'; | ||
} else if (aChar === '$') { | ||
stream.eatWhile(/[^ ]/); | ||
if (stream.next() === '<') { | ||
stream.eatWhile(/[^ >]/); | ||
stream.next(); | ||
} | ||
token.name = 'string-2'; | ||
@@ -122,3 +125,2 @@ | ||
state.lastToken = token; | ||
return token.name; | ||
@@ -125,0 +127,0 @@ }, |
@@ -54,3 +54,3 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { | ||
// .1 for 0.1 | ||
if (stream.match(/^[0-9eE]+/) && support.zerolessFloat == true) { | ||
if (support.zerolessFloat == true && stream.match(/^(?:\d+(?:e\d*)?|\d*e\d+)/i)) { | ||
return "number"; | ||
@@ -170,6 +170,5 @@ } | ||
function hookIdentifier(stream) { | ||
var escaped = false, ch; | ||
var ch; | ||
while ((ch = stream.next()) != null) { | ||
if (ch == "`" && !escaped) return "variable-2"; | ||
escaped = !escaped && ch == "`"; | ||
if (ch == "`" && !stream.eat("`")) return "variable-2"; | ||
} | ||
@@ -176,0 +175,0 @@ return null; |
@@ -98,3 +98,3 @@ /* | ||
// white space control characters | ||
if (source.match(/^\\[,;!\/]/)) { | ||
if (source.match(/^\\[,;!\/\\]/)) { | ||
return "tag"; | ||
@@ -101,0 +101,0 @@ } |
@@ -117,2 +117,5 @@ (function() { | ||
"[variable-2 y][keyword $] other text"); | ||
MT("lineBreakArgument", | ||
"[tag \\\\][bracket [[][atom 1cm][bracket ]]]"); | ||
})(); |
@@ -320,2 +320,4 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { | ||
electricChars: "/", | ||
blockCommentStart: "<!--", | ||
blockCommentEnd: "-->", | ||
@@ -322,0 +324,0 @@ configuration: parserConfig.htmlMode ? "html" : "xml" |
@@ -12,3 +12,5 @@ CodeMirror.defineMode("yaml", function() { | ||
/* comments */ | ||
if (ch == "#") { stream.skipToEnd(); return "comment"; } | ||
if (ch == "#" && (stream.pos == 0 || /\s/.test(stream.string.charAt(stream.pos - 1)))) { | ||
stream.skipToEnd(); return "comment"; | ||
} | ||
if (state.literal && stream.indentation() > state.keyCol) { | ||
@@ -15,0 +17,0 @@ stream.skipToEnd(); return "string"; |
{ | ||
"name": "codemirror", | ||
"version":"3.12.00", | ||
"version":"3.13.00", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable", |
@@ -26,4 +26,5 @@ var tests = [], debug = null, debugUsed = new Array(), allNames = []; | ||
} | ||
var namespace = ""; | ||
function testCM(name, run, opts, expectedFail) { | ||
return test("core_" + name, function() { | ||
return test(namespace + name, function() { | ||
var place = document.getElementById("testground"), cm = CodeMirror(place, opts); | ||
@@ -30,0 +31,0 @@ var successful = false; |
@@ -35,2 +35,4 @@ var Pos = CodeMirror.Pos; | ||
namespace = "core_"; | ||
test("core_fromTextArea", function() { | ||
@@ -1017,3 +1019,4 @@ var te = document.getElementById("code"); | ||
forEach(["خحج", "خحabcخحج", "abخحخحجcd", "abخde", "abخح2342خ1حج", "خ1ح2خح3حxج", | ||
"خحcd", "1خحcd", "abcdeح1ج", "خمرحبها مها!", "foobarر"], function(line) { | ||
"خحcd", "1خحcd", "abcdeح1ج", "خمرحبها مها!", "foobarر", | ||
"<img src=\"/בדיקה3.jpg\">"], function(line) { | ||
var inv = line.charAt(0) == "خ"; | ||
@@ -1020,0 +1023,0 @@ cm.setValue(line + "\n"); cm.execCommand(inv ? "goLineEnd" : "goLineStart"); |
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 not supported yet
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 not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
284
34126
2071931