From 01685c255fda6e13f1cd2980130d2e388d52125c Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 4 Jul 2015 11:31:01 +0800 Subject: Updated codemirror to 5.4.0 --- .../codemirror/addon/comment/continuecomment.js | 2 +- public/vendor/codemirror/addon/dialog/dialog.css | 8 +-- public/vendor/codemirror/addon/display/rulers.js | 3 +- .../vendor/codemirror/addon/edit/closebrackets.js | 1 + public/vendor/codemirror/addon/edit/closetag.js | 2 +- .../vendor/codemirror/addon/edit/continuelist.js | 9 ++- public/vendor/codemirror/addon/hint/show-hint.js | 37 ++++------ public/vendor/codemirror/addon/hint/sql-hint.js | 17 +++-- public/vendor/codemirror/addon/lint/lint.js | 12 ++-- .../codemirror/addon/runmode/runmode.node.js | 80 +++++++++++++++++++--- .../vendor/codemirror/addon/search/searchcursor.js | 4 +- public/vendor/codemirror/addon/tern/tern.js | 6 +- public/vendor/codemirror/addon/tern/worker.js | 2 +- 13 files changed, 119 insertions(+), 64 deletions(-) (limited to 'public/vendor/codemirror/addon') diff --git a/public/vendor/codemirror/addon/comment/continuecomment.js b/public/vendor/codemirror/addon/comment/continuecomment.js index d0b81d30..b11d51e6 100755 --- a/public/vendor/codemirror/addon/comment/continuecomment.js +++ b/public/vendor/codemirror/addon/comment/continuecomment.js @@ -57,7 +57,7 @@ cm.operation(function() { for (var i = ranges.length - 1; i >= 0; i--) - cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+input"); + cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+insert"); }); } diff --git a/public/vendor/codemirror/addon/dialog/dialog.css b/public/vendor/codemirror/addon/dialog/dialog.css index c8c139d9..677c0783 100755 --- a/public/vendor/codemirror/addon/dialog/dialog.css +++ b/public/vendor/codemirror/addon/dialog/dialog.css @@ -1,11 +1,11 @@ .CodeMirror-dialog { position: absolute; left: 0; right: 0; - background: white; + background: inherit; z-index: 15; padding: .1em .8em; overflow: hidden; - color: #333; + color: inherit; } .CodeMirror-dialog-top { @@ -27,10 +27,6 @@ font-family: monospace; } -.CodeMirror-dialog input::selection { - color: white; -} - .CodeMirror-dialog button { font-size: 70%; } diff --git a/public/vendor/codemirror/addon/display/rulers.js b/public/vendor/codemirror/addon/display/rulers.js index 13185d30..01f65667 100755 --- a/public/vendor/codemirror/addon/display/rulers.js +++ b/public/vendor/codemirror/addon/display/rulers.js @@ -38,7 +38,7 @@ for (var i = 0; i < val.length; i++) { var elt = document.createElement("div"); elt.className = "CodeMirror-ruler"; - var col, cls = null, conf = val[i]; + var col, conf = val[i]; if (typeof conf == "number") { col = conf; } else { @@ -47,7 +47,6 @@ if (conf.color) elt.style.borderColor = conf.color; if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle; if (conf.width) elt.style.borderLeftWidth = conf.width; - cls = val[i].className; } elt.style.left = (left + col * cw) + "px"; elt.style.top = "-50px"; diff --git a/public/vendor/codemirror/addon/edit/closebrackets.js b/public/vendor/codemirror/addon/edit/closebrackets.js index 35b5b32c..1ceda4e3 100755 --- a/public/vendor/codemirror/addon/edit/closebrackets.js +++ b/public/vendor/codemirror/addon/edit/closebrackets.js @@ -147,6 +147,7 @@ cm.replaceSelections(sels, "around", "+input"); } else if (type == "both") { cm.replaceSelection(left + right, null, "+input"); + cm.triggerElectric(left + right); cm.execCommand("goCharLeft"); } else if (type == "addFour") { cm.replaceSelection(left + left + left + left, "before", "+input"); diff --git a/public/vendor/codemirror/addon/edit/closetag.js b/public/vendor/codemirror/addon/edit/closetag.js index 4ab36cce..c2d2263e 100755 --- a/public/vendor/codemirror/addon/edit/closetag.js +++ b/public/vendor/codemirror/addon/edit/closetag.js @@ -83,7 +83,7 @@ for (var i = ranges.length - 1; i >= 0; i--) { var info = replacements[i]; - cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+input"); + cm.replaceRange(info.text, ranges[i].head, ranges[i].anchor, "+insert"); var sel = cm.listSelections().slice(0); sel[i] = {head: info.newPos, anchor: info.newPos}; cm.setSelections(sel); diff --git a/public/vendor/codemirror/addon/edit/continuelist.js b/public/vendor/codemirror/addon/edit/continuelist.js index e21d0f95..a0941d4f 100755 --- a/public/vendor/codemirror/addon/edit/continuelist.js +++ b/public/vendor/codemirror/addon/edit/continuelist.js @@ -11,8 +11,8 @@ })(function(CodeMirror) { "use strict"; - var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)\.)(\[\s\]\s|\[x\]\s|\s*)/, - emptyListRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)\.)(\[\s\]\s*|\[x\]\s|\s*)$/, + var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\[\s\]\s|\[x\]\s|\s*)/, + emptyListRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)[.)])(\[\s\]\s*|\[x\]\s|\s*)$/, unorderedListRE = /[*+-]\s/; CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) { @@ -36,12 +36,11 @@ line: pos.line, ch: pos.ch + 1 }, "+delete"); replacements[i] = "\n"; - } else { - var indent = match[1], after = match[4]; + var indent = match[1], after = match[5]; var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0 ? match[2] - : (parseInt(match[3], 10) + 1) + "."; + : (parseInt(match[3], 10) + 1) + match[4]; replacements[i] = "\n" + indent + bullet + after; } diff --git a/public/vendor/codemirror/addon/hint/show-hint.js b/public/vendor/codemirror/addon/hint/show-hint.js index 539181fd..d228fc88 100755 --- a/public/vendor/codemirror/addon/hint/show-hint.js +++ b/public/vendor/codemirror/addon/hint/show-hint.js @@ -33,7 +33,7 @@ if (!completion.options.hint) return; CodeMirror.signal(this, "startCompletion", this); - completion.update(); + completion.update(true); }); function Completion(cm, options) { @@ -61,6 +61,7 @@ this.tick = null; this.cm.off("cursorActivity", this.activityFunc); + if (this.widget && this.data) CodeMirror.signal(this.data, "close"); if (this.widget) this.widget.close(); CodeMirror.signal(this.cm, "endCompletion", this.cm); }, @@ -78,15 +79,6 @@ this.close(); }, - showHints: function(data) { - if (!data || !data.list.length || !this.active()) return this.close(); - - if (this.options.completeSingle && data.list.length == 1) - this.pick(data, 0); - else - this.showWidget(data); - }, - cursorActivity: function() { if (this.debounce) { cancelAnimationFrame(this.debounce); @@ -105,35 +97,34 @@ } }, - update: function() { + update: function(first) { if (this.tick == null) return; if (this.data) CodeMirror.signal(this.data, "update"); if (!this.options.hint.async) { - this.finishUpdate(this.options.hint(this.cm, this.options), myTick); + this.finishUpdate(this.options.hint(this.cm, this.options), first); } else { var myTick = ++this.tick, self = this; this.options.hint(this.cm, function(data) { - if (self.tick == myTick) self.finishUpdate(data); + if (self.tick == myTick) self.finishUpdate(data, first); }, this.options); } }, - finishUpdate: function(data) { + finishUpdate: function(data, first) { this.data = data; - var picked = this.widget && this.widget.picked; + + var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle); if (this.widget) this.widget.close(); if (data && data.list.length) { - if (picked && data.list.length == 1) this.pick(data, 0); - else this.widget = new Widget(this, data); + if (picked && data.list.length == 1) { + this.pick(data, 0); + } else { + this.widget = new Widget(this, data); + CodeMirror.signal(data, "shown"); + } } }, - showWidget: function(data) { - this.data = data; - this.widget = new Widget(this, data); - CodeMirror.signal(data, "shown"); - }, - buildOptions: function(options) { var editor = this.cm.options.hintOptions; var out = {}; diff --git a/public/vendor/codemirror/addon/hint/sql-hint.js b/public/vendor/codemirror/addon/hint/sql-hint.js index cba27a0b..22124b58 100755 --- a/public/vendor/codemirror/addon/hint/sql-hint.js +++ b/public/vendor/codemirror/addon/hint/sql-hint.js @@ -112,9 +112,14 @@ string = nameParts.pop(); var table = nameParts.join("."); + var alias = false; + var aliasTable = table; // Check if table is available. If not, find table by Alias - if (!getItem(tables, table)) + if (!getItem(tables, table)) { + var oldTable = table; table = findTableByAlias(table, editor); + if (table !== oldTable) alias = true; + } var columns = getItem(tables, table); if (columns && columns.columns) @@ -122,11 +127,13 @@ if (columns) { addMatches(result, string, columns, function(w) { + var tableInsert = table; + if (alias == true) tableInsert = aliasTable; if (typeof w == "string") { - w = table + "." + w; + w = tableInsert + "." + w; } else { w = shallowClone(w); - w.text = table + "." + w.text; + w.text = tableInsert + "." + w.text; } return useBacktick ? insertBackticks(w) : w; }); @@ -205,6 +212,7 @@ CodeMirror.registerHelper("hint", "sql", function(editor, options) { tables = (options && options.tables) || {}; var defaultTableName = options && options.defaultTable; + var disableKeywords = options && options.disableKeywords; defaultTable = defaultTableName && getItem(tables, defaultTableName); keywords = keywords || getKeywords(editor); @@ -237,7 +245,8 @@ } else { addMatches(result, search, tables, function(w) {return w;}); addMatches(result, search, defaultTable, function(w) {return w;}); - addMatches(result, search, keywords, function(w) {return w.toUpperCase();}); + if (!disableKeywords) + addMatches(result, search, keywords, function(w) {return w.toUpperCase();}); } return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)}; diff --git a/public/vendor/codemirror/addon/lint/lint.js b/public/vendor/codemirror/addon/lint/lint.js index c7e09396..3eea203c 100755 --- a/public/vendor/codemirror/addon/lint/lint.js +++ b/public/vendor/codemirror/addon/lint/lint.js @@ -63,11 +63,9 @@ this.onMouseOver = function(e) { onMouseOver(cm, e); }; } - function parseOptions(cm, options) { + function parseOptions(_cm, options) { if (options instanceof Function) return {getAnnotations: options}; if (!options || options === true) options = {}; - if (!options.getAnnotations) options.getAnnotations = cm.getHelper(CodeMirror.Pos(0, 0), "lint"); - if (!options.getAnnotations) throw new Error("Required option 'getAnnotations' missing (lint addon)"); return options; } @@ -120,10 +118,12 @@ function startLinting(cm) { var state = cm.state.lint, options = state.options; var passOptions = options.options || options; // Support deprecated passing of `options` property in options - if (options.async || options.getAnnotations.async) - options.getAnnotations(cm.getValue(), updateLinting, passOptions, cm); + var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint"); + if (!getAnnotations) return; + if (options.async || getAnnotations.async) + getAnnotations(cm.getValue(), updateLinting, passOptions, cm); else - updateLinting(cm, options.getAnnotations(cm.getValue(), passOptions, cm)); + updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm)); } function updateLinting(cm, annotationsNotSorted) { diff --git a/public/vendor/codemirror/addon/runmode/runmode.node.js b/public/vendor/codemirror/addon/runmode/runmode.node.js index 8b8140b4..8f345a32 100755 --- a/public/vendor/codemirror/addon/runmode/runmode.node.js +++ b/public/vendor/codemirror/addon/runmode/runmode.node.js @@ -3,19 +3,37 @@ /* Just enough of CodeMirror to run runMode under node.js */ -// declare global: StringStream +function splitLines(string){return string.split(/\r\n?|\n/);}; -function splitLines(string){ return string.split(/\r?\n|\r/); }; +// Counts the column offset in a string, taking tabs into account. +// Used mostly to find indentation. +var countColumn = function(string, end, tabSize, startIndex, startValue) { + if (end == null) { + end = string.search(/[^\s\u00a0]/); + if (end == -1) end = string.length; + } + for (var i = startIndex || 0, n = startValue || 0;;) { + var nextTab = string.indexOf("\t", i); + if (nextTab < 0 || nextTab >= end) + return n + (end - i); + n += nextTab - i; + n += tabSize - (n % tabSize); + i = nextTab + 1; + } +}; -function StringStream(string) { +function StringStream(string, tabSize) { this.pos = this.start = 0; this.string = string; + this.tabSize = tabSize || 8; + this.lastColumnPos = this.lastColumnValue = 0; this.lineStart = 0; -} +}; + StringStream.prototype = { eol: function() {return this.pos >= this.string.length;}, - sol: function() {return this.pos == 0;}, - peek: function() {return this.string.charAt(this.pos) || null;}, + sol: function() {return this.pos == this.lineStart;}, + peek: function() {return this.string.charAt(this.pos) || undefined;}, next: function() { if (this.pos < this.string.length) return this.string.charAt(this.pos++); @@ -42,8 +60,17 @@ StringStream.prototype = { if (found > -1) {this.pos = found; return true;} }, backUp: function(n) {this.pos -= n;}, - column: function() {return this.start - this.lineStart;}, - indentation: function() {return 0;}, + column: function() { + if (this.lastColumnPos < this.start) { + this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); + this.lastColumnPos = this.start; + } + return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); + }, + indentation: function() { + return countColumn(this.string, null, this.tabSize) - + (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); + }, match: function(pattern, consume, caseInsensitive) { if (typeof pattern == "string") { var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; @@ -94,11 +121,42 @@ exports.resolveMode = function(spec) { if (typeof spec == "string") return {name: spec}; else return spec || {name: "null"}; }; + +function copyObj(obj, target, overwrite) { + if (!target) target = {}; + for (var prop in obj) + if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) + target[prop] = obj[prop]; + return target; +} + +// This can be used to attach properties to mode objects from +// outside the actual mode definition. +var modeExtensions = exports.modeExtensions = {}; +exports.extendMode = function(mode, properties) { + var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); + copyObj(properties, exts); +}; + exports.getMode = function(options, spec) { - spec = exports.resolveMode(spec); + var spec = exports.resolveMode(spec); var mfactory = modes[spec.name]; - if (!mfactory) throw new Error("Unknown mode: " + spec); - return mfactory(options, spec); + if (!mfactory) return exports.getMode(options, "text/plain"); + var modeObj = mfactory(options, spec); + if (modeExtensions.hasOwnProperty(spec.name)) { + var exts = modeExtensions[spec.name]; + for (var prop in exts) { + if (!exts.hasOwnProperty(prop)) continue; + if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop]; + modeObj[prop] = exts[prop]; + } + } + modeObj.name = spec.name; + if (spec.helperType) modeObj.helperType = spec.helperType; + if (spec.modeProps) for (var prop in spec.modeProps) + modeObj[prop] = spec.modeProps[prop]; + + return modeObj; }; exports.registerHelper = exports.registerGlobalHelper = Math.min; diff --git a/public/vendor/codemirror/addon/search/searchcursor.js b/public/vendor/codemirror/addon/search/searchcursor.js index 97088bf1..b70242ee 100755 --- a/public/vendor/codemirror/addon/search/searchcursor.js +++ b/public/vendor/codemirror/addon/search/searchcursor.js @@ -177,9 +177,9 @@ }); CodeMirror.defineExtension("selectMatches", function(query, caseFold) { - var ranges = [], next; + var ranges = []; var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold); - while (next = cur.findNext()) { + while (cur.findNext()) { if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break; ranges.push({anchor: cur.from(), head: cur.to()}); } diff --git a/public/vendor/codemirror/addon/tern/tern.js b/public/vendor/codemirror/addon/tern/tern.js index 99b8a646..dfb19b84 100755 --- a/public/vendor/codemirror/addon/tern/tern.js +++ b/public/vendor/codemirror/addon/tern/tern.js @@ -59,6 +59,7 @@ this.options = options || {}; var plugins = this.options.plugins || (this.options.plugins = {}); if (!plugins.doc_comment) plugins.doc_comment = true; + this.docs = Object.create(null); if (this.options.useWorker) { this.server = new WorkerServer(this); } else { @@ -69,7 +70,6 @@ plugins: plugins }); } - this.docs = Object.create(null); this.trackChange = function(doc, change) { trackChange(self, doc, change); }; this.cachedArgHints = null; @@ -124,6 +124,8 @@ var self = this; var doc = findDoc(this, cm.getDoc()); var request = buildRequest(this, doc, query, pos); + var extraOptions = request.query && this.options.queryOptions && this.options.queryOptions[request.query.type] + if (extraOptions) for (var prop in extraOptions) request.query[prop] = extraOptions[prop]; this.server.request(request, function (error, data) { if (!error && self.options.responseFilter) @@ -442,7 +444,7 @@ function atInterestingExpression(cm) { var pos = cm.getCursor("end"), tok = cm.getTokenAt(pos); - if (tok.start < pos.ch && (tok.type == "comment" || tok.type == "string")) return false; + if (tok.start < pos.ch && tok.type == "comment") return false; return /[\w)\]]/.test(cm.getLine(pos.line).slice(Math.max(pos.ch - 1, 0), pos.ch + 1)); } diff --git a/public/vendor/codemirror/addon/tern/worker.js b/public/vendor/codemirror/addon/tern/worker.js index 48277af8..887f906a 100755 --- a/public/vendor/codemirror/addon/tern/worker.js +++ b/public/vendor/codemirror/addon/tern/worker.js @@ -39,6 +39,6 @@ function startServer(defs, plugins, scripts) { }); } -var console = { +this.console = { log: function(v) { postMessage({type: "debug", message: v}); } }; -- cgit v1.2.3