Skip to content

Commit

Permalink
stephanrauh/ngx-extended-pdf-viewer#2339 added comments to simplify m…
Browse files Browse the repository at this point in the history
…erging
  • Loading branch information
stephanrauh committed May 24, 2024
1 parent ab1e907 commit 9c15ea3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion web/ngx-extended-pdf-viewer-version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const ngxExtendedPdfViewerVersion = '20.0.2';
export const ngxExtendedPdfViewerVersion = '20.1.0';
18 changes: 9 additions & 9 deletions web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import { getCharacterType, getNormalizeWithNFKC } from "./pdf_find_utils.js";

/**
* Search and replacements for ngx-extended-pdf-viewer
*
*
* `#convertToRegExpString` -> `_convertToRegExpString`
* `#calculateMatch` -> `_calculateMatch`
* `#calculateRegExpMatch` -> `_calculateRegExpMatch`
*
*
*/

const FindState = {
Expand Down Expand Up @@ -688,7 +688,7 @@ class PDFFindController {
return true;
}

_calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
_calculateRegExpMatch(query, entireWord, pageIndex, pageContent) { // #2339 modified by ngx-extended-pdf-viewer
const matches = (this._pageMatches[pageIndex] = []);
const matchesLength = (this._pageMatchesLength[pageIndex] = []);
if (!query) {
Expand Down Expand Up @@ -719,7 +719,7 @@ class PDFFindController {
}
}

_convertToRegExpString(query, hasDiacritics) {
_convertToRegExpString(query, hasDiacritics) { // #2339 modified by ngx-extended-pdf-viewer
const { matchDiacritics } = this.#state;
let isUnicode = false;
query = query.replaceAll(
Expand Down Expand Up @@ -789,7 +789,7 @@ class PDFFindController {
return [isUnicode, query];
}

_calculateMatch(pageIndex) {
_calculateMatch(pageIndex) { // #2339 modified by ngx-extended-pdf-viewer
let query = this.#query;
if (query.length === 0) {
return; // Do nothing: the matches should be wiped out already.
Expand All @@ -800,15 +800,15 @@ class PDFFindController {

let isUnicode = false;
if (typeof query === "string") {
[isUnicode, query] = this._convertToRegExpString(query, hasDiacritics);
[isUnicode, query] = this._convertToRegExpString(query, hasDiacritics); // #2339 modified by ngx-extended-pdf-viewer
} else {
// Words are sorted in reverse order to be sure that "foobar" is matched
// before "foo" in case the query is "foobar foo".
query = query
.sort()
.reverse()
.map(q => {
const [isUnicodePart, queryPart] = this._convertToRegExpString(
const [isUnicodePart, queryPart] = this._convertToRegExpString( // #2339 modified by ngx-extended-pdf-viewer
q,
hasDiacritics
);
Expand All @@ -821,7 +821,7 @@ class PDFFindController {
const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
query = query ? new RegExp(query, flags) : null;

this._calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
this._calculateRegExpMatch(query, entireWord, pageIndex, pageContent); // #2339 modified by ngx-extended-pdf-viewer

// When `highlightAll` is set, ensure that the matches on previously
// rendered (and still active) pages are correctly highlighted.
Expand Down Expand Up @@ -950,7 +950,7 @@ class PDFFindController {
this._pendingFindMatches.add(i);
this._extractTextPromises[i].then(() => {
this._pendingFindMatches.delete(i);
this._calculateMatch(i);
this._calculateMatch(i); // #2339 modified by ngx-extended-pdf-viewer
});
}
}
Expand Down

0 comments on commit 9c15ea3

Please sign in to comment.