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 5.9.0 to 5.10.0

.npmignore

7

addon/hint/show-hint.js

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

if (completion.options.completeOnSingleClick)
CodeMirror.on(hints, "mousemove", function(e) {
var elt = getHintElement(hints, e.target || e.srcElement);
if (elt && elt.hintId != null)
widget.changeActive(elt.hintId);
});
CodeMirror.signal(data, "select", completions[0], hints.firstChild);

@@ -307,0 +300,0 @@ return true;

2

addon/mode/simple.js

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

if (!states.hasOwnProperty(name))
throw new Error("Undefined state " + name + "in simple mode");
throw new Error("Undefined state " + name + " in simple mode");
}

@@ -66,0 +66,0 @@

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

if (callback.nodeType == 1) {
if (callback.appendChild) {
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;

@@ -22,0 +22,0 @@ var node = callback, col = 0;

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

elt.className = this.options.className;
if (ann.id) {
elt.setAttribute("annotation-id", ann.id);
}
}

@@ -105,0 +108,0 @@ this.div.textContent = "";

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

function insertLine(cm, above) {
if (cm.isReadOnly()) return CodeMirror.Pass
cm.operation(function() {

@@ -127,5 +128,5 @@ var len = cm.listSelections().length, newSelection = [], last = -1;

cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { insertLine(cm, false); };
cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { return insertLine(cm, false); };
cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { insertLine(cm, true); };
cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { return insertLine(cm, true); };

@@ -197,2 +198,3 @@ function wordAt(cm, pos) {

cmds[map[swapLineCombo + "Up"] = "swapLineUp"] = function(cm) {
if (cm.isReadOnly()) return CodeMirror.Pass
var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = [];

@@ -224,2 +226,3 @@ for (var i = 0; i < ranges.length; i++) {

cmds[map[swapLineCombo + "Down"] = "swapLineDown"] = function(cm) {
if (cm.isReadOnly()) return CodeMirror.Pass
var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;

@@ -247,3 +250,3 @@ for (var i = ranges.length - 1; i >= 0; i--) {

map[ctrl + "/"] = function(cm) {
cmds[map[ctrl + "/"] = "toggleCommentIndented"] = function(cm) {
cm.toggleComment({ indent: true });

@@ -297,2 +300,3 @@ }

function sortLines(cm, caseSensitive) {
if (cm.isReadOnly()) return CodeMirror.Pass
var ranges = cm.listSelections(), toSort = [], selected;

@@ -299,0 +303,0 @@ for (var i = 0; i < ranges.length; i++) {

@@ -265,17 +265,16 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

function cppHook(stream, state) {
if (!state.startOfLine) return false;
for (;;) {
if (stream.skipTo("\\")) {
stream.next();
if (stream.eol()) {
state.tokenize = cppHook;
break;
}
} else {
stream.skipToEnd();
state.tokenize = null;
break;
if (!state.startOfLine) return false
for (var ch, next = null; ch = stream.peek();) {
if (!ch) {
break
} else if (ch == "\\" && stream.match(/^.$/)) {
next = cppHook
break
} else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) {
break
}
stream.next()
}
return "meta";
state.tokenize = next
return "meta"
}

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

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

CodeMirror.defineMode("css", function(config, parserConfig) {
var provided = parserConfig;
var inline = parserConfig.inline
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
parserConfig.inline = provided.inline;

@@ -372,5 +371,5 @@ var indentUnit = config.indentUnit,

return {tokenize: null,
state: parserConfig.inline ? "block" : "top",
state: inline ? "block" : "top",
stateArg: null,
context: new Context(parserConfig.inline ? "block" : "top", base || 0, null)};
context: new Context(inline ? "block" : "top", base || 0, null)};
},

@@ -377,0 +376,0 @@

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

"urlizetrunc", "wordcount", "wordwrap", "yesno"],
operators = ["==", "!=", "<", ">", "<=", ">=", "in", "not", "or", "and"];
operators = ["==", "!=", "<", ">", "<=", ">="],
wordOperators = ["in", "not", "or", "and"];

@@ -44,2 +45,3 @@ keywords = new RegExp("^\\b(" + keywords.join("|") + ")\\b");

operators = new RegExp("^\\b(" + operators.join("|") + ")\\b");
wordOperators = new RegExp("^\\b(" + wordOperators.join("|") + ")\\b");

@@ -275,2 +277,7 @@ // We have to return "null" instead of null, in order to avoid string

// Attempt to match a word operator
if (stream.match(wordOperators)) {
return "keyword";
}
// Attempt to match a keyword

@@ -277,0 +284,0 @@ var keywordMatch = stream.match(keywords);

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

if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
mod(require("../../lib/codemirror"), require("../../addon/mode/simple"), require("../../addon/mode/multiplex"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
define(["../../lib/codemirror", "../../addon/mode/simple", "../../addon/mode/multiplex"], mod);
else // Plain browser env

@@ -15,3 +15,3 @@ mod(CodeMirror);

CodeMirror.defineSimpleMode("handlebars", {
CodeMirror.defineSimpleMode("handlebars-tags", {
start: [

@@ -54,3 +54,12 @@ { regex: /\{\{!--/, push: "dash_comment", token: "comment" },

CodeMirror.defineMode("handlebars", function(config, parserConfig) {
var handlebars = CodeMirror.getMode(config, "handlebars-tags");
if (!parserConfig || !parserConfig.base) return handlebars;
return CodeMirror.multiplexingMode(
CodeMirror.getMode(config, parserConfig.base),
{open: "{{", close: "}}", mode: handlebars, parseDelimiters: true}
);
});
CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");
});

@@ -48,12 +48,17 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

// object-like things
"interface": kw("interface"),
"extends": kw("extends"),
"constructor": kw("constructor"),
"interface": kw("class"),
"implements": C,
"namespace": C,
"module": kw("module"),
"enum": kw("module"),
// scope modifiers
"public": kw("public"),
"private": kw("private"),
"protected": kw("protected"),
"static": kw("static"),
"public": kw("modifier"),
"private": kw("modifier"),
"protected": kw("modifier"),
"abstract": kw("modifier"),
// operators
"as": operator,
// types

@@ -125,3 +130,4 @@ "string": type, "number": type, "boolean": type, "any": type

return ret("comment", "comment");
} else if (/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:])$/.test(state.lastType)) {
} else if (/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:])$/.test(state.lastType) ||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - 1)))) {
readRegexp(stream);

@@ -360,2 +366,3 @@ stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);

if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
return pass(pushlex("stat"), expression, expect(";"), poplex);

@@ -465,2 +472,4 @@ }

return cont(afterprop);
} else if (type == "modifier") {
return cont(objprop)
} else if (type == "[") {

@@ -518,2 +527,3 @@ return cont(expression, expect("]"), afterprop);

function pattern(type, value) {
if (type == "modifier") return cont(pattern)
if (type == "variable") { register(value); return cont(); }

@@ -520,0 +530,0 @@ if (type == "spread") return cont(pattern);

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

function footnoteLink(stream, state) {
if (stream.match(/^[^\]]*\]:/, false)) {
if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
state.f = footnoteLinkInside;

@@ -643,3 +643,3 @@ stream.next(); // Consume [

stream.match(/^[^\]]+/, true);
stream.match(/^([^\]\\]|\\.)+/, true);

@@ -646,0 +646,0 @@ return tokenTypes.linkText;

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

{name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
{name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
{name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},

@@ -33,0 +34,0 @@ {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},

@@ -72,7 +72,7 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

function wordRegexpBoundary(pWords) {
return new RegExp("\\b((" + pWords.join(")|(") + "))\\b", "i");
return new RegExp("\\b(" + pWords.join("|") + ")\\b", "i");
}
function wordRegexp(pWords) {
return new RegExp("((" + pWords.join(")|(") + "))", "i");
return new RegExp("(" + pWords.join("|") + ")", "i");
}

@@ -79,0 +79,0 @@

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

return context.indent + (closing ? 0 : indentUnit);
}
},
lineComment: "#"
};

@@ -171,0 +173,0 @@ });

@@ -16,185 +16,145 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others

function trim(str) { return /^\s*(.*?)\s*$/.exec(str)[1] }
function wordSet(words) {
var set = {}
for (var i = 0; i < words.length; i++) set[words[i]] = true
return set
}
var separators = [" ","\\\+","\\\-","\\\(","\\\)","\\\*","/",":","\\\?","\\\<","\\\>"," ","\\\."]
var tokens = new RegExp(separators.join("|"),"g")
var keywords = wordSet(["var","let","class","deinit","enum","extension","func","import","init","protocol",
"static","struct","subscript","typealias","as","dynamicType","is","new","super",
"self","Self","Type","__COLUMN__","__FILE__","__FUNCTION__","__LINE__","break","case",
"continue","default","do","else","fallthrough","if","in","for","return","switch",
"where","while","associativity","didSet","get","infix","inout","left","mutating",
"none","nonmutating","operator","override","postfix","precedence","prefix","right",
"set","unowned","weak","willSet"])
var definingKeywords = wordSet(["var","let","class","enum","extension","func","import","protocol","struct",
"typealias","dynamicType","for"])
var atoms = wordSet(["Infinity","NaN","undefined","null","true","false","on","off","yes","no","nil","null",
"this","super"])
var types = wordSet(["String","bool","int","string","double","Double","Int","Float","float","public",
"private","extension"])
var operators = "+-/*%=|&<>#"
var punc = ";,.(){}[]"
var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/
var number = /^-?(?:(?:[\d_]+\.[_\d]*|\.[_\d]+|0o[0-7_\.]+|0b[01_\.]+)(?:e-?[\d_]+)?|0x[\d_a-f\.]+(?:p-?[\d_]+)?)/i
var identifier = /^[_A-Za-z$][_A-Za-z$0-9]*/
var property = /^[@\.][_A-Za-z$][_A-Za-z$0-9]*/
var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\//
function getWord(string, pos) {
var index = -1, count = 1
var words = string.split(tokens)
for (var i = 0; i < words.length; i++) {
for(var j = 1; j <= words[i].length; j++) {
if (count==pos) index = i
count++
function tokenBase(stream, state, prev) {
if (stream.eatSpace()) return null
var ch = stream.peek()
if (ch == "/") {
if (stream.match("//")) {
stream.skipToEnd()
return "comment"
}
count++
if (stream.match("/*")) {
state.tokenize.push(tokenComment)
return tokenComment(stream, state)
}
if (stream.match(regexp)) return "string-2"
}
var ret = ["", ""]
if (pos == 0) {
ret[1] = words[0]
ret[0] = null
} else {
ret[1] = words[index]
ret[0] = words[index-1]
if (operators.indexOf(ch) > -1) {
stream.next()
return "operator"
}
return ret
if (punc.indexOf(ch) > -1) {
stream.match(delimiters)
return "punctuation"
}
if (ch == '"' || ch == "'") {
stream.next()
var tokenize = tokenString(ch)
state.tokenize.push(tokenize)
return tokenize(stream, state)
}
if (stream.match(number)) return "number"
if (stream.match(property)) return "property"
if (stream.match(identifier)) {
var ident = stream.current()
if (keywords.hasOwnProperty(ident)) {
if (definingKeywords.hasOwnProperty(ident))
state.prev = "define"
return "keyword"
}
if (types.hasOwnProperty(ident)) return "variable-2"
if (atoms.hasOwnProperty(ident)) return "atom"
if (prev == "define") return "def"
return "variable"
}
stream.next()
return null
}
CodeMirror.defineMode("swift", function() {
var keywords=["var","let","class","deinit","enum","extension","func","import","init","let","protocol","static","struct","subscript","typealias","var","as","dynamicType","is","new","super","self","Self","Type","__COLUMN__","__FILE__","__FUNCTION__","__LINE__","break","case","continue","default","do","else","fallthrough","if","in","for","return","switch","where","while","associativity","didSet","get","infix","inout","left","mutating","none","nonmutating","operator","override","postfix","precedence","prefix","right","set","unowned","unowned(safe)","unowned(unsafe)","weak","willSet"]
var commonConstants=["Infinity","NaN","undefined","null","true","false","on","off","yes","no","nil","null","this","super"]
var types=["String","bool","int","string","double","Double","Int","Float","float","public","private","extension"]
var numbers=["0","1","2","3","4","5","6","7","8","9"]
var operators=["+","-","/","*","%","=","|","&","<",">"]
var punc=[";",",",".","(",")","{","}","[","]"]
var delimiters=/^(?:[()\[\]{},:`=;]|\.\.?\.?)/
var identifiers=/^[_A-Za-z$][_A-Za-z$0-9]*/
var properties=/^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/
var regexPrefixes=/^(\/{3}|\/)/
return {
startState: function() {
return {
prev: false,
string: false,
escape: false,
inner: false,
comment: false,
num_left: 0,
num_right: 0,
doubleString: false,
singleString: false
function tokenUntilClosingParen() {
var depth = 0
return function(stream, state, prev) {
var inner = tokenBase(stream, state, prev)
if (inner == "punctuation") {
if (stream.current() == "(") ++depth
else if (stream.current() == ")") {
if (depth == 0) {
stream.backUp(1)
state.tokenize.pop()
return state.tokenize[state.tokenize.length - 1](stream, state)
}
else --depth
}
},
token: function(stream, state) {
if (stream.eatSpace()) return null
}
return inner
}
}
var ch = stream.next()
if (state.string) {
if (state.escape) {
state.escape = false
function tokenString(quote) {
return function(stream, state) {
var ch, escaped = false
while (ch = stream.next()) {
if (escaped) {
if (ch == "(") {
state.tokenize.push(tokenUntilClosingParen())
return "string"
} else {
if ((ch == "\"" && (state.doubleString && !state.singleString) ||
(ch == "'" && (!state.doubleString && state.singleString))) &&
!state.escape) {
state.string = false
state.doubleString = false
state.singleString = false
return "string"
} else if (ch == "\\" && stream.peek() == "(") {
state.inner = true
state.string = false
return "keyword"
} else if (ch == "\\" && stream.peek() != "(") {
state.escape = true
state.string = true
return "string"
} else {
return "string"
}
}
} else if (state.comment) {
if (ch == "*" && stream.peek() == "/") {
state.prev = "*"
return "comment"
} else if (ch == "/" && state.prev == "*") {
state.prev = false
state.comment = false
return "comment"
}
return "comment"
escaped = false
} else if (ch == quote) {
break
} else {
if (ch == "/") {
if (stream.peek() == "/") {
stream.skipToEnd()
return "comment"
}
if (stream.peek() == "*") {
state.comment = true
return "comment"
}
}
if (ch == "(" && state.inner) {
state.num_left++
return null
}
if (ch == ")" && state.inner) {
state.num_right++
if (state.num_left == state.num_right) {
state.inner=false
state.string=true
}
return null
}
escaped = ch == "\\"
}
}
state.tokenize.pop()
return "string"
}
}
var ret = getWord(stream.string, stream.pos)
var the_word = ret[1]
var prev_word = ret[0]
function tokenComment(stream, state) {
stream.match(/^(?:[^*]|\*(?!\/))*/)
if (stream.match("*/")) state.tokenize.pop()
return "comment"
}
if (operators.indexOf(ch + "") > -1) return "operator"
if (punc.indexOf(ch) > -1) return "punctuation"
if (typeof the_word != "undefined") {
the_word = trim(the_word)
if (typeof prev_word != "undefined") prev_word = trim(prev_word)
if (the_word.charAt(0) == "#") return null
if (types.indexOf(the_word) > -1) return "def"
if (commonConstants.indexOf(the_word) > -1) return "atom"
if (numbers.indexOf(the_word) > -1) return "number"
if ((numbers.indexOf(the_word.charAt(0) + "") > -1 ||
operators.indexOf(the_word.charAt(0) + "") > -1) &&
numbers.indexOf(ch) > -1) {
return "number"
}
if (keywords.indexOf(the_word) > -1 ||
keywords.indexOf(the_word.split(tokens)[0]) > -1)
return "keyword"
if (keywords.indexOf(prev_word) > -1) return "def"
}
if (ch == '"' && !state.doubleString) {
state.string = true
state.doubleString = true
return "string"
}
if (ch == "'" && !state.singleString) {
state.string = true
state.singleString = true
return "string"
}
if (ch == "(" && state.inner)
state.num_left++
if (ch == ")" && state.inner) {
state.num_right++
if (state.num_left == state.num_right) {
state.inner = false
state.string = true
}
return null
}
if (stream.match(/^-?[0-9\.]/, false)) {
if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i) ||
stream.match(/^-?\d+\.\d*/) ||
stream.match(/^-?\.\d+/)) {
if (stream.peek() == ".") stream.backUp(1)
return "number"
}
if (stream.match(/^-?0x[0-9a-f]+/i) ||
stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/) ||
stream.match(/^-?0(?![\dx])/i))
return "number"
}
if (stream.match(regexPrefixes)) {
if (stream.current()!="/" || stream.match(/^.*\//,false)) return "string"
else stream.backUp(1)
}
if (stream.match(delimiters)) return "punctuation"
if (stream.match(identifiers)) return "variable"
if (stream.match(properties)) return "property"
return "variable"
CodeMirror.defineMode("swift", function() {
return {
startState: function() {
return {
prev: null,
tokenize: []
}
}
},
token: function(stream, state) {
var prev = state.prev
state.prev = null
var tokenize = state.tokenize[state.tokenize.length - 1] || tokenBase
var style = tokenize(stream, state, prev)
if (!style || style == "comment") state.prev = prev
else if (!state.prev) state.prev = style
return style
},
lineComment: "//",
blockCommentStart: "/*",
blockCommentEnd: "*/"
}

@@ -201,0 +161,0 @@ })

{
"name": "codemirror",
"version":"5.9.0",
"version":"5.10.0",
"main": "lib/codemirror.js",

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

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

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