@progress/kendo-pdfviewer-common 0.5.0-develop.6 → 0.5.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/dist/es/search.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { toArray } from "./common/core";
1
2
  const unwrapElement = (element) => {
2
3
  const parentElement = element.parentElement;
3
4
  if (!element || !parentElement) {
@@ -106,7 +107,12 @@ export class SearchService {
106
107
  this.forEachTextContainer((textContainer) => {
107
108
  const nodes = Array.from(textContainer.querySelectorAll('span:not(.' + this.options.charClass + ')'));
108
109
  nodes.forEach((node) => {
109
- node.innerHTML = node.textContent;
110
+ const nodeTextContent = node.textContent;
111
+ toArray(node.childNodes).forEach((childNode) => {
112
+ node.removeChild(childNode);
113
+ });
114
+ const textNode = node.ownerDocument.createTextNode(nodeTextContent);
115
+ node.appendChild(textNode);
110
116
  });
111
117
  });
112
118
  }
@@ -145,17 +151,24 @@ export class SearchService {
145
151
  this.state.text = this.state.text + text;
146
152
  const span = document.createElement('span');
147
153
  wrapElement(node, span);
148
- const splittedHtml = this.splitTextByChars(text);
149
- span.innerHTML = splittedHtml;
154
+ node.textContent = "";
155
+ const textElements = this.splitTextByChars(text);
156
+ textElements.forEach((textElement) => {
157
+ span.appendChild(textElement);
158
+ });
150
159
  unwrapElement(span.childNodes[0]);
151
160
  }
152
161
  splitTextByChars(text) {
153
- let splittedTextHtml = '';
162
+ const splittedTextElements = [];
154
163
  for (let i = 0; i < text.length; i++) {
155
- splittedTextHtml += `<span class='${this.options.charClass}' ${CHAR_INDEX_DATA_ATTR}=${this.state.charIndex}>${text[i]}</span>`;
164
+ const textElement = document.createElement('span');
165
+ addClass(this.options.charClass, textElement);
166
+ textElement.setAttribute(`${CHAR_INDEX_DATA_ATTR}`, `${this.state.charIndex}`);
167
+ textElement.textContent = text[i];
168
+ splittedTextElements.push(textElement);
156
169
  this.state.charIndex++;
157
170
  }
158
- return splittedTextHtml;
171
+ return splittedTextElements;
159
172
  }
160
173
  forEachTextContainer(callback) {
161
174
  for (let i = 0; i < this.options.textContainers.length; i++) {
@@ -1,3 +1,4 @@
1
+ import { toArray } from "./common/core";
1
2
  const unwrapElement = (element) => {
2
3
  const parentElement = element.parentElement;
3
4
  if (!element || !parentElement) {
@@ -106,7 +107,12 @@ export class SearchService {
106
107
  this.forEachTextContainer((textContainer) => {
107
108
  const nodes = Array.from(textContainer.querySelectorAll('span:not(.' + this.options.charClass + ')'));
108
109
  nodes.forEach((node) => {
109
- node.innerHTML = node.textContent;
110
+ const nodeTextContent = node.textContent;
111
+ toArray(node.childNodes).forEach((childNode) => {
112
+ node.removeChild(childNode);
113
+ });
114
+ const textNode = node.ownerDocument.createTextNode(nodeTextContent);
115
+ node.appendChild(textNode);
110
116
  });
111
117
  });
112
118
  }
@@ -145,17 +151,24 @@ export class SearchService {
145
151
  this.state.text = this.state.text + text;
146
152
  const span = document.createElement('span');
147
153
  wrapElement(node, span);
148
- const splittedHtml = this.splitTextByChars(text);
149
- span.innerHTML = splittedHtml;
154
+ node.textContent = "";
155
+ const textElements = this.splitTextByChars(text);
156
+ textElements.forEach((textElement) => {
157
+ span.appendChild(textElement);
158
+ });
150
159
  unwrapElement(span.childNodes[0]);
151
160
  }
152
161
  splitTextByChars(text) {
153
- let splittedTextHtml = '';
162
+ const splittedTextElements = [];
154
163
  for (let i = 0; i < text.length; i++) {
155
- splittedTextHtml += `<span class='${this.options.charClass}' ${CHAR_INDEX_DATA_ATTR}=${this.state.charIndex}>${text[i]}</span>`;
164
+ const textElement = document.createElement('span');
165
+ addClass(this.options.charClass, textElement);
166
+ textElement.setAttribute(`${CHAR_INDEX_DATA_ATTR}`, `${this.state.charIndex}`);
167
+ textElement.textContent = text[i];
168
+ splittedTextElements.push(textElement);
156
169
  this.state.charIndex++;
157
170
  }
158
- return splittedTextHtml;
171
+ return splittedTextElements;
159
172
  }
160
173
  forEachTextContainer(callback) {
161
174
  for (let i = 0; i < this.options.textContainers.length; i++) {
@@ -21,7 +21,7 @@ export declare class SearchService {
21
21
  extractTextNodes(node: any): void;
22
22
  transformTextNodesForSearch(textNodes: any): void;
23
23
  transformTextNodeForSearch(node: any): void;
24
- splitTextByChars(text: any): string;
24
+ splitTextByChars(text: any): Array<HTMLElement>;
25
25
  forEachTextContainer(callback: any): void;
26
26
  highlightAllMatches(): void;
27
27
  addMatchHighlight(matchStartOffset: number, matchEndOffset: number, matchIndex: number): void;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SearchService = void 0;
4
+ const core_1 = require("./common/core");
4
5
  const unwrapElement = (element) => {
5
6
  const parentElement = element.parentElement;
6
7
  if (!element || !parentElement) {
@@ -109,7 +110,12 @@ class SearchService {
109
110
  this.forEachTextContainer((textContainer) => {
110
111
  const nodes = Array.from(textContainer.querySelectorAll('span:not(.' + this.options.charClass + ')'));
111
112
  nodes.forEach((node) => {
112
- node.innerHTML = node.textContent;
113
+ const nodeTextContent = node.textContent;
114
+ (0, core_1.toArray)(node.childNodes).forEach((childNode) => {
115
+ node.removeChild(childNode);
116
+ });
117
+ const textNode = node.ownerDocument.createTextNode(nodeTextContent);
118
+ node.appendChild(textNode);
113
119
  });
114
120
  });
115
121
  }
@@ -148,17 +154,24 @@ class SearchService {
148
154
  this.state.text = this.state.text + text;
149
155
  const span = document.createElement('span');
150
156
  wrapElement(node, span);
151
- const splittedHtml = this.splitTextByChars(text);
152
- span.innerHTML = splittedHtml;
157
+ node.textContent = "";
158
+ const textElements = this.splitTextByChars(text);
159
+ textElements.forEach((textElement) => {
160
+ span.appendChild(textElement);
161
+ });
153
162
  unwrapElement(span.childNodes[0]);
154
163
  }
155
164
  splitTextByChars(text) {
156
- let splittedTextHtml = '';
165
+ const splittedTextElements = [];
157
166
  for (let i = 0; i < text.length; i++) {
158
- splittedTextHtml += `<span class='${this.options.charClass}' ${CHAR_INDEX_DATA_ATTR}=${this.state.charIndex}>${text[i]}</span>`;
167
+ const textElement = document.createElement('span');
168
+ addClass(this.options.charClass, textElement);
169
+ textElement.setAttribute(`${CHAR_INDEX_DATA_ATTR}`, `${this.state.charIndex}`);
170
+ textElement.textContent = text[i];
171
+ splittedTextElements.push(textElement);
159
172
  this.state.charIndex++;
160
173
  }
161
- return splittedTextHtml;
174
+ return splittedTextElements;
162
175
  }
163
176
  forEachTextContainer(callback) {
164
177
  for (let i = 0; i < this.options.textContainers.length; i++) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-pdfviewer-common",
3
3
  "description": "Kendo UI TypeScript package exporting functions for PDFViewer component",
4
- "version": "0.5.0-develop.6",
4
+ "version": "0.5.0",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],