@ntlab/ntjs-assets 2.0.39 → 2.0.41
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.
- package/assets/js/DataTables/DataTables/js/dataTables.js +62 -21
- package/assets/js/DataTables/DataTables/js/dataTables.min.js +2 -2
- package/assets/js/DataTables/Extensions/Buttons/js/buttons.html5.js +20 -13
- package/assets/js/DataTables/Extensions/Buttons/js/buttons.html5.min.js +1 -1
- package/assets/js/DataTables/Extensions/Buttons/js/dataTables.buttons.js +2 -2
- package/assets/js/DataTables/Extensions/Buttons/js/dataTables.buttons.min.js +2 -2
- package/assets/js/DataTables/Extensions/Responsive/js/dataTables.responsive.js +59 -51
- package/assets/js/DataTables/Extensions/Responsive/js/dataTables.responsive.min.js +2 -2
- package/assets/js/cdn.json +3 -3
- package/assets/js/pdfjs/build/pdf.mjs +586 -365
- package/assets/js/pdfjs/build/pdf.mjs.map +1 -1
- package/assets/js/pdfjs/build/pdf.sandbox.mjs +3 -3
- package/assets/js/pdfjs/build/pdf.sandbox.mjs.map +1 -1
- package/assets/js/pdfjs/build/pdf.worker.mjs +33 -56
- package/assets/js/pdfjs/build/pdf.worker.mjs.map +1 -1
- package/assets/js/pdfjs/web/images/altText_disclaimer.svg +3 -0
- package/assets/js/pdfjs/web/images/altText_spinner.svg +30 -0
- package/assets/js/pdfjs/web/images/altText_warning.svg +3 -0
- package/assets/js/pdfjs/web/images/messageBar_closingButton.svg +3 -0
- package/assets/js/pdfjs/web/images/messageBar_warning.svg +3 -0
- package/assets/js/pdfjs/web/locale/be/viewer.ftl +63 -8
- package/assets/js/pdfjs/web/locale/bg/viewer.ftl +25 -8
- package/assets/js/pdfjs/web/locale/cs/viewer.ftl +63 -8
- package/assets/js/pdfjs/web/locale/cy/viewer.ftl +57 -8
- package/assets/js/pdfjs/web/locale/da/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/de/viewer.ftl +59 -8
- package/assets/js/pdfjs/web/locale/dsb/viewer.ftl +57 -8
- package/assets/js/pdfjs/web/locale/el/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/en-CA/viewer.ftl +57 -8
- package/assets/js/pdfjs/web/locale/en-GB/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/en-US/viewer.ftl +97 -20
- package/assets/js/pdfjs/web/locale/eo/viewer.ftl +57 -2
- package/assets/js/pdfjs/web/locale/es-AR/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/es-CL/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/es-MX/viewer.ftl +34 -6
- package/assets/js/pdfjs/web/locale/fi/viewer.ftl +59 -8
- package/assets/js/pdfjs/web/locale/fr/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/fur/viewer.ftl +59 -8
- package/assets/js/pdfjs/web/locale/fy-NL/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/gn/viewer.ftl +53 -8
- package/assets/js/pdfjs/web/locale/he/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/hr/viewer.ftl +143 -4
- package/assets/js/pdfjs/web/locale/hsb/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/hu/viewer.ftl +71 -2
- package/assets/js/pdfjs/web/locale/ia/viewer.ftl +71 -0
- package/assets/js/pdfjs/web/locale/is/viewer.ftl +57 -0
- package/assets/js/pdfjs/web/locale/it/viewer.ftl +81 -5
- package/assets/js/pdfjs/web/locale/ja/viewer.ftl +60 -10
- package/assets/js/pdfjs/web/locale/kk/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/ko/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/nl/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/nn-NO/viewer.ftl +57 -2
- package/assets/js/pdfjs/web/locale/oc/viewer.ftl +13 -6
- package/assets/js/pdfjs/web/locale/pa-IN/viewer.ftl +59 -2
- package/assets/js/pdfjs/web/locale/pl/viewer.ftl +57 -8
- package/assets/js/pdfjs/web/locale/pt-BR/viewer.ftl +71 -2
- package/assets/js/pdfjs/web/locale/pt-PT/viewer.ftl +59 -8
- package/assets/js/pdfjs/web/locale/ru/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/sc/viewer.ftl +83 -6
- package/assets/js/pdfjs/web/locale/sk/viewer.ftl +59 -8
- package/assets/js/pdfjs/web/locale/skr/viewer.ftl +49 -2
- package/assets/js/pdfjs/web/locale/sl/viewer.ftl +71 -0
- package/assets/js/pdfjs/web/locale/sq/viewer.ftl +57 -2
- package/assets/js/pdfjs/web/locale/sv-SE/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/tg/viewer.ftl +8 -2
- package/assets/js/pdfjs/web/locale/th/viewer.ftl +57 -8
- package/assets/js/pdfjs/web/locale/tr/viewer.ftl +71 -2
- package/assets/js/pdfjs/web/locale/uk/viewer.ftl +33 -2
- package/assets/js/pdfjs/web/locale/vi/viewer.ftl +71 -8
- package/assets/js/pdfjs/web/locale/zh-CN/viewer.ftl +71 -2
- package/assets/js/pdfjs/web/locale/zh-TW/viewer.ftl +71 -0
- package/assets/js/pdfjs/web/viewer.css +1250 -790
- package/assets/js/pdfjs/web/viewer.html +141 -47
- package/assets/js/pdfjs/web/viewer.mjs +1187 -563
- package/assets/js/pdfjs/web/viewer.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -658,16 +658,20 @@ const defaultOptions = {
|
|
|
658
658
|
value: false,
|
|
659
659
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
|
660
660
|
},
|
|
661
|
+
enableAltTextModelDownload: {
|
|
662
|
+
value: true,
|
|
663
|
+
kind: OptionKind.VIEWER + OptionKind.PREFERENCE + OptionKind.EVENT_DISPATCH
|
|
664
|
+
},
|
|
661
665
|
enableGuessAltText: {
|
|
662
666
|
value: true,
|
|
663
|
-
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
|
667
|
+
kind: OptionKind.VIEWER + OptionKind.PREFERENCE + OptionKind.EVENT_DISPATCH
|
|
664
668
|
},
|
|
665
|
-
|
|
669
|
+
enableHighlightFloatingButton: {
|
|
666
670
|
value: false,
|
|
667
671
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
|
668
672
|
},
|
|
669
|
-
|
|
670
|
-
value:
|
|
673
|
+
enableNewAltTextWhenAddingImage: {
|
|
674
|
+
value: true,
|
|
671
675
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
|
672
676
|
},
|
|
673
677
|
enablePermissions: {
|
|
@@ -845,6 +849,10 @@ const defaultOptions = {
|
|
|
845
849
|
value: 0,
|
|
846
850
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
|
847
851
|
};
|
|
852
|
+
defaultOptions.enableFakeMLManager = {
|
|
853
|
+
value: true,
|
|
854
|
+
kind: OptionKind.VIEWER
|
|
855
|
+
};
|
|
848
856
|
}
|
|
849
857
|
{
|
|
850
858
|
defaultOptions.disablePreferences = {
|
|
@@ -852,19 +860,29 @@ const defaultOptions = {
|
|
|
852
860
|
kind: OptionKind.VIEWER
|
|
853
861
|
};
|
|
854
862
|
}
|
|
855
|
-
const userOptions = new Map();
|
|
856
|
-
{
|
|
857
|
-
for (const [name, value] of compatParams) {
|
|
858
|
-
userOptions.set(name, value);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
863
|
class AppOptions {
|
|
862
864
|
static eventBus;
|
|
863
|
-
|
|
864
|
-
|
|
865
|
+
static #opts = new Map();
|
|
866
|
+
static {
|
|
867
|
+
for (const name in defaultOptions) {
|
|
868
|
+
this.#opts.set(name, defaultOptions[name].value);
|
|
869
|
+
}
|
|
870
|
+
for (const [name, value] of compatParams) {
|
|
871
|
+
this.#opts.set(name, value);
|
|
872
|
+
}
|
|
873
|
+
this._hasInvokedSet = false;
|
|
874
|
+
this._checkDisablePreferences = () => {
|
|
875
|
+
if (this.get("disablePreferences")) {
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
if (this._hasInvokedSet) {
|
|
879
|
+
console.warn("The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option to prevent that.');
|
|
880
|
+
}
|
|
881
|
+
return false;
|
|
882
|
+
};
|
|
865
883
|
}
|
|
866
884
|
static get(name) {
|
|
867
|
-
return
|
|
885
|
+
return this.#opts.get(name);
|
|
868
886
|
}
|
|
869
887
|
static getAll(kind = null, defaultOnly = false) {
|
|
870
888
|
const options = Object.create(null);
|
|
@@ -873,7 +891,7 @@ class AppOptions {
|
|
|
873
891
|
if (kind && !(kind & defaultOpt.kind)) {
|
|
874
892
|
continue;
|
|
875
893
|
}
|
|
876
|
-
options[name] = !defaultOnly
|
|
894
|
+
options[name] = !defaultOnly ? this.#opts.get(name) : defaultOpt.value;
|
|
877
895
|
}
|
|
878
896
|
return options;
|
|
879
897
|
}
|
|
@@ -883,6 +901,7 @@ class AppOptions {
|
|
|
883
901
|
});
|
|
884
902
|
}
|
|
885
903
|
static setAll(options, prefs = false) {
|
|
904
|
+
this._hasInvokedSet ||= true;
|
|
886
905
|
let events;
|
|
887
906
|
for (const name in options) {
|
|
888
907
|
const defaultOpt = defaultOptions[name],
|
|
@@ -899,7 +918,7 @@ class AppOptions {
|
|
|
899
918
|
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
|
|
900
919
|
(events ||= new Map()).set(name, userOpt);
|
|
901
920
|
}
|
|
902
|
-
|
|
921
|
+
this.#opts.set(name, userOpt);
|
|
903
922
|
}
|
|
904
923
|
if (events) {
|
|
905
924
|
for (const [name, value] of events) {
|
|
@@ -911,21 +930,6 @@ class AppOptions {
|
|
|
911
930
|
}
|
|
912
931
|
}
|
|
913
932
|
}
|
|
914
|
-
{
|
|
915
|
-
AppOptions._checkDisablePreferences = () => {
|
|
916
|
-
if (AppOptions.get("disablePreferences")) {
|
|
917
|
-
return true;
|
|
918
|
-
}
|
|
919
|
-
for (const [name] of userOptions) {
|
|
920
|
-
if (compatParams.has(name)) {
|
|
921
|
-
continue;
|
|
922
|
-
}
|
|
923
|
-
console.warn("The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option to prevent that.');
|
|
924
|
-
break;
|
|
925
|
-
}
|
|
926
|
-
return false;
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
933
|
|
|
930
934
|
;// CONCATENATED MODULE: ./web/pdf_link_service.js
|
|
931
935
|
|
|
@@ -1443,11 +1447,6 @@ class FirefoxEventBus extends EventBus {
|
|
|
1443
1447
|
|
|
1444
1448
|
;// CONCATENATED MODULE: ./web/external_services.js
|
|
1445
1449
|
class BaseExternalServices {
|
|
1446
|
-
constructor() {
|
|
1447
|
-
if (this.constructor === BaseExternalServices) {
|
|
1448
|
-
throw new Error("Cannot initialize BaseExternalServices.");
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
1450
|
updateFindControlState(data) {}
|
|
1452
1451
|
updateFindMatchesCount(data) {}
|
|
1453
1452
|
initPassiveLoading() {}
|
|
@@ -1476,9 +1475,10 @@ class BasePreferences {
|
|
|
1476
1475
|
defaultZoomValue: "",
|
|
1477
1476
|
disablePageLabels: false,
|
|
1478
1477
|
enableAltText: false,
|
|
1478
|
+
enableAltTextModelDownload: true,
|
|
1479
1479
|
enableGuessAltText: true,
|
|
1480
|
-
enableHighlightEditor: false,
|
|
1481
1480
|
enableHighlightFloatingButton: false,
|
|
1481
|
+
enableNewAltTextWhenAddingImage: true,
|
|
1482
1482
|
enablePermissions: false,
|
|
1483
1483
|
enablePrintAutoRotate: true,
|
|
1484
1484
|
enableScripting: true,
|
|
@@ -1506,9 +1506,6 @@ class BasePreferences {
|
|
|
1506
1506
|
});
|
|
1507
1507
|
#initializedPromise = null;
|
|
1508
1508
|
constructor() {
|
|
1509
|
-
if (this.constructor === BasePreferences) {
|
|
1510
|
-
throw new Error("Cannot initialize BasePreferences.");
|
|
1511
|
-
}
|
|
1512
1509
|
this.#initializedPromise = this._readFromStorage(this.#defaults).then(({
|
|
1513
1510
|
browserPrefs,
|
|
1514
1511
|
prefs
|
|
@@ -2908,7 +2905,7 @@ class L10n {
|
|
|
2908
2905
|
id: ids,
|
|
2909
2906
|
args
|
|
2910
2907
|
}]);
|
|
2911
|
-
return messages
|
|
2908
|
+
return messages[0]?.value || fallback;
|
|
2912
2909
|
}
|
|
2913
2910
|
async translate(element) {
|
|
2914
2911
|
this.#elements.add(element);
|
|
@@ -2917,6 +2914,13 @@ class L10n {
|
|
|
2917
2914
|
await this.#l10n.translateRoots();
|
|
2918
2915
|
} catch {}
|
|
2919
2916
|
}
|
|
2917
|
+
async translateOnce(element) {
|
|
2918
|
+
try {
|
|
2919
|
+
await this.#l10n.translateElements([element]);
|
|
2920
|
+
} catch (ex) {
|
|
2921
|
+
console.error(`translateOnce: "${ex}".`);
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2920
2924
|
async destroy() {
|
|
2921
2925
|
for (const element of this.#elements) {
|
|
2922
2926
|
this.#l10n.disconnectRoot(element);
|
|
@@ -3030,7 +3034,7 @@ class genericl10n_GenericL10n extends L10n {
|
|
|
3030
3034
|
yield this.#createBundleFallback(lang);
|
|
3031
3035
|
}
|
|
3032
3036
|
static async #createBundleFallback(lang) {
|
|
3033
|
-
const text = "pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties\u2026\npdfjs-document-properties-button-label = Document Properties\u2026\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-kb = { $size_kb } KB ({ $size_b } bytes)\npdfjs-document-properties-mb = { $size_mb } MB ({ $size_b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-string = { $date }, { $time }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } \xD7 { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } \xD7 { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing\u2026\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document\u2026\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-string = { $date }, { $time }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text =\n .aria-label = Text Editor\npdfjs-free-text-default-content = Start typing\u2026\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can\u2019t see the image or when it doesn\u2019t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, \u201CA young man sits down at a table to eat a meal\u201D\npdfjs-editor-resizer-label-top-left = Top left corner \u2014 resize\npdfjs-editor-resizer-label-top-middle = Top middle \u2014 resize\npdfjs-editor-resizer-label-top-right = Top right corner \u2014 resize\npdfjs-editor-resizer-label-middle-right = Middle right \u2014 resize\npdfjs-editor-resizer-label-bottom-right = Bottom right corner \u2014 resize\npdfjs-editor-resizer-label-bottom-middle = Bottom middle \u2014 resize\npdfjs-editor-resizer-label-bottom-left = Bottom left corner \u2014 resize\npdfjs-editor-resizer-label-middle-left = Middle left \u2014 resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all";
|
|
3037
|
+
const text = "pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties\u2026\npdfjs-document-properties-button-label = Document Properties\u2026\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: \"short\", timeStyle: \"medium\") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } \xD7 { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } \xD7 { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing\u2026\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document\u2026\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: \"short\", timeStyle: \"medium\") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text =\n .aria-label = Text Editor\npdfjs-free-text-default-content = Start typing\u2026\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can\u2019t see the image or when it doesn\u2019t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, \u201CA young man sits down at a table to eat a meal\u201D\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner \u2014 resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle \u2014 resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner \u2014 resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right \u2014 resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner \u2014 resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle \u2014 resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner \u2014 resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left \u2014 resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here\u2026\npdfjs-editor-new-alt-text-description = Short description for people who can\u2019t see the image or when the image doesn\u2019t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn\u2019t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can\u2019t see the image or when the image doesn\u2019t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading\u2026\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close";
|
|
3034
3038
|
return createBundle(lang, text);
|
|
3035
3039
|
}
|
|
3036
3040
|
}
|
|
@@ -3118,9 +3122,625 @@ class MLManager {
|
|
|
3118
3122
|
async deleteModel(_service) {
|
|
3119
3123
|
return null;
|
|
3120
3124
|
}
|
|
3121
|
-
|
|
3125
|
+
isReady(_name) {
|
|
3126
|
+
return false;
|
|
3127
|
+
}
|
|
3128
|
+
guess(_data) {}
|
|
3129
|
+
toggleService(_name, _enabled) {}
|
|
3130
|
+
static getFakeMLManager(options) {
|
|
3131
|
+
return new FakeMLManager(options);
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
class FakeMLManager {
|
|
3135
|
+
eventBus = null;
|
|
3136
|
+
hasProgress = false;
|
|
3137
|
+
constructor({
|
|
3138
|
+
enableGuessAltText,
|
|
3139
|
+
enableAltTextModelDownload
|
|
3140
|
+
}) {
|
|
3141
|
+
this.enableGuessAltText = enableGuessAltText;
|
|
3142
|
+
this.enableAltTextModelDownload = enableAltTextModelDownload;
|
|
3143
|
+
}
|
|
3144
|
+
setEventBus(eventBus, abortSignal) {
|
|
3145
|
+
this.eventBus = eventBus;
|
|
3146
|
+
}
|
|
3147
|
+
async isEnabledFor(_name) {
|
|
3148
|
+
return this.enableGuessAltText;
|
|
3149
|
+
}
|
|
3150
|
+
async deleteModel(_name) {
|
|
3151
|
+
this.enableAltTextModelDownload = false;
|
|
3122
3152
|
return null;
|
|
3123
3153
|
}
|
|
3154
|
+
async loadModel(_name) {}
|
|
3155
|
+
async downloadModel(_name) {
|
|
3156
|
+
this.hasProgress = true;
|
|
3157
|
+
const {
|
|
3158
|
+
promise,
|
|
3159
|
+
resolve
|
|
3160
|
+
} = Promise.withResolvers();
|
|
3161
|
+
const total = 1e8;
|
|
3162
|
+
const end = 1.5 * total;
|
|
3163
|
+
const increment = 5e6;
|
|
3164
|
+
let loaded = 0;
|
|
3165
|
+
const id = setInterval(() => {
|
|
3166
|
+
loaded += increment;
|
|
3167
|
+
if (loaded <= end) {
|
|
3168
|
+
this.eventBus.dispatch("loadaiengineprogress", {
|
|
3169
|
+
source: this,
|
|
3170
|
+
detail: {
|
|
3171
|
+
total,
|
|
3172
|
+
totalLoaded: loaded,
|
|
3173
|
+
finished: loaded + increment >= end
|
|
3174
|
+
}
|
|
3175
|
+
});
|
|
3176
|
+
return;
|
|
3177
|
+
}
|
|
3178
|
+
clearInterval(id);
|
|
3179
|
+
this.hasProgress = false;
|
|
3180
|
+
this.enableAltTextModelDownload = true;
|
|
3181
|
+
resolve(true);
|
|
3182
|
+
}, 900);
|
|
3183
|
+
return promise;
|
|
3184
|
+
}
|
|
3185
|
+
isReady(_name) {
|
|
3186
|
+
return this.enableAltTextModelDownload;
|
|
3187
|
+
}
|
|
3188
|
+
guess({
|
|
3189
|
+
request: {
|
|
3190
|
+
data
|
|
3191
|
+
}
|
|
3192
|
+
}) {
|
|
3193
|
+
return new Promise(resolve => {
|
|
3194
|
+
setTimeout(() => {
|
|
3195
|
+
resolve(data ? {
|
|
3196
|
+
output: "Fake alt text"
|
|
3197
|
+
} : {
|
|
3198
|
+
error: true
|
|
3199
|
+
});
|
|
3200
|
+
}, 3000);
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3203
|
+
toggleService(_name, enabled) {
|
|
3204
|
+
this.enableGuessAltText = enabled;
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
;// CONCATENATED MODULE: ./web/new_alt_text_manager.js
|
|
3209
|
+
|
|
3210
|
+
class NewAltTextManager {
|
|
3211
|
+
#boundCancel = this.#cancel.bind(this);
|
|
3212
|
+
#createAutomaticallyButton;
|
|
3213
|
+
#currentEditor = null;
|
|
3214
|
+
#cancelButton;
|
|
3215
|
+
#descriptionContainer;
|
|
3216
|
+
#dialog;
|
|
3217
|
+
#disclaimer;
|
|
3218
|
+
#downloadModel;
|
|
3219
|
+
#downloadModelDescription;
|
|
3220
|
+
#eventBus;
|
|
3221
|
+
#firstTime = false;
|
|
3222
|
+
#guessedAltText;
|
|
3223
|
+
#isEditing = null;
|
|
3224
|
+
#imagePreview;
|
|
3225
|
+
#imageData;
|
|
3226
|
+
#isAILoading = false;
|
|
3227
|
+
#wasAILoading = false;
|
|
3228
|
+
#learnMore;
|
|
3229
|
+
#notNowButton;
|
|
3230
|
+
#overlayManager;
|
|
3231
|
+
#textarea;
|
|
3232
|
+
#title;
|
|
3233
|
+
#uiManager;
|
|
3234
|
+
#previousAltText = null;
|
|
3235
|
+
constructor({
|
|
3236
|
+
descriptionContainer,
|
|
3237
|
+
dialog,
|
|
3238
|
+
imagePreview,
|
|
3239
|
+
cancelButton,
|
|
3240
|
+
disclaimer,
|
|
3241
|
+
notNowButton,
|
|
3242
|
+
saveButton,
|
|
3243
|
+
textarea,
|
|
3244
|
+
learnMore,
|
|
3245
|
+
errorCloseButton,
|
|
3246
|
+
createAutomaticallyButton,
|
|
3247
|
+
downloadModel,
|
|
3248
|
+
downloadModelDescription,
|
|
3249
|
+
title
|
|
3250
|
+
}, overlayManager, eventBus) {
|
|
3251
|
+
this.#cancelButton = cancelButton;
|
|
3252
|
+
this.#createAutomaticallyButton = createAutomaticallyButton;
|
|
3253
|
+
this.#descriptionContainer = descriptionContainer;
|
|
3254
|
+
this.#dialog = dialog;
|
|
3255
|
+
this.#disclaimer = disclaimer;
|
|
3256
|
+
this.#notNowButton = notNowButton;
|
|
3257
|
+
this.#imagePreview = imagePreview;
|
|
3258
|
+
this.#textarea = textarea;
|
|
3259
|
+
this.#learnMore = learnMore;
|
|
3260
|
+
this.#title = title;
|
|
3261
|
+
this.#downloadModel = downloadModel;
|
|
3262
|
+
this.#downloadModelDescription = downloadModelDescription;
|
|
3263
|
+
this.#overlayManager = overlayManager;
|
|
3264
|
+
this.#eventBus = eventBus;
|
|
3265
|
+
dialog.addEventListener("close", this.#close.bind(this));
|
|
3266
|
+
dialog.addEventListener("contextmenu", event => {
|
|
3267
|
+
if (event.target !== this.#textarea) {
|
|
3268
|
+
event.preventDefault();
|
|
3269
|
+
}
|
|
3270
|
+
});
|
|
3271
|
+
cancelButton.addEventListener("click", this.#boundCancel);
|
|
3272
|
+
notNowButton.addEventListener("click", this.#boundCancel);
|
|
3273
|
+
saveButton.addEventListener("click", this.#save.bind(this));
|
|
3274
|
+
errorCloseButton.addEventListener("click", () => {
|
|
3275
|
+
this.#toggleError(false);
|
|
3276
|
+
});
|
|
3277
|
+
createAutomaticallyButton.addEventListener("click", async () => {
|
|
3278
|
+
const checked = createAutomaticallyButton.getAttribute("aria-pressed") !== "true";
|
|
3279
|
+
this.#currentEditor._reportTelemetry({
|
|
3280
|
+
action: "pdfjs.image.alt_text.ai_generation_check",
|
|
3281
|
+
data: {
|
|
3282
|
+
status: checked
|
|
3283
|
+
}
|
|
3284
|
+
});
|
|
3285
|
+
if (this.#uiManager) {
|
|
3286
|
+
this.#uiManager.setPreference("enableGuessAltText", checked);
|
|
3287
|
+
await this.#uiManager.mlManager.toggleService("altText", checked);
|
|
3288
|
+
}
|
|
3289
|
+
this.#toggleGuessAltText(checked, false);
|
|
3290
|
+
});
|
|
3291
|
+
textarea.addEventListener("focus", () => {
|
|
3292
|
+
this.#wasAILoading = this.#isAILoading;
|
|
3293
|
+
this.#toggleLoading(false);
|
|
3294
|
+
});
|
|
3295
|
+
textarea.addEventListener("blur", () => {
|
|
3296
|
+
if (textarea.value) {
|
|
3297
|
+
return;
|
|
3298
|
+
}
|
|
3299
|
+
this.#toggleLoading(this.#wasAILoading);
|
|
3300
|
+
});
|
|
3301
|
+
textarea.addEventListener("input", () => {
|
|
3302
|
+
this.#toggleTitle();
|
|
3303
|
+
this.#toggleDisclaimer();
|
|
3304
|
+
});
|
|
3305
|
+
eventBus._on("enableguessalttext", ({
|
|
3306
|
+
value
|
|
3307
|
+
}) => {
|
|
3308
|
+
this.#toggleGuessAltText(value, false);
|
|
3309
|
+
});
|
|
3310
|
+
this.#overlayManager.register(dialog);
|
|
3311
|
+
this.#learnMore.addEventListener("click", () => {
|
|
3312
|
+
this.#currentEditor._reportTelemetry({
|
|
3313
|
+
action: "pdfjs.image.alt_text.info",
|
|
3314
|
+
data: {
|
|
3315
|
+
topic: "alt_text"
|
|
3316
|
+
}
|
|
3317
|
+
});
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
#toggleLoading(value) {
|
|
3321
|
+
if (!this.#uiManager || this.#isAILoading === value) {
|
|
3322
|
+
return;
|
|
3323
|
+
}
|
|
3324
|
+
this.#isAILoading = value;
|
|
3325
|
+
this.#descriptionContainer.classList.toggle("loading", value);
|
|
3326
|
+
}
|
|
3327
|
+
#toggleError(value) {
|
|
3328
|
+
if (!this.#uiManager) {
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
this.#dialog.classList.toggle("error", value);
|
|
3332
|
+
}
|
|
3333
|
+
#toggleTitle() {
|
|
3334
|
+
const isEditing = this.#isAILoading || !!this.#textarea.value;
|
|
3335
|
+
if (this.#isEditing === isEditing) {
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3338
|
+
this.#isEditing = isEditing;
|
|
3339
|
+
this.#title.setAttribute("data-l10n-id", isEditing ? "pdfjs-editor-new-alt-text-dialog-edit-label" : "pdfjs-editor-new-alt-text-dialog-add-label");
|
|
3340
|
+
}
|
|
3341
|
+
async #toggleGuessAltText(value, isInitial = false) {
|
|
3342
|
+
if (!this.#uiManager) {
|
|
3343
|
+
return;
|
|
3344
|
+
}
|
|
3345
|
+
this.#dialog.classList.toggle("aiDisabled", !value);
|
|
3346
|
+
this.#createAutomaticallyButton.setAttribute("aria-pressed", value);
|
|
3347
|
+
if (value) {
|
|
3348
|
+
const {
|
|
3349
|
+
altTextLearnMoreUrl
|
|
3350
|
+
} = this.#uiManager.mlManager;
|
|
3351
|
+
if (altTextLearnMoreUrl) {
|
|
3352
|
+
this.#learnMore.href = altTextLearnMoreUrl;
|
|
3353
|
+
}
|
|
3354
|
+
this.#mlGuessAltText(isInitial);
|
|
3355
|
+
} else {
|
|
3356
|
+
this.#toggleLoading(false);
|
|
3357
|
+
this.#isAILoading = false;
|
|
3358
|
+
this.#toggleTitle();
|
|
3359
|
+
this.#toggleDisclaimer();
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
#toggleNotNow() {
|
|
3363
|
+
this.#notNowButton.classList.toggle("hidden", !this.#firstTime);
|
|
3364
|
+
this.#cancelButton.classList.toggle("hidden", this.#firstTime);
|
|
3365
|
+
}
|
|
3366
|
+
#toggleAI(value) {
|
|
3367
|
+
this.#dialog.classList.toggle("noAi", !value);
|
|
3368
|
+
this.#toggleTitle();
|
|
3369
|
+
}
|
|
3370
|
+
#toggleDisclaimer(value = null) {
|
|
3371
|
+
if (!this.#uiManager) {
|
|
3372
|
+
return;
|
|
3373
|
+
}
|
|
3374
|
+
const hidden = value === null ? !this.#guessedAltText || this.#guessedAltText !== this.#textarea.value : !value;
|
|
3375
|
+
this.#disclaimer.classList.toggle("hidden", hidden);
|
|
3376
|
+
}
|
|
3377
|
+
async #mlGuessAltText(isInitial) {
|
|
3378
|
+
if (this.#isAILoading) {
|
|
3379
|
+
return;
|
|
3380
|
+
}
|
|
3381
|
+
if (this.#textarea.value) {
|
|
3382
|
+
return;
|
|
3383
|
+
}
|
|
3384
|
+
if (isInitial && this.#previousAltText !== null) {
|
|
3385
|
+
return;
|
|
3386
|
+
}
|
|
3387
|
+
this.#guessedAltText = this.#currentEditor.guessedAltText;
|
|
3388
|
+
if (this.#previousAltText === null && this.#guessedAltText) {
|
|
3389
|
+
this.#addAltText(this.#guessedAltText);
|
|
3390
|
+
this.#toggleDisclaimer();
|
|
3391
|
+
this.#toggleTitle();
|
|
3392
|
+
return;
|
|
3393
|
+
}
|
|
3394
|
+
this.#toggleLoading(true);
|
|
3395
|
+
this.#toggleTitle();
|
|
3396
|
+
this.#toggleDisclaimer(true);
|
|
3397
|
+
let hasError = false;
|
|
3398
|
+
try {
|
|
3399
|
+
const altText = await this.#currentEditor.mlGuessAltText(this.#imageData, false);
|
|
3400
|
+
if (altText) {
|
|
3401
|
+
this.#guessedAltText = altText;
|
|
3402
|
+
this.#wasAILoading = this.#isAILoading;
|
|
3403
|
+
if (this.#isAILoading) {
|
|
3404
|
+
this.#addAltText(altText);
|
|
3405
|
+
}
|
|
3406
|
+
}
|
|
3407
|
+
} catch (e) {
|
|
3408
|
+
console.error(e);
|
|
3409
|
+
hasError = true;
|
|
3410
|
+
}
|
|
3411
|
+
this.#toggleLoading(false);
|
|
3412
|
+
if (hasError && this.#uiManager) {
|
|
3413
|
+
this.#toggleError(true);
|
|
3414
|
+
this.#toggleTitle();
|
|
3415
|
+
this.#toggleDisclaimer();
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
#addAltText(altText) {
|
|
3419
|
+
if (!this.#uiManager || this.#textarea.value) {
|
|
3420
|
+
return;
|
|
3421
|
+
}
|
|
3422
|
+
this.#textarea.value = altText;
|
|
3423
|
+
}
|
|
3424
|
+
#setProgress() {
|
|
3425
|
+
this.#downloadModel.classList.toggle("hidden", false);
|
|
3426
|
+
const callback = async ({
|
|
3427
|
+
detail: {
|
|
3428
|
+
finished,
|
|
3429
|
+
total,
|
|
3430
|
+
totalLoaded
|
|
3431
|
+
}
|
|
3432
|
+
}) => {
|
|
3433
|
+
const ONE_MEGA_BYTES = 1e6;
|
|
3434
|
+
totalLoaded = Math.min(0.99 * total, totalLoaded);
|
|
3435
|
+
const totalSize = this.#downloadModelDescription.ariaValueMax = Math.round(total / ONE_MEGA_BYTES);
|
|
3436
|
+
const downloadedSize = this.#downloadModelDescription.ariaValueNow = Math.round(totalLoaded / ONE_MEGA_BYTES);
|
|
3437
|
+
this.#downloadModelDescription.setAttribute("data-l10n-args", JSON.stringify({
|
|
3438
|
+
totalSize,
|
|
3439
|
+
downloadedSize
|
|
3440
|
+
}));
|
|
3441
|
+
if (!finished) {
|
|
3442
|
+
return;
|
|
3443
|
+
}
|
|
3444
|
+
this.#eventBus._off("loadaiengineprogress", callback);
|
|
3445
|
+
this.#downloadModel.classList.toggle("hidden", true);
|
|
3446
|
+
this.#toggleAI(true);
|
|
3447
|
+
if (!this.#uiManager) {
|
|
3448
|
+
return;
|
|
3449
|
+
}
|
|
3450
|
+
const {
|
|
3451
|
+
mlManager
|
|
3452
|
+
} = this.#uiManager;
|
|
3453
|
+
mlManager.toggleService("altText", true);
|
|
3454
|
+
this.#toggleGuessAltText(await mlManager.isEnabledFor("altText"), true);
|
|
3455
|
+
};
|
|
3456
|
+
this.#eventBus._on("loadaiengineprogress", callback);
|
|
3457
|
+
}
|
|
3458
|
+
async editAltText(uiManager, editor, firstTime) {
|
|
3459
|
+
if (this.#currentEditor || !editor) {
|
|
3460
|
+
return;
|
|
3461
|
+
}
|
|
3462
|
+
if (firstTime && editor.hasAltTextData()) {
|
|
3463
|
+
editor.altTextFinish();
|
|
3464
|
+
return;
|
|
3465
|
+
}
|
|
3466
|
+
this.#firstTime = firstTime;
|
|
3467
|
+
let {
|
|
3468
|
+
mlManager
|
|
3469
|
+
} = uiManager;
|
|
3470
|
+
let hasAI = !!mlManager;
|
|
3471
|
+
if (mlManager && !mlManager.isReady("altText")) {
|
|
3472
|
+
hasAI = false;
|
|
3473
|
+
if (mlManager.hasProgress) {
|
|
3474
|
+
this.#setProgress();
|
|
3475
|
+
} else {
|
|
3476
|
+
mlManager = null;
|
|
3477
|
+
}
|
|
3478
|
+
} else {
|
|
3479
|
+
this.#downloadModel.classList.toggle("hidden", true);
|
|
3480
|
+
}
|
|
3481
|
+
const isAltTextEnabledPromise = mlManager?.isEnabledFor("altText");
|
|
3482
|
+
this.#currentEditor = editor;
|
|
3483
|
+
this.#uiManager = uiManager;
|
|
3484
|
+
this.#uiManager.removeEditListeners();
|
|
3485
|
+
({
|
|
3486
|
+
altText: this.#previousAltText
|
|
3487
|
+
} = editor.altTextData);
|
|
3488
|
+
this.#textarea.value = this.#previousAltText ?? "";
|
|
3489
|
+
const AI_MAX_IMAGE_DIMENSION = 224;
|
|
3490
|
+
let canvas;
|
|
3491
|
+
if (mlManager) {
|
|
3492
|
+
({
|
|
3493
|
+
canvas,
|
|
3494
|
+
imageData: this.#imageData
|
|
3495
|
+
} = editor.copyCanvas(AI_MAX_IMAGE_DIMENSION, true));
|
|
3496
|
+
if (hasAI) {
|
|
3497
|
+
this.#toggleGuessAltText(await isAltTextEnabledPromise, true);
|
|
3498
|
+
}
|
|
3499
|
+
} else {
|
|
3500
|
+
({
|
|
3501
|
+
canvas
|
|
3502
|
+
} = editor.copyCanvas(AI_MAX_IMAGE_DIMENSION, false));
|
|
3503
|
+
}
|
|
3504
|
+
canvas.setAttribute("role", "presentation");
|
|
3505
|
+
this.#imagePreview.append(canvas);
|
|
3506
|
+
this.#toggleNotNow();
|
|
3507
|
+
this.#toggleAI(hasAI);
|
|
3508
|
+
this.#toggleError(false);
|
|
3509
|
+
try {
|
|
3510
|
+
await this.#overlayManager.open(this.#dialog);
|
|
3511
|
+
} catch (ex) {
|
|
3512
|
+
this.#close();
|
|
3513
|
+
throw ex;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
#cancel() {
|
|
3517
|
+
this.#currentEditor.altTextData = {
|
|
3518
|
+
cancel: true
|
|
3519
|
+
};
|
|
3520
|
+
const altText = this.#textarea.value.trim();
|
|
3521
|
+
this.#currentEditor._reportTelemetry({
|
|
3522
|
+
action: "pdfjs.image.alt_text.dismiss",
|
|
3523
|
+
data: {
|
|
3524
|
+
alt_text_type: altText ? "present" : "empty",
|
|
3525
|
+
flow: this.#firstTime ? "image_add" : "alt_text_edit"
|
|
3526
|
+
}
|
|
3527
|
+
});
|
|
3528
|
+
this.#currentEditor._reportTelemetry({
|
|
3529
|
+
action: "pdfjs.image.image_added",
|
|
3530
|
+
data: {
|
|
3531
|
+
alt_text_modal: true,
|
|
3532
|
+
alt_text_type: "skipped"
|
|
3533
|
+
}
|
|
3534
|
+
});
|
|
3535
|
+
this.#finish();
|
|
3536
|
+
}
|
|
3537
|
+
#finish() {
|
|
3538
|
+
if (this.#overlayManager.active === this.#dialog) {
|
|
3539
|
+
this.#overlayManager.close(this.#dialog);
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
#close() {
|
|
3543
|
+
const canvas = this.#imagePreview.firstChild;
|
|
3544
|
+
canvas.remove();
|
|
3545
|
+
canvas.width = canvas.height = 0;
|
|
3546
|
+
this.#imageData = null;
|
|
3547
|
+
this.#toggleLoading(false);
|
|
3548
|
+
this.#uiManager?.addEditListeners();
|
|
3549
|
+
this.#currentEditor.altTextFinish();
|
|
3550
|
+
this.#uiManager?.setSelected(this.#currentEditor);
|
|
3551
|
+
this.#currentEditor = null;
|
|
3552
|
+
this.#uiManager = null;
|
|
3553
|
+
}
|
|
3554
|
+
#save() {
|
|
3555
|
+
const altText = this.#textarea.value.trim();
|
|
3556
|
+
this.#currentEditor.altTextData = {
|
|
3557
|
+
altText,
|
|
3558
|
+
decorative: false
|
|
3559
|
+
};
|
|
3560
|
+
this.#currentEditor.altTextData.guessedAltText = this.#guessedAltText;
|
|
3561
|
+
if (this.#guessedAltText && this.#guessedAltText !== altText) {
|
|
3562
|
+
const guessedWords = new Set(this.#guessedAltText.split(/\s+/));
|
|
3563
|
+
const words = new Set(altText.split(/\s+/));
|
|
3564
|
+
this.#currentEditor._reportTelemetry({
|
|
3565
|
+
action: "pdfjs.image.alt_text.user_edit",
|
|
3566
|
+
data: {
|
|
3567
|
+
total_words: guessedWords.size,
|
|
3568
|
+
words_removed: guessedWords.difference(words).size,
|
|
3569
|
+
words_added: words.difference(guessedWords).size
|
|
3570
|
+
}
|
|
3571
|
+
});
|
|
3572
|
+
}
|
|
3573
|
+
this.#currentEditor._reportTelemetry({
|
|
3574
|
+
action: "pdfjs.image.image_added",
|
|
3575
|
+
data: {
|
|
3576
|
+
alt_text_modal: true,
|
|
3577
|
+
alt_text_type: altText ? "present" : "empty"
|
|
3578
|
+
}
|
|
3579
|
+
});
|
|
3580
|
+
this.#currentEditor._reportTelemetry({
|
|
3581
|
+
action: "pdfjs.image.alt_text.save",
|
|
3582
|
+
data: {
|
|
3583
|
+
alt_text_type: altText ? "present" : "empty",
|
|
3584
|
+
flow: this.#firstTime ? "image_add" : "alt_text_edit"
|
|
3585
|
+
}
|
|
3586
|
+
});
|
|
3587
|
+
this.#finish();
|
|
3588
|
+
}
|
|
3589
|
+
destroy() {
|
|
3590
|
+
this.#uiManager = null;
|
|
3591
|
+
this.#finish();
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
class ImageAltTextSettings {
|
|
3595
|
+
#aiModelSettings;
|
|
3596
|
+
#createModelButton;
|
|
3597
|
+
#downloadModelButton;
|
|
3598
|
+
#dialog;
|
|
3599
|
+
#eventBus;
|
|
3600
|
+
#mlManager;
|
|
3601
|
+
#overlayManager;
|
|
3602
|
+
#showAltTextDialogButton;
|
|
3603
|
+
constructor({
|
|
3604
|
+
dialog,
|
|
3605
|
+
createModelButton,
|
|
3606
|
+
aiModelSettings,
|
|
3607
|
+
learnMore,
|
|
3608
|
+
closeButton,
|
|
3609
|
+
deleteModelButton,
|
|
3610
|
+
downloadModelButton,
|
|
3611
|
+
showAltTextDialogButton
|
|
3612
|
+
}, overlayManager, eventBus, mlManager) {
|
|
3613
|
+
this.#dialog = dialog;
|
|
3614
|
+
this.#aiModelSettings = aiModelSettings;
|
|
3615
|
+
this.#createModelButton = createModelButton;
|
|
3616
|
+
this.#downloadModelButton = downloadModelButton;
|
|
3617
|
+
this.#showAltTextDialogButton = showAltTextDialogButton;
|
|
3618
|
+
this.#overlayManager = overlayManager;
|
|
3619
|
+
this.#eventBus = eventBus;
|
|
3620
|
+
this.#mlManager = mlManager;
|
|
3621
|
+
const {
|
|
3622
|
+
altTextLearnMoreUrl
|
|
3623
|
+
} = mlManager;
|
|
3624
|
+
if (altTextLearnMoreUrl) {
|
|
3625
|
+
learnMore.href = altTextLearnMoreUrl;
|
|
3626
|
+
}
|
|
3627
|
+
dialog.addEventListener("contextmenu", noContextMenu);
|
|
3628
|
+
createModelButton.addEventListener("click", async e => {
|
|
3629
|
+
const checked = this.#togglePref("enableGuessAltText", e);
|
|
3630
|
+
await mlManager.toggleService("altText", checked);
|
|
3631
|
+
this.#reportTelemetry({
|
|
3632
|
+
type: "stamp",
|
|
3633
|
+
action: "pdfjs.image.alt_text.settings_ai_generation_check",
|
|
3634
|
+
data: {
|
|
3635
|
+
status: checked
|
|
3636
|
+
}
|
|
3637
|
+
});
|
|
3638
|
+
});
|
|
3639
|
+
showAltTextDialogButton.addEventListener("click", e => {
|
|
3640
|
+
const checked = this.#togglePref("enableNewAltTextWhenAddingImage", e);
|
|
3641
|
+
this.#reportTelemetry({
|
|
3642
|
+
type: "stamp",
|
|
3643
|
+
action: "pdfjs.image.alt_text.settings_edit_alt_text_check",
|
|
3644
|
+
data: {
|
|
3645
|
+
status: checked
|
|
3646
|
+
}
|
|
3647
|
+
});
|
|
3648
|
+
});
|
|
3649
|
+
deleteModelButton.addEventListener("click", this.#delete.bind(this, true));
|
|
3650
|
+
downloadModelButton.addEventListener("click", this.#download.bind(this, true));
|
|
3651
|
+
closeButton.addEventListener("click", this.#finish.bind(this));
|
|
3652
|
+
learnMore.addEventListener("click", () => {
|
|
3653
|
+
this.#reportTelemetry({
|
|
3654
|
+
type: "stamp",
|
|
3655
|
+
action: "pdfjs.image.alt_text.info",
|
|
3656
|
+
data: {
|
|
3657
|
+
topic: "ai_generation"
|
|
3658
|
+
}
|
|
3659
|
+
});
|
|
3660
|
+
});
|
|
3661
|
+
eventBus._on("enablealttextmodeldownload", ({
|
|
3662
|
+
value
|
|
3663
|
+
}) => {
|
|
3664
|
+
if (value) {
|
|
3665
|
+
this.#download(false);
|
|
3666
|
+
} else {
|
|
3667
|
+
this.#delete(false);
|
|
3668
|
+
}
|
|
3669
|
+
});
|
|
3670
|
+
this.#overlayManager.register(dialog);
|
|
3671
|
+
}
|
|
3672
|
+
#reportTelemetry(data) {
|
|
3673
|
+
this.#eventBus.dispatch("reporttelemetry", {
|
|
3674
|
+
source: this,
|
|
3675
|
+
details: {
|
|
3676
|
+
type: "editing",
|
|
3677
|
+
data
|
|
3678
|
+
}
|
|
3679
|
+
});
|
|
3680
|
+
}
|
|
3681
|
+
async #download(isFromUI = false) {
|
|
3682
|
+
if (isFromUI) {
|
|
3683
|
+
this.#downloadModelButton.disabled = true;
|
|
3684
|
+
const span = this.#downloadModelButton.firstChild;
|
|
3685
|
+
span.setAttribute("data-l10n-id", "pdfjs-editor-alt-text-settings-downloading-model-button");
|
|
3686
|
+
await this.#mlManager.downloadModel("altText");
|
|
3687
|
+
span.setAttribute("data-l10n-id", "pdfjs-editor-alt-text-settings-download-model-button");
|
|
3688
|
+
this.#createModelButton.disabled = false;
|
|
3689
|
+
this.#setPref("enableGuessAltText", true);
|
|
3690
|
+
this.#mlManager.toggleService("altText", true);
|
|
3691
|
+
this.#setPref("enableAltTextModelDownload", true);
|
|
3692
|
+
this.#downloadModelButton.disabled = false;
|
|
3693
|
+
}
|
|
3694
|
+
this.#aiModelSettings.classList.toggle("download", false);
|
|
3695
|
+
this.#createModelButton.setAttribute("aria-pressed", true);
|
|
3696
|
+
}
|
|
3697
|
+
async #delete(isFromUI = false) {
|
|
3698
|
+
if (isFromUI) {
|
|
3699
|
+
await this.#mlManager.deleteModel("altText");
|
|
3700
|
+
this.#setPref("enableGuessAltText", false);
|
|
3701
|
+
this.#setPref("enableAltTextModelDownload", false);
|
|
3702
|
+
}
|
|
3703
|
+
this.#aiModelSettings.classList.toggle("download", true);
|
|
3704
|
+
this.#createModelButton.disabled = true;
|
|
3705
|
+
this.#createModelButton.setAttribute("aria-pressed", false);
|
|
3706
|
+
}
|
|
3707
|
+
async open({
|
|
3708
|
+
enableGuessAltText,
|
|
3709
|
+
enableNewAltTextWhenAddingImage
|
|
3710
|
+
}) {
|
|
3711
|
+
const {
|
|
3712
|
+
enableAltTextModelDownload
|
|
3713
|
+
} = this.#mlManager;
|
|
3714
|
+
this.#createModelButton.disabled = !enableAltTextModelDownload;
|
|
3715
|
+
this.#createModelButton.setAttribute("aria-pressed", enableAltTextModelDownload && enableGuessAltText);
|
|
3716
|
+
this.#showAltTextDialogButton.setAttribute("aria-pressed", enableNewAltTextWhenAddingImage);
|
|
3717
|
+
this.#aiModelSettings.classList.toggle("download", !enableAltTextModelDownload);
|
|
3718
|
+
await this.#overlayManager.open(this.#dialog);
|
|
3719
|
+
this.#reportTelemetry({
|
|
3720
|
+
type: "stamp",
|
|
3721
|
+
action: "pdfjs.image.alt_text.settings_displayed"
|
|
3722
|
+
});
|
|
3723
|
+
}
|
|
3724
|
+
#togglePref(name, {
|
|
3725
|
+
target
|
|
3726
|
+
}) {
|
|
3727
|
+
const checked = target.getAttribute("aria-pressed") !== "true";
|
|
3728
|
+
this.#setPref(name, checked);
|
|
3729
|
+
target.setAttribute("aria-pressed", checked);
|
|
3730
|
+
return checked;
|
|
3731
|
+
}
|
|
3732
|
+
#setPref(name, value) {
|
|
3733
|
+
this.#eventBus.dispatch("setpreference", {
|
|
3734
|
+
source: this,
|
|
3735
|
+
name,
|
|
3736
|
+
value
|
|
3737
|
+
});
|
|
3738
|
+
}
|
|
3739
|
+
#finish() {
|
|
3740
|
+
if (this.#overlayManager.active === this.#dialog) {
|
|
3741
|
+
this.#overlayManager.close(this.#dialog);
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3124
3744
|
}
|
|
3125
3745
|
|
|
3126
3746
|
;// CONCATENATED MODULE: ./web/alt_text_manager.js
|
|
@@ -3410,6 +4030,15 @@ class AnnotationEditorParams {
|
|
|
3410
4030
|
dispatchEvent("INK_OPACITY", this.valueAsNumber);
|
|
3411
4031
|
});
|
|
3412
4032
|
editorStampAddImage.addEventListener("click", () => {
|
|
4033
|
+
this.eventBus.dispatch("reporttelemetry", {
|
|
4034
|
+
source: this,
|
|
4035
|
+
details: {
|
|
4036
|
+
type: "editing",
|
|
4037
|
+
data: {
|
|
4038
|
+
action: "pdfjs.image.add_image_click"
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
});
|
|
3413
4042
|
dispatchEvent("CREATE");
|
|
3414
4043
|
});
|
|
3415
4044
|
editorFreeHighlightThickness.addEventListener("input", function () {
|
|
@@ -3706,7 +4335,7 @@ class DownloadManager {
|
|
|
3706
4335
|
this.downloadData(data, filename, contentType);
|
|
3707
4336
|
return false;
|
|
3708
4337
|
}
|
|
3709
|
-
download(data, url, filename
|
|
4338
|
+
download(data, url, filename) {
|
|
3710
4339
|
let blobUrl;
|
|
3711
4340
|
if (data) {
|
|
3712
4341
|
blobUrl = URL.createObjectURL(new Blob([data], {
|
|
@@ -3808,7 +4437,7 @@ class PasswordPrompt {
|
|
|
3808
4437
|
if (!this._isViewerEmbedded || passwordIncorrect) {
|
|
3809
4438
|
this.input.focus();
|
|
3810
4439
|
}
|
|
3811
|
-
this.label.setAttribute("data-l10n-id",
|
|
4440
|
+
this.label.setAttribute("data-l10n-id", passwordIncorrect ? "pdfjs-password-invalid" : "pdfjs-password-label");
|
|
3812
4441
|
}
|
|
3813
4442
|
async close() {
|
|
3814
4443
|
if (this.overlayManager.active === this.dialog) {
|
|
@@ -3849,9 +4478,6 @@ const TREEITEM_OFFSET_TOP = -100;
|
|
|
3849
4478
|
const TREEITEM_SELECTED_CLASS = "selected";
|
|
3850
4479
|
class BaseTreeViewer {
|
|
3851
4480
|
constructor(options) {
|
|
3852
|
-
if (this.constructor === BaseTreeViewer) {
|
|
3853
|
-
throw new Error("Cannot initialize BaseTreeViewer.");
|
|
3854
|
-
}
|
|
3855
4481
|
this.container = options.container;
|
|
3856
4482
|
this.eventBus = options.eventBus;
|
|
3857
4483
|
this._l10n = options.l10n;
|
|
@@ -4244,15 +4870,14 @@ class PDFCursorTools {
|
|
|
4244
4870
|
;// CONCATENATED MODULE: ./web/pdf_document_properties.js
|
|
4245
4871
|
|
|
4246
4872
|
|
|
4247
|
-
const DEFAULT_FIELD_CONTENT = "-";
|
|
4248
4873
|
const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
|
|
4249
4874
|
const US_PAGE_NAMES = {
|
|
4250
|
-
"8.5x11": "letter",
|
|
4251
|
-
"8.5x14": "legal"
|
|
4875
|
+
"8.5x11": "pdfjs-document-properties-page-size-name-letter",
|
|
4876
|
+
"8.5x14": "pdfjs-document-properties-page-size-name-legal"
|
|
4252
4877
|
};
|
|
4253
4878
|
const METRIC_PAGE_NAMES = {
|
|
4254
|
-
"297x420": "a-three",
|
|
4255
|
-
"210x297": "a-four"
|
|
4879
|
+
"297x420": "pdfjs-document-properties-page-size-name-a-three",
|
|
4880
|
+
"210x297": "pdfjs-document-properties-page-size-name-a-four"
|
|
4256
4881
|
};
|
|
4257
4882
|
function getPageName(size, isPortrait, pageNames) {
|
|
4258
4883
|
const width = isPortrait ? size.width : size.height;
|
|
@@ -4280,7 +4905,6 @@ class PDFDocumentProperties {
|
|
|
4280
4905
|
eventBus._on("rotationchanging", evt => {
|
|
4281
4906
|
this._pagesRotation = evt.pagesRotation;
|
|
4282
4907
|
});
|
|
4283
|
-
this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage());
|
|
4284
4908
|
}
|
|
4285
4909
|
async open() {
|
|
4286
4910
|
await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
|
|
@@ -4333,7 +4957,7 @@ class PDFDocumentProperties {
|
|
|
4333
4957
|
setDocument(pdfDocument) {
|
|
4334
4958
|
if (this.pdfDocument) {
|
|
4335
4959
|
this.#reset();
|
|
4336
|
-
this.#updateUI(
|
|
4960
|
+
this.#updateUI();
|
|
4337
4961
|
}
|
|
4338
4962
|
if (!pdfDocument) {
|
|
4339
4963
|
return;
|
|
@@ -4348,32 +4972,23 @@ class PDFDocumentProperties {
|
|
|
4348
4972
|
this._currentPageNumber = 1;
|
|
4349
4973
|
this._pagesRotation = 0;
|
|
4350
4974
|
}
|
|
4351
|
-
#updateUI(
|
|
4352
|
-
if (
|
|
4353
|
-
for (const id in this.fields) {
|
|
4354
|
-
this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
|
|
4355
|
-
}
|
|
4356
|
-
return;
|
|
4357
|
-
}
|
|
4358
|
-
if (this.overlayManager.active !== this.dialog) {
|
|
4975
|
+
#updateUI() {
|
|
4976
|
+
if (this.#fieldData && this.overlayManager.active !== this.dialog) {
|
|
4359
4977
|
return;
|
|
4360
4978
|
}
|
|
4361
4979
|
for (const id in this.fields) {
|
|
4362
|
-
const content = this.#fieldData[id];
|
|
4363
|
-
this.fields[id].textContent = content || content === 0 ? content :
|
|
4980
|
+
const content = this.#fieldData?.[id];
|
|
4981
|
+
this.fields[id].textContent = content || content === 0 ? content : "-";
|
|
4364
4982
|
}
|
|
4365
4983
|
}
|
|
4366
|
-
async #parseFileSize(
|
|
4367
|
-
const kb =
|
|
4984
|
+
async #parseFileSize(b = 0) {
|
|
4985
|
+
const kb = b / 1024,
|
|
4368
4986
|
mb = kb / 1024;
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
|
|
4375
|
-
size_b: fileSize.toLocaleString()
|
|
4376
|
-
});
|
|
4987
|
+
return kb ? this.l10n.get(mb >= 1 ? "pdfjs-document-properties-size-mb" : "pdfjs-document-properties-size-kb", {
|
|
4988
|
+
mb,
|
|
4989
|
+
kb,
|
|
4990
|
+
b
|
|
4991
|
+
}) : undefined;
|
|
4377
4992
|
}
|
|
4378
4993
|
async #parsePageSize(pageSizeInches, pagesRotation) {
|
|
4379
4994
|
if (!pageSizeInches) {
|
|
@@ -4385,7 +5000,8 @@ class PDFDocumentProperties {
|
|
|
4385
5000
|
height: pageSizeInches.width
|
|
4386
5001
|
};
|
|
4387
5002
|
}
|
|
4388
|
-
const isPortrait = isPortraitOrientation(pageSizeInches)
|
|
5003
|
+
const isPortrait = isPortraitOrientation(pageSizeInches),
|
|
5004
|
+
nonMetric = NON_METRIC_LOCALES.includes(this.l10n.getLanguage());
|
|
4389
5005
|
let sizeInches = {
|
|
4390
5006
|
width: Math.round(pageSizeInches.width * 100) / 100,
|
|
4391
5007
|
height: Math.round(pageSizeInches.height * 100) / 100
|
|
@@ -4394,8 +5010,8 @@ class PDFDocumentProperties {
|
|
|
4394
5010
|
width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
|
|
4395
5011
|
height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
|
|
4396
5012
|
};
|
|
4397
|
-
let
|
|
4398
|
-
if (!
|
|
5013
|
+
let nameId = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
|
|
5014
|
+
if (!nameId && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
|
|
4399
5015
|
const exactMillimeters = {
|
|
4400
5016
|
width: pageSizeInches.width * 25.4,
|
|
4401
5017
|
height: pageSizeInches.height * 25.4
|
|
@@ -4405,8 +5021,8 @@ class PDFDocumentProperties {
|
|
|
4405
5021
|
height: Math.round(sizeMillimeters.height)
|
|
4406
5022
|
};
|
|
4407
5023
|
if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
|
|
4408
|
-
|
|
4409
|
-
if (
|
|
5024
|
+
nameId = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
|
|
5025
|
+
if (nameId) {
|
|
4410
5026
|
sizeInches = {
|
|
4411
5027
|
width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
|
|
4412
5028
|
height: Math.round(intMillimeters.height / 25.4 * 100) / 100
|
|
@@ -4418,27 +5034,23 @@ class PDFDocumentProperties {
|
|
|
4418
5034
|
const [{
|
|
4419
5035
|
width,
|
|
4420
5036
|
height
|
|
4421
|
-
}, unit, name, orientation] = await Promise.all([
|
|
4422
|
-
return this.l10n.get(
|
|
4423
|
-
width
|
|
4424
|
-
height
|
|
5037
|
+
}, unit, name, orientation] = await Promise.all([nonMetric ? sizeInches : sizeMillimeters, this.l10n.get(nonMetric ? "pdfjs-document-properties-page-size-unit-inches" : "pdfjs-document-properties-page-size-unit-millimeters"), nameId && this.l10n.get(nameId), this.l10n.get(isPortrait ? "pdfjs-document-properties-page-size-orientation-portrait" : "pdfjs-document-properties-page-size-orientation-landscape")]);
|
|
5038
|
+
return this.l10n.get(name ? "pdfjs-document-properties-page-size-dimension-name-string" : "pdfjs-document-properties-page-size-dimension-string", {
|
|
5039
|
+
width,
|
|
5040
|
+
height,
|
|
4425
5041
|
unit,
|
|
4426
5042
|
name,
|
|
4427
5043
|
orientation
|
|
4428
5044
|
});
|
|
4429
5045
|
}
|
|
4430
5046
|
async #parseDate(inputDate) {
|
|
4431
|
-
const
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
}
|
|
4435
|
-
return this.l10n.get("pdfjs-document-properties-date-string", {
|
|
4436
|
-
date: dateObject.toLocaleDateString(),
|
|
4437
|
-
time: dateObject.toLocaleTimeString()
|
|
4438
|
-
});
|
|
5047
|
+
const dateObj = PDFDateString.toDateObject(inputDate);
|
|
5048
|
+
return dateObj ? this.l10n.get("pdfjs-document-properties-date-time-string", {
|
|
5049
|
+
dateObj
|
|
5050
|
+
}) : undefined;
|
|
4439
5051
|
}
|
|
4440
5052
|
#parseLinearization(isLinearized) {
|
|
4441
|
-
return this.l10n.get(
|
|
5053
|
+
return this.l10n.get(isLinearized ? "pdfjs-document-properties-linearized-yes" : "pdfjs-document-properties-linearized-no");
|
|
4442
5054
|
}
|
|
4443
5055
|
}
|
|
4444
5056
|
|
|
@@ -4915,25 +5527,6 @@ class PDFFindController {
|
|
|
4915
5527
|
}
|
|
4916
5528
|
return true;
|
|
4917
5529
|
}
|
|
4918
|
-
#calculateRegExpMatch(query, entireWord, pageIndex, pageContent) {
|
|
4919
|
-
const matches = this._pageMatches[pageIndex] = [];
|
|
4920
|
-
const matchesLength = this._pageMatchesLength[pageIndex] = [];
|
|
4921
|
-
if (!query) {
|
|
4922
|
-
return;
|
|
4923
|
-
}
|
|
4924
|
-
const diffs = this._pageDiffs[pageIndex];
|
|
4925
|
-
let match;
|
|
4926
|
-
while ((match = query.exec(pageContent)) !== null) {
|
|
4927
|
-
if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
|
|
4928
|
-
continue;
|
|
4929
|
-
}
|
|
4930
|
-
const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
|
|
4931
|
-
if (matchLen) {
|
|
4932
|
-
matches.push(matchPos);
|
|
4933
|
-
matchesLength.push(matchLen);
|
|
4934
|
-
}
|
|
4935
|
-
}
|
|
4936
|
-
}
|
|
4937
5530
|
#convertToRegExpString(query, hasDiacritics) {
|
|
4938
5531
|
const {
|
|
4939
5532
|
matchDiacritics
|
|
@@ -4975,29 +5568,25 @@ class PDFFindController {
|
|
|
4975
5568
|
return [isUnicode, query];
|
|
4976
5569
|
}
|
|
4977
5570
|
#calculateMatch(pageIndex) {
|
|
4978
|
-
|
|
5571
|
+
const query = this.#query;
|
|
4979
5572
|
if (query.length === 0) {
|
|
4980
5573
|
return;
|
|
4981
5574
|
}
|
|
4982
|
-
const {
|
|
4983
|
-
caseSensitive,
|
|
4984
|
-
entireWord
|
|
4985
|
-
} = this.#state;
|
|
4986
5575
|
const pageContent = this._pageContents[pageIndex];
|
|
4987
|
-
const
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5576
|
+
const matcherResult = this.match(query, pageContent, pageIndex);
|
|
5577
|
+
const matches = this._pageMatches[pageIndex] = [];
|
|
5578
|
+
const matchesLength = this._pageMatchesLength[pageIndex] = [];
|
|
5579
|
+
const diffs = this._pageDiffs[pageIndex];
|
|
5580
|
+
matcherResult?.forEach(({
|
|
5581
|
+
index,
|
|
5582
|
+
length
|
|
5583
|
+
}) => {
|
|
5584
|
+
const [matchPos, matchLen] = getOriginalIndex(diffs, index, length);
|
|
5585
|
+
if (matchLen) {
|
|
5586
|
+
matches.push(matchPos);
|
|
5587
|
+
matchesLength.push(matchLen);
|
|
5588
|
+
}
|
|
5589
|
+
});
|
|
5001
5590
|
if (this.#state.highlightAll) {
|
|
5002
5591
|
this.#updatePage(pageIndex);
|
|
5003
5592
|
}
|
|
@@ -5005,7 +5594,7 @@ class PDFFindController {
|
|
|
5005
5594
|
this._resumePageIdx = null;
|
|
5006
5595
|
this.#nextPageMatch();
|
|
5007
5596
|
}
|
|
5008
|
-
const pageMatchesCount =
|
|
5597
|
+
const pageMatchesCount = matches.length;
|
|
5009
5598
|
this._matchesCountTotal += pageMatchesCount;
|
|
5010
5599
|
if (this.#updateMatchesCountOnProgress) {
|
|
5011
5600
|
if (pageMatchesCount > 0) {
|
|
@@ -5015,6 +5604,40 @@ class PDFFindController {
|
|
|
5015
5604
|
this.#updateUIResultsCount();
|
|
5016
5605
|
}
|
|
5017
5606
|
}
|
|
5607
|
+
match(query, pageContent, pageIndex) {
|
|
5608
|
+
const hasDiacritics = this._hasDiacritics[pageIndex];
|
|
5609
|
+
let isUnicode = false;
|
|
5610
|
+
if (typeof query === "string") {
|
|
5611
|
+
[isUnicode, query] = this.#convertToRegExpString(query, hasDiacritics);
|
|
5612
|
+
} else {
|
|
5613
|
+
query = query.sort().reverse().map(q => {
|
|
5614
|
+
const [isUnicodePart, queryPart] = this.#convertToRegExpString(q, hasDiacritics);
|
|
5615
|
+
isUnicode ||= isUnicodePart;
|
|
5616
|
+
return `(${queryPart})`;
|
|
5617
|
+
}).join("|");
|
|
5618
|
+
}
|
|
5619
|
+
if (!query) {
|
|
5620
|
+
return undefined;
|
|
5621
|
+
}
|
|
5622
|
+
const {
|
|
5623
|
+
caseSensitive,
|
|
5624
|
+
entireWord
|
|
5625
|
+
} = this.#state;
|
|
5626
|
+
const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
|
|
5627
|
+
query = new RegExp(query, flags);
|
|
5628
|
+
const matches = [];
|
|
5629
|
+
let match;
|
|
5630
|
+
while ((match = query.exec(pageContent)) !== null) {
|
|
5631
|
+
if (entireWord && !this.#isEntireWord(pageContent, match.index, match[0].length)) {
|
|
5632
|
+
continue;
|
|
5633
|
+
}
|
|
5634
|
+
matches.push({
|
|
5635
|
+
index: match.index,
|
|
5636
|
+
length: match[0].length
|
|
5637
|
+
});
|
|
5638
|
+
}
|
|
5639
|
+
return matches;
|
|
5640
|
+
}
|
|
5018
5641
|
#extractText() {
|
|
5019
5642
|
if (this._extractTextPromises.length > 0) {
|
|
5020
5643
|
return;
|
|
@@ -5328,7 +5951,7 @@ class PDFFindBar {
|
|
|
5328
5951
|
status = "notFound";
|
|
5329
5952
|
break;
|
|
5330
5953
|
case FindState.WRAPPED:
|
|
5331
|
-
findMsgId =
|
|
5954
|
+
findMsgId = previous ? "pdfjs-find-reached-top" : "pdfjs-find-reached-bottom";
|
|
5332
5955
|
break;
|
|
5333
5956
|
}
|
|
5334
5957
|
findField.setAttribute("data-status", status);
|
|
@@ -5351,7 +5974,7 @@ class PDFFindBar {
|
|
|
5351
5974
|
} = this;
|
|
5352
5975
|
if (total > 0) {
|
|
5353
5976
|
const limit = MATCHES_COUNT_LIMIT;
|
|
5354
|
-
findResultsCount.setAttribute("data-l10n-id",
|
|
5977
|
+
findResultsCount.setAttribute("data-l10n-id", total > limit ? "pdfjs-find-match-count-limit" : "pdfjs-find-match-count");
|
|
5355
5978
|
findResultsCount.setAttribute("data-l10n-args", JSON.stringify({
|
|
5356
5979
|
limit,
|
|
5357
5980
|
current,
|
|
@@ -5918,15 +6541,16 @@ class PDFLayerViewer extends BaseTreeViewer {
|
|
|
5918
6541
|
return false;
|
|
5919
6542
|
};
|
|
5920
6543
|
}
|
|
5921
|
-
|
|
6544
|
+
_setNestedName(element, {
|
|
5922
6545
|
name = null
|
|
5923
6546
|
}) {
|
|
5924
6547
|
if (typeof name === "string") {
|
|
5925
6548
|
element.textContent = this._normalizeTextContent(name);
|
|
5926
6549
|
return;
|
|
5927
6550
|
}
|
|
5928
|
-
element.
|
|
6551
|
+
element.setAttribute("data-l10n-id", "pdfjs-additional-layers");
|
|
5929
6552
|
element.style.fontStyle = "italic";
|
|
6553
|
+
this._l10n.translateOnce(element);
|
|
5930
6554
|
}
|
|
5931
6555
|
_addToggleButton(div, {
|
|
5932
6556
|
name = null
|
|
@@ -6794,22 +7418,24 @@ class PDFPrintService {
|
|
|
6794
7418
|
useRenderedPage() {
|
|
6795
7419
|
this.throwIfInactive();
|
|
6796
7420
|
const img = document.createElement("img");
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
img.src = URL.createObjectURL(blob);
|
|
6801
|
-
});
|
|
6802
|
-
} else {
|
|
6803
|
-
img.src = scratchCanvas.toDataURL();
|
|
6804
|
-
}
|
|
7421
|
+
this.scratchCanvas.toBlob(blob => {
|
|
7422
|
+
img.src = URL.createObjectURL(blob);
|
|
7423
|
+
});
|
|
6805
7424
|
const wrapper = document.createElement("div");
|
|
6806
7425
|
wrapper.className = "printedPage";
|
|
6807
7426
|
wrapper.append(img);
|
|
6808
7427
|
this.printContainer.append(wrapper);
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
7428
|
+
const {
|
|
7429
|
+
promise,
|
|
7430
|
+
resolve,
|
|
7431
|
+
reject
|
|
7432
|
+
} = Promise.withResolvers();
|
|
7433
|
+
img.onload = resolve;
|
|
7434
|
+
img.onerror = reject;
|
|
7435
|
+
promise.catch(() => {}).then(() => {
|
|
7436
|
+
URL.revokeObjectURL(img.src);
|
|
6812
7437
|
});
|
|
7438
|
+
return promise;
|
|
6813
7439
|
}
|
|
6814
7440
|
performPrint() {
|
|
6815
7441
|
this.throwIfInactive();
|
|
@@ -7423,8 +8049,7 @@ const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
|
|
|
7423
8049
|
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
|
7424
8050
|
class PDFSidebar {
|
|
7425
8051
|
#isRTL = false;
|
|
7426
|
-
#
|
|
7427
|
-
#mouseUpBound = this.#mouseUp.bind(this);
|
|
8052
|
+
#mouseAC = null;
|
|
7428
8053
|
#outerContainerWidth = null;
|
|
7429
8054
|
#width = null;
|
|
7430
8055
|
constructor({
|
|
@@ -7591,10 +8216,14 @@ class PDFSidebar {
|
|
|
7591
8216
|
}
|
|
7592
8217
|
}
|
|
7593
8218
|
#addEventListeners() {
|
|
8219
|
+
const {
|
|
8220
|
+
eventBus,
|
|
8221
|
+
outerContainer
|
|
8222
|
+
} = this;
|
|
7594
8223
|
this.sidebarContainer.addEventListener("transitionend", evt => {
|
|
7595
8224
|
if (evt.target === this.sidebarContainer) {
|
|
7596
|
-
|
|
7597
|
-
|
|
8225
|
+
outerContainer.classList.remove("sidebarMoving");
|
|
8226
|
+
eventBus.dispatch("resize", {
|
|
7598
8227
|
source: this
|
|
7599
8228
|
});
|
|
7600
8229
|
}
|
|
@@ -7609,7 +8238,7 @@ class PDFSidebar {
|
|
|
7609
8238
|
this.switchView(SidebarView.OUTLINE);
|
|
7610
8239
|
});
|
|
7611
8240
|
this.outlineButton.addEventListener("dblclick", () => {
|
|
7612
|
-
|
|
8241
|
+
eventBus.dispatch("toggleoutlinetree", {
|
|
7613
8242
|
source: this
|
|
7614
8243
|
});
|
|
7615
8244
|
});
|
|
@@ -7620,12 +8249,12 @@ class PDFSidebar {
|
|
|
7620
8249
|
this.switchView(SidebarView.LAYERS);
|
|
7621
8250
|
});
|
|
7622
8251
|
this.layersButton.addEventListener("dblclick", () => {
|
|
7623
|
-
|
|
8252
|
+
eventBus.dispatch("resetlayers", {
|
|
7624
8253
|
source: this
|
|
7625
8254
|
});
|
|
7626
8255
|
});
|
|
7627
8256
|
this._currentOutlineItemButton.addEventListener("click", () => {
|
|
7628
|
-
|
|
8257
|
+
eventBus.dispatch("currentoutlineitem", {
|
|
7629
8258
|
source: this
|
|
7630
8259
|
});
|
|
7631
8260
|
});
|
|
@@ -7637,7 +8266,7 @@ class PDFSidebar {
|
|
|
7637
8266
|
this.switchView(SidebarView.THUMBS);
|
|
7638
8267
|
}
|
|
7639
8268
|
};
|
|
7640
|
-
|
|
8269
|
+
eventBus._on("outlineloaded", evt => {
|
|
7641
8270
|
onTreeLoaded(evt.outlineCount, this.outlineButton, SidebarView.OUTLINE);
|
|
7642
8271
|
evt.currentOutlineItemPromise.then(enabled => {
|
|
7643
8272
|
if (!this.isInitialViewSet) {
|
|
@@ -7646,13 +8275,13 @@ class PDFSidebar {
|
|
|
7646
8275
|
this._currentOutlineItemButton.disabled = !enabled;
|
|
7647
8276
|
});
|
|
7648
8277
|
});
|
|
7649
|
-
|
|
8278
|
+
eventBus._on("attachmentsloaded", evt => {
|
|
7650
8279
|
onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, SidebarView.ATTACHMENTS);
|
|
7651
8280
|
});
|
|
7652
|
-
|
|
8281
|
+
eventBus._on("layersloaded", evt => {
|
|
7653
8282
|
onTreeLoaded(evt.layersCount, this.layersButton, SidebarView.LAYERS);
|
|
7654
8283
|
});
|
|
7655
|
-
|
|
8284
|
+
eventBus._on("presentationmodechanged", evt => {
|
|
7656
8285
|
if (evt.state === PresentationModeState.NORMAL && this.visibleView === SidebarView.THUMBS) {
|
|
7657
8286
|
this.onUpdateThumbnails();
|
|
7658
8287
|
}
|
|
@@ -7661,11 +8290,16 @@ class PDFSidebar {
|
|
|
7661
8290
|
if (evt.button !== 0) {
|
|
7662
8291
|
return;
|
|
7663
8292
|
}
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
8293
|
+
outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
|
|
8294
|
+
this.#mouseAC = new AbortController();
|
|
8295
|
+
const opts = {
|
|
8296
|
+
signal: this.#mouseAC.signal
|
|
8297
|
+
};
|
|
8298
|
+
window.addEventListener("mousemove", this.#mouseMove.bind(this), opts);
|
|
8299
|
+
window.addEventListener("mouseup", this.#mouseUp.bind(this), opts);
|
|
8300
|
+
window.addEventListener("blur", this.#mouseUp.bind(this), opts);
|
|
7667
8301
|
});
|
|
7668
|
-
|
|
8302
|
+
eventBus._on("resize", evt => {
|
|
7669
8303
|
if (evt.source !== window) {
|
|
7670
8304
|
return;
|
|
7671
8305
|
}
|
|
@@ -7677,12 +8311,12 @@ class PDFSidebar {
|
|
|
7677
8311
|
this.#updateWidth(this.#width);
|
|
7678
8312
|
return;
|
|
7679
8313
|
}
|
|
7680
|
-
|
|
8314
|
+
outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
|
|
7681
8315
|
const updated = this.#updateWidth(this.#width);
|
|
7682
8316
|
Promise.resolve().then(() => {
|
|
7683
|
-
|
|
8317
|
+
outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
|
|
7684
8318
|
if (updated) {
|
|
7685
|
-
|
|
8319
|
+
eventBus.dispatch("resize", {
|
|
7686
8320
|
source: this
|
|
7687
8321
|
});
|
|
7688
8322
|
}
|
|
@@ -7719,8 +8353,8 @@ class PDFSidebar {
|
|
|
7719
8353
|
this.eventBus.dispatch("resize", {
|
|
7720
8354
|
source: this
|
|
7721
8355
|
});
|
|
7722
|
-
|
|
7723
|
-
|
|
8356
|
+
this.#mouseAC?.abort();
|
|
8357
|
+
this.#mouseAC = null;
|
|
7724
8358
|
}
|
|
7725
8359
|
}
|
|
7726
8360
|
|
|
@@ -9051,8 +9685,8 @@ class TextLayerBuilder {
|
|
|
9051
9685
|
const {
|
|
9052
9686
|
div
|
|
9053
9687
|
} = this;
|
|
9054
|
-
div.addEventListener("mousedown",
|
|
9055
|
-
|
|
9688
|
+
div.addEventListener("mousedown", () => {
|
|
9689
|
+
div.classList.add("selecting");
|
|
9056
9690
|
});
|
|
9057
9691
|
div.addEventListener("copy", event => {
|
|
9058
9692
|
if (!this.#enablePermissions) {
|
|
@@ -9084,13 +9718,33 @@ class TextLayerBuilder {
|
|
|
9084
9718
|
textLayer.append(end);
|
|
9085
9719
|
end.style.width = "";
|
|
9086
9720
|
end.style.height = "";
|
|
9087
|
-
|
|
9721
|
+
textLayer.classList.remove("selecting");
|
|
9088
9722
|
};
|
|
9723
|
+
let isPointerDown = false;
|
|
9724
|
+
document.addEventListener("pointerdown", () => {
|
|
9725
|
+
isPointerDown = true;
|
|
9726
|
+
}, {
|
|
9727
|
+
signal
|
|
9728
|
+
});
|
|
9089
9729
|
document.addEventListener("pointerup", () => {
|
|
9730
|
+
isPointerDown = false;
|
|
9731
|
+
this.#textLayers.forEach(reset);
|
|
9732
|
+
}, {
|
|
9733
|
+
signal
|
|
9734
|
+
});
|
|
9735
|
+
window.addEventListener("blur", () => {
|
|
9736
|
+
isPointerDown = false;
|
|
9090
9737
|
this.#textLayers.forEach(reset);
|
|
9091
9738
|
}, {
|
|
9092
9739
|
signal
|
|
9093
9740
|
});
|
|
9741
|
+
document.addEventListener("keyup", () => {
|
|
9742
|
+
if (!isPointerDown) {
|
|
9743
|
+
this.#textLayers.forEach(reset);
|
|
9744
|
+
}
|
|
9745
|
+
}, {
|
|
9746
|
+
signal
|
|
9747
|
+
});
|
|
9094
9748
|
var isFirefox, prevRange;
|
|
9095
9749
|
document.addEventListener("selectionchange", () => {
|
|
9096
9750
|
const selection = document.getSelection();
|
|
@@ -9109,7 +9763,7 @@ class TextLayerBuilder {
|
|
|
9109
9763
|
}
|
|
9110
9764
|
for (const [textLayerDiv, endDiv] of this.#textLayers) {
|
|
9111
9765
|
if (activeTextLayers.has(textLayerDiv)) {
|
|
9112
|
-
|
|
9766
|
+
textLayerDiv.classList.add("selecting");
|
|
9113
9767
|
} else {
|
|
9114
9768
|
reset(endDiv, textLayerDiv);
|
|
9115
9769
|
}
|
|
@@ -9878,20 +10532,18 @@ class PDFPageView {
|
|
|
9878
10532
|
});
|
|
9879
10533
|
await this.#renderDrawLayer();
|
|
9880
10534
|
this.drawLayer.setParent(canvasWrapper);
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
});
|
|
9894
|
-
}
|
|
10535
|
+
this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({
|
|
10536
|
+
uiManager: annotationEditorUIManager,
|
|
10537
|
+
pdfPage,
|
|
10538
|
+
l10n,
|
|
10539
|
+
accessibilityManager: this._accessibilityManager,
|
|
10540
|
+
annotationLayer: this.annotationLayer?.annotationLayer,
|
|
10541
|
+
textLayer: this.textLayer,
|
|
10542
|
+
drawLayer: this.drawLayer.getDrawLayer(),
|
|
10543
|
+
onAppend: annotationEditorLayerDiv => {
|
|
10544
|
+
this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer");
|
|
10545
|
+
}
|
|
10546
|
+
});
|
|
9895
10547
|
this.#renderAnnotationEditorLayer();
|
|
9896
10548
|
}, error => {
|
|
9897
10549
|
if (!(error instanceof RenderingCancelledException)) {
|
|
@@ -10017,6 +10669,7 @@ class PDFViewer {
|
|
|
10017
10669
|
#enableHighlightFloatingButton = false;
|
|
10018
10670
|
#enablePermissions = false;
|
|
10019
10671
|
#enableUpdatedAddImage = false;
|
|
10672
|
+
#enableNewAltTextWhenAddingImage = false;
|
|
10020
10673
|
#eventAbortController = null;
|
|
10021
10674
|
#mlManager = null;
|
|
10022
10675
|
#onPageRenderedCallback = null;
|
|
@@ -10030,7 +10683,7 @@ class PDFViewer {
|
|
|
10030
10683
|
#scaleTimeoutId = null;
|
|
10031
10684
|
#textLayerMode = TextLayerMode.ENABLE;
|
|
10032
10685
|
constructor(options) {
|
|
10033
|
-
const viewerVersion = "4.
|
|
10686
|
+
const viewerVersion = "4.6.82";
|
|
10034
10687
|
if (version !== viewerVersion) {
|
|
10035
10688
|
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
|
|
10036
10689
|
}
|
|
@@ -10058,6 +10711,7 @@ class PDFViewer {
|
|
|
10058
10711
|
this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
|
|
10059
10712
|
this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
|
|
10060
10713
|
this.#enableUpdatedAddImage = options.enableUpdatedAddImage === true;
|
|
10714
|
+
this.#enableNewAltTextWhenAddingImage = options.enableNewAltTextWhenAddingImage === true;
|
|
10061
10715
|
this.imageResourcesPath = options.imageResourcesPath || "";
|
|
10062
10716
|
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
|
10063
10717
|
this.removePageBorders = options.removePageBorders || false;
|
|
@@ -10382,10 +11036,8 @@ class PDFViewer {
|
|
|
10382
11036
|
this._resetView();
|
|
10383
11037
|
this.findController?.setDocument(null);
|
|
10384
11038
|
this._scriptingManager?.setDocument(null);
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
this.#annotationEditorUIManager = null;
|
|
10388
|
-
}
|
|
11039
|
+
this.#annotationEditorUIManager?.destroy();
|
|
11040
|
+
this.#annotationEditorUIManager = null;
|
|
10389
11041
|
}
|
|
10390
11042
|
this.pdfDocument = pdfDocument;
|
|
10391
11043
|
if (!pdfDocument) {
|
|
@@ -10458,17 +11110,20 @@ class PDFViewer {
|
|
|
10458
11110
|
element.id = "hiddenCopyElement";
|
|
10459
11111
|
viewer.before(element);
|
|
10460
11112
|
}
|
|
10461
|
-
if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
|
|
11113
|
+
if (typeof AbortSignal.any === "function" && annotationEditorMode !== AnnotationEditorType.DISABLE) {
|
|
10462
11114
|
const mode = annotationEditorMode;
|
|
10463
11115
|
if (pdfDocument.isPureXfa) {
|
|
10464
11116
|
console.warn("Warning: XFA-editing is not implemented.");
|
|
10465
11117
|
} else if (isValidAnnotationEditorMode(mode)) {
|
|
10466
|
-
this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#enableUpdatedAddImage, this.#mlManager);
|
|
11118
|
+
this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#enableUpdatedAddImage, this.#enableNewAltTextWhenAddingImage, this.#mlManager);
|
|
10467
11119
|
eventBus.dispatch("annotationeditoruimanager", {
|
|
10468
11120
|
source: this,
|
|
10469
11121
|
uiManager: this.#annotationEditorUIManager
|
|
10470
11122
|
});
|
|
10471
11123
|
if (mode !== AnnotationEditorType.NONE) {
|
|
11124
|
+
if (mode === AnnotationEditorType.STAMP) {
|
|
11125
|
+
this.#mlManager?.loadModel("altText");
|
|
11126
|
+
}
|
|
10472
11127
|
this.#annotationEditorUIManager.updateMode(mode);
|
|
10473
11128
|
}
|
|
10474
11129
|
} else {
|
|
@@ -11485,6 +12140,9 @@ class PDFViewer {
|
|
|
11485
12140
|
if (!this.pdfDocument) {
|
|
11486
12141
|
return;
|
|
11487
12142
|
}
|
|
12143
|
+
if (mode === AnnotationEditorType.STAMP) {
|
|
12144
|
+
this.#mlManager?.loadModel("altText");
|
|
12145
|
+
}
|
|
11488
12146
|
const {
|
|
11489
12147
|
eventBus
|
|
11490
12148
|
} = this;
|
|
@@ -11527,15 +12185,6 @@ class PDFViewer {
|
|
|
11527
12185
|
}
|
|
11528
12186
|
updater();
|
|
11529
12187
|
}
|
|
11530
|
-
set annotationEditorParams({
|
|
11531
|
-
type,
|
|
11532
|
-
value
|
|
11533
|
-
}) {
|
|
11534
|
-
if (!this.#annotationEditorUIManager) {
|
|
11535
|
-
throw new Error(`The AnnotationEditor is not enabled.`);
|
|
11536
|
-
}
|
|
11537
|
-
this.#annotationEditorUIManager.updateParams(type, value);
|
|
11538
|
-
}
|
|
11539
12188
|
refresh(noUpdate = false, updateArgs = Object.create(null)) {
|
|
11540
12189
|
if (!this.pdfDocument) {
|
|
11541
12190
|
return;
|
|
@@ -11655,6 +12304,10 @@ class SecondaryToolbar {
|
|
|
11655
12304
|
mode: SpreadMode.EVEN
|
|
11656
12305
|
},
|
|
11657
12306
|
close: true
|
|
12307
|
+
}, {
|
|
12308
|
+
element: options.imageAltTextSettingsButton,
|
|
12309
|
+
eventName: "imagealttextsettings",
|
|
12310
|
+
close: true
|
|
11658
12311
|
}, {
|
|
11659
12312
|
element: options.documentPropertiesButton,
|
|
11660
12313
|
eventName: "documentproperties",
|
|
@@ -11895,28 +12548,15 @@ class Toolbar {
|
|
|
11895
12548
|
} = options.editorStampButton;
|
|
11896
12549
|
return classList.contains("toggled") ? AnnotationEditorType.NONE : AnnotationEditorType.STAMP;
|
|
11897
12550
|
}
|
|
12551
|
+
},
|
|
12552
|
+
telemetry: {
|
|
12553
|
+
type: "editing",
|
|
12554
|
+
data: {
|
|
12555
|
+
action: "pdfjs.image.icon_click"
|
|
12556
|
+
}
|
|
11898
12557
|
}
|
|
11899
12558
|
}];
|
|
11900
12559
|
this.#bindListeners(buttons);
|
|
11901
|
-
if (options.editorHighlightColorPicker) {
|
|
11902
|
-
eventBus._on("annotationeditoruimanager", ({
|
|
11903
|
-
uiManager
|
|
11904
|
-
}) => {
|
|
11905
|
-
this.#setAnnotationEditorUIManager(uiManager, options.editorHighlightColorPicker);
|
|
11906
|
-
}, {
|
|
11907
|
-
once: true
|
|
11908
|
-
});
|
|
11909
|
-
}
|
|
11910
|
-
eventBus._on("showannotationeditorui", ({
|
|
11911
|
-
mode
|
|
11912
|
-
}) => {
|
|
11913
|
-
switch (mode) {
|
|
11914
|
-
case AnnotationEditorType.HIGHLIGHT:
|
|
11915
|
-
options.editorHighlightButton.click();
|
|
11916
|
-
break;
|
|
11917
|
-
}
|
|
11918
|
-
});
|
|
11919
|
-
eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
|
|
11920
12560
|
this.#updateToolbarDensity({
|
|
11921
12561
|
value: toolbarDensity
|
|
11922
12562
|
});
|
|
@@ -11963,6 +12603,8 @@ class Toolbar {
|
|
|
11963
12603
|
eventBus
|
|
11964
12604
|
} = this;
|
|
11965
12605
|
const {
|
|
12606
|
+
editorHighlightColorPicker,
|
|
12607
|
+
editorHighlightButton,
|
|
11966
12608
|
pageNumber,
|
|
11967
12609
|
scaleSelect
|
|
11968
12610
|
} = this.#opts;
|
|
@@ -11970,7 +12612,8 @@ class Toolbar {
|
|
|
11970
12612
|
for (const {
|
|
11971
12613
|
element,
|
|
11972
12614
|
eventName,
|
|
11973
|
-
eventDetails
|
|
12615
|
+
eventDetails,
|
|
12616
|
+
telemetry
|
|
11974
12617
|
} of buttons) {
|
|
11975
12618
|
element.addEventListener("click", evt => {
|
|
11976
12619
|
if (eventName !== null) {
|
|
@@ -11980,6 +12623,12 @@ class Toolbar {
|
|
|
11980
12623
|
isFromKeyboard: evt.detail === 0
|
|
11981
12624
|
});
|
|
11982
12625
|
}
|
|
12626
|
+
if (telemetry) {
|
|
12627
|
+
eventBus.dispatch("reporttelemetry", {
|
|
12628
|
+
source: this,
|
|
12629
|
+
details: telemetry
|
|
12630
|
+
});
|
|
12631
|
+
}
|
|
11983
12632
|
});
|
|
11984
12633
|
}
|
|
11985
12634
|
pageNumber.addEventListener("click", function () {
|
|
@@ -12009,6 +12658,25 @@ class Toolbar {
|
|
|
12009
12658
|
});
|
|
12010
12659
|
scaleSelect.oncontextmenu = noContextMenu;
|
|
12011
12660
|
eventBus._on("annotationeditormodechanged", this.#editorModeChanged.bind(this));
|
|
12661
|
+
eventBus._on("showannotationeditorui", ({
|
|
12662
|
+
mode
|
|
12663
|
+
}) => {
|
|
12664
|
+
switch (mode) {
|
|
12665
|
+
case AnnotationEditorType.HIGHLIGHT:
|
|
12666
|
+
editorHighlightButton.click();
|
|
12667
|
+
break;
|
|
12668
|
+
}
|
|
12669
|
+
});
|
|
12670
|
+
eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
|
|
12671
|
+
if (editorHighlightColorPicker) {
|
|
12672
|
+
eventBus._on("annotationeditoruimanager", ({
|
|
12673
|
+
uiManager
|
|
12674
|
+
}) => {
|
|
12675
|
+
this.#setAnnotationEditorUIManager(uiManager, editorHighlightColorPicker);
|
|
12676
|
+
}, {
|
|
12677
|
+
once: true
|
|
12678
|
+
});
|
|
12679
|
+
}
|
|
12012
12680
|
}
|
|
12013
12681
|
#editorModeChanged({
|
|
12014
12682
|
mode
|
|
@@ -12188,6 +12856,7 @@ class ViewHistory {
|
|
|
12188
12856
|
|
|
12189
12857
|
|
|
12190
12858
|
|
|
12859
|
+
|
|
12191
12860
|
|
|
12192
12861
|
|
|
12193
12862
|
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
|
|
@@ -12228,6 +12897,7 @@ const PDFViewerApplication = {
|
|
|
12228
12897
|
eventBus: null,
|
|
12229
12898
|
l10n: null,
|
|
12230
12899
|
annotationEditorParams: null,
|
|
12900
|
+
imageAltTextSettings: null,
|
|
12231
12901
|
isInitialViewSet: false,
|
|
12232
12902
|
isViewerEmbedded: window.parent !== window,
|
|
12233
12903
|
url: "",
|
|
@@ -12315,24 +12985,6 @@ const PDFViewerApplication = {
|
|
|
12315
12985
|
console.error(`_parseHashParams: "${ex.message}".`);
|
|
12316
12986
|
}
|
|
12317
12987
|
}
|
|
12318
|
-
if (params.has("disablerange")) {
|
|
12319
|
-
AppOptions.set("disableRange", params.get("disablerange") === "true");
|
|
12320
|
-
}
|
|
12321
|
-
if (params.has("disablestream")) {
|
|
12322
|
-
AppOptions.set("disableStream", params.get("disablestream") === "true");
|
|
12323
|
-
}
|
|
12324
|
-
if (params.has("disableautofetch")) {
|
|
12325
|
-
AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
|
|
12326
|
-
}
|
|
12327
|
-
if (params.has("disablefontface")) {
|
|
12328
|
-
AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
|
|
12329
|
-
}
|
|
12330
|
-
if (params.has("disablehistory")) {
|
|
12331
|
-
AppOptions.set("disableHistory", params.get("disablehistory") === "true");
|
|
12332
|
-
}
|
|
12333
|
-
if (params.has("verbosity")) {
|
|
12334
|
-
AppOptions.set("verbosity", params.get("verbosity") | 0);
|
|
12335
|
-
}
|
|
12336
12988
|
if (params.has("textlayer")) {
|
|
12337
12989
|
switch (params.get("textlayer")) {
|
|
12338
12990
|
case "off":
|
|
@@ -12369,6 +13021,21 @@ const PDFViewerApplication = {
|
|
|
12369
13021
|
lang: params.get("locale")
|
|
12370
13022
|
});
|
|
12371
13023
|
}
|
|
13024
|
+
const opts = {
|
|
13025
|
+
disableAutoFetch: x => x === "true",
|
|
13026
|
+
disableFontFace: x => x === "true",
|
|
13027
|
+
disableHistory: x => x === "true",
|
|
13028
|
+
disableRange: x => x === "true",
|
|
13029
|
+
disableStream: x => x === "true",
|
|
13030
|
+
verbosity: x => x | 0
|
|
13031
|
+
};
|
|
13032
|
+
for (const name in opts) {
|
|
13033
|
+
const check = opts[name],
|
|
13034
|
+
key = name.toLowerCase();
|
|
13035
|
+
if (params.has(key)) {
|
|
13036
|
+
AppOptions.set(name, check(params.get(key)));
|
|
13037
|
+
}
|
|
13038
|
+
}
|
|
12372
13039
|
},
|
|
12373
13040
|
async _initializeViewerComponents() {
|
|
12374
13041
|
const {
|
|
@@ -12378,6 +13045,7 @@ const PDFViewerApplication = {
|
|
|
12378
13045
|
} = this;
|
|
12379
13046
|
let eventBus;
|
|
12380
13047
|
eventBus = new EventBus();
|
|
13048
|
+
this.mlManager?.setEventBus(eventBus, this._globalAbortController.signal);
|
|
12381
13049
|
this.eventBus = eventBus;
|
|
12382
13050
|
this.overlayManager = new OverlayManager();
|
|
12383
13051
|
const pdfRenderingQueue = new PDFRenderingQueue();
|
|
@@ -12410,7 +13078,12 @@ const PDFViewerApplication = {
|
|
|
12410
13078
|
background: AppOptions.get("pageColorsBackground"),
|
|
12411
13079
|
foreground: AppOptions.get("pageColorsForeground")
|
|
12412
13080
|
} : null;
|
|
12413
|
-
|
|
13081
|
+
let altTextManager;
|
|
13082
|
+
if (AppOptions.get("enableUpdatedAddImage")) {
|
|
13083
|
+
altTextManager = appConfig.newAltTextDialog ? new NewAltTextManager(appConfig.newAltTextDialog, this.overlayManager, eventBus) : null;
|
|
13084
|
+
} else {
|
|
13085
|
+
altTextManager = appConfig.altTextDialog ? new AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null;
|
|
13086
|
+
}
|
|
12414
13087
|
const enableHWA = AppOptions.get("enableHWA");
|
|
12415
13088
|
const pdfViewer = new PDFViewer({
|
|
12416
13089
|
container,
|
|
@@ -12429,6 +13102,7 @@ const PDFViewerApplication = {
|
|
|
12429
13102
|
annotationEditorHighlightColors: AppOptions.get("highlightEditorColors"),
|
|
12430
13103
|
enableHighlightFloatingButton: AppOptions.get("enableHighlightFloatingButton"),
|
|
12431
13104
|
enableUpdatedAddImage: AppOptions.get("enableUpdatedAddImage"),
|
|
13105
|
+
enableNewAltTextWhenAddingImage: AppOptions.get("enableNewAltTextWhenAddingImage"),
|
|
12432
13106
|
imageResourcesPath: AppOptions.get("imageResourcesPath"),
|
|
12433
13107
|
enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
|
|
12434
13108
|
maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
|
|
@@ -12465,11 +13139,7 @@ const PDFViewerApplication = {
|
|
|
12465
13139
|
this.findBar = new PDFFindBar(appConfig.findBar, eventBus);
|
|
12466
13140
|
}
|
|
12467
13141
|
if (appConfig.annotationEditorParams) {
|
|
12468
|
-
if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
|
|
12469
|
-
const editorHighlightButton = appConfig.toolbar?.editorHighlightButton;
|
|
12470
|
-
if (editorHighlightButton && AppOptions.get("enableHighlightEditor")) {
|
|
12471
|
-
editorHighlightButton.hidden = false;
|
|
12472
|
-
}
|
|
13142
|
+
if (typeof AbortSignal.any === "function" && annotationEditorMode !== AnnotationEditorType.DISABLE) {
|
|
12473
13143
|
this.annotationEditorParams = new AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
|
|
12474
13144
|
} else {
|
|
12475
13145
|
for (const id of ["editorModeButtons", "editorModeSeparator"]) {
|
|
@@ -12477,6 +13147,9 @@ const PDFViewerApplication = {
|
|
|
12477
13147
|
}
|
|
12478
13148
|
}
|
|
12479
13149
|
}
|
|
13150
|
+
if (this.mlManager && appConfig.secondaryToolbar?.imageAltTextSettingsButton) {
|
|
13151
|
+
this.imageAltTextSettings = new ImageAltTextSettings(appConfig.altTextSettingsDialog, this.overlayManager, eventBus, this.mlManager);
|
|
13152
|
+
}
|
|
12480
13153
|
if (appConfig.documentProperties) {
|
|
12481
13154
|
this.pdfDocumentProperties = new PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, l10n, () => this._docFilename);
|
|
12482
13155
|
}
|
|
@@ -12491,6 +13164,10 @@ const PDFViewerApplication = {
|
|
|
12491
13164
|
this.toolbar = new Toolbar(appConfig.toolbar, eventBus, AppOptions.get("toolbarDensity"));
|
|
12492
13165
|
}
|
|
12493
13166
|
if (appConfig.secondaryToolbar) {
|
|
13167
|
+
if (AppOptions.get("enableAltText")) {
|
|
13168
|
+
appConfig.secondaryToolbar.imageAltTextSettingsButton?.classList.remove("hidden");
|
|
13169
|
+
appConfig.secondaryToolbar.imageAltTextSettingsSeparator?.classList.remove("hidden");
|
|
13170
|
+
}
|
|
12494
13171
|
this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
|
|
12495
13172
|
}
|
|
12496
13173
|
if (this.supportsFullscreen && appConfig.secondaryToolbar?.presentationModeButton) {
|
|
@@ -12608,7 +13285,7 @@ const PDFViewerApplication = {
|
|
|
12608
13285
|
appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
|
|
12609
13286
|
}
|
|
12610
13287
|
if (this.supportsIntegratedFind) {
|
|
12611
|
-
appConfig.
|
|
13288
|
+
appConfig.findBar?.toggleButton?.classList.add("hidden");
|
|
12612
13289
|
}
|
|
12613
13290
|
if (file) {
|
|
12614
13291
|
this.open({
|
|
@@ -12822,14 +13499,14 @@ const PDFViewerApplication = {
|
|
|
12822
13499
|
});
|
|
12823
13500
|
});
|
|
12824
13501
|
},
|
|
12825
|
-
async download(
|
|
13502
|
+
async download() {
|
|
12826
13503
|
let data;
|
|
12827
13504
|
try {
|
|
12828
13505
|
data = await this.pdfDocument.getData();
|
|
12829
13506
|
} catch {}
|
|
12830
|
-
this.downloadManager.download(data, this._downloadUrl, this._docFilename
|
|
13507
|
+
this.downloadManager.download(data, this._downloadUrl, this._docFilename);
|
|
12831
13508
|
},
|
|
12832
|
-
async save(
|
|
13509
|
+
async save() {
|
|
12833
13510
|
if (this._saveInProgress) {
|
|
12834
13511
|
return;
|
|
12835
13512
|
}
|
|
@@ -12837,10 +13514,10 @@ const PDFViewerApplication = {
|
|
|
12837
13514
|
await this.pdfScriptingManager.dispatchWillSave();
|
|
12838
13515
|
try {
|
|
12839
13516
|
const data = await this.pdfDocument.saveDocument();
|
|
12840
|
-
this.downloadManager.download(data, this._downloadUrl, this._docFilename
|
|
13517
|
+
this.downloadManager.download(data, this._downloadUrl, this._docFilename);
|
|
12841
13518
|
} catch (reason) {
|
|
12842
13519
|
console.error(`Error when saving the document: ${reason.message}`);
|
|
12843
|
-
await this.download(
|
|
13520
|
+
await this.download();
|
|
12844
13521
|
} finally {
|
|
12845
13522
|
await this.pdfScriptingManager.dispatchDidSave();
|
|
12846
13523
|
this._saveInProgress = false;
|
|
@@ -12855,12 +13532,12 @@ const PDFViewerApplication = {
|
|
|
12855
13532
|
});
|
|
12856
13533
|
}
|
|
12857
13534
|
},
|
|
12858
|
-
async downloadOrSave(
|
|
13535
|
+
async downloadOrSave() {
|
|
12859
13536
|
const {
|
|
12860
13537
|
classList
|
|
12861
13538
|
} = this.appConfig.appContainer;
|
|
12862
13539
|
classList.add("wait");
|
|
12863
|
-
await (this.pdfDocument?.annotationStorage.size > 0 ? this.save(
|
|
13540
|
+
await (this.pdfDocument?.annotationStorage.size > 0 ? this.save() : this.download());
|
|
12864
13541
|
classList.remove("wait");
|
|
12865
13542
|
},
|
|
12866
13543
|
async _documentError(key, moreInfo = null) {
|
|
@@ -13343,10 +14020,9 @@ const PDFViewerApplication = {
|
|
|
13343
14020
|
this.pdfPresentationMode?.request();
|
|
13344
14021
|
},
|
|
13345
14022
|
triggerPrinting() {
|
|
13346
|
-
if (
|
|
13347
|
-
|
|
14023
|
+
if (this.supportsPrinting) {
|
|
14024
|
+
window.print();
|
|
13348
14025
|
}
|
|
13349
|
-
window.print();
|
|
13350
14026
|
},
|
|
13351
14027
|
bindEvents() {
|
|
13352
14028
|
if (this._eventBusAbortController) {
|
|
@@ -13355,14 +14031,18 @@ const PDFViewerApplication = {
|
|
|
13355
14031
|
this._eventBusAbortController = new AbortController();
|
|
13356
14032
|
const {
|
|
13357
14033
|
eventBus,
|
|
14034
|
+
externalServices,
|
|
14035
|
+
pdfDocumentProperties,
|
|
14036
|
+
pdfViewer,
|
|
14037
|
+
preferences,
|
|
13358
14038
|
_eventBusAbortController: {
|
|
13359
14039
|
signal
|
|
13360
14040
|
}
|
|
13361
14041
|
} = this;
|
|
13362
|
-
eventBus._on("resize",
|
|
14042
|
+
eventBus._on("resize", onResize.bind(this), {
|
|
13363
14043
|
signal
|
|
13364
14044
|
});
|
|
13365
|
-
eventBus._on("hashchange",
|
|
14045
|
+
eventBus._on("hashchange", onHashchange.bind(this), {
|
|
13366
14046
|
signal
|
|
13367
14047
|
});
|
|
13368
14048
|
eventBus._on("beforeprint", this.beforePrint.bind(this), {
|
|
@@ -13371,115 +14051,115 @@ const PDFViewerApplication = {
|
|
|
13371
14051
|
eventBus._on("afterprint", this.afterPrint.bind(this), {
|
|
13372
14052
|
signal
|
|
13373
14053
|
});
|
|
13374
|
-
eventBus._on("pagerender",
|
|
14054
|
+
eventBus._on("pagerender", onPageRender.bind(this), {
|
|
13375
14055
|
signal
|
|
13376
14056
|
});
|
|
13377
|
-
eventBus._on("pagerendered",
|
|
14057
|
+
eventBus._on("pagerendered", onPageRendered.bind(this), {
|
|
13378
14058
|
signal
|
|
13379
14059
|
});
|
|
13380
|
-
eventBus._on("updateviewarea",
|
|
14060
|
+
eventBus._on("updateviewarea", onUpdateViewarea.bind(this), {
|
|
13381
14061
|
signal
|
|
13382
14062
|
});
|
|
13383
|
-
eventBus._on("pagechanging",
|
|
14063
|
+
eventBus._on("pagechanging", onPageChanging.bind(this), {
|
|
13384
14064
|
signal
|
|
13385
14065
|
});
|
|
13386
|
-
eventBus._on("scalechanging",
|
|
14066
|
+
eventBus._on("scalechanging", onScaleChanging.bind(this), {
|
|
13387
14067
|
signal
|
|
13388
14068
|
});
|
|
13389
|
-
eventBus._on("rotationchanging",
|
|
14069
|
+
eventBus._on("rotationchanging", onRotationChanging.bind(this), {
|
|
13390
14070
|
signal
|
|
13391
14071
|
});
|
|
13392
|
-
eventBus._on("sidebarviewchanged",
|
|
14072
|
+
eventBus._on("sidebarviewchanged", onSidebarViewChanged.bind(this), {
|
|
13393
14073
|
signal
|
|
13394
14074
|
});
|
|
13395
|
-
eventBus._on("pagemode",
|
|
14075
|
+
eventBus._on("pagemode", onPageMode.bind(this), {
|
|
13396
14076
|
signal
|
|
13397
14077
|
});
|
|
13398
|
-
eventBus._on("namedaction",
|
|
14078
|
+
eventBus._on("namedaction", onNamedAction.bind(this), {
|
|
13399
14079
|
signal
|
|
13400
14080
|
});
|
|
13401
|
-
eventBus._on("presentationmodechanged",
|
|
14081
|
+
eventBus._on("presentationmodechanged", evt => pdfViewer.presentationModeState = evt.state, {
|
|
13402
14082
|
signal
|
|
13403
14083
|
});
|
|
13404
|
-
eventBus._on("presentationmode",
|
|
14084
|
+
eventBus._on("presentationmode", this.requestPresentationMode.bind(this), {
|
|
13405
14085
|
signal
|
|
13406
14086
|
});
|
|
13407
|
-
eventBus._on("switchannotationeditormode",
|
|
14087
|
+
eventBus._on("switchannotationeditormode", evt => pdfViewer.annotationEditorMode = evt, {
|
|
13408
14088
|
signal
|
|
13409
14089
|
});
|
|
13410
|
-
eventBus._on("
|
|
14090
|
+
eventBus._on("print", this.triggerPrinting.bind(this), {
|
|
13411
14091
|
signal
|
|
13412
14092
|
});
|
|
13413
|
-
eventBus._on("
|
|
14093
|
+
eventBus._on("download", this.downloadOrSave.bind(this), {
|
|
13414
14094
|
signal
|
|
13415
14095
|
});
|
|
13416
|
-
eventBus._on("
|
|
14096
|
+
eventBus._on("firstpage", () => this.page = 1, {
|
|
13417
14097
|
signal
|
|
13418
14098
|
});
|
|
13419
|
-
eventBus._on("
|
|
14099
|
+
eventBus._on("lastpage", () => this.page = this.pagesCount, {
|
|
13420
14100
|
signal
|
|
13421
14101
|
});
|
|
13422
|
-
eventBus._on("
|
|
14102
|
+
eventBus._on("nextpage", () => pdfViewer.nextPage(), {
|
|
13423
14103
|
signal
|
|
13424
14104
|
});
|
|
13425
|
-
eventBus._on("
|
|
14105
|
+
eventBus._on("previouspage", () => pdfViewer.previousPage(), {
|
|
13426
14106
|
signal
|
|
13427
14107
|
});
|
|
13428
|
-
eventBus._on("
|
|
14108
|
+
eventBus._on("zoomin", this.zoomIn.bind(this), {
|
|
13429
14109
|
signal
|
|
13430
14110
|
});
|
|
13431
|
-
eventBus._on("
|
|
14111
|
+
eventBus._on("zoomout", this.zoomOut.bind(this), {
|
|
13432
14112
|
signal
|
|
13433
14113
|
});
|
|
13434
|
-
eventBus._on("
|
|
14114
|
+
eventBus._on("zoomreset", this.zoomReset.bind(this), {
|
|
13435
14115
|
signal
|
|
13436
14116
|
});
|
|
13437
|
-
eventBus._on("
|
|
14117
|
+
eventBus._on("pagenumberchanged", onPageNumberChanged.bind(this), {
|
|
13438
14118
|
signal
|
|
13439
14119
|
});
|
|
13440
|
-
eventBus._on("
|
|
14120
|
+
eventBus._on("scalechanged", evt => pdfViewer.currentScaleValue = evt.value, {
|
|
13441
14121
|
signal
|
|
13442
14122
|
});
|
|
13443
|
-
eventBus._on("
|
|
14123
|
+
eventBus._on("rotatecw", this.rotatePages.bind(this, 90), {
|
|
13444
14124
|
signal
|
|
13445
14125
|
});
|
|
13446
|
-
eventBus._on("
|
|
14126
|
+
eventBus._on("rotateccw", this.rotatePages.bind(this, -90), {
|
|
13447
14127
|
signal
|
|
13448
14128
|
});
|
|
13449
|
-
eventBus._on("
|
|
14129
|
+
eventBus._on("optionalcontentconfig", evt => pdfViewer.optionalContentConfigPromise = evt.promise, {
|
|
13450
14130
|
signal
|
|
13451
14131
|
});
|
|
13452
|
-
eventBus._on("
|
|
14132
|
+
eventBus._on("switchscrollmode", evt => pdfViewer.scrollMode = evt.mode, {
|
|
13453
14133
|
signal
|
|
13454
14134
|
});
|
|
13455
|
-
eventBus._on("
|
|
14135
|
+
eventBus._on("scrollmodechanged", onViewerModesChanged.bind(this, "scrollMode"), {
|
|
13456
14136
|
signal
|
|
13457
14137
|
});
|
|
13458
|
-
eventBus._on("
|
|
14138
|
+
eventBus._on("switchspreadmode", evt => pdfViewer.spreadMode = evt.mode, {
|
|
13459
14139
|
signal
|
|
13460
14140
|
});
|
|
13461
|
-
eventBus._on("
|
|
14141
|
+
eventBus._on("spreadmodechanged", onViewerModesChanged.bind(this, "spreadMode"), {
|
|
13462
14142
|
signal
|
|
13463
14143
|
});
|
|
13464
|
-
eventBus._on("
|
|
14144
|
+
eventBus._on("imagealttextsettings", onImageAltTextSettings.bind(this), {
|
|
13465
14145
|
signal
|
|
13466
14146
|
});
|
|
13467
|
-
eventBus._on("documentproperties",
|
|
14147
|
+
eventBus._on("documentproperties", () => pdfDocumentProperties?.open(), {
|
|
13468
14148
|
signal
|
|
13469
14149
|
});
|
|
13470
|
-
eventBus._on("findfromurlhash",
|
|
14150
|
+
eventBus._on("findfromurlhash", onFindFromUrlHash.bind(this), {
|
|
13471
14151
|
signal
|
|
13472
14152
|
});
|
|
13473
|
-
eventBus._on("updatefindmatchescount",
|
|
14153
|
+
eventBus._on("updatefindmatchescount", onUpdateFindMatchesCount.bind(this), {
|
|
13474
14154
|
signal
|
|
13475
14155
|
});
|
|
13476
|
-
eventBus._on("updatefindcontrolstate",
|
|
14156
|
+
eventBus._on("updatefindcontrolstate", onUpdateFindControlState.bind(this), {
|
|
13477
14157
|
signal
|
|
13478
14158
|
});
|
|
13479
|
-
eventBus._on("fileinputchange",
|
|
14159
|
+
eventBus._on("fileinputchange", onFileInputChange.bind(this), {
|
|
13480
14160
|
signal
|
|
13481
14161
|
});
|
|
13482
|
-
eventBus._on("openfile",
|
|
14162
|
+
eventBus._on("openfile", onOpenFile.bind(this), {
|
|
13483
14163
|
signal
|
|
13484
14164
|
});
|
|
13485
14165
|
},
|
|
@@ -13493,13 +14173,14 @@ const PDFViewerApplication = {
|
|
|
13493
14173
|
appConfig: {
|
|
13494
14174
|
mainContainer
|
|
13495
14175
|
},
|
|
14176
|
+
pdfViewer,
|
|
13496
14177
|
_windowAbortController: {
|
|
13497
14178
|
signal
|
|
13498
14179
|
}
|
|
13499
14180
|
} = this;
|
|
13500
14181
|
function addWindowResolutionChange(evt = null) {
|
|
13501
14182
|
if (evt) {
|
|
13502
|
-
|
|
14183
|
+
pdfViewer.refresh();
|
|
13503
14184
|
}
|
|
13504
14185
|
const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
|
|
13505
14186
|
mediaQueryList.addEventListener("change", addWindowResolutionChange, {
|
|
@@ -13508,36 +14189,34 @@ const PDFViewerApplication = {
|
|
|
13508
14189
|
});
|
|
13509
14190
|
}
|
|
13510
14191
|
addWindowResolutionChange();
|
|
13511
|
-
window.addEventListener("wheel",
|
|
14192
|
+
window.addEventListener("wheel", onWheel.bind(this), {
|
|
13512
14193
|
passive: false,
|
|
13513
14194
|
signal
|
|
13514
14195
|
});
|
|
13515
|
-
window.addEventListener("touchstart",
|
|
14196
|
+
window.addEventListener("touchstart", onTouchStart.bind(this), {
|
|
13516
14197
|
passive: false,
|
|
13517
14198
|
signal
|
|
13518
14199
|
});
|
|
13519
|
-
window.addEventListener("touchmove",
|
|
14200
|
+
window.addEventListener("touchmove", onTouchMove.bind(this), {
|
|
13520
14201
|
passive: false,
|
|
13521
14202
|
signal
|
|
13522
14203
|
});
|
|
13523
|
-
window.addEventListener("touchend",
|
|
14204
|
+
window.addEventListener("touchend", onTouchEnd.bind(this), {
|
|
13524
14205
|
passive: false,
|
|
13525
14206
|
signal
|
|
13526
14207
|
});
|
|
13527
|
-
window.addEventListener("click",
|
|
14208
|
+
window.addEventListener("click", onClick.bind(this), {
|
|
13528
14209
|
signal
|
|
13529
14210
|
});
|
|
13530
|
-
window.addEventListener("keydown",
|
|
14211
|
+
window.addEventListener("keydown", onKeyDown.bind(this), {
|
|
13531
14212
|
signal
|
|
13532
14213
|
});
|
|
13533
|
-
window.addEventListener("keyup",
|
|
14214
|
+
window.addEventListener("keyup", onKeyUp.bind(this), {
|
|
13534
14215
|
signal
|
|
13535
14216
|
});
|
|
13536
|
-
window.addEventListener("resize", () => {
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
});
|
|
13540
|
-
}, {
|
|
14217
|
+
window.addEventListener("resize", () => eventBus.dispatch("resize", {
|
|
14218
|
+
source: window
|
|
14219
|
+
}), {
|
|
13541
14220
|
signal
|
|
13542
14221
|
});
|
|
13543
14222
|
window.addEventListener("hashchange", () => {
|
|
@@ -13548,24 +14227,20 @@ const PDFViewerApplication = {
|
|
|
13548
14227
|
}, {
|
|
13549
14228
|
signal
|
|
13550
14229
|
});
|
|
13551
|
-
window.addEventListener("beforeprint", () => {
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
});
|
|
13555
|
-
}, {
|
|
14230
|
+
window.addEventListener("beforeprint", () => eventBus.dispatch("beforeprint", {
|
|
14231
|
+
source: window
|
|
14232
|
+
}), {
|
|
13556
14233
|
signal
|
|
13557
14234
|
});
|
|
13558
|
-
window.addEventListener("afterprint", () => {
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
});
|
|
13562
|
-
}, {
|
|
14235
|
+
window.addEventListener("afterprint", () => eventBus.dispatch("afterprint", {
|
|
14236
|
+
source: window
|
|
14237
|
+
}), {
|
|
13563
14238
|
signal
|
|
13564
14239
|
});
|
|
13565
|
-
window.addEventListener("updatefromsandbox",
|
|
14240
|
+
window.addEventListener("updatefromsandbox", evt => {
|
|
13566
14241
|
eventBus.dispatch("updatefromsandbox", {
|
|
13567
14242
|
source: window,
|
|
13568
|
-
detail:
|
|
14243
|
+
detail: evt.detail
|
|
13569
14244
|
});
|
|
13570
14245
|
}, {
|
|
13571
14246
|
signal
|
|
@@ -13683,33 +14358,46 @@ initCom(PDFViewerApplication);
|
|
|
13683
14358
|
throw ex;
|
|
13684
14359
|
}
|
|
13685
14360
|
};
|
|
14361
|
+
var onFileInputChange = function (evt) {
|
|
14362
|
+
if (this.pdfViewer?.isInPresentationMode) {
|
|
14363
|
+
return;
|
|
14364
|
+
}
|
|
14365
|
+
const file = evt.fileInput.files[0];
|
|
14366
|
+
this.open({
|
|
14367
|
+
url: URL.createObjectURL(file),
|
|
14368
|
+
originalUrl: file.name
|
|
14369
|
+
});
|
|
14370
|
+
};
|
|
14371
|
+
var onOpenFile = function (evt) {
|
|
14372
|
+
this._openFileInput?.click();
|
|
14373
|
+
};
|
|
13686
14374
|
}
|
|
13687
|
-
function
|
|
14375
|
+
function onPageRender({
|
|
13688
14376
|
pageNumber
|
|
13689
14377
|
}) {
|
|
13690
|
-
if (pageNumber ===
|
|
13691
|
-
|
|
14378
|
+
if (pageNumber === this.page) {
|
|
14379
|
+
this.toolbar?.updateLoadingIndicatorState(true);
|
|
13692
14380
|
}
|
|
13693
14381
|
}
|
|
13694
|
-
function
|
|
14382
|
+
function onPageRendered({
|
|
13695
14383
|
pageNumber,
|
|
13696
14384
|
error
|
|
13697
14385
|
}) {
|
|
13698
|
-
if (pageNumber ===
|
|
13699
|
-
|
|
14386
|
+
if (pageNumber === this.page) {
|
|
14387
|
+
this.toolbar?.updateLoadingIndicatorState(false);
|
|
13700
14388
|
}
|
|
13701
|
-
if (
|
|
13702
|
-
const pageView =
|
|
13703
|
-
const thumbnailView =
|
|
14389
|
+
if (this.pdfSidebar?.visibleView === SidebarView.THUMBS) {
|
|
14390
|
+
const pageView = this.pdfViewer.getPageView(pageNumber - 1);
|
|
14391
|
+
const thumbnailView = this.pdfThumbnailViewer?.getThumbnail(pageNumber - 1);
|
|
13704
14392
|
if (pageView) {
|
|
13705
14393
|
thumbnailView?.setImage(pageView);
|
|
13706
14394
|
}
|
|
13707
14395
|
}
|
|
13708
14396
|
if (error) {
|
|
13709
|
-
|
|
14397
|
+
this._otherError("pdfjs-rendering-error", error);
|
|
13710
14398
|
}
|
|
13711
14399
|
}
|
|
13712
|
-
function
|
|
14400
|
+
function onPageMode({
|
|
13713
14401
|
mode
|
|
13714
14402
|
}) {
|
|
13715
14403
|
let view;
|
|
@@ -13734,42 +14422,39 @@ function webViewerPageMode({
|
|
|
13734
14422
|
console.error('Invalid "pagemode" hash parameter: ' + mode);
|
|
13735
14423
|
return;
|
|
13736
14424
|
}
|
|
13737
|
-
|
|
14425
|
+
this.pdfSidebar?.switchView(view, true);
|
|
13738
14426
|
}
|
|
13739
|
-
function
|
|
14427
|
+
function onNamedAction(evt) {
|
|
13740
14428
|
switch (evt.action) {
|
|
13741
14429
|
case "GoToPage":
|
|
13742
|
-
|
|
14430
|
+
this.appConfig.toolbar?.pageNumber.select();
|
|
13743
14431
|
break;
|
|
13744
14432
|
case "Find":
|
|
13745
|
-
if (!
|
|
13746
|
-
|
|
14433
|
+
if (!this.supportsIntegratedFind) {
|
|
14434
|
+
this.findBar?.toggle();
|
|
13747
14435
|
}
|
|
13748
14436
|
break;
|
|
13749
14437
|
case "Print":
|
|
13750
|
-
|
|
14438
|
+
this.triggerPrinting();
|
|
13751
14439
|
break;
|
|
13752
14440
|
case "SaveAs":
|
|
13753
|
-
|
|
14441
|
+
this.downloadOrSave();
|
|
13754
14442
|
break;
|
|
13755
14443
|
}
|
|
13756
14444
|
}
|
|
13757
|
-
function
|
|
13758
|
-
PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
|
|
13759
|
-
}
|
|
13760
|
-
function webViewerSidebarViewChanged({
|
|
14445
|
+
function onSidebarViewChanged({
|
|
13761
14446
|
view
|
|
13762
14447
|
}) {
|
|
13763
|
-
|
|
13764
|
-
if (
|
|
13765
|
-
|
|
14448
|
+
this.pdfRenderingQueue.isThumbnailViewEnabled = view === SidebarView.THUMBS;
|
|
14449
|
+
if (this.isInitialViewSet) {
|
|
14450
|
+
this.store?.set("sidebarView", view).catch(() => {});
|
|
13766
14451
|
}
|
|
13767
14452
|
}
|
|
13768
|
-
function
|
|
14453
|
+
function onUpdateViewarea({
|
|
13769
14454
|
location
|
|
13770
14455
|
}) {
|
|
13771
|
-
if (
|
|
13772
|
-
|
|
14456
|
+
if (this.isInitialViewSet) {
|
|
14457
|
+
this.store?.setMultiple({
|
|
13773
14458
|
page: location.pageNumber,
|
|
13774
14459
|
zoom: location.scale,
|
|
13775
14460
|
scrollLeft: location.left,
|
|
@@ -13777,27 +14462,21 @@ function webViewerUpdateViewarea({
|
|
|
13777
14462
|
rotation: location.rotation
|
|
13778
14463
|
}).catch(() => {});
|
|
13779
14464
|
}
|
|
13780
|
-
if (
|
|
13781
|
-
|
|
13782
|
-
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
|
|
14465
|
+
if (this.appConfig.secondaryToolbar) {
|
|
14466
|
+
this.appConfig.secondaryToolbar.viewBookmarkButton.href = this.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
|
|
13783
14467
|
}
|
|
13784
14468
|
}
|
|
13785
|
-
function
|
|
13786
|
-
if (
|
|
13787
|
-
|
|
14469
|
+
function onViewerModesChanged(name, evt) {
|
|
14470
|
+
if (this.isInitialViewSet && !this.pdfViewer.isInPresentationMode) {
|
|
14471
|
+
this.store?.set(name, evt.mode).catch(() => {});
|
|
13788
14472
|
}
|
|
13789
14473
|
}
|
|
13790
|
-
function
|
|
13791
|
-
if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
|
|
13792
|
-
PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {});
|
|
13793
|
-
}
|
|
13794
|
-
}
|
|
13795
|
-
function webViewerResize() {
|
|
14474
|
+
function onResize() {
|
|
13796
14475
|
const {
|
|
13797
14476
|
pdfDocument,
|
|
13798
14477
|
pdfViewer,
|
|
13799
14478
|
pdfRenderingQueue
|
|
13800
|
-
} =
|
|
14479
|
+
} = this;
|
|
13801
14480
|
if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
|
|
13802
14481
|
return;
|
|
13803
14482
|
}
|
|
@@ -13810,100 +14489,36 @@ function webViewerResize() {
|
|
|
13810
14489
|
}
|
|
13811
14490
|
pdfViewer.update();
|
|
13812
14491
|
}
|
|
13813
|
-
function
|
|
14492
|
+
function onHashchange(evt) {
|
|
13814
14493
|
const hash = evt.hash;
|
|
13815
14494
|
if (!hash) {
|
|
13816
14495
|
return;
|
|
13817
14496
|
}
|
|
13818
|
-
if (!
|
|
13819
|
-
|
|
13820
|
-
} else if (!
|
|
13821
|
-
|
|
14497
|
+
if (!this.isInitialViewSet) {
|
|
14498
|
+
this.initialBookmark = hash;
|
|
14499
|
+
} else if (!this.pdfHistory?.popStateInProgress) {
|
|
14500
|
+
this.pdfLinkService.setHash(hash);
|
|
13822
14501
|
}
|
|
13823
14502
|
}
|
|
13824
|
-
{
|
|
13825
|
-
|
|
13826
|
-
|
|
13827
|
-
|
|
13828
|
-
}
|
|
13829
|
-
const file = evt.fileInput.files[0];
|
|
13830
|
-
PDFViewerApplication.open({
|
|
13831
|
-
url: URL.createObjectURL(file),
|
|
13832
|
-
originalUrl: file.name
|
|
13833
|
-
});
|
|
13834
|
-
};
|
|
13835
|
-
var webViewerOpenFile = function (evt) {
|
|
13836
|
-
PDFViewerApplication._openFileInput?.click();
|
|
13837
|
-
};
|
|
13838
|
-
}
|
|
13839
|
-
function webViewerPresentationMode() {
|
|
13840
|
-
PDFViewerApplication.requestPresentationMode();
|
|
13841
|
-
}
|
|
13842
|
-
function webViewerSwitchAnnotationEditorMode(evt) {
|
|
13843
|
-
PDFViewerApplication.pdfViewer.annotationEditorMode = evt;
|
|
13844
|
-
}
|
|
13845
|
-
function webViewerSwitchAnnotationEditorParams(evt) {
|
|
13846
|
-
PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
|
|
13847
|
-
}
|
|
13848
|
-
function webViewerPrint() {
|
|
13849
|
-
PDFViewerApplication.triggerPrinting();
|
|
13850
|
-
}
|
|
13851
|
-
function webViewerDownload() {
|
|
13852
|
-
PDFViewerApplication.downloadOrSave();
|
|
13853
|
-
}
|
|
13854
|
-
function webViewerFirstPage() {
|
|
13855
|
-
PDFViewerApplication.page = 1;
|
|
13856
|
-
}
|
|
13857
|
-
function webViewerLastPage() {
|
|
13858
|
-
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
|
13859
|
-
}
|
|
13860
|
-
function webViewerNextPage() {
|
|
13861
|
-
PDFViewerApplication.pdfViewer.nextPage();
|
|
13862
|
-
}
|
|
13863
|
-
function webViewerPreviousPage() {
|
|
13864
|
-
PDFViewerApplication.pdfViewer.previousPage();
|
|
13865
|
-
}
|
|
13866
|
-
function webViewerZoomIn() {
|
|
13867
|
-
PDFViewerApplication.zoomIn();
|
|
13868
|
-
}
|
|
13869
|
-
function webViewerZoomOut() {
|
|
13870
|
-
PDFViewerApplication.zoomOut();
|
|
13871
|
-
}
|
|
13872
|
-
function webViewerZoomReset() {
|
|
13873
|
-
PDFViewerApplication.zoomReset();
|
|
13874
|
-
}
|
|
13875
|
-
function webViewerPageNumberChanged(evt) {
|
|
13876
|
-
const pdfViewer = PDFViewerApplication.pdfViewer;
|
|
14503
|
+
function onPageNumberChanged(evt) {
|
|
14504
|
+
const {
|
|
14505
|
+
pdfViewer
|
|
14506
|
+
} = this;
|
|
13877
14507
|
if (evt.value !== "") {
|
|
13878
|
-
|
|
14508
|
+
this.pdfLinkService.goToPage(evt.value);
|
|
13879
14509
|
}
|
|
13880
14510
|
if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
|
|
13881
|
-
|
|
14511
|
+
this.toolbar?.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
|
|
13882
14512
|
}
|
|
13883
14513
|
}
|
|
13884
|
-
function
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
}
|
|
13890
|
-
function webViewerRotateCcw() {
|
|
13891
|
-
PDFViewerApplication.rotatePages(-90);
|
|
13892
|
-
}
|
|
13893
|
-
function webViewerOptionalContentConfig(evt) {
|
|
13894
|
-
PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
|
|
13895
|
-
}
|
|
13896
|
-
function webViewerSwitchScrollMode(evt) {
|
|
13897
|
-
PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
|
|
13898
|
-
}
|
|
13899
|
-
function webViewerSwitchSpreadMode(evt) {
|
|
13900
|
-
PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
|
|
13901
|
-
}
|
|
13902
|
-
function webViewerDocumentProperties() {
|
|
13903
|
-
PDFViewerApplication.pdfDocumentProperties?.open();
|
|
14514
|
+
function onImageAltTextSettings() {
|
|
14515
|
+
this.imageAltTextSettings?.open({
|
|
14516
|
+
enableGuessAltText: AppOptions.get("enableGuessAltText"),
|
|
14517
|
+
enableNewAltTextWhenAddingImage: AppOptions.get("enableNewAltTextWhenAddingImage")
|
|
14518
|
+
});
|
|
13904
14519
|
}
|
|
13905
|
-
function
|
|
13906
|
-
|
|
14520
|
+
function onFindFromUrlHash(evt) {
|
|
14521
|
+
this.eventBus.dispatch("find", {
|
|
13907
14522
|
source: evt.source,
|
|
13908
14523
|
type: "",
|
|
13909
14524
|
query: evt.query,
|
|
@@ -13914,24 +14529,24 @@ function webViewerFindFromUrlHash(evt) {
|
|
|
13914
14529
|
matchDiacritics: true
|
|
13915
14530
|
});
|
|
13916
14531
|
}
|
|
13917
|
-
function
|
|
14532
|
+
function onUpdateFindMatchesCount({
|
|
13918
14533
|
matchesCount
|
|
13919
14534
|
}) {
|
|
13920
|
-
if (
|
|
13921
|
-
|
|
14535
|
+
if (this.supportsIntegratedFind) {
|
|
14536
|
+
this.externalServices.updateFindMatchesCount(matchesCount);
|
|
13922
14537
|
} else {
|
|
13923
|
-
|
|
14538
|
+
this.findBar?.updateResultsCount(matchesCount);
|
|
13924
14539
|
}
|
|
13925
14540
|
}
|
|
13926
|
-
function
|
|
14541
|
+
function onUpdateFindControlState({
|
|
13927
14542
|
state,
|
|
13928
14543
|
previous,
|
|
13929
14544
|
entireWord,
|
|
13930
14545
|
matchesCount,
|
|
13931
14546
|
rawQuery
|
|
13932
14547
|
}) {
|
|
13933
|
-
if (
|
|
13934
|
-
|
|
14548
|
+
if (this.supportsIntegratedFind) {
|
|
14549
|
+
this.externalServices.updateFindControlState({
|
|
13935
14550
|
result: state,
|
|
13936
14551
|
findPrevious: previous,
|
|
13937
14552
|
entireWord,
|
|
@@ -13939,104 +14554,97 @@ function webViewerUpdateFindControlState({
|
|
|
13939
14554
|
rawQuery
|
|
13940
14555
|
});
|
|
13941
14556
|
} else {
|
|
13942
|
-
|
|
14557
|
+
this.findBar?.updateUIState(state, previous, matchesCount);
|
|
13943
14558
|
}
|
|
13944
14559
|
}
|
|
13945
|
-
function
|
|
13946
|
-
|
|
13947
|
-
|
|
14560
|
+
function onScaleChanging(evt) {
|
|
14561
|
+
this.toolbar?.setPageScale(evt.presetValue, evt.scale);
|
|
14562
|
+
this.pdfViewer.update();
|
|
13948
14563
|
}
|
|
13949
|
-
function
|
|
13950
|
-
if (
|
|
13951
|
-
|
|
14564
|
+
function onRotationChanging(evt) {
|
|
14565
|
+
if (this.pdfThumbnailViewer) {
|
|
14566
|
+
this.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
|
|
13952
14567
|
}
|
|
13953
|
-
|
|
13954
|
-
|
|
14568
|
+
this.forceRendering();
|
|
14569
|
+
this.pdfViewer.currentPageNumber = evt.pageNumber;
|
|
13955
14570
|
}
|
|
13956
|
-
function
|
|
14571
|
+
function onPageChanging({
|
|
13957
14572
|
pageNumber,
|
|
13958
14573
|
pageLabel
|
|
13959
14574
|
}) {
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
if (
|
|
13963
|
-
|
|
14575
|
+
this.toolbar?.setPageNumber(pageNumber, pageLabel);
|
|
14576
|
+
this.secondaryToolbar?.setPageNumber(pageNumber);
|
|
14577
|
+
if (this.pdfSidebar?.visibleView === SidebarView.THUMBS) {
|
|
14578
|
+
this.pdfThumbnailViewer?.scrollThumbnailIntoView(pageNumber);
|
|
13964
14579
|
}
|
|
13965
|
-
const currentPage =
|
|
13966
|
-
|
|
13967
|
-
}
|
|
13968
|
-
function webViewerResolutionChange(evt) {
|
|
13969
|
-
PDFViewerApplication.pdfViewer.refresh();
|
|
14580
|
+
const currentPage = this.pdfViewer.getPageView(pageNumber - 1);
|
|
14581
|
+
this.toolbar?.updateLoadingIndicatorState(currentPage?.renderingState === RenderingStates.RUNNING);
|
|
13970
14582
|
}
|
|
13971
|
-
function
|
|
14583
|
+
function onWheel(evt) {
|
|
13972
14584
|
const {
|
|
13973
14585
|
pdfViewer,
|
|
13974
14586
|
supportsMouseWheelZoomCtrlKey,
|
|
13975
14587
|
supportsMouseWheelZoomMetaKey,
|
|
13976
14588
|
supportsPinchToZoom
|
|
13977
|
-
} =
|
|
14589
|
+
} = this;
|
|
13978
14590
|
if (pdfViewer.isInPresentationMode) {
|
|
13979
14591
|
return;
|
|
13980
14592
|
}
|
|
13981
14593
|
const deltaMode = evt.deltaMode;
|
|
13982
14594
|
let scaleFactor = Math.exp(-evt.deltaY / 100);
|
|
13983
14595
|
const isBuiltInMac = false;
|
|
13984
|
-
const isPinchToZoom = evt.ctrlKey && !
|
|
14596
|
+
const isPinchToZoom = evt.ctrlKey && !this._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
|
|
13985
14597
|
const origin = [evt.clientX, evt.clientY];
|
|
13986
14598
|
if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
|
|
13987
14599
|
evt.preventDefault();
|
|
13988
|
-
if (
|
|
14600
|
+
if (this._isScrolling || document.visibilityState === "hidden" || this.overlayManager.active) {
|
|
13989
14601
|
return;
|
|
13990
14602
|
}
|
|
13991
14603
|
if (isPinchToZoom && supportsPinchToZoom) {
|
|
13992
|
-
scaleFactor =
|
|
13993
|
-
|
|
14604
|
+
scaleFactor = this._accumulateFactor(pdfViewer.currentScale, scaleFactor, "_wheelUnusedFactor");
|
|
14605
|
+
this.updateZoom(null, scaleFactor, origin);
|
|
13994
14606
|
} else {
|
|
13995
14607
|
const delta = normalizeWheelEventDirection(evt);
|
|
13996
14608
|
let ticks = 0;
|
|
13997
14609
|
if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
|
13998
|
-
|
|
13999
|
-
ticks = Math.sign(delta);
|
|
14000
|
-
} else {
|
|
14001
|
-
ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks");
|
|
14002
|
-
}
|
|
14610
|
+
ticks = Math.abs(delta) >= 1 ? Math.sign(delta) : this._accumulateTicks(delta, "_wheelUnusedTicks");
|
|
14003
14611
|
} else {
|
|
14004
14612
|
const PIXELS_PER_LINE_SCALE = 30;
|
|
14005
|
-
ticks =
|
|
14613
|
+
ticks = this._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
|
|
14006
14614
|
}
|
|
14007
|
-
|
|
14615
|
+
this.updateZoom(ticks, null, origin);
|
|
14008
14616
|
}
|
|
14009
14617
|
}
|
|
14010
14618
|
}
|
|
14011
|
-
function
|
|
14012
|
-
if (
|
|
14619
|
+
function onTouchStart(evt) {
|
|
14620
|
+
if (this.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
|
|
14013
14621
|
return;
|
|
14014
14622
|
}
|
|
14015
14623
|
evt.preventDefault();
|
|
14016
|
-
if (evt.touches.length !== 2 ||
|
|
14017
|
-
|
|
14624
|
+
if (evt.touches.length !== 2 || this.overlayManager.active) {
|
|
14625
|
+
this._touchInfo = null;
|
|
14018
14626
|
return;
|
|
14019
14627
|
}
|
|
14020
14628
|
let [touch0, touch1] = evt.touches;
|
|
14021
14629
|
if (touch0.identifier > touch1.identifier) {
|
|
14022
14630
|
[touch0, touch1] = [touch1, touch0];
|
|
14023
14631
|
}
|
|
14024
|
-
|
|
14632
|
+
this._touchInfo = {
|
|
14025
14633
|
touch0X: touch0.pageX,
|
|
14026
14634
|
touch0Y: touch0.pageY,
|
|
14027
14635
|
touch1X: touch1.pageX,
|
|
14028
14636
|
touch1Y: touch1.pageY
|
|
14029
14637
|
};
|
|
14030
14638
|
}
|
|
14031
|
-
function
|
|
14032
|
-
if (!
|
|
14639
|
+
function onTouchMove(evt) {
|
|
14640
|
+
if (!this._touchInfo || evt.touches.length !== 2) {
|
|
14033
14641
|
return;
|
|
14034
14642
|
}
|
|
14035
14643
|
const {
|
|
14036
14644
|
pdfViewer,
|
|
14037
14645
|
_touchInfo,
|
|
14038
14646
|
supportsPinchToZoom
|
|
14039
|
-
} =
|
|
14647
|
+
} = this;
|
|
14040
14648
|
let [touch0, touch1] = evt.touches;
|
|
14041
14649
|
if (touch0.identifier > touch1.identifier) {
|
|
14042
14650
|
[touch0, touch1] = [touch1, touch0];
|
|
@@ -14095,46 +14703,46 @@ function webViewerTouchMove(evt) {
|
|
|
14095
14703
|
const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
|
|
14096
14704
|
const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
|
|
14097
14705
|
if (supportsPinchToZoom) {
|
|
14098
|
-
const newScaleFactor =
|
|
14099
|
-
|
|
14706
|
+
const newScaleFactor = this._accumulateFactor(pdfViewer.currentScale, distance / pDistance, "_touchUnusedFactor");
|
|
14707
|
+
this.updateZoom(null, newScaleFactor, origin);
|
|
14100
14708
|
} else {
|
|
14101
14709
|
const PIXELS_PER_LINE_SCALE = 30;
|
|
14102
|
-
const ticks =
|
|
14103
|
-
|
|
14710
|
+
const ticks = this._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
|
|
14711
|
+
this.updateZoom(ticks, null, origin);
|
|
14104
14712
|
}
|
|
14105
14713
|
}
|
|
14106
|
-
function
|
|
14107
|
-
if (!
|
|
14714
|
+
function onTouchEnd(evt) {
|
|
14715
|
+
if (!this._touchInfo) {
|
|
14108
14716
|
return;
|
|
14109
14717
|
}
|
|
14110
14718
|
evt.preventDefault();
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14719
|
+
this._touchInfo = null;
|
|
14720
|
+
this._touchUnusedTicks = 0;
|
|
14721
|
+
this._touchUnusedFactor = 1;
|
|
14114
14722
|
}
|
|
14115
|
-
function
|
|
14116
|
-
if (!
|
|
14723
|
+
function onClick(evt) {
|
|
14724
|
+
if (!this.secondaryToolbar?.isOpen) {
|
|
14117
14725
|
return;
|
|
14118
14726
|
}
|
|
14119
|
-
const appConfig =
|
|
14120
|
-
if (
|
|
14121
|
-
|
|
14727
|
+
const appConfig = this.appConfig;
|
|
14728
|
+
if (this.pdfViewer.containsElement(evt.target) || appConfig.toolbar?.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar?.toggleButton) {
|
|
14729
|
+
this.secondaryToolbar.close();
|
|
14122
14730
|
}
|
|
14123
14731
|
}
|
|
14124
|
-
function
|
|
14732
|
+
function onKeyUp(evt) {
|
|
14125
14733
|
if (evt.key === "Control") {
|
|
14126
|
-
|
|
14734
|
+
this._isCtrlKeyDown = false;
|
|
14127
14735
|
}
|
|
14128
14736
|
}
|
|
14129
|
-
function
|
|
14130
|
-
|
|
14131
|
-
if (
|
|
14737
|
+
function onKeyDown(evt) {
|
|
14738
|
+
this._isCtrlKeyDown = evt.key === "Control";
|
|
14739
|
+
if (this.overlayManager.active) {
|
|
14132
14740
|
return;
|
|
14133
14741
|
}
|
|
14134
14742
|
const {
|
|
14135
14743
|
eventBus,
|
|
14136
14744
|
pdfViewer
|
|
14137
|
-
} =
|
|
14745
|
+
} = this;
|
|
14138
14746
|
const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
|
|
14139
14747
|
let handled = false,
|
|
14140
14748
|
ensureViewerFocused = false;
|
|
@@ -14142,16 +14750,16 @@ function webViewerKeyDown(evt) {
|
|
|
14142
14750
|
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
|
|
14143
14751
|
switch (evt.keyCode) {
|
|
14144
14752
|
case 70:
|
|
14145
|
-
if (!
|
|
14146
|
-
|
|
14753
|
+
if (!this.supportsIntegratedFind && !evt.shiftKey) {
|
|
14754
|
+
this.findBar?.open();
|
|
14147
14755
|
handled = true;
|
|
14148
14756
|
}
|
|
14149
14757
|
break;
|
|
14150
14758
|
case 71:
|
|
14151
|
-
if (!
|
|
14759
|
+
if (!this.supportsIntegratedFind) {
|
|
14152
14760
|
const {
|
|
14153
14761
|
state
|
|
14154
|
-
} =
|
|
14762
|
+
} = this.findController;
|
|
14155
14763
|
if (state) {
|
|
14156
14764
|
const newState = {
|
|
14157
14765
|
source: window,
|
|
@@ -14170,34 +14778,34 @@ function webViewerKeyDown(evt) {
|
|
|
14170
14778
|
case 107:
|
|
14171
14779
|
case 187:
|
|
14172
14780
|
case 171:
|
|
14173
|
-
|
|
14781
|
+
this.zoomIn();
|
|
14174
14782
|
handled = true;
|
|
14175
14783
|
break;
|
|
14176
14784
|
case 173:
|
|
14177
14785
|
case 109:
|
|
14178
14786
|
case 189:
|
|
14179
|
-
|
|
14787
|
+
this.zoomOut();
|
|
14180
14788
|
handled = true;
|
|
14181
14789
|
break;
|
|
14182
14790
|
case 48:
|
|
14183
14791
|
case 96:
|
|
14184
14792
|
if (!isViewerInPresentationMode) {
|
|
14185
|
-
setTimeout(
|
|
14186
|
-
|
|
14793
|
+
setTimeout(() => {
|
|
14794
|
+
this.zoomReset();
|
|
14187
14795
|
});
|
|
14188
14796
|
handled = false;
|
|
14189
14797
|
}
|
|
14190
14798
|
break;
|
|
14191
14799
|
case 38:
|
|
14192
|
-
if (isViewerInPresentationMode ||
|
|
14193
|
-
|
|
14800
|
+
if (isViewerInPresentationMode || this.page > 1) {
|
|
14801
|
+
this.page = 1;
|
|
14194
14802
|
handled = true;
|
|
14195
14803
|
ensureViewerFocused = true;
|
|
14196
14804
|
}
|
|
14197
14805
|
break;
|
|
14198
14806
|
case 40:
|
|
14199
|
-
if (isViewerInPresentationMode ||
|
|
14200
|
-
|
|
14807
|
+
if (isViewerInPresentationMode || this.page < this.pagesCount) {
|
|
14808
|
+
this.page = this.pagesCount;
|
|
14201
14809
|
handled = true;
|
|
14202
14810
|
ensureViewerFocused = true;
|
|
14203
14811
|
}
|
|
@@ -14225,9 +14833,9 @@ function webViewerKeyDown(evt) {
|
|
|
14225
14833
|
if (cmd === 3 || cmd === 10) {
|
|
14226
14834
|
switch (evt.keyCode) {
|
|
14227
14835
|
case 80:
|
|
14228
|
-
|
|
14836
|
+
this.requestPresentationMode();
|
|
14229
14837
|
handled = true;
|
|
14230
|
-
|
|
14838
|
+
this.externalServices.reportTelemetry({
|
|
14231
14839
|
type: "buttons",
|
|
14232
14840
|
data: {
|
|
14233
14841
|
id: "presentationModeKeyboard"
|
|
@@ -14235,8 +14843,8 @@ function webViewerKeyDown(evt) {
|
|
|
14235
14843
|
});
|
|
14236
14844
|
break;
|
|
14237
14845
|
case 71:
|
|
14238
|
-
if (
|
|
14239
|
-
|
|
14846
|
+
if (this.appConfig.toolbar) {
|
|
14847
|
+
this.appConfig.toolbar.pageNumber.select();
|
|
14240
14848
|
handled = true;
|
|
14241
14849
|
}
|
|
14242
14850
|
break;
|
|
@@ -14261,8 +14869,8 @@ function webViewerKeyDown(evt) {
|
|
|
14261
14869
|
turnOnlyIfPageFit = false;
|
|
14262
14870
|
switch (evt.keyCode) {
|
|
14263
14871
|
case 38:
|
|
14264
|
-
if (
|
|
14265
|
-
|
|
14872
|
+
if (this.supportsCaretBrowsingMode) {
|
|
14873
|
+
this.moveCaret(true, false);
|
|
14266
14874
|
handled = true;
|
|
14267
14875
|
break;
|
|
14268
14876
|
}
|
|
@@ -14279,7 +14887,7 @@ function webViewerKeyDown(evt) {
|
|
|
14279
14887
|
turnPage = -1;
|
|
14280
14888
|
break;
|
|
14281
14889
|
case 37:
|
|
14282
|
-
if (
|
|
14890
|
+
if (this.supportsCaretBrowsingMode) {
|
|
14283
14891
|
return;
|
|
14284
14892
|
}
|
|
14285
14893
|
if (pdfViewer.isHorizontalScrollbarEnabled) {
|
|
@@ -14290,18 +14898,18 @@ function webViewerKeyDown(evt) {
|
|
|
14290
14898
|
turnPage = -1;
|
|
14291
14899
|
break;
|
|
14292
14900
|
case 27:
|
|
14293
|
-
if (
|
|
14294
|
-
|
|
14901
|
+
if (this.secondaryToolbar?.isOpen) {
|
|
14902
|
+
this.secondaryToolbar.close();
|
|
14295
14903
|
handled = true;
|
|
14296
14904
|
}
|
|
14297
|
-
if (!
|
|
14298
|
-
|
|
14905
|
+
if (!this.supportsIntegratedFind && this.findBar?.opened) {
|
|
14906
|
+
this.findBar.close();
|
|
14299
14907
|
handled = true;
|
|
14300
14908
|
}
|
|
14301
14909
|
break;
|
|
14302
14910
|
case 40:
|
|
14303
|
-
if (
|
|
14304
|
-
|
|
14911
|
+
if (this.supportsCaretBrowsingMode) {
|
|
14912
|
+
this.moveCaret(false, false);
|
|
14305
14913
|
handled = true;
|
|
14306
14914
|
break;
|
|
14307
14915
|
}
|
|
@@ -14319,7 +14927,7 @@ function webViewerKeyDown(evt) {
|
|
|
14319
14927
|
turnPage = 1;
|
|
14320
14928
|
break;
|
|
14321
14929
|
case 39:
|
|
14322
|
-
if (
|
|
14930
|
+
if (this.supportsCaretBrowsingMode) {
|
|
14323
14931
|
return;
|
|
14324
14932
|
}
|
|
14325
14933
|
if (pdfViewer.isHorizontalScrollbarEnabled) {
|
|
@@ -14330,30 +14938,30 @@ function webViewerKeyDown(evt) {
|
|
|
14330
14938
|
turnPage = 1;
|
|
14331
14939
|
break;
|
|
14332
14940
|
case 36:
|
|
14333
|
-
if (isViewerInPresentationMode ||
|
|
14334
|
-
|
|
14941
|
+
if (isViewerInPresentationMode || this.page > 1) {
|
|
14942
|
+
this.page = 1;
|
|
14335
14943
|
handled = true;
|
|
14336
14944
|
ensureViewerFocused = true;
|
|
14337
14945
|
}
|
|
14338
14946
|
break;
|
|
14339
14947
|
case 35:
|
|
14340
|
-
if (isViewerInPresentationMode ||
|
|
14341
|
-
|
|
14948
|
+
if (isViewerInPresentationMode || this.page < this.pagesCount) {
|
|
14949
|
+
this.page = this.pagesCount;
|
|
14342
14950
|
handled = true;
|
|
14343
14951
|
ensureViewerFocused = true;
|
|
14344
14952
|
}
|
|
14345
14953
|
break;
|
|
14346
14954
|
case 83:
|
|
14347
|
-
|
|
14955
|
+
this.pdfCursorTools?.switchTool(CursorTool.SELECT);
|
|
14348
14956
|
break;
|
|
14349
14957
|
case 72:
|
|
14350
|
-
|
|
14958
|
+
this.pdfCursorTools?.switchTool(CursorTool.HAND);
|
|
14351
14959
|
break;
|
|
14352
14960
|
case 82:
|
|
14353
|
-
|
|
14961
|
+
this.rotatePages(90);
|
|
14354
14962
|
break;
|
|
14355
14963
|
case 115:
|
|
14356
|
-
|
|
14964
|
+
this.pdfSidebar?.toggle();
|
|
14357
14965
|
break;
|
|
14358
14966
|
}
|
|
14359
14967
|
if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
|
|
@@ -14376,15 +14984,15 @@ function webViewerKeyDown(evt) {
|
|
|
14376
14984
|
handled = true;
|
|
14377
14985
|
break;
|
|
14378
14986
|
case 38:
|
|
14379
|
-
|
|
14987
|
+
this.moveCaret(true, true);
|
|
14380
14988
|
handled = true;
|
|
14381
14989
|
break;
|
|
14382
14990
|
case 40:
|
|
14383
|
-
|
|
14991
|
+
this.moveCaret(false, true);
|
|
14384
14992
|
handled = true;
|
|
14385
14993
|
break;
|
|
14386
14994
|
case 82:
|
|
14387
|
-
|
|
14995
|
+
this.rotatePages(-90);
|
|
14388
14996
|
break;
|
|
14389
14997
|
}
|
|
14390
14998
|
}
|
|
@@ -14405,28 +15013,14 @@ function beforeUnload(evt) {
|
|
|
14405
15013
|
evt.returnValue = "";
|
|
14406
15014
|
return false;
|
|
14407
15015
|
}
|
|
14408
|
-
function webViewerAnnotationEditorStatesChanged(data) {
|
|
14409
|
-
PDFViewerApplication.externalServices.updateEditorStates(data);
|
|
14410
|
-
}
|
|
14411
|
-
function webViewerReportTelemetry({
|
|
14412
|
-
details
|
|
14413
|
-
}) {
|
|
14414
|
-
PDFViewerApplication.externalServices.reportTelemetry(details);
|
|
14415
|
-
}
|
|
14416
|
-
function webViewerSetPreference({
|
|
14417
|
-
name,
|
|
14418
|
-
value
|
|
14419
|
-
}) {
|
|
14420
|
-
PDFViewerApplication.preferences.set(name, value);
|
|
14421
|
-
}
|
|
14422
15016
|
|
|
14423
15017
|
;// CONCATENATED MODULE: ./web/viewer.js
|
|
14424
15018
|
|
|
14425
15019
|
|
|
14426
15020
|
|
|
14427
15021
|
|
|
14428
|
-
const pdfjsVersion = "4.
|
|
14429
|
-
const pdfjsBuild = "
|
|
15022
|
+
const pdfjsVersion = "4.6.82";
|
|
15023
|
+
const pdfjsBuild = "9b541910f";
|
|
14430
15024
|
const AppConstants = {
|
|
14431
15025
|
LinkTarget: LinkTarget,
|
|
14432
15026
|
RenderingStates: RenderingStates,
|
|
@@ -14451,7 +15045,6 @@ function getViewerConfiguration() {
|
|
|
14451
15045
|
next: document.getElementById("next"),
|
|
14452
15046
|
zoomIn: document.getElementById("zoomIn"),
|
|
14453
15047
|
zoomOut: document.getElementById("zoomOut"),
|
|
14454
|
-
viewFind: document.getElementById("viewFind"),
|
|
14455
15048
|
print: document.getElementById("print"),
|
|
14456
15049
|
editorFreeTextButton: document.getElementById("editorFreeText"),
|
|
14457
15050
|
editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
|
|
@@ -14485,6 +15078,8 @@ function getViewerConfiguration() {
|
|
|
14485
15078
|
spreadNoneButton: document.getElementById("spreadNone"),
|
|
14486
15079
|
spreadOddButton: document.getElementById("spreadOdd"),
|
|
14487
15080
|
spreadEvenButton: document.getElementById("spreadEven"),
|
|
15081
|
+
imageAltTextSettingsButton: document.getElementById("imageAltTextSettings"),
|
|
15082
|
+
imageAltTextSettingsSeparator: document.getElementById("imageAltTextSettingsSeparator"),
|
|
14488
15083
|
documentPropertiesButton: document.getElementById("documentProperties")
|
|
14489
15084
|
},
|
|
14490
15085
|
sidebar: {
|
|
@@ -14550,6 +15145,35 @@ function getViewerConfiguration() {
|
|
|
14550
15145
|
cancelButton: document.getElementById("altTextCancel"),
|
|
14551
15146
|
saveButton: document.getElementById("altTextSave")
|
|
14552
15147
|
},
|
|
15148
|
+
newAltTextDialog: {
|
|
15149
|
+
dialog: document.getElementById("newAltTextDialog"),
|
|
15150
|
+
title: document.getElementById("newAltTextTitle"),
|
|
15151
|
+
descriptionContainer: document.getElementById("newAltTextDescriptionContainer"),
|
|
15152
|
+
textarea: document.getElementById("newAltTextDescriptionTextarea"),
|
|
15153
|
+
disclaimer: document.getElementById("newAltTextDisclaimer"),
|
|
15154
|
+
learnMore: document.getElementById("newAltTextLearnMore"),
|
|
15155
|
+
imagePreview: document.getElementById("newAltTextImagePreview"),
|
|
15156
|
+
createAutomatically: document.getElementById("newAltTextCreateAutomatically"),
|
|
15157
|
+
createAutomaticallyButton: document.getElementById("newAltTextCreateAutomaticallyButton"),
|
|
15158
|
+
downloadModel: document.getElementById("newAltTextDownloadModel"),
|
|
15159
|
+
downloadModelDescription: document.getElementById("newAltTextDownloadModelDescription"),
|
|
15160
|
+
error: document.getElementById("newAltTextError"),
|
|
15161
|
+
errorCloseButton: document.getElementById("newAltTextCloseButton"),
|
|
15162
|
+
cancelButton: document.getElementById("newAltTextCancel"),
|
|
15163
|
+
notNowButton: document.getElementById("newAltTextNotNow"),
|
|
15164
|
+
saveButton: document.getElementById("newAltTextSave")
|
|
15165
|
+
},
|
|
15166
|
+
altTextSettingsDialog: {
|
|
15167
|
+
dialog: document.getElementById("altTextSettingsDialog"),
|
|
15168
|
+
createModelButton: document.getElementById("createModelButton"),
|
|
15169
|
+
aiModelSettings: document.getElementById("aiModelSettings"),
|
|
15170
|
+
learnMore: document.getElementById("altTextSettingsLearnMore"),
|
|
15171
|
+
deleteModelButton: document.getElementById("deleteModelButton"),
|
|
15172
|
+
downloadModelButton: document.getElementById("downloadModelButton"),
|
|
15173
|
+
showAltTextDialogButton: document.getElementById("showAltTextDialogButton"),
|
|
15174
|
+
altTextSettingsCloseButton: document.getElementById("altTextSettingsCloseButton"),
|
|
15175
|
+
closeButton: document.getElementById("altTextSettingsCloseButton")
|
|
15176
|
+
},
|
|
14553
15177
|
annotationEditorParams: {
|
|
14554
15178
|
editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
|
|
14555
15179
|
editorFreeTextColor: document.getElementById("editorFreeTextColor"),
|