@4tw/vue-cli-plugin-pdfjs-viewer 1.6.0 → 1.7.0

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.
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * JavaScript code in this page
4
4
  *
5
- * Copyright 2023 Mozilla Foundation
5
+ * Copyright 2024 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -446,7 +446,7 @@ class ProgressBar {
446
446
  }
447
447
  }
448
448
  setDisableAutoFetch(delay = 5000) {
449
- if (isNaN(this.#percent)) {
449
+ if (this.#percent === 100 || isNaN(this.#percent)) {
450
450
  return;
451
451
  }
452
452
  if (this.#disableAutoFetchTimeout) {
@@ -535,15 +535,20 @@ function toggleExpandedBtn(button, toggle, view = null) {
535
535
 
536
536
  ;// CONCATENATED MODULE: ./web/app_options.js
537
537
  {
538
- var compatibilityParams = Object.create(null);
538
+ var compatParams = new Map();
539
539
  const userAgent = navigator.userAgent || "";
540
540
  const platform = navigator.platform || "";
541
541
  const maxTouchPoints = navigator.maxTouchPoints || 1;
542
542
  const isAndroid = /Android/.test(userAgent);
543
543
  const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
544
- (function checkCanvasSizeLimitation() {
544
+ (function () {
545
545
  if (isIOS || isAndroid) {
546
- compatibilityParams.maxCanvasPixels = 5242880;
546
+ compatParams.set("maxCanvasPixels", 5242880);
547
+ }
548
+ })();
549
+ (function () {
550
+ if (isAndroid) {
551
+ compatParams.set("useSystemFonts", false);
547
552
  }
548
553
  })();
549
554
  }
@@ -552,9 +557,21 @@ const OptionKind = {
552
557
  VIEWER: 0x02,
553
558
  API: 0x04,
554
559
  WORKER: 0x08,
560
+ EVENT_DISPATCH: 0x10,
555
561
  PREFERENCE: 0x80
556
562
  };
563
+ const Type = {
564
+ BOOLEAN: 0x01,
565
+ NUMBER: 0x02,
566
+ OBJECT: 0x04,
567
+ STRING: 0x08,
568
+ UNDEFINED: 0x10
569
+ };
557
570
  const defaultOptions = {
571
+ allowedGlobalEvents: {
572
+ value: null,
573
+ kind: OptionKind.BROWSER
574
+ },
558
575
  canvasMaxAreaInBytes: {
559
576
  value: -1,
560
577
  kind: OptionKind.BROWSER + OptionKind.API
@@ -563,6 +580,16 @@ const defaultOptions = {
563
580
  value: false,
564
581
  kind: OptionKind.BROWSER
565
582
  },
583
+ localeProperties: {
584
+ value: {
585
+ lang: navigator.language || "en-US"
586
+ },
587
+ kind: OptionKind.BROWSER
588
+ },
589
+ nimbusDataStr: {
590
+ value: "",
591
+ kind: OptionKind.BROWSER
592
+ },
566
593
  supportsCaretBrowsingMode: {
567
594
  value: false,
568
595
  kind: OptionKind.BROWSER
@@ -587,6 +614,14 @@ const defaultOptions = {
587
614
  value: true,
588
615
  kind: OptionKind.BROWSER
589
616
  },
617
+ toolbarDensity: {
618
+ value: 0,
619
+ kind: OptionKind.BROWSER + OptionKind.EVENT_DISPATCH
620
+ },
621
+ altTextLearnMoreUrl: {
622
+ value: "",
623
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
624
+ },
590
625
  annotationEditorMode: {
591
626
  value: 0,
592
627
  kind: OptionKind.VIEWER + OptionKind.PREFERENCE
@@ -619,15 +654,19 @@ const defaultOptions = {
619
654
  value: false,
620
655
  kind: OptionKind.VIEWER + OptionKind.PREFERENCE
621
656
  },
622
- enableHighlightEditor: {
657
+ enableAltText: {
623
658
  value: false,
624
659
  kind: OptionKind.VIEWER + OptionKind.PREFERENCE
625
660
  },
626
- enableHighlightFloatingButton: {
661
+ enableGuessAltText: {
662
+ value: true,
663
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
664
+ },
665
+ enableHighlightEditor: {
627
666
  value: false,
628
667
  kind: OptionKind.VIEWER + OptionKind.PREFERENCE
629
668
  },
630
- enableML: {
669
+ enableHighlightFloatingButton: {
631
670
  value: false,
632
671
  kind: OptionKind.VIEWER + OptionKind.PREFERENCE
633
672
  },
@@ -643,8 +682,8 @@ const defaultOptions = {
643
682
  value: true,
644
683
  kind: OptionKind.VIEWER + OptionKind.PREFERENCE
645
684
  },
646
- enableStampEditor: {
647
- value: true,
685
+ enableUpdatedAddImage: {
686
+ value: false,
648
687
  kind: OptionKind.VIEWER + OptionKind.PREFERENCE
649
688
  },
650
689
  externalLinkRel: {
@@ -775,6 +814,11 @@ const defaultOptions = {
775
814
  value: "../web/standard_fonts/",
776
815
  kind: OptionKind.API
777
816
  },
817
+ useSystemFonts: {
818
+ value: undefined,
819
+ kind: OptionKind.API,
820
+ type: Type.BOOLEAN + Type.UNDEFINED
821
+ },
778
822
  verbosity: {
779
823
  value: 1,
780
824
  kind: OptionKind.API
@@ -807,62 +851,80 @@ const defaultOptions = {
807
851
  value: false,
808
852
  kind: OptionKind.VIEWER
809
853
  };
810
- defaultOptions.locale = {
811
- value: navigator.language || "en-US",
812
- kind: OptionKind.VIEWER
813
- };
814
854
  }
815
- const userOptions = Object.create(null);
855
+ const userOptions = new Map();
816
856
  {
817
- for (const name in compatibilityParams) {
818
- userOptions[name] = compatibilityParams[name];
857
+ for (const [name, value] of compatParams) {
858
+ userOptions.set(name, value);
819
859
  }
820
860
  }
821
861
  class AppOptions {
862
+ static eventBus;
822
863
  constructor() {
823
864
  throw new Error("Cannot initialize AppOptions.");
824
865
  }
825
866
  static get(name) {
826
- return userOptions[name] ?? defaultOptions[name]?.value ?? undefined;
867
+ return userOptions.has(name) ? userOptions.get(name) : defaultOptions[name]?.value;
827
868
  }
828
869
  static getAll(kind = null, defaultOnly = false) {
829
870
  const options = Object.create(null);
830
871
  for (const name in defaultOptions) {
831
- const defaultOption = defaultOptions[name];
832
- if (kind && !(kind & defaultOption.kind)) {
872
+ const defaultOpt = defaultOptions[name];
873
+ if (kind && !(kind & defaultOpt.kind)) {
833
874
  continue;
834
875
  }
835
- options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? defaultOption.value;
876
+ options[name] = !defaultOnly && userOptions.has(name) ? userOptions.get(name) : defaultOpt.value;
836
877
  }
837
878
  return options;
838
879
  }
839
880
  static set(name, value) {
840
- userOptions[name] = value;
881
+ this.setAll({
882
+ [name]: value
883
+ });
841
884
  }
842
- static setAll(options, init = false) {
843
- if (init) {
844
- if (this.get("disablePreferences")) {
845
- return;
885
+ static setAll(options, prefs = false) {
886
+ let events;
887
+ for (const name in options) {
888
+ const defaultOpt = defaultOptions[name],
889
+ userOpt = options[name];
890
+ if (!defaultOpt || !(typeof userOpt === typeof defaultOpt.value || Type[(typeof userOpt).toUpperCase()] & defaultOpt.type)) {
891
+ continue;
846
892
  }
847
- for (const name in userOptions) {
848
- if (compatibilityParams[name] !== undefined) {
849
- continue;
850
- }
851
- console.warn("setAll: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
852
- break;
893
+ const {
894
+ kind
895
+ } = defaultOpt;
896
+ if (prefs && !(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) {
897
+ continue;
898
+ }
899
+ if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
900
+ (events ||= new Map()).set(name, userOpt);
853
901
  }
902
+ userOptions.set(name, userOpt);
854
903
  }
855
- for (const name in options) {
856
- userOptions[name] = options[name];
904
+ if (events) {
905
+ for (const [name, value] of events) {
906
+ this.eventBus.dispatch(name.toLowerCase(), {
907
+ source: this,
908
+ value
909
+ });
910
+ }
857
911
  }
858
912
  }
859
- static remove(name) {
860
- delete userOptions[name];
861
- const val = compatibilityParams[name];
862
- if (val !== undefined) {
863
- userOptions[name] = val;
913
+ }
914
+ {
915
+ AppOptions._checkDisablePreferences = () => {
916
+ if (AppOptions.get("disablePreferences")) {
917
+ return true;
864
918
  }
865
- }
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
+ };
866
928
  }
867
929
 
868
930
  ;// CONCATENATED MODULE: ./web/pdf_link_service.js
@@ -1171,26 +1233,27 @@ class PDFLinkService {
1171
1233
  if (!(typeof zoom === "object" && typeof zoom?.name === "string")) {
1172
1234
  return false;
1173
1235
  }
1236
+ const argsLen = args.length;
1174
1237
  let allowNull = true;
1175
1238
  switch (zoom.name) {
1176
1239
  case "XYZ":
1177
- if (args.length !== 3) {
1240
+ if (argsLen < 2 || argsLen > 3) {
1178
1241
  return false;
1179
1242
  }
1180
1243
  break;
1181
1244
  case "Fit":
1182
1245
  case "FitB":
1183
- return args.length === 0;
1246
+ return argsLen === 0;
1184
1247
  case "FitH":
1185
1248
  case "FitBH":
1186
1249
  case "FitV":
1187
1250
  case "FitBV":
1188
- if (args.length !== 1) {
1251
+ if (argsLen > 1) {
1189
1252
  return false;
1190
1253
  }
1191
1254
  break;
1192
1255
  case "FitR":
1193
- if (args.length !== 4) {
1256
+ if (argsLen !== 4) {
1194
1257
  return false;
1195
1258
  }
1196
1259
  allowNull = false;
@@ -1240,7 +1303,6 @@ const {
1240
1303
  noContextMenu,
1241
1304
  normalizeUnicode,
1242
1305
  OPS,
1243
- Outliner,
1244
1306
  PasswordResponses,
1245
1307
  PDFDataRangeTransport,
1246
1308
  PDFDateString,
@@ -1248,12 +1310,10 @@ const {
1248
1310
  PermissionFlag,
1249
1311
  PixelsPerInch,
1250
1312
  RenderingCancelledException,
1251
- renderTextLayer,
1252
1313
  setLayerDimensions,
1253
1314
  shadow,
1254
1315
  TextLayer,
1255
1316
  UnexpectedResponseException,
1256
- updateTextLayer,
1257
1317
  Util,
1258
1318
  VerbosityLevel,
1259
1319
  version,
@@ -1401,40 +1461,28 @@ class BaseExternalServices {
1401
1461
  updateEditorStates(data) {
1402
1462
  throw new Error("Not implemented: updateEditorStates");
1403
1463
  }
1404
- async getNimbusExperimentData() {}
1405
- async getGlobalEventNames() {
1406
- return null;
1407
- }
1408
1464
  dispatchGlobalEvent(_event) {}
1409
1465
  }
1410
1466
 
1411
1467
  ;// CONCATENATED MODULE: ./web/preferences.js
1412
1468
 
1413
1469
  class BasePreferences {
1414
- #browserDefaults = Object.freeze({
1415
- canvasMaxAreaInBytes: -1,
1416
- isInAutomation: false,
1417
- supportsCaretBrowsingMode: false,
1418
- supportsDocumentFonts: true,
1419
- supportsIntegratedFind: false,
1420
- supportsMouseWheelZoomCtrlKey: true,
1421
- supportsMouseWheelZoomMetaKey: true,
1422
- supportsPinchToZoom: true
1423
- });
1424
1470
  #defaults = Object.freeze({
1471
+ altTextLearnMoreUrl: "",
1425
1472
  annotationEditorMode: 0,
1426
1473
  annotationMode: 2,
1427
1474
  cursorToolOnLoad: 0,
1428
1475
  defaultZoomDelay: 400,
1429
1476
  defaultZoomValue: "",
1430
1477
  disablePageLabels: false,
1478
+ enableAltText: false,
1479
+ enableGuessAltText: true,
1431
1480
  enableHighlightEditor: false,
1432
1481
  enableHighlightFloatingButton: false,
1433
- enableML: false,
1434
1482
  enablePermissions: false,
1435
1483
  enablePrintAutoRotate: true,
1436
1484
  enableScripting: true,
1437
- enableStampEditor: true,
1485
+ enableUpdatedAddImage: false,
1438
1486
  externalLinkTarget: 0,
1439
1487
  highlightEditorColors: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
1440
1488
  historyUpdateUrl: false,
@@ -1456,7 +1504,6 @@ class BasePreferences {
1456
1504
  enableXfa: true,
1457
1505
  viewerCssTheme: 0
1458
1506
  });
1459
- #prefs = Object.create(null);
1460
1507
  #initializedPromise = null;
1461
1508
  constructor() {
1462
1509
  if (this.constructor === BasePreferences) {
@@ -1466,16 +1513,13 @@ class BasePreferences {
1466
1513
  browserPrefs,
1467
1514
  prefs
1468
1515
  }) => {
1469
- const options = Object.create(null);
1470
- for (const [name, val] of Object.entries(this.#browserDefaults)) {
1471
- const prefVal = browserPrefs?.[name];
1472
- options[name] = typeof prefVal === typeof val ? prefVal : val;
1473
- }
1474
- for (const [name, val] of Object.entries(this.#defaults)) {
1475
- const prefVal = prefs?.[name];
1476
- options[name] = this.#prefs[name] = typeof prefVal === typeof val ? prefVal : val;
1516
+ if (AppOptions._checkDisablePreferences()) {
1517
+ return;
1477
1518
  }
1478
- AppOptions.setAll(options, true);
1519
+ AppOptions.setAll({
1520
+ ...browserPrefs,
1521
+ ...prefs
1522
+ }, true);
1479
1523
  });
1480
1524
  }
1481
1525
  async _writeToStorage(prefObj) {
@@ -1484,58 +1528,21 @@ class BasePreferences {
1484
1528
  async _readFromStorage(prefObj) {
1485
1529
  throw new Error("Not implemented: _readFromStorage");
1486
1530
  }
1487
- #updatePref({
1488
- name,
1489
- value
1490
- }) {
1491
- throw new Error("Not implemented: #updatePref");
1492
- }
1493
1531
  async reset() {
1494
1532
  await this.#initializedPromise;
1495
- const oldPrefs = structuredClone(this.#prefs);
1496
- this.#prefs = Object.create(null);
1497
- try {
1498
- await this._writeToStorage(this.#defaults);
1499
- } catch (reason) {
1500
- this.#prefs = oldPrefs;
1501
- throw reason;
1502
- }
1533
+ AppOptions.setAll(this.#defaults, true);
1534
+ await this._writeToStorage(this.#defaults);
1503
1535
  }
1504
1536
  async set(name, value) {
1505
1537
  await this.#initializedPromise;
1506
- const defaultValue = this.#defaults[name],
1507
- oldPrefs = structuredClone(this.#prefs);
1508
- if (defaultValue === undefined) {
1509
- throw new Error(`Set preference: "${name}" is undefined.`);
1510
- } else if (value === undefined) {
1511
- throw new Error("Set preference: no value is specified.");
1512
- }
1513
- const valueType = typeof value,
1514
- defaultType = typeof defaultValue;
1515
- if (valueType !== defaultType) {
1516
- if (valueType === "number" && defaultType === "string") {
1517
- value = value.toString();
1518
- } else {
1519
- throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
1520
- }
1521
- } else if (valueType === "number" && !Number.isInteger(value)) {
1522
- throw new Error(`Set preference: "${value}" must be an integer.`);
1523
- }
1524
- this.#prefs[name] = value;
1525
- try {
1526
- await this._writeToStorage(this.#prefs);
1527
- } catch (reason) {
1528
- this.#prefs = oldPrefs;
1529
- throw reason;
1530
- }
1538
+ AppOptions.setAll({
1539
+ [name]: value
1540
+ }, true);
1541
+ await this._writeToStorage(AppOptions.getAll(OptionKind.PREFERENCE));
1531
1542
  }
1532
1543
  async get(name) {
1533
1544
  await this.#initializedPromise;
1534
- const defaultValue = this.#defaults[name];
1535
- if (defaultValue === undefined) {
1536
- throw new Error(`Get preference: "${name}" is undefined.`);
1537
- }
1538
- return this.#prefs[name] ?? defaultValue;
1545
+ return AppOptions.get(name);
1539
1546
  }
1540
1547
  get initializedPromise() {
1541
1548
  return this.#initializedPromise;
@@ -3098,13 +3105,19 @@ class Preferences extends BasePreferences {
3098
3105
  }
3099
3106
  class ExternalServices extends BaseExternalServices {
3100
3107
  async createL10n() {
3101
- return new genericl10n_GenericL10n(AppOptions.get("locale"));
3108
+ return new genericl10n_GenericL10n(AppOptions.get("localeProperties")?.lang);
3102
3109
  }
3103
3110
  createScripting() {
3104
3111
  return new GenericScripting(AppOptions.get("sandboxBundleSrc"));
3105
3112
  }
3106
3113
  }
3107
3114
  class MLManager {
3115
+ async isEnabledFor(_name) {
3116
+ return false;
3117
+ }
3118
+ async deleteModel(_service) {
3119
+ return null;
3120
+ }
3108
3121
  async guess() {
3109
3122
  return null;
3110
3123
  }
@@ -8411,6 +8424,9 @@ class AnnotationLayerBuilder {
8411
8424
  }
8412
8425
  this.div.hidden = true;
8413
8426
  }
8427
+ hasEditableAnnotations() {
8428
+ return !!this.annotationLayer?.hasEditableAnnotations();
8429
+ }
8414
8430
  #updatePresentationModeState(state) {
8415
8431
  if (!this.div) {
8416
8432
  return;
@@ -9142,6 +9158,7 @@ class PDFPageView {
9142
9158
  #annotationMode = AnnotationMode.ENABLE_FORMS;
9143
9159
  #enableHWA = false;
9144
9160
  #hasRestrictedScaling = false;
9161
+ #isEditing = false;
9145
9162
  #layerProperties = null;
9146
9163
  #loadingId = null;
9147
9164
  #previousRotation = null;
@@ -9296,6 +9313,9 @@ class PDFPageView {
9296
9313
  this.reset();
9297
9314
  this.pdfPage?.cleanup();
9298
9315
  }
9316
+ hasEditableAnnotations() {
9317
+ return !!this.annotationLayer?.hasEditableAnnotations();
9318
+ }
9299
9319
  get _textHighlighter() {
9300
9320
  return shadow(this, "_textHighlighter", new TextHighlighter({
9301
9321
  pageIndex: this.id - 1,
@@ -9472,6 +9492,19 @@ class PDFPageView {
9472
9492
  this._resetZoomLayer();
9473
9493
  }
9474
9494
  }
9495
+ toggleEditingMode(isEditing) {
9496
+ if (!this.hasEditableAnnotations()) {
9497
+ return;
9498
+ }
9499
+ this.#isEditing = isEditing;
9500
+ this.reset({
9501
+ keepZoomLayer: true,
9502
+ keepAnnotationLayer: true,
9503
+ keepAnnotationEditorLayer: true,
9504
+ keepXfaLayer: true,
9505
+ keepTextLayer: true
9506
+ });
9507
+ }
9475
9508
  update({
9476
9509
  scale = 0,
9477
9510
  rotation = null,
@@ -9822,7 +9855,8 @@ class PDFPageView {
9822
9855
  annotationMode: this.#annotationMode,
9823
9856
  optionalContentConfigPromise: this._optionalContentConfigPromise,
9824
9857
  annotationCanvasMap: this._annotationCanvasMap,
9825
- pageColors
9858
+ pageColors,
9859
+ isEditing: this.#isEditing
9826
9860
  };
9827
9861
  const renderTask = this.renderTask = pdfPage.render(renderContext);
9828
9862
  renderTask.onContinue = renderContinueCallback;
@@ -9982,8 +10016,11 @@ class PDFViewer {
9982
10016
  #enableHWA = false;
9983
10017
  #enableHighlightFloatingButton = false;
9984
10018
  #enablePermissions = false;
10019
+ #enableUpdatedAddImage = false;
9985
10020
  #eventAbortController = null;
9986
10021
  #mlManager = null;
10022
+ #onPageRenderedCallback = null;
10023
+ #switchAnnotationEditorModeTimeoutId = null;
9987
10024
  #getAllTextInProgress = false;
9988
10025
  #hiddenCopyElement = null;
9989
10026
  #interruptCopyCondition = false;
@@ -9993,7 +10030,7 @@ class PDFViewer {
9993
10030
  #scaleTimeoutId = null;
9994
10031
  #textLayerMode = TextLayerMode.ENABLE;
9995
10032
  constructor(options) {
9996
- const viewerVersion = "4.4.168";
10033
+ const viewerVersion = "4.5.136";
9997
10034
  if (version !== viewerVersion) {
9998
10035
  throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
9999
10036
  }
@@ -10020,6 +10057,7 @@ class PDFViewer {
10020
10057
  this.#annotationEditorMode = options.annotationEditorMode ?? AnnotationEditorType.NONE;
10021
10058
  this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
10022
10059
  this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
10060
+ this.#enableUpdatedAddImage = options.enableUpdatedAddImage === true;
10023
10061
  this.imageResourcesPath = options.imageResourcesPath || "";
10024
10062
  this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
10025
10063
  this.removePageBorders = options.removePageBorders || false;
@@ -10425,7 +10463,7 @@ class PDFViewer {
10425
10463
  if (pdfDocument.isPureXfa) {
10426
10464
  console.warn("Warning: XFA-editing is not implemented.");
10427
10465
  } else if (isValidAnnotationEditorMode(mode)) {
10428
- this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#mlManager);
10466
+ this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#enableUpdatedAddImage, this.#mlManager);
10429
10467
  eventBus.dispatch("annotationeditoruimanager", {
10430
10468
  source: this,
10431
10469
  uiManager: this.#annotationEditorUIManager
@@ -10584,6 +10622,7 @@ class PDFViewer {
10584
10622
  this.viewer.removeAttribute("lang");
10585
10623
  this.#hiddenCopyElement?.remove();
10586
10624
  this.#hiddenCopyElement = null;
10625
+ this.#cleanupSwitchAnnotationEditorMode();
10587
10626
  }
10588
10627
  #ensurePageViewVisible() {
10589
10628
  if (this._scrollMode !== ScrollMode.PAGE) {
@@ -10956,6 +10995,34 @@ class PDFViewer {
10956
10995
  location: this._location
10957
10996
  });
10958
10997
  }
10998
+ #switchToEditAnnotationMode() {
10999
+ const visible = this._getVisiblePages();
11000
+ const pagesToRefresh = [];
11001
+ const {
11002
+ ids,
11003
+ views
11004
+ } = visible;
11005
+ for (const page of views) {
11006
+ const {
11007
+ view
11008
+ } = page;
11009
+ if (!view.hasEditableAnnotations()) {
11010
+ ids.delete(view.id);
11011
+ continue;
11012
+ }
11013
+ pagesToRefresh.push(page);
11014
+ }
11015
+ if (pagesToRefresh.length === 0) {
11016
+ return null;
11017
+ }
11018
+ this.renderingQueue.renderHighestPriority({
11019
+ first: pagesToRefresh[0],
11020
+ last: pagesToRefresh.at(-1),
11021
+ views: pagesToRefresh,
11022
+ ids
11023
+ });
11024
+ return ids;
11025
+ }
10959
11026
  containsElement(element) {
10960
11027
  return this.container.contains(element);
10961
11028
  }
@@ -11388,6 +11455,16 @@ class PDFViewer {
11388
11455
  get containerTopLeft() {
11389
11456
  return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
11390
11457
  }
11458
+ #cleanupSwitchAnnotationEditorMode() {
11459
+ if (this.#onPageRenderedCallback) {
11460
+ this.eventBus._off("pagerendered", this.#onPageRenderedCallback);
11461
+ this.#onPageRenderedCallback = null;
11462
+ }
11463
+ if (this.#switchAnnotationEditorModeTimeoutId !== null) {
11464
+ clearTimeout(this.#switchAnnotationEditorModeTimeoutId);
11465
+ this.#switchAnnotationEditorModeTimeoutId = null;
11466
+ }
11467
+ }
11391
11468
  get annotationEditorMode() {
11392
11469
  return this.#annotationEditorUIManager ? this.#annotationEditorMode : AnnotationEditorType.DISABLE;
11393
11470
  }
@@ -11408,12 +11485,47 @@ class PDFViewer {
11408
11485
  if (!this.pdfDocument) {
11409
11486
  return;
11410
11487
  }
11411
- this.#annotationEditorMode = mode;
11412
- this.eventBus.dispatch("annotationeditormodechanged", {
11413
- source: this,
11414
- mode
11415
- });
11416
- this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
11488
+ const {
11489
+ eventBus
11490
+ } = this;
11491
+ const updater = () => {
11492
+ this.#cleanupSwitchAnnotationEditorMode();
11493
+ this.#annotationEditorMode = mode;
11494
+ this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
11495
+ eventBus.dispatch("annotationeditormodechanged", {
11496
+ source: this,
11497
+ mode
11498
+ });
11499
+ };
11500
+ if (mode === AnnotationEditorType.NONE || this.#annotationEditorMode === AnnotationEditorType.NONE) {
11501
+ const isEditing = mode !== AnnotationEditorType.NONE;
11502
+ if (!isEditing) {
11503
+ this.pdfDocument.annotationStorage.resetModifiedIds();
11504
+ }
11505
+ for (const pageView of this._pages) {
11506
+ pageView.toggleEditingMode(isEditing);
11507
+ }
11508
+ const idsToRefresh = this.#switchToEditAnnotationMode();
11509
+ if (isEditing && idsToRefresh) {
11510
+ this.#cleanupSwitchAnnotationEditorMode();
11511
+ this.#onPageRenderedCallback = ({
11512
+ pageNumber
11513
+ }) => {
11514
+ idsToRefresh.delete(pageNumber);
11515
+ if (idsToRefresh.size === 0) {
11516
+ this.#switchAnnotationEditorModeTimeoutId = setTimeout(updater, 0);
11517
+ }
11518
+ };
11519
+ const {
11520
+ signal
11521
+ } = this.#eventAbortController;
11522
+ eventBus._on("pagerendered", this.#onPageRenderedCallback, {
11523
+ signal
11524
+ });
11525
+ return;
11526
+ }
11527
+ }
11528
+ updater();
11417
11529
  }
11418
11530
  set annotationEditorParams({
11419
11531
  type,
@@ -11719,7 +11831,7 @@ class SecondaryToolbar {
11719
11831
 
11720
11832
  class Toolbar {
11721
11833
  #opts;
11722
- constructor(options, eventBus) {
11834
+ constructor(options, eventBus, toolbarDensity = 0) {
11723
11835
  this.#opts = options;
11724
11836
  this.eventBus = eventBus;
11725
11837
  const buttons = [{
@@ -11804,8 +11916,13 @@ class Toolbar {
11804
11916
  break;
11805
11917
  }
11806
11918
  });
11919
+ eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
11920
+ this.#updateToolbarDensity({
11921
+ value: toolbarDensity
11922
+ });
11807
11923
  this.reset();
11808
11924
  }
11925
+ #updateToolbarDensity() {}
11809
11926
  #setAnnotationEditorUIManager(uiManager, parentContainer) {
11810
11927
  const colorPicker = new ColorPicker({
11811
11928
  uiManager
@@ -12074,7 +12191,6 @@ class ViewHistory {
12074
12191
 
12075
12192
 
12076
12193
  const FORCE_PAGES_LOADED_TIMEOUT = 10000;
12077
- const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
12078
12194
  const ViewOnLoad = {
12079
12195
  UNKNOWN: -1,
12080
12196
  PREVIOUS: 0,
@@ -12106,18 +12222,17 @@ const PDFViewerApplication = {
12106
12222
  store: null,
12107
12223
  downloadManager: null,
12108
12224
  overlayManager: null,
12109
- preferences: null,
12225
+ preferences: new Preferences(),
12110
12226
  toolbar: null,
12111
12227
  secondaryToolbar: null,
12112
12228
  eventBus: null,
12113
12229
  l10n: null,
12114
12230
  annotationEditorParams: null,
12115
12231
  isInitialViewSet: false,
12116
- downloadComplete: false,
12117
12232
  isViewerEmbedded: window.parent !== window,
12118
12233
  url: "",
12119
12234
  baseUrl: "",
12120
- _allowedGlobalEventsPromise: null,
12235
+ mlManager: null,
12121
12236
  _downloadUrl: "",
12122
12237
  _eventBusAbortController: null,
12123
12238
  _windowAbortController: null,
@@ -12137,11 +12252,9 @@ const PDFViewerApplication = {
12137
12252
  _printAnnotationStoragePromise: null,
12138
12253
  _touchInfo: null,
12139
12254
  _isCtrlKeyDown: false,
12140
- _nimbusDataPromise: null,
12141
12255
  _caretBrowsing: null,
12142
12256
  _isScrolling: false,
12143
12257
  async initialize(appConfig) {
12144
- let l10nPromise;
12145
12258
  this.appConfig = appConfig;
12146
12259
  try {
12147
12260
  await this.preferences.initializedPromise;
@@ -12163,8 +12276,7 @@ const PDFViewerApplication = {
12163
12276
  if (mode) {
12164
12277
  document.documentElement.classList.add(mode);
12165
12278
  }
12166
- l10nPromise = this.externalServices.createL10n();
12167
- this.l10n = await l10nPromise;
12279
+ this.l10n = await this.externalServices.createL10n();
12168
12280
  document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
12169
12281
  this.l10n.translate(appConfig.appContainer || document.documentElement);
12170
12282
  if (this.isViewerEmbedded && AppOptions.get("externalLinkTarget") === LinkTarget.NONE) {
@@ -12253,7 +12365,9 @@ const PDFViewerApplication = {
12253
12365
  }
12254
12366
  }
12255
12367
  if (params.has("locale")) {
12256
- AppOptions.set("locale", params.get("locale"));
12368
+ AppOptions.set("localeProperties", {
12369
+ lang: params.get("locale")
12370
+ });
12257
12371
  }
12258
12372
  },
12259
12373
  async _initializeViewerComponents() {
@@ -12314,6 +12428,7 @@ const PDFViewerApplication = {
12314
12428
  annotationEditorMode,
12315
12429
  annotationEditorHighlightColors: AppOptions.get("highlightEditorColors"),
12316
12430
  enableHighlightFloatingButton: AppOptions.get("enableHighlightFloatingButton"),
12431
+ enableUpdatedAddImage: AppOptions.get("enableUpdatedAddImage"),
12317
12432
  imageResourcesPath: AppOptions.get("imageResourcesPath"),
12318
12433
  enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
12319
12434
  maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
@@ -12351,9 +12466,6 @@ const PDFViewerApplication = {
12351
12466
  }
12352
12467
  if (appConfig.annotationEditorParams) {
12353
12468
  if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
12354
- if (AppOptions.get("enableStampEditor")) {
12355
- appConfig.toolbar?.editorStampButton?.classList.remove("hidden");
12356
- }
12357
12469
  const editorHighlightButton = appConfig.toolbar?.editorHighlightButton;
12358
12470
  if (editorHighlightButton && AppOptions.get("enableHighlightEditor")) {
12359
12471
  editorHighlightButton.hidden = false;
@@ -12376,7 +12488,7 @@ const PDFViewerApplication = {
12376
12488
  });
12377
12489
  }
12378
12490
  if (appConfig.toolbar) {
12379
- this.toolbar = new Toolbar(appConfig.toolbar, eventBus);
12491
+ this.toolbar = new Toolbar(appConfig.toolbar, eventBus, AppOptions.get("toolbarDensity"));
12380
12492
  }
12381
12493
  if (appConfig.secondaryToolbar) {
12382
12494
  this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
@@ -12433,7 +12545,6 @@ const PDFViewerApplication = {
12433
12545
  }
12434
12546
  },
12435
12547
  async run(config) {
12436
- this.preferences = new Preferences();
12437
12548
  await this.initialize(config);
12438
12549
  const {
12439
12550
  appConfig,
@@ -12510,9 +12621,6 @@ const PDFViewerApplication = {
12510
12621
  get externalServices() {
12511
12622
  return shadow(this, "externalServices", new ExternalServices());
12512
12623
  },
12513
- get mlManager() {
12514
- return shadow(this, "mlManager", AppOptions.get("enableML") === true ? new MLManager() : null);
12515
- },
12516
12624
  get initialized() {
12517
12625
  return this._initializedCapability.settled;
12518
12626
  },
@@ -12593,12 +12701,10 @@ const PDFViewerApplication = {
12593
12701
  let title = pdfjs_getPdfFilenameFromUrl(url, "");
12594
12702
  if (!title) {
12595
12703
  try {
12596
- title = decodeURIComponent(getFilenameFromUrl(url)) || url;
12597
- } catch {
12598
- title = url;
12599
- }
12704
+ title = decodeURIComponent(getFilenameFromUrl(url));
12705
+ } catch {}
12600
12706
  }
12601
- this.setTitle(title);
12707
+ this.setTitle(title || url);
12602
12708
  },
12603
12709
  setTitle(title = this._title) {
12604
12710
  this._title = title;
@@ -12644,7 +12750,6 @@ const PDFViewerApplication = {
12644
12750
  this.pdfLinkService.externalLinkEnabled = true;
12645
12751
  this.store = null;
12646
12752
  this.isInitialViewSet = false;
12647
- this.downloadComplete = false;
12648
12753
  this.url = "";
12649
12754
  this.baseUrl = "";
12650
12755
  this._downloadUrl = "";
@@ -12720,9 +12825,7 @@ const PDFViewerApplication = {
12720
12825
  async download(options = {}) {
12721
12826
  let data;
12722
12827
  try {
12723
- if (this.downloadComplete) {
12724
- data = await this.pdfDocument.getData();
12725
- }
12828
+ data = await this.pdfDocument.getData();
12726
12829
  } catch {}
12727
12830
  this.downloadManager.download(data, this._downloadUrl, this._docFilename, options);
12728
12831
  },
@@ -12789,11 +12892,8 @@ const PDFViewerApplication = {
12789
12892
  return message;
12790
12893
  },
12791
12894
  progress(level) {
12792
- if (!this.loadingBar || this.downloadComplete) {
12793
- return;
12794
- }
12795
12895
  const percent = Math.round(level * 100);
12796
- if (percent <= this.loadingBar.percent) {
12896
+ if (!this.loadingBar || percent <= this.loadingBar.percent) {
12797
12897
  return;
12798
12898
  }
12799
12899
  this.loadingBar.percent = percent;
@@ -12807,7 +12907,6 @@ const PDFViewerApplication = {
12807
12907
  length
12808
12908
  }) => {
12809
12909
  this._contentLength = length;
12810
- this.downloadComplete = true;
12811
12910
  this.loadingBar?.hide();
12812
12911
  firstPagePromise.then(() => {
12813
12912
  this.eventBus.dispatch("documentloaded", {
@@ -13409,9 +13508,6 @@ const PDFViewerApplication = {
13409
13508
  });
13410
13509
  }
13411
13510
  addWindowResolutionChange();
13412
- window.addEventListener("visibilitychange", webViewerVisibilityChange, {
13413
- signal
13414
- });
13415
13511
  window.addEventListener("wheel", webViewerWheel, {
13416
13512
  passive: false,
13417
13513
  signal
@@ -13872,20 +13968,6 @@ function webViewerPageChanging({
13872
13968
  function webViewerResolutionChange(evt) {
13873
13969
  PDFViewerApplication.pdfViewer.refresh();
13874
13970
  }
13875
- function webViewerVisibilityChange(evt) {
13876
- if (document.visibilityState === "visible") {
13877
- setZoomDisabledTimeout();
13878
- }
13879
- }
13880
- let zoomDisabledTimeout = null;
13881
- function setZoomDisabledTimeout() {
13882
- if (zoomDisabledTimeout) {
13883
- clearTimeout(zoomDisabledTimeout);
13884
- }
13885
- zoomDisabledTimeout = setTimeout(function () {
13886
- zoomDisabledTimeout = null;
13887
- }, WHEEL_ZOOM_DISABLED_TIMEOUT);
13888
- }
13889
13971
  function webViewerWheel(evt) {
13890
13972
  const {
13891
13973
  pdfViewer,
@@ -13903,7 +13985,7 @@ function webViewerWheel(evt) {
13903
13985
  const origin = [evt.clientX, evt.clientY];
13904
13986
  if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
13905
13987
  evt.preventDefault();
13906
- if (PDFViewerApplication._isScrolling || zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
13988
+ if (PDFViewerApplication._isScrolling || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
13907
13989
  return;
13908
13990
  }
13909
13991
  if (isPinchToZoom && supportsPinchToZoom) {
@@ -14331,14 +14413,20 @@ function webViewerReportTelemetry({
14331
14413
  }) {
14332
14414
  PDFViewerApplication.externalServices.reportTelemetry(details);
14333
14415
  }
14416
+ function webViewerSetPreference({
14417
+ name,
14418
+ value
14419
+ }) {
14420
+ PDFViewerApplication.preferences.set(name, value);
14421
+ }
14334
14422
 
14335
14423
  ;// CONCATENATED MODULE: ./web/viewer.js
14336
14424
 
14337
14425
 
14338
14426
 
14339
14427
 
14340
- const pdfjsVersion = "4.4.168";
14341
- const pdfjsBuild = "19fbc8998";
14428
+ const pdfjsVersion = "4.5.136";
14429
+ const pdfjsBuild = "3a21f03b0";
14342
14430
  const AppConstants = {
14343
14431
  LinkTarget: LinkTarget,
14344
14432
  RenderingStates: RenderingStates,