|
@@ -23,7 +23,8 @@ import { PDFAnnotationLayer } from './pdf_annotation_layer.js'
|
|
import { TextLayerBuilder } from "./text_layer_builder.js";
|
|
import { TextLayerBuilder } from "./text_layer_builder.js";
|
|
import ComPDFAnnotationLayer from './annotation/layer.js';
|
|
import ComPDFAnnotationLayer from './annotation/layer.js';
|
|
import { ContentContainer } from "./editor/content_container.js";
|
|
import { ContentContainer } from "./editor/content_container.js";
|
|
-import { TextSelection } from "./TextSelection";
|
|
|
|
|
|
+import TextSelection from "./TextSelection";
|
|
|
|
+import TextSearch from './TextSearch'
|
|
|
|
|
|
import AnnotationManager from "./annotations";
|
|
import AnnotationManager from "./annotations";
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -153,6 +154,8 @@ class PDFPageView {
|
|
this.structTreeLayer = null;
|
|
this.structTreeLayer = null;
|
|
this.contentContainer = null;
|
|
this.contentContainer = null;
|
|
this.textSelection = null
|
|
this.textSelection = null
|
|
|
|
+ this.textSearch = null
|
|
|
|
+ this.searchResults = null
|
|
|
|
|
|
const div = document.createElement("div");
|
|
const div = document.createElement("div");
|
|
div.className = "page page-number" + this.id;
|
|
div.className = "page page-number" + this.id;
|
|
@@ -171,6 +174,7 @@ class PDFPageView {
|
|
|
|
|
|
this.eventBus._on('toolChanged', this.handleTool.bind(this))
|
|
this.eventBus._on('toolChanged', this.handleTool.bind(this))
|
|
this.eventBus._on('toolModeChanged', this.handleToolMode.bind(this))
|
|
this.eventBus._on('toolModeChanged', this.handleToolMode.bind(this))
|
|
|
|
+ this.eventBus._on('search', this.handleSearch.bind(this))
|
|
|
|
|
|
this.mode = null
|
|
this.mode = null
|
|
|
|
|
|
@@ -294,6 +298,13 @@ class PDFPageView {
|
|
if (this.compdfAnnotationLayer) return
|
|
if (this.compdfAnnotationLayer) return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ handleSearch(searchResults) {
|
|
|
|
+ this.searchResults = searchResults
|
|
|
|
+ if (this.textSearch) {
|
|
|
|
+ this.textSearch.searchResults = searchResults
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
get annotations() {
|
|
get annotations() {
|
|
return this._annotations
|
|
return this._annotations
|
|
}
|
|
}
|
|
@@ -402,6 +413,12 @@ class PDFPageView {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ clearSearchResults() {
|
|
|
|
+ if (this.textSearch) {
|
|
|
|
+ this.textSearch.destroy()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @private
|
|
* @private
|
|
*/
|
|
*/
|
|
@@ -809,6 +826,11 @@ class PDFPageView {
|
|
this.textSelection.destroy()
|
|
this.textSelection.destroy()
|
|
this.textSelection = null
|
|
this.textSelection = null
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (this.textSearch) {
|
|
|
|
+ this.textSearch.destroy()
|
|
|
|
+ this.textSearch = null
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
cssTransform({
|
|
cssTransform({
|
|
@@ -1077,6 +1099,16 @@ class PDFPageView {
|
|
pageViewer: this
|
|
pageViewer: this
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (!this.textSearch) {
|
|
|
|
+ this.textSearch = new TextSearch({
|
|
|
|
+ viewport: this.viewport,
|
|
|
|
+ scale: this.scale,
|
|
|
|
+ pageIndex: this.pageIndex,
|
|
|
|
+ container: div,
|
|
|
|
+ results: this.searchResults,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
function (reason) {
|
|
function (reason) {
|
|
return finishPaintTask(reason);
|
|
return finishPaintTask(reason);
|
|
@@ -1106,6 +1138,12 @@ class PDFPageView {
|
|
return resultPromise;
|
|
return resultPromise;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ setActiveSearchResult(search) {
|
|
|
|
+ if (this.textSearch) {
|
|
|
|
+ this.textSearch.setActiveResult(search)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
async paintOnCanvas(canvasWrapper) {
|
|
async paintOnCanvas(canvasWrapper) {
|
|
const renderCapability = createPromiseCapability();
|
|
const renderCapability = createPromiseCapability();
|
|
const result = {
|
|
const result = {
|