Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/embedpre.../assets/pdf/web
File: viewer.js
"\u201F": '"',
[8500] Fix | Delete
"\u00BC": "1/4",
[8501] Fix | Delete
"\u00BD": "1/2",
[8502] Fix | Delete
"\u00BE": "3/4"
[8503] Fix | Delete
};
[8504] Fix | Delete
const DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd, 0x0b4d, 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba, 0x0f84, 0x1039, 0x103a, 0x1714, 0x1734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab, 0x1bf2, 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed, 0x0c56, 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74]);
[8505] Fix | Delete
let DIACRITICS_EXCEPTION_STR;
[8506] Fix | Delete
const DIACRITICS_REG_EXP = /\p{M}+/gu;
[8507] Fix | Delete
const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
[8508] Fix | Delete
const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
[8509] Fix | Delete
const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
[8510] Fix | Delete
const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
[8511] Fix | Delete
const SYLLABLES_LENGTHS = new Map();
[8512] Fix | Delete
const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
[8513] Fix | Delete
const NFKC_CHARS_TO_NORMALIZE = new Map();
[8514] Fix | Delete
let noSyllablesRegExp = null;
[8515] Fix | Delete
let withSyllablesRegExp = null;
[8516] Fix | Delete
function normalize(text) {
[8517] Fix | Delete
const syllablePositions = [];
[8518] Fix | Delete
let m;
[8519] Fix | Delete
while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
[8520] Fix | Delete
let {
[8521] Fix | Delete
index
[8522] Fix | Delete
} = m;
[8523] Fix | Delete
for (const char of m[0]) {
[8524] Fix | Delete
let len = SYLLABLES_LENGTHS.get(char);
[8525] Fix | Delete
if (!len) {
[8526] Fix | Delete
len = char.normalize("NFD").length;
[8527] Fix | Delete
SYLLABLES_LENGTHS.set(char, len);
[8528] Fix | Delete
}
[8529] Fix | Delete
syllablePositions.push([len, index++]);
[8530] Fix | Delete
}
[8531] Fix | Delete
}
[8532] Fix | Delete
let normalizationRegex;
[8533] Fix | Delete
if (syllablePositions.length === 0 && noSyllablesRegExp) {
[8534] Fix | Delete
normalizationRegex = noSyllablesRegExp;
[8535] Fix | Delete
} else if (syllablePositions.length > 0 && withSyllablesRegExp) {
[8536] Fix | Delete
normalizationRegex = withSyllablesRegExp;
[8537] Fix | Delete
} else {
[8538] Fix | Delete
const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
[8539] Fix | Delete
const toNormalizeWithNFKC = getNormalizeWithNFKC();
[8540] Fix | Delete
const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
[8541] Fix | Delete
const HKDiacritics = "(?:\u3099|\u309A)";
[8542] Fix | Delete
const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
[8543] Fix | Delete
if (syllablePositions.length === 0) {
[8544] Fix | Delete
normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
[8545] Fix | Delete
} else {
[8546] Fix | Delete
normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
[8547] Fix | Delete
}
[8548] Fix | Delete
}
[8549] Fix | Delete
const rawDiacriticsPositions = [];
[8550] Fix | Delete
while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
[8551] Fix | Delete
rawDiacriticsPositions.push([m[0].length, m.index]);
[8552] Fix | Delete
}
[8553] Fix | Delete
let normalized = text.normalize("NFD");
[8554] Fix | Delete
const positions = [[0, 0]];
[8555] Fix | Delete
let rawDiacriticsIndex = 0;
[8556] Fix | Delete
let syllableIndex = 0;
[8557] Fix | Delete
let shift = 0;
[8558] Fix | Delete
let shiftOrigin = 0;
[8559] Fix | Delete
let eol = 0;
[8560] Fix | Delete
let hasDiacritics = false;
[8561] Fix | Delete
normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => {
[8562] Fix | Delete
i -= shiftOrigin;
[8563] Fix | Delete
if (p1) {
[8564] Fix | Delete
const replacement = CHARACTERS_TO_NORMALIZE[p1];
[8565] Fix | Delete
const jj = replacement.length;
[8566] Fix | Delete
for (let j = 1; j < jj; j++) {
[8567] Fix | Delete
positions.push([i - shift + j, shift - j]);
[8568] Fix | Delete
}
[8569] Fix | Delete
shift -= jj - 1;
[8570] Fix | Delete
return replacement;
[8571] Fix | Delete
}
[8572] Fix | Delete
if (p2) {
[8573] Fix | Delete
let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
[8574] Fix | Delete
if (!replacement) {
[8575] Fix | Delete
replacement = p2.normalize("NFKC");
[8576] Fix | Delete
NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
[8577] Fix | Delete
}
[8578] Fix | Delete
const jj = replacement.length;
[8579] Fix | Delete
for (let j = 1; j < jj; j++) {
[8580] Fix | Delete
positions.push([i - shift + j, shift - j]);
[8581] Fix | Delete
}
[8582] Fix | Delete
shift -= jj - 1;
[8583] Fix | Delete
return replacement;
[8584] Fix | Delete
}
[8585] Fix | Delete
if (p3) {
[8586] Fix | Delete
hasDiacritics = true;
[8587] Fix | Delete
if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
[8588] Fix | Delete
++rawDiacriticsIndex;
[8589] Fix | Delete
} else {
[8590] Fix | Delete
positions.push([i - 1 - shift + 1, shift - 1]);
[8591] Fix | Delete
shift -= 1;
[8592] Fix | Delete
shiftOrigin += 1;
[8593] Fix | Delete
}
[8594] Fix | Delete
positions.push([i - shift + 1, shift]);
[8595] Fix | Delete
shiftOrigin += 1;
[8596] Fix | Delete
eol += 1;
[8597] Fix | Delete
return p3.charAt(0);
[8598] Fix | Delete
}
[8599] Fix | Delete
if (p4) {
[8600] Fix | Delete
const hasTrailingDashEOL = p4.endsWith("\n");
[8601] Fix | Delete
const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
[8602] Fix | Delete
hasDiacritics = true;
[8603] Fix | Delete
let jj = len;
[8604] Fix | Delete
if (i + eol === rawDiacriticsPositions[rawDiacriticsIndex]?.[1]) {
[8605] Fix | Delete
jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
[8606] Fix | Delete
++rawDiacriticsIndex;
[8607] Fix | Delete
}
[8608] Fix | Delete
for (let j = 1; j <= jj; j++) {
[8609] Fix | Delete
positions.push([i - 1 - shift + j, shift - j]);
[8610] Fix | Delete
}
[8611] Fix | Delete
shift -= jj;
[8612] Fix | Delete
shiftOrigin += jj;
[8613] Fix | Delete
if (hasTrailingDashEOL) {
[8614] Fix | Delete
i += len - 1;
[8615] Fix | Delete
positions.push([i - shift + 1, 1 + shift]);
[8616] Fix | Delete
shift += 1;
[8617] Fix | Delete
shiftOrigin += 1;
[8618] Fix | Delete
eol += 1;
[8619] Fix | Delete
return p4.slice(0, len);
[8620] Fix | Delete
}
[8621] Fix | Delete
return p4;
[8622] Fix | Delete
}
[8623] Fix | Delete
if (p5) {
[8624] Fix | Delete
const len = p5.length - 2;
[8625] Fix | Delete
positions.push([i - shift + len, 1 + shift]);
[8626] Fix | Delete
shift += 1;
[8627] Fix | Delete
shiftOrigin += 1;
[8628] Fix | Delete
eol += 1;
[8629] Fix | Delete
return p5.slice(0, -2);
[8630] Fix | Delete
}
[8631] Fix | Delete
if (p6) {
[8632] Fix | Delete
const len = p6.length - 1;
[8633] Fix | Delete
positions.push([i - shift + len, shift]);
[8634] Fix | Delete
shiftOrigin += 1;
[8635] Fix | Delete
eol += 1;
[8636] Fix | Delete
return p6.slice(0, -1);
[8637] Fix | Delete
}
[8638] Fix | Delete
if (p7) {
[8639] Fix | Delete
positions.push([i - shift + 1, shift - 1]);
[8640] Fix | Delete
shift -= 1;
[8641] Fix | Delete
shiftOrigin += 1;
[8642] Fix | Delete
eol += 1;
[8643] Fix | Delete
return " ";
[8644] Fix | Delete
}
[8645] Fix | Delete
if (i + eol === syllablePositions[syllableIndex]?.[1]) {
[8646] Fix | Delete
const newCharLen = syllablePositions[syllableIndex][0] - 1;
[8647] Fix | Delete
++syllableIndex;
[8648] Fix | Delete
for (let j = 1; j <= newCharLen; j++) {
[8649] Fix | Delete
positions.push([i - (shift - j), shift - j]);
[8650] Fix | Delete
}
[8651] Fix | Delete
shift -= newCharLen;
[8652] Fix | Delete
shiftOrigin += newCharLen;
[8653] Fix | Delete
}
[8654] Fix | Delete
return p8;
[8655] Fix | Delete
});
[8656] Fix | Delete
positions.push([normalized.length, shift]);
[8657] Fix | Delete
return [normalized, positions, hasDiacritics];
[8658] Fix | Delete
}
[8659] Fix | Delete
function getOriginalIndex(diffs, pos, len) {
[8660] Fix | Delete
if (!diffs) {
[8661] Fix | Delete
return [pos, len];
[8662] Fix | Delete
}
[8663] Fix | Delete
const start = pos;
[8664] Fix | Delete
const end = pos + len - 1;
[8665] Fix | Delete
let i = binarySearchFirstItem(diffs, x => x[0] >= start);
[8666] Fix | Delete
if (diffs[i][0] > start) {
[8667] Fix | Delete
--i;
[8668] Fix | Delete
}
[8669] Fix | Delete
let j = binarySearchFirstItem(diffs, x => x[0] >= end, i);
[8670] Fix | Delete
if (diffs[j][0] > end) {
[8671] Fix | Delete
--j;
[8672] Fix | Delete
}
[8673] Fix | Delete
const oldStart = start + diffs[i][1];
[8674] Fix | Delete
const oldEnd = end + diffs[j][1];
[8675] Fix | Delete
const oldLen = oldEnd + 1 - oldStart;
[8676] Fix | Delete
return [oldStart, oldLen];
[8677] Fix | Delete
}
[8678] Fix | Delete
class PDFFindController {
[8679] Fix | Delete
#state = null;
[8680] Fix | Delete
#updateMatchesCountOnProgress = true;
[8681] Fix | Delete
#visitedPagesCount = 0;
[8682] Fix | Delete
constructor({
[8683] Fix | Delete
linkService,
[8684] Fix | Delete
eventBus,
[8685] Fix | Delete
updateMatchesCountOnProgress = true
[8686] Fix | Delete
}) {
[8687] Fix | Delete
this._linkService = linkService;
[8688] Fix | Delete
this._eventBus = eventBus;
[8689] Fix | Delete
this.#updateMatchesCountOnProgress = updateMatchesCountOnProgress;
[8690] Fix | Delete
this.onIsPageVisible = null;
[8691] Fix | Delete
this.#reset();
[8692] Fix | Delete
eventBus._on("find", this.#onFind.bind(this));
[8693] Fix | Delete
eventBus._on("findbarclose", this.#onFindBarClose.bind(this));
[8694] Fix | Delete
}
[8695] Fix | Delete
get highlightMatches() {
[8696] Fix | Delete
return this._highlightMatches;
[8697] Fix | Delete
}
[8698] Fix | Delete
get pageMatches() {
[8699] Fix | Delete
return this._pageMatches;
[8700] Fix | Delete
}
[8701] Fix | Delete
get pageMatchesLength() {
[8702] Fix | Delete
return this._pageMatchesLength;
[8703] Fix | Delete
}
[8704] Fix | Delete
get selected() {
[8705] Fix | Delete
return this._selected;
[8706] Fix | Delete
}
[8707] Fix | Delete
get state() {
[8708] Fix | Delete
return this.#state;
[8709] Fix | Delete
}
[8710] Fix | Delete
setDocument(pdfDocument) {
[8711] Fix | Delete
if (this._pdfDocument) {
[8712] Fix | Delete
this.#reset();
[8713] Fix | Delete
}
[8714] Fix | Delete
if (!pdfDocument) {
[8715] Fix | Delete
return;
[8716] Fix | Delete
}
[8717] Fix | Delete
this._pdfDocument = pdfDocument;
[8718] Fix | Delete
this._firstPageCapability.resolve();
[8719] Fix | Delete
}
[8720] Fix | Delete
#onFind(state) {
[8721] Fix | Delete
if (!state) {
[8722] Fix | Delete
return;
[8723] Fix | Delete
}
[8724] Fix | Delete
const pdfDocument = this._pdfDocument;
[8725] Fix | Delete
const {
[8726] Fix | Delete
type
[8727] Fix | Delete
} = state;
[8728] Fix | Delete
if (this.#state === null || this.#shouldDirtyMatch(state)) {
[8729] Fix | Delete
this._dirtyMatch = true;
[8730] Fix | Delete
}
[8731] Fix | Delete
this.#state = state;
[8732] Fix | Delete
if (type !== "highlightallchange") {
[8733] Fix | Delete
this.#updateUIState(FindState.PENDING);
[8734] Fix | Delete
}
[8735] Fix | Delete
this._firstPageCapability.promise.then(() => {
[8736] Fix | Delete
if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
[8737] Fix | Delete
return;
[8738] Fix | Delete
}
[8739] Fix | Delete
this.#extractText();
[8740] Fix | Delete
const findbarClosed = !this._highlightMatches;
[8741] Fix | Delete
const pendingTimeout = !!this._findTimeout;
[8742] Fix | Delete
if (this._findTimeout) {
[8743] Fix | Delete
clearTimeout(this._findTimeout);
[8744] Fix | Delete
this._findTimeout = null;
[8745] Fix | Delete
}
[8746] Fix | Delete
if (!type) {
[8747] Fix | Delete
this._findTimeout = setTimeout(() => {
[8748] Fix | Delete
this.#nextMatch();
[8749] Fix | Delete
this._findTimeout = null;
[8750] Fix | Delete
}, FIND_TIMEOUT);
[8751] Fix | Delete
} else if (this._dirtyMatch) {
[8752] Fix | Delete
this.#nextMatch();
[8753] Fix | Delete
} else if (type === "again") {
[8754] Fix | Delete
this.#nextMatch();
[8755] Fix | Delete
if (findbarClosed && this.#state.highlightAll) {
[8756] Fix | Delete
this.#updateAllPages();
[8757] Fix | Delete
}
[8758] Fix | Delete
} else if (type === "highlightallchange") {
[8759] Fix | Delete
if (pendingTimeout) {
[8760] Fix | Delete
this.#nextMatch();
[8761] Fix | Delete
} else {
[8762] Fix | Delete
this._highlightMatches = true;
[8763] Fix | Delete
}
[8764] Fix | Delete
this.#updateAllPages();
[8765] Fix | Delete
} else {
[8766] Fix | Delete
this.#nextMatch();
[8767] Fix | Delete
}
[8768] Fix | Delete
});
[8769] Fix | Delete
}
[8770] Fix | Delete
scrollMatchIntoView({
[8771] Fix | Delete
element = null,
[8772] Fix | Delete
selectedLeft = 0,
[8773] Fix | Delete
pageIndex = -1,
[8774] Fix | Delete
matchIndex = -1
[8775] Fix | Delete
}) {
[8776] Fix | Delete
if (!this._scrollMatches || !element) {
[8777] Fix | Delete
return;
[8778] Fix | Delete
} else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
[8779] Fix | Delete
return;
[8780] Fix | Delete
} else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
[8781] Fix | Delete
return;
[8782] Fix | Delete
}
[8783] Fix | Delete
this._scrollMatches = false;
[8784] Fix | Delete
const spot = {
[8785] Fix | Delete
top: MATCH_SCROLL_OFFSET_TOP,
[8786] Fix | Delete
left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
[8787] Fix | Delete
};
[8788] Fix | Delete
scrollIntoView(element, spot, true);
[8789] Fix | Delete
}
[8790] Fix | Delete
#reset() {
[8791] Fix | Delete
this._highlightMatches = false;
[8792] Fix | Delete
this._scrollMatches = false;
[8793] Fix | Delete
this._pdfDocument = null;
[8794] Fix | Delete
this._pageMatches = [];
[8795] Fix | Delete
this._pageMatchesLength = [];
[8796] Fix | Delete
this.#visitedPagesCount = 0;
[8797] Fix | Delete
this.#state = null;
[8798] Fix | Delete
this._selected = {
[8799] Fix | Delete
pageIdx: -1,
[8800] Fix | Delete
matchIdx: -1
[8801] Fix | Delete
};
[8802] Fix | Delete
this._offset = {
[8803] Fix | Delete
pageIdx: null,
[8804] Fix | Delete
matchIdx: null,
[8805] Fix | Delete
wrapped: false
[8806] Fix | Delete
};
[8807] Fix | Delete
this._extractTextPromises = [];
[8808] Fix | Delete
this._pageContents = [];
[8809] Fix | Delete
this._pageDiffs = [];
[8810] Fix | Delete
this._hasDiacritics = [];
[8811] Fix | Delete
this._matchesCountTotal = 0;
[8812] Fix | Delete
this._pagesToSearch = null;
[8813] Fix | Delete
this._pendingFindMatches = new Set();
[8814] Fix | Delete
this._resumePageIdx = null;
[8815] Fix | Delete
this._dirtyMatch = false;
[8816] Fix | Delete
clearTimeout(this._findTimeout);
[8817] Fix | Delete
this._findTimeout = null;
[8818] Fix | Delete
this._firstPageCapability = Promise.withResolvers();
[8819] Fix | Delete
}
[8820] Fix | Delete
get #query() {
[8821] Fix | Delete
const {
[8822] Fix | Delete
query
[8823] Fix | Delete
} = this.#state;
[8824] Fix | Delete
if (typeof query === "string") {
[8825] Fix | Delete
if (query !== this._rawQuery) {
[8826] Fix | Delete
this._rawQuery = query;
[8827] Fix | Delete
[this._normalizedQuery] = normalize(query);
[8828] Fix | Delete
}
[8829] Fix | Delete
return this._normalizedQuery;
[8830] Fix | Delete
}
[8831] Fix | Delete
return (query || []).filter(q => !!q).map(q => normalize(q)[0]);
[8832] Fix | Delete
}
[8833] Fix | Delete
#shouldDirtyMatch(state) {
[8834] Fix | Delete
const newQuery = state.query,
[8835] Fix | Delete
prevQuery = this.#state.query;
[8836] Fix | Delete
const newType = typeof newQuery,
[8837] Fix | Delete
prevType = typeof prevQuery;
[8838] Fix | Delete
if (newType !== prevType) {
[8839] Fix | Delete
return true;
[8840] Fix | Delete
}
[8841] Fix | Delete
if (newType === "string") {
[8842] Fix | Delete
if (newQuery !== prevQuery) {
[8843] Fix | Delete
return true;
[8844] Fix | Delete
}
[8845] Fix | Delete
} else if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
[8846] Fix | Delete
return true;
[8847] Fix | Delete
}
[8848] Fix | Delete
switch (state.type) {
[8849] Fix | Delete
case "again":
[8850] Fix | Delete
const pageNumber = this._selected.pageIdx + 1;
[8851] Fix | Delete
const linkService = this._linkService;
[8852] Fix | Delete
return pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !(this.onIsPageVisible?.(pageNumber) ?? true);
[8853] Fix | Delete
case "highlightallchange":
[8854] Fix | Delete
return false;
[8855] Fix | Delete
}
[8856] Fix | Delete
return true;
[8857] Fix | Delete
}
[8858] Fix | Delete
#isEntireWord(content, startIdx, length) {
[8859] Fix | Delete
let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
[8860] Fix | Delete
if (match) {
[8861] Fix | Delete
const first = content.charCodeAt(startIdx);
[8862] Fix | Delete
const limit = match[1].charCodeAt(0);
[8863] Fix | Delete
if (getCharacterType(first) === getCharacterType(limit)) {
[8864] Fix | Delete
return false;
[8865] Fix | Delete
}
[8866] Fix | Delete
}
[8867] Fix | Delete
match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
[8868] Fix | Delete
if (match) {
[8869] Fix | Delete
const last = content.charCodeAt(startIdx + length - 1);
[8870] Fix | Delete
const limit = match[1].charCodeAt(0);
[8871] Fix | Delete
if (getCharacterType(last) === getCharacterType(limit)) {
[8872] Fix | Delete
return false;
[8873] Fix | Delete
}
[8874] Fix | Delete
}
[8875] Fix | Delete
return true;
[8876] Fix | Delete
}
[8877] Fix | Delete
#calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
[8878] Fix | Delete
const matches = this._pageMatches[pageIndex] = [];
[8879] Fix | Delete
const matchesLength = this._pageMatchesLength[pageIndex] = [];
[8880] Fix | Delete
if (!query) {
[8881] Fix | Delete
return;
[8882] Fix | Delete
}
[8883] Fix | Delete
const diffs = this._pageDiffs[pageIndex];
[8884] Fix | Delete
let match;
[8885] Fix | Delete
while ((match = query.exec(pageContent)) !== null) {
[8886] Fix | Delete
if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
[8887] Fix | Delete
continue;
[8888] Fix | Delete
}
[8889] Fix | Delete
const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
[8890] Fix | Delete
if (matchLen) {
[8891] Fix | Delete
matches.push(matchPos);
[8892] Fix | Delete
matchesLength.push(matchLen);
[8893] Fix | Delete
}
[8894] Fix | Delete
}
[8895] Fix | Delete
}
[8896] Fix | Delete
#convertToRegExpString(query, hasDiacritics) {
[8897] Fix | Delete
const {
[8898] Fix | Delete
matchDiacritics
[8899] Fix | Delete
} = this.#state;
[8900] Fix | Delete
let isUnicode = false;
[8901] Fix | Delete
query = query.replaceAll(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
[8902] Fix | Delete
if (p1) {
[8903] Fix | Delete
return `[ ]*\\${p1}[ ]*`;
[8904] Fix | Delete
}
[8905] Fix | Delete
if (p2) {
[8906] Fix | Delete
return `[ ]*${p2}[ ]*`;
[8907] Fix | Delete
}
[8908] Fix | Delete
if (p3) {
[8909] Fix | Delete
return "[ ]+";
[8910] Fix | Delete
}
[8911] Fix | Delete
if (matchDiacritics) {
[8912] Fix | Delete
return p4 || p5;
[8913] Fix | Delete
}
[8914] Fix | Delete
if (p4) {
[8915] Fix | Delete
return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
[8916] Fix | Delete
}
[8917] Fix | Delete
if (hasDiacritics) {
[8918] Fix | Delete
isUnicode = true;
[8919] Fix | Delete
return `${p5}\\p{M}*`;
[8920] Fix | Delete
}
[8921] Fix | Delete
return p5;
[8922] Fix | Delete
});
[8923] Fix | Delete
const trailingSpaces = "[ ]*";
[8924] Fix | Delete
if (query.endsWith(trailingSpaces)) {
[8925] Fix | Delete
query = query.slice(0, query.length - trailingSpaces.length);
[8926] Fix | Delete
}
[8927] Fix | Delete
if (matchDiacritics) {
[8928] Fix | Delete
if (hasDiacritics) {
[8929] Fix | Delete
DIACRITICS_EXCEPTION_STR ||= String.fromCharCode(...DIACRITICS_EXCEPTION);
[8930] Fix | Delete
isUnicode = true;
[8931] Fix | Delete
query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
[8932] Fix | Delete
}
[8933] Fix | Delete
}
[8934] Fix | Delete
return [isUnicode, query];
[8935] Fix | Delete
}
[8936] Fix | Delete
#calculateMatch(pageIndex) {
[8937] Fix | Delete
let query = this.#query;
[8938] Fix | Delete
if (query.length === 0) {
[8939] Fix | Delete
return;
[8940] Fix | Delete
}
[8941] Fix | Delete
const {
[8942] Fix | Delete
caseSensitive,
[8943] Fix | Delete
entireWord
[8944] Fix | Delete
} = this.#state;
[8945] Fix | Delete
const pageContent = this._pageContents[pageIndex];
[8946] Fix | Delete
const hasDiacritics = this._hasDiacritics[pageIndex];
[8947] Fix | Delete
let isUnicode = false;
[8948] Fix | Delete
if (typeof query === "string") {
[8949] Fix | Delete
[isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
[8950] Fix | Delete
} else {
[8951] Fix | Delete
query = query.sort().reverse().map(q => {
[8952] Fix | Delete
const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
[8953] Fix | Delete
isUnicode ||= isUnicodePart;
[8954] Fix | Delete
return `(${queryPart})`;
[8955] Fix | Delete
}).join("|");
[8956] Fix | Delete
}
[8957] Fix | Delete
const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
[8958] Fix | Delete
query = query ? new RegExp(query, flags) : null;
[8959] Fix | Delete
this.#calculateRegExpMatch(query, entireWord, pageIndex, pageContent);
[8960] Fix | Delete
if (this.#state.highlightAll) {
[8961] Fix | Delete
this.#updatePage(pageIndex);
[8962] Fix | Delete
}
[8963] Fix | Delete
if (this._resumePageIdx === pageIndex) {
[8964] Fix | Delete
this._resumePageIdx = null;
[8965] Fix | Delete
this.#nextPageMatch();
[8966] Fix | Delete
}
[8967] Fix | Delete
const pageMatchesCount = this._pageMatches[pageIndex].length;
[8968] Fix | Delete
this._matchesCountTotal += pageMatchesCount;
[8969] Fix | Delete
if (this.#updateMatchesCountOnProgress) {
[8970] Fix | Delete
if (pageMatchesCount > 0) {
[8971] Fix | Delete
this.#updateUIResultsCount();
[8972] Fix | Delete
}
[8973] Fix | Delete
} else if (++this.#visitedPagesCount === this._linkService.pagesCount) {
[8974] Fix | Delete
this.#updateUIResultsCount();
[8975] Fix | Delete
}
[8976] Fix | Delete
}
[8977] Fix | Delete
#extractText() {
[8978] Fix | Delete
if (this._extractTextPromises.length > 0) {
[8979] Fix | Delete
return;
[8980] Fix | Delete
}
[8981] Fix | Delete
let deferred = Promise.resolve();
[8982] Fix | Delete
const textOptions = {
[8983] Fix | Delete
disableNormalization: true
[8984] Fix | Delete
};
[8985] Fix | Delete
for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
[8986] Fix | Delete
const {
[8987] Fix | Delete
promise,
[8988] Fix | Delete
resolve
[8989] Fix | Delete
} = Promise.withResolvers();
[8990] Fix | Delete
this._extractTextPromises[i] = promise;
[8991] Fix | Delete
deferred = deferred.then(() => {
[8992] Fix | Delete
return this._pdfDocument.getPage(i + 1).then(pdfPage => pdfPage.getTextContent(textOptions)).then(textContent => {
[8993] Fix | Delete
const strBuf = [];
[8994] Fix | Delete
for (const textItem of textContent.items) {
[8995] Fix | Delete
strBuf.push(textItem.str);
[8996] Fix | Delete
if (textItem.hasEOL) {
[8997] Fix | Delete
strBuf.push("\n");
[8998] Fix | Delete
}
[8999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function