Update ACE Editor to version 1.2.9
The new ACE editor introduces full support for emojis (and, thereby, UTF-16 characters with high- and low-surrogates). Hence, we can remove our custom fix. Further, this update will allow emojis to be used in pair programming sessions.
This commit is contained in:
103
vendor/assets/javascripts/ace/ext-emmet.js
vendored
103
vendor/assets/javascripts/ace/ext-emmet.js
vendored
@@ -243,6 +243,7 @@ var SnippetManager = function() {
|
||||
if (cursor.column < indentString.length)
|
||||
indentString = indentString.slice(0, cursor.column);
|
||||
|
||||
snippetText = snippetText.replace(/\r/g, "");
|
||||
var tokens = this.tokenizeTmSnippet(snippetText);
|
||||
tokens = this.resolveVariables(tokens, editor);
|
||||
tokens = tokens.map(function(x) {
|
||||
@@ -271,14 +272,14 @@ var SnippetManager = function() {
|
||||
return;
|
||||
|
||||
var value = tokens.slice(i + 1, i1);
|
||||
var isNested = value.some(function(t) {return typeof t === "object"});
|
||||
var isNested = value.some(function(t) {return typeof t === "object";});
|
||||
if (isNested && !ts.value) {
|
||||
ts.value = value;
|
||||
} else if (value.length && (!ts.value || typeof ts.value !== "string")) {
|
||||
ts.value = value.join("");
|
||||
}
|
||||
});
|
||||
tabstops.forEach(function(ts) {ts.length = 0});
|
||||
tabstops.forEach(function(ts) {ts.length = 0;});
|
||||
var expanding = {};
|
||||
function copyValue(val) {
|
||||
var copy = [];
|
||||
@@ -320,9 +321,10 @@ var SnippetManager = function() {
|
||||
var text = "";
|
||||
tokens.forEach(function(t) {
|
||||
if (typeof t === "string") {
|
||||
if (t[0] === "\n"){
|
||||
column = t.length - 1;
|
||||
row ++;
|
||||
var lines = t.split("\n");
|
||||
if (lines.length > 1){
|
||||
column = lines[lines.length - 1].length;
|
||||
row += lines.length - 1;
|
||||
} else
|
||||
column += t.length;
|
||||
text += t;
|
||||
@@ -502,7 +504,10 @@ var SnippetManager = function() {
|
||||
s.guard = "\\b";
|
||||
s.trigger = lang.escapeRegExp(s.tabTrigger);
|
||||
}
|
||||
|
||||
|
||||
if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard)
|
||||
return;
|
||||
|
||||
s.startRe = guardedRegexp(s.trigger, s.guard, true);
|
||||
s.triggerRe = new RegExp(s.trigger, "", true);
|
||||
|
||||
@@ -901,7 +906,7 @@ var Editor = require("./editor").Editor;
|
||||
|
||||
});
|
||||
|
||||
define("ace/ext/emmet",["require","exports","module","ace/keyboard/hash_handler","ace/editor","ace/snippets","ace/range","resources","resources","range","tabStops","resources","utils","actions","ace/config","ace/config"], function(require, exports, module) {
|
||||
define("ace/ext/emmet",["require","exports","module","ace/keyboard/hash_handler","ace/editor","ace/snippets","ace/range","resources","resources","tabStops","resources","utils","actions","ace/config","ace/config"], function(require, exports, module) {
|
||||
"use strict";
|
||||
var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
|
||||
var Editor = require("ace/editor").Editor;
|
||||
@@ -916,7 +921,8 @@ AceEmmetEditor.prototype = {
|
||||
this.indentation = editor.session.getTabString();
|
||||
if (!emmet)
|
||||
emmet = window.emmet;
|
||||
emmet.require("resources").setVariable("indentation", this.indentation);
|
||||
var resources = emmet.resources || emmet.require("resources");
|
||||
resources.setVariable("indentation", this.indentation);
|
||||
this.$syntax = null;
|
||||
this.$syntax = this.getSyntax();
|
||||
},
|
||||
@@ -996,18 +1002,21 @@ AceEmmetEditor.prototype = {
|
||||
return syntax;
|
||||
},
|
||||
getProfileName: function() {
|
||||
switch(this.getSyntax()) {
|
||||
var resources = emmet.resources || emmet.require("resources");
|
||||
switch (this.getSyntax()) {
|
||||
case "css": return "css";
|
||||
case "xml":
|
||||
case "xsl":
|
||||
return "xml";
|
||||
case "html":
|
||||
var profile = emmet.require("resources").getVariable("profile");
|
||||
var profile = resources.getVariable("profile");
|
||||
if (!profile)
|
||||
profile = this.ace.session.getLines(0,2).join("").search(/<!DOCTYPE[^>]+XHTML/i) != -1 ? "xhtml": "html";
|
||||
return profile;
|
||||
default:
|
||||
var mode = this.ace.session.$mode;
|
||||
return mode.emmetConfig && mode.emmetConfig.profile || "xhtml";
|
||||
}
|
||||
return "xhtml";
|
||||
},
|
||||
prompt: function(title) {
|
||||
return prompt(title);
|
||||
@@ -1022,9 +1031,9 @@ AceEmmetEditor.prototype = {
|
||||
var base = 1000;
|
||||
var zeroBase = 0;
|
||||
var lastZero = null;
|
||||
var range = emmet.require('range');
|
||||
var ts = emmet.require('tabStops');
|
||||
var settings = emmet.require('resources').getVocabulary("user");
|
||||
var ts = emmet.tabStops || emmet.require('tabStops');
|
||||
var resources = emmet.resources || emmet.require("resources");
|
||||
var settings = resources.getVocabulary("user");
|
||||
var tabstopOptions = {
|
||||
tabstop: function(data) {
|
||||
var group = parseInt(data.group, 10);
|
||||
@@ -1042,7 +1051,7 @@ AceEmmetEditor.prototype = {
|
||||
var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}';
|
||||
|
||||
if (isZero) {
|
||||
lastZero = range.create(data.start, result);
|
||||
lastZero = [data.start, result];
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -1059,7 +1068,8 @@ AceEmmetEditor.prototype = {
|
||||
if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) {
|
||||
value += '${0}';
|
||||
} else if (lastZero) {
|
||||
value = emmet.require('utils').replaceSubstring(value, '${0}', lastZero);
|
||||
var common = emmet.utils ? emmet.utils.common : emmet.require('utils');
|
||||
value = common.replaceSubstring(value, '${0}', lastZero[0], lastZero[1]);
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -1095,16 +1105,18 @@ var keymap = {
|
||||
|
||||
var editorProxy = new AceEmmetEditor();
|
||||
exports.commands = new HashHandler();
|
||||
exports.runEmmetCommand = function(editor) {
|
||||
exports.runEmmetCommand = function runEmmetCommand(editor) {
|
||||
try {
|
||||
editorProxy.setupContext(editor);
|
||||
if (editorProxy.getSyntax() == "php")
|
||||
return false;
|
||||
var actions = emmet.require("actions");
|
||||
var actions = emmet.actions || emmet.require("actions");
|
||||
|
||||
if (this.action == "expand_abbreviation_with_tab") {
|
||||
if (!editor.selection.isEmpty())
|
||||
return false;
|
||||
var pos = editor.selection.lead;
|
||||
var token = editor.session.getTokenAt(pos.row, pos.column);
|
||||
if (token && /\btag\b/.test(token.type))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.action == "wrap_with_abbreviation") {
|
||||
@@ -1113,13 +1125,12 @@ exports.runEmmetCommand = function(editor) {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var pos = editor.selection.lead;
|
||||
var token = editor.session.getTokenAt(pos.row, pos.column);
|
||||
if (token && /\btag\b/.test(token.type))
|
||||
return false;
|
||||
|
||||
var result = actions.run(this.action, editorProxy);
|
||||
} catch(e) {
|
||||
if (!emmet) {
|
||||
load(runEmmetCommand.bind(this, editor));
|
||||
return true;
|
||||
}
|
||||
editor._signal("changeStatus", typeof e == "string" ? e : e.message);
|
||||
console.log(e);
|
||||
result = false;
|
||||
@@ -1145,27 +1156,49 @@ exports.updateCommands = function(editor, enabled) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.isSupportedMode = function(modeId) {
|
||||
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(modeId);
|
||||
exports.isSupportedMode = function(mode) {
|
||||
if (!mode) return false;
|
||||
if (mode.emmetConfig) return true;
|
||||
var id = mode.$id || mode;
|
||||
return /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(id);
|
||||
};
|
||||
|
||||
exports.isAvailable = function(editor, command) {
|
||||
if (/(evaluate_math_expression|expand_abbreviation)$/.test(command))
|
||||
return true;
|
||||
var mode = editor.session.$mode;
|
||||
var isSupported = exports.isSupportedMode(mode);
|
||||
if (isSupported && mode.$modes) {
|
||||
try {
|
||||
editorProxy.setupContext(editor);
|
||||
if (/js|php/.test(editorProxy.getSyntax()))
|
||||
isSupported = false;
|
||||
} catch(e) {}
|
||||
}
|
||||
return isSupported;
|
||||
};
|
||||
|
||||
var onChangeMode = function(e, target) {
|
||||
var editor = target;
|
||||
if (!editor)
|
||||
return;
|
||||
var enabled = exports.isSupportedMode(editor.session.$modeId);
|
||||
var enabled = exports.isSupportedMode(editor.session.$mode);
|
||||
if (e.enableEmmet === false)
|
||||
enabled = false;
|
||||
if (enabled) {
|
||||
if (typeof emmetPath == "string") {
|
||||
require("ace/config").loadModule(emmetPath, function() {
|
||||
emmetPath = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
load();
|
||||
exports.updateCommands(editor, enabled);
|
||||
};
|
||||
|
||||
var load = function(cb) {
|
||||
if (typeof emmetPath == "string") {
|
||||
require("ace/config").loadModule(emmetPath, function() {
|
||||
emmetPath = null;
|
||||
cb && cb();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.AceEmmetEditor = AceEmmetEditor;
|
||||
require("ace/config").defineOptions(Editor.prototype, "editor", {
|
||||
enableEmmet: {
|
||||
|
Reference in New Issue
Block a user