New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.46.0 to 5.47.0

26

addon/hint/show-hint.js

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

var container = completion.options.container || ownerDocument.body;
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
var left = pos.left, top = pos.bottom, below = true;
hints.style.left = left + "px";
hints.style.top = top + "px";
var offsetLeft = 0, offsetTop = 0;
if (container !== ownerDocument.body) {
// We offset the cursor position because left and top are relative to the offsetParent's top left corner.
var isContainerPositioned = ['absolute', 'relative', 'fixed'].indexOf(parentWindow.getComputedStyle(container).position) !== -1;
var offsetParent = isContainerPositioned ? container : container.offsetParent;
var offsetParentPosition = offsetParent.getBoundingClientRect();
var bodyPosition = ownerDocument.body.getBoundingClientRect();
offsetLeft = (offsetParentPosition.left - bodyPosition.left);
offsetTop = (offsetParentPosition.top - bodyPosition.top);
}
hints.style.left = (left - offsetLeft) + "px";
hints.style.top = (top - offsetTop) + "px";
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth);
var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight);
(completion.options.container || ownerDocument.body).appendChild(hints);
container.appendChild(hints);
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;

@@ -248,11 +260,11 @@ var scrolls = hints.scrollHeight > hints.clientHeight + 1

if (curTop - height > 0) { // Fits above cursor
hints.style.top = (top = pos.top - height) + "px";
hints.style.top = (top = pos.top - height - offsetTop) + "px";
below = false;
} else if (height > winH) {
hints.style.height = (winH - 5) + "px";
hints.style.top = (top = pos.bottom - box.top) + "px";
hints.style.top = (top = pos.bottom - box.top - offsetTop) + "px";
var cursor = cm.getCursor();
if (data.from.ch != cursor.ch) {
pos = cm.cursorCoords(cursor);
hints.style.left = (left = pos.left) + "px";
hints.style.left = (left = pos.left - offsetLeft) + "px";
box = hints.getBoundingClientRect();

@@ -268,3 +280,3 @@ }

}
hints.style.left = (left = pos.left - overlapX) + "px";
hints.style.left = (left = pos.left - overlapX - offsetLeft) + "px";
}

@@ -271,0 +283,0 @@ if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)

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

"Ctrl-Z": repeated("undo"), "Cmd-Z": repeated("undo"),
"Shift-Ctrl-Z": "redo",
"Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",

@@ -374,0 +375,0 @@ "Ctrl-S": "findPersistentNext", "Ctrl-R": "findPersistentPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",

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

function base(stream, state) {
if (stream.eatSpace()) return ["space", null];
if (stream.eatSpace() || stream.eat(",")) return ["space", null];
if (stream.match(numberLiteral)) return [null, "number"];

@@ -172,0 +172,0 @@ if (stream.match(characterLiteral)) return [null, "string-2"];

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

var operators = [parserConf.singleOperators, parserConf.doubleOperators, parserConf.doubleDelimiters, parserConf.tripleDelimiters,
parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@])/]
parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/]
for (var i = 0; i < operators.length; i++) if (!operators[i]) operators.splice(i--, 1)

@@ -50,0 +50,0 @@

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

var dedentWords = wordObj(["end", "until"]);
var matching = {"[": "]", "{": "}", "(": ")"};
var opening = {"[": "]", "{": "}", "(": ")"};
var closing = {"]": "[", "}": "{", ")": "("};
var curPunc;

@@ -62,3 +63,3 @@

if (!delim) return "operator";
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
if (opening.propertyIsEnumerable(delim)) delim = opening[delim];
return chain(readQuoted(delim, style, embed, true), stream, state);

@@ -68,3 +69,3 @@ } else if (ch == "#") {

return "comment";
} else if (ch == "<" && (m = stream.match(/^<(-)?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
} else if (ch == "<" && (m = stream.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
return chain(readHereDoc(m[2], m[1]), stream, state);

@@ -286,5 +287,5 @@ } else if (ch == "0") {

var ct = state.context;
var closing = ct.type == matching[firstChar] ||
var closed = ct.type == closing[firstChar] ||
ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
return ct.indented + (closing ? 0 : config.indentUnit) +
return ct.indented + (closed ? 0 : config.indentUnit) +
(state.continuedLine ? config.indentUnit : 0);

@@ -291,0 +292,0 @@ },

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

var indentingTags = ["template", "literal", "msg", "fallbackmsg", "let", "if", "elseif",
"else", "switch", "case", "default", "foreach", "ifempty", "for",
"call", "param", "deltemplate", "delcall", "log", "element"];
var paramData = { noEndTag: true, soyState: "param-def" };
var tags = {
"alias": { noEndTag: true },
"delpackage": { noEndTag: true },
"namespace": { noEndTag: true, soyState: "namespace-def" },
"@param": paramData,
"@param?": paramData,
"@inject": paramData,
"@inject?": paramData,
"@state": paramData,
"@state?": paramData,
"template": { soyState: "templ-def", variableScope: true},
"literal": { },
"msg": {},
"fallbackmsg": { noEndTag: true, reduceIndent: true},
"let": { soyState: "var-def" },
"if": {},
"elseif": { noEndTag: true, reduceIndent: true},
"else": { noEndTag: true, reduceIndent: true},
"switch": {},
"case": { noEndTag: true, reduceIndent: true},
"default": { noEndTag: true, reduceIndent: true},
"foreach": { variableScope: true, soyState: "var-def" },
"ifempty": { noEndTag: true, reduceIndent: true},
"for": { variableScope: true, soyState: "var-def" },
"call": { soyState: "templ-ref" },
"param": { soyState: "param-ref"},
"print": { noEndTag: true },
"deltemplate": { soyState: "templ-def", variableScope: true},
"delcall": { soyState: "templ-ref" },
"log": {},
"element": { variableScope: true },
};
var indentingTags = Object.keys(tags).filter(function(tag) {
return !tags[tag].noEndTag || tags[tag].reduceIndent;
});
CodeMirror.defineMode("soy", function(config) {

@@ -72,2 +106,10 @@ var textMode = CodeMirror.getMode(config, "text/plain");

function popcontext(state) {
if (!state.context) return;
if (state.context.scope) {
state.variables = state.context.scope;
}
state.context = state.context.previousContext;
}
// Reference a variable `name` in `list`.

@@ -79,7 +121,8 @@ // Let `loose` be truthy to ignore missing identifiers.

function popscope(state) {
if (state.scopes) {
state.variables = state.scopes.element;
state.scopes = state.scopes.next;
}
// Data for an open soy tag.
function Context(previousContext, tag, scope) {
this.previousContext = previousContext;
this.tag = tag;
this.kind = null;
this.scope = scope;
}

@@ -90,4 +133,2 @@

return {
kind: [],
kindTag: [],
soyState: [],

@@ -99,2 +140,3 @@ templates: null,

quoteKind: null,
context: null,
localStates: [{

@@ -110,8 +152,6 @@ mode: modes.html,

tag: state.tag, // Last seen Soy tag.
kind: state.kind.concat([]), // Values of kind="" attributes.
kindTag: state.kindTag.concat([]), // Opened tags with kind="" attributes.
soyState: state.soyState.concat([]),
templates: state.templates,
variables: state.variables,
scopes: state.scopes,
context: state.context,
indent: state.indent, // Indentation of the following line.

@@ -138,3 +178,3 @@ quoteKind: state.quoteKind,

}
if (!state.scopes) {
if (!state.context || !state.context.scope) {
var paramRe = /@param\??\s+(\S+)/g;

@@ -172,3 +212,2 @@ var current = stream.current();

state.templates = prepend(state.templates, match[1]);
state.scopes = prepend(state.scopes, state.variables);
state.soyState.pop();

@@ -240,13 +279,16 @@ return "def";

case "tag":
var endTag = state.tag[0] == "/";
var tagName = endTag ? state.tag.substring(1) : state.tag;
var tag = tags[tagName];
if (stream.match(/^\/?}/)) {
var selfClosed = stream.current() == "/}";
if (selfClosed && !endTag) {
popcontext(state);
}
if (state.tag == "/template" || state.tag == "/deltemplate") {
popscope(state);
state.variables = prepend(null, 'ij');
state.indent = 0;
} else {
if (state.tag == "/for" || state.tag == "/foreach") {
popscope(state);
}
state.indent -= config.indentUnit *
(stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1);
(selfClosed || indentingTags.indexOf(state.tag) == -1 ? 2 : 1);
}

@@ -258,4 +300,3 @@ state.soyState.pop();

var kind = match[1];
state.kind.push(kind);
state.kindTag.push(state.tag);
state.context.kind = kind;
var mode = modes[kind] || modes.html;

@@ -309,2 +350,3 @@ var localState = last(state.localStates);

state.soyState.push("literal");
state.context = new Context(state.context, "literal", state.variables);
return "keyword";

@@ -314,36 +356,40 @@

} else if (match = stream.match(/^\{([/@\\]?\w+\??)(?=$|[\s}]|\/[/*])/)) {
if (match[1] != "/switch")
state.indent += (/^(\/|(else|elseif|ifempty|case|fallbackmsg|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit;
var prevTag = state.tag;
state.tag = match[1];
if (state.tag == "/" + last(state.kindTag)) {
// We found the tag that opened the current kind="".
state.kind.pop();
state.kindTag.pop();
state.localStates.pop();
var localState = last(state.localStates);
if (localState.mode.indent) {
state.indent -= localState.mode.indent(localState.state, "", "");
}
}
var endTag = state.tag[0] == "/";
var indentingTag = !!tags[state.tag];
var tagName = endTag ? state.tag.substring(1) : state.tag;
var tag = tags[tagName];
if (state.tag != "/switch")
state.indent += ((endTag || tag && tag.reduceIndent) && prevTag != "switch" ? 1 : 2) * config.indentUnit;
state.soyState.push("tag");
if (state.tag == "template" || state.tag == "deltemplate") {
state.soyState.push("templ-def");
} else if (state.tag == "call" || state.tag == "delcall") {
state.soyState.push("templ-ref");
} else if (state.tag == "let") {
state.soyState.push("var-def");
} else if (state.tag == "for" || state.tag == "foreach") {
state.scopes = prepend(state.scopes, state.variables);
state.soyState.push("var-def");
} else if (state.tag == "namespace") {
state.soyState.push("namespace-def");
if (!state.scopes) {
state.variables = prepend(null, 'ij');
var tagError = false;
if (tag) {
if (!endTag) {
if (tag.soyState) state.soyState.push(tag.soyState);
}
} else if (state.tag.match(/^@(?:param\??|inject|state)/)) {
state.soyState.push("param-def");
} else if (state.tag.match(/^(?:param)/)) {
state.soyState.push("param-ref");
// If a new tag, open a new context.
if (!tag.noEndTag && (indentingTag || !endTag)) {
state.context = new Context(state.context, state.tag, tag.variableScope ? state.variables : null);
// Otherwise close the current context.
} else if (endTag) {
if (!state.context || state.context.tag != tagName) {
tagError = true;
} else if (state.context) {
if (state.context.kind) {
state.localStates.pop();
var localState = last(state.localStates);
if (localState.mode.indent) {
state.indent -= localState.mode.indent(localState.state, "", "");
}
}
popcontext(state);
}
}
} else if (endTag) {
// Assume all tags with a closing tag are defined in the config.
tagError = true;
}
return "keyword";
return (tagError ? "error " : "") + "keyword";

@@ -397,6 +443,6 @@ // Not a tag-keyword; it's an implicit print tag.

CodeMirror.registerHelper("hintWords", "soy", indentingTags.concat(
["delpackage", "namespace", "alias", "print", "css", "debugger"]));
CodeMirror.registerHelper("hintWords", "soy", Object.keys(tags).concat(
["css", "debugger"]));
CodeMirror.defineMIME("text/x-soy", "soy");
});
{
"name": "codemirror",
"version": "5.46.0",
"version": "5.47.0",
"main": "lib/codemirror.js",

@@ -5,0 +5,0 @@ "style": "lib/codemirror.css",

@@ -69,2 +69,2 @@ // EDITOR CONSTRUCTOR

CodeMirror.version = "5.46.0"
CodeMirror.version = "5.47.0"

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 too big to display

Sorry, the diff of this file is not supported yet

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