Skip to content

Commit

Permalink
stephanrauh/ngx-extended-pdf-viewer#2339 allow for custom find contro…
Browse files Browse the repository at this point in the history
…llers
  • Loading branch information
stephanrauh committed Aug 14, 2024
1 parent 2117c3d commit 818631d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
11 changes: 9 additions & 2 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,15 @@ const PDFViewerApplication = {

const downloadManager = (this.downloadManager = new DownloadManager());

// #2399 modified by ngx-extended-pdf-viewer
let FindControllerConstructor = PDFFindController;
if (AppOptions.get("findController")) {
FindControllerConstructor = AppOptions.get("findController");
}
// #2399 end of modification by ngx-extended-pdf-viewer

// #2488 modified by ngx-extended-pdf-viewer
const customFindController = new PDFFindController({
const customFindController = new FindControllerConstructor({ // #2399 modified by ngx-extended-pdf-viewer
linkService: pdfLinkService,
eventBus,
// #492 modified by ngx-extended-pdf-viewer
Expand All @@ -451,7 +458,7 @@ const PDFViewerApplication = {
this.customFindController = customFindController;
// #2488 end of modification by ngx-extended-pdf-viewer

const findController = new PDFFindController({
const findController = new FindControllerConstructor({ // #2399 modified by ngx-extended-pdf-viewer
linkService: pdfLinkService,
eventBus,
// #492 modified by ngx-extended-pdf-viewer
Expand Down
21 changes: 20 additions & 1 deletion web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ const defaultOptions = {
kind: OptionKind.VIEWER,
},
// #2459 end of modification by ngx-extended-pdf-viewer
// #2480 modified by ngx-extended-pdf-viewer
worker: {
/** @type {Object} */
value: null,
kind: OptionKind.WORKER,
},
// #2480 end of modification by ngx-extended-pdf-viewer
// #2339 modified by ngx-extended-pdf-viewer
findController: {
/** @type {Object} */
value: null,
kind: OptionKind.VIEWER,
},
secondaryFindController: {
/** @type {Object} */
value: null,
kind: OptionKind.VIEWER,
},
// #2339 end of modification by ngx-extended-pdf-viewer
allowedGlobalEvents: {
/** @type {Object} */
value: null,
Expand Down Expand Up @@ -664,7 +683,7 @@ class AppOptions {
}
}
if (!(typeof userOpt === typeof defaultOpt.value || Type[(typeof userOpt).toUpperCase()] & defaultOpt.type)) {
if (name !== "maxZoom" && name !== "minZoom" && name !== "passwordPrompt" && name !== "defaultZoomValue") {
if (!["maxZoom", "minZoom", "passwordPrompt", "defaultZoomValue", "findController"].includes(name)) {
console.error("Invalid AppOptions value: " + name + " = " + userOpt);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class PDFFindController {
left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT,
};
/** #492 modified by ngx-extended-pdf-viewer */
scrollIntoView(element, spot, /* scrollMatches = */ true, this._pageViewMode === 'infinite-scroll');
scrollIntoView(element, spot, /* scrollMatches = */ true, this._pageViewMode === "infinite-scroll");
/** #492 end of modification */
}

Expand Down

0 comments on commit 818631d

Please sign in to comment.