@progress/kendo-pdfviewer-common 0.3.1 → 0.3.2

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.
@@ -573,8 +573,8 @@ export class Page extends Component {
573
573
  yield __classPrivateFieldGet(this, _Page_instances, "m", _Page_finishRenderTask).call(this, renderTask);
574
574
  // todo: awaiting this breaks text nodes positioning after zoom
575
575
  // if "includeMarkedContent": true is set in TextLayerBuilder
576
- // await this.#renderTextLayer();
577
- __classPrivateFieldGet(this, _Page_instances, "m", _Page_renderTextLayer).call(this);
576
+ yield __classPrivateFieldGet(this, _Page_instances, "m", _Page_renderTextLayer).call(this);
577
+ // this.#renderTextLayer();
578
578
  if (this.annotationLayer) {
579
579
  yield __classPrivateFieldGet(this, _Page_instances, "m", _Page_renderAnnotationLayer).call(this);
580
580
  }
@@ -1147,18 +1147,25 @@ export class PdfViewer extends Component {
1147
1147
  searchText(options = { text: "", matchCase: false }) {
1148
1148
  var _a;
1149
1149
  this.initSearchService();
1150
- return (_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(options);
1150
+ const matches = (_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(options);
1151
+ return matches;
1151
1152
  }
1152
1153
  clearSearch() {
1153
1154
  this.destroySearchService();
1154
1155
  }
1155
1156
  initSearchService() {
1157
+ const textLayers = Array.from(this.wrapper.querySelectorAll(toClassSelector(this.options.elementSelectors.textLayerClass)) || []);
1156
1158
  if (this.searchService) {
1157
- return;
1159
+ // refresh text nodes as text layers have changed
1160
+ if (textLayers.every((x, i) => x === this.searchService.options.textContainers[i])) {
1161
+ return;
1162
+ }
1163
+ else {
1164
+ this.destroySearchService();
1165
+ }
1158
1166
  }
1159
- const pagesTextLayers = this.wrapper.querySelectorAll(toClassSelector(this.options.elementSelectors.textLayerClass));
1160
1167
  this.searchService = new SearchService({
1161
- textContainers: pagesTextLayers || [],
1168
+ textContainers: textLayers,
1162
1169
  highlightClass: this.options.elementSelectors.searchHighlightClass,
1163
1170
  highlightMarkClass: this.options.elementSelectors.searchHighlightMarkClass,
1164
1171
  charClass: this.options.elementSelectors.charClass
@@ -1171,19 +1178,6 @@ export class PdfViewer extends Component {
1171
1178
  this.searchService.destroy();
1172
1179
  this.searchService = null;
1173
1180
  }
1174
- getPagesContainer() {
1175
- return this.element.querySelector(toClassSelector(this.options.elementSelectors.pagesContainerClass));
1176
- }
1177
- getDocumentContainer() {
1178
- return this.wrapper.querySelector(toClassSelector(this.options.elementSelectors.documentContainerClass));
1179
- }
1180
- getPagesElements() {
1181
- const documentContainer = this.getDocumentContainer();
1182
- if (!documentContainer) {
1183
- return [];
1184
- }
1185
- return toArray(documentContainer.querySelectorAll(toClassSelector(this.options.elementSelectors.pageSelector)));
1186
- }
1187
1181
  goToNextSearchMatch() {
1188
1182
  if (!this.searchService) {
1189
1183
  return;
@@ -1200,6 +1194,19 @@ export class PdfViewer extends Component {
1200
1194
  const matchElement = this.searchService.getActiveMatchElement();
1201
1195
  this.scrollToSearchMatch(matchElement);
1202
1196
  }
1197
+ getPagesContainer() {
1198
+ return this.element.querySelector(toClassSelector(this.options.elementSelectors.pagesContainerClass));
1199
+ }
1200
+ getDocumentContainer() {
1201
+ return this.wrapper.querySelector(toClassSelector(this.options.elementSelectors.documentContainerClass));
1202
+ }
1203
+ getPagesElements() {
1204
+ const documentContainer = this.getDocumentContainer();
1205
+ if (!documentContainer) {
1206
+ return [];
1207
+ }
1208
+ return toArray(documentContainer.querySelectorAll(toClassSelector(this.options.elementSelectors.pageSelector)));
1209
+ }
1203
1210
  scrollToSearchMatch(matchElement) {
1204
1211
  if (!matchElement) {
1205
1212
  return;
@@ -573,8 +573,8 @@ export class Page extends Component {
573
573
  yield __classPrivateFieldGet(this, _Page_instances, "m", _Page_finishRenderTask).call(this, renderTask);
574
574
  // todo: awaiting this breaks text nodes positioning after zoom
575
575
  // if "includeMarkedContent": true is set in TextLayerBuilder
576
- // await this.#renderTextLayer();
577
- __classPrivateFieldGet(this, _Page_instances, "m", _Page_renderTextLayer).call(this);
576
+ yield __classPrivateFieldGet(this, _Page_instances, "m", _Page_renderTextLayer).call(this);
577
+ // this.#renderTextLayer();
578
578
  if (this.annotationLayer) {
579
579
  yield __classPrivateFieldGet(this, _Page_instances, "m", _Page_renderAnnotationLayer).call(this);
580
580
  }
@@ -1147,18 +1147,25 @@ export class PdfViewer extends Component {
1147
1147
  searchText(options = { text: "", matchCase: false }) {
1148
1148
  var _a;
1149
1149
  this.initSearchService();
1150
- return (_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(options);
1150
+ const matches = (_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(options);
1151
+ return matches;
1151
1152
  }
1152
1153
  clearSearch() {
1153
1154
  this.destroySearchService();
1154
1155
  }
1155
1156
  initSearchService() {
1157
+ const textLayers = Array.from(this.wrapper.querySelectorAll(toClassSelector(this.options.elementSelectors.textLayerClass)) || []);
1156
1158
  if (this.searchService) {
1157
- return;
1159
+ // refresh text nodes as text layers have changed
1160
+ if (textLayers.every((x, i) => x === this.searchService.options.textContainers[i])) {
1161
+ return;
1162
+ }
1163
+ else {
1164
+ this.destroySearchService();
1165
+ }
1158
1166
  }
1159
- const pagesTextLayers = this.wrapper.querySelectorAll(toClassSelector(this.options.elementSelectors.textLayerClass));
1160
1167
  this.searchService = new SearchService({
1161
- textContainers: pagesTextLayers || [],
1168
+ textContainers: textLayers,
1162
1169
  highlightClass: this.options.elementSelectors.searchHighlightClass,
1163
1170
  highlightMarkClass: this.options.elementSelectors.searchHighlightMarkClass,
1164
1171
  charClass: this.options.elementSelectors.charClass
@@ -1171,19 +1178,6 @@ export class PdfViewer extends Component {
1171
1178
  this.searchService.destroy();
1172
1179
  this.searchService = null;
1173
1180
  }
1174
- getPagesContainer() {
1175
- return this.element.querySelector(toClassSelector(this.options.elementSelectors.pagesContainerClass));
1176
- }
1177
- getDocumentContainer() {
1178
- return this.wrapper.querySelector(toClassSelector(this.options.elementSelectors.documentContainerClass));
1179
- }
1180
- getPagesElements() {
1181
- const documentContainer = this.getDocumentContainer();
1182
- if (!documentContainer) {
1183
- return [];
1184
- }
1185
- return toArray(documentContainer.querySelectorAll(toClassSelector(this.options.elementSelectors.pageSelector)));
1186
- }
1187
1181
  goToNextSearchMatch() {
1188
1182
  if (!this.searchService) {
1189
1183
  return;
@@ -1200,6 +1194,19 @@ export class PdfViewer extends Component {
1200
1194
  const matchElement = this.searchService.getActiveMatchElement();
1201
1195
  this.scrollToSearchMatch(matchElement);
1202
1196
  }
1197
+ getPagesContainer() {
1198
+ return this.element.querySelector(toClassSelector(this.options.elementSelectors.pagesContainerClass));
1199
+ }
1200
+ getDocumentContainer() {
1201
+ return this.wrapper.querySelector(toClassSelector(this.options.elementSelectors.documentContainerClass));
1202
+ }
1203
+ getPagesElements() {
1204
+ const documentContainer = this.getDocumentContainer();
1205
+ if (!documentContainer) {
1206
+ return [];
1207
+ }
1208
+ return toArray(documentContainer.querySelectorAll(toClassSelector(this.options.elementSelectors.pageSelector)));
1209
+ }
1203
1210
  scrollToSearchMatch(matchElement) {
1204
1211
  if (!matchElement) {
1205
1212
  return;
@@ -573,8 +573,8 @@ class Page extends component_1.Component {
573
573
  yield tslib_1.__classPrivateFieldGet(this, _Page_instances, "m", _Page_finishRenderTask).call(this, renderTask);
574
574
  // todo: awaiting this breaks text nodes positioning after zoom
575
575
  // if "includeMarkedContent": true is set in TextLayerBuilder
576
- // await this.#renderTextLayer();
577
- tslib_1.__classPrivateFieldGet(this, _Page_instances, "m", _Page_renderTextLayer).call(this);
576
+ yield tslib_1.__classPrivateFieldGet(this, _Page_instances, "m", _Page_renderTextLayer).call(this);
577
+ // this.#renderTextLayer();
578
578
  if (this.annotationLayer) {
579
579
  yield tslib_1.__classPrivateFieldGet(this, _Page_instances, "m", _Page_renderAnnotationLayer).call(this);
580
580
  }
@@ -163,11 +163,11 @@ export declare class PdfViewer extends Component {
163
163
  clearSearch(): void;
164
164
  initSearchService(): void;
165
165
  destroySearchService(): void;
166
+ goToNextSearchMatch(): void;
167
+ goToPreviousSearchMatch(): void;
166
168
  getPagesContainer(): HTMLElement;
167
169
  getDocumentContainer(): HTMLDivElement;
168
170
  getPagesElements(): unknown[];
169
- goToNextSearchMatch(): void;
170
- goToPreviousSearchMatch(): void;
171
171
  scrollToSearchMatch(matchElement: HTMLElement): void;
172
172
  resetInteractionMode(): void;
173
173
  setInteractionMode(args: any): void;
@@ -1150,18 +1150,25 @@ class PdfViewer extends main_1.Component {
1150
1150
  searchText(options = { text: "", matchCase: false }) {
1151
1151
  var _a;
1152
1152
  this.initSearchService();
1153
- return (_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(options);
1153
+ const matches = (_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(options);
1154
+ return matches;
1154
1155
  }
1155
1156
  clearSearch() {
1156
1157
  this.destroySearchService();
1157
1158
  }
1158
1159
  initSearchService() {
1160
+ const textLayers = Array.from(this.wrapper.querySelectorAll((0, main_1.toClassSelector)(this.options.elementSelectors.textLayerClass)) || []);
1159
1161
  if (this.searchService) {
1160
- return;
1162
+ // refresh text nodes as text layers have changed
1163
+ if (textLayers.every((x, i) => x === this.searchService.options.textContainers[i])) {
1164
+ return;
1165
+ }
1166
+ else {
1167
+ this.destroySearchService();
1168
+ }
1161
1169
  }
1162
- const pagesTextLayers = this.wrapper.querySelectorAll((0, main_1.toClassSelector)(this.options.elementSelectors.textLayerClass));
1163
1170
  this.searchService = new search_1.SearchService({
1164
- textContainers: pagesTextLayers || [],
1171
+ textContainers: textLayers,
1165
1172
  highlightClass: this.options.elementSelectors.searchHighlightClass,
1166
1173
  highlightMarkClass: this.options.elementSelectors.searchHighlightMarkClass,
1167
1174
  charClass: this.options.elementSelectors.charClass
@@ -1174,19 +1181,6 @@ class PdfViewer extends main_1.Component {
1174
1181
  this.searchService.destroy();
1175
1182
  this.searchService = null;
1176
1183
  }
1177
- getPagesContainer() {
1178
- return this.element.querySelector((0, main_1.toClassSelector)(this.options.elementSelectors.pagesContainerClass));
1179
- }
1180
- getDocumentContainer() {
1181
- return this.wrapper.querySelector((0, main_1.toClassSelector)(this.options.elementSelectors.documentContainerClass));
1182
- }
1183
- getPagesElements() {
1184
- const documentContainer = this.getDocumentContainer();
1185
- if (!documentContainer) {
1186
- return [];
1187
- }
1188
- return (0, main_1.toArray)(documentContainer.querySelectorAll((0, main_1.toClassSelector)(this.options.elementSelectors.pageSelector)));
1189
- }
1190
1184
  goToNextSearchMatch() {
1191
1185
  if (!this.searchService) {
1192
1186
  return;
@@ -1203,6 +1197,19 @@ class PdfViewer extends main_1.Component {
1203
1197
  const matchElement = this.searchService.getActiveMatchElement();
1204
1198
  this.scrollToSearchMatch(matchElement);
1205
1199
  }
1200
+ getPagesContainer() {
1201
+ return this.element.querySelector((0, main_1.toClassSelector)(this.options.elementSelectors.pagesContainerClass));
1202
+ }
1203
+ getDocumentContainer() {
1204
+ return this.wrapper.querySelector((0, main_1.toClassSelector)(this.options.elementSelectors.documentContainerClass));
1205
+ }
1206
+ getPagesElements() {
1207
+ const documentContainer = this.getDocumentContainer();
1208
+ if (!documentContainer) {
1209
+ return [];
1210
+ }
1211
+ return (0, main_1.toArray)(documentContainer.querySelectorAll((0, main_1.toClassSelector)(this.options.elementSelectors.pageSelector)));
1212
+ }
1206
1213
  scrollToSearchMatch(matchElement) {
1207
1214
  if (!matchElement) {
1208
1215
  return;
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.3.1",
4
+ "version": "0.3.2",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],