@openui5/sap.ui.codeeditor 1.101.0 → 1.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRDPARTY.txt +1 -1
- package/package.json +2 -2
- package/src/sap/ui/codeeditor/.library +1 -1
- package/src/sap/ui/codeeditor/CodeEditor.js +4 -6
- package/src/sap/ui/codeeditor/aceWorkerProxy.html +11 -0
- package/src/sap/ui/codeeditor/aceWorkerProxy.js +57 -0
- package/src/sap/ui/codeeditor/js/ace/ace.js +89 -6
- package/src/sap/ui/codeeditor/library.js +2 -2
package/THIRDPARTY.txt
CHANGED
|
@@ -450,7 +450,7 @@ License: Apache-2.0
|
|
|
450
450
|
License Text: https://github.com/SAP/openui5/blob/master/LICENSES/Apache-2.0.txt
|
|
451
451
|
Contained in: lib/jsdoc/ui5/plugin.js
|
|
452
452
|
|
|
453
|
-
Component: SAP Theming Base Content, version: 11.1.
|
|
453
|
+
Component: SAP Theming Base Content, version: 11.1.39
|
|
454
454
|
Copyright: SAP SE or an SAP affiliate company and Theming Base Content contributors
|
|
455
455
|
License: Apache-2.0
|
|
456
456
|
License Text: https://github.com/SAP/openui5/blob/master/LICENSES/Apache-2.0.txt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openui5/sap.ui.codeeditor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.102.0",
|
|
4
4
|
"description": "OpenUI5 UI Library sap.ui.codeeditor",
|
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
"url": "https://github.com/SAP/openui5.git"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@openui5/sap.ui.core": "1.
|
|
17
|
+
"@openui5/sap.ui.core": "1.102.0"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<copyright>OpenUI5
|
|
7
7
|
* (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
|
|
8
8
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.</copyright>
|
|
9
|
-
<version>1.
|
|
9
|
+
<version>1.102.0</version>
|
|
10
10
|
|
|
11
11
|
<documentation>UI5 library: sap.ui.codeeditor</documentation>
|
|
12
12
|
|
|
@@ -63,7 +63,7 @@ sap.ui.define([
|
|
|
63
63
|
* @extends sap.ui.core.Control
|
|
64
64
|
*
|
|
65
65
|
* @author SAP SE
|
|
66
|
-
* @version 1.
|
|
66
|
+
* @version 1.102.0
|
|
67
67
|
*
|
|
68
68
|
* @constructor
|
|
69
69
|
* @public
|
|
@@ -290,6 +290,7 @@ sap.ui.define([
|
|
|
290
290
|
CodeEditor.prototype.exit = function() {
|
|
291
291
|
this._deregisterResizeListener();
|
|
292
292
|
this._oEditor.destroy(); // clear ace intervals
|
|
293
|
+
this._oEditor.getSession().setUseWorker(false); // explicitly disable worker usage, in case the ace mode is still loading, to avoid worker initialization after destroy
|
|
293
294
|
jQuery(this._oEditorDomRef).remove(); // remove DOM node together with all event listeners
|
|
294
295
|
this._oEditorDomRef = null;
|
|
295
296
|
this._oEditor = null;
|
|
@@ -316,6 +317,8 @@ sap.ui.define([
|
|
|
316
317
|
sEditorTheme = "crimson_editor";
|
|
317
318
|
} else if (sUiTheme === "sap_fiori_3_dark") {
|
|
318
319
|
sEditorTheme = "clouds_midnight";
|
|
320
|
+
} else if (sUiTheme === "sap_horizon_dark") {
|
|
321
|
+
sEditorTheme = "nord_dark";
|
|
319
322
|
}
|
|
320
323
|
this.setColorTheme(sEditorTheme);
|
|
321
324
|
};
|
|
@@ -500,11 +503,6 @@ sap.ui.define([
|
|
|
500
503
|
ace.require("ace/ext/beautify").beautify(this._oEditor.session);
|
|
501
504
|
};
|
|
502
505
|
|
|
503
|
-
CodeEditor.prototype.destroy = function (bSuppressInvalidate) {
|
|
504
|
-
this._oEditor.destroy(bSuppressInvalidate);
|
|
505
|
-
Control.prototype.destroy.call(this, bSuppressInvalidate);
|
|
506
|
-
};
|
|
507
|
-
|
|
508
506
|
CodeEditor.prototype.onfocusout = function () {
|
|
509
507
|
this._oEditor.getSession().setUseWorker(false);
|
|
510
508
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Wrapper for Ace Worker</title>
|
|
7
|
+
<script src="aceWorkerProxy.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
</body>
|
|
11
|
+
</html>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* OpenUI5
|
|
3
|
+
* (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
window.addEventListener("load", function () {
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
var ACE_BASE_PATH = new URL("./js/ace/", document.baseURI).href;
|
|
11
|
+
var workers = new Map();
|
|
12
|
+
|
|
13
|
+
// listen for messages from ace
|
|
14
|
+
window.addEventListener("message", function (event) {
|
|
15
|
+
var message = event.data.message;
|
|
16
|
+
var workerId = event.data.workerId;
|
|
17
|
+
var senderOrigin = event.origin;
|
|
18
|
+
|
|
19
|
+
if (message.createWorker) {
|
|
20
|
+
var workerEntry = createWorkerEntry(message.workerUrl, senderOrigin, workerId);
|
|
21
|
+
|
|
22
|
+
if (workerEntry) {
|
|
23
|
+
workers.set(workerId, workerEntry);
|
|
24
|
+
}
|
|
25
|
+
} else if (message.terminateWorker) {
|
|
26
|
+
workers.get(workerId).worker.terminate();
|
|
27
|
+
workers.delete(workerId);
|
|
28
|
+
} else if (senderOrigin === workers.get(workerId).creatorOrigin) { // send message to the worker only from the origin that created it
|
|
29
|
+
workers.get(workerId).worker.postMessage(message);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function createWorkerEntry(url, origin, workerId) {
|
|
34
|
+
if (!url || typeof url !== "string") {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var absoluteWorkerUrl = new URL(url, document.baseURI).href;
|
|
39
|
+
|
|
40
|
+
// create worker only if it's located on the same origin and is in the "./js/ace/" folder
|
|
41
|
+
if (!absoluteWorkerUrl.startsWith(ACE_BASE_PATH)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var worker = new Worker(absoluteWorkerUrl);
|
|
46
|
+
// forward messages from worker to ace
|
|
47
|
+
worker.addEventListener("message", function(event) {
|
|
48
|
+
event.data.workerId = workerId;
|
|
49
|
+
window.parent.postMessage(event.data, origin);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
creatorOrigin: origin,
|
|
54
|
+
worker: worker
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
@@ -12518,6 +12518,9 @@ var TokenIterator = require("./token_iterator").TokenIterator;
|
|
|
12518
12518
|
|
|
12519
12519
|
var clipboard = require("./clipboard");
|
|
12520
12520
|
var Editor = function(renderer, session, options) {
|
|
12521
|
+
// #### BEGIN MODIFIED BY SAP
|
|
12522
|
+
Editor._instancesCnt ++;
|
|
12523
|
+
// #### END MODIFIED BY SAP
|
|
12521
12524
|
this.$toDestroy = [];
|
|
12522
12525
|
var container = renderer.getContainerElement();
|
|
12523
12526
|
this.container = container;
|
|
@@ -12559,6 +12562,9 @@ var Editor = function(renderer, session, options) {
|
|
|
12559
12562
|
this.setOptions(options);
|
|
12560
12563
|
config._signal("editor", this);
|
|
12561
12564
|
};
|
|
12565
|
+
// ##### BEGIN MODIFIED BY SAP
|
|
12566
|
+
Editor._instancesCnt = 0;
|
|
12567
|
+
// ##### END MODIFIED BY SAP
|
|
12562
12568
|
|
|
12563
12569
|
Editor.$uid = 0;
|
|
12564
12570
|
|
|
@@ -14419,6 +14425,14 @@ Editor.$uid = 0;
|
|
|
14419
14425
|
if (this._$emitInputEvent)
|
|
14420
14426
|
this._$emitInputEvent.cancel();
|
|
14421
14427
|
this.removeAllListeners();
|
|
14428
|
+
|
|
14429
|
+
// ##### BEGIN MODIFIED BY SAP
|
|
14430
|
+
Editor._instancesCnt--;
|
|
14431
|
+
var iframe = document.getElementById("sap-ui-codeeditor-ace-worker-proxy");
|
|
14432
|
+
if (Editor._instancesCnt === 0 && iframe) {
|
|
14433
|
+
iframe.remove();
|
|
14434
|
+
}
|
|
14435
|
+
// ##### END MODIFIED BY SAP
|
|
14422
14436
|
};
|
|
14423
14437
|
this.setAutoScrollEditorIntoView = function(enable) {
|
|
14424
14438
|
if (!enable)
|
|
@@ -19090,16 +19104,85 @@ function $workerBlob(workerUrl) {
|
|
|
19090
19104
|
}
|
|
19091
19105
|
}
|
|
19092
19106
|
|
|
19107
|
+
// ##### BEGIN MODIFIED BY SAP
|
|
19108
|
+
var workersCnt = 0;
|
|
19109
|
+
|
|
19093
19110
|
function createWorker(workerUrl) {
|
|
19094
19111
|
if (typeof Worker == "undefined")
|
|
19095
19112
|
return { postMessage: function() {}, terminate: function() {} };
|
|
19096
|
-
|
|
19097
|
-
|
|
19098
|
-
|
|
19099
|
-
|
|
19100
|
-
|
|
19113
|
+
|
|
19114
|
+
var iframe = document.getElementById("sap-ui-codeeditor-ace-worker-proxy");
|
|
19115
|
+
var iframeLoaded = true;
|
|
19116
|
+
if (!iframe) {
|
|
19117
|
+
iframeLoaded = false;
|
|
19118
|
+
iframe = document.createElement("iframe");
|
|
19119
|
+
iframe.id = "sap-ui-codeeditor-ace-worker-proxy";
|
|
19120
|
+
iframe.src = sap.ui.require.toUrl("sap/ui/codeeditor/aceWorkerProxy.html");
|
|
19121
|
+
iframe.hidden = true;
|
|
19122
|
+
iframe.sandbox = "allow-scripts allow-same-origin";
|
|
19123
|
+
document.body.appendChild(iframe);
|
|
19124
|
+
|
|
19125
|
+
// await for the iframe to load and then send to it the pending messages
|
|
19126
|
+
iframe.onload = function () {
|
|
19127
|
+
iframeLoaded = true;
|
|
19128
|
+
messageQueue.forEach(function (entry) {
|
|
19129
|
+
entry.workerProxy.postMessage(entry.message)
|
|
19130
|
+
});
|
|
19131
|
+
}
|
|
19132
|
+
}
|
|
19133
|
+
|
|
19134
|
+
var iframeOrigin = new URL(iframe.src).origin;
|
|
19135
|
+
var messageQueue = [];
|
|
19136
|
+
var workerProxy = {
|
|
19137
|
+
postMessage: function (message) {
|
|
19138
|
+
if (!iframeLoaded) {
|
|
19139
|
+
// enqueue the messages until the iframe is loaded
|
|
19140
|
+
messageQueue.push({
|
|
19141
|
+
workerProxy: this,
|
|
19142
|
+
message: message
|
|
19143
|
+
});
|
|
19144
|
+
return;
|
|
19145
|
+
}
|
|
19146
|
+
|
|
19147
|
+
var wrappedMessage = {
|
|
19148
|
+
workerId: this._id,
|
|
19149
|
+
message: message
|
|
19150
|
+
}
|
|
19151
|
+
// send message to worker
|
|
19152
|
+
iframe.contentWindow.postMessage.call(iframe.contentWindow, wrappedMessage, iframeOrigin);
|
|
19153
|
+
},
|
|
19154
|
+
terminate: function () {
|
|
19155
|
+
this.postMessage({
|
|
19156
|
+
terminateWorker: true
|
|
19157
|
+
});
|
|
19158
|
+
|
|
19159
|
+
window.removeEventListener("message", this._messageFromFrameListener);
|
|
19160
|
+
},
|
|
19161
|
+
set onmessage(cb) {
|
|
19162
|
+
this._messageCb = cb;
|
|
19163
|
+
},
|
|
19164
|
+
_id: workersCnt++,
|
|
19165
|
+
_listenForMessageFromFrame: function () {
|
|
19166
|
+
this._messageFromFrameListener = function (event) {
|
|
19167
|
+
if (!iframe || event.origin !== iframeOrigin || event.source !== iframe.contentWindow || event.data.workerId !== this._id) {
|
|
19168
|
+
return;
|
|
19169
|
+
}
|
|
19170
|
+
|
|
19171
|
+
this._messageCb.call(this._messageCb, event);
|
|
19172
|
+
}.bind(this)
|
|
19173
|
+
window.addEventListener("message", this._messageFromFrameListener);
|
|
19174
|
+
}
|
|
19101
19175
|
}
|
|
19102
|
-
|
|
19176
|
+
|
|
19177
|
+
workerProxy.postMessage({
|
|
19178
|
+
createWorker: true,
|
|
19179
|
+
workerUrl: workerUrl
|
|
19180
|
+
});
|
|
19181
|
+
|
|
19182
|
+
workerProxy._listenForMessageFromFrame();
|
|
19183
|
+
|
|
19184
|
+
return workerProxy;
|
|
19185
|
+
// ##### END MODIFIED BY SAP
|
|
19103
19186
|
}
|
|
19104
19187
|
|
|
19105
19188
|
var WorkerClient = function(worker) {
|
|
@@ -19,7 +19,7 @@ sap.ui.define([
|
|
|
19
19
|
* @namespace
|
|
20
20
|
* @alias sap.ui.codeeditor
|
|
21
21
|
* @author SAP SE
|
|
22
|
-
* @version 1.
|
|
22
|
+
* @version 1.102.0
|
|
23
23
|
* @since 1.48
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
@@ -33,7 +33,7 @@ sap.ui.define([
|
|
|
33
33
|
],
|
|
34
34
|
elements: [],
|
|
35
35
|
noLibraryCSS: false,
|
|
36
|
-
version: "1.
|
|
36
|
+
version: "1.102.0"
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
return thisLib;
|