codemirror
Advanced tools
Comparing version 5.4.0 to 5.5.0
@@ -102,3 +102,2 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
if (this.tick == null) return; | ||
if (this.data) CodeMirror.signal(this.data, "update"); | ||
if (!this.options.hint.async) { | ||
@@ -115,2 +114,4 @@ this.finishUpdate(this.options.hint(this.cm, this.options), first); | ||
finishUpdate: function(data, first) { | ||
if (this.data) CodeMirror.signal(this.data, "update"); | ||
if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null; | ||
this.data = data; | ||
@@ -356,14 +357,16 @@ | ||
var cur = cm.getCursor(), token = cm.getTokenAt(cur); | ||
var to = CodeMirror.Pos(cur.line, token.end); | ||
if (token.string && /\w/.test(token.string[token.string.length - 1])) { | ||
var term = token.string, from = CodeMirror.Pos(cur.line, token.start); | ||
} else { | ||
var term = "", from = to; | ||
} | ||
var found = []; | ||
for (var i = 0; i < options.words.length; i++) { | ||
var word = options.words[i]; | ||
if (word.slice(0, token.string.length) == token.string) | ||
if (word.slice(0, term.length) == term) | ||
found.push(word); | ||
} | ||
if (found.length) return { | ||
list: found, | ||
from: CodeMirror.Pos(cur.line, token.start), | ||
to: CodeMirror.Pos(cur.line, token.end) | ||
}; | ||
if (found.length) return {list: found, from: from, to: to}; | ||
}); | ||
@@ -370,0 +373,0 @@ |
@@ -21,2 +21,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
"use strict"; | ||
function searchOverlay(query, caseInsensitive) { | ||
@@ -46,8 +47,11 @@ if (typeof query == "string") | ||
} | ||
function getSearchState(cm) { | ||
return cm.state.search || (cm.state.search = new SearchState()); | ||
} | ||
function queryCaseInsensitive(query) { | ||
return typeof query == "string" && query == query.toLowerCase(); | ||
} | ||
function getSearchCursor(cm, query, pos) { | ||
@@ -57,2 +61,12 @@ // Heuristic: if the query string is all lowercase, do a case insensitive search. | ||
} | ||
function persistentDialog(cm, text, deflt, f) { | ||
cm.openDialog(text, f, { | ||
value: deflt, | ||
selectValueOnOpen: true, | ||
closeOnEnter: false, | ||
onClose: function() { clearSearch(cm); } | ||
}); | ||
} | ||
function dialog(cm, text, shortText, deflt, f) { | ||
@@ -62,2 +76,3 @@ if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); | ||
} | ||
function confirmDialog(cm, text, shortText, fs) { | ||
@@ -67,2 +82,3 @@ if (cm.openConfirm) cm.openConfirm(text, fs); | ||
} | ||
function parseQuery(query) { | ||
@@ -78,24 +94,40 @@ var isRE = query.match(/^\/(.*)\/([a-z]*)$/); | ||
} | ||
var queryDialog = | ||
'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>'; | ||
function doSearch(cm, rev) { | ||
function startSearch(cm, state, query) { | ||
state.queryText = query; | ||
state.query = parseQuery(query); | ||
cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); | ||
state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); | ||
cm.addOverlay(state.overlay); | ||
if (cm.showMatchesOnScrollbar) { | ||
if (state.annotate) { state.annotate.clear(); state.annotate = null; } | ||
state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); | ||
} | ||
} | ||
function doSearch(cm, rev, persistent) { | ||
var state = getSearchState(cm); | ||
if (state.query) return findNext(cm, rev); | ||
var q = cm.getSelection() || state.lastQuery; | ||
dialog(cm, queryDialog, "Search for:", q, function(query) { | ||
cm.operation(function() { | ||
if (!query || state.query) return; | ||
state.query = parseQuery(query); | ||
cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); | ||
state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); | ||
cm.addOverlay(state.overlay); | ||
if (cm.showMatchesOnScrollbar) { | ||
if (state.annotate) { state.annotate.clear(); state.annotate = null; } | ||
state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); | ||
} | ||
state.posFrom = state.posTo = cm.getCursor(); | ||
findNext(cm, rev); | ||
if (persistent && cm.openDialog) { | ||
persistentDialog(cm, queryDialog, q, function(query, event) { | ||
CodeMirror.e_stop(event); | ||
if (!query) return; | ||
if (query != state.queryText) startSearch(cm, state, query); | ||
findNext(cm, event.shiftKey); | ||
}); | ||
}); | ||
} else { | ||
dialog(cm, queryDialog, "Search for:", q, function(query) { | ||
if (query && !state.query) cm.operation(function() { | ||
startSearch(cm, state, query); | ||
state.posFrom = state.posTo = cm.getCursor(); | ||
findNext(cm, rev); | ||
}); | ||
}); | ||
} | ||
} | ||
function findNext(cm, rev) {cm.operation(function() { | ||
@@ -109,5 +141,6 @@ var state = getSearchState(cm); | ||
cm.setSelection(cursor.from(), cursor.to()); | ||
cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); | ||
cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20); | ||
state.posFrom = cursor.from(); state.posTo = cursor.to(); | ||
});} | ||
function clearSearch(cm) {cm.operation(function() { | ||
@@ -117,3 +150,3 @@ var state = getSearchState(cm); | ||
if (!state.query) return; | ||
state.query = null; | ||
state.query = state.queryText = null; | ||
cm.removeOverlay(state.overlay); | ||
@@ -127,2 +160,3 @@ if (state.annotate) { state.annotate.clear(); state.annotate = null; } | ||
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>"; | ||
function replace(cm, all) { | ||
@@ -171,2 +205,3 @@ if (cm.getOption("readOnly")) return; | ||
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);}; | ||
CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);}; | ||
CodeMirror.commands.findNext = doSearch; | ||
@@ -173,0 +208,0 @@ CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);}; |
@@ -219,3 +219,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
completions.push({text: completion.name + after, | ||
displayText: completion.name, | ||
displayText: completion.displayName || completion.name, | ||
className: className, | ||
@@ -222,0 +222,0 @@ data: completion}); |
@@ -64,3 +64,4 @@ # How to contribute | ||
- Submit a pull request | ||
([how to create a pull request](https://help.github.com/articles/fork-a-repo)) | ||
([how to create a pull request](https://help.github.com/articles/fork-a-repo)). | ||
Don't put more than one feature/fix in a single pull request. | ||
@@ -67,0 +68,0 @@ By contributing code to CodeMirror you |
@@ -380,3 +380,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var num; | ||
if (str && !isNaN(num = Number(str)) && num == num|0 && num > 0) | ||
if (str && !isNaN(num = Number(str)) && num == (num|0) && num > 0) | ||
cm.setCursor(num - 1); | ||
@@ -383,0 +383,0 @@ }); |
@@ -58,3 +58,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
cmds[map[ctrl + "Up"] = "scrollLineUp"] = function(cm) { | ||
var scrollLineCombo = mac ? "Ctrl-Alt-" : "Ctrl-"; | ||
cmds[map[scrollLineCombo + "Up"] = "scrollLineUp"] = function(cm) { | ||
var info = cm.getScrollInfo(); | ||
@@ -68,3 +70,3 @@ if (!cm.somethingSelected()) { | ||
}; | ||
cmds[map[ctrl + "Down"] = "scrollLineDown"] = function(cm) { | ||
cmds[map[scrollLineCombo + "Down"] = "scrollLineDown"] = function(cm) { | ||
var info = cm.getScrollInfo(); | ||
@@ -71,0 +73,0 @@ if (!cm.somethingSelected()) { |
@@ -591,2 +591,15 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
def("text/x-squirrel", { | ||
name: "clike", | ||
keywords: words("base break clone continue const default delete enum extends function in class" + | ||
" foreach local resume return this throw typeof yield constructor instanceof static"), | ||
types: words(cTypes), | ||
blockKeywords: words("case catch class else for foreach if switch try while"), | ||
defKeywords: words("function local class"), | ||
typeFirstDefinitions: true, | ||
atoms: words("true false null"), | ||
hooks: {"#": cppHook}, | ||
modeProps: {fold: ["brace", "include"]} | ||
}); | ||
}); |
@@ -276,2 +276,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
override = "atom"; | ||
else if (colorKeywords.hasOwnProperty(word)) | ||
override = "keyword"; | ||
else | ||
@@ -278,0 +280,0 @@ override = "error"; |
@@ -223,4 +223,2 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
} | ||
}else if (is_member(w,operatorAtomWords)) { | ||
return rval(state,stream,"operator"); | ||
}else if (lookahead(stream) == ":") { | ||
@@ -234,4 +232,2 @@ if (w == "erlang") { | ||
return rval(state,stream,"boolean"); | ||
}else if (is_member(w,["true","false"])) { | ||
return rval(state,stream,"boolean"); | ||
}else{ | ||
@@ -238,0 +234,0 @@ return rval(state,stream,"atom"); |
@@ -119,6 +119,7 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
markdownConfig.name = "markdown"; | ||
CodeMirror.defineMIME("gfmBase", markdownConfig); | ||
return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay); | ||
return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay); | ||
}, "markdown"); | ||
CodeMirror.defineMIME("text/x-gfm", "gfm"); | ||
}); |
@@ -205,3 +205,4 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var style = htmlMode.token(stream, state.htmlState); | ||
if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) || | ||
if ((htmlFound && state.htmlState.tagStart === null && | ||
(!state.htmlState.context && state.htmlState.tokenize.isInText)) || | ||
(state.md_inside && stream.current().indexOf(">") > -1)) { | ||
@@ -450,8 +451,7 @@ state.f = inlineNormal; | ||
if (ch === '<' && stream.match(/^\w/, false)) { | ||
if (stream.string.indexOf(">") != -1) { | ||
var atts = stream.string.substring(1,stream.string.indexOf(">")); | ||
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) { | ||
state.md_inside = true; | ||
} | ||
if (ch === '<' && stream.match(/^(!--|\w)/, false)) { | ||
var end = stream.string.indexOf(">", stream.pos); | ||
if (end != -1) { | ||
var atts = stream.string.substring(stream.start, end); | ||
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true; | ||
} | ||
@@ -458,0 +458,0 @@ stream.backUp(1); |
@@ -17,4 +17,5 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
{name: "PGP", mimes: ["application/pgp", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["pgp"]}, | ||
{name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn, asn1"]}, | ||
{name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]}, | ||
{name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i}, | ||
{name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]}, | ||
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]}, | ||
@@ -120,2 +121,3 @@ {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]}, | ||
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]}, | ||
{name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]}, | ||
{name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]}, | ||
@@ -122,0 +124,0 @@ {name: "MariaDB", mime: "text/x-mariadb", mode: "sql"}, |
@@ -40,3 +40,2 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
function tokenBase(stream, state) { | ||
curPunc = null; | ||
if (stream.sol() && stream.match("=begin") && stream.eol()) { | ||
@@ -236,2 +235,3 @@ state.tokenize.push(readBlockComment); | ||
token: function(stream, state) { | ||
curPunc = null; | ||
if (stream.sol()) state.indented = stream.indentation(); | ||
@@ -238,0 +238,0 @@ var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype; |
@@ -29,3 +29,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
var keywords = {"fn": "fn", "block": "fn", "obj": "obj"}; | ||
var atoms = "bool uint int i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 str char".split(" "); | ||
var atoms = "bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 str char isize usize".split(" "); | ||
for (var i = 0, e = atoms.length; i < e; ++i) keywords[atoms[i]] = "atom"; | ||
@@ -32,0 +32,0 @@ return keywords; |
@@ -112,2 +112,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
} | ||
inText.isInText = true; | ||
@@ -114,0 +115,0 @@ function inTag(stream, state) { |
{ | ||
"name": "codemirror", | ||
"version":"5.4.0", | ||
"version":"5.5.0", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable", |
@@ -6,8 +6,23 @@ # CodeMirror | ||
CodeMirror is a JavaScript component that provides a code editor in | ||
the browser. When a mode is available for the language you are coding | ||
in, it will color your code, and optionally help with indentation. | ||
CodeMirror is a versatile text editor implemented in JavaScript for | ||
the browser. It is specialized for editing code, and comes with over | ||
100 language modes and various addons that implement more advanced | ||
editing functionality. | ||
The project page is http://codemirror.net | ||
The manual is at http://codemirror.net/doc/manual.html | ||
The contributing guidelines are in [CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md) | ||
A rich programming API and a CSS theming system are available for | ||
customizing CodeMirror to fit your application, and extending it with | ||
new functionality. | ||
You can find more information (and the | ||
[manual](http://codemirror.net/doc/manual.html)) on the [project | ||
page](http://codemirror.net). For questions and discussion, use the | ||
[discussion forum](http://discuss.codemirror.net/). | ||
See | ||
[CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md) | ||
for contributing guidelines. | ||
The CodeMirror community aims to be welcoming to everybody. We use the | ||
[Contributor Covenant | ||
(1.1)](http://contributor-covenant.org/version/1/1/0/) as our code of | ||
conduct. |
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 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 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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
28
1
2000730
237
47531