Use ace-builds NPM package
This commit is contained in:
parent
2b5a22c132
commit
36d81e839c
16 changed files with 30 additions and 42628 deletions
2
.babelrc
2
.babelrc
|
@ -7,7 +7,7 @@
|
|||
"ignore": [
|
||||
"chrome/content/zotero/include.js",
|
||||
"chrome/content/zotero/xpcom/citeproc.js",
|
||||
"chrome/content/scaffold/ace/*",
|
||||
"chrome/content/ace/*",
|
||||
"chrome/content/scaffold/templates/*",
|
||||
"resource/react.js",
|
||||
"resource/react-dom.js",
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script type="text/javascript" src="chrome://scaffold/content/ace/ace.js"></script>
|
||||
<script type="text/javascript" src="chrome://scaffold/content/ace/mode-javascript.js"></script>
|
||||
<script type="text/javascript" src="chrome://scaffold/content/aceWrapper.js"></script>
|
||||
</head>
|
||||
<body id="body"></body>
|
||||
</html>
|
File diff suppressed because it is too large
Load diff
|
@ -1,514 +0,0 @@
|
|||
define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var lang = require("../lib/lang");
|
||||
var event = require("../lib/event");
|
||||
var searchboxCss = "\
|
||||
.ace_search {\
|
||||
background-color: #ddd;\
|
||||
color: #666;\
|
||||
border: 1px solid #cbcbcb;\
|
||||
border-top: 0 none;\
|
||||
overflow: hidden;\
|
||||
margin: 0;\
|
||||
padding: 4px 6px 0 4px;\
|
||||
position: absolute;\
|
||||
top: 0;\
|
||||
z-index: 99;\
|
||||
white-space: normal;\
|
||||
}\
|
||||
.ace_search.left {\
|
||||
border-left: 0 none;\
|
||||
border-radius: 0px 0px 5px 0px;\
|
||||
left: 0;\
|
||||
}\
|
||||
.ace_search.right {\
|
||||
border-radius: 0px 0px 0px 5px;\
|
||||
border-right: 0 none;\
|
||||
right: 0;\
|
||||
}\
|
||||
.ace_search_form, .ace_replace_form {\
|
||||
margin: 0 20px 4px 0;\
|
||||
overflow: hidden;\
|
||||
line-height: 1.9;\
|
||||
}\
|
||||
.ace_replace_form {\
|
||||
margin-right: 0;\
|
||||
}\
|
||||
.ace_search_form.ace_nomatch {\
|
||||
outline: 1px solid red;\
|
||||
}\
|
||||
.ace_search_field {\
|
||||
border-radius: 3px 0 0 3px;\
|
||||
background-color: white;\
|
||||
color: black;\
|
||||
border: 1px solid #cbcbcb;\
|
||||
border-right: 0 none;\
|
||||
outline: 0;\
|
||||
padding: 0;\
|
||||
font-size: inherit;\
|
||||
margin: 0;\
|
||||
line-height: inherit;\
|
||||
padding: 0 6px;\
|
||||
min-width: 17em;\
|
||||
vertical-align: top;\
|
||||
min-height: 1.8em;\
|
||||
box-sizing: content-box;\
|
||||
}\
|
||||
.ace_searchbtn {\
|
||||
border: 1px solid #cbcbcb;\
|
||||
line-height: inherit;\
|
||||
display: inline-block;\
|
||||
padding: 0 6px;\
|
||||
background: #fff;\
|
||||
border-right: 0 none;\
|
||||
border-left: 1px solid #dcdcdc;\
|
||||
cursor: pointer;\
|
||||
margin: 0;\
|
||||
position: relative;\
|
||||
color: #666;\
|
||||
}\
|
||||
.ace_searchbtn:last-child {\
|
||||
border-radius: 0 3px 3px 0;\
|
||||
border-right: 1px solid #cbcbcb;\
|
||||
}\
|
||||
.ace_searchbtn:disabled {\
|
||||
background: none;\
|
||||
cursor: default;\
|
||||
}\
|
||||
.ace_searchbtn:hover {\
|
||||
background-color: #eef1f6;\
|
||||
}\
|
||||
.ace_searchbtn.prev, .ace_searchbtn.next {\
|
||||
padding: 0px 0.7em\
|
||||
}\
|
||||
.ace_searchbtn.prev:after, .ace_searchbtn.next:after {\
|
||||
content: \"\";\
|
||||
border: solid 2px #888;\
|
||||
width: 0.5em;\
|
||||
height: 0.5em;\
|
||||
border-width: 2px 0 0 2px;\
|
||||
display:inline-block;\
|
||||
transform: rotate(-45deg);\
|
||||
}\
|
||||
.ace_searchbtn.next:after {\
|
||||
border-width: 0 2px 2px 0 ;\
|
||||
}\
|
||||
.ace_searchbtn_close {\
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\
|
||||
border-radius: 50%;\
|
||||
border: 0 none;\
|
||||
color: #656565;\
|
||||
cursor: pointer;\
|
||||
font: 16px/16px Arial;\
|
||||
padding: 0;\
|
||||
height: 14px;\
|
||||
width: 14px;\
|
||||
top: 9px;\
|
||||
right: 7px;\
|
||||
position: absolute;\
|
||||
}\
|
||||
.ace_searchbtn_close:hover {\
|
||||
background-color: #656565;\
|
||||
background-position: 50% 100%;\
|
||||
color: white;\
|
||||
}\
|
||||
.ace_button {\
|
||||
margin-left: 2px;\
|
||||
cursor: pointer;\
|
||||
-webkit-user-select: none;\
|
||||
-moz-user-select: none;\
|
||||
-o-user-select: none;\
|
||||
-ms-user-select: none;\
|
||||
user-select: none;\
|
||||
overflow: hidden;\
|
||||
opacity: 0.7;\
|
||||
border: 1px solid rgba(100,100,100,0.23);\
|
||||
padding: 1px;\
|
||||
box-sizing: border-box!important;\
|
||||
color: black;\
|
||||
}\
|
||||
.ace_button:hover {\
|
||||
background-color: #eee;\
|
||||
opacity:1;\
|
||||
}\
|
||||
.ace_button:active {\
|
||||
background-color: #ddd;\
|
||||
}\
|
||||
.ace_button.checked {\
|
||||
border-color: #3399ff;\
|
||||
opacity:1;\
|
||||
}\
|
||||
.ace_search_options{\
|
||||
margin-bottom: 3px;\
|
||||
text-align: right;\
|
||||
-webkit-user-select: none;\
|
||||
-moz-user-select: none;\
|
||||
-o-user-select: none;\
|
||||
-ms-user-select: none;\
|
||||
user-select: none;\
|
||||
clear: both;\
|
||||
}\
|
||||
.ace_search_counter {\
|
||||
float: left;\
|
||||
font-family: arial;\
|
||||
padding: 0 8px;\
|
||||
}";
|
||||
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
||||
var keyUtil = require("../lib/keys");
|
||||
|
||||
var MAX_COUNT = 999;
|
||||
|
||||
dom.importCssString(searchboxCss, "ace_searchbox");
|
||||
|
||||
var SearchBox = function(editor, range, showReplaceForm) {
|
||||
var div = dom.createElement("div");
|
||||
dom.buildDom(["div", {class:"ace_search right"},
|
||||
["span", {action: "hide", class: "ace_searchbtn_close"}],
|
||||
["div", {class: "ace_search_form"},
|
||||
["input", {class: "ace_search_field", placeholder: "Search for", spellcheck: "false"}],
|
||||
["span", {action: "findPrev", class: "ace_searchbtn prev"}, "\u200b"],
|
||||
["span", {action: "findNext", class: "ace_searchbtn next"}, "\u200b"],
|
||||
["span", {action: "findAll", class: "ace_searchbtn", title: "Alt-Enter"}, "All"]
|
||||
],
|
||||
["div", {class: "ace_replace_form"},
|
||||
["input", {class: "ace_search_field", placeholder: "Replace with", spellcheck: "false"}],
|
||||
["span", {action: "replaceAndFindNext", class: "ace_searchbtn"}, "Replace"],
|
||||
["span", {action: "replaceAll", class: "ace_searchbtn"}, "All"]
|
||||
],
|
||||
["div", {class: "ace_search_options"},
|
||||
["span", {action: "toggleReplace", class: "ace_button", title: "Toggle Replace mode",
|
||||
style: "float:left;margin-top:-2px;padding:0 5px;"}, "+"],
|
||||
["span", {class: "ace_search_counter"}],
|
||||
["span", {action: "toggleRegexpMode", class: "ace_button", title: "RegExp Search"}, ".*"],
|
||||
["span", {action: "toggleCaseSensitive", class: "ace_button", title: "CaseSensitive Search"}, "Aa"],
|
||||
["span", {action: "toggleWholeWords", class: "ace_button", title: "Whole Word Search"}, "\\b"],
|
||||
["span", {action: "searchInSelection", class: "ace_button", title: "Search In Selection"}, "S"]
|
||||
]
|
||||
], div);
|
||||
this.element = div.firstChild;
|
||||
|
||||
this.setSession = this.setSession.bind(this);
|
||||
|
||||
this.$init();
|
||||
this.setEditor(editor);
|
||||
dom.importCssString(searchboxCss, "ace_searchbox", editor.container);
|
||||
};
|
||||
|
||||
(function() {
|
||||
this.setEditor = function(editor) {
|
||||
editor.searchBox = this;
|
||||
editor.renderer.scroller.appendChild(this.element);
|
||||
this.editor = editor;
|
||||
};
|
||||
|
||||
this.setSession = function(e) {
|
||||
this.searchRange = null;
|
||||
this.$syncOptions(true);
|
||||
};
|
||||
|
||||
this.$initElements = function(sb) {
|
||||
this.searchBox = sb.querySelector(".ace_search_form");
|
||||
this.replaceBox = sb.querySelector(".ace_replace_form");
|
||||
this.searchOption = sb.querySelector("[action=searchInSelection]");
|
||||
this.replaceOption = sb.querySelector("[action=toggleReplace]");
|
||||
this.regExpOption = sb.querySelector("[action=toggleRegexpMode]");
|
||||
this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]");
|
||||
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
|
||||
this.searchInput = this.searchBox.querySelector(".ace_search_field");
|
||||
this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
|
||||
this.searchCounter = sb.querySelector(".ace_search_counter");
|
||||
};
|
||||
|
||||
this.$init = function() {
|
||||
var sb = this.element;
|
||||
|
||||
this.$initElements(sb);
|
||||
|
||||
var _this = this;
|
||||
event.addListener(sb, "mousedown", function(e) {
|
||||
setTimeout(function(){
|
||||
_this.activeInput.focus();
|
||||
}, 0);
|
||||
event.stopPropagation(e);
|
||||
});
|
||||
event.addListener(sb, "click", function(e) {
|
||||
var t = e.target || e.srcElement;
|
||||
var action = t.getAttribute("action");
|
||||
if (action && _this[action])
|
||||
_this[action]();
|
||||
else if (_this.$searchBarKb.commands[action])
|
||||
_this.$searchBarKb.commands[action].exec(_this);
|
||||
event.stopPropagation(e);
|
||||
});
|
||||
|
||||
event.addCommandKeyListener(sb, function(e, hashId, keyCode) {
|
||||
var keyString = keyUtil.keyCodeToString(keyCode);
|
||||
var command = _this.$searchBarKb.findKeyCommand(hashId, keyString);
|
||||
if (command && command.exec) {
|
||||
command.exec(_this);
|
||||
event.stopEvent(e);
|
||||
}
|
||||
});
|
||||
|
||||
this.$onChange = lang.delayedCall(function() {
|
||||
_this.find(false, false);
|
||||
});
|
||||
|
||||
event.addListener(this.searchInput, "input", function() {
|
||||
_this.$onChange.schedule(20);
|
||||
});
|
||||
event.addListener(this.searchInput, "focus", function() {
|
||||
_this.activeInput = _this.searchInput;
|
||||
_this.searchInput.value && _this.highlight();
|
||||
});
|
||||
event.addListener(this.replaceInput, "focus", function() {
|
||||
_this.activeInput = _this.replaceInput;
|
||||
_this.searchInput.value && _this.highlight();
|
||||
});
|
||||
};
|
||||
this.$closeSearchBarKb = new HashHandler([{
|
||||
bindKey: "Esc",
|
||||
name: "closeSearchBar",
|
||||
exec: function(editor) {
|
||||
editor.searchBox.hide();
|
||||
}
|
||||
}]);
|
||||
this.$searchBarKb = new HashHandler();
|
||||
this.$searchBarKb.bindKeys({
|
||||
"Ctrl-f|Command-f": function(sb) {
|
||||
var isReplace = sb.isReplace = !sb.isReplace;
|
||||
sb.replaceBox.style.display = isReplace ? "" : "none";
|
||||
sb.replaceOption.checked = false;
|
||||
sb.$syncOptions();
|
||||
sb.searchInput.focus();
|
||||
},
|
||||
"Ctrl-H|Command-Option-F": function(sb) {
|
||||
if (sb.editor.getReadOnly())
|
||||
return;
|
||||
sb.replaceOption.checked = true;
|
||||
sb.$syncOptions();
|
||||
sb.replaceInput.focus();
|
||||
},
|
||||
"Ctrl-G|Command-G": function(sb) {
|
||||
sb.findNext();
|
||||
},
|
||||
"Ctrl-Shift-G|Command-Shift-G": function(sb) {
|
||||
sb.findPrev();
|
||||
},
|
||||
"esc": function(sb) {
|
||||
setTimeout(function() { sb.hide();});
|
||||
},
|
||||
"Return": function(sb) {
|
||||
if (sb.activeInput == sb.replaceInput)
|
||||
sb.replace();
|
||||
sb.findNext();
|
||||
},
|
||||
"Shift-Return": function(sb) {
|
||||
if (sb.activeInput == sb.replaceInput)
|
||||
sb.replace();
|
||||
sb.findPrev();
|
||||
},
|
||||
"Alt-Return": function(sb) {
|
||||
if (sb.activeInput == sb.replaceInput)
|
||||
sb.replaceAll();
|
||||
sb.findAll();
|
||||
},
|
||||
"Tab": function(sb) {
|
||||
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
|
||||
}
|
||||
});
|
||||
|
||||
this.$searchBarKb.addCommands([{
|
||||
name: "toggleRegexpMode",
|
||||
bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"},
|
||||
exec: function(sb) {
|
||||
sb.regExpOption.checked = !sb.regExpOption.checked;
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}, {
|
||||
name: "toggleCaseSensitive",
|
||||
bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"},
|
||||
exec: function(sb) {
|
||||
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}, {
|
||||
name: "toggleWholeWords",
|
||||
bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"},
|
||||
exec: function(sb) {
|
||||
sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}, {
|
||||
name: "toggleReplace",
|
||||
exec: function(sb) {
|
||||
sb.replaceOption.checked = !sb.replaceOption.checked;
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}, {
|
||||
name: "searchInSelection",
|
||||
exec: function(sb) {
|
||||
sb.searchOption.checked = !sb.searchRange;
|
||||
sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange());
|
||||
sb.$syncOptions();
|
||||
}
|
||||
}]);
|
||||
|
||||
this.setSearchRange = function(range) {
|
||||
this.searchRange = range;
|
||||
if (range) {
|
||||
this.searchRangeMarker = this.editor.session.addMarker(range, "ace_active-line");
|
||||
} else if (this.searchRangeMarker) {
|
||||
this.editor.session.removeMarker(this.searchRangeMarker);
|
||||
this.searchRangeMarker = null;
|
||||
}
|
||||
};
|
||||
|
||||
this.$syncOptions = function(preventScroll) {
|
||||
dom.setCssClass(this.replaceOption, "checked", this.searchRange);
|
||||
dom.setCssClass(this.searchOption, "checked", this.searchOption.checked);
|
||||
this.replaceOption.textContent = this.replaceOption.checked ? "-" : "+";
|
||||
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
|
||||
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked);
|
||||
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked);
|
||||
var readOnly = this.editor.getReadOnly();
|
||||
this.replaceOption.style.display = readOnly ? "none" : "";
|
||||
this.replaceBox.style.display = this.replaceOption.checked && !readOnly ? "" : "none";
|
||||
this.find(false, false, preventScroll);
|
||||
};
|
||||
|
||||
this.highlight = function(re) {
|
||||
this.editor.session.highlight(re || this.editor.$search.$options.re);
|
||||
this.editor.renderer.updateBackMarkers();
|
||||
};
|
||||
this.find = function(skipCurrent, backwards, preventScroll) {
|
||||
var range = this.editor.find(this.searchInput.value, {
|
||||
skipCurrent: skipCurrent,
|
||||
backwards: backwards,
|
||||
wrap: true,
|
||||
regExp: this.regExpOption.checked,
|
||||
caseSensitive: this.caseSensitiveOption.checked,
|
||||
wholeWord: this.wholeWordOption.checked,
|
||||
preventScroll: preventScroll,
|
||||
range: this.searchRange
|
||||
});
|
||||
var noMatch = !range && this.searchInput.value;
|
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
||||
this.editor._emit("findSearchBox", { match: !noMatch });
|
||||
this.highlight();
|
||||
this.updateCounter();
|
||||
};
|
||||
this.updateCounter = function() {
|
||||
var editor = this.editor;
|
||||
var regex = editor.$search.$options.re;
|
||||
var all = 0;
|
||||
var before = 0;
|
||||
if (regex) {
|
||||
var value = this.searchRange
|
||||
? editor.session.getTextRange(this.searchRange)
|
||||
: editor.getValue();
|
||||
|
||||
var offset = editor.session.doc.positionToIndex(editor.selection.anchor);
|
||||
if (this.searchRange)
|
||||
offset -= editor.session.doc.positionToIndex(this.searchRange.start);
|
||||
|
||||
var last = regex.lastIndex = 0;
|
||||
var m;
|
||||
while ((m = regex.exec(value))) {
|
||||
all++;
|
||||
last = m.index;
|
||||
if (last <= offset)
|
||||
before++;
|
||||
if (all > MAX_COUNT)
|
||||
break;
|
||||
if (!m[0]) {
|
||||
regex.lastIndex = last += 1;
|
||||
if (last >= value.length)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.searchCounter.textContent = before + " of " + (all > MAX_COUNT ? MAX_COUNT + "+" : all);
|
||||
};
|
||||
this.findNext = function() {
|
||||
this.find(true, false);
|
||||
};
|
||||
this.findPrev = function() {
|
||||
this.find(true, true);
|
||||
};
|
||||
this.findAll = function(){
|
||||
var range = this.editor.findAll(this.searchInput.value, {
|
||||
regExp: this.regExpOption.checked,
|
||||
caseSensitive: this.caseSensitiveOption.checked,
|
||||
wholeWord: this.wholeWordOption.checked
|
||||
});
|
||||
var noMatch = !range && this.searchInput.value;
|
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
||||
this.editor._emit("findSearchBox", { match: !noMatch });
|
||||
this.highlight();
|
||||
this.hide();
|
||||
};
|
||||
this.replace = function() {
|
||||
if (!this.editor.getReadOnly())
|
||||
this.editor.replace(this.replaceInput.value);
|
||||
};
|
||||
this.replaceAndFindNext = function() {
|
||||
if (!this.editor.getReadOnly()) {
|
||||
this.editor.replace(this.replaceInput.value);
|
||||
this.findNext();
|
||||
}
|
||||
};
|
||||
this.replaceAll = function() {
|
||||
if (!this.editor.getReadOnly())
|
||||
this.editor.replaceAll(this.replaceInput.value);
|
||||
};
|
||||
|
||||
this.hide = function() {
|
||||
this.active = false;
|
||||
this.setSearchRange(null);
|
||||
this.editor.off("changeSession", this.setSession);
|
||||
|
||||
this.element.style.display = "none";
|
||||
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
|
||||
this.editor.focus();
|
||||
};
|
||||
this.show = function(value, isReplace) {
|
||||
this.active = true;
|
||||
this.editor.on("changeSession", this.setSession);
|
||||
this.element.style.display = "";
|
||||
this.replaceOption.checked = isReplace;
|
||||
|
||||
if (value)
|
||||
this.searchInput.value = value;
|
||||
|
||||
this.searchInput.focus();
|
||||
this.searchInput.select();
|
||||
|
||||
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
|
||||
|
||||
this.$syncOptions(true);
|
||||
};
|
||||
|
||||
this.isFocused = function() {
|
||||
var el = document.activeElement;
|
||||
return el == this.searchInput || el == this.replaceInput;
|
||||
};
|
||||
}).call(SearchBox.prototype);
|
||||
|
||||
exports.SearchBox = SearchBox;
|
||||
|
||||
exports.Search = function(editor, isReplace) {
|
||||
var sb = editor.searchBox || new SearchBox(editor);
|
||||
sb.show(editor.session.getTextRange(), isReplace);
|
||||
};
|
||||
|
||||
}); (function() {
|
||||
window.require(["ace/ext/searchbox"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,789 +0,0 @@
|
|||
define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DocCommentHighlightRules = function() {
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment.doc.tag",
|
||||
regex : "@[\\w\\d_]+" // TODO: fix email addresses
|
||||
},
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{
|
||||
defaultToken : "comment.doc",
|
||||
caseInsensitive: true
|
||||
}]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
||||
|
||||
DocCommentHighlightRules.getTagRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc.tag.storage.type",
|
||||
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
|
||||
};
|
||||
}
|
||||
|
||||
DocCommentHighlightRules.getStartRule = function(start) {
|
||||
return {
|
||||
token : "comment.doc", // doc comment
|
||||
regex : "\\/\\*(?=\\*)",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
DocCommentHighlightRules.getEndRule = function (start) {
|
||||
return {
|
||||
token : "comment.doc", // closing comment
|
||||
regex : "\\*\\/",
|
||||
next : start
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
||||
|
||||
});
|
||||
|
||||
define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
|
||||
|
||||
var JavaScriptHighlightRules = function(options) {
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"variable.language":
|
||||
"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
|
||||
"Namespace|QName|XML|XMLList|" + // E4X
|
||||
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
|
||||
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
|
||||
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
|
||||
"SyntaxError|TypeError|URIError|" +
|
||||
"decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
|
||||
"isNaN|parseFloat|parseInt|" +
|
||||
"JSON|Math|" + // Other
|
||||
"this|arguments|prototype|window|document" , // Pseudo
|
||||
"keyword":
|
||||
"const|yield|import|get|set|async|await|" +
|
||||
"break|case|catch|continue|default|delete|do|else|finally|for|function|" +
|
||||
"if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
|
||||
"__parent__|__count__|escape|unescape|with|__proto__|" +
|
||||
"class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
|
||||
"storage.type":
|
||||
"const|let|var|function",
|
||||
"constant.language":
|
||||
"null|Infinity|NaN|undefined",
|
||||
"support.function":
|
||||
"alert",
|
||||
"constant.language.boolean": "true|false"
|
||||
}, "identifier");
|
||||
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
|
||||
|
||||
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
|
||||
"u[0-9a-fA-F]{4}|" + // unicode
|
||||
"u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
|
||||
"[0-2][0-7]{0,2}|" + // oct
|
||||
"3[0-7][0-7]?|" + // oct
|
||||
"[4-7][0-7]?|" + //oct
|
||||
".)";
|
||||
|
||||
this.$rules = {
|
||||
"no_regex" : [
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
comments("no_regex"),
|
||||
{
|
||||
token : "string",
|
||||
regex : "'(?=.)",
|
||||
next : "qstring"
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '"(?=.)',
|
||||
next : "qqstring"
|
||||
}, {
|
||||
token : "constant.numeric", // hexadecimal, octal and binary
|
||||
regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
|
||||
}, {
|
||||
token : "constant.numeric", // decimal integers and floats
|
||||
regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
|
||||
}, {
|
||||
token : [
|
||||
"storage.type", "punctuation.operator", "support.function",
|
||||
"punctuation.operator", "entity.name.function", "text","keyword.operator"
|
||||
],
|
||||
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
|
||||
next: "function_arguments"
|
||||
}, {
|
||||
token : [
|
||||
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
||||
"keyword.operator", "text", "storage.type", "text", "paren.lparen"
|
||||
],
|
||||
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
|
||||
next: "function_arguments"
|
||||
}, {
|
||||
token : [
|
||||
"entity.name.function", "text", "keyword.operator", "text", "storage.type",
|
||||
"text", "paren.lparen"
|
||||
],
|
||||
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
|
||||
next: "function_arguments"
|
||||
}, {
|
||||
token : [
|
||||
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
||||
"keyword.operator", "text",
|
||||
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
||||
],
|
||||
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
|
||||
next: "function_arguments"
|
||||
}, {
|
||||
token : [
|
||||
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
||||
],
|
||||
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
|
||||
next: "function_arguments"
|
||||
}, {
|
||||
token : [
|
||||
"entity.name.function", "text", "punctuation.operator",
|
||||
"text", "storage.type", "text", "paren.lparen"
|
||||
],
|
||||
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
|
||||
next: "function_arguments"
|
||||
}, {
|
||||
token : [
|
||||
"text", "text", "storage.type", "text", "paren.lparen"
|
||||
],
|
||||
regex : "(:)(\\s*)(function)(\\s*)(\\()",
|
||||
next: "function_arguments"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : "from(?=\\s*('|\"))"
|
||||
}, {
|
||||
token : "keyword",
|
||||
regex : "(?:" + kwBeforeRe + ")\\b",
|
||||
next : "start"
|
||||
}, {
|
||||
token : ["support.constant"],
|
||||
regex : /that\b/
|
||||
}, {
|
||||
token : ["storage.type", "punctuation.operator", "support.function.firebug"],
|
||||
regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : identifierRe
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : /[.](?![.])/,
|
||||
next : "property"
|
||||
}, {
|
||||
token : "storage.type",
|
||||
regex : /=>/
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
|
||||
next : "start"
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : /[?:,;.]/,
|
||||
next : "start"
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : /[\[({]/,
|
||||
next : "start"
|
||||
}, {
|
||||
token : "paren.rparen",
|
||||
regex : /[\])}]/
|
||||
}, {
|
||||
token: "comment",
|
||||
regex: /^#!.*$/
|
||||
}
|
||||
],
|
||||
property: [{
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
token : [
|
||||
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
||||
"keyword.operator", "text",
|
||||
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
||||
],
|
||||
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
|
||||
next: "function_arguments"
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : /[.](?![.])/
|
||||
}, {
|
||||
token : "support.function",
|
||||
regex : /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
|
||||
}, {
|
||||
token : "support.function.dom",
|
||||
regex : /(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
|
||||
}, {
|
||||
token : "support.constant",
|
||||
regex : /(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
|
||||
}, {
|
||||
token : "identifier",
|
||||
regex : identifierRe
|
||||
}, {
|
||||
regex: "",
|
||||
token: "empty",
|
||||
next: "no_regex"
|
||||
}
|
||||
],
|
||||
"start": [
|
||||
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||
comments("start"),
|
||||
{
|
||||
token: "string.regexp",
|
||||
regex: "\\/",
|
||||
next: "regex"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+|^$",
|
||||
next : "start"
|
||||
}, {
|
||||
token: "empty",
|
||||
regex: "",
|
||||
next: "no_regex"
|
||||
}
|
||||
],
|
||||
"regex": [
|
||||
{
|
||||
token: "regexp.keyword.operator",
|
||||
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
|
||||
}, {
|
||||
token: "string.regexp",
|
||||
regex: "/[sxngimy]*",
|
||||
next: "no_regex"
|
||||
}, {
|
||||
token : "invalid",
|
||||
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
|
||||
}, {
|
||||
token : "constant.language.escape",
|
||||
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
|
||||
}, {
|
||||
token : "constant.language.delimiter",
|
||||
regex: /\|/
|
||||
}, {
|
||||
token: "constant.language.escape",
|
||||
regex: /\[\^?/,
|
||||
next: "regex_character_class"
|
||||
}, {
|
||||
token: "empty",
|
||||
regex: "$",
|
||||
next: "no_regex"
|
||||
}, {
|
||||
defaultToken: "string.regexp"
|
||||
}
|
||||
],
|
||||
"regex_character_class": [
|
||||
{
|
||||
token: "regexp.charclass.keyword.operator",
|
||||
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
|
||||
}, {
|
||||
token: "constant.language.escape",
|
||||
regex: "]",
|
||||
next: "regex"
|
||||
}, {
|
||||
token: "constant.language.escape",
|
||||
regex: "-"
|
||||
}, {
|
||||
token: "empty",
|
||||
regex: "$",
|
||||
next: "no_regex"
|
||||
}, {
|
||||
defaultToken: "string.regexp.charachterclass"
|
||||
}
|
||||
],
|
||||
"function_arguments": [
|
||||
{
|
||||
token: "variable.parameter",
|
||||
regex: identifierRe
|
||||
}, {
|
||||
token: "punctuation.operator",
|
||||
regex: "[, ]+"
|
||||
}, {
|
||||
token: "punctuation.operator",
|
||||
regex: "$"
|
||||
}, {
|
||||
token: "empty",
|
||||
regex: "",
|
||||
next: "no_regex"
|
||||
}
|
||||
],
|
||||
"qqstring" : [
|
||||
{
|
||||
token : "constant.language.escape",
|
||||
regex : escapedRe
|
||||
}, {
|
||||
token : "string",
|
||||
regex : "\\\\$",
|
||||
consumeLineEnd : true
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '"|$',
|
||||
next : "no_regex"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}
|
||||
],
|
||||
"qstring" : [
|
||||
{
|
||||
token : "constant.language.escape",
|
||||
regex : escapedRe
|
||||
}, {
|
||||
token : "string",
|
||||
regex : "\\\\$",
|
||||
consumeLineEnd : true
|
||||
}, {
|
||||
token : "string",
|
||||
regex : "'|$",
|
||||
next : "no_regex"
|
||||
}, {
|
||||
defaultToken: "string"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
if (!options || !options.noES6) {
|
||||
this.$rules.no_regex.unshift({
|
||||
regex: "[{}]", onMatch: function(val, state, stack) {
|
||||
this.next = val == "{" ? this.nextState : "";
|
||||
if (val == "{" && stack.length) {
|
||||
stack.unshift("start", state);
|
||||
}
|
||||
else if (val == "}" && stack.length) {
|
||||
stack.shift();
|
||||
this.next = stack.shift();
|
||||
if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
|
||||
return "paren.quasi.end";
|
||||
}
|
||||
return val == "{" ? "paren.lparen" : "paren.rparen";
|
||||
},
|
||||
nextState: "start"
|
||||
}, {
|
||||
token : "string.quasi.start",
|
||||
regex : /`/,
|
||||
push : [{
|
||||
token : "constant.language.escape",
|
||||
regex : escapedRe
|
||||
}, {
|
||||
token : "paren.quasi.start",
|
||||
regex : /\${/,
|
||||
push : "start"
|
||||
}, {
|
||||
token : "string.quasi.end",
|
||||
regex : /`/,
|
||||
next : "pop"
|
||||
}, {
|
||||
defaultToken: "string.quasi"
|
||||
}]
|
||||
});
|
||||
|
||||
if (!options || options.jsx != false)
|
||||
JSX.call(this);
|
||||
}
|
||||
|
||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
|
||||
|
||||
function JSX() {
|
||||
var tagRegex = identifierRe.replace("\\d", "\\d\\-");
|
||||
var jsxTag = {
|
||||
onMatch : function(val, state, stack) {
|
||||
var offset = val.charAt(1) == "/" ? 2 : 1;
|
||||
if (offset == 1) {
|
||||
if (state != this.nextState)
|
||||
stack.unshift(this.next, this.nextState, 0);
|
||||
else
|
||||
stack.unshift(this.next);
|
||||
stack[2]++;
|
||||
} else if (offset == 2) {
|
||||
if (state == this.nextState) {
|
||||
stack[1]--;
|
||||
if (!stack[1] || stack[1] < 0) {
|
||||
stack.shift();
|
||||
stack.shift();
|
||||
}
|
||||
}
|
||||
}
|
||||
return [{
|
||||
type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
|
||||
value: val.slice(0, offset)
|
||||
}, {
|
||||
type: "meta.tag.tag-name.xml",
|
||||
value: val.substr(offset)
|
||||
}];
|
||||
},
|
||||
regex : "</?" + tagRegex + "",
|
||||
next: "jsxAttributes",
|
||||
nextState: "jsx"
|
||||
};
|
||||
this.$rules.start.unshift(jsxTag);
|
||||
var jsxJsRule = {
|
||||
regex: "{",
|
||||
token: "paren.quasi.start",
|
||||
push: "start"
|
||||
};
|
||||
this.$rules.jsx = [
|
||||
jsxJsRule,
|
||||
jsxTag,
|
||||
{include : "reference"},
|
||||
{defaultToken: "string"}
|
||||
];
|
||||
this.$rules.jsxAttributes = [{
|
||||
token : "meta.tag.punctuation.tag-close.xml",
|
||||
regex : "/?>",
|
||||
onMatch : function(value, currentState, stack) {
|
||||
if (currentState == stack[0])
|
||||
stack.shift();
|
||||
if (value.length == 2) {
|
||||
if (stack[0] == this.nextState)
|
||||
stack[1]--;
|
||||
if (!stack[1] || stack[1] < 0) {
|
||||
stack.splice(0, 2);
|
||||
}
|
||||
}
|
||||
this.next = stack[0] || "start";
|
||||
return [{type: this.token, value: value}];
|
||||
},
|
||||
nextState: "jsx"
|
||||
},
|
||||
jsxJsRule,
|
||||
comments("jsxAttributes"),
|
||||
{
|
||||
token : "entity.other.attribute-name.xml",
|
||||
regex : tagRegex
|
||||
}, {
|
||||
token : "keyword.operator.attribute-equals.xml",
|
||||
regex : "="
|
||||
}, {
|
||||
token : "text.tag-whitespace.xml",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
token : "string.attribute-value.xml",
|
||||
regex : "'",
|
||||
stateName : "jsx_attr_q",
|
||||
push : [
|
||||
{token : "string.attribute-value.xml", regex: "'", next: "pop"},
|
||||
{include : "reference"},
|
||||
{defaultToken : "string.attribute-value.xml"}
|
||||
]
|
||||
}, {
|
||||
token : "string.attribute-value.xml",
|
||||
regex : '"',
|
||||
stateName : "jsx_attr_qq",
|
||||
push : [
|
||||
{token : "string.attribute-value.xml", regex: '"', next: "pop"},
|
||||
{include : "reference"},
|
||||
{defaultToken : "string.attribute-value.xml"}
|
||||
]
|
||||
},
|
||||
jsxTag
|
||||
];
|
||||
this.$rules.reference = [{
|
||||
token : "constant.language.escape.reference.xml",
|
||||
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
|
||||
}];
|
||||
}
|
||||
|
||||
function comments(next) {
|
||||
return [
|
||||
{
|
||||
token : "comment", // multi line comment
|
||||
regex : /\/\*/,
|
||||
next: [
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{token : "comment", regex : "\\*\\/", next : next || "pop"},
|
||||
{defaultToken : "comment", caseInsensitive: true}
|
||||
]
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : "\\/\\/",
|
||||
next: [
|
||||
DocCommentHighlightRules.getTagRule(),
|
||||
{token : "comment", regex : "$|^", next : next || "pop"},
|
||||
{defaultToken : "comment", caseInsensitive: true}
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
|
||||
});
|
||||
|
||||
define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require("../range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
(function() {
|
||||
|
||||
this.checkOutdent = function(line, input) {
|
||||
if (! /^\s+$/.test(line))
|
||||
return false;
|
||||
|
||||
return /^\s*\}/.test(input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(doc, row) {
|
||||
var line = doc.getLine(row);
|
||||
var match = line.match(/^(\s*\})/);
|
||||
|
||||
if (!match) return 0;
|
||||
|
||||
var column = match[1].length;
|
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0;
|
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||
};
|
||||
|
||||
this.$getIndent = function(line) {
|
||||
return line.match(/^\s*/)[0];
|
||||
};
|
||||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
||||
define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var Range = require("../../range").Range;
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||
if (commentRegex) {
|
||||
this.foldingStartMarker = new RegExp(
|
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||
);
|
||||
this.foldingStopMarker = new RegExp(
|
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||
);
|
||||
}
|
||||
};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
|
||||
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
|
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||
this._getFoldWidgetBase = this.getFoldWidget;
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) {
|
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||
return "";
|
||||
}
|
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||
|
||||
if (!fw && this.startRegionRe.test(line))
|
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw;
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||
var line = session.getLine(row);
|
||||
|
||||
if (this.startRegionRe.test(line))
|
||||
return this.getCommentRegionBlock(session, line, row);
|
||||
|
||||
var match = line.match(this.foldingStartMarker);
|
||||
if (match) {
|
||||
var i = match.index;
|
||||
|
||||
if (match[1])
|
||||
return this.openingBracketBlock(session, match[1], row, i);
|
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||
|
||||
if (range && !range.isMultiLine()) {
|
||||
if (forceMultiline) {
|
||||
range = this.getSectionRange(session, row);
|
||||
} else if (foldStyle != "all")
|
||||
range = null;
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
if (foldStyle === "markbegin")
|
||||
return;
|
||||
|
||||
var match = line.match(this.foldingStopMarker);
|
||||
if (match) {
|
||||
var i = match.index + match[0].length;
|
||||
|
||||
if (match[1])
|
||||
return this.closingBracketBlock(session, match[1], row, i);
|
||||
|
||||
return session.getCommentFoldRange(row, i, -1);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSectionRange = function(session, row) {
|
||||
var line = session.getLine(row);
|
||||
var startIndent = line.search(/\S/);
|
||||
var startRow = row;
|
||||
var startColumn = line.length;
|
||||
row = row + 1;
|
||||
var endRow = row;
|
||||
var maxRow = session.getLength();
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var indent = line.search(/\S/);
|
||||
if (indent === -1)
|
||||
continue;
|
||||
if (startIndent > indent)
|
||||
break;
|
||||
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||
|
||||
if (subRange) {
|
||||
if (subRange.start.row <= startRow) {
|
||||
break;
|
||||
} else if (subRange.isMultiLine()) {
|
||||
row = subRange.end.row;
|
||||
} else if (startIndent == indent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
endRow = row;
|
||||
}
|
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||
};
|
||||
this.getCommentRegionBlock = function(session, line, row) {
|
||||
var startColumn = line.search(/\s*$/);
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||
var depth = 1;
|
||||
while (++row < maxRow) {
|
||||
line = session.getLine(row);
|
||||
var m = re.exec(line);
|
||||
if (!m) continue;
|
||||
if (m[1]) depth--;
|
||||
else depth++;
|
||||
|
||||
if (!depth) break;
|
||||
}
|
||||
|
||||
var endRow = row;
|
||||
if (endRow > startRow) {
|
||||
return new Range(startRow, startColumn, endRow, line.length);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
||||
define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = JavaScriptHighlightRules;
|
||||
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
this.$quotes = {'"': '"', "'": "'", "`": "`"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
var endState = tokenizedLine.state;
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "start" || state == "no_regex") {
|
||||
var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
} else if (state == "doc-start") {
|
||||
if (endState == "start" || endState == "no_regex") {
|
||||
return "";
|
||||
}
|
||||
var match = line.match(/^\s*(\/?)\*/);
|
||||
if (match) {
|
||||
if (match[1]) {
|
||||
indent += " ";
|
||||
}
|
||||
indent += "* ";
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
worker.on("annotate", function(results) {
|
||||
session.setAnnotations(results.data);
|
||||
});
|
||||
|
||||
worker.on("terminate", function() {
|
||||
session.clearAnnotations();
|
||||
});
|
||||
|
||||
return worker;
|
||||
};
|
||||
|
||||
this.$id = "ace/mode/javascript";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
|
@ -1,112 +0,0 @@
|
|||
define("ace/theme/monokai",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
|
||||
|
||||
exports.isDark = true;
|
||||
exports.cssClass = "ace-monokai";
|
||||
exports.cssText = ".ace-monokai .ace_gutter {\
|
||||
background: #2F3129;\
|
||||
color: #8F908A\
|
||||
}\
|
||||
.ace-monokai .ace_print-margin {\
|
||||
width: 1px;\
|
||||
background: #555651\
|
||||
}\
|
||||
.ace-monokai {\
|
||||
background-color: #272822;\
|
||||
color: #F8F8F2\
|
||||
}\
|
||||
.ace-monokai .ace_cursor {\
|
||||
color: #F8F8F0\
|
||||
}\
|
||||
.ace-monokai .ace_marker-layer .ace_selection {\
|
||||
background: #49483E\
|
||||
}\
|
||||
.ace-monokai.ace_multiselect .ace_selection.ace_start {\
|
||||
box-shadow: 0 0 3px 0px #272822;\
|
||||
}\
|
||||
.ace-monokai .ace_marker-layer .ace_step {\
|
||||
background: rgb(102, 82, 0)\
|
||||
}\
|
||||
.ace-monokai .ace_marker-layer .ace_bracket {\
|
||||
margin: -1px 0 0 -1px;\
|
||||
border: 1px solid #49483E\
|
||||
}\
|
||||
.ace-monokai .ace_marker-layer .ace_active-line {\
|
||||
background: #202020\
|
||||
}\
|
||||
.ace-monokai .ace_gutter-active-line {\
|
||||
background-color: #272727\
|
||||
}\
|
||||
.ace-monokai .ace_marker-layer .ace_selected-word {\
|
||||
border: 1px solid #49483E\
|
||||
}\
|
||||
.ace-monokai .ace_invisible {\
|
||||
color: #52524d\
|
||||
}\
|
||||
.ace-monokai .ace_entity.ace_name.ace_tag,\
|
||||
.ace-monokai .ace_keyword,\
|
||||
.ace-monokai .ace_meta.ace_tag,\
|
||||
.ace-monokai .ace_storage {\
|
||||
color: #F92672\
|
||||
}\
|
||||
.ace-monokai .ace_punctuation,\
|
||||
.ace-monokai .ace_punctuation.ace_tag {\
|
||||
color: #fff\
|
||||
}\
|
||||
.ace-monokai .ace_constant.ace_character,\
|
||||
.ace-monokai .ace_constant.ace_language,\
|
||||
.ace-monokai .ace_constant.ace_numeric,\
|
||||
.ace-monokai .ace_constant.ace_other {\
|
||||
color: #AE81FF\
|
||||
}\
|
||||
.ace-monokai .ace_invalid {\
|
||||
color: #F8F8F0;\
|
||||
background-color: #F92672\
|
||||
}\
|
||||
.ace-monokai .ace_invalid.ace_deprecated {\
|
||||
color: #F8F8F0;\
|
||||
background-color: #AE81FF\
|
||||
}\
|
||||
.ace-monokai .ace_support.ace_constant,\
|
||||
.ace-monokai .ace_support.ace_function {\
|
||||
color: #66D9EF\
|
||||
}\
|
||||
.ace-monokai .ace_fold {\
|
||||
background-color: #A6E22E;\
|
||||
border-color: #F8F8F2\
|
||||
}\
|
||||
.ace-monokai .ace_storage.ace_type,\
|
||||
.ace-monokai .ace_support.ace_class,\
|
||||
.ace-monokai .ace_support.ace_type {\
|
||||
font-style: italic;\
|
||||
color: #66D9EF\
|
||||
}\
|
||||
.ace-monokai .ace_entity.ace_name.ace_function,\
|
||||
.ace-monokai .ace_entity.ace_other,\
|
||||
.ace-monokai .ace_entity.ace_other.ace_attribute-name,\
|
||||
.ace-monokai .ace_variable {\
|
||||
color: #A6E22E\
|
||||
}\
|
||||
.ace-monokai .ace_variable.ace_parameter {\
|
||||
font-style: italic;\
|
||||
color: #FD971F\
|
||||
}\
|
||||
.ace-monokai .ace_string {\
|
||||
color: #E6DB74\
|
||||
}\
|
||||
.ace-monokai .ace_comment {\
|
||||
color: #75715E\
|
||||
}\
|
||||
.ace-monokai .ace_indent-guide {\
|
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ0FD0ZXBzd/wPAAjVAoxeSgNeAAAAAElFTkSuQmCC) right repeat-y\
|
||||
}";
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
}); (function() {
|
||||
window.require(["ace/theme/monokai"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -191,7 +191,7 @@
|
|||
</menupopup>
|
||||
</toolbarbutton>
|
||||
</hbox>
|
||||
<iframe src="chrome://scaffold/content/ace/ace.html" id="editor-code" flex="1"/>
|
||||
<iframe src="chrome://zotero/content/ace.html" id="editor-code" flex="1"/>
|
||||
<hbox id="editor-external-box" align="center">
|
||||
<checkbox id="checkbox-editor-external"/>
|
||||
<label class="label-metadata" value="&scaffold.editor.external.label;" control="checkbox-editor-external"/>
|
||||
|
@ -199,10 +199,10 @@
|
|||
</vbox>
|
||||
</tabpanel>
|
||||
<tabpanel flex="1" id="tabpanel-import">
|
||||
<iframe src="chrome://scaffold/content/ace/ace.html" id="editor-import" flex="1"/>
|
||||
<iframe src="chrome://zotero/content/ace.html" id="editor-import" flex="1"/>
|
||||
</tabpanel>
|
||||
<tabpanel flex="1" id="tabpanel-tests">
|
||||
<iframe src="chrome://scaffold/content/ace/ace.html" id="editor-tests" flex="1"/>
|
||||
<iframe src="chrome://zotero/content/ace.html" id="editor-tests" flex="1"/>
|
||||
</tabpanel>
|
||||
<tabpanel flex="1" id="tabpanel-testing">
|
||||
<vbox flex="1"><hbox><description>&scaffold.testing.description;</description></hbox>
|
||||
|
|
10
chrome/content/zotero/ace/ace.html
Normal file
10
chrome/content/zotero/ace/ace.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script type="text/javascript" src="chrome://zotero/content/include.js"></script>
|
||||
<script type="text/javascript" src="resource://zotero/ace/ace.js"></script>
|
||||
<script type="text/javascript" src="resource://zotero/ace/mode-javascript.js"></script>
|
||||
<script type="text/javascript" src="aceWrapper.js"></script>
|
||||
</head>
|
||||
<body id="body"></body>
|
||||
</html>
|
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -773,6 +773,11 @@
|
|||
"through": ">=2.2.7 <3"
|
||||
}
|
||||
},
|
||||
"ace-builds": {
|
||||
"version": "1.4.12",
|
||||
"resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.4.12.tgz",
|
||||
"integrity": "sha512-G+chJctFPiiLGvs3+/Mly3apXTcfgE45dT5yp12BcWZ1kUs+gm0qd3/fv4gsz6fVag4mM0moHVpjHDIgph6Psg=="
|
||||
},
|
||||
"acorn": {
|
||||
"version": "7.4.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
},
|
||||
"license": "",
|
||||
"dependencies": {
|
||||
"ace-builds": "^1.4.12",
|
||||
"bluebird": "^3.5.1",
|
||||
"classnames": "^2.2.6",
|
||||
"prop-types": "^15.7.2",
|
||||
|
|
1
resource/ace
Symbolic link
1
resource/ace
Symbolic link
|
@ -0,0 +1 @@
|
|||
../node_modules/ace-builds/src/
|
|
@ -38,6 +38,15 @@ const symlinkFiles = [
|
|||
'resource/SingleFile/lib/**/*',
|
||||
'resource/SingleFile/extension/lib/single-file/fetch/content/content-fetch.js',
|
||||
'!resource/SingleFile/lib/single-file/single-file.js',
|
||||
// We only need a couple Ace Editor files
|
||||
'!resource/ace/**/*',
|
||||
'resource/ace/ace.js',
|
||||
'resource/ace/ext-searchbox.js',
|
||||
'resource/ace/keybinding-emacs.js',
|
||||
'resource/ace/keybinding-vim.js',
|
||||
'resource/ace/mode-javascript.js',
|
||||
'resource/ace/theme-monokai.js',
|
||||
'resource/ace/worker-javascript.js',
|
||||
'update.rdf'
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue