Skip to content

Commit 6e9b698

Browse files
committed
upgrading ACE editor to latest release
1 parent 8366a1d commit 6e9b698

File tree

427 files changed

+331223
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

427 files changed

+331223
-291
lines changed

THIRD_PARTY_LICENSES.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3444,4 +3444,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34443444

34453445
--------------------------------------------------------------------------------
34463446

3447+
Ace (Ajax.org Cloud9 Editor) 1.4.13
34473448

3449+
Copyright (c) 2010, Ajax.org B.V.
3450+
All rights reserved.
3451+
3452+
Redistribution and use in source and binary forms, with or without
3453+
modification, are permitted provided that the following conditions are met:
3454+
* Redistributions of source code must retain the above copyright
3455+
notice, this list of conditions and the following disclaimer.
3456+
* Redistributions in binary form must reproduce the above copyright
3457+
notice, this list of conditions and the following disclaimer in the
3458+
documentation and/or other materials provided with the distribution.
3459+
* Neither the name of Ajax.org B.V. nor the
3460+
names of its contributors may be used to endorse or promote products
3461+
derived from this software without specific prior written permission.
3462+
3463+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3464+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
3465+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3466+
DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
3467+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3468+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3469+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3470+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3471+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3472+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

webui/src/js/libs/ace/ace.js

Lines changed: 21386 additions & 1 deletion
Large diffs are not rendered by default.

webui/src/js/libs/ace/ext-beautify.js

Lines changed: 324 additions & 1 deletion
Large diffs are not rendered by default.

webui/src/js/libs/ace/ext-code_lens.js

Lines changed: 231 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,234 @@
1-
ace.define("ace/ext/code_lens",["require","exports","module","ace/line_widgets","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/editor","ace/config"],function(e,t,n){"use strict";function u(e){var t=e.$textLayer,n=t.$lenses;n&&n.forEach(function(e){e.remove()}),t.$lenses=null}function a(e,t){var n=e&t.CHANGE_LINES||e&t.CHANGE_FULL||e&t.CHANGE_SCROLL||e&t.CHANGE_TEXT;if(!n)return;var r=t.session,i=t.session.lineWidgets,s=t.$textLayer,a=s.$lenses;if(!i){a&&u(t);return}var f=t.$textLayer.$lines.cells,l=t.layerConfig,c=t.$padding;a||(a=s.$lenses=[]);var h=0;for(var p=0;p<f.length;p++){var d=f[p].row,v=i[d],m=v&&v.lenses;if(!m||!m.length)continue;var g=a[h];g||(g=a[h]=o.buildDom(["div",{"class":"ace_codeLens"}],t.container)),g.style.height=l.lineHeight+"px",h++;for(var y=0;y<m.length;y++){var b=g.childNodes[2*y];b||(y!=0&&g.appendChild(o.createTextNode("\u00a0|\u00a0")),b=o.buildDom(["a"],g)),b.textContent=m[y].title,b.lensCommand=m[y]}while(g.childNodes.length>2*y-1)g.lastChild.remove();var w=t.$cursorLayer.getPixelPosition({row:d,column:0},!0).top-l.lineHeight*v.rowsAbove-l.offset;g.style.top=w+"px";var E=t.gutterWidth,S=r.getLine(d).search(/\S|$/);S==-1&&(S=0),E+=S*l.characterWidth,E-=t.scrollLeft,g.style.paddingLeft=c+E+"px"}while(h<a.length)a.pop().remove()}function f(e){if(!e.lineWidgets)return;var t=e.widgetManager;e.lineWidgets.forEach(function(e){e&&e.lenses&&t.removeLineWidget(e)})}function l(e){e.codeLensProviders=[],e.renderer.on("afterRender",a),e.$codeLensClickHandler||(e.$codeLensClickHandler=function(t){var n=t.target.lensCommand;n&&e.execCommand(n.id,n.arguments)},i.addListener(e.container,"click",e.$codeLensClickHandler,e)),e.$updateLenses=function(){function o(){var r=n.selection.cursor,i=n.documentToScreenRow(r);t.setLenses(n,s);var o=n.$undoManager&&n.$undoManager.$lastDelta;if(o&&o.action=="remove"&&o.lines.length>1)return;var u=n.documentToScreenRow(r),a=e.renderer.layerConfig.lineHeight,f=n.getScrollTop()+(u-i)*a;n.setScrollTop(f)}var n=e.session;if(!n)return;n.widgetManager||(n.widgetManager=new r(n),n.widgetManager.attach(e));var i=e.codeLensProviders.length,s=[];e.codeLensProviders.forEach(function(e){e.provideCodeLenses(n,function(e,t){if(e)return;t.forEach(function(e){s.push(e)}),i--,i==0&&o()})})};var n=s.delayedCall(e.$updateLenses);e.$updateLensesOnInput=function(){n.delay(250)},e.on("input",e.$updateLensesOnInput)}function c(e){e.off("input",e.$updateLensesOnInput),e.renderer.off("afterRender",a),e.$codeLensClickHandler&&e.container.removeEventListener("click",e.$codeLensClickHandler)}var r=e("../line_widgets").LineWidgets,i=e("../lib/event"),s=e("../lib/lang"),o=e("../lib/dom");t.setLenses=function(e,t){var n=Number.MAX_VALUE;f(e),t&&t.forEach(function(t){var r=t.start.row,i=t.start.column,s=e.lineWidgets&&e.lineWidgets[r];if(!s||!s.lenses)s=e.widgetManager.$registerLineWidget({rowCount:1,rowsAbove:1,row:r,column:i,lenses:[]});s.lenses.push(t.command),r<n&&(n=r)}),e._emit("changeFold",{data:{start:{row:n}}})},t.registerCodeLensProvider=function(e,t){e.setOption("enableCodeLens",!0),e.codeLensProviders.push(t),e.$updateLensesOnInput()},t.clear=function(e){t.setLenses(e,null)};var h=e("../editor").Editor;e("../config").defineOptions(h.prototype,"editor",{enableCodeLens:{set:function(e){e?l(this):c(this)}}}),o.importCssString(".ace_codeLens { position: absolute; color: #aaa; font-size: 88%; background: inherit; width: 100%; display: flex; align-items: flex-end; pointer-events: none;}.ace_codeLens > a { cursor: pointer; pointer-events: auto;}.ace_codeLens > a:hover { color: #0000ff; text-decoration: underline;}.ace_dark > .ace_codeLens > a:hover { color: #4e94ce;}","")}); (function() {
1+
ace.define("ace/ext/code_lens",["require","exports","module","ace/line_widgets","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/editor","ace/config"], function(require, exports, module) {
2+
"use strict";
3+
var LineWidgets = require("../line_widgets").LineWidgets;
4+
var event = require("../lib/event");
5+
var lang = require("../lib/lang");
6+
var dom = require("../lib/dom");
7+
8+
function clearLensElements(renderer) {
9+
var textLayer = renderer.$textLayer;
10+
var lensElements = textLayer.$lenses;
11+
if (lensElements)
12+
lensElements.forEach(function(el) {el.remove(); });
13+
textLayer.$lenses = null;
14+
}
15+
16+
function renderWidgets(changes, renderer) {
17+
var changed = changes & renderer.CHANGE_LINES
18+
|| changes & renderer.CHANGE_FULL
19+
|| changes & renderer.CHANGE_SCROLL
20+
|| changes & renderer.CHANGE_TEXT;
21+
if (!changed)
22+
return;
23+
24+
var session = renderer.session;
25+
var lineWidgets = renderer.session.lineWidgets;
26+
var textLayer = renderer.$textLayer;
27+
var lensElements = textLayer.$lenses;
28+
if (!lineWidgets) {
29+
if (lensElements)
30+
clearLensElements(renderer);
31+
return;
32+
}
33+
34+
var textCells = renderer.$textLayer.$lines.cells;
35+
var config = renderer.layerConfig;
36+
var padding = renderer.$padding;
37+
38+
if (!lensElements)
39+
lensElements = textLayer.$lenses = [];
40+
41+
42+
var index = 0;
43+
for (var i = 0; i < textCells.length; i++) {
44+
var row = textCells[i].row;
45+
var widget = lineWidgets[row];
46+
var lenses = widget && widget.lenses;
47+
48+
if (!lenses || !lenses.length) continue;
49+
50+
var lensContainer = lensElements[index];
51+
if (!lensContainer) {
52+
lensContainer = lensElements[index]
53+
= dom.buildDom(["div", {class: "ace_codeLens"}], renderer.container);
54+
}
55+
lensContainer.style.height = config.lineHeight + "px";
56+
index++;
57+
58+
for (var j = 0; j < lenses.length; j++) {
59+
var el = lensContainer.childNodes[2 * j];
60+
if (!el) {
61+
if (j != 0) lensContainer.appendChild(dom.createTextNode("\xa0|\xa0"));
62+
el = dom.buildDom(["a"], lensContainer);
63+
}
64+
el.textContent = lenses[j].title;
65+
el.lensCommand = lenses[j];
66+
}
67+
while (lensContainer.childNodes.length > 2 * j - 1)
68+
lensContainer.lastChild.remove();
69+
70+
var top = renderer.$cursorLayer.getPixelPosition({
71+
row: row,
72+
column: 0
73+
}, true).top - config.lineHeight * widget.rowsAbove - config.offset;
74+
lensContainer.style.top = top + "px";
75+
76+
var left = renderer.gutterWidth;
77+
var indent = session.getLine(row).search(/\S|$/);
78+
if (indent == -1)
79+
indent = 0;
80+
left += indent * config.characterWidth;
81+
left -= renderer.scrollLeft;
82+
lensContainer.style.paddingLeft = padding + left + "px";
83+
}
84+
while (index < lensElements.length)
85+
lensElements.pop().remove();
86+
}
87+
88+
function clearCodeLensWidgets(session) {
89+
if (!session.lineWidgets) return;
90+
var widgetManager = session.widgetManager;
91+
session.lineWidgets.forEach(function(widget) {
92+
if (widget && widget.lenses)
93+
widgetManager.removeLineWidget(widget);
94+
});
95+
}
96+
97+
exports.setLenses = function(session, lenses) {
98+
var firstRow = Number.MAX_VALUE;
99+
100+
clearCodeLensWidgets(session);
101+
lenses && lenses.forEach(function(lens) {
102+
var row = lens.start.row;
103+
var column = lens.start.column;
104+
var widget = session.lineWidgets && session.lineWidgets[row];
105+
if (!widget || !widget.lenses) {
106+
widget = session.widgetManager.$registerLineWidget({
107+
rowCount: 1,
108+
rowsAbove: 1,
109+
row: row,
110+
column: column,
111+
lenses: []
112+
});
113+
}
114+
widget.lenses.push(lens.command);
115+
if (row < firstRow)
116+
firstRow = row;
117+
});
118+
session._emit("changeFold", {data: {start: {row: firstRow}}});
119+
};
120+
121+
function attachToEditor(editor) {
122+
editor.codeLensProviders = [];
123+
editor.renderer.on("afterRender", renderWidgets);
124+
if (!editor.$codeLensClickHandler) {
125+
editor.$codeLensClickHandler = function(e) {
126+
var command = e.target.lensCommand;
127+
if (command)
128+
editor.execCommand(command.id, command.arguments);
129+
};
130+
event.addListener(editor.container, "click", editor.$codeLensClickHandler, editor);
131+
}
132+
editor.$updateLenses = function() {
133+
var session = editor.session;
134+
if (!session) return;
135+
136+
if (!session.widgetManager) {
137+
session.widgetManager = new LineWidgets(session);
138+
session.widgetManager.attach(editor);
139+
}
140+
141+
var providersToWaitNum = editor.codeLensProviders.length;
142+
var lenses = [];
143+
editor.codeLensProviders.forEach(function(provider) {
144+
provider.provideCodeLenses(session, function(err, payload) {
145+
if (err) return;
146+
payload.forEach(function(lens) {
147+
lenses.push(lens);
148+
});
149+
providersToWaitNum--;
150+
if (providersToWaitNum == 0) {
151+
applyLenses();
152+
}
153+
});
154+
});
155+
156+
function applyLenses() {
157+
var cursor = session.selection.cursor;
158+
var oldRow = session.documentToScreenRow(cursor);
159+
exports.setLenses(session, lenses);
160+
161+
var lastDelta = session.$undoManager && session.$undoManager.$lastDelta;
162+
if (lastDelta && lastDelta.action == "remove" && lastDelta.lines.length > 1)
163+
return;
164+
var row = session.documentToScreenRow(cursor);
165+
var lineHeight = editor.renderer.layerConfig.lineHeight;
166+
var top = session.getScrollTop() + (row - oldRow) * lineHeight;
167+
session.setScrollTop(top);
168+
}
169+
};
170+
var updateLenses = lang.delayedCall(editor.$updateLenses);
171+
editor.$updateLensesOnInput = function() {
172+
updateLenses.delay(250);
173+
};
174+
editor.on("input", editor.$updateLensesOnInput);
175+
}
176+
177+
function detachFromEditor(editor) {
178+
editor.off("input", editor.$updateLensesOnInput);
179+
editor.renderer.off("afterRender", renderWidgets);
180+
if (editor.$codeLensClickHandler)
181+
editor.container.removeEventListener("click", editor.$codeLensClickHandler);
182+
}
183+
184+
exports.registerCodeLensProvider = function(editor, codeLensProvider) {
185+
editor.setOption("enableCodeLens", true);
186+
editor.codeLensProviders.push(codeLensProvider);
187+
editor.$updateLensesOnInput();
188+
};
189+
190+
exports.clear = function(session) {
191+
exports.setLenses(session, null);
192+
};
193+
194+
var Editor = require("../editor").Editor;
195+
require("../config").defineOptions(Editor.prototype, "editor", {
196+
enableCodeLens: {
197+
set: function(val) {
198+
if (val) {
199+
attachToEditor(this);
200+
} else {
201+
detachFromEditor(this);
202+
}
203+
}
204+
}
205+
});
206+
207+
dom.importCssString("\
208+
.ace_codeLens {\
209+
position: absolute;\
210+
color: #aaa;\
211+
font-size: 88%;\
212+
background: inherit;\
213+
width: 100%;\
214+
display: flex;\
215+
align-items: flex-end;\
216+
pointer-events: none;\
217+
}\
218+
.ace_codeLens > a {\
219+
cursor: pointer;\
220+
pointer-events: auto;\
221+
}\
222+
.ace_codeLens > a:hover {\
223+
color: #0000ff;\
224+
text-decoration: underline;\
225+
}\
226+
.ace_dark > .ace_codeLens > a:hover {\
227+
color: #4e94ce;\
228+
}\
229+
", "codelense.css", false);
230+
231+
}); (function() {
2232
ace.require(["ace/ext/code_lens"], function(m) {
3233
if (typeof module == "object" && typeof exports == "object" && module) {
4234
module.exports = m;

0 commit comments

Comments
 (0)