1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-23 18:17:24 +00:00

Update pdf.js to version 4.4.168

This commit is contained in:
Ozzie Isaacs 2024-07-13 10:49:47 +02:00
parent a6931b4936
commit 87c0b15f5f
10 changed files with 1155 additions and 559 deletions

View File

@ -1894,6 +1894,8 @@
width:100%; width:100%;
height:100%; height:100%;
margin:0; margin:0;
top:0;
left:0;
} }
.annotationEditorLayer :is(.freeTextEditor, .inkEditor, .stampEditor) > .resizers{ .annotationEditorLayer :is(.freeTextEditor, .inkEditor, .stampEditor) > .resizers{
@ -2646,6 +2648,10 @@
} }
} }
.pdfViewer.copyAll{
cursor:wait;
}
.pdfViewer .canvasWrapper{ .pdfViewer .canvasWrapper{
overflow:hidden; overflow:hidden;
width:100%; width:100%;
@ -3010,6 +3016,15 @@ body{
scrollbar-color:var(--scrollbar-color) var(--scrollbar-bg-color); scrollbar-color:var(--scrollbar-color) var(--scrollbar-bg-color);
} }
body.wait::before{
content:"";
position:fixed;
width:100%;
height:100%;
z-index:100000;
cursor:wait;
}
.hidden, .hidden,
[hidden]{ [hidden]{
display:none !important; display:none !important;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -142,7 +142,7 @@ function scrollIntoView(element, spot, scrollMatches = false) {
} }
parent.scrollTop = offsetY; parent.scrollTop = offsetY;
} }
function watchScroll(viewAreaElement, callback) { function watchScroll(viewAreaElement, callback, abortSignal = undefined) {
const debounceScroll = function (evt) { const debounceScroll = function (evt) {
if (rAF) { if (rAF) {
return; return;
@ -172,7 +172,13 @@ function watchScroll(viewAreaElement, callback) {
_eventHandler: debounceScroll _eventHandler: debounceScroll
}; };
let rAF = null; let rAF = null;
viewAreaElement.addEventListener("scroll", debounceScroll, true); viewAreaElement.addEventListener("scroll", debounceScroll, {
useCapture: true,
signal: abortSignal
});
abortSignal?.addEventListener("abort", () => window.cancelAnimationFrame(rAF), {
once: true
});
return state; return state;
} }
function parseQueryString(query) { function parseQueryString(query) {
@ -250,9 +256,8 @@ function approximateFraction(x) {
} }
return result; return result;
} }
function roundToDivide(x, div) { function floorToDivide(x, div) {
const r = x % div; return x - x % div;
return r === 0 ? x : Math.round(x - r + div);
} }
function getPageSizeInches({ function getPageSizeInches({
view, view,
@ -738,6 +743,10 @@ const defaultOptions = {
value: "", value: "",
kind: OptionKind.API kind: OptionKind.API
}, },
enableHWA: {
value: true,
kind: OptionKind.API + OptionKind.VIEWER + OptionKind.PREFERENCE
},
enableXfa: { enableXfa: {
value: true, value: true,
kind: OptionKind.API + OptionKind.PREFERENCE kind: OptionKind.API + OptionKind.PREFERENCE
@ -1357,9 +1366,18 @@ class EventBus {
} }
} }
} }
class AutomationEventBus extends EventBus { class FirefoxEventBus extends EventBus {
#externalServices;
#globalEventNames;
#isInAutomation;
constructor(globalEventNames, externalServices, isInAutomation) {
super();
this.#globalEventNames = globalEventNames;
this.#externalServices = externalServices;
this.#isInAutomation = isInAutomation;
}
dispatch(eventName, data) { dispatch(eventName, data) {
throw new Error("Not implemented: AutomationEventBus.dispatch"); throw new Error("Not implemented: FirefoxEventBus.dispatch");
} }
} }
@ -1384,6 +1402,10 @@ class BaseExternalServices {
throw new Error("Not implemented: updateEditorStates"); throw new Error("Not implemented: updateEditorStates");
} }
async getNimbusExperimentData() {} async getNimbusExperimentData() {}
async getGlobalEventNames() {
return null;
}
dispatchGlobalEvent(_event) {}
} }
;// CONCATENATED MODULE: ./web/preferences.js ;// CONCATENATED MODULE: ./web/preferences.js
@ -1430,6 +1452,7 @@ class BasePreferences {
disableFontFace: false, disableFontFace: false,
disableRange: false, disableRange: false,
disableStream: false, disableStream: false,
enableHWA: true,
enableXfa: true, enableXfa: true,
viewerCssTheme: 0 viewerCssTheme: 0
}); });
@ -2743,6 +2766,9 @@ class DOMLocalization extends Localization {
this.pauseObserving(); this.pauseObserving();
if (this.roots.size === 0) { if (this.roots.size === 0) {
this.mutationObserver = null; this.mutationObserver = null;
if (this.windowElement && this.pendingrAF) {
this.windowElement.cancelAnimationFrame(this.pendingrAF);
}
this.windowElement = null; this.windowElement = null;
this.pendingrAF = null; this.pendingrAF = null;
this.pendingElements.clear(); this.pendingElements.clear();
@ -2843,6 +2869,7 @@ class DOMLocalization extends Localization {
;// CONCATENATED MODULE: ./web/l10n.js ;// CONCATENATED MODULE: ./web/l10n.js
class L10n { class L10n {
#dir; #dir;
#elements = new Set();
#lang; #lang;
#l10n; #l10n;
constructor({ constructor({
@ -2877,11 +2904,19 @@ class L10n {
return messages?.[0].value || fallback; return messages?.[0].value || fallback;
} }
async translate(element) { async translate(element) {
this.#elements.add(element);
try { try {
this.#l10n.connectRoot(element); this.#l10n.connectRoot(element);
await this.#l10n.translateRoots(); await this.#l10n.translateRoots();
} catch {} } catch {}
} }
async destroy() {
for (const element of this.#elements) {
this.#l10n.disconnectRoot(element);
}
this.#elements.clear();
this.#l10n.pauseObserving();
}
pause() { pause() {
this.#l10n.pauseObserving(); this.#l10n.pauseObserving();
} }
@ -2954,8 +2989,7 @@ class genericl10n_GenericL10n extends L10n {
const bundle = await this.#createBundle(lang, baseURL, paths); const bundle = await this.#createBundle(lang, baseURL, paths);
if (bundle) { if (bundle) {
yield bundle; yield bundle;
} } else if (lang === "en-us") {
if (lang === "en-us") {
yield this.#createBundleFallback(lang); yield this.#createBundleFallback(lang);
} }
} }
@ -3625,13 +3659,6 @@ function download(blobUrl, filename) {
} }
class DownloadManager { class DownloadManager {
#openBlobUrls = new WeakMap(); #openBlobUrls = new WeakMap();
downloadUrl(url, filename, _options) {
if (!createValidAbsoluteUrl(url, "http://example.com")) {
console.error(`downloadUrl - not a valid URL: ${url}`);
return;
}
download(url + "#pdfjs.action=download", filename);
}
downloadData(data, filename, contentType) { downloadData(data, filename, contentType) {
const blobUrl = URL.createObjectURL(new Blob([data], { const blobUrl = URL.createObjectURL(new Blob([data], {
type: contentType type: contentType
@ -3666,8 +3693,19 @@ class DownloadManager {
this.downloadData(data, filename, contentType); this.downloadData(data, filename, contentType);
return false; return false;
} }
download(blob, url, filename, _options) { download(data, url, filename, _options) {
const blobUrl = URL.createObjectURL(blob); let blobUrl;
if (data) {
blobUrl = URL.createObjectURL(new Blob([data], {
type: "application/pdf"
}));
} else {
if (!createValidAbsoluteUrl(url, "http://example.com")) {
console.error(`download - not a valid URL: ${url}`);
return;
}
blobUrl = url + "#pdfjs.action=download";
}
download(blobUrl, filename); download(blobUrl, filename);
} }
} }
@ -5180,6 +5218,7 @@ class PDFFindController {
source: this, source: this,
state, state,
previous, previous,
entireWord: this.#state?.entireWord ?? null,
matchesCount: this.#requestMatchesCount(), matchesCount: this.#requestMatchesCount(),
rawQuery: this.#state?.query ?? null rawQuery: this.#state?.query ?? null
}); });
@ -7711,7 +7750,8 @@ class PDFThumbnailView {
optionalContentConfigPromise, optionalContentConfigPromise,
linkService, linkService,
renderingQueue, renderingQueue,
pageColors pageColors,
enableHWA
}) { }) {
this.id = id; this.id = id;
this.renderingId = "thumbnail" + id; this.renderingId = "thumbnail" + id;
@ -7722,6 +7762,7 @@ class PDFThumbnailView {
this.pdfPageRotate = defaultViewport.rotation; this.pdfPageRotate = defaultViewport.rotation;
this._optionalContentConfigPromise = optionalContentConfigPromise || null; this._optionalContentConfigPromise = optionalContentConfigPromise || null;
this.pageColors = pageColors || null; this.pageColors = pageColors || null;
this.enableHWA = enableHWA || false;
this.eventBus = eventBus; this.eventBus = eventBus;
this.linkService = linkService; this.linkService = linkService;
this.renderingQueue = renderingQueue; this.renderingQueue = renderingQueue;
@ -7805,10 +7846,11 @@ class PDFThumbnailView {
} }
this.resume = null; this.resume = null;
} }
#getPageDrawContext(upscaleFactor = 1) { #getPageDrawContext(upscaleFactor = 1, enableHWA = this.enableHWA) {
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d", { const ctx = canvas.getContext("2d", {
alpha: false alpha: false,
willReadFrequently: !enableHWA
}); });
const outputScale = new OutputScale(); const outputScale = new OutputScale();
canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0; canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
@ -7927,7 +7969,7 @@ class PDFThumbnailView {
const { const {
ctx, ctx,
canvas canvas
} = this.#getPageDrawContext(); } = this.#getPageDrawContext(1, true);
if (img.width <= 2 * canvas.width) { if (img.width <= 2 * canvas.width) {
ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height); ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
return canvas; return canvas;
@ -7974,14 +8016,17 @@ class PDFThumbnailViewer {
eventBus, eventBus,
linkService, linkService,
renderingQueue, renderingQueue,
pageColors pageColors,
abortSignal,
enableHWA
}) { }) {
this.container = container; this.container = container;
this.eventBus = eventBus; this.eventBus = eventBus;
this.linkService = linkService; this.linkService = linkService;
this.renderingQueue = renderingQueue; this.renderingQueue = renderingQueue;
this.pageColors = pageColors || null; this.pageColors = pageColors || null;
this.scroll = watchScroll(this.container, this.#scrollUpdated.bind(this)); this.enableHWA = enableHWA || false;
this.scroll = watchScroll(this.container, this.#scrollUpdated.bind(this), abortSignal);
this.#resetView(); this.#resetView();
} }
#scrollUpdated() { #scrollUpdated() {
@ -8102,7 +8147,8 @@ class PDFThumbnailViewer {
optionalContentConfigPromise, optionalContentConfigPromise,
linkService: this.linkService, linkService: this.linkService,
renderingQueue: this.renderingQueue, renderingQueue: this.renderingQueue,
pageColors: this.pageColors pageColors: this.pageColors,
enableHWA: this.enableHWA
}); });
this._thumbnails.push(thumbnail); this._thumbnails.push(thumbnail);
} }
@ -8932,13 +8978,6 @@ class TextLayerBuilder {
this.div.tabIndex = 0; this.div.tabIndex = 0;
this.div.className = "textLayer"; this.div.className = "textLayer";
} }
#finishRendering() {
this.#renderingDone = true;
const endOfContent = document.createElement("div");
endOfContent.className = "endOfContent";
this.div.append(endOfContent);
this.#bindMouse(endOfContent);
}
async render(viewport, textContentParams = null) { async render(viewport, textContentParams = null) {
if (this.#renderingDone && this.#textLayer) { if (this.#renderingDone && this.#textLayer) {
this.#textLayer.update({ this.#textLayer.update({
@ -8964,7 +9003,11 @@ class TextLayerBuilder {
this.highlighter?.setTextMapping(textDivs, textContentItemsStr); this.highlighter?.setTextMapping(textDivs, textContentItemsStr);
this.accessibilityManager?.setTextMapping(textDivs); this.accessibilityManager?.setTextMapping(textDivs);
await this.#textLayer.render(); await this.#textLayer.render();
this.#finishRendering(); this.#renderingDone = true;
const endOfContent = document.createElement("div");
endOfContent.className = "endOfContent";
this.div.append(endOfContent);
this.#bindMouse(endOfContent);
this.#onAppend?.(this.div); this.#onAppend?.(this.div);
this.highlighter?.enable(); this.highlighter?.enable();
this.accessibilityManager?.enable(); this.accessibilityManager?.enable();
@ -9097,6 +9140,7 @@ const DEFAULT_LAYER_PROPERTIES = null;
const LAYERS_ORDER = new Map([["canvasWrapper", 0], ["textLayer", 1], ["annotationLayer", 2], ["annotationEditorLayer", 3], ["xfaLayer", 3]]); const LAYERS_ORDER = new Map([["canvasWrapper", 0], ["textLayer", 1], ["annotationLayer", 2], ["annotationEditorLayer", 3], ["xfaLayer", 3]]);
class PDFPageView { class PDFPageView {
#annotationMode = AnnotationMode.ENABLE_FORMS; #annotationMode = AnnotationMode.ENABLE_FORMS;
#enableHWA = false;
#hasRestrictedScaling = false; #hasRestrictedScaling = false;
#layerProperties = null; #layerProperties = null;
#loadingId = null; #loadingId = null;
@ -9129,6 +9173,7 @@ class PDFPageView {
this.imageResourcesPath = options.imageResourcesPath || ""; this.imageResourcesPath = options.imageResourcesPath || "";
this.maxCanvasPixels = options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels"); this.maxCanvasPixels = options.maxCanvasPixels ?? AppOptions.get("maxCanvasPixels");
this.pageColors = options.pageColors || null; this.pageColors = options.pageColors || null;
this.#enableHWA = options.enableHWA || false;
this.eventBus = options.eventBus; this.eventBus = options.eventBus;
this.renderingQueue = options.renderingQueue; this.renderingQueue = options.renderingQueue;
this.l10n = options.l10n; this.l10n = options.l10n;
@ -9739,7 +9784,8 @@ class PDFPageView {
canvasWrapper.append(canvas); canvasWrapper.append(canvas);
this.canvas = canvas; this.canvas = canvas;
const ctx = canvas.getContext("2d", { const ctx = canvas.getContext("2d", {
alpha: false alpha: false,
willReadFrequently: !this.#enableHWA
}); });
const outputScale = this.outputScale = new OutputScale(); const outputScale = this.outputScale = new OutputScale();
if (this.maxCanvasPixels === 0) { if (this.maxCanvasPixels === 0) {
@ -9760,13 +9806,13 @@ class PDFPageView {
} }
const sfx = approximateFraction(outputScale.sx); const sfx = approximateFraction(outputScale.sx);
const sfy = approximateFraction(outputScale.sy); const sfy = approximateFraction(outputScale.sy);
canvas.width = roundToDivide(width * outputScale.sx, sfx[0]); canvas.width = floorToDivide(width * outputScale.sx, sfx[0]);
canvas.height = roundToDivide(height * outputScale.sy, sfy[0]); canvas.height = floorToDivide(height * outputScale.sy, sfy[0]);
const { const {
style style
} = canvas; } = canvas;
style.width = roundToDivide(width, sfx[1]) + "px"; style.width = floorToDivide(width, sfx[1]) + "px";
style.height = roundToDivide(height, sfy[1]) + "px"; style.height = floorToDivide(height, sfy[1]) + "px";
this.#viewportMap.set(canvas, viewport); this.#viewportMap.set(canvas, viewport);
const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null; const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
const renderContext = { const renderContext = {
@ -9870,8 +9916,8 @@ class PDFPageView {
const DEFAULT_CACHE_SIZE = 10; const DEFAULT_CACHE_SIZE = 10;
const PagesCountLimit = { const PagesCountLimit = {
FORCE_SCROLL_MODE_PAGE: 15000, FORCE_SCROLL_MODE_PAGE: 10000,
FORCE_LAZY_PAGE_INIT: 7500, FORCE_LAZY_PAGE_INIT: 5000,
PAUSE_EAGER_PAGE_INIT: 250 PAUSE_EAGER_PAGE_INIT: 250
}; };
function isValidAnnotationEditorMode(mode) { function isValidAnnotationEditorMode(mode) {
@ -9933,6 +9979,7 @@ class PDFViewer {
#annotationEditorUIManager = null; #annotationEditorUIManager = null;
#annotationMode = AnnotationMode.ENABLE_FORMS; #annotationMode = AnnotationMode.ENABLE_FORMS;
#containerTopLeft = null; #containerTopLeft = null;
#enableHWA = false;
#enableHighlightFloatingButton = false; #enableHighlightFloatingButton = false;
#enablePermissions = false; #enablePermissions = false;
#eventAbortController = null; #eventAbortController = null;
@ -9946,7 +9993,7 @@ class PDFViewer {
#scaleTimeoutId = null; #scaleTimeoutId = null;
#textLayerMode = TextLayerMode.ENABLE; #textLayerMode = TextLayerMode.ENABLE;
constructor(options) { constructor(options) {
const viewerVersion = "4.3.136"; const viewerVersion = "4.4.168";
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}".`);
} }
@ -9982,6 +10029,7 @@ class PDFViewer {
this.#enablePermissions = options.enablePermissions || false; this.#enablePermissions = options.enablePermissions || false;
this.pageColors = options.pageColors || null; this.pageColors = options.pageColors || null;
this.#mlManager = options.mlManager || null; this.#mlManager = options.mlManager || null;
this.#enableHWA = options.enableHWA || false;
this.defaultRenderingQueue = !options.renderingQueue; this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) { if (this.defaultRenderingQueue) {
this.renderingQueue = new PDFRenderingQueue(); this.renderingQueue = new PDFRenderingQueue();
@ -9989,7 +10037,16 @@ class PDFViewer {
} else { } else {
this.renderingQueue = options.renderingQueue; this.renderingQueue = options.renderingQueue;
} }
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this)); const {
abortSignal
} = options;
abortSignal?.addEventListener("abort", () => {
this.#resizeObserver.disconnect();
this.#resizeObserver = null;
}, {
once: true
});
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this), abortSignal);
this.presentationModeState = PresentationModeState.UNKNOWN; this.presentationModeState = PresentationModeState.UNKNOWN;
this._resetView(); this._resetView();
if (this.removePageBorders) { if (this.removePageBorders) {
@ -10254,10 +10311,14 @@ class PDFViewer {
return; return;
} }
this.#getAllTextInProgress = true; this.#getAllTextInProgress = true;
const savedCursor = this.container.style.cursor; const {
this.container.style.cursor = "wait"; classList
const interruptCopy = ev => this.#interruptCopyCondition = ev.key === "Escape"; } = this.viewer;
window.addEventListener("keydown", interruptCopy); classList.add("copyAll");
const ac = new AbortController();
window.addEventListener("keydown", ev => this.#interruptCopyCondition = ev.key === "Escape", {
signal: ac.signal
});
this.getAllText().then(async text => { this.getAllText().then(async text => {
if (text !== null) { if (text !== null) {
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);
@ -10267,8 +10328,8 @@ class PDFViewer {
}).finally(() => { }).finally(() => {
this.#getAllTextInProgress = false; this.#getAllTextInProgress = false;
this.#interruptCopyCondition = false; this.#interruptCopyCondition = false;
window.removeEventListener("keydown", interruptCopy); ac.abort();
this.container.style.cursor = savedCursor; classList.remove("copyAll");
}); });
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -10401,7 +10462,8 @@ class PDFViewer {
maxCanvasPixels: this.maxCanvasPixels, maxCanvasPixels: this.maxCanvasPixels,
pageColors, pageColors,
l10n: this.l10n, l10n: this.l10n,
layerProperties: this._layerProperties layerProperties: this._layerProperties,
enableHWA: this.#enableHWA
}); });
this._pages.push(pageView); this._pages.push(pageView);
} }
@ -11549,26 +11611,26 @@ class SecondaryToolbar {
eventDetails eventDetails
} of buttons) { } of buttons) {
if ( element !== null ) { if ( element !== null ) {
element.addEventListener("click", evt => { element.addEventListener("click", evt => {
if (eventName !== null) { if (eventName !== null) {
eventBus.dispatch(eventName, { eventBus.dispatch(eventName, {
source: this, source: this,
...eventDetails ...eventDetails
}); });
}
if (close) {
this.close();
}
eventBus.dispatch("reporttelemetry", {
source: this,
details: {
type: "buttons",
data: {
id: element.id
} }
if (close) { }
this.close();
}
eventBus.dispatch("reporttelemetry", {
source: this,
details: {
type: "buttons",
data: {
id: element.id
}
}
});
}); });
});
} }
} }
eventBus._on("cursortoolchanged", this.#cursorToolChanged.bind(this)); eventBus._on("cursortoolchanged", this.#cursorToolChanged.bind(this));
@ -12059,9 +12121,11 @@ const PDFViewerApplication = {
isViewerEmbedded: window.parent !== window, isViewerEmbedded: window.parent !== window,
url: "", url: "",
baseUrl: "", baseUrl: "",
_allowedGlobalEventsPromise: null,
_downloadUrl: "", _downloadUrl: "",
_eventBusAbortController: null, _eventBusAbortController: null,
_windowAbortController: null, _windowAbortController: null,
_globalAbortController: new AbortController(),
documentInfo: null, documentInfo: null,
metadata: null, metadata: null,
_contentDispositionFilename: null, _contentDispositionFilename: null,
@ -12202,7 +12266,8 @@ const PDFViewerApplication = {
externalServices, externalServices,
l10n l10n
} = this; } = this;
const eventBus = AppOptions.get("isInAutomation") ? new AutomationEventBus() : new EventBus(); let eventBus;
eventBus = new EventBus();
this.eventBus = eventBus; this.eventBus = eventBus;
this.overlayManager = new OverlayManager(); this.overlayManager = new OverlayManager();
const pdfRenderingQueue = new PDFRenderingQueue(); const pdfRenderingQueue = new PDFRenderingQueue();
@ -12236,6 +12301,7 @@ const PDFViewerApplication = {
foreground: AppOptions.get("pageColorsForeground") foreground: AppOptions.get("pageColorsForeground")
} : null; } : null;
const altTextManager = appConfig.altTextDialog ? new AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null; const altTextManager = appConfig.altTextDialog ? new AltTextManager(appConfig.altTextDialog, container, this.overlayManager, eventBus) : null;
const enableHWA = AppOptions.get("enableHWA");
const pdfViewer = new PDFViewer({ const pdfViewer = new PDFViewer({
container, container,
viewer, viewer,
@ -12257,7 +12323,9 @@ const PDFViewerApplication = {
maxCanvasPixels: AppOptions.get("maxCanvasPixels"), maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
enablePermissions: AppOptions.get("enablePermissions"), enablePermissions: AppOptions.get("enablePermissions"),
pageColors, pageColors,
mlManager: this.mlManager mlManager: this.mlManager,
abortSignal: this._globalAbortController.signal,
enableHWA
}); });
this.pdfViewer = pdfViewer; this.pdfViewer = pdfViewer;
pdfRenderingQueue.setViewer(pdfViewer); pdfRenderingQueue.setViewer(pdfViewer);
@ -12269,7 +12337,9 @@ const PDFViewerApplication = {
eventBus, eventBus,
renderingQueue: pdfRenderingQueue, renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService, linkService: pdfLinkService,
pageColors pageColors,
abortSignal: this._globalAbortController.signal,
enableHWA
}); });
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
} }
@ -12378,7 +12448,7 @@ const PDFViewerApplication = {
const params = parseQueryString(queryString); const params = parseQueryString(queryString);
file = params.get("file") ?? AppOptions.get("defaultUrl"); file = params.get("file") ?? AppOptions.get("defaultUrl");
validateFileURL(file); validateFileURL(file);
/* const fileInput = this._openFileInput = document.createElement("input"); /*const fileInput = this._openFileInput = document.createElement("input");
fileInput.id = "fileInput"; fileInput.id = "fileInput";
fileInput.hidden = true; fileInput.hidden = true;
fileInput.type = "file"; fileInput.type = "file";
@ -12395,24 +12465,28 @@ const PDFViewerApplication = {
source: this, source: this,
fileInput: evt.target fileInput: evt.target
}); });
});*/ });
appConfig.mainContainer.addEventListener("dragover", function (evt) { appConfig.mainContainer.addEventListener("dragover", function (evt) {
evt.preventDefault(); for (const item of evt.dataTransfer.items) {
evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move"; if (item.type === "application/pdf") {
evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
evt.preventDefault();
evt.stopPropagation();
return;
}
}
}); });
appConfig.mainContainer.addEventListener("drop", function (evt) { appConfig.mainContainer.addEventListener("drop", function (evt) {
evt.preventDefault(); if (evt.dataTransfer.files?.[0].type !== "application/pdf") {
const {
files
} = evt.dataTransfer;
if (!files || files.length === 0) {
return; return;
} }
/*eventBus.dispatch("fileinputchange", { evt.preventDefault();
evt.stopPropagation();
eventBus.dispatch("fileinputchange", {
source: this, source: this,
fileInput: evt.dataTransfer fileInput: evt.dataTransfer
});*/ });
}); });*/
if (!AppOptions.get("supportsDocumentFonts")) { if (!AppOptions.get("supportsDocumentFonts")) {
AppOptions.set("disableFontFace", true); AppOptions.set("disableFontFace", true);
this.l10n.get("pdfjs-web-fonts-disabled").then(msg => { this.l10n.get("pdfjs-web-fonts-disabled").then(msg => {
@ -12647,25 +12721,14 @@ const PDFViewerApplication = {
}); });
}); });
}, },
_ensureDownloadComplete() {
if (this.pdfDocument && this.downloadComplete) {
return;
}
throw new Error("PDF document not downloaded.");
},
async download(options = {}) { async download(options = {}) {
const url = this._downloadUrl, let data;
filename = this._docFilename;
try { try {
this._ensureDownloadComplete(); if (this.downloadComplete) {
const data = await this.pdfDocument.getData(); data = await this.pdfDocument.getData();
const blob = new Blob([data], { }
type: "application/pdf" } catch {}
}); this.downloadManager.download(data, this._downloadUrl, this._docFilename, options);
await this.downloadManager.download(blob, url, filename, options);
} catch {
await this.downloadManager.downloadUrl(url, filename, options);
}
}, },
async save(options = {}) { async save(options = {}) {
if (this._saveInProgress) { if (this._saveInProgress) {
@ -12673,15 +12736,9 @@ const PDFViewerApplication = {
} }
this._saveInProgress = true; this._saveInProgress = true;
await this.pdfScriptingManager.dispatchWillSave(); await this.pdfScriptingManager.dispatchWillSave();
const url = this._downloadUrl,
filename = this._docFilename;
try { try {
this._ensureDownloadComplete();
const data = await this.pdfDocument.saveDocument(); const data = await this.pdfDocument.saveDocument();
const blob = new Blob([data], { this.downloadManager.download(data, this._downloadUrl, this._docFilename, options);
type: "application/pdf"
});
await this.downloadManager.download(blob, url, filename, options);
} catch (reason) { } catch (reason) {
console.error(`Error when saving the document: ${reason.message}`); console.error(`Error when saving the document: ${reason.message}`);
await this.download(options); await this.download(options);
@ -12699,12 +12756,13 @@ const PDFViewerApplication = {
}); });
} }
}, },
downloadOrSave(options = {}) { async downloadOrSave(options = {}) {
if (this.pdfDocument?.annotationStorage.size > 0) { const {
this.save(options); classList
} else { } = this.appConfig.appContainer;
this.download(options); classList.add("wait");
} await (this.pdfDocument?.annotationStorage.size > 0 ? this.save(options) : this.download(options));
classList.remove("wait");
}, },
async _documentError(key, moreInfo = null) { async _documentError(key, moreInfo = null) {
this._unblockDocumentLoadEvent(); this._unblockDocumentLoadEvent();
@ -13471,6 +13529,14 @@ const PDFViewerApplication = {
this._windowAbortController?.abort(); this._windowAbortController?.abort();
this._windowAbortController = null; this._windowAbortController = null;
}, },
async testingClose() {
this.unbindEvents();
this.unbindWindowEvents();
this._globalAbortController?.abort();
this._globalAbortController = null;
this.findBar?.close();
await Promise.all([this.l10n?.destroy(), this.close()]);
},
_accumulateTicks(ticks, prop) { _accumulateTicks(ticks, prop) {
if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) { if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
this[prop] = 0; this[prop] = 0;
@ -13664,7 +13730,7 @@ function webViewerHashchange(evt) {
} }
} }
{ {
var webViewerFileInputChange = function (evt) { /*var webViewerFileInputChange = function (evt) {
if (PDFViewerApplication.pdfViewer?.isInPresentationMode) { if (PDFViewerApplication.pdfViewer?.isInPresentationMode) {
return; return;
} }
@ -13674,7 +13740,7 @@ function webViewerHashchange(evt) {
originalUrl: file.name originalUrl: file.name
}); });
}; };
/*var webViewerOpenFile = function (evt) { var webViewerOpenFile = function (evt) {
PDFViewerApplication._openFileInput?.click(); PDFViewerApplication._openFileInput?.click();
};*/ };*/
} }
@ -13768,6 +13834,7 @@ function webViewerUpdateFindMatchesCount({
function webViewerUpdateFindControlState({ function webViewerUpdateFindControlState({
state, state,
previous, previous,
entireWord,
matchesCount, matchesCount,
rawQuery rawQuery
}) { }) {
@ -13775,6 +13842,7 @@ function webViewerUpdateFindControlState({
PDFViewerApplication.externalServices.updateFindControlState({ PDFViewerApplication.externalServices.updateFindControlState({
result: state, result: state,
findPrevious: previous, findPrevious: previous,
entireWord,
matchesCount, matchesCount,
rawQuery rawQuery
}); });
@ -14066,14 +14134,14 @@ function webViewerKeyDown(evt) {
}); });
handled = true; handled = true;
break; break;
/*case 79: case 79:
{ {
eventBus.dispatch("openfile", { eventBus.dispatch("openfile", {
source: window source: window
}); });
handled = true; handled = true;
} }
break;*/ break;
} }
} }
if (cmd === 3 || cmd === 10) { if (cmd === 3 || cmd === 10) {
@ -14273,8 +14341,8 @@ function webViewerReportTelemetry({
const pdfjsVersion = "4.3.136"; const pdfjsVersion = "4.4.168";
const pdfjsBuild = "0cec64437"; const pdfjsBuild = "19fbc8998";
const AppConstants = { const AppConstants = {
LinkTarget: LinkTarget, LinkTarget: LinkTarget,
RenderingStates: RenderingStates, RenderingStates: RenderingStates,

View File

@ -49,12 +49,6 @@ pdfjs-download-button =
# Length of the translation matters since we are in a mobile context, with limited screen estate. # Length of the translation matters since we are in a mobile context, with limited screen estate.
pdfjs-download-button-label = Pellgargañ pdfjs-download-button-label = Pellgargañ
pdfjs-bookmark-button-label = Pajenn a-vremañ pdfjs-bookmark-button-label = Pajenn a-vremañ
# Used in Firefox for Android.
pdfjs-open-in-app-button =
.title = Digeriñ en arload
# Used in Firefox for Android.
# Length of the translation matters since we are in a mobile context, with limited screen estate.
pdfjs-open-in-app-button-label = Digeriñ en arload
## Secondary toolbar and context menu ## Secondary toolbar and context menu
@ -214,6 +208,7 @@ pdfjs-find-next-button =
pdfjs-find-next-button-label = War-lerc'h pdfjs-find-next-button-label = War-lerc'h
pdfjs-find-highlight-checkbox = Usskediñ pep tra pdfjs-find-highlight-checkbox = Usskediñ pep tra
pdfjs-find-match-case-checkbox-label = Teurel evezh ouzh ar pennlizherennoù pdfjs-find-match-case-checkbox-label = Teurel evezh ouzh ar pennlizherennoù
pdfjs-find-match-diacritics-checkbox-label = Doujañ dan tiredoù
pdfjs-find-entire-word-checkbox-label = Gerioù a-bezh pdfjs-find-entire-word-checkbox-label = Gerioù a-bezh
pdfjs-find-reached-top = Tizhet eo bet derou ar bajenn, kenderc'hel diouzh an diaz pdfjs-find-reached-top = Tizhet eo bet derou ar bajenn, kenderc'hel diouzh an diaz
pdfjs-find-reached-bottom = Tizhet eo bet dibenn ar bajenn, kenderc'hel diouzh ar c'hrec'h pdfjs-find-reached-bottom = Tizhet eo bet dibenn ar bajenn, kenderc'hel diouzh ar c'hrec'h
@ -311,3 +306,7 @@ pdfjs-editor-alt-text-save-button = Enrollañ
## Color picker ## Color picker
## Show all highlights
## This is a toggle button to show/hide all the highlights.

View File

@ -51,12 +51,6 @@ pdfjs-download-button-label = Sækja
pdfjs-bookmark-button = pdfjs-bookmark-button =
.title = Núverandi síða (Skoða vefslóð frá núverandi síðu) .title = Núverandi síða (Skoða vefslóð frá núverandi síðu)
pdfjs-bookmark-button-label = Núverandi síða pdfjs-bookmark-button-label = Núverandi síða
# Used in Firefox for Android.
pdfjs-open-in-app-button =
.title = Opna í smáforriti
# Used in Firefox for Android.
# Length of the translation matters since we are in a mobile context, with limited screen estate.
pdfjs-open-in-app-button-label = Opna í smáforriti
## Secondary toolbar and context menu ## Secondary toolbar and context menu
@ -284,7 +278,7 @@ pdfjs-text-annotation-type =
## Password ## Password
pdfjs-password-label = Sláðu inn lykilorð til að opna þessa PDF skrá. pdfjs-password-label = Settu inn lykilorð til að opna þessa PDF-skrá.
pdfjs-password-invalid = Ógilt lykilorð. Reyndu aftur. pdfjs-password-invalid = Ógilt lykilorð. Reyndu aftur.
pdfjs-password-ok-button = Í lagi pdfjs-password-ok-button = Í lagi
pdfjs-password-cancel-button = Hætta við pdfjs-password-cancel-button = Hætta við
@ -304,8 +298,6 @@ pdfjs-editor-stamp-button-label = Bæta við eða breyta myndum
pdfjs-editor-highlight-button = pdfjs-editor-highlight-button =
.title = Áherslulita .title = Áherslulita
pdfjs-editor-highlight-button-label = Áherslulita pdfjs-editor-highlight-button-label = Áherslulita
pdfjs-highlight-floating-button =
.title = Áherslulita
pdfjs-highlight-floating-button1 = pdfjs-highlight-floating-button1 =
.title = Áherslulita .title = Áherslulita
.aria-label = Áherslulita .aria-label = Áherslulita

View File

@ -279,7 +279,7 @@ pdfjs-text-annotation-type =
## Password ## Password
pdfjs-password-label = この PDF ファイルを開くためのパスワードを入力してください。 pdfjs-password-label = この PDF ファイルを開くためのパスワードを入力してください。
pdfjs-password-invalid = 無効なパスワードです。もう一度やり直してください。 pdfjs-password-invalid = パスワードが正しくありません。もう一度試してください。
pdfjs-password-ok-button = OK pdfjs-password-ok-button = OK
pdfjs-password-cancel-button = キャンセル pdfjs-password-cancel-button = キャンセル
pdfjs-web-fonts-disabled = ウェブフォントが無効になっています: 埋め込まれた PDF のフォントを使用できません。 pdfjs-web-fonts-disabled = ウェブフォントが無効になっています: 埋め込まれた PDF のフォントを使用できません。
@ -298,8 +298,6 @@ pdfjs-editor-stamp-button-label = 画像を追加または編集
pdfjs-editor-highlight-button = pdfjs-editor-highlight-button =
.title = 強調します .title = 強調します
pdfjs-editor-highlight-button-label = 強調 pdfjs-editor-highlight-button-label = 強調
pdfjs-highlight-floating-button =
.title = 強調
pdfjs-highlight-floating-button1 = pdfjs-highlight-floating-button1 =
.title = 強調 .title = 強調
.aria-label = 強調します .aria-label = 強調します

View File

@ -51,12 +51,6 @@ pdfjs-download-button-label = Sader
pdfjs-bookmark-button = pdfjs-bookmark-button =
.title = Asebter amiran (Sken-d tansa URL seg usebter amiran) .title = Asebter amiran (Sken-d tansa URL seg usebter amiran)
pdfjs-bookmark-button-label = Asebter amiran pdfjs-bookmark-button-label = Asebter amiran
# Used in Firefox for Android.
pdfjs-open-in-app-button =
.title = Ldi deg usnas
# Used in Firefox for Android.
# Length of the translation matters since we are in a mobile context, with limited screen estate.
pdfjs-open-in-app-button-label = Ldi deg usnas
## Secondary toolbar and context menu ## Secondary toolbar and context menu
@ -301,8 +295,27 @@ pdfjs-editor-ink-button-label = Suneɣ
pdfjs-editor-stamp-button = pdfjs-editor-stamp-button =
.title = Rnu neɣ ẓreg tugniwin .title = Rnu neɣ ẓreg tugniwin
pdfjs-editor-stamp-button-label = Rnu neɣ ẓreg tugniwin pdfjs-editor-stamp-button-label = Rnu neɣ ẓreg tugniwin
pdfjs-editor-remove-button = pdfjs-editor-highlight-button =
.title = Kkes .title = Derrer
pdfjs-editor-highlight-button-label = Derrer
pdfjs-highlight-floating-button1 =
.title = Derrer
.aria-label = Derrer
pdfjs-highlight-floating-button-label = Derrer
## Remove button for the various kind of editor.
pdfjs-editor-remove-ink-button =
.title = Kkes asuneɣ
pdfjs-editor-remove-freetext-button =
.title = Kkes aḍris
pdfjs-editor-remove-stamp-button =
.title = Kkes tugna
pdfjs-editor-remove-highlight-button =
.title = Kkes aderrer
##
# Editor Parameters # Editor Parameters
pdfjs-editor-free-text-color-input = Initen pdfjs-editor-free-text-color-input = Initen
pdfjs-editor-free-text-size-input = Teɣzi pdfjs-editor-free-text-size-input = Teɣzi
@ -312,6 +325,8 @@ pdfjs-editor-ink-opacity-input = Tebrek
pdfjs-editor-stamp-add-image-button = pdfjs-editor-stamp-add-image-button =
.title = Rnu tawlaft .title = Rnu tawlaft
pdfjs-editor-stamp-add-image-button-label = Rnu tawlaft pdfjs-editor-stamp-add-image-button-label = Rnu tawlaft
# This refers to the thickness of the line used for free highlighting (not bound to text)
pdfjs-editor-free-highlight-thickness-input = Tuzert
pdfjs-free-text = pdfjs-free-text =
.aria-label = Amaẓrag n uḍris .aria-label = Amaẓrag n uḍris
pdfjs-free-text-default-content = Bdu tira... pdfjs-free-text-default-content = Bdu tira...
@ -335,3 +350,37 @@ pdfjs-editor-alt-text-decorative-tooltip = Yettwacreḍ d adlag
## Editor resizers ## Editor resizers
## This is used in an aria label to help to understand the role of the resizer. ## This is used in an aria label to help to understand the role of the resizer.
pdfjs-editor-resizer-label-top-left = Tiɣmert n ufella n zelmeḍ — semsawi teɣzi
pdfjs-editor-resizer-label-top-middle = Talemmat n ufella — semsawi teɣzi
pdfjs-editor-resizer-label-top-right = Tiɣmert n ufella n yeffus — semsawi teɣzi
pdfjs-editor-resizer-label-middle-right = Talemmast tayeffust — semsawi teɣzi
pdfjs-editor-resizer-label-bottom-right = Tiɣmert n wadda n yeffus — semsawi teɣzi
pdfjs-editor-resizer-label-bottom-middle = Talemmat n wadda — semsawi teɣzi
pdfjs-editor-resizer-label-bottom-left = Tiɣmert n wadda n zelmeḍ — semsawi teɣzi
pdfjs-editor-resizer-label-middle-left = Talemmast tazelmdaḍt — semsawi teɣzi
## Color picker
# This means "Color used to highlight text"
pdfjs-editor-highlight-colorpicker-label = Ini n uderrer
pdfjs-editor-colorpicker-button =
.title = Senfel ini
pdfjs-editor-colorpicker-dropdown =
.aria-label = Afran n yiniten
pdfjs-editor-colorpicker-yellow =
.title = Awraɣ
pdfjs-editor-colorpicker-green =
.title = Azegzaw
pdfjs-editor-colorpicker-blue =
.title = Amidadi
pdfjs-editor-colorpicker-pink =
.title = Axuxi
pdfjs-editor-colorpicker-red =
.title = Azggaɣ
## Show all highlights
## This is a toggle button to show/hide all the highlights.
pdfjs-editor-highlight-show-all-button-label = Sken akk
pdfjs-editor-highlight-show-all-button =
.title = Sken akk

View File

@ -51,12 +51,6 @@ pdfjs-download-button-label = Last ned
pdfjs-bookmark-button = pdfjs-bookmark-button =
.title = Gjeldande side (sjå URL frå gjeldande side) .title = Gjeldande side (sjå URL frå gjeldande side)
pdfjs-bookmark-button-label = Gjeldande side pdfjs-bookmark-button-label = Gjeldande side
# Used in Firefox for Android.
pdfjs-open-in-app-button =
.title = Opne i app
# Used in Firefox for Android.
# Length of the translation matters since we are in a mobile context, with limited screen estate.
pdfjs-open-in-app-button-label = Opne i app
## Secondary toolbar and context menu ## Secondary toolbar and context menu
@ -301,9 +295,24 @@ pdfjs-editor-ink-button-label = Teikne
pdfjs-editor-stamp-button = pdfjs-editor-stamp-button =
.title = Legg til eller rediger bilde .title = Legg til eller rediger bilde
pdfjs-editor-stamp-button-label = Legg til eller rediger bilde pdfjs-editor-stamp-button-label = Legg til eller rediger bilde
pdfjs-editor-highlight-button =
.title = Markere
pdfjs-editor-highlight-button-label = Markere
pdfjs-highlight-floating-button1 =
.title = Markere
.aria-label = Markere
pdfjs-highlight-floating-button-label = Markere
## Remove button for the various kind of editor. ## Remove button for the various kind of editor.
pdfjs-editor-remove-ink-button =
.title = Fjern teikninga
pdfjs-editor-remove-freetext-button =
.title = Fjern tekst
pdfjs-editor-remove-stamp-button =
.title = Fjern bildet
pdfjs-editor-remove-highlight-button =
.title = Fjern utheving
## ##
@ -316,6 +325,10 @@ pdfjs-editor-ink-opacity-input = Ugjennomskinleg
pdfjs-editor-stamp-add-image-button = pdfjs-editor-stamp-add-image-button =
.title = Legg til bilde .title = Legg til bilde
pdfjs-editor-stamp-add-image-button-label = Legg til bilde pdfjs-editor-stamp-add-image-button-label = Legg til bilde
# This refers to the thickness of the line used for free highlighting (not bound to text)
pdfjs-editor-free-highlight-thickness-input = Tjukkleik
pdfjs-editor-free-highlight-thickness-title =
.title = Endre tjukn når du markerer andre element enn tekst
pdfjs-free-text = pdfjs-free-text =
.aria-label = Tekstredigering .aria-label = Tekstredigering
pdfjs-free-text-default-content = Byrje å skrive… pdfjs-free-text-default-content = Byrje å skrive…
@ -345,9 +358,23 @@ pdfjs-editor-alt-text-textarea =
## Editor resizers ## Editor resizers
## This is used in an aria label to help to understand the role of the resizer. ## This is used in an aria label to help to understand the role of the resizer.
pdfjs-editor-resizer-label-top-left = Øvste venstre hjørne endre størrelse
pdfjs-editor-resizer-label-top-middle = Øvst i midten — endre størrelse
pdfjs-editor-resizer-label-top-right = Øvste høgre hjørne endre størrelse
pdfjs-editor-resizer-label-middle-right = Midt til høgre endre størrelse
pdfjs-editor-resizer-label-bottom-right = Nedste høgre hjørne endre størrelse
pdfjs-editor-resizer-label-bottom-middle = Nedst i midten — endre størrelse
pdfjs-editor-resizer-label-bottom-left = Nedste venstre hjørne endre størrelse
pdfjs-editor-resizer-label-middle-left = Midt til venstre — endre størrelse
## Color picker ## Color picker
# This means "Color used to highlight text"
pdfjs-editor-highlight-colorpicker-label = Uthevingsfarge
pdfjs-editor-colorpicker-button =
.title = Endre farge
pdfjs-editor-colorpicker-dropdown =
.aria-label = Fargeval
pdfjs-editor-colorpicker-yellow = pdfjs-editor-colorpicker-yellow =
.title = Gul .title = Gul
pdfjs-editor-colorpicker-green = pdfjs-editor-colorpicker-green =
@ -358,3 +385,10 @@ pdfjs-editor-colorpicker-pink =
.title = Rosa .title = Rosa
pdfjs-editor-colorpicker-red = pdfjs-editor-colorpicker-red =
.title = Raud .title = Raud
## Show all highlights
## This is a toggle button to show/hide all the highlights.
pdfjs-editor-highlight-show-all-button-label = Vis alle
pdfjs-editor-highlight-show-all-button =
.title = Vis alle

View File

@ -302,6 +302,10 @@ pdfjs-editor-stamp-button-label = Dodajanje ali urejanje slik
pdfjs-editor-highlight-button = pdfjs-editor-highlight-button =
.title = Označevalnik .title = Označevalnik
pdfjs-editor-highlight-button-label = Označevalnik pdfjs-editor-highlight-button-label = Označevalnik
pdfjs-highlight-floating-button1 =
.title = Označi
.aria-label = Označi
pdfjs-highlight-floating-button-label = Označi
## Remove button for the various kind of editor. ## Remove button for the various kind of editor.