mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-10 20:10:00 +00:00
Update pdf.js to 4.5.136
This commit is contained in:
parent
b3d878bae8
commit
2f8db1f7f0
5298
cps/static/js/libs/pdf.mjs
vendored
5298
cps/static/js/libs/pdf.mjs
vendored
File diff suppressed because it is too large
Load Diff
5314
cps/static/js/libs/pdf.worker.mjs
vendored
5314
cps/static/js/libs/pdf.worker.mjs
vendored
File diff suppressed because it is too large
Load Diff
444
cps/static/js/libs/viewer.mjs
vendored
444
cps/static/js/libs/viewer.mjs
vendored
@ -2,7 +2,7 @@
|
|||||||
* @licstart The following is the entire license notice for the
|
* @licstart The following is the entire license notice for the
|
||||||
* JavaScript code in this page
|
* JavaScript code in this page
|
||||||
*
|
*
|
||||||
* Copyright 2023 Mozilla Foundation
|
* Copyright 2024 Mozilla Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -446,7 +446,7 @@ class ProgressBar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setDisableAutoFetch(delay = 5000) {
|
setDisableAutoFetch(delay = 5000) {
|
||||||
if (isNaN(this.#percent)) {
|
if (this.#percent === 100 || isNaN(this.#percent)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.#disableAutoFetchTimeout) {
|
if (this.#disableAutoFetchTimeout) {
|
||||||
@ -535,15 +535,20 @@ function toggleExpandedBtn(button, toggle, view = null) {
|
|||||||
|
|
||||||
;// CONCATENATED MODULE: ./web/app_options.js
|
;// CONCATENATED MODULE: ./web/app_options.js
|
||||||
{
|
{
|
||||||
var compatibilityParams = Object.create(null);
|
var compatParams = new Map();
|
||||||
const userAgent = navigator.userAgent || "";
|
const userAgent = navigator.userAgent || "";
|
||||||
const platform = navigator.platform || "";
|
const platform = navigator.platform || "";
|
||||||
const maxTouchPoints = navigator.maxTouchPoints || 1;
|
const maxTouchPoints = navigator.maxTouchPoints || 1;
|
||||||
const isAndroid = /Android/.test(userAgent);
|
const isAndroid = /Android/.test(userAgent);
|
||||||
const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
|
const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
|
||||||
(function checkCanvasSizeLimitation() {
|
(function () {
|
||||||
if (isIOS || isAndroid) {
|
if (isIOS || isAndroid) {
|
||||||
compatibilityParams.maxCanvasPixels = 5242880;
|
compatParams.set("maxCanvasPixels", 5242880);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
(function () {
|
||||||
|
if (isAndroid) {
|
||||||
|
compatParams.set("useSystemFonts", false);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
@ -552,9 +557,21 @@ const OptionKind = {
|
|||||||
VIEWER: 0x02,
|
VIEWER: 0x02,
|
||||||
API: 0x04,
|
API: 0x04,
|
||||||
WORKER: 0x08,
|
WORKER: 0x08,
|
||||||
|
EVENT_DISPATCH: 0x10,
|
||||||
PREFERENCE: 0x80
|
PREFERENCE: 0x80
|
||||||
};
|
};
|
||||||
|
const Type = {
|
||||||
|
BOOLEAN: 0x01,
|
||||||
|
NUMBER: 0x02,
|
||||||
|
OBJECT: 0x04,
|
||||||
|
STRING: 0x08,
|
||||||
|
UNDEFINED: 0x10
|
||||||
|
};
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
|
allowedGlobalEvents: {
|
||||||
|
value: null,
|
||||||
|
kind: OptionKind.BROWSER
|
||||||
|
},
|
||||||
canvasMaxAreaInBytes: {
|
canvasMaxAreaInBytes: {
|
||||||
value: -1,
|
value: -1,
|
||||||
kind: OptionKind.BROWSER + OptionKind.API
|
kind: OptionKind.BROWSER + OptionKind.API
|
||||||
@ -563,6 +580,16 @@ const defaultOptions = {
|
|||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.BROWSER
|
kind: OptionKind.BROWSER
|
||||||
},
|
},
|
||||||
|
localeProperties: {
|
||||||
|
value: {
|
||||||
|
lang: navigator.language || "en-US"
|
||||||
|
},
|
||||||
|
kind: OptionKind.BROWSER
|
||||||
|
},
|
||||||
|
nimbusDataStr: {
|
||||||
|
value: "",
|
||||||
|
kind: OptionKind.BROWSER
|
||||||
|
},
|
||||||
supportsCaretBrowsingMode: {
|
supportsCaretBrowsingMode: {
|
||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.BROWSER
|
kind: OptionKind.BROWSER
|
||||||
@ -587,6 +614,14 @@ const defaultOptions = {
|
|||||||
value: true,
|
value: true,
|
||||||
kind: OptionKind.BROWSER
|
kind: OptionKind.BROWSER
|
||||||
},
|
},
|
||||||
|
toolbarDensity: {
|
||||||
|
value: 0,
|
||||||
|
kind: OptionKind.BROWSER + OptionKind.EVENT_DISPATCH
|
||||||
|
},
|
||||||
|
altTextLearnMoreUrl: {
|
||||||
|
value: "",
|
||||||
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
|
},
|
||||||
annotationEditorMode: {
|
annotationEditorMode: {
|
||||||
value: 0,
|
value: 0,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
@ -619,6 +654,14 @@ const defaultOptions = {
|
|||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
},
|
},
|
||||||
|
enableAltText: {
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
|
},
|
||||||
|
enableGuessAltText: {
|
||||||
|
value: true,
|
||||||
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
|
},
|
||||||
enableHighlightEditor: {
|
enableHighlightEditor: {
|
||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
@ -627,10 +670,6 @@ const defaultOptions = {
|
|||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
},
|
},
|
||||||
enableML: {
|
|
||||||
value: false,
|
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
|
||||||
},
|
|
||||||
enablePermissions: {
|
enablePermissions: {
|
||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
@ -643,8 +682,8 @@ const defaultOptions = {
|
|||||||
value: true,
|
value: true,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
},
|
},
|
||||||
enableStampEditor: {
|
enableUpdatedAddImage: {
|
||||||
value: true,
|
value: false,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE
|
||||||
},
|
},
|
||||||
externalLinkRel: {
|
externalLinkRel: {
|
||||||
@ -775,6 +814,11 @@ const defaultOptions = {
|
|||||||
value: "../web/standard_fonts/",
|
value: "../web/standard_fonts/",
|
||||||
kind: OptionKind.API
|
kind: OptionKind.API
|
||||||
},
|
},
|
||||||
|
useSystemFonts: {
|
||||||
|
value: undefined,
|
||||||
|
kind: OptionKind.API,
|
||||||
|
type: Type.BOOLEAN + Type.UNDEFINED
|
||||||
|
},
|
||||||
verbosity: {
|
verbosity: {
|
||||||
value: 1,
|
value: 1,
|
||||||
kind: OptionKind.API
|
kind: OptionKind.API
|
||||||
@ -807,62 +851,80 @@ const defaultOptions = {
|
|||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.VIEWER
|
kind: OptionKind.VIEWER
|
||||||
};
|
};
|
||||||
defaultOptions.locale = {
|
|
||||||
value: navigator.language || "en-US",
|
|
||||||
kind: OptionKind.VIEWER
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
const userOptions = Object.create(null);
|
const userOptions = new Map();
|
||||||
{
|
{
|
||||||
for (const name in compatibilityParams) {
|
for (const [name, value] of compatParams) {
|
||||||
userOptions[name] = compatibilityParams[name];
|
userOptions.set(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class AppOptions {
|
class AppOptions {
|
||||||
|
static eventBus;
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error("Cannot initialize AppOptions.");
|
throw new Error("Cannot initialize AppOptions.");
|
||||||
}
|
}
|
||||||
static get(name) {
|
static get(name) {
|
||||||
return userOptions[name] ?? defaultOptions[name]?.value ?? undefined;
|
return userOptions.has(name) ? userOptions.get(name) : defaultOptions[name]?.value;
|
||||||
}
|
}
|
||||||
static getAll(kind = null, defaultOnly = false) {
|
static getAll(kind = null, defaultOnly = false) {
|
||||||
const options = Object.create(null);
|
const options = Object.create(null);
|
||||||
for (const name in defaultOptions) {
|
for (const name in defaultOptions) {
|
||||||
const defaultOption = defaultOptions[name];
|
const defaultOpt = defaultOptions[name];
|
||||||
if (kind && !(kind & defaultOption.kind)) {
|
if (kind && !(kind & defaultOpt.kind)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
options[name] = defaultOnly ? defaultOption.value : userOptions[name] ?? defaultOption.value;
|
options[name] = !defaultOnly && userOptions.has(name) ? userOptions.get(name) : defaultOpt.value;
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
static set(name, value) {
|
static set(name, value) {
|
||||||
userOptions[name] = value;
|
this.setAll({
|
||||||
|
[name]: value
|
||||||
|
});
|
||||||
}
|
}
|
||||||
static setAll(options, init = false) {
|
static setAll(options, prefs = false) {
|
||||||
if (init) {
|
let events;
|
||||||
if (this.get("disablePreferences")) {
|
for (const name in options) {
|
||||||
return;
|
const defaultOpt = defaultOptions[name],
|
||||||
}
|
userOpt = options[name];
|
||||||
for (const name in userOptions) {
|
if (!defaultOpt || !(typeof userOpt === typeof defaultOpt.value || Type[(typeof userOpt).toUpperCase()] & defaultOpt.type)) {
|
||||||
if (compatibilityParams[name] !== undefined) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
console.warn("setAll: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
|
const {
|
||||||
|
kind
|
||||||
|
} = defaultOpt;
|
||||||
|
if (prefs && !(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
|
||||||
|
(events ||= new Map()).set(name, userOpt);
|
||||||
|
}
|
||||||
|
userOptions.set(name, userOpt);
|
||||||
|
}
|
||||||
|
if (events) {
|
||||||
|
for (const [name, value] of events) {
|
||||||
|
this.eventBus.dispatch(name.toLowerCase(), {
|
||||||
|
source: this,
|
||||||
|
value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
AppOptions._checkDisablePreferences = () => {
|
||||||
|
if (AppOptions.get("disablePreferences")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (const [name] of userOptions) {
|
||||||
|
if (compatParams.has(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
console.warn("The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option to prevent that.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
for (const name in options) {
|
};
|
||||||
userOptions[name] = options[name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static remove(name) {
|
|
||||||
delete userOptions[name];
|
|
||||||
const val = compatibilityParams[name];
|
|
||||||
if (val !== undefined) {
|
|
||||||
userOptions[name] = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./web/pdf_link_service.js
|
;// CONCATENATED MODULE: ./web/pdf_link_service.js
|
||||||
@ -1171,26 +1233,27 @@ class PDFLinkService {
|
|||||||
if (!(typeof zoom === "object" && typeof zoom?.name === "string")) {
|
if (!(typeof zoom === "object" && typeof zoom?.name === "string")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const argsLen = args.length;
|
||||||
let allowNull = true;
|
let allowNull = true;
|
||||||
switch (zoom.name) {
|
switch (zoom.name) {
|
||||||
case "XYZ":
|
case "XYZ":
|
||||||
if (args.length !== 3) {
|
if (argsLen < 2 || argsLen > 3) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Fit":
|
case "Fit":
|
||||||
case "FitB":
|
case "FitB":
|
||||||
return args.length === 0;
|
return argsLen === 0;
|
||||||
case "FitH":
|
case "FitH":
|
||||||
case "FitBH":
|
case "FitBH":
|
||||||
case "FitV":
|
case "FitV":
|
||||||
case "FitBV":
|
case "FitBV":
|
||||||
if (args.length !== 1) {
|
if (argsLen > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "FitR":
|
case "FitR":
|
||||||
if (args.length !== 4) {
|
if (argsLen !== 4) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
allowNull = false;
|
allowNull = false;
|
||||||
@ -1240,7 +1303,6 @@ const {
|
|||||||
noContextMenu,
|
noContextMenu,
|
||||||
normalizeUnicode,
|
normalizeUnicode,
|
||||||
OPS,
|
OPS,
|
||||||
Outliner,
|
|
||||||
PasswordResponses,
|
PasswordResponses,
|
||||||
PDFDataRangeTransport,
|
PDFDataRangeTransport,
|
||||||
PDFDateString,
|
PDFDateString,
|
||||||
@ -1248,12 +1310,10 @@ const {
|
|||||||
PermissionFlag,
|
PermissionFlag,
|
||||||
PixelsPerInch,
|
PixelsPerInch,
|
||||||
RenderingCancelledException,
|
RenderingCancelledException,
|
||||||
renderTextLayer,
|
|
||||||
setLayerDimensions,
|
setLayerDimensions,
|
||||||
shadow,
|
shadow,
|
||||||
TextLayer,
|
TextLayer,
|
||||||
UnexpectedResponseException,
|
UnexpectedResponseException,
|
||||||
updateTextLayer,
|
|
||||||
Util,
|
Util,
|
||||||
VerbosityLevel,
|
VerbosityLevel,
|
||||||
version,
|
version,
|
||||||
@ -1401,40 +1461,28 @@ class BaseExternalServices {
|
|||||||
updateEditorStates(data) {
|
updateEditorStates(data) {
|
||||||
throw new Error("Not implemented: updateEditorStates");
|
throw new Error("Not implemented: updateEditorStates");
|
||||||
}
|
}
|
||||||
async getNimbusExperimentData() {}
|
|
||||||
async getGlobalEventNames() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
dispatchGlobalEvent(_event) {}
|
dispatchGlobalEvent(_event) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./web/preferences.js
|
;// CONCATENATED MODULE: ./web/preferences.js
|
||||||
|
|
||||||
class BasePreferences {
|
class BasePreferences {
|
||||||
#browserDefaults = Object.freeze({
|
|
||||||
canvasMaxAreaInBytes: -1,
|
|
||||||
isInAutomation: false,
|
|
||||||
supportsCaretBrowsingMode: false,
|
|
||||||
supportsDocumentFonts: true,
|
|
||||||
supportsIntegratedFind: false,
|
|
||||||
supportsMouseWheelZoomCtrlKey: true,
|
|
||||||
supportsMouseWheelZoomMetaKey: true,
|
|
||||||
supportsPinchToZoom: true
|
|
||||||
});
|
|
||||||
#defaults = Object.freeze({
|
#defaults = Object.freeze({
|
||||||
|
altTextLearnMoreUrl: "",
|
||||||
annotationEditorMode: 0,
|
annotationEditorMode: 0,
|
||||||
annotationMode: 2,
|
annotationMode: 2,
|
||||||
cursorToolOnLoad: 0,
|
cursorToolOnLoad: 0,
|
||||||
defaultZoomDelay: 400,
|
defaultZoomDelay: 400,
|
||||||
defaultZoomValue: "",
|
defaultZoomValue: "",
|
||||||
disablePageLabels: false,
|
disablePageLabels: false,
|
||||||
|
enableAltText: false,
|
||||||
|
enableGuessAltText: true,
|
||||||
enableHighlightEditor: false,
|
enableHighlightEditor: false,
|
||||||
enableHighlightFloatingButton: false,
|
enableHighlightFloatingButton: false,
|
||||||
enableML: false,
|
|
||||||
enablePermissions: false,
|
enablePermissions: false,
|
||||||
enablePrintAutoRotate: true,
|
enablePrintAutoRotate: true,
|
||||||
enableScripting: true,
|
enableScripting: true,
|
||||||
enableStampEditor: true,
|
enableUpdatedAddImage: false,
|
||||||
externalLinkTarget: 0,
|
externalLinkTarget: 0,
|
||||||
highlightEditorColors: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
|
highlightEditorColors: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
|
||||||
historyUpdateUrl: false,
|
historyUpdateUrl: false,
|
||||||
@ -1456,7 +1504,6 @@ class BasePreferences {
|
|||||||
enableXfa: true,
|
enableXfa: true,
|
||||||
viewerCssTheme: 0
|
viewerCssTheme: 0
|
||||||
});
|
});
|
||||||
#prefs = Object.create(null);
|
|
||||||
#initializedPromise = null;
|
#initializedPromise = null;
|
||||||
constructor() {
|
constructor() {
|
||||||
if (this.constructor === BasePreferences) {
|
if (this.constructor === BasePreferences) {
|
||||||
@ -1466,16 +1513,13 @@ class BasePreferences {
|
|||||||
browserPrefs,
|
browserPrefs,
|
||||||
prefs
|
prefs
|
||||||
}) => {
|
}) => {
|
||||||
const options = Object.create(null);
|
if (AppOptions._checkDisablePreferences()) {
|
||||||
for (const [name, val] of Object.entries(this.#browserDefaults)) {
|
return;
|
||||||
const prefVal = browserPrefs?.[name];
|
|
||||||
options[name] = typeof prefVal === typeof val ? prefVal : val;
|
|
||||||
}
|
}
|
||||||
for (const [name, val] of Object.entries(this.#defaults)) {
|
AppOptions.setAll({
|
||||||
const prefVal = prefs?.[name];
|
...browserPrefs,
|
||||||
options[name] = this.#prefs[name] = typeof prefVal === typeof val ? prefVal : val;
|
...prefs
|
||||||
}
|
}, true);
|
||||||
AppOptions.setAll(options, true);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async _writeToStorage(prefObj) {
|
async _writeToStorage(prefObj) {
|
||||||
@ -1484,58 +1528,21 @@ class BasePreferences {
|
|||||||
async _readFromStorage(prefObj) {
|
async _readFromStorage(prefObj) {
|
||||||
throw new Error("Not implemented: _readFromStorage");
|
throw new Error("Not implemented: _readFromStorage");
|
||||||
}
|
}
|
||||||
#updatePref({
|
|
||||||
name,
|
|
||||||
value
|
|
||||||
}) {
|
|
||||||
throw new Error("Not implemented: #updatePref");
|
|
||||||
}
|
|
||||||
async reset() {
|
async reset() {
|
||||||
await this.#initializedPromise;
|
await this.#initializedPromise;
|
||||||
const oldPrefs = structuredClone(this.#prefs);
|
AppOptions.setAll(this.#defaults, true);
|
||||||
this.#prefs = Object.create(null);
|
|
||||||
try {
|
|
||||||
await this._writeToStorage(this.#defaults);
|
await this._writeToStorage(this.#defaults);
|
||||||
} catch (reason) {
|
|
||||||
this.#prefs = oldPrefs;
|
|
||||||
throw reason;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
async set(name, value) {
|
async set(name, value) {
|
||||||
await this.#initializedPromise;
|
await this.#initializedPromise;
|
||||||
const defaultValue = this.#defaults[name],
|
AppOptions.setAll({
|
||||||
oldPrefs = structuredClone(this.#prefs);
|
[name]: value
|
||||||
if (defaultValue === undefined) {
|
}, true);
|
||||||
throw new Error(`Set preference: "${name}" is undefined.`);
|
await this._writeToStorage(AppOptions.getAll(OptionKind.PREFERENCE));
|
||||||
} else if (value === undefined) {
|
|
||||||
throw new Error("Set preference: no value is specified.");
|
|
||||||
}
|
|
||||||
const valueType = typeof value,
|
|
||||||
defaultType = typeof defaultValue;
|
|
||||||
if (valueType !== defaultType) {
|
|
||||||
if (valueType === "number" && defaultType === "string") {
|
|
||||||
value = value.toString();
|
|
||||||
} else {
|
|
||||||
throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
|
|
||||||
}
|
|
||||||
} else if (valueType === "number" && !Number.isInteger(value)) {
|
|
||||||
throw new Error(`Set preference: "${value}" must be an integer.`);
|
|
||||||
}
|
|
||||||
this.#prefs[name] = value;
|
|
||||||
try {
|
|
||||||
await this._writeToStorage(this.#prefs);
|
|
||||||
} catch (reason) {
|
|
||||||
this.#prefs = oldPrefs;
|
|
||||||
throw reason;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
async get(name) {
|
async get(name) {
|
||||||
await this.#initializedPromise;
|
await this.#initializedPromise;
|
||||||
const defaultValue = this.#defaults[name];
|
return AppOptions.get(name);
|
||||||
if (defaultValue === undefined) {
|
|
||||||
throw new Error(`Get preference: "${name}" is undefined.`);
|
|
||||||
}
|
|
||||||
return this.#prefs[name] ?? defaultValue;
|
|
||||||
}
|
}
|
||||||
get initializedPromise() {
|
get initializedPromise() {
|
||||||
return this.#initializedPromise;
|
return this.#initializedPromise;
|
||||||
@ -3098,13 +3105,19 @@ class Preferences extends BasePreferences {
|
|||||||
}
|
}
|
||||||
class ExternalServices extends BaseExternalServices {
|
class ExternalServices extends BaseExternalServices {
|
||||||
async createL10n() {
|
async createL10n() {
|
||||||
return new genericl10n_GenericL10n(AppOptions.get("locale"));
|
return new genericl10n_GenericL10n(AppOptions.get("localeProperties")?.lang);
|
||||||
}
|
}
|
||||||
createScripting() {
|
createScripting() {
|
||||||
return new GenericScripting(AppOptions.get("sandboxBundleSrc"));
|
return new GenericScripting(AppOptions.get("sandboxBundleSrc"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class MLManager {
|
class MLManager {
|
||||||
|
async isEnabledFor(_name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
async deleteModel(_service) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
async guess() {
|
async guess() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -8411,6 +8424,9 @@ class AnnotationLayerBuilder {
|
|||||||
}
|
}
|
||||||
this.div.hidden = true;
|
this.div.hidden = true;
|
||||||
}
|
}
|
||||||
|
hasEditableAnnotations() {
|
||||||
|
return !!this.annotationLayer?.hasEditableAnnotations();
|
||||||
|
}
|
||||||
#updatePresentationModeState(state) {
|
#updatePresentationModeState(state) {
|
||||||
if (!this.div) {
|
if (!this.div) {
|
||||||
return;
|
return;
|
||||||
@ -9142,6 +9158,7 @@ class PDFPageView {
|
|||||||
#annotationMode = AnnotationMode.ENABLE_FORMS;
|
#annotationMode = AnnotationMode.ENABLE_FORMS;
|
||||||
#enableHWA = false;
|
#enableHWA = false;
|
||||||
#hasRestrictedScaling = false;
|
#hasRestrictedScaling = false;
|
||||||
|
#isEditing = false;
|
||||||
#layerProperties = null;
|
#layerProperties = null;
|
||||||
#loadingId = null;
|
#loadingId = null;
|
||||||
#previousRotation = null;
|
#previousRotation = null;
|
||||||
@ -9296,6 +9313,9 @@ class PDFPageView {
|
|||||||
this.reset();
|
this.reset();
|
||||||
this.pdfPage?.cleanup();
|
this.pdfPage?.cleanup();
|
||||||
}
|
}
|
||||||
|
hasEditableAnnotations() {
|
||||||
|
return !!this.annotationLayer?.hasEditableAnnotations();
|
||||||
|
}
|
||||||
get _textHighlighter() {
|
get _textHighlighter() {
|
||||||
return shadow(this, "_textHighlighter", new TextHighlighter({
|
return shadow(this, "_textHighlighter", new TextHighlighter({
|
||||||
pageIndex: this.id - 1,
|
pageIndex: this.id - 1,
|
||||||
@ -9472,6 +9492,19 @@ class PDFPageView {
|
|||||||
this._resetZoomLayer();
|
this._resetZoomLayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
toggleEditingMode(isEditing) {
|
||||||
|
if (!this.hasEditableAnnotations()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.#isEditing = isEditing;
|
||||||
|
this.reset({
|
||||||
|
keepZoomLayer: true,
|
||||||
|
keepAnnotationLayer: true,
|
||||||
|
keepAnnotationEditorLayer: true,
|
||||||
|
keepXfaLayer: true,
|
||||||
|
keepTextLayer: true
|
||||||
|
});
|
||||||
|
}
|
||||||
update({
|
update({
|
||||||
scale = 0,
|
scale = 0,
|
||||||
rotation = null,
|
rotation = null,
|
||||||
@ -9822,7 +9855,8 @@ class PDFPageView {
|
|||||||
annotationMode: this.#annotationMode,
|
annotationMode: this.#annotationMode,
|
||||||
optionalContentConfigPromise: this._optionalContentConfigPromise,
|
optionalContentConfigPromise: this._optionalContentConfigPromise,
|
||||||
annotationCanvasMap: this._annotationCanvasMap,
|
annotationCanvasMap: this._annotationCanvasMap,
|
||||||
pageColors
|
pageColors,
|
||||||
|
isEditing: this.#isEditing
|
||||||
};
|
};
|
||||||
const renderTask = this.renderTask = pdfPage.render(renderContext);
|
const renderTask = this.renderTask = pdfPage.render(renderContext);
|
||||||
renderTask.onContinue = renderContinueCallback;
|
renderTask.onContinue = renderContinueCallback;
|
||||||
@ -9982,8 +10016,11 @@ class PDFViewer {
|
|||||||
#enableHWA = false;
|
#enableHWA = false;
|
||||||
#enableHighlightFloatingButton = false;
|
#enableHighlightFloatingButton = false;
|
||||||
#enablePermissions = false;
|
#enablePermissions = false;
|
||||||
|
#enableUpdatedAddImage = false;
|
||||||
#eventAbortController = null;
|
#eventAbortController = null;
|
||||||
#mlManager = null;
|
#mlManager = null;
|
||||||
|
#onPageRenderedCallback = null;
|
||||||
|
#switchAnnotationEditorModeTimeoutId = null;
|
||||||
#getAllTextInProgress = false;
|
#getAllTextInProgress = false;
|
||||||
#hiddenCopyElement = null;
|
#hiddenCopyElement = null;
|
||||||
#interruptCopyCondition = false;
|
#interruptCopyCondition = false;
|
||||||
@ -9993,7 +10030,7 @@ class PDFViewer {
|
|||||||
#scaleTimeoutId = null;
|
#scaleTimeoutId = null;
|
||||||
#textLayerMode = TextLayerMode.ENABLE;
|
#textLayerMode = TextLayerMode.ENABLE;
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
const viewerVersion = "4.4.168";
|
const viewerVersion = "4.5.136";
|
||||||
if (version !== viewerVersion) {
|
if (version !== viewerVersion) {
|
||||||
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
|
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
|
||||||
}
|
}
|
||||||
@ -10020,6 +10057,7 @@ class PDFViewer {
|
|||||||
this.#annotationEditorMode = options.annotationEditorMode ?? AnnotationEditorType.NONE;
|
this.#annotationEditorMode = options.annotationEditorMode ?? AnnotationEditorType.NONE;
|
||||||
this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
|
this.#annotationEditorHighlightColors = options.annotationEditorHighlightColors || null;
|
||||||
this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
|
this.#enableHighlightFloatingButton = options.enableHighlightFloatingButton === true;
|
||||||
|
this.#enableUpdatedAddImage = options.enableUpdatedAddImage === true;
|
||||||
this.imageResourcesPath = options.imageResourcesPath || "";
|
this.imageResourcesPath = options.imageResourcesPath || "";
|
||||||
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
||||||
this.removePageBorders = options.removePageBorders || false;
|
this.removePageBorders = options.removePageBorders || false;
|
||||||
@ -10425,7 +10463,7 @@ class PDFViewer {
|
|||||||
if (pdfDocument.isPureXfa) {
|
if (pdfDocument.isPureXfa) {
|
||||||
console.warn("Warning: XFA-editing is not implemented.");
|
console.warn("Warning: XFA-editing is not implemented.");
|
||||||
} else if (isValidAnnotationEditorMode(mode)) {
|
} else if (isValidAnnotationEditorMode(mode)) {
|
||||||
this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#mlManager);
|
this.#annotationEditorUIManager = new AnnotationEditorUIManager(this.container, viewer, this.#altTextManager, eventBus, pdfDocument, pageColors, this.#annotationEditorHighlightColors, this.#enableHighlightFloatingButton, this.#enableUpdatedAddImage, this.#mlManager);
|
||||||
eventBus.dispatch("annotationeditoruimanager", {
|
eventBus.dispatch("annotationeditoruimanager", {
|
||||||
source: this,
|
source: this,
|
||||||
uiManager: this.#annotationEditorUIManager
|
uiManager: this.#annotationEditorUIManager
|
||||||
@ -10584,6 +10622,7 @@ class PDFViewer {
|
|||||||
this.viewer.removeAttribute("lang");
|
this.viewer.removeAttribute("lang");
|
||||||
this.#hiddenCopyElement?.remove();
|
this.#hiddenCopyElement?.remove();
|
||||||
this.#hiddenCopyElement = null;
|
this.#hiddenCopyElement = null;
|
||||||
|
this.#cleanupSwitchAnnotationEditorMode();
|
||||||
}
|
}
|
||||||
#ensurePageViewVisible() {
|
#ensurePageViewVisible() {
|
||||||
if (this._scrollMode !== ScrollMode.PAGE) {
|
if (this._scrollMode !== ScrollMode.PAGE) {
|
||||||
@ -10956,6 +10995,34 @@ class PDFViewer {
|
|||||||
location: this._location
|
location: this._location
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
#switchToEditAnnotationMode() {
|
||||||
|
const visible = this._getVisiblePages();
|
||||||
|
const pagesToRefresh = [];
|
||||||
|
const {
|
||||||
|
ids,
|
||||||
|
views
|
||||||
|
} = visible;
|
||||||
|
for (const page of views) {
|
||||||
|
const {
|
||||||
|
view
|
||||||
|
} = page;
|
||||||
|
if (!view.hasEditableAnnotations()) {
|
||||||
|
ids.delete(view.id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pagesToRefresh.push(page);
|
||||||
|
}
|
||||||
|
if (pagesToRefresh.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
this.renderingQueue.renderHighestPriority({
|
||||||
|
first: pagesToRefresh[0],
|
||||||
|
last: pagesToRefresh.at(-1),
|
||||||
|
views: pagesToRefresh,
|
||||||
|
ids
|
||||||
|
});
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
containsElement(element) {
|
containsElement(element) {
|
||||||
return this.container.contains(element);
|
return this.container.contains(element);
|
||||||
}
|
}
|
||||||
@ -11388,6 +11455,16 @@ class PDFViewer {
|
|||||||
get containerTopLeft() {
|
get containerTopLeft() {
|
||||||
return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
|
return this.#containerTopLeft ||= [this.container.offsetTop, this.container.offsetLeft];
|
||||||
}
|
}
|
||||||
|
#cleanupSwitchAnnotationEditorMode() {
|
||||||
|
if (this.#onPageRenderedCallback) {
|
||||||
|
this.eventBus._off("pagerendered", this.#onPageRenderedCallback);
|
||||||
|
this.#onPageRenderedCallback = null;
|
||||||
|
}
|
||||||
|
if (this.#switchAnnotationEditorModeTimeoutId !== null) {
|
||||||
|
clearTimeout(this.#switchAnnotationEditorModeTimeoutId);
|
||||||
|
this.#switchAnnotationEditorModeTimeoutId = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
get annotationEditorMode() {
|
get annotationEditorMode() {
|
||||||
return this.#annotationEditorUIManager ? this.#annotationEditorMode : AnnotationEditorType.DISABLE;
|
return this.#annotationEditorUIManager ? this.#annotationEditorMode : AnnotationEditorType.DISABLE;
|
||||||
}
|
}
|
||||||
@ -11408,12 +11485,47 @@ class PDFViewer {
|
|||||||
if (!this.pdfDocument) {
|
if (!this.pdfDocument) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const {
|
||||||
|
eventBus
|
||||||
|
} = this;
|
||||||
|
const updater = () => {
|
||||||
|
this.#cleanupSwitchAnnotationEditorMode();
|
||||||
this.#annotationEditorMode = mode;
|
this.#annotationEditorMode = mode;
|
||||||
this.eventBus.dispatch("annotationeditormodechanged", {
|
this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
|
||||||
|
eventBus.dispatch("annotationeditormodechanged", {
|
||||||
source: this,
|
source: this,
|
||||||
mode
|
mode
|
||||||
});
|
});
|
||||||
this.#annotationEditorUIManager.updateMode(mode, editId, isFromKeyboard);
|
};
|
||||||
|
if (mode === AnnotationEditorType.NONE || this.#annotationEditorMode === AnnotationEditorType.NONE) {
|
||||||
|
const isEditing = mode !== AnnotationEditorType.NONE;
|
||||||
|
if (!isEditing) {
|
||||||
|
this.pdfDocument.annotationStorage.resetModifiedIds();
|
||||||
|
}
|
||||||
|
for (const pageView of this._pages) {
|
||||||
|
pageView.toggleEditingMode(isEditing);
|
||||||
|
}
|
||||||
|
const idsToRefresh = this.#switchToEditAnnotationMode();
|
||||||
|
if (isEditing && idsToRefresh) {
|
||||||
|
this.#cleanupSwitchAnnotationEditorMode();
|
||||||
|
this.#onPageRenderedCallback = ({
|
||||||
|
pageNumber
|
||||||
|
}) => {
|
||||||
|
idsToRefresh.delete(pageNumber);
|
||||||
|
if (idsToRefresh.size === 0) {
|
||||||
|
this.#switchAnnotationEditorModeTimeoutId = setTimeout(updater, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const {
|
||||||
|
signal
|
||||||
|
} = this.#eventAbortController;
|
||||||
|
eventBus._on("pagerendered", this.#onPageRenderedCallback, {
|
||||||
|
signal
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updater();
|
||||||
}
|
}
|
||||||
set annotationEditorParams({
|
set annotationEditorParams({
|
||||||
type,
|
type,
|
||||||
@ -11721,7 +11833,7 @@ class SecondaryToolbar {
|
|||||||
|
|
||||||
class Toolbar {
|
class Toolbar {
|
||||||
#opts;
|
#opts;
|
||||||
constructor(options, eventBus) {
|
constructor(options, eventBus, toolbarDensity = 0) {
|
||||||
this.#opts = options;
|
this.#opts = options;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
const buttons = [{
|
const buttons = [{
|
||||||
@ -11806,8 +11918,13 @@ class Toolbar {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
|
||||||
|
this.#updateToolbarDensity({
|
||||||
|
value: toolbarDensity
|
||||||
|
});
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
#updateToolbarDensity() {}
|
||||||
#setAnnotationEditorUIManager(uiManager, parentContainer) {
|
#setAnnotationEditorUIManager(uiManager, parentContainer) {
|
||||||
const colorPicker = new ColorPicker({
|
const colorPicker = new ColorPicker({
|
||||||
uiManager
|
uiManager
|
||||||
@ -12078,7 +12195,6 @@ class ViewHistory {
|
|||||||
|
|
||||||
|
|
||||||
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
|
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
|
||||||
const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
|
|
||||||
const ViewOnLoad = {
|
const ViewOnLoad = {
|
||||||
UNKNOWN: -1,
|
UNKNOWN: -1,
|
||||||
PREVIOUS: 0,
|
PREVIOUS: 0,
|
||||||
@ -12110,18 +12226,17 @@ const PDFViewerApplication = {
|
|||||||
store: null,
|
store: null,
|
||||||
downloadManager: null,
|
downloadManager: null,
|
||||||
overlayManager: null,
|
overlayManager: null,
|
||||||
preferences: null,
|
preferences: new Preferences(),
|
||||||
toolbar: null,
|
toolbar: null,
|
||||||
secondaryToolbar: null,
|
secondaryToolbar: null,
|
||||||
eventBus: null,
|
eventBus: null,
|
||||||
l10n: null,
|
l10n: null,
|
||||||
annotationEditorParams: null,
|
annotationEditorParams: null,
|
||||||
isInitialViewSet: false,
|
isInitialViewSet: false,
|
||||||
downloadComplete: false,
|
|
||||||
isViewerEmbedded: window.parent !== window,
|
isViewerEmbedded: window.parent !== window,
|
||||||
url: "",
|
url: "",
|
||||||
baseUrl: "",
|
baseUrl: "",
|
||||||
_allowedGlobalEventsPromise: null,
|
mlManager: null,
|
||||||
_downloadUrl: "",
|
_downloadUrl: "",
|
||||||
_eventBusAbortController: null,
|
_eventBusAbortController: null,
|
||||||
_windowAbortController: null,
|
_windowAbortController: null,
|
||||||
@ -12141,11 +12256,9 @@ const PDFViewerApplication = {
|
|||||||
_printAnnotationStoragePromise: null,
|
_printAnnotationStoragePromise: null,
|
||||||
_touchInfo: null,
|
_touchInfo: null,
|
||||||
_isCtrlKeyDown: false,
|
_isCtrlKeyDown: false,
|
||||||
_nimbusDataPromise: null,
|
|
||||||
_caretBrowsing: null,
|
_caretBrowsing: null,
|
||||||
_isScrolling: false,
|
_isScrolling: false,
|
||||||
async initialize(appConfig) {
|
async initialize(appConfig) {
|
||||||
let l10nPromise;
|
|
||||||
this.appConfig = appConfig;
|
this.appConfig = appConfig;
|
||||||
try {
|
try {
|
||||||
await this.preferences.initializedPromise;
|
await this.preferences.initializedPromise;
|
||||||
@ -12167,8 +12280,7 @@ const PDFViewerApplication = {
|
|||||||
if (mode) {
|
if (mode) {
|
||||||
document.documentElement.classList.add(mode);
|
document.documentElement.classList.add(mode);
|
||||||
}
|
}
|
||||||
l10nPromise = this.externalServices.createL10n();
|
this.l10n = await this.externalServices.createL10n();
|
||||||
this.l10n = await l10nPromise;
|
|
||||||
document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
|
document.getElementsByTagName("html")[0].dir = this.l10n.getDirection();
|
||||||
this.l10n.translate(appConfig.appContainer || document.documentElement);
|
this.l10n.translate(appConfig.appContainer || document.documentElement);
|
||||||
if (this.isViewerEmbedded && AppOptions.get("externalLinkTarget") === LinkTarget.NONE) {
|
if (this.isViewerEmbedded && AppOptions.get("externalLinkTarget") === LinkTarget.NONE) {
|
||||||
@ -12257,7 +12369,9 @@ const PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (params.has("locale")) {
|
if (params.has("locale")) {
|
||||||
AppOptions.set("locale", params.get("locale"));
|
AppOptions.set("localeProperties", {
|
||||||
|
lang: params.get("locale")
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async _initializeViewerComponents() {
|
async _initializeViewerComponents() {
|
||||||
@ -12318,6 +12432,7 @@ const PDFViewerApplication = {
|
|||||||
annotationEditorMode,
|
annotationEditorMode,
|
||||||
annotationEditorHighlightColors: AppOptions.get("highlightEditorColors"),
|
annotationEditorHighlightColors: AppOptions.get("highlightEditorColors"),
|
||||||
enableHighlightFloatingButton: AppOptions.get("enableHighlightFloatingButton"),
|
enableHighlightFloatingButton: AppOptions.get("enableHighlightFloatingButton"),
|
||||||
|
enableUpdatedAddImage: AppOptions.get("enableUpdatedAddImage"),
|
||||||
imageResourcesPath: AppOptions.get("imageResourcesPath"),
|
imageResourcesPath: AppOptions.get("imageResourcesPath"),
|
||||||
enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
|
enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"),
|
||||||
maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
|
maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
|
||||||
@ -12355,9 +12470,6 @@ const PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
if (appConfig.annotationEditorParams) {
|
if (appConfig.annotationEditorParams) {
|
||||||
if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
|
if (annotationEditorMode !== AnnotationEditorType.DISABLE) {
|
||||||
if (AppOptions.get("enableStampEditor")) {
|
|
||||||
appConfig.toolbar?.editorStampButton?.classList.remove("hidden");
|
|
||||||
}
|
|
||||||
const editorHighlightButton = appConfig.toolbar?.editorHighlightButton;
|
const editorHighlightButton = appConfig.toolbar?.editorHighlightButton;
|
||||||
if (editorHighlightButton && AppOptions.get("enableHighlightEditor")) {
|
if (editorHighlightButton && AppOptions.get("enableHighlightEditor")) {
|
||||||
editorHighlightButton.hidden = false;
|
editorHighlightButton.hidden = false;
|
||||||
@ -12380,7 +12492,7 @@ const PDFViewerApplication = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (appConfig.toolbar) {
|
if (appConfig.toolbar) {
|
||||||
this.toolbar = new Toolbar(appConfig.toolbar, eventBus);
|
this.toolbar = new Toolbar(appConfig.toolbar, eventBus, AppOptions.get("toolbarDensity"));
|
||||||
}
|
}
|
||||||
if (appConfig.secondaryToolbar) {
|
if (appConfig.secondaryToolbar) {
|
||||||
this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
|
this.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, eventBus);
|
||||||
@ -12437,7 +12549,6 @@ const PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async run(config) {
|
async run(config) {
|
||||||
this.preferences = new Preferences();
|
|
||||||
await this.initialize(config);
|
await this.initialize(config);
|
||||||
const {
|
const {
|
||||||
appConfig,
|
appConfig,
|
||||||
@ -12514,9 +12625,6 @@ const PDFViewerApplication = {
|
|||||||
get externalServices() {
|
get externalServices() {
|
||||||
return shadow(this, "externalServices", new ExternalServices());
|
return shadow(this, "externalServices", new ExternalServices());
|
||||||
},
|
},
|
||||||
get mlManager() {
|
|
||||||
return shadow(this, "mlManager", AppOptions.get("enableML") === true ? new MLManager() : null);
|
|
||||||
},
|
|
||||||
get initialized() {
|
get initialized() {
|
||||||
return this._initializedCapability.settled;
|
return this._initializedCapability.settled;
|
||||||
},
|
},
|
||||||
@ -12597,12 +12705,10 @@ const PDFViewerApplication = {
|
|||||||
let title = pdfjs_getPdfFilenameFromUrl(url, "");
|
let title = pdfjs_getPdfFilenameFromUrl(url, "");
|
||||||
if (!title) {
|
if (!title) {
|
||||||
try {
|
try {
|
||||||
title = decodeURIComponent(getFilenameFromUrl(url)) || url;
|
title = decodeURIComponent(getFilenameFromUrl(url));
|
||||||
} catch {
|
} catch {}
|
||||||
title = url;
|
|
||||||
}
|
}
|
||||||
}
|
this.setTitle(title || url);
|
||||||
this.setTitle(title);
|
|
||||||
},
|
},
|
||||||
setTitle(title = this._title) {
|
setTitle(title = this._title) {
|
||||||
this._title = title;
|
this._title = title;
|
||||||
@ -12648,7 +12754,6 @@ const PDFViewerApplication = {
|
|||||||
this.pdfLinkService.externalLinkEnabled = true;
|
this.pdfLinkService.externalLinkEnabled = true;
|
||||||
this.store = null;
|
this.store = null;
|
||||||
this.isInitialViewSet = false;
|
this.isInitialViewSet = false;
|
||||||
this.downloadComplete = false;
|
|
||||||
this.url = "";
|
this.url = "";
|
||||||
this.baseUrl = "";
|
this.baseUrl = "";
|
||||||
this._downloadUrl = "";
|
this._downloadUrl = "";
|
||||||
@ -12724,9 +12829,7 @@ const PDFViewerApplication = {
|
|||||||
async download(options = {}) {
|
async download(options = {}) {
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
if (this.downloadComplete) {
|
|
||||||
data = await this.pdfDocument.getData();
|
data = await this.pdfDocument.getData();
|
||||||
}
|
|
||||||
} catch {}
|
} catch {}
|
||||||
this.downloadManager.download(data, this._downloadUrl, this._docFilename, options);
|
this.downloadManager.download(data, this._downloadUrl, this._docFilename, options);
|
||||||
},
|
},
|
||||||
@ -12793,11 +12896,8 @@ const PDFViewerApplication = {
|
|||||||
return message;
|
return message;
|
||||||
},
|
},
|
||||||
progress(level) {
|
progress(level) {
|
||||||
if (!this.loadingBar || this.downloadComplete) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const percent = Math.round(level * 100);
|
const percent = Math.round(level * 100);
|
||||||
if (percent <= this.loadingBar.percent) {
|
if (!this.loadingBar || percent <= this.loadingBar.percent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loadingBar.percent = percent;
|
this.loadingBar.percent = percent;
|
||||||
@ -12811,7 +12911,6 @@ const PDFViewerApplication = {
|
|||||||
length
|
length
|
||||||
}) => {
|
}) => {
|
||||||
this._contentLength = length;
|
this._contentLength = length;
|
||||||
this.downloadComplete = true;
|
|
||||||
this.loadingBar?.hide();
|
this.loadingBar?.hide();
|
||||||
firstPagePromise.then(() => {
|
firstPagePromise.then(() => {
|
||||||
this.eventBus.dispatch("documentloaded", {
|
this.eventBus.dispatch("documentloaded", {
|
||||||
@ -13413,9 +13512,6 @@ const PDFViewerApplication = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
addWindowResolutionChange();
|
addWindowResolutionChange();
|
||||||
window.addEventListener("visibilitychange", webViewerVisibilityChange, {
|
|
||||||
signal
|
|
||||||
});
|
|
||||||
window.addEventListener("wheel", webViewerWheel, {
|
window.addEventListener("wheel", webViewerWheel, {
|
||||||
passive: false,
|
passive: false,
|
||||||
signal
|
signal
|
||||||
@ -13730,7 +13826,7 @@ function webViewerHashchange(evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
/*var webViewerFileInputChange = function (evt) {
|
var webViewerFileInputChange = function (evt) {
|
||||||
if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
|
if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -13742,7 +13838,7 @@ function webViewerHashchange(evt) {
|
|||||||
};
|
};
|
||||||
var webViewerOpenFile = function (evt) {
|
var webViewerOpenFile = function (evt) {
|
||||||
PDFViewerApplication._openFileInput?.click();
|
PDFViewerApplication._openFileInput?.click();
|
||||||
};*/
|
};
|
||||||
}
|
}
|
||||||
function webViewerPresentationMode() {
|
function webViewerPresentationMode() {
|
||||||
PDFViewerApplication.requestPresentationMode();
|
PDFViewerApplication.requestPresentationMode();
|
||||||
@ -13876,20 +13972,6 @@ function webViewerPageChanging({
|
|||||||
function webViewerResolutionChange(evt) {
|
function webViewerResolutionChange(evt) {
|
||||||
PDFViewerApplication.pdfViewer.refresh();
|
PDFViewerApplication.pdfViewer.refresh();
|
||||||
}
|
}
|
||||||
function webViewerVisibilityChange(evt) {
|
|
||||||
if (document.visibilityState === "visible") {
|
|
||||||
setZoomDisabledTimeout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let zoomDisabledTimeout = null;
|
|
||||||
function setZoomDisabledTimeout() {
|
|
||||||
if (zoomDisabledTimeout) {
|
|
||||||
clearTimeout(zoomDisabledTimeout);
|
|
||||||
}
|
|
||||||
zoomDisabledTimeout = setTimeout(function () {
|
|
||||||
zoomDisabledTimeout = null;
|
|
||||||
}, WHEEL_ZOOM_DISABLED_TIMEOUT);
|
|
||||||
}
|
|
||||||
function webViewerWheel(evt) {
|
function webViewerWheel(evt) {
|
||||||
const {
|
const {
|
||||||
pdfViewer,
|
pdfViewer,
|
||||||
@ -13907,7 +13989,7 @@ function webViewerWheel(evt) {
|
|||||||
const origin = [evt.clientX, evt.clientY];
|
const origin = [evt.clientX, evt.clientY];
|
||||||
if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
|
if (isPinchToZoom || evt.ctrlKey && supportsMouseWheelZoomCtrlKey || evt.metaKey && supportsMouseWheelZoomMetaKey) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
if (PDFViewerApplication._isScrolling || zoomDisabledTimeout || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
|
if (PDFViewerApplication._isScrolling || document.visibilityState === "hidden" || PDFViewerApplication.overlayManager.active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isPinchToZoom && supportsPinchToZoom) {
|
if (isPinchToZoom && supportsPinchToZoom) {
|
||||||
@ -14335,14 +14417,20 @@ function webViewerReportTelemetry({
|
|||||||
}) {
|
}) {
|
||||||
PDFViewerApplication.externalServices.reportTelemetry(details);
|
PDFViewerApplication.externalServices.reportTelemetry(details);
|
||||||
}
|
}
|
||||||
|
function webViewerSetPreference({
|
||||||
|
name,
|
||||||
|
value
|
||||||
|
}) {
|
||||||
|
PDFViewerApplication.preferences.set(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./web/viewer.js
|
;// CONCATENATED MODULE: ./web/viewer.js
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const pdfjsVersion = "4.4.168";
|
const pdfjsVersion = "4.5.136";
|
||||||
const pdfjsBuild = "19fbc8998";
|
const pdfjsBuild = "3a21f03b0";
|
||||||
const AppConstants = {
|
const AppConstants = {
|
||||||
LinkTarget: LinkTarget,
|
LinkTarget: LinkTarget,
|
||||||
RenderingStates: RenderingStates,
|
RenderingStates: RenderingStates,
|
||||||
|
Loading…
Reference in New Issue
Block a user