@openui5/sap.ui.documentation 1.84.28 → 1.84.30-SNAPSHOT

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openui5/sap.ui.documentation",
3
- "version": "1.84.28",
3
+ "version": "1.84.30-SNAPSHOT",
4
4
  "description": "OpenUI5 UI Library sap.ui.documentation",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -14,10 +14,10 @@
14
14
  "url": "https://github.com/SAP/openui5.git"
15
15
  },
16
16
  "dependencies": {
17
- "@openui5/sap.m": "1.84.28",
18
- "@openui5/sap.ui.core": "1.84.28",
19
- "@openui5/sap.ui.layout": "1.84.28",
20
- "@openui5/themelib_sap_belize": "1.84.28",
21
- "@openui5/themelib_sap_fiori_3": "1.84.28"
17
+ "@openui5/sap.m": "1.84.30-SNAPSHOT",
18
+ "@openui5/sap.ui.core": "1.84.30-SNAPSHOT",
19
+ "@openui5/sap.ui.layout": "1.84.30-SNAPSHOT",
20
+ "@openui5/themelib_sap_belize": "1.84.30-SNAPSHOT",
21
+ "@openui5/themelib_sap_fiori_3": "1.84.30-SNAPSHOT"
22
22
  }
23
23
  }
@@ -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.84.28</version>
9
+ <version>1.84.30-SNAPSHOT</version>
10
10
 
11
11
  <documentation>SAPUI5 library for the Demokit 2.0.</documentation>
12
12
 
@@ -21,7 +21,7 @@ sap.ui.define([
21
21
  // delegate further initialization of this library to the Core
22
22
  sap.ui.getCore().initLibrary({
23
23
  name : 'sap.ui.documentation',
24
- version: '1.84.28',
24
+ version: '1.84.30-SNAPSHOT',
25
25
  dependencies : ['sap.ui.core','sap.m'],
26
26
  types: [],
27
27
  interfaces: [],
@@ -47,7 +47,7 @@ sap.ui.define([
47
47
  * @namespace
48
48
  * @name sap.ui.documentation
49
49
  * @author SAP SE
50
- * @version 1.84.28
50
+ * @version 1.84.30-SNAPSHOT
51
51
  * @public
52
52
  */
53
53
  var thisLibrary = sap.ui.documentation;
@@ -131,7 +131,8 @@ function() {
131
131
 
132
132
  Highlighter.prototype._processNode = function (oNode) {
133
133
  var sText, oRegEx, i, j, oMatches, sCurrentMatch,
134
- oCurrentMatch, aBlockedIndices, iCurrMatchIndex;
134
+ oCurrentMatch, aBlockedIndices, iCurrMatchIndex,
135
+ oHighligtedNode;
135
136
 
136
137
  if (oNode.nodeName === "IFRAME") {
137
138
  this._highlightSubTree(oNode.contentDocument.body);
@@ -168,8 +169,8 @@ function() {
168
169
  }
169
170
 
170
171
  if (Object.keys(oMatches).length !== 0) {
171
- sText = this._highlightTerms(oMatches, sText);
172
- this._replaceNode(oNode, sText);
172
+ oHighligtedNode = this._createHighlightedNode(oMatches, sText);
173
+ this._replaceNode(oNode, oHighligtedNode);
173
174
  }
174
175
  }
175
176
  };
@@ -195,17 +196,13 @@ function() {
195
196
  });
196
197
  };
197
198
 
198
- Highlighter.prototype._replaceNode = function (oNode, sHtml) {
199
- var oWrapper;
199
+ Highlighter.prototype._replaceNode = function (oNode, oHighligtedNode) {
200
200
 
201
201
  if (oNode.parentNode) {
202
- oWrapper = document.createElement('span');
203
- oWrapper.innerHTML = sHtml;
204
-
205
- oNode.parentNode.replaceChild(oWrapper, oNode);
202
+ oNode.parentNode.replaceChild(oHighligtedNode, oNode);
206
203
 
207
204
  // we cache which nodes are replaced with such as highlighted spans
208
- this._aPreviouslyHighlightedNodes.push(oWrapper); // Highlighted Node with span
205
+ this._aPreviouslyHighlightedNodes.push(oHighligtedNode); // Highlighted Node with span
209
206
  this._aPreviouslyOriginalNodes.push(oNode); // Original Node
210
207
  }
211
208
  };
@@ -230,27 +227,50 @@ function() {
230
227
  this._toggleMutationObserver(true);
231
228
  };
232
229
 
233
- Highlighter.prototype._highlightTerms = function (oMatches, sText) {
234
- var sOpeningTag = this._bUseExternalStyles ? '<span class="highlightedText">'
235
- : '<span class="defaultHighlightedText">',
236
- sClosingTag = '</span>',
237
- sCurrMatch,
238
- iUpdatedIndex,
239
- iCounter = 0,
240
- iIndex;
230
+ Highlighter.prototype._createHighlightedNode = function (oTokensToHighlight, sText) {
231
+ var oRootNode = document.createElement("span"),
232
+ aAllTokens = [],
233
+ fnSort = function(a, b) {return a > b;},
234
+ aIndices = Object.keys(oTokensToHighlight).sort(fnSort),
235
+ iIndex,
236
+ iStartIndex = 0;
237
+
238
+ // split the <code>sText</code> into tokens,
239
+ // including both the tokens to highlight
240
+ // and the remaing parts of the <code>sText</code> string
241
+ for (var i = 0; i < aIndices.length; i++) {
242
+ var iTokenIndex = Number(aIndices[i]),
243
+ sToken = oTokensToHighlight[iTokenIndex],
244
+ iTokenLength = sToken.length,
245
+ sBeforeToken = sText.substring(iStartIndex, iTokenIndex);
246
+
247
+ if (sBeforeToken.length) {
248
+ aAllTokens.push(sBeforeToken);
249
+ }
250
+ aAllTokens.push(sToken);
251
+
252
+ // shift the <code>iStartIndex</code> to the
253
+ // remaining part of the <code>sText</code> string
254
+ iStartIndex = iTokenIndex + iTokenLength;
255
+ }
241
256
 
242
- for (iIndex in oMatches) {
243
- iUpdatedIndex = +iIndex + (iCounter * (sOpeningTag.length + sClosingTag.length));
257
+ if (iStartIndex < sText.length) {
258
+ aAllTokens.push(sText.substring(iStartIndex));
259
+ }
244
260
 
245
- sCurrMatch = oMatches[iIndex];
246
- sText = sText.substring(0, iUpdatedIndex)
247
- + sOpeningTag + sCurrMatch + sClosingTag
248
- + sText.substring(iUpdatedIndex + sCurrMatch.length);
261
+ // wrap each token in a span
262
+ // and append to the root span
263
+ for (iIndex in aAllTokens) {
264
+ var oNextNode = document.createElement("span");
265
+ oNextNode.innerText = aAllTokens[iIndex];
266
+ if (Object.values(oTokensToHighlight).indexOf(aAllTokens[iIndex]) > -1) {
267
+ oNextNode.classList.add("defaultHighlightedText");
268
+ }
249
269
 
250
- iCounter++;
270
+ oRootNode.appendChild(oNextNode);
251
271
  }
252
272
 
253
- return sText;
273
+ return oRootNode;
254
274
  };
255
275
 
256
276
  Highlighter.prototype._addMutationObserver = function () {