Bug 1735409 - Update pdf.js to version 2.12.16 r=pdfjs-reviewers,marco

Differential Revision: https://phabricator.services.mozilla.com/D128291
This commit is contained in:
Brendan Dahl 2021-10-12 23:49:41 +00:00
Родитель 90ef3d34d8
Коммит d44f75dbba
7 изменённых файлов: 821 добавлений и 408 удалений

Просмотреть файл

@ -1,5 +1,5 @@
This is the PDF.js project output, https://github.com/mozilla/pdf.js This is the PDF.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 2.11.298 Current extension version is: 2.12.16
Taken from upstream commit: d370a281c Taken from upstream commit: 394596560

Просмотреть файл

@ -51,14 +51,13 @@ exports.isDataScheme = isDataScheme;
exports.isPdfFile = isPdfFile; exports.isPdfFile = isPdfFile;
exports.isValidFetchUrl = isValidFetchUrl; exports.isValidFetchUrl = isValidFetchUrl;
exports.loadScript = loadScript; exports.loadScript = loadScript;
exports.StatTimer = exports.RenderingCancelledException = exports.PixelsPerInch = exports.PDFDateString = exports.PageViewport = exports.LinkTarget = exports.DOMSVGFactory = exports.DOMStandardFontDataFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = void 0; exports.StatTimer = exports.RenderingCancelledException = exports.PixelsPerInch = exports.PDFDateString = exports.PageViewport = exports.LinkTarget = exports.DOMSVGFactory = exports.DOMStandardFontDataFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = void 0;
var _util = __w_pdfjs_require__(2); var _util = __w_pdfjs_require__(2);
var _base_factory = __w_pdfjs_require__(5); var _base_factory = __w_pdfjs_require__(5);
const DEFAULT_LINK_REL = "noopener noreferrer nofollow"; const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
const SVG_NS = "http://www.w3.org/2000/svg"; const SVG_NS = "http://www.w3.org/2000/svg";
const PixelsPerInch = { const PixelsPerInch = {
CSS: 96.0, CSS: 96.0,
@ -972,12 +971,28 @@ function _isValidProtocol(url) {
} }
} }
function createValidAbsoluteUrl(url, baseUrl) { function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
if (!url) { if (!url) {
return null; return null;
} }
try { try {
if (options && typeof url === "string") {
if (options.addDefaultProtocol && url.startsWith("www.")) {
const dots = url.match(/\./g);
if (dots && dots.length >= 2) {
url = `http://${url}`;
}
}
if (options.tryConvertEncoding) {
try {
url = stringToUTF8String(url);
} catch (ex) {}
}
}
const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url); const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
if (_isValidProtocol(absoluteUrl)) { if (_isValidProtocol(absoluteUrl)) {
@ -1912,7 +1927,7 @@ async function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", { const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", {
docId, docId,
apiVersion: '2.11.298', apiVersion: '2.12.16',
source: { source: {
data: source.data, data: source.data,
url: source.url, url: source.url,
@ -2718,84 +2733,14 @@ exports.PDFPageProxy = PDFPageProxy;
class LoopbackPort { class LoopbackPort {
constructor() { constructor() {
this._listeners = []; this._listeners = [];
this._deferred = Promise.resolve(undefined); this._deferred = Promise.resolve();
} }
postMessage(obj, transfers) { postMessage(obj, transfers) {
function cloneValue(value) { function cloneValue(object) {
if (typeof value === "function" || typeof value === "symbol" || value instanceof URL) { return globalThis.structuredClone(object, transfers);
throw new Error(`LoopbackPort.postMessage - cannot clone: ${value?.toString()}`);
}
if (typeof value !== "object" || value === null) {
return value;
}
if (cloned.has(value)) {
return cloned.get(value);
}
let buffer, result;
if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
if (transfers?.includes(buffer)) {
result = new value.constructor(buffer, value.byteOffset, value.byteLength);
} else {
result = new value.constructor(value);
}
cloned.set(value, result);
return result;
}
if (value instanceof Map) {
result = new Map();
cloned.set(value, result);
for (const [key, val] of value) {
result.set(key, cloneValue(val));
}
return result;
}
if (value instanceof Set) {
result = new Set();
cloned.set(value, result);
for (const val of value) {
result.add(cloneValue(val));
}
return result;
}
result = Array.isArray(value) ? [] : Object.create(null);
cloned.set(value, result);
for (const i in value) {
let desc,
p = value;
while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
p = Object.getPrototypeOf(p);
}
if (typeof desc.value === "undefined") {
continue;
}
if (typeof desc.value === "function" && !value.hasOwnProperty?.(i)) {
continue;
}
result[i] = cloneValue(desc.value);
}
return result;
} }
const cloned = new WeakMap();
const event = { const event = {
data: cloneValue(obj) data: cloneValue(obj)
}; };
@ -3996,9 +3941,9 @@ class InternalRenderTask {
} }
const version = '2.11.298'; const version = '2.12.16';
exports.version = version; exports.version = version;
const build = 'd370a281c'; const build = '394596560';
exports.build = build; exports.build = build;
/***/ }), /***/ }),
@ -7594,10 +7539,10 @@ class MessageHandler {
} }
sendWithStream(actionName, data, queueingStrategy, transfers) { sendWithStream(actionName, data, queueingStrategy, transfers) {
const streamId = this.streamId++; const streamId = this.streamId++,
const sourceName = this.sourceName; sourceName = this.sourceName,
const targetName = this.targetName; targetName = this.targetName,
const comObj = this.comObj; comObj = this.comObj;
return new ReadableStream({ return new ReadableStream({
start: controller => { start: controller => {
const startCapability = (0, _util.createPromiseCapability)(); const startCapability = (0, _util.createPromiseCapability)();
@ -7650,12 +7595,12 @@ class MessageHandler {
} }
_createStreamSink(data) { _createStreamSink(data) {
const self = this; const streamId = data.streamId,
const action = this.actionHandler[data.action]; sourceName = this.sourceName,
const streamId = data.streamId; targetName = data.sourceName,
const sourceName = this.sourceName; comObj = this.comObj;
const targetName = data.sourceName; const self = this,
const comObj = this.comObj; action = this.actionHandler[data.action];
const streamSink = { const streamSink = {
enqueue(chunk, size = 1, transfers) { enqueue(chunk, size = 1, transfers) {
if (this.isCancelled) { if (this.isCancelled) {
@ -7743,32 +7688,34 @@ class MessageHandler {
} }
_processStreamMessage(data) { _processStreamMessage(data) {
const streamId = data.streamId; const streamId = data.streamId,
const sourceName = this.sourceName; sourceName = this.sourceName,
const targetName = data.sourceName; targetName = data.sourceName,
const comObj = this.comObj; comObj = this.comObj;
const streamController = this.streamControllers[streamId],
streamSink = this.streamSinks[streamId];
switch (data.stream) { switch (data.stream) {
case StreamKind.START_COMPLETE: case StreamKind.START_COMPLETE:
if (data.success) { if (data.success) {
this.streamControllers[streamId].startCall.resolve(); streamController.startCall.resolve();
} else { } else {
this.streamControllers[streamId].startCall.reject(wrapReason(data.reason)); streamController.startCall.reject(wrapReason(data.reason));
} }
break; break;
case StreamKind.PULL_COMPLETE: case StreamKind.PULL_COMPLETE:
if (data.success) { if (data.success) {
this.streamControllers[streamId].pullCall.resolve(); streamController.pullCall.resolve();
} else { } else {
this.streamControllers[streamId].pullCall.reject(wrapReason(data.reason)); streamController.pullCall.reject(wrapReason(data.reason));
} }
break; break;
case StreamKind.PULL: case StreamKind.PULL:
if (!this.streamSinks[streamId]) { if (!streamSink) {
comObj.postMessage({ comObj.postMessage({
sourceName, sourceName,
targetName, targetName,
@ -7779,16 +7726,13 @@ class MessageHandler {
break; break;
} }
if (this.streamSinks[streamId].desiredSize <= 0 && data.desiredSize > 0) { if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
this.streamSinks[streamId].sinkCapability.resolve(); streamSink.sinkCapability.resolve();
} }
this.streamSinks[streamId].desiredSize = data.desiredSize; streamSink.desiredSize = data.desiredSize;
const {
onPull
} = this.streamSinks[streamId];
new Promise(function (resolve) { new Promise(function (resolve) {
resolve(onPull && onPull()); resolve(streamSink.onPull && streamSink.onPull());
}).then(function () { }).then(function () {
comObj.postMessage({ comObj.postMessage({
sourceName, sourceName,
@ -7809,58 +7753,55 @@ class MessageHandler {
break; break;
case StreamKind.ENQUEUE: case StreamKind.ENQUEUE:
(0, _util.assert)(this.streamControllers[streamId], "enqueue should have stream controller"); (0, _util.assert)(streamController, "enqueue should have stream controller");
if (this.streamControllers[streamId].isClosed) { if (streamController.isClosed) {
break; break;
} }
this.streamControllers[streamId].controller.enqueue(data.chunk); streamController.controller.enqueue(data.chunk);
break; break;
case StreamKind.CLOSE: case StreamKind.CLOSE:
(0, _util.assert)(this.streamControllers[streamId], "close should have stream controller"); (0, _util.assert)(streamController, "close should have stream controller");
if (this.streamControllers[streamId].isClosed) { if (streamController.isClosed) {
break; break;
} }
this.streamControllers[streamId].isClosed = true; streamController.isClosed = true;
this.streamControllers[streamId].controller.close(); streamController.controller.close();
this._deleteStreamController(streamId); this._deleteStreamController(streamController, streamId);
break; break;
case StreamKind.ERROR: case StreamKind.ERROR:
(0, _util.assert)(this.streamControllers[streamId], "error should have stream controller"); (0, _util.assert)(streamController, "error should have stream controller");
this.streamControllers[streamId].controller.error(wrapReason(data.reason)); streamController.controller.error(wrapReason(data.reason));
this._deleteStreamController(streamId); this._deleteStreamController(streamController, streamId);
break; break;
case StreamKind.CANCEL_COMPLETE: case StreamKind.CANCEL_COMPLETE:
if (data.success) { if (data.success) {
this.streamControllers[streamId].cancelCall.resolve(); streamController.cancelCall.resolve();
} else { } else {
this.streamControllers[streamId].cancelCall.reject(wrapReason(data.reason)); streamController.cancelCall.reject(wrapReason(data.reason));
} }
this._deleteStreamController(streamId); this._deleteStreamController(streamController, streamId);
break; break;
case StreamKind.CANCEL: case StreamKind.CANCEL:
if (!this.streamSinks[streamId]) { if (!streamSink) {
break; break;
} }
const {
onCancel
} = this.streamSinks[streamId];
new Promise(function (resolve) { new Promise(function (resolve) {
resolve(onCancel && onCancel(wrapReason(data.reason))); resolve(streamSink.onCancel && streamSink.onCancel(wrapReason(data.reason)));
}).then(function () { }).then(function () {
comObj.postMessage({ comObj.postMessage({
sourceName, sourceName,
@ -7878,8 +7819,8 @@ class MessageHandler {
reason: wrapReason(reason) reason: wrapReason(reason)
}); });
}); });
this.streamSinks[streamId].sinkCapability.reject(wrapReason(data.reason)); streamSink.sinkCapability.reject(wrapReason(data.reason));
this.streamSinks[streamId].isCancelled = true; streamSink.isCancelled = true;
delete this.streamSinks[streamId]; delete this.streamSinks[streamId];
break; break;
@ -7888,10 +7829,8 @@ class MessageHandler {
} }
} }
async _deleteStreamController(streamId) { async _deleteStreamController(streamController, streamId) {
await Promise.allSettled([this.streamControllers[streamId].startCall, this.streamControllers[streamId].pullCall, this.streamControllers[streamId].cancelCall].map(function (capability) { await Promise.allSettled([streamController.startCall && streamController.startCall.promise, streamController.pullCall && streamController.pullCall.promise, streamController.cancelCall && streamController.cancelCall.promise]);
return capability && capability.promise;
}));
delete this.streamControllers[streamId]; delete this.streamControllers[streamId];
} }
@ -8604,10 +8543,10 @@ Object.defineProperty(exports, "__esModule", ({
})); }));
exports.AnnotationLayer = void 0; exports.AnnotationLayer = void 0;
var _display_utils = __w_pdfjs_require__(1);
var _util = __w_pdfjs_require__(2); var _util = __w_pdfjs_require__(2);
var _display_utils = __w_pdfjs_require__(1);
var _annotation_storage = __w_pdfjs_require__(9); var _annotation_storage = __w_pdfjs_require__(9);
var _scripting_utils = __w_pdfjs_require__(19); var _scripting_utils = __w_pdfjs_require__(19);
@ -8786,7 +8725,9 @@ class AnnotationElement {
break; break;
} }
if (data.color) { const borderColor = data.borderColor || data.color || null;
if (borderColor) {
container.style.borderColor = _util.Util.makeHexColor(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0); container.style.borderColor = _util.Util.makeHexColor(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
} else { } else {
container.style.borderWidth = 0; container.style.borderWidth = 0;
@ -8836,9 +8777,9 @@ class AnnotationElement {
container, container,
trigger, trigger,
color: data.color, color: data.color,
title: data.title, titleObj: data.titleObj,
modificationDate: data.modificationDate, modificationDate: data.modificationDate,
contents: data.contents, contentsObj: data.contentsObj,
hideWrapper: true hideWrapper: true
}); });
const popup = popupElement.render(); const popup = popupElement.render();
@ -8933,7 +8874,7 @@ class AnnotationElement {
class LinkAnnotationElement extends AnnotationElement { class LinkAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action || parameters.data.isTooltipOnly || parameters.data.actions && (parameters.data.actions.Action || parameters.data.actions["Mouse Up"] || parameters.data.actions["Mouse Down"])); const isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action || parameters.data.isTooltipOnly || parameters.data.resetForm || parameters.data.actions && (parameters.data.actions.Action || parameters.data.actions["Mouse Up"] || parameters.data.actions["Mouse Down"]));
super(parameters, { super(parameters, {
isRenderable, isRenderable,
createQuadrilaterals: true createQuadrilaterals: true
@ -8948,20 +8889,25 @@ class LinkAnnotationElement extends AnnotationElement {
const link = document.createElement("a"); const link = document.createElement("a");
if (data.url) { if (data.url) {
(0, _display_utils.addLinkAttributes)(link, { linkService.addLinkAttributes?.(link, data.url, data.newWindow);
url: data.url,
target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
rel: linkService.externalLinkRel,
enabled: linkService.externalLinkEnabled
});
} else if (data.action) { } else if (data.action) {
this._bindNamedAction(link, data.action); this._bindNamedAction(link, data.action);
} else if (data.dest) { } else if (data.dest) {
this._bindLink(link, data.dest); this._bindLink(link, data.dest);
} else if (data.actions && (data.actions.Action || data.actions["Mouse Up"] || data.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions) {
this._bindJSAction(link, data);
} else { } else {
this._bindLink(link, ""); let hasClickAction = false;
if (data.actions && (data.actions.Action || data.actions["Mouse Up"] || data.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions) {
hasClickAction = true;
this._bindJSAction(link, data);
}
if (data.resetForm) {
this._bindResetFormAction(link, data.resetForm);
} else if (!hasClickAction) {
this._bindLink(link, "");
}
} }
if (this.quadrilaterals) { if (this.quadrilaterals) {
@ -9034,11 +8980,136 @@ class LinkAnnotationElement extends AnnotationElement {
link.className = "internalLink"; link.className = "internalLink";
} }
_bindResetFormAction(link, resetForm) {
const otherClickAction = link.onclick;
if (!otherClickAction) {
link.href = this.linkService.getAnchorUrl("");
}
link.className = "internalLink";
if (!this._fieldObjects) {
(0, _util.warn)(`_bindResetFormAction - "resetForm" action not supported, ` + "ensure that the `fieldObjects` parameter is provided.");
if (!otherClickAction) {
link.onclick = () => false;
}
return;
}
link.onclick = () => {
if (otherClickAction) {
otherClickAction();
}
const {
fields: resetFormFields,
refs: resetFormRefs,
include
} = resetForm;
const allFields = [];
if (resetFormFields.length !== 0 || resetFormRefs.length !== 0) {
const fieldIds = new Set(resetFormRefs);
for (const fieldName of resetFormFields) {
const fields = this._fieldObjects[fieldName] || [];
for (const {
id
} of fields) {
fieldIds.add(id);
}
}
for (const fields of Object.values(this._fieldObjects)) {
for (const field of fields) {
if (fieldIds.has(field.id) === include) {
allFields.push(field);
}
}
}
} else {
for (const fields of Object.values(this._fieldObjects)) {
allFields.push(...fields);
}
}
const storage = this.annotationStorage;
const allIds = [];
for (const field of allFields) {
const {
id
} = field;
allIds.push(id);
switch (field.type) {
case "text":
{
const value = field.defaultValue || "";
storage.setValue(id, {
value,
valueAsString: value
});
break;
}
case "checkbox":
case "radiobutton":
{
const value = field.defaultValue === field.exportValues;
storage.setValue(id, {
value
});
break;
}
case "combobox":
case "listbox":
{
const value = field.defaultValue || "";
storage.setValue(id, {
value
});
break;
}
default:
continue;
}
const domElement = document.getElementById(id);
if (!domElement || !GetElementsByNameSet.has(domElement)) {
continue;
}
domElement.dispatchEvent(new Event("resetform"));
}
if (this.enableScripting) {
this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
source: this,
detail: {
id: "app",
ids: allIds,
name: "ResetForm"
}
});
}
return false;
};
}
} }
class TextAnnotationElement extends AnnotationElement { class TextAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable isRenderable
}); });
@ -9119,6 +9190,11 @@ class WidgetAnnotationElement extends AnnotationElement {
} }
} }
_setBackgroundColor(element) {
const color = this.data.backgroundColor || null;
element.style.backgroundColor = color === null ? "transparent" : _util.Util.makeHexColor(color[0], color[1], color[2]);
}
_dispatchEventFromSandbox(actions, jsEvent) { _dispatchEventFromSandbox(actions, jsEvent) {
const setColor = (jsName, styleName, event) => { const setColor = (jsName, styleName, event) => {
const color = event.detail[jsName]; const color = event.detail[jsName];
@ -9260,6 +9336,11 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
}); });
this.setPropertyOnSiblings(element, "value", event.target.value, "value"); this.setPropertyOnSiblings(element, "value", event.target.value, "value");
}); });
element.addEventListener("resetform", event => {
const defaultValue = this.data.defaultFieldValue || "";
element.value = elementData.userValue = defaultValue;
delete elementData.formattedValue;
});
let blurListener = event => { let blurListener = event => {
if (elementData.formattedValue) { if (elementData.formattedValue) {
@ -9427,6 +9508,8 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
this._setTextStyle(element); this._setTextStyle(element);
this._setBackgroundColor(element);
this.container.appendChild(element); this.container.appendChild(element);
return this.container; return this.container;
} }
@ -9464,7 +9547,7 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
const data = this.data; const data = this.data;
const id = data.id; const id = data.id;
let value = storage.getValue(id, { let value = storage.getValue(id, {
value: data.fieldValue && (data.exportValue && data.exportValue === data.fieldValue || !data.exportValue && data.fieldValue !== "Off") value: data.exportValue === data.fieldValue
}).value; }).value;
if (typeof value === "string") { if (typeof value === "string") {
@ -9510,6 +9593,10 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
value: checked value: checked
}); });
}); });
element.addEventListener("resetform", event => {
const defaultValue = data.defaultFieldValue || "Off";
event.target.checked = defaultValue === data.exportValue;
});
if (this.enableScripting && this.hasJSActions) { if (this.enableScripting && this.hasJSActions) {
element.addEventListener("updatefromsandbox", jsEvent => { element.addEventListener("updatefromsandbox", jsEvent => {
@ -9529,6 +9616,8 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked); this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
} }
this._setBackgroundColor(element);
this.container.appendChild(element); this.container.appendChild(element);
return this.container; return this.container;
} }
@ -9586,6 +9675,10 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
value: checked value: checked
}); });
}); });
element.addEventListener("resetform", event => {
const defaultValue = data.defaultFieldValue;
event.target.checked = defaultValue !== null && defaultValue !== undefined && defaultValue === data.buttonValue;
});
if (this.enableScripting && this.hasJSActions) { if (this.enableScripting && this.hasJSActions) {
const pdfButtonValue = data.buttonValue; const pdfButtonValue = data.buttonValue;
@ -9614,6 +9707,8 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked); this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
} }
this._setBackgroundColor(element);
this.container.appendChild(element); this.container.appendChild(element);
return this.container; return this.container;
} }
@ -9673,6 +9768,14 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
} }
} }
selectElement.addEventListener("resetform", event => {
const defaultValue = this.data.defaultFieldValue;
for (const option of selectElement.options) {
option.selected = option.value === defaultValue;
}
});
for (const option of this.data.options) { for (const option of this.data.options) {
const optionElement = document.createElement("option"); const optionElement = document.createElement("option");
optionElement.textContent = option.displayValue; optionElement.textContent = option.displayValue;
@ -9714,12 +9817,13 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
selectElement.addEventListener("updatefromsandbox", jsEvent => { selectElement.addEventListener("updatefromsandbox", jsEvent => {
const actions = { const actions = {
value(event) { value(event) {
const options = selectElement.options;
const value = event.detail.value; const value = event.detail.value;
const values = new Set(Array.isArray(value) ? value : [value]); const values = new Set(Array.isArray(value) ? value : [value]);
Array.prototype.forEach.call(options, option => {
for (const option of selectElement.options) {
option.selected = values.has(option.value); option.selected = values.has(option.value);
}); }
storage.setValue(id, { storage.setValue(id, {
value: getValue(event, true) value: getValue(event, true)
}); });
@ -9808,10 +9912,11 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
indices(event) { indices(event) {
const indices = new Set(event.detail.indices); const indices = new Set(event.detail.indices);
const options = event.target.options;
Array.prototype.forEach.call(options, (option, i) => { for (const option of event.target.options) {
option.selected = indices.has(i); option.selected = indices.has(option.index);
}); }
storage.setValue(id, { storage.setValue(id, {
value: getValue(event, true) value: getValue(event, true)
}); });
@ -9854,6 +9959,8 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
}); });
} }
this._setBackgroundColor(selectElement);
this.container.appendChild(selectElement); this.container.appendChild(selectElement);
return this.container; return this.container;
} }
@ -9862,7 +9969,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
class PopupAnnotationElement extends AnnotationElement { class PopupAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable isRenderable
}); });
@ -9887,9 +9994,9 @@ class PopupAnnotationElement extends AnnotationElement {
container: this.container, container: this.container,
trigger: Array.from(parentElements), trigger: Array.from(parentElements),
color: this.data.color, color: this.data.color,
title: this.data.title, titleObj: this.data.titleObj,
modificationDate: this.data.modificationDate, modificationDate: this.data.modificationDate,
contents: this.data.contents contentsObj: this.data.contentsObj
}); });
const page = this.page; const page = this.page;
@ -9911,9 +10018,9 @@ class PopupElement {
this.container = parameters.container; this.container = parameters.container;
this.trigger = parameters.trigger; this.trigger = parameters.trigger;
this.color = parameters.color; this.color = parameters.color;
this.title = parameters.title; this.titleObj = parameters.titleObj;
this.modificationDate = parameters.modificationDate; this.modificationDate = parameters.modificationDate;
this.contents = parameters.contents; this.contentsObj = parameters.contentsObj;
this.hideWrapper = parameters.hideWrapper || false; this.hideWrapper = parameters.hideWrapper || false;
this.pinned = false; this.pinned = false;
} }
@ -9936,7 +10043,8 @@ class PopupElement {
} }
const title = document.createElement("h1"); const title = document.createElement("h1");
title.textContent = this.title; title.dir = this.titleObj.dir;
title.textContent = this.titleObj.str;
popup.appendChild(title); popup.appendChild(title);
const dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate); const dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
@ -9952,7 +10060,7 @@ class PopupElement {
popup.appendChild(modificationDate); popup.appendChild(modificationDate);
} }
const contents = this._formatContents(this.contents); const contents = this._formatContents(this.contentsObj);
popup.appendChild(contents); popup.appendChild(contents);
@ -9971,9 +10079,13 @@ class PopupElement {
return wrapper; return wrapper;
} }
_formatContents(contents) { _formatContents({
str,
dir
}) {
const p = document.createElement("p"); const p = document.createElement("p");
const lines = contents.split(/(?:\r\n?|\n)/); p.dir = dir;
const lines = str.split(/(?:\r\n?|\n)/);
for (let i = 0, ii = lines.length; i < ii; ++i) { for (let i = 0, ii = lines.length; i < ii; ++i) {
const line = lines[i]; const line = lines[i];
@ -10021,7 +10133,7 @@ class PopupElement {
class FreeTextAnnotationElement extends AnnotationElement { class FreeTextAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true ignoreBorder: true
@ -10042,7 +10154,7 @@ class FreeTextAnnotationElement extends AnnotationElement {
class LineAnnotationElement extends AnnotationElement { class LineAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true ignoreBorder: true
@ -10062,6 +10174,7 @@ class LineAnnotationElement extends AnnotationElement {
line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]); line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
line.setAttribute("stroke-width", data.borderStyle.width || 1); line.setAttribute("stroke-width", data.borderStyle.width || 1);
line.setAttribute("stroke", "transparent"); line.setAttribute("stroke", "transparent");
line.setAttribute("fill", "transparent");
svg.appendChild(line); svg.appendChild(line);
this.container.append(svg); this.container.append(svg);
@ -10074,7 +10187,7 @@ class LineAnnotationElement extends AnnotationElement {
class SquareAnnotationElement extends AnnotationElement { class SquareAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true ignoreBorder: true
@ -10095,7 +10208,7 @@ class SquareAnnotationElement extends AnnotationElement {
square.setAttribute("height", height - borderWidth); square.setAttribute("height", height - borderWidth);
square.setAttribute("stroke-width", borderWidth || 1); square.setAttribute("stroke-width", borderWidth || 1);
square.setAttribute("stroke", "transparent"); square.setAttribute("stroke", "transparent");
square.setAttribute("fill", "none"); square.setAttribute("fill", "transparent");
svg.appendChild(square); svg.appendChild(square);
this.container.append(svg); this.container.append(svg);
@ -10108,7 +10221,7 @@ class SquareAnnotationElement extends AnnotationElement {
class CircleAnnotationElement extends AnnotationElement { class CircleAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true ignoreBorder: true
@ -10129,7 +10242,7 @@ class CircleAnnotationElement extends AnnotationElement {
circle.setAttribute("ry", height / 2 - borderWidth / 2); circle.setAttribute("ry", height / 2 - borderWidth / 2);
circle.setAttribute("stroke-width", borderWidth || 1); circle.setAttribute("stroke-width", borderWidth || 1);
circle.setAttribute("stroke", "transparent"); circle.setAttribute("stroke", "transparent");
circle.setAttribute("fill", "none"); circle.setAttribute("fill", "transparent");
svg.appendChild(circle); svg.appendChild(circle);
this.container.append(svg); this.container.append(svg);
@ -10142,7 +10255,7 @@ class CircleAnnotationElement extends AnnotationElement {
class PolylineAnnotationElement extends AnnotationElement { class PolylineAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true ignoreBorder: true
@ -10170,7 +10283,7 @@ class PolylineAnnotationElement extends AnnotationElement {
polyline.setAttribute("points", points); polyline.setAttribute("points", points);
polyline.setAttribute("stroke-width", data.borderStyle.width || 1); polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
polyline.setAttribute("stroke", "transparent"); polyline.setAttribute("stroke", "transparent");
polyline.setAttribute("fill", "none"); polyline.setAttribute("fill", "transparent");
svg.appendChild(polyline); svg.appendChild(polyline);
this.container.append(svg); this.container.append(svg);
@ -10192,7 +10305,7 @@ class PolygonAnnotationElement extends PolylineAnnotationElement {
class CaretAnnotationElement extends AnnotationElement { class CaretAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true ignoreBorder: true
@ -10213,7 +10326,7 @@ class CaretAnnotationElement extends AnnotationElement {
class InkAnnotationElement extends AnnotationElement { class InkAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true ignoreBorder: true
@ -10243,7 +10356,7 @@ class InkAnnotationElement extends AnnotationElement {
polyline.setAttribute("points", points); polyline.setAttribute("points", points);
polyline.setAttribute("stroke-width", data.borderStyle.width || 1); polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
polyline.setAttribute("stroke", "transparent"); polyline.setAttribute("stroke", "transparent");
polyline.setAttribute("fill", "none"); polyline.setAttribute("fill", "transparent");
this._createPopup(polyline, data); this._createPopup(polyline, data);
@ -10258,7 +10371,7 @@ class InkAnnotationElement extends AnnotationElement {
class HighlightAnnotationElement extends AnnotationElement { class HighlightAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true, ignoreBorder: true,
@ -10283,7 +10396,7 @@ class HighlightAnnotationElement extends AnnotationElement {
class UnderlineAnnotationElement extends AnnotationElement { class UnderlineAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true, ignoreBorder: true,
@ -10308,7 +10421,7 @@ class UnderlineAnnotationElement extends AnnotationElement {
class SquigglyAnnotationElement extends AnnotationElement { class SquigglyAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true, ignoreBorder: true,
@ -10333,7 +10446,7 @@ class SquigglyAnnotationElement extends AnnotationElement {
class StrikeOutAnnotationElement extends AnnotationElement { class StrikeOutAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true, ignoreBorder: true,
@ -10358,7 +10471,7 @@ class StrikeOutAnnotationElement extends AnnotationElement {
class StampAnnotationElement extends AnnotationElement { class StampAnnotationElement extends AnnotationElement {
constructor(parameters) { constructor(parameters) {
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); const isRenderable = !!(parameters.data.hasPopup || parameters.data.titleObj?.str || parameters.data.contentsObj?.str);
super(parameters, { super(parameters, {
isRenderable, isRenderable,
ignoreBorder: true ignoreBorder: true
@ -10403,7 +10516,7 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
trigger.style.width = this.container.style.width; trigger.style.width = this.container.style.width;
trigger.addEventListener("dblclick", this._download.bind(this)); trigger.addEventListener("dblclick", this._download.bind(this));
if (!this.data.hasPopup && (this.data.title || this.data.contents)) { if (!this.data.hasPopup && (this.data.titleObj?.str || this.data.contentsObj?.str)) {
this._createPopup(trigger, this.data); this._createPopup(trigger, this.data);
} }
@ -11388,6 +11501,8 @@ Object.defineProperty(exports, "__esModule", ({
})); }));
exports.XfaLayer = void 0; exports.XfaLayer = void 0;
var _util = __w_pdfjs_require__(2);
var _xfa_text = __w_pdfjs_require__(17); var _xfa_text = __w_pdfjs_require__(17);
class XfaLayer { class XfaLayer {
@ -11468,10 +11583,17 @@ class XfaLayer {
} }
} }
static setAttributes(html, element, storage, intent) { static setAttributes({
html,
element,
storage = null,
intent,
linkService
}) {
const { const {
attributes attributes
} = element; } = element;
const isHTMLAnchorElement = html instanceof HTMLAnchorElement;
if (attributes.type === "radio") { if (attributes.type === "radio") {
attributes.name = `${attributes.name}-${intent}`; attributes.name = `${attributes.name}-${intent}`;
@ -11488,6 +11610,10 @@ class XfaLayer {
} else if (key === "class") { } else if (key === "class") {
html.setAttribute(key, value.join(" ")); html.setAttribute(key, value.join(" "));
} else { } else {
if (isHTMLAnchorElement && (key === "href" || key === "newWindow")) {
continue;
}
html.setAttribute(key, value); html.setAttribute(key, value);
} }
} else { } else {
@ -11495,6 +11621,10 @@ class XfaLayer {
} }
} }
if (isHTMLAnchorElement) {
linkService.addLinkAttributes?.(html, attributes.href, attributes.newWindow);
}
if (storage && attributes.dataId) { if (storage && attributes.dataId) {
this.setupStorage(html, attributes.dataId, element, storage); this.setupStorage(html, attributes.dataId, element, storage);
} }
@ -11502,12 +11632,18 @@ class XfaLayer {
static render(parameters) { static render(parameters) {
const storage = parameters.annotationStorage; const storage = parameters.annotationStorage;
const linkService = parameters.linkService;
const root = parameters.xfa; const root = parameters.xfa;
const intent = parameters.intent || "display"; const intent = parameters.intent || "display";
const rootHtml = document.createElement(root.name); const rootHtml = document.createElement(root.name);
if (root.attributes) { if (root.attributes) {
this.setAttributes(rootHtml, root); this.setAttributes({
html: rootHtml,
element: root,
intent,
linkService
});
} }
const stack = [[root, -1, rootHtml]]; const stack = [[root, -1, rootHtml]];
@ -11554,7 +11690,13 @@ class XfaLayer {
html.appendChild(childHtml); html.appendChild(childHtml);
if (child.attributes) { if (child.attributes) {
this.setAttributes(childHtml, child, storage, intent); this.setAttributes({
html: childHtml,
element: child,
storage,
intent,
linkService
});
} }
if (child.children && child.children.length > 0) { if (child.children && child.children.length > 0) {
@ -11867,8 +12009,8 @@ var _svg = __w_pdfjs_require__(21);
var _xfa_layer = __w_pdfjs_require__(22); var _xfa_layer = __w_pdfjs_require__(22);
const pdfjsVersion = '2.11.298'; const pdfjsVersion = '2.12.16';
const pdfjsBuild = 'd370a281c'; const pdfjsBuild = '394596560';
; ;
})(); })();

Просмотреть файл

@ -927,6 +927,10 @@ class Field extends _pdf_object.PDFObject {
return false; return false;
} }
_reset() {
this.value = this.valueAsString = this.defaultValue;
}
_runActions(event) { _runActions(event) {
const eventName = event.name; const eventName = event.name;
@ -2643,6 +2647,14 @@ class EventDispatcher {
this._document.obj._dispatchDocEvent(event.name); this._document.obj._dispatchDocEvent(event.name);
} else if (id === "page") { } else if (id === "page") {
this._document.obj._dispatchPageEvent(event.name, baseEvent.actions, baseEvent.pageNumber); this._document.obj._dispatchPageEvent(event.name, baseEvent.actions, baseEvent.pageNumber);
} else if (id === "app" && baseEvent.name === "ResetForm") {
for (const fieldId of baseEvent.ids) {
const obj = this._objects[fieldId];
if (obj) {
obj.obj._reset();
}
}
} }
return; return;
@ -4932,8 +4944,8 @@ Object.defineProperty(exports, "initSandbox", ({
var _initialization = __w_pdfjs_require__(1); var _initialization = __w_pdfjs_require__(1);
const pdfjsVersion = '2.11.298'; const pdfjsVersion = '2.12.16';
const pdfjsBuild = 'd370a281c'; const pdfjsBuild = '394596560';
})(); })();
/******/ return __webpack_exports__; /******/ return __webpack_exports__;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -87,6 +87,10 @@
} }
:root {
--annotation-unfocused-field-background: url("data:image/svg+xml;charset=UTF-8,<svg width='1px' height='1px' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' style='fill:rgba(0, 54, 255, 0.13);'/></svg>");
}
.annotationLayer section { .annotationLayer section {
position: absolute; position: absolute;
text-align: initial; text-align: initial;
@ -119,7 +123,7 @@
.annotationLayer .choiceWidgetAnnotation select, .annotationLayer .choiceWidgetAnnotation select,
.annotationLayer .buttonWidgetAnnotation.checkBox input, .annotationLayer .buttonWidgetAnnotation.checkBox input,
.annotationLayer .buttonWidgetAnnotation.radioButton input { .annotationLayer .buttonWidgetAnnotation.radioButton input {
background-color: rgba(0, 54, 255, 0.13); background-image: var(--annotation-unfocused-field-background);
border: 1px solid transparent; border: 1px solid transparent;
box-sizing: border-box; box-sizing: border-box;
font-size: 9px; font-size: 9px;
@ -174,6 +178,8 @@
.annotationLayer .choiceWidgetAnnotation select :focus, .annotationLayer .choiceWidgetAnnotation select :focus,
.annotationLayer .buttonWidgetAnnotation.checkBox :focus, .annotationLayer .buttonWidgetAnnotation.checkBox :focus,
.annotationLayer .buttonWidgetAnnotation.radioButton :focus { .annotationLayer .buttonWidgetAnnotation.radioButton :focus {
background-image: none;
background-color: transparent;
outline: auto; outline: auto;
} }
@ -290,7 +296,7 @@
:root { :root {
--unfocused-field-background: url("data:image/svg+xml;charset=UTF-8,<svg width='1px' height='1px' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' style='fill:rgba(0, 54, 255, 0.13);'/></svg>"); --xfa-unfocused-field-background: url("data:image/svg+xml;charset=UTF-8,<svg width='1px' height='1px' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' style='fill:rgba(0, 54, 255, 0.13);'/></svg>");
} }
.xfaLayer .highlight { .xfaLayer .highlight {
@ -478,7 +484,7 @@
flex: 1 1 auto; flex: 1 1 auto;
border: none; border: none;
resize: none; resize: none;
background-image: var(--unfocused-field-background); background-image: var(--xfa-unfocused-field-background);
} }
.xfaTop > .xfaTextfield, .xfaTop > .xfaTextfield,
@ -496,6 +502,11 @@
text-align: center; text-align: center;
} }
.xfaLink {
width: 100%;
height: 100%;
}
.xfaCheckbox, .xfaCheckbox,
.xfaRadio { .xfaRadio {
width: 100%; width: 100%;
@ -871,7 +882,6 @@
@media screen and (forced-colors: active) { @media screen and (forced-colors: active) {
:root { :root {
--main-color: ButtonText;
--button-hover-color: Highlight; --button-hover-color: Highlight;
--doorhanger-hover-bg-color: Highlight; --doorhanger-hover-bg-color: Highlight;
--toolbar-icon-opacity: 1; --toolbar-icon-opacity: 1;

Просмотреть файл

@ -4045,7 +4045,7 @@ class PDFRenderingQueue {
} }
} }
getHighestPriority(visible, views, scrolledDown) { getHighestPriority(visible, views, scrolledDown, preRenderExtra = false) {
const visibleViews = visible.views; const visibleViews = visible.views;
const numVisible = visibleViews.length; const numVisible = visibleViews.length;
@ -4061,17 +4061,19 @@ class PDFRenderingQueue {
} }
} }
if (scrolledDown) { let preRenderIndex = scrolledDown ? visible.last.id : visible.first.id - 2;
const nextPageIndex = visible.last.id; let preRenderView = views[preRenderIndex];
if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) { if (preRenderView && !this.isViewFinished(preRenderView)) {
return views[nextPageIndex]; return preRenderView;
} }
} else {
const previousPageIndex = visible.first.id - 2;
if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) { if (preRenderExtra) {
return views[previousPageIndex]; preRenderIndex += scrolledDown ? 1 : -1;
preRenderView = views[preRenderIndex];
if (preRenderView && !this.isViewFinished(preRenderView)) {
return preRenderView;
} }
} }
@ -6693,6 +6695,8 @@ Object.defineProperty(exports, "__esModule", ({
})); }));
exports.SimpleLinkService = exports.PDFLinkService = void 0; exports.SimpleLinkService = exports.PDFLinkService = void 0;
var _pdfjsLib = __webpack_require__(4);
var _ui_utils = __webpack_require__(3); var _ui_utils = __webpack_require__(3);
class PDFLinkService { class PDFLinkService {
@ -6838,6 +6842,15 @@ class PDFLinkService {
}); });
} }
addLinkAttributes(link, url, newWindow = false) {
(0, _pdfjsLib.addLinkAttributes)(link, {
url,
target: newWindow ? _pdfjsLib.LinkTarget.BLANK : this.externalLinkTarget,
rel: this.externalLinkRel,
enabled: this.externalLinkEnabled
});
}
getDestinationHash(dest) { getDestinationHash(dest) {
if (typeof dest === "string") { if (typeof dest === "string") {
if (dest.length > 0) { if (dest.length > 0) {
@ -7086,10 +7099,7 @@ function isValidExplicitDestination(dest) {
class SimpleLinkService { class SimpleLinkService {
constructor() { constructor() {
this.externalLinkTarget = null;
this.externalLinkRel = null;
this.externalLinkEnabled = true; this.externalLinkEnabled = true;
this._ignoreDestinationZoom = false;
} }
get pagesCount() { get pagesCount() {
@ -7112,6 +7122,13 @@ class SimpleLinkService {
goToPage(val) {} goToPage(val) {}
addLinkAttributes(link, url, newWindow = false) {
(0, _pdfjsLib.addLinkAttributes)(link, {
url,
enabled: this.externalLinkEnabled
});
}
getDestinationHash(dest) { getDestinationHash(dest) {
return "#"; return "#";
} }
@ -7149,10 +7166,10 @@ Object.defineProperty(exports, "__esModule", ({
})); }));
exports.PDFOutlineViewer = void 0; exports.PDFOutlineViewer = void 0;
var _pdfjsLib = __webpack_require__(4);
var _base_tree_viewer = __webpack_require__(11); var _base_tree_viewer = __webpack_require__(11);
var _pdfjsLib = __webpack_require__(4);
var _ui_utils = __webpack_require__(3); var _ui_utils = __webpack_require__(3);
class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer { class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
@ -7221,12 +7238,7 @@ class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
} = this; } = this;
if (url) { if (url) {
(0, _pdfjsLib.addLinkAttributes)(element, { linkService.addLinkAttributes(element, url, newWindow);
url,
target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
rel: linkService.externalLinkRel,
enabled: linkService.externalLinkEnabled
});
return; return;
} }
@ -9682,7 +9694,7 @@ class BaseViewer {
throw new Error("Cannot initialize BaseViewer."); throw new Error("Cannot initialize BaseViewer.");
} }
const viewerVersion = '2.11.298'; const viewerVersion = '2.12.16';
if (_pdfjsLib.version !== viewerVersion) { if (_pdfjsLib.version !== viewerVersion) {
throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`); throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
@ -10633,7 +10645,8 @@ class BaseViewer {
const visiblePages = currentlyVisiblePages || this._getVisiblePages(); const visiblePages = currentlyVisiblePages || this._getVisiblePages();
const scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down; const scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead); const preRenderExtra = this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode !== _ui_utils.SpreadMode.NONE && !this.isInPresentationMode;
const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
if (pageView) { if (pageView) {
this._ensurePdfPageLoaded(pageView).then(() => { this._ensurePdfPageLoaded(pageView).then(() => {
@ -10686,7 +10699,8 @@ class BaseViewer {
return new _xfa_layer_builder.XfaLayerBuilder({ return new _xfa_layer_builder.XfaLayerBuilder({
pageDiv, pageDiv,
pdfPage, pdfPage,
annotationStorage: annotationStorage || this.pdfDocument?.annotationStorage annotationStorage: annotationStorage || this.pdfDocument?.annotationStorage,
linkService: this.linkService
}); });
} }
@ -12624,6 +12638,8 @@ Object.defineProperty(exports, "__esModule", ({
})); }));
exports.XfaLayerBuilder = exports.DefaultXfaLayerFactory = void 0; exports.XfaLayerBuilder = exports.DefaultXfaLayerFactory = void 0;
var _pdf_link_service = __webpack_require__(18);
var _pdfjsLib = __webpack_require__(4); var _pdfjsLib = __webpack_require__(4);
class XfaLayerBuilder { class XfaLayerBuilder {
@ -12631,11 +12647,13 @@ class XfaLayerBuilder {
pageDiv, pageDiv,
pdfPage, pdfPage,
annotationStorage, annotationStorage,
linkService,
xfaHtml xfaHtml
}) { }) {
this.pageDiv = pageDiv; this.pageDiv = pageDiv;
this.pdfPage = pdfPage; this.pdfPage = pdfPage;
this.annotationStorage = annotationStorage; this.annotationStorage = annotationStorage;
this.linkService = linkService;
this.xfaHtml = xfaHtml; this.xfaHtml = xfaHtml;
this.div = null; this.div = null;
this._cancelled = false; this._cancelled = false;
@ -12651,6 +12669,7 @@ class XfaLayerBuilder {
xfa: this.xfaHtml, xfa: this.xfaHtml,
page: null, page: null,
annotationStorage: this.annotationStorage, annotationStorage: this.annotationStorage,
linkService: this.linkService,
intent intent
}; };
const div = document.createElement("div"); const div = document.createElement("div");
@ -12677,6 +12696,7 @@ class XfaLayerBuilder {
xfa, xfa,
page: this.pdfPage, page: this.pdfPage,
annotationStorage: this.annotationStorage, annotationStorage: this.annotationStorage,
linkService: this.linkService,
intent intent
}; };
@ -12715,6 +12735,7 @@ class DefaultXfaLayerFactory {
pageDiv, pageDiv,
pdfPage, pdfPage,
annotationStorage, annotationStorage,
linkService: new _pdf_link_service.SimpleLinkService(),
xfaHtml xfaHtml
}); });
} }
@ -14429,8 +14450,8 @@ var _app_options = __webpack_require__(1);
var _app = __webpack_require__(2); var _app = __webpack_require__(2);
const pdfjsVersion = '2.11.298'; const pdfjsVersion = '2.12.16';
const pdfjsBuild = 'd370a281c'; const pdfjsBuild = '394596560';
window.PDFViewerApplication = _app.PDFViewerApplication; window.PDFViewerApplication = _app.PDFViewerApplication;
window.PDFViewerApplicationOptions = _app_options.AppOptions; window.PDFViewerApplicationOptions = _app_options.AppOptions;
; ;

Просмотреть файл

@ -20,7 +20,7 @@ origin:
# Human-readable identifier for this version/release # Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS" # Generally "version NNN", "tag SSS", "bookmark SSS"
release: version 2.11.298 release: version 2.12.16
# The package's license, where possible using the mnemonic from # The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/ # https://spdx.org/licenses/