forked from Wavyzz/dolibarr
Upgrade ACE Editor from 1.4.7 to 1.4.14
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/lib/dom","ace/editor"], function(require, exports, module) {
|
||||
define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var dom = require("./lib/dom");
|
||||
var oop = require("./lib/oop");
|
||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
var lang = require("./lib/lang");
|
||||
@@ -144,7 +145,9 @@ var SnippetManager = function() {
|
||||
{regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
|
||||
var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function(operator) {
|
||||
return operator.length == 2 ? operator[1] : "\x00";
|
||||
}).split("\x00");
|
||||
}).split("\x00").map(function(value){
|
||||
return {value: value};
|
||||
});
|
||||
stack[0].choices = choices;
|
||||
return [choices[0]];
|
||||
}, next: "start"},
|
||||
@@ -615,6 +618,12 @@ var SnippetManager = function() {
|
||||
}
|
||||
snippetMap[scope].push(s);
|
||||
|
||||
if (s.prefix)
|
||||
s.tabTrigger = s.prefix;
|
||||
|
||||
if (!s.content && s.body)
|
||||
s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body;
|
||||
|
||||
if (s.tabTrigger && !s.trigger) {
|
||||
if (!s.guard && /^\w/.test(s.tabTrigger))
|
||||
s.guard = "\\b";
|
||||
@@ -631,10 +640,13 @@ var SnippetManager = function() {
|
||||
s.endTriggerRe = new RegExp(s.endTrigger);
|
||||
}
|
||||
|
||||
if (snippets && snippets.content)
|
||||
addSnippet(snippets);
|
||||
else if (Array.isArray(snippets))
|
||||
if (Array.isArray(snippets)) {
|
||||
snippets.forEach(addSnippet);
|
||||
} else {
|
||||
Object.keys(snippets).forEach(function(key) {
|
||||
addSnippet(snippets[key]);
|
||||
});
|
||||
}
|
||||
|
||||
this._signal("registerSnippets", {scope: scope});
|
||||
};
|
||||
@@ -684,7 +696,7 @@ var SnippetManager = function() {
|
||||
snippet.tabTrigger = val.match(/^\S*/)[0];
|
||||
if (!snippet.name)
|
||||
snippet.name = val;
|
||||
} else {
|
||||
} else if (key) {
|
||||
snippet[key] = val;
|
||||
}
|
||||
}
|
||||
@@ -833,18 +845,17 @@ var TabstopManager = function(editor) {
|
||||
|
||||
this.selectedTabstop = ts;
|
||||
var range = ts.firstNonLinked || ts;
|
||||
if (ts.choices) range.cursor = range.start;
|
||||
if (!this.editor.inVirtualSelectionMode) {
|
||||
var sel = this.editor.multiSelect;
|
||||
sel.toSingleRange(range.clone());
|
||||
sel.toSingleRange(range);
|
||||
for (var i = 0; i < ts.length; i++) {
|
||||
if (ts.hasLinkedRanges && ts[i].linked)
|
||||
continue;
|
||||
sel.addRange(ts[i].clone(), true);
|
||||
}
|
||||
if (sel.ranges[0])
|
||||
sel.addRange(sel.ranges[0].clone());
|
||||
} else {
|
||||
this.editor.selection.setRange(range);
|
||||
this.editor.selection.fromOrientedRange(range);
|
||||
}
|
||||
|
||||
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
|
||||
@@ -971,14 +982,14 @@ var moveRelative = function(point, start) {
|
||||
};
|
||||
|
||||
|
||||
require("./lib/dom").importCssString("\
|
||||
dom.importCssString("\
|
||||
.ace_snippet-marker {\
|
||||
-moz-box-sizing: border-box;\
|
||||
box-sizing: border-box;\
|
||||
background: rgba(194, 193, 208, 0.09);\
|
||||
border: 1px dotted rgba(211, 208, 235, 0.62);\
|
||||
position: absolute;\
|
||||
}");
|
||||
}", "snippets.css", false);
|
||||
|
||||
exports.snippetManager = new SnippetManager();
|
||||
|
||||
@@ -1330,7 +1341,7 @@ dom.importCssString("\
|
||||
line-height: 1.4;\
|
||||
background: #25282c;\
|
||||
color: #c1c1c1;\
|
||||
}", "autocompletion.css");
|
||||
}", "autocompletion.css", false);
|
||||
|
||||
exports.AcePopup = AcePopup;
|
||||
exports.$singleLineEditor = $singleLineEditor;
|
||||
@@ -1476,6 +1487,7 @@ var Autocomplete = function() {
|
||||
} else if (keepPopupPosition && !prefix) {
|
||||
this.detach();
|
||||
}
|
||||
this.changeTimer.cancel();
|
||||
};
|
||||
|
||||
this.detach = function() {
|
||||
@@ -1538,13 +1550,15 @@ var Autocomplete = function() {
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
var completions = this.completions;
|
||||
this.editor.startOperation({command: {name: "insertMatch"}});
|
||||
if (data.completer && data.completer.insertMatch) {
|
||||
data.completer.insertMatch(this.editor, data);
|
||||
} else {
|
||||
if (this.completions.filterText) {
|
||||
if (completions.filterText) {
|
||||
var ranges = this.editor.selection.getAllRanges();
|
||||
for (var i = 0, range; range = ranges[i]; i++) {
|
||||
range.start.column -= this.completions.filterText.length;
|
||||
range.start.column -= completions.filterText.length;
|
||||
this.editor.session.remove(range);
|
||||
}
|
||||
}
|
||||
@@ -1553,7 +1567,9 @@ var Autocomplete = function() {
|
||||
else
|
||||
this.editor.execCommand("insertstring", data.value || data);
|
||||
}
|
||||
this.detach();
|
||||
if (this.completions == completions)
|
||||
this.detach();
|
||||
this.editor.endOperation();
|
||||
};
|
||||
|
||||
|
||||
@@ -1649,19 +1665,14 @@ var Autocomplete = function() {
|
||||
return this.openPopup(this.editor, "", keepPopupPosition);
|
||||
}
|
||||
var _id = this.gatherCompletionsId;
|
||||
this.gatherCompletions(this.editor, function(err, results) {
|
||||
var detachIfFinished = function() {
|
||||
if (!results.finished) return;
|
||||
return this.detach();
|
||||
}.bind(this);
|
||||
var detachIfFinished = function(results) {
|
||||
if (!results.finished) return;
|
||||
return this.detach();
|
||||
}.bind(this);
|
||||
|
||||
var processResults = function(results) {
|
||||
var prefix = results.prefix;
|
||||
var matches = results && results.matches;
|
||||
|
||||
if (!matches || !matches.length)
|
||||
return detachIfFinished();
|
||||
if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId)
|
||||
return;
|
||||
var matches = results.matches;
|
||||
|
||||
this.completions = new FilteredList(matches);
|
||||
|
||||
@@ -1671,14 +1682,39 @@ var Autocomplete = function() {
|
||||
this.completions.setFilter(prefix);
|
||||
var filtered = this.completions.filtered;
|
||||
if (!filtered.length)
|
||||
return detachIfFinished();
|
||||
return detachIfFinished(results);
|
||||
if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet)
|
||||
return detachIfFinished();
|
||||
return detachIfFinished(results);
|
||||
if (this.autoInsert && filtered.length == 1 && results.finished)
|
||||
return this.insertMatch(filtered[0]);
|
||||
|
||||
this.openPopup(this.editor, prefix, keepPopupPosition);
|
||||
}.bind(this);
|
||||
|
||||
var isImmediate = true;
|
||||
var immediateResults = null;
|
||||
this.gatherCompletions(this.editor, function(err, results) {
|
||||
var prefix = results.prefix;
|
||||
var matches = results && results.matches;
|
||||
|
||||
if (!matches || !matches.length)
|
||||
return detachIfFinished(results);
|
||||
if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId)
|
||||
return;
|
||||
if (isImmediate) {
|
||||
immediateResults = results;
|
||||
return;
|
||||
}
|
||||
|
||||
processResults(results);
|
||||
}.bind(this));
|
||||
|
||||
isImmediate = false;
|
||||
if (immediateResults) {
|
||||
var results = immediateResults;
|
||||
immediateResults = null;
|
||||
processResults(results);
|
||||
}
|
||||
};
|
||||
|
||||
this.cancelContextMenu = function() {
|
||||
@@ -2032,31 +2068,33 @@ var onChangeMode = function(e, editor) {
|
||||
};
|
||||
|
||||
var loadSnippetsForMode = function(mode) {
|
||||
var id = mode.$id;
|
||||
if (typeof mode == "string")
|
||||
mode = config.$modes[mode];
|
||||
if (!mode)
|
||||
return;
|
||||
if (!snippetManager.files)
|
||||
snippetManager.files = {};
|
||||
loadSnippetFile(id);
|
||||
|
||||
loadSnippetFile(mode.$id, mode.snippetFileId);
|
||||
if (mode.modes)
|
||||
mode.modes.forEach(loadSnippetsForMode);
|
||||
};
|
||||
|
||||
var loadSnippetFile = function(id) {
|
||||
if (!id || snippetManager.files[id])
|
||||
var loadSnippetFile = function(id, snippetFilePath) {
|
||||
if (!snippetFilePath || !id || snippetManager.files[id])
|
||||
return;
|
||||
var snippetFilePath = id.replace("mode", "snippets");
|
||||
snippetManager.files[id] = {};
|
||||
config.loadModule(snippetFilePath, function(m) {
|
||||
if (m) {
|
||||
snippetManager.files[id] = m;
|
||||
if (!m.snippets && m.snippetText)
|
||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
||||
snippetManager.register(m.snippets || [], m.scope);
|
||||
if (m.includeScopes) {
|
||||
snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
|
||||
m.includeScopes.forEach(function(x) {
|
||||
loadSnippetFile("ace/mode/" + x);
|
||||
});
|
||||
}
|
||||
if (!m) return;
|
||||
snippetManager.files[id] = m;
|
||||
if (!m.snippets && m.snippetText)
|
||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
||||
snippetManager.register(m.snippets || [], m.scope);
|
||||
if (m.includeScopes) {
|
||||
snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
|
||||
m.includeScopes.forEach(function(x) {
|
||||
loadSnippetsForMode("ace/mode/" + x);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user