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