Enable the unicorn/prefer-dom-node-append
ESLint plugin rule
This rule will help enforce slightly shorter code, especially since you can insert multiple elements at once, and according to MDN `Element.append()` is available in all browsers that we currently support. Please find additional information here: - https://developer.mozilla.org/en-US/docs/Web/API/Element/append - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-append.md
This commit is contained in:
parent
d7122becaf
commit
8129815538
@ -51,6 +51,7 @@
|
|||||||
"unicorn/no-useless-spread": "error",
|
"unicorn/no-useless-spread": "error",
|
||||||
"unicorn/prefer-at": "error",
|
"unicorn/prefer-at": "error",
|
||||||
"unicorn/prefer-date-now": "error",
|
"unicorn/prefer-date-now": "error",
|
||||||
|
"unicorn/prefer-dom-node-append": "error",
|
||||||
"unicorn/prefer-dom-node-remove": "error",
|
"unicorn/prefer-dom-node-remove": "error",
|
||||||
"unicorn/prefer-string-starts-ends-with": "error",
|
"unicorn/prefer-string-starts-ends-with": "error",
|
||||||
|
|
||||||
|
@ -100,6 +100,15 @@ DOMElement.prototype = {
|
|||||||
this.setAttribute(name, value);
|
this.setAttribute(name, value);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
append: function DOMElement_append(...elements) {
|
||||||
|
const childNodes = this.childNodes;
|
||||||
|
for (const element of elements) {
|
||||||
|
if (!childNodes.includes(element)) {
|
||||||
|
childNodes.push(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
appendChild: function DOMElement_appendChild(element) {
|
appendChild: function DOMElement_appendChild(element) {
|
||||||
const childNodes = this.childNodes;
|
const childNodes = this.childNodes;
|
||||||
if (!childNodes.includes(element)) {
|
if (!childNodes.includes(element)) {
|
||||||
|
@ -43,7 +43,7 @@ function buildSVG(viewport, textContent) {
|
|||||||
text.setAttribute("transform", "matrix(" + tx.join(" ") + ")");
|
text.setAttribute("transform", "matrix(" + tx.join(" ") + ")");
|
||||||
text.setAttribute("font-family", style.fontFamily);
|
text.setAttribute("font-family", style.fontFamily);
|
||||||
text.textContent = textItem.str;
|
text.textContent = textItem.str;
|
||||||
svg.appendChild(text);
|
svg.append(text);
|
||||||
});
|
});
|
||||||
return svg;
|
return svg;
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ async function pageLoaded() {
|
|||||||
const textContent = await page.getTextContent();
|
const textContent = await page.getTextContent();
|
||||||
// building SVG and adding that to the DOM
|
// building SVG and adding that to the DOM
|
||||||
const svg = buildSVG(viewport, textContent);
|
const svg = buildSVG(viewport, textContent);
|
||||||
document.getElementById("pageContainer").appendChild(svg);
|
document.getElementById("pageContainer").append(svg);
|
||||||
// Release page resources.
|
// Release page resources.
|
||||||
page.cleanup();
|
page.cleanup();
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ function updateObjectElement(elem) {
|
|||||||
if (!iframe || !iframe.__inserted_by_pdfjs) {
|
if (!iframe || !iframe.__inserted_by_pdfjs) {
|
||||||
iframe = createFullSizeIframe();
|
iframe = createFullSizeIframe();
|
||||||
elem.textContent = "";
|
elem.textContent = "";
|
||||||
elem.appendChild(iframe);
|
elem.append(iframe);
|
||||||
iframe.__inserted_by_pdfjs = true;
|
iframe.__inserted_by_pdfjs = true;
|
||||||
}
|
}
|
||||||
iframe.src = getEmbeddedViewerURL(elem.data);
|
iframe.src = getEmbeddedViewerURL(elem.data);
|
||||||
|
@ -155,7 +155,7 @@ function renderBooleanPref(shortDescription, description, prefName) {
|
|||||||
storageArea.set(pref);
|
storageArea.set(pref);
|
||||||
};
|
};
|
||||||
wrapper.querySelector("span").textContent = shortDescription;
|
wrapper.querySelector("span").textContent = shortDescription;
|
||||||
document.getElementById("settings-boxes").appendChild(wrapper);
|
document.getElementById("settings-boxes").append(wrapper);
|
||||||
|
|
||||||
function renderPreference(value) {
|
function renderPreference(value) {
|
||||||
checkbox.checked = value;
|
checkbox.checked = value;
|
||||||
@ -172,7 +172,7 @@ function renderEnumPref(shortDescription, prefName) {
|
|||||||
storageArea.set(pref);
|
storageArea.set(pref);
|
||||||
};
|
};
|
||||||
wrapper.querySelector("span").textContent = shortDescription;
|
wrapper.querySelector("span").textContent = shortDescription;
|
||||||
document.getElementById("settings-boxes").appendChild(wrapper);
|
document.getElementById("settings-boxes").append(wrapper);
|
||||||
|
|
||||||
function renderPreference(value) {
|
function renderPreference(value) {
|
||||||
select.value = value;
|
select.value = value;
|
||||||
@ -189,7 +189,7 @@ function renderDefaultZoomValue(shortDescription) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
wrapper.querySelector("span").textContent = shortDescription;
|
wrapper.querySelector("span").textContent = shortDescription;
|
||||||
document.getElementById("settings-boxes").appendChild(wrapper);
|
document.getElementById("settings-boxes").append(wrapper);
|
||||||
|
|
||||||
function renderPreference(value) {
|
function renderPreference(value) {
|
||||||
value = value || "auto";
|
value = value || "auto";
|
||||||
|
@ -448,7 +448,7 @@ class AnnotationElement {
|
|||||||
trigger = document.createElement("div");
|
trigger = document.createElement("div");
|
||||||
trigger.style.height = container.style.height;
|
trigger.style.height = container.style.height;
|
||||||
trigger.style.width = container.style.width;
|
trigger.style.width = container.style.width;
|
||||||
container.appendChild(trigger);
|
container.append(trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
const popupElement = new PopupElement({
|
const popupElement = new PopupElement({
|
||||||
@ -466,7 +466,7 @@ class AnnotationElement {
|
|||||||
// Position the popup next to the annotation's container.
|
// Position the popup next to the annotation's container.
|
||||||
popup.style.left = container.style.width;
|
popup.style.left = container.style.width;
|
||||||
|
|
||||||
container.appendChild(popup);
|
container.append(popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -607,7 +607,7 @@ class LinkAnnotationElement extends AnnotationElement {
|
|||||||
return this._renderQuadrilaterals("linkAnnotation").map(
|
return this._renderQuadrilaterals("linkAnnotation").map(
|
||||||
(quadrilateral, index) => {
|
(quadrilateral, index) => {
|
||||||
const linkElement = index === 0 ? link : link.cloneNode();
|
const linkElement = index === 0 ? link : link.cloneNode();
|
||||||
quadrilateral.appendChild(linkElement);
|
quadrilateral.append(linkElement);
|
||||||
return quadrilateral;
|
return quadrilateral;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -615,7 +615,7 @@ class LinkAnnotationElement extends AnnotationElement {
|
|||||||
|
|
||||||
this.container.className = "linkAnnotation";
|
this.container.className = "linkAnnotation";
|
||||||
if (isBound) {
|
if (isBound) {
|
||||||
this.container.appendChild(link);
|
this.container.append(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.container;
|
return this.container;
|
||||||
@ -828,7 +828,7 @@ class TextAnnotationElement extends AnnotationElement {
|
|||||||
this._createPopup(image, this.data);
|
this._createPopup(image, this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.appendChild(image);
|
this.container.append(image);
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1234,7 +1234,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
this._setBackgroundColor(element);
|
this._setBackgroundColor(element);
|
||||||
this._setDefaultPropertiesFromJS(element);
|
this._setDefaultPropertiesFromJS(element);
|
||||||
|
|
||||||
this.container.appendChild(element);
|
this.container.append(element);
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1319,7 +1319,7 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
this._setBackgroundColor(element);
|
this._setBackgroundColor(element);
|
||||||
this._setDefaultPropertiesFromJS(element);
|
this._setDefaultPropertiesFromJS(element);
|
||||||
|
|
||||||
this.container.appendChild(element);
|
this.container.append(element);
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1408,7 +1408,7 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
this._setBackgroundColor(element);
|
this._setBackgroundColor(element);
|
||||||
this._setDefaultPropertiesFromJS(element);
|
this._setDefaultPropertiesFromJS(element);
|
||||||
|
|
||||||
this.container.appendChild(element);
|
this.container.append(element);
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1490,7 +1490,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
optionElement.setAttribute("selected", true);
|
optionElement.setAttribute("selected", true);
|
||||||
addAnEmptyEntry = false;
|
addAnEmptyEntry = false;
|
||||||
}
|
}
|
||||||
selectElement.appendChild(optionElement);
|
selectElement.append(optionElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
let removeEmptyEntry = null;
|
let removeEmptyEntry = null;
|
||||||
@ -1595,7 +1595,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
const optionElement = document.createElement("option");
|
const optionElement = document.createElement("option");
|
||||||
optionElement.textContent = displayValue;
|
optionElement.textContent = displayValue;
|
||||||
optionElement.value = exportValue;
|
optionElement.value = exportValue;
|
||||||
selectElement.appendChild(optionElement);
|
selectElement.append(optionElement);
|
||||||
}
|
}
|
||||||
if (selectElement.options.length > 0) {
|
if (selectElement.options.length > 0) {
|
||||||
selectElement.options[0].selected = true;
|
selectElement.options[0].selected = true;
|
||||||
@ -1668,7 +1668,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
this._setBackgroundColor(selectElement);
|
this._setBackgroundColor(selectElement);
|
||||||
this._setDefaultPropertiesFromJS(selectElement);
|
this._setDefaultPropertiesFromJS(selectElement);
|
||||||
|
|
||||||
this.container.appendChild(selectElement);
|
this.container.append(selectElement);
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1734,7 +1734,7 @@ class PopupAnnotationElement extends AnnotationElement {
|
|||||||
this.container.style.left = `${popupLeft}px`;
|
this.container.style.left = `${popupLeft}px`;
|
||||||
this.container.style.top = `${popupTop}px`;
|
this.container.style.top = `${popupTop}px`;
|
||||||
|
|
||||||
this.container.appendChild(popup.render());
|
this.container.append(popup.render());
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1781,7 +1781,7 @@ class PopupElement {
|
|||||||
const title = document.createElement("h1");
|
const title = document.createElement("h1");
|
||||||
title.dir = this.titleObj.dir;
|
title.dir = this.titleObj.dir;
|
||||||
title.textContent = this.titleObj.str;
|
title.textContent = this.titleObj.str;
|
||||||
popup.appendChild(title);
|
popup.append(title);
|
||||||
|
|
||||||
// The modification date is shown in the popup instead of the creation
|
// The modification date is shown in the popup instead of the creation
|
||||||
// date if it is available and can be parsed correctly, which is
|
// date if it is available and can be parsed correctly, which is
|
||||||
@ -1796,7 +1796,7 @@ class PopupElement {
|
|||||||
date: dateObject.toLocaleDateString(),
|
date: dateObject.toLocaleDateString(),
|
||||||
time: dateObject.toLocaleTimeString(),
|
time: dateObject.toLocaleTimeString(),
|
||||||
});
|
});
|
||||||
popup.appendChild(modificationDate);
|
popup.append(modificationDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -1811,7 +1811,7 @@ class PopupElement {
|
|||||||
popup.lastChild.className = "richText popupContent";
|
popup.lastChild.className = "richText popupContent";
|
||||||
} else {
|
} else {
|
||||||
const contents = this._formatContents(this.contentsObj);
|
const contents = this._formatContents(this.contentsObj);
|
||||||
popup.appendChild(contents);
|
popup.append(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(this.trigger)) {
|
if (!Array.isArray(this.trigger)) {
|
||||||
@ -1826,7 +1826,7 @@ class PopupElement {
|
|||||||
}
|
}
|
||||||
popup.addEventListener("click", this._hide.bind(this, true));
|
popup.addEventListener("click", this._hide.bind(this, true));
|
||||||
|
|
||||||
wrapper.appendChild(popup);
|
wrapper.append(popup);
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1845,9 +1845,9 @@ class PopupElement {
|
|||||||
const lines = str.split(/(?:\r\n?|\n)/);
|
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];
|
||||||
p.appendChild(document.createTextNode(line));
|
p.append(document.createTextNode(line));
|
||||||
if (i < ii - 1) {
|
if (i < ii - 1) {
|
||||||
p.appendChild(document.createElement("br"));
|
p.append(document.createElement("br"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
@ -1957,7 +1957,7 @@ class LineAnnotationElement extends AnnotationElement {
|
|||||||
line.setAttribute("stroke", "transparent");
|
line.setAttribute("stroke", "transparent");
|
||||||
line.setAttribute("fill", "transparent");
|
line.setAttribute("fill", "transparent");
|
||||||
|
|
||||||
svg.appendChild(line);
|
svg.append(line);
|
||||||
this.container.append(svg);
|
this.container.append(svg);
|
||||||
|
|
||||||
// Create the popup ourselves so that we can bind it to the line instead
|
// Create the popup ourselves so that we can bind it to the line instead
|
||||||
@ -2004,7 +2004,7 @@ class SquareAnnotationElement extends AnnotationElement {
|
|||||||
square.setAttribute("stroke", "transparent");
|
square.setAttribute("stroke", "transparent");
|
||||||
square.setAttribute("fill", "transparent");
|
square.setAttribute("fill", "transparent");
|
||||||
|
|
||||||
svg.appendChild(square);
|
svg.append(square);
|
||||||
this.container.append(svg);
|
this.container.append(svg);
|
||||||
|
|
||||||
// Create the popup ourselves so that we can bind it to the square instead
|
// Create the popup ourselves so that we can bind it to the square instead
|
||||||
@ -2051,7 +2051,7 @@ class CircleAnnotationElement extends AnnotationElement {
|
|||||||
circle.setAttribute("stroke", "transparent");
|
circle.setAttribute("stroke", "transparent");
|
||||||
circle.setAttribute("fill", "transparent");
|
circle.setAttribute("fill", "transparent");
|
||||||
|
|
||||||
svg.appendChild(circle);
|
svg.append(circle);
|
||||||
this.container.append(svg);
|
this.container.append(svg);
|
||||||
|
|
||||||
// Create the popup ourselves so that we can bind it to the circle instead
|
// Create the popup ourselves so that we can bind it to the circle instead
|
||||||
@ -2106,7 +2106,7 @@ class PolylineAnnotationElement extends AnnotationElement {
|
|||||||
polyline.setAttribute("stroke", "transparent");
|
polyline.setAttribute("stroke", "transparent");
|
||||||
polyline.setAttribute("fill", "transparent");
|
polyline.setAttribute("fill", "transparent");
|
||||||
|
|
||||||
svg.appendChild(polyline);
|
svg.append(polyline);
|
||||||
this.container.append(svg);
|
this.container.append(svg);
|
||||||
|
|
||||||
// Create the popup ourselves so that we can bind it to the polyline
|
// Create the popup ourselves so that we can bind it to the polyline
|
||||||
@ -2199,7 +2199,7 @@ class InkAnnotationElement extends AnnotationElement {
|
|||||||
// instead of to the entire container (which is the default).
|
// instead of to the entire container (which is the default).
|
||||||
this._createPopup(polyline, data);
|
this._createPopup(polyline, data);
|
||||||
|
|
||||||
svg.appendChild(polyline);
|
svg.append(polyline);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.append(svg);
|
this.container.append(svg);
|
||||||
@ -2376,7 +2376,7 @@ class FileAttachmentAnnotationElement extends AnnotationElement {
|
|||||||
this._createPopup(trigger, this.data);
|
this._createPopup(trigger, this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.appendChild(trigger);
|
this.container.append(trigger);
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2471,7 +2471,7 @@ class AnnotationLayer {
|
|||||||
}
|
}
|
||||||
if (Array.isArray(rendered)) {
|
if (Array.isArray(rendered)) {
|
||||||
for (const renderedElement of rendered) {
|
for (const renderedElement of rendered) {
|
||||||
div.appendChild(renderedElement);
|
div.append(renderedElement);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (element instanceof PopupAnnotationElement) {
|
if (element instanceof PopupAnnotationElement) {
|
||||||
@ -2479,7 +2479,7 @@ class AnnotationLayer {
|
|||||||
// annotation elements to prevent interfering with mouse events.
|
// annotation elements to prevent interfering with mouse events.
|
||||||
div.prepend(rendered);
|
div.prepend(rendered);
|
||||||
} else {
|
} else {
|
||||||
div.appendChild(rendered);
|
div.append(rendered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2557,7 +2557,7 @@ class AnnotationLayer {
|
|||||||
|
|
||||||
const { firstChild } = element;
|
const { firstChild } = element;
|
||||||
if (!firstChild) {
|
if (!firstChild) {
|
||||||
element.appendChild(canvas);
|
element.append(canvas);
|
||||||
} else if (firstChild.nodeName === "CANVAS") {
|
} else if (firstChild.nodeName === "CANVAS") {
|
||||||
element.replaceChild(canvas, firstChild);
|
element.replaceChild(canvas, firstChild);
|
||||||
} else {
|
} else {
|
||||||
|
@ -459,7 +459,7 @@ function loadScript(src, removeScriptElement = false) {
|
|||||||
script.onerror = function () {
|
script.onerror = function () {
|
||||||
reject(new Error(`Cannot load script at: ${script.src}`));
|
reject(new Error(`Cannot load script at: ${script.src}`));
|
||||||
};
|
};
|
||||||
(document.head || document.documentElement).appendChild(script);
|
(document.head || document.documentElement).append(script);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ class AnnotationEditorLayer {
|
|||||||
editor.parent = this;
|
editor.parent = this;
|
||||||
if (editor.div && editor.isAttachedToDOM) {
|
if (editor.div && editor.isAttachedToDOM) {
|
||||||
editor.div.remove();
|
editor.div.remove();
|
||||||
this.div.appendChild(editor.div);
|
this.div.append(editor.div);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ class AnnotationEditorLayer {
|
|||||||
|
|
||||||
if (!editor.isAttachedToDOM) {
|
if (!editor.isAttachedToDOM) {
|
||||||
const div = editor.render();
|
const div = editor.render();
|
||||||
this.div.appendChild(div);
|
this.div.append(div);
|
||||||
editor.isAttachedToDOM = true;
|
editor.isAttachedToDOM = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,11 +211,11 @@ class FreeTextEditor extends AnnotationEditor {
|
|||||||
style.fontSize = `calc(${this.#fontSize}px * var(--zoom-factor))`;
|
style.fontSize = `calc(${this.#fontSize}px * var(--zoom-factor))`;
|
||||||
style.color = this.#color;
|
style.color = this.#color;
|
||||||
|
|
||||||
this.div.appendChild(this.editorDiv);
|
this.div.append(this.editorDiv);
|
||||||
|
|
||||||
this.overlayDiv = document.createElement("div");
|
this.overlayDiv = document.createElement("div");
|
||||||
this.overlayDiv.classList.add("overlay", "enabled");
|
this.overlayDiv.classList.add("overlay", "enabled");
|
||||||
this.div.appendChild(this.overlayDiv);
|
this.div.append(this.overlayDiv);
|
||||||
|
|
||||||
// TODO: implement paste callback.
|
// TODO: implement paste callback.
|
||||||
// The goal is to sanitize and have something suitable for this
|
// The goal is to sanitize and have something suitable for this
|
||||||
|
@ -353,7 +353,7 @@ class InkEditor extends AnnotationEditor {
|
|||||||
#createCanvas() {
|
#createCanvas() {
|
||||||
this.canvas = document.createElement("canvas");
|
this.canvas = document.createElement("canvas");
|
||||||
this.canvas.className = "inkEditorCanvas";
|
this.canvas.className = "inkEditorCanvas";
|
||||||
this.div.appendChild(this.canvas);
|
this.div.append(this.canvas);
|
||||||
this.ctx = this.canvas.getContext("2d");
|
this.ctx = this.canvas.getContext("2d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class BaseFontLoader {
|
|||||||
styleElement.id = `PDFJS_FONT_STYLE_TAG_${this.docId}`;
|
styleElement.id = `PDFJS_FONT_STYLE_TAG_${this.docId}`;
|
||||||
this._document.documentElement
|
this._document.documentElement
|
||||||
.getElementsByTagName("head")[0]
|
.getElementsByTagName("head")[0]
|
||||||
.appendChild(styleElement);
|
.append(styleElement);
|
||||||
}
|
}
|
||||||
const styleSheet = styleElement.sheet;
|
const styleSheet = styleElement.sheet;
|
||||||
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
||||||
@ -345,9 +345,9 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|||||||
const span = this._document.createElement("span");
|
const span = this._document.createElement("span");
|
||||||
span.textContent = "Hi";
|
span.textContent = "Hi";
|
||||||
span.style.fontFamily = name;
|
span.style.fontFamily = name;
|
||||||
div.appendChild(span);
|
div.append(span);
|
||||||
}
|
}
|
||||||
this._document.body.appendChild(div);
|
this._document.body.append(div);
|
||||||
|
|
||||||
isFontReady(loadTestFontId, () => {
|
isFontReady(loadTestFontId, () => {
|
||||||
div.remove();
|
div.remove();
|
||||||
|
@ -778,7 +778,7 @@ if (
|
|||||||
current.tspan.setAttributeNS(null, "y", pf(-current.y));
|
current.tspan.setAttributeNS(null, "y", pf(-current.y));
|
||||||
|
|
||||||
current.txtElement = this.svgFactory.createElement("svg:text");
|
current.txtElement = this.svgFactory.createElement("svg:text");
|
||||||
current.txtElement.appendChild(current.tspan);
|
current.txtElement.append(current.tspan);
|
||||||
}
|
}
|
||||||
|
|
||||||
beginText() {
|
beginText() {
|
||||||
@ -959,10 +959,10 @@ if (
|
|||||||
`${pm(textMatrix)} scale(${pf(textHScale)}, -1)`
|
`${pm(textMatrix)} scale(${pf(textHScale)}, -1)`
|
||||||
);
|
);
|
||||||
current.txtElement.setAttributeNS(XML_NS, "xml:space", "preserve");
|
current.txtElement.setAttributeNS(XML_NS, "xml:space", "preserve");
|
||||||
current.txtElement.appendChild(current.tspan);
|
current.txtElement.append(current.tspan);
|
||||||
current.txtgrp.appendChild(current.txtElement);
|
current.txtgrp.append(current.txtElement);
|
||||||
|
|
||||||
this._ensureTransformGroup().appendChild(current.txtElement);
|
this._ensureTransformGroup().append(current.txtElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLeadingMoveText(x, y) {
|
setLeadingMoveText(x, y) {
|
||||||
@ -980,7 +980,7 @@ if (
|
|||||||
if (!this.cssStyle) {
|
if (!this.cssStyle) {
|
||||||
this.cssStyle = this.svgFactory.createElement("svg:style");
|
this.cssStyle = this.svgFactory.createElement("svg:style");
|
||||||
this.cssStyle.setAttributeNS(null, "type", "text/css");
|
this.cssStyle.setAttributeNS(null, "type", "text/css");
|
||||||
this.defs.appendChild(this.cssStyle);
|
this.defs.append(this.cssStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = createObjectURL(
|
const url = createObjectURL(
|
||||||
@ -1115,7 +1115,7 @@ if (
|
|||||||
if (this.current.fillAlpha < 1) {
|
if (this.current.fillAlpha < 1) {
|
||||||
rect.setAttributeNS(null, "fill-opacity", this.current.fillAlpha);
|
rect.setAttributeNS(null, "fill-opacity", this.current.fillAlpha);
|
||||||
}
|
}
|
||||||
this._ensureTransformGroup().appendChild(rect);
|
this._ensureTransformGroup().append(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1179,8 +1179,8 @@ if (
|
|||||||
this.current.fillColor = fillColor;
|
this.current.fillColor = fillColor;
|
||||||
this.current.strokeColor = strokeColor;
|
this.current.strokeColor = strokeColor;
|
||||||
|
|
||||||
tiling.appendChild(bbox.childNodes[0]);
|
tiling.append(bbox.childNodes[0]);
|
||||||
this.defs.appendChild(tiling);
|
this.defs.append(tiling);
|
||||||
return `url(#${tilingId})`;
|
return `url(#${tilingId})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1231,9 +1231,9 @@ if (
|
|||||||
const stop = this.svgFactory.createElement("svg:stop");
|
const stop = this.svgFactory.createElement("svg:stop");
|
||||||
stop.setAttributeNS(null, "offset", colorStop[0]);
|
stop.setAttributeNS(null, "offset", colorStop[0]);
|
||||||
stop.setAttributeNS(null, "stop-color", colorStop[1]);
|
stop.setAttributeNS(null, "stop-color", colorStop[1]);
|
||||||
gradient.appendChild(stop);
|
gradient.append(stop);
|
||||||
}
|
}
|
||||||
this.defs.appendChild(gradient);
|
this.defs.append(gradient);
|
||||||
return `url(#${shadingId})`;
|
return `url(#${shadingId})`;
|
||||||
case "Mesh":
|
case "Mesh":
|
||||||
warn("Unimplemented pattern Mesh");
|
warn("Unimplemented pattern Mesh");
|
||||||
@ -1354,7 +1354,7 @@ if (
|
|||||||
d = current.path.getAttributeNS(null, "d") + d;
|
d = current.path.getAttributeNS(null, "d") + d;
|
||||||
} else {
|
} else {
|
||||||
current.path = this.svgFactory.createElement("svg:path");
|
current.path = this.svgFactory.createElement("svg:path");
|
||||||
this._ensureTransformGroup().appendChild(current.path);
|
this._ensureTransformGroup().append(current.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
current.path.setAttributeNS(null, "d", d);
|
current.path.setAttributeNS(null, "d", d);
|
||||||
@ -1394,8 +1394,8 @@ if (
|
|||||||
clipElement.setAttributeNS(null, "clip-rule", "nonzero");
|
clipElement.setAttributeNS(null, "clip-rule", "nonzero");
|
||||||
}
|
}
|
||||||
this.pendingClip = null;
|
this.pendingClip = null;
|
||||||
clipPath.appendChild(clipElement);
|
clipPath.append(clipElement);
|
||||||
this.defs.appendChild(clipPath);
|
this.defs.append(clipPath);
|
||||||
|
|
||||||
if (current.activeClipUrl) {
|
if (current.activeClipUrl) {
|
||||||
// The previous clipping group content can go out of order -- resetting
|
// The previous clipping group content can go out of order -- resetting
|
||||||
@ -1583,7 +1583,7 @@ if (
|
|||||||
rect.setAttributeNS(null, "height", "1px");
|
rect.setAttributeNS(null, "height", "1px");
|
||||||
rect.setAttributeNS(null, "fill", this.current.fillColor);
|
rect.setAttributeNS(null, "fill", this.current.fillColor);
|
||||||
|
|
||||||
this._ensureTransformGroup().appendChild(rect);
|
this._ensureTransformGroup().append(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
paintImageXObject(objId) {
|
paintImageXObject(objId) {
|
||||||
@ -1622,9 +1622,9 @@ if (
|
|||||||
`scale(${pf(1 / width)} ${pf(-1 / height)})`
|
`scale(${pf(1 / width)} ${pf(-1 / height)})`
|
||||||
);
|
);
|
||||||
if (mask) {
|
if (mask) {
|
||||||
mask.appendChild(imgEl);
|
mask.append(imgEl);
|
||||||
} else {
|
} else {
|
||||||
this._ensureTransformGroup().appendChild(imgEl);
|
this._ensureTransformGroup().append(imgEl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1646,8 +1646,8 @@ if (
|
|||||||
rect.setAttributeNS(null, "fill", fillColor);
|
rect.setAttributeNS(null, "fill", fillColor);
|
||||||
rect.setAttributeNS(null, "mask", `url(#${current.maskId})`);
|
rect.setAttributeNS(null, "mask", `url(#${current.maskId})`);
|
||||||
|
|
||||||
this.defs.appendChild(mask);
|
this.defs.append(mask);
|
||||||
this._ensureTransformGroup().appendChild(rect);
|
this._ensureTransformGroup().append(rect);
|
||||||
|
|
||||||
this.paintInlineImageXObject(imgData, mask);
|
this.paintInlineImageXObject(imgData, mask);
|
||||||
}
|
}
|
||||||
@ -1689,14 +1689,14 @@ if (
|
|||||||
|
|
||||||
// Create the definitions element.
|
// Create the definitions element.
|
||||||
const definitions = this.svgFactory.createElement("svg:defs");
|
const definitions = this.svgFactory.createElement("svg:defs");
|
||||||
svg.appendChild(definitions);
|
svg.append(definitions);
|
||||||
this.defs = definitions;
|
this.defs = definitions;
|
||||||
|
|
||||||
// Create the root group element, which acts a container for all other
|
// Create the root group element, which acts a container for all other
|
||||||
// groups and applies the viewport transform.
|
// groups and applies the viewport transform.
|
||||||
const rootGroup = this.svgFactory.createElement("svg:g");
|
const rootGroup = this.svgFactory.createElement("svg:g");
|
||||||
rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
|
rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
|
||||||
svg.appendChild(rootGroup);
|
svg.append(rootGroup);
|
||||||
|
|
||||||
// For the construction of the SVG image we are only interested in the
|
// For the construction of the SVG image we are only interested in the
|
||||||
// root group, so we expose it as the entry point of the SVG image for
|
// root group, so we expose it as the entry point of the SVG image for
|
||||||
@ -1713,7 +1713,7 @@ if (
|
|||||||
if (!this.current.clipGroup) {
|
if (!this.current.clipGroup) {
|
||||||
const clipGroup = this.svgFactory.createElement("svg:g");
|
const clipGroup = this.svgFactory.createElement("svg:g");
|
||||||
clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
|
clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
|
||||||
this.svg.appendChild(clipGroup);
|
this.svg.append(clipGroup);
|
||||||
this.current.clipGroup = clipGroup;
|
this.current.clipGroup = clipGroup;
|
||||||
}
|
}
|
||||||
return this.current.clipGroup;
|
return this.current.clipGroup;
|
||||||
@ -1727,9 +1727,9 @@ if (
|
|||||||
this.tgrp = this.svgFactory.createElement("svg:g");
|
this.tgrp = this.svgFactory.createElement("svg:g");
|
||||||
this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
|
this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
|
||||||
if (this.current.activeClipUrl) {
|
if (this.current.activeClipUrl) {
|
||||||
this._ensureClipGroup().appendChild(this.tgrp);
|
this._ensureClipGroup().append(this.tgrp);
|
||||||
} else {
|
} else {
|
||||||
this.svg.appendChild(this.tgrp);
|
this.svg.append(this.tgrp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.tgrp;
|
return this.tgrp;
|
||||||
|
@ -658,7 +658,7 @@ class TextLayerRenderTask {
|
|||||||
if (items[i].id !== null) {
|
if (items[i].id !== null) {
|
||||||
this._container.setAttribute("id", `${items[i].id}`);
|
this._container.setAttribute("id", `${items[i].id}`);
|
||||||
}
|
}
|
||||||
parent.appendChild(this._container);
|
parent.append(this._container);
|
||||||
} else if (items[i].type === "endMarkedContent") {
|
} else if (items[i].type === "endMarkedContent") {
|
||||||
this._container = this._container.parentNode;
|
this._container = this._container.parentNode;
|
||||||
}
|
}
|
||||||
@ -710,12 +710,12 @@ class TextLayerRenderTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (textDivProperties.hasText) {
|
if (textDivProperties.hasText) {
|
||||||
this._container.appendChild(textDiv);
|
this._container.append(textDiv);
|
||||||
}
|
}
|
||||||
if (textDivProperties.hasEOL) {
|
if (textDivProperties.hasEOL) {
|
||||||
const br = document.createElement("br");
|
const br = document.createElement("br");
|
||||||
br.setAttribute("role", "presentation");
|
br.setAttribute("role", "presentation");
|
||||||
this._container.appendChild(br);
|
this._container.append(br);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ class XfaLayer {
|
|||||||
const stack = [[root, -1, rootHtml]];
|
const stack = [[root, -1, rootHtml]];
|
||||||
|
|
||||||
const rootDiv = parameters.div;
|
const rootDiv = parameters.div;
|
||||||
rootDiv.appendChild(rootHtml);
|
rootDiv.append(rootHtml);
|
||||||
|
|
||||||
if (parameters.viewport) {
|
if (parameters.viewport) {
|
||||||
const transform = `matrix(${parameters.viewport.transform.join(",")})`;
|
const transform = `matrix(${parameters.viewport.transform.join(",")})`;
|
||||||
@ -200,7 +200,7 @@ class XfaLayer {
|
|||||||
if (name === "#text") {
|
if (name === "#text") {
|
||||||
const node = document.createTextNode(child.value);
|
const node = document.createTextNode(child.value);
|
||||||
textDivs.push(node);
|
textDivs.push(node);
|
||||||
html.appendChild(node);
|
html.append(node);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ class XfaLayer {
|
|||||||
childHtml = document.createElement(name);
|
childHtml = document.createElement(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.appendChild(childHtml);
|
html.append(childHtml);
|
||||||
if (child.attributes) {
|
if (child.attributes) {
|
||||||
this.setAttributes({
|
this.setAttributes({
|
||||||
html: childHtml,
|
html: childHtml,
|
||||||
@ -229,7 +229,7 @@ class XfaLayer {
|
|||||||
if (XfaText.shouldBuildText(name)) {
|
if (XfaText.shouldBuildText(name)) {
|
||||||
textDivs.push(node);
|
textDivs.push(node);
|
||||||
}
|
}
|
||||||
childHtml.appendChild(node);
|
childHtml.append(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,10 +192,10 @@ class Rasterize {
|
|||||||
foreignObject.setAttribute("height", `${viewport.height}px`);
|
foreignObject.setAttribute("height", `${viewport.height}px`);
|
||||||
|
|
||||||
const style = document.createElement("style");
|
const style = document.createElement("style");
|
||||||
foreignObject.appendChild(style);
|
foreignObject.append(style);
|
||||||
|
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
foreignObject.appendChild(div);
|
foreignObject.append(div);
|
||||||
|
|
||||||
return { svg, foreignObject, style, div };
|
return { svg, foreignObject, style, div };
|
||||||
}
|
}
|
||||||
@ -238,8 +238,8 @@ class Rasterize {
|
|||||||
|
|
||||||
// Inline SVG images from text annotations.
|
// Inline SVG images from text annotations.
|
||||||
await inlineImages(div);
|
await inlineImages(div);
|
||||||
foreignObject.appendChild(div);
|
foreignObject.append(div);
|
||||||
svg.appendChild(foreignObject);
|
svg.append(foreignObject);
|
||||||
|
|
||||||
await writeSVG(svg, ctx);
|
await writeSVG(svg, ctx);
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
@ -268,7 +268,7 @@ class Rasterize {
|
|||||||
await task.promise;
|
await task.promise;
|
||||||
|
|
||||||
task.expandTextDivs(true);
|
task.expandTextDivs(true);
|
||||||
svg.appendChild(foreignObject);
|
svg.append(foreignObject);
|
||||||
|
|
||||||
await writeSVG(svg, ctx);
|
await writeSVG(svg, ctx);
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
@ -302,7 +302,7 @@ class Rasterize {
|
|||||||
|
|
||||||
// Some unsupported type of images (e.g. tiff) lead to errors.
|
// Some unsupported type of images (e.g. tiff) lead to errors.
|
||||||
await inlineImages(div, /* silentErrors = */ true);
|
await inlineImages(div, /* silentErrors = */ true);
|
||||||
svg.appendChild(foreignObject);
|
svg.append(foreignObject);
|
||||||
|
|
||||||
await writeSVG(svg, ctx);
|
await writeSVG(svg, ctx);
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
@ -468,7 +468,7 @@ class Driver {
|
|||||||
xfaStyleElement = document.createElement("style");
|
xfaStyleElement = document.createElement("style");
|
||||||
document.documentElement
|
document.documentElement
|
||||||
.getElementsByTagName("head")[0]
|
.getElementsByTagName("head")[0]
|
||||||
.appendChild(xfaStyleElement);
|
.append(xfaStyleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadingTask = getDocument({
|
const loadingTask = getDocument({
|
||||||
|
@ -79,7 +79,7 @@ window.onload = function () {
|
|||||||
r.setAttribute("y", (gMagZoom * -gMagHeight) / 2);
|
r.setAttribute("y", (gMagZoom * -gMagHeight) / 2);
|
||||||
r.setAttribute("width", gMagZoom * gMagWidth);
|
r.setAttribute("width", gMagZoom * gMagWidth);
|
||||||
r.setAttribute("height", gMagZoom * gMagHeight);
|
r.setAttribute("height", gMagZoom * gMagHeight);
|
||||||
mag.appendChild(r);
|
mag.append(r);
|
||||||
mag.setAttribute(
|
mag.setAttribute(
|
||||||
"transform",
|
"transform",
|
||||||
"translate(" +
|
"translate(" +
|
||||||
@ -124,8 +124,7 @@ window.onload = function () {
|
|||||||
p2.setAttribute("stroke-width", "1px");
|
p2.setAttribute("stroke-width", "1px");
|
||||||
p2.setAttribute("fill", "#888");
|
p2.setAttribute("fill", "#888");
|
||||||
|
|
||||||
mag.appendChild(p1);
|
mag.append(p1, p2);
|
||||||
mag.appendChild(p2);
|
|
||||||
gMagPixPaths[x][y] = [p1, p2];
|
gMagPixPaths[x][y] = [p1, p2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,7 +250,7 @@ window.onload = function () {
|
|||||||
const table = document.getElementById("itemtable");
|
const table = document.getElementById("itemtable");
|
||||||
table.textContent = ""; // Remove any table contents from the DOM.
|
table.textContent = ""; // Remove any table contents from the DOM.
|
||||||
const tbody = document.createElement("tbody");
|
const tbody = document.createElement("tbody");
|
||||||
table.appendChild(tbody);
|
table.append(tbody);
|
||||||
|
|
||||||
for (const i in gTestItems) {
|
for (const i in gTestItems) {
|
||||||
const item = gTestItems[i];
|
const item = gTestItems[i];
|
||||||
@ -276,8 +275,8 @@ window.onload = function () {
|
|||||||
text += "S";
|
text += "S";
|
||||||
rowclass += " skip";
|
rowclass += " skip";
|
||||||
}
|
}
|
||||||
td.appendChild(document.createTextNode(text));
|
td.append(document.createTextNode(text));
|
||||||
tr.appendChild(td);
|
tr.append(td);
|
||||||
|
|
||||||
td = document.createElement("td");
|
td = document.createElement("td");
|
||||||
td.id = "url" + i;
|
td.id = "url" + i;
|
||||||
@ -290,14 +289,14 @@ window.onload = function () {
|
|||||||
a.id = i;
|
a.id = i;
|
||||||
a.className = "image";
|
a.className = "image";
|
||||||
a.href = "#";
|
a.href = "#";
|
||||||
a.appendChild(text);
|
a.append(text);
|
||||||
td.appendChild(a);
|
td.append(a);
|
||||||
} else {
|
} else {
|
||||||
td.appendChild(text);
|
td.append(text);
|
||||||
}
|
}
|
||||||
tr.appendChild(td);
|
tr.append(td);
|
||||||
tr.className = rowclass;
|
tr.className = rowclass;
|
||||||
tbody.appendChild(tr);
|
tbody.append(tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind an event handler to each image link
|
// Bind an event handler to each image link
|
||||||
@ -481,8 +480,8 @@ window.onload = function () {
|
|||||||
p2.setAttribute("fill", color2);
|
p2.setAttribute("fill", color2);
|
||||||
if (color1 !== color2) {
|
if (color1 !== color2) {
|
||||||
gFlashingPixels.push(p1, p2);
|
gFlashingPixels.push(p1, p2);
|
||||||
p1.parentNode.appendChild(p1);
|
p1.parentNode.append(p1);
|
||||||
p2.parentNode.appendChild(p2);
|
p2.parentNode.append(p2);
|
||||||
}
|
}
|
||||||
if (i === 0 && j === 0) {
|
if (i === 0 && j === 0) {
|
||||||
centerPixelColor1 = color1;
|
centerPixelColor1 = color1;
|
||||||
|
@ -134,7 +134,7 @@ describe("custom ownerDocument", function () {
|
|||||||
fonts: new Set(),
|
fonts: new Set(),
|
||||||
createElement,
|
createElement,
|
||||||
documentElement: {
|
documentElement: {
|
||||||
getElementsByTagName: () => [{ appendChild: () => {} }],
|
getElementsByTagName: () => [{ append: () => {} }],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const CanvasFactory = new DefaultCanvasFactory({ ownerDocument });
|
const CanvasFactory = new DefaultCanvasFactory({ ownerDocument });
|
||||||
|
@ -84,8 +84,8 @@ describe("SVGGraphics", function () {
|
|||||||
let svgImg;
|
let svgImg;
|
||||||
// A mock to steal the svg:image element from paintInlineImageXObject.
|
// A mock to steal the svg:image element from paintInlineImageXObject.
|
||||||
const elementContainer = {
|
const elementContainer = {
|
||||||
appendChild(element) {
|
append(...elements) {
|
||||||
svgImg = element;
|
svgImg = elements.at(-1);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class AnnotationEditorLayerBuilder {
|
|||||||
|
|
||||||
this.annotationEditorLayer.render(parameters);
|
this.annotationEditorLayer.render(parameters);
|
||||||
|
|
||||||
this.pageDiv.appendChild(this.div);
|
this.pageDiv.append(this.div);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
|
@ -123,7 +123,7 @@ class AnnotationLayerBuilder {
|
|||||||
// if there is at least one annotation.
|
// if there is at least one annotation.
|
||||||
this.div = document.createElement("div");
|
this.div = document.createElement("div");
|
||||||
this.div.className = "annotationLayer";
|
this.div.className = "annotationLayer";
|
||||||
this.pageDiv.appendChild(this.div);
|
this.pageDiv.append(this.div);
|
||||||
parameters.div = this.div;
|
parameters.div = this.div;
|
||||||
|
|
||||||
AnnotationLayer.render(parameters);
|
AnnotationLayer.render(parameters);
|
||||||
|
@ -122,7 +122,7 @@ class BaseTreeViewer {
|
|||||||
|
|
||||||
this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
|
this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
|
||||||
}
|
}
|
||||||
this.container.appendChild(fragment);
|
this.container.append(fragment);
|
||||||
|
|
||||||
this._dispatchEvent(count);
|
this._dispatchEvent(count);
|
||||||
}
|
}
|
||||||
|
@ -941,7 +941,7 @@ class BaseViewer {
|
|||||||
if (this._spreadMode === SpreadMode.NONE && !this.isInPresentationMode) {
|
if (this._spreadMode === SpreadMode.NONE && !this.isInPresentationMode) {
|
||||||
// Finally, append the new page to the viewer.
|
// Finally, append the new page to the viewer.
|
||||||
const pageView = this._pages[pageNumber - 1];
|
const pageView = this._pages[pageNumber - 1];
|
||||||
viewer.appendChild(pageView.div);
|
viewer.append(pageView.div);
|
||||||
|
|
||||||
state.pages.push(pageView);
|
state.pages.push(pageView);
|
||||||
} else {
|
} else {
|
||||||
@ -969,7 +969,7 @@ class BaseViewer {
|
|||||||
if (this.isInPresentationMode) {
|
if (this.isInPresentationMode) {
|
||||||
const dummyPage = document.createElement("div");
|
const dummyPage = document.createElement("div");
|
||||||
dummyPage.className = "dummyPage";
|
dummyPage.className = "dummyPage";
|
||||||
spread.appendChild(dummyPage);
|
spread.append(dummyPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const i of pageIndexSet) {
|
for (const i of pageIndexSet) {
|
||||||
@ -977,11 +977,11 @@ class BaseViewer {
|
|||||||
if (!pageView) {
|
if (!pageView) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
spread.appendChild(pageView.div);
|
spread.append(pageView.div);
|
||||||
|
|
||||||
state.pages.push(pageView);
|
state.pages.push(pageView);
|
||||||
}
|
}
|
||||||
viewer.appendChild(spread);
|
viewer.append(spread);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.scrollDown = pageNumber >= state.previousPageNumber;
|
state.scrollDown = pageNumber >= state.previousPageNumber;
|
||||||
@ -1925,7 +1925,7 @@ class BaseViewer {
|
|||||||
|
|
||||||
if (this._spreadMode === SpreadMode.NONE) {
|
if (this._spreadMode === SpreadMode.NONE) {
|
||||||
for (const pageView of this._pages) {
|
for (const pageView of this._pages) {
|
||||||
viewer.appendChild(pageView.div);
|
viewer.append(pageView.div);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const parity = this._spreadMode - 1;
|
const parity = this._spreadMode - 1;
|
||||||
@ -1934,12 +1934,12 @@ class BaseViewer {
|
|||||||
if (spread === null) {
|
if (spread === null) {
|
||||||
spread = document.createElement("div");
|
spread = document.createElement("div");
|
||||||
spread.className = "spread";
|
spread.className = "spread";
|
||||||
viewer.appendChild(spread);
|
viewer.append(spread);
|
||||||
} else if (i % 2 === parity) {
|
} else if (i % 2 === parity) {
|
||||||
spread = spread.cloneNode(false);
|
spread = spread.cloneNode(false);
|
||||||
viewer.appendChild(spread);
|
viewer.append(spread);
|
||||||
}
|
}
|
||||||
spread.appendChild(pages[i].div);
|
spread.append(pages[i].div);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,10 @@ const FontInspector = (function FontInspectorClosure() {
|
|||||||
const tmp = document.createElement("button");
|
const tmp = document.createElement("button");
|
||||||
tmp.addEventListener("click", resetSelection);
|
tmp.addEventListener("click", resetSelection);
|
||||||
tmp.textContent = "Refresh";
|
tmp.textContent = "Refresh";
|
||||||
panel.appendChild(tmp);
|
panel.append(tmp);
|
||||||
|
|
||||||
fonts = document.createElement("div");
|
fonts = document.createElement("div");
|
||||||
panel.appendChild(fonts);
|
panel.append(fonts);
|
||||||
},
|
},
|
||||||
cleanup() {
|
cleanup() {
|
||||||
fonts.textContent = "";
|
fonts.textContent = "";
|
||||||
@ -98,11 +98,11 @@ const FontInspector = (function FontInspectorClosure() {
|
|||||||
const tr = document.createElement("tr");
|
const tr = document.createElement("tr");
|
||||||
const td1 = document.createElement("td");
|
const td1 = document.createElement("td");
|
||||||
td1.textContent = entry;
|
td1.textContent = entry;
|
||||||
tr.appendChild(td1);
|
tr.append(td1);
|
||||||
const td2 = document.createElement("td");
|
const td2 = document.createElement("td");
|
||||||
td2.textContent = obj[entry].toString();
|
td2.textContent = obj[entry].toString();
|
||||||
tr.appendChild(td2);
|
tr.append(td2);
|
||||||
moreInfo.appendChild(tr);
|
moreInfo.append(tr);
|
||||||
}
|
}
|
||||||
return moreInfo;
|
return moreInfo;
|
||||||
}
|
}
|
||||||
@ -134,14 +134,8 @@ const FontInspector = (function FontInspectorClosure() {
|
|||||||
select.addEventListener("click", function () {
|
select.addEventListener("click", function () {
|
||||||
selectFont(fontName, select.checked);
|
selectFont(fontName, select.checked);
|
||||||
});
|
});
|
||||||
font.appendChild(select);
|
font.append(select, name, " ", download, " ", logIt, moreInfo);
|
||||||
font.appendChild(name);
|
fonts.append(font);
|
||||||
font.appendChild(document.createTextNode(" "));
|
|
||||||
font.appendChild(download);
|
|
||||||
font.appendChild(document.createTextNode(" "));
|
|
||||||
font.appendChild(logIt);
|
|
||||||
font.appendChild(moreInfo);
|
|
||||||
fonts.appendChild(font);
|
|
||||||
// Somewhat of a hack, should probably add a hook for when the text layer
|
// Somewhat of a hack, should probably add a hook for when the text layer
|
||||||
// is done rendering.
|
// is done rendering.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -173,10 +167,9 @@ const StepperManager = (function StepperManagerClosure() {
|
|||||||
stepperChooser.addEventListener("change", function (event) {
|
stepperChooser.addEventListener("change", function (event) {
|
||||||
self.selectStepper(this.value);
|
self.selectStepper(this.value);
|
||||||
});
|
});
|
||||||
stepperControls.appendChild(stepperChooser);
|
stepperControls.append(stepperChooser);
|
||||||
stepperDiv = document.createElement("div");
|
stepperDiv = document.createElement("div");
|
||||||
this.panel.appendChild(stepperControls);
|
this.panel.append(stepperControls, stepperDiv);
|
||||||
this.panel.appendChild(stepperDiv);
|
|
||||||
if (sessionStorage.getItem("pdfjsBreakPoints")) {
|
if (sessionStorage.getItem("pdfjsBreakPoints")) {
|
||||||
breakPoints = JSON.parse(sessionStorage.getItem("pdfjsBreakPoints"));
|
breakPoints = JSON.parse(sessionStorage.getItem("pdfjsBreakPoints"));
|
||||||
}
|
}
|
||||||
@ -199,11 +192,11 @@ const StepperManager = (function StepperManagerClosure() {
|
|||||||
debug.id = "stepper" + pageIndex;
|
debug.id = "stepper" + pageIndex;
|
||||||
debug.hidden = true;
|
debug.hidden = true;
|
||||||
debug.className = "stepper";
|
debug.className = "stepper";
|
||||||
stepperDiv.appendChild(debug);
|
stepperDiv.append(debug);
|
||||||
const b = document.createElement("option");
|
const b = document.createElement("option");
|
||||||
b.textContent = "Page " + (pageIndex + 1);
|
b.textContent = "Page " + (pageIndex + 1);
|
||||||
b.value = pageIndex;
|
b.value = pageIndex;
|
||||||
stepperChooser.appendChild(b);
|
stepperChooser.append(b);
|
||||||
const initBreakPoints = breakPoints[pageIndex] || [];
|
const initBreakPoints = breakPoints[pageIndex] || [];
|
||||||
const stepper = new Stepper(debug, pageIndex, initBreakPoints);
|
const stepper = new Stepper(debug, pageIndex, initBreakPoints);
|
||||||
steppers.push(stepper);
|
steppers.push(stepper);
|
||||||
@ -289,15 +282,17 @@ const Stepper = (function StepperClosure() {
|
|||||||
const panel = this.panel;
|
const panel = this.panel;
|
||||||
const content = c("div", "c=continue, s=step");
|
const content = c("div", "c=continue, s=step");
|
||||||
const table = c("table");
|
const table = c("table");
|
||||||
content.appendChild(table);
|
content.append(table);
|
||||||
table.cellSpacing = 0;
|
table.cellSpacing = 0;
|
||||||
const headerRow = c("tr");
|
const headerRow = c("tr");
|
||||||
table.appendChild(headerRow);
|
table.append(headerRow);
|
||||||
headerRow.appendChild(c("th", "Break"));
|
headerRow.append(
|
||||||
headerRow.appendChild(c("th", "Idx"));
|
c("th", "Break"),
|
||||||
headerRow.appendChild(c("th", "fn"));
|
c("th", "Idx"),
|
||||||
headerRow.appendChild(c("th", "args"));
|
c("th", "fn"),
|
||||||
panel.appendChild(content);
|
c("th", "args")
|
||||||
|
);
|
||||||
|
panel.append(content);
|
||||||
this.table = table;
|
this.table = table;
|
||||||
this.updateOperatorList(operatorList);
|
this.updateOperatorList(operatorList);
|
||||||
}
|
}
|
||||||
@ -329,7 +324,7 @@ const Stepper = (function StepperClosure() {
|
|||||||
const line = c("tr");
|
const line = c("tr");
|
||||||
line.className = "line";
|
line.className = "line";
|
||||||
line.dataset.idx = i;
|
line.dataset.idx = i;
|
||||||
chunk.appendChild(line);
|
chunk.append(line);
|
||||||
const checked = this.breakPoints.includes(i);
|
const checked = this.breakPoints.includes(i);
|
||||||
const args = operatorList.argsArray[i] || [];
|
const args = operatorList.argsArray[i] || [];
|
||||||
|
|
||||||
@ -341,9 +336,8 @@ const Stepper = (function StepperClosure() {
|
|||||||
cbox.dataset.idx = i;
|
cbox.dataset.idx = i;
|
||||||
cbox.onclick = cboxOnClick;
|
cbox.onclick = cboxOnClick;
|
||||||
|
|
||||||
breakCell.appendChild(cbox);
|
breakCell.append(cbox);
|
||||||
line.appendChild(breakCell);
|
line.append(breakCell, c("td", i.toString()));
|
||||||
line.appendChild(c("td", i.toString()));
|
|
||||||
const fn = opMap[operatorList.fnArray[i]];
|
const fn = opMap[operatorList.fnArray[i]];
|
||||||
let decArgs = args;
|
let decArgs = args;
|
||||||
if (fn === "showText") {
|
if (fn === "showText") {
|
||||||
@ -353,46 +347,44 @@ const Stepper = (function StepperClosure() {
|
|||||||
const unicodeRow = c("tr");
|
const unicodeRow = c("tr");
|
||||||
for (const glyph of glyphs) {
|
for (const glyph of glyphs) {
|
||||||
if (typeof glyph === "object" && glyph !== null) {
|
if (typeof glyph === "object" && glyph !== null) {
|
||||||
charCodeRow.appendChild(c("td", glyph.originalCharCode));
|
charCodeRow.append(c("td", glyph.originalCharCode));
|
||||||
fontCharRow.appendChild(c("td", glyph.fontChar));
|
fontCharRow.append(c("td", glyph.fontChar));
|
||||||
unicodeRow.appendChild(c("td", glyph.unicode));
|
unicodeRow.append(c("td", glyph.unicode));
|
||||||
} else {
|
} else {
|
||||||
// null or number
|
// null or number
|
||||||
const advanceEl = c("td", glyph);
|
const advanceEl = c("td", glyph);
|
||||||
advanceEl.classList.add("advance");
|
advanceEl.classList.add("advance");
|
||||||
charCodeRow.appendChild(advanceEl);
|
charCodeRow.append(advanceEl);
|
||||||
fontCharRow.appendChild(c("td"));
|
fontCharRow.append(c("td"));
|
||||||
unicodeRow.appendChild(c("td"));
|
unicodeRow.append(c("td"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
decArgs = c("td");
|
decArgs = c("td");
|
||||||
const table = c("table");
|
const table = c("table");
|
||||||
table.classList.add("showText");
|
table.classList.add("showText");
|
||||||
decArgs.appendChild(table);
|
decArgs.append(table);
|
||||||
table.appendChild(charCodeRow);
|
table.append(charCodeRow, fontCharRow, unicodeRow);
|
||||||
table.appendChild(fontCharRow);
|
|
||||||
table.appendChild(unicodeRow);
|
|
||||||
} else if (fn === "restore") {
|
} else if (fn === "restore") {
|
||||||
this.indentLevel--;
|
this.indentLevel--;
|
||||||
}
|
}
|
||||||
line.appendChild(c("td", " ".repeat(this.indentLevel * 2) + fn));
|
line.append(c("td", " ".repeat(this.indentLevel * 2) + fn));
|
||||||
if (fn === "save") {
|
if (fn === "save") {
|
||||||
this.indentLevel++;
|
this.indentLevel++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decArgs instanceof HTMLElement) {
|
if (decArgs instanceof HTMLElement) {
|
||||||
line.appendChild(decArgs);
|
line.append(decArgs);
|
||||||
} else {
|
} else {
|
||||||
line.appendChild(c("td", JSON.stringify(simplifyArgs(decArgs))));
|
line.append(c("td", JSON.stringify(simplifyArgs(decArgs))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operatorsToDisplay < operatorList.fnArray.length) {
|
if (operatorsToDisplay < operatorList.fnArray.length) {
|
||||||
const lastCell = c("td", "...");
|
const lastCell = c("td", "...");
|
||||||
lastCell.colspan = 4;
|
lastCell.colspan = 4;
|
||||||
chunk.appendChild(lastCell);
|
chunk.append(lastCell);
|
||||||
}
|
}
|
||||||
this.operatorListIdx = operatorList.fnArray.length;
|
this.operatorListIdx = operatorList.fnArray.length;
|
||||||
this.table.appendChild(chunk);
|
this.table.append(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
getNextBreakPoint() {
|
getNextBreakPoint() {
|
||||||
@ -485,15 +477,14 @@ const Stats = (function Stats() {
|
|||||||
title.textContent = "Page: " + pageNumber;
|
title.textContent = "Page: " + pageNumber;
|
||||||
const statsDiv = document.createElement("div");
|
const statsDiv = document.createElement("div");
|
||||||
statsDiv.textContent = stat.toString();
|
statsDiv.textContent = stat.toString();
|
||||||
wrapper.appendChild(title);
|
wrapper.append(title, statsDiv);
|
||||||
wrapper.appendChild(statsDiv);
|
|
||||||
stats.push({ pageNumber, div: wrapper });
|
stats.push({ pageNumber, div: wrapper });
|
||||||
stats.sort(function (a, b) {
|
stats.sort(function (a, b) {
|
||||||
return a.pageNumber - b.pageNumber;
|
return a.pageNumber - b.pageNumber;
|
||||||
});
|
});
|
||||||
clear(this.panel);
|
clear(this.panel);
|
||||||
for (const entry of stats) {
|
for (const entry of stats) {
|
||||||
this.panel.appendChild(entry.div);
|
this.panel.append(entry.div);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cleanup() {
|
cleanup() {
|
||||||
@ -547,13 +538,13 @@ const PDFBug = (function PDFBugClosure() {
|
|||||||
|
|
||||||
const controls = document.createElement("div");
|
const controls = document.createElement("div");
|
||||||
controls.setAttribute("class", "controls");
|
controls.setAttribute("class", "controls");
|
||||||
ui.appendChild(controls);
|
ui.append(controls);
|
||||||
|
|
||||||
const panels = document.createElement("div");
|
const panels = document.createElement("div");
|
||||||
panels.setAttribute("class", "panels");
|
panels.setAttribute("class", "panels");
|
||||||
ui.appendChild(panels);
|
ui.append(panels);
|
||||||
|
|
||||||
container.appendChild(ui);
|
container.append(ui);
|
||||||
container.style.right = panelWidth + "px";
|
container.style.right = panelWidth + "px";
|
||||||
|
|
||||||
// Initialize all the debugging tools.
|
// Initialize all the debugging tools.
|
||||||
@ -565,8 +556,8 @@ const PDFBug = (function PDFBugClosure() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.selectPanel(tool);
|
this.selectPanel(tool);
|
||||||
});
|
});
|
||||||
controls.appendChild(panelButton);
|
controls.append(panelButton);
|
||||||
panels.appendChild(panel);
|
panels.append(panel);
|
||||||
tool.panel = panel;
|
tool.panel = panel;
|
||||||
tool.manager = this;
|
tool.manager = this;
|
||||||
if (tool.enabled) {
|
if (tool.enabled) {
|
||||||
@ -587,7 +578,7 @@ const PDFBug = (function PDFBugClosure() {
|
|||||||
link.rel = "stylesheet";
|
link.rel = "stylesheet";
|
||||||
link.href = url.replace(/.js$/, ".css");
|
link.href = url.replace(/.js$/, ".css");
|
||||||
|
|
||||||
document.head.appendChild(link);
|
document.head.append(link);
|
||||||
},
|
},
|
||||||
cleanup() {
|
cleanup() {
|
||||||
for (const tool of this.tools) {
|
for (const tool of this.tools) {
|
||||||
|
@ -38,7 +38,7 @@ function download(blobUrl, filename) {
|
|||||||
}
|
}
|
||||||
// <a> must be in the document for recent Firefox versions,
|
// <a> must be in the document for recent Firefox versions,
|
||||||
// otherwise .click() is ignored.
|
// otherwise .click() is ignored.
|
||||||
(document.body || document.documentElement).appendChild(a);
|
(document.body || document.documentElement).append(a);
|
||||||
a.click();
|
a.click();
|
||||||
a.remove();
|
a.remove();
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ function composePage(
|
|||||||
|
|
||||||
const canvasWrapper = document.createElement("div");
|
const canvasWrapper = document.createElement("div");
|
||||||
canvasWrapper.className = "printedPage";
|
canvasWrapper.className = "printedPage";
|
||||||
canvasWrapper.appendChild(canvas);
|
canvasWrapper.append(canvas);
|
||||||
printContainer.appendChild(canvasWrapper);
|
printContainer.append(canvasWrapper);
|
||||||
|
|
||||||
// A callback for a given page may be executed multiple times for different
|
// A callback for a given page may be executed multiple times for different
|
||||||
// print operations (think of changing the print settings in the browser).
|
// print operations (think of changing the print settings in the browser).
|
||||||
|
@ -38,7 +38,7 @@ class FirefoxCom {
|
|||||||
*/
|
*/
|
||||||
static requestSync(action, data) {
|
static requestSync(action, data) {
|
||||||
const request = document.createTextNode("");
|
const request = document.createTextNode("");
|
||||||
document.documentElement.appendChild(request);
|
document.documentElement.append(request);
|
||||||
|
|
||||||
const sender = document.createEvent("CustomEvent");
|
const sender = document.createEvent("CustomEvent");
|
||||||
sender.initCustomEvent("pdf.js.message", true, false, {
|
sender.initCustomEvent("pdf.js.message", true, false, {
|
||||||
@ -86,7 +86,7 @@ class FirefoxCom {
|
|||||||
{ once: true }
|
{ once: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
document.documentElement.appendChild(request);
|
document.documentElement.append(request);
|
||||||
|
|
||||||
const sender = document.createEvent("CustomEvent");
|
const sender = document.createEvent("CustomEvent");
|
||||||
sender.initCustomEvent("pdf.js.message", true, false, {
|
sender.initCustomEvent("pdf.js.message", true, false, {
|
||||||
|
@ -153,7 +153,7 @@ class GrabToPan {
|
|||||||
this.element.scrollLeft = scrollLeft;
|
this.element.scrollLeft = scrollLeft;
|
||||||
}
|
}
|
||||||
if (!this.overlay.parentNode) {
|
if (!this.overlay.parentNode) {
|
||||||
document.body.appendChild(this.overlay);
|
document.body.append(this.overlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,9 +127,9 @@ class PDFAttachmentViewer extends BaseTreeViewer {
|
|||||||
this._bindLink(element, { content, filename });
|
this._bindLink(element, { content, filename });
|
||||||
element.textContent = this._normalizeTextContent(filename);
|
element.textContent = this._normalizeTextContent(filename);
|
||||||
|
|
||||||
div.appendChild(element);
|
div.append(element);
|
||||||
|
|
||||||
fragment.appendChild(div);
|
fragment.append(div);
|
||||||
attachmentsCount++;
|
attachmentsCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ class PDFLayerViewer extends BaseTreeViewer {
|
|||||||
div.className = "treeItem";
|
div.className = "treeItem";
|
||||||
|
|
||||||
const element = document.createElement("a");
|
const element = document.createElement("a");
|
||||||
div.appendChild(element);
|
div.append(element);
|
||||||
|
|
||||||
if (typeof groupId === "object") {
|
if (typeof groupId === "object") {
|
||||||
hasAnyNesting = true;
|
hasAnyNesting = true;
|
||||||
@ -144,7 +144,7 @@ class PDFLayerViewer extends BaseTreeViewer {
|
|||||||
|
|
||||||
const itemsDiv = document.createElement("div");
|
const itemsDiv = document.createElement("div");
|
||||||
itemsDiv.className = "treeItems";
|
itemsDiv.className = "treeItems";
|
||||||
div.appendChild(itemsDiv);
|
div.append(itemsDiv);
|
||||||
|
|
||||||
queue.push({ parent: itemsDiv, groups: groupId.order });
|
queue.push({ parent: itemsDiv, groups: groupId.order });
|
||||||
} else {
|
} else {
|
||||||
@ -160,13 +160,11 @@ class PDFLayerViewer extends BaseTreeViewer {
|
|||||||
label.setAttribute("for", groupId);
|
label.setAttribute("for", groupId);
|
||||||
label.textContent = this._normalizeTextContent(group.name);
|
label.textContent = this._normalizeTextContent(group.name);
|
||||||
|
|
||||||
element.appendChild(input);
|
element.append(input, label);
|
||||||
element.appendChild(label);
|
|
||||||
|
|
||||||
layersCount++;
|
layersCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
levelData.parent.appendChild(div);
|
levelData.parent.append(div);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
|
|||||||
this._setStyles(element, item);
|
this._setStyles(element, item);
|
||||||
element.textContent = this._normalizeTextContent(item.title);
|
element.textContent = this._normalizeTextContent(item.title);
|
||||||
|
|
||||||
div.appendChild(element);
|
div.append(element);
|
||||||
|
|
||||||
if (item.items.length > 0) {
|
if (item.items.length > 0) {
|
||||||
hasAnyNesting = true;
|
hasAnyNesting = true;
|
||||||
@ -212,12 +212,12 @@ class PDFOutlineViewer extends BaseTreeViewer {
|
|||||||
|
|
||||||
const itemsDiv = document.createElement("div");
|
const itemsDiv = document.createElement("div");
|
||||||
itemsDiv.className = "treeItems";
|
itemsDiv.className = "treeItems";
|
||||||
div.appendChild(itemsDiv);
|
div.append(itemsDiv);
|
||||||
|
|
||||||
queue.push({ parent: itemsDiv, items: item.items });
|
queue.push({ parent: itemsDiv, items: item.items });
|
||||||
}
|
}
|
||||||
|
|
||||||
levelData.parent.appendChild(div);
|
levelData.parent.append(div);
|
||||||
outlineCount++;
|
outlineCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ class PDFPageView {
|
|||||||
});
|
});
|
||||||
this.div = div;
|
this.div = div;
|
||||||
|
|
||||||
container?.appendChild(div);
|
container?.append(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPdfPage(pdfPage) {
|
setPdfPage(pdfPage) {
|
||||||
@ -358,7 +358,7 @@ class PDFPageView {
|
|||||||
this.l10n.get("loading").then(msg => {
|
this.l10n.get("loading").then(msg => {
|
||||||
this.loadingIconDiv?.setAttribute("aria-label", msg);
|
this.loadingIconDiv?.setAttribute("aria-label", msg);
|
||||||
});
|
});
|
||||||
div.appendChild(this.loadingIconDiv);
|
div.append(this.loadingIconDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
update({ scale = 0, rotation = null, optionalContentConfigPromise = null }) {
|
update({ scale = 0, rotation = null, optionalContentConfigPromise = null }) {
|
||||||
@ -629,7 +629,7 @@ class PDFPageView {
|
|||||||
// The annotation layer needs to stay on top.
|
// The annotation layer needs to stay on top.
|
||||||
div.insertBefore(canvasWrapper, lastDivBeforeTextDiv);
|
div.insertBefore(canvasWrapper, lastDivBeforeTextDiv);
|
||||||
} else {
|
} else {
|
||||||
div.appendChild(canvasWrapper);
|
div.append(canvasWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
let textLayer = null;
|
let textLayer = null;
|
||||||
@ -642,7 +642,7 @@ class PDFPageView {
|
|||||||
// The annotation layer needs to stay on top.
|
// The annotation layer needs to stay on top.
|
||||||
div.insertBefore(textLayerDiv, lastDivBeforeTextDiv);
|
div.insertBefore(textLayerDiv, lastDivBeforeTextDiv);
|
||||||
} else {
|
} else {
|
||||||
div.appendChild(textLayerDiv);
|
div.append(textLayerDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
textLayer = this.textLayerFactory.createTextLayerBuilder(
|
textLayer = this.textLayerFactory.createTextLayerBuilder(
|
||||||
@ -679,7 +679,7 @@ class PDFPageView {
|
|||||||
|
|
||||||
if (this.xfaLayer?.div) {
|
if (this.xfaLayer?.div) {
|
||||||
// The xfa layer needs to stay on top.
|
// The xfa layer needs to stay on top.
|
||||||
div.appendChild(this.xfaLayer.div);
|
div.append(this.xfaLayer.div);
|
||||||
}
|
}
|
||||||
|
|
||||||
let renderContinueCallback = null;
|
let renderContinueCallback = null;
|
||||||
@ -806,7 +806,7 @@ class PDFPageView {
|
|||||||
}
|
}
|
||||||
const treeDom = this.structTreeLayer.render(tree);
|
const treeDom = this.structTreeLayer.render(tree);
|
||||||
treeDom.classList.add("structTree");
|
treeDom.classList.add("structTree");
|
||||||
this.canvas.appendChild(treeDom);
|
this.canvas.append(treeDom);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
|
this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
|
||||||
@ -850,7 +850,7 @@ class PDFPageView {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
canvasWrapper.appendChild(canvas);
|
canvasWrapper.append(canvas);
|
||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
|
|
||||||
const ctx = canvas.getContext("2d", { alpha: false });
|
const ctx = canvas.getContext("2d", { alpha: false });
|
||||||
@ -967,7 +967,7 @@ class PDFPageView {
|
|||||||
svg.style.width = wrapper.style.width;
|
svg.style.width = wrapper.style.width;
|
||||||
svg.style.height = wrapper.style.height;
|
svg.style.height = wrapper.style.height;
|
||||||
this.renderingState = RenderingStates.FINISHED;
|
this.renderingState = RenderingStates.FINISHED;
|
||||||
wrapper.appendChild(svg);
|
wrapper.append(svg);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ PDFPrintService.prototype = {
|
|||||||
const pageSize = this.pagesOverview[0];
|
const pageSize = this.pagesOverview[0];
|
||||||
this.pageStyleSheet.textContent =
|
this.pageStyleSheet.textContent =
|
||||||
"@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}";
|
"@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}";
|
||||||
body.appendChild(this.pageStyleSheet);
|
body.append(this.pageStyleSheet);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
@ -184,8 +184,8 @@ PDFPrintService.prototype = {
|
|||||||
|
|
||||||
const wrapper = document.createElement("div");
|
const wrapper = document.createElement("div");
|
||||||
wrapper.className = "printedPage";
|
wrapper.className = "printedPage";
|
||||||
wrapper.appendChild(img);
|
wrapper.append(img);
|
||||||
this.printContainer.appendChild(wrapper);
|
this.printContainer.append(wrapper);
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
img.onload = resolve;
|
img.onload = resolve;
|
||||||
|
@ -148,9 +148,9 @@ class PDFThumbnailView {
|
|||||||
ring.style.height = this.canvasHeight + borderAdjustment + "px";
|
ring.style.height = this.canvasHeight + borderAdjustment + "px";
|
||||||
this.ring = ring;
|
this.ring = ring;
|
||||||
|
|
||||||
div.appendChild(ring);
|
div.append(ring);
|
||||||
anchor.appendChild(div);
|
anchor.append(div);
|
||||||
container.appendChild(anchor);
|
container.append(anchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPdfPage(pdfPage) {
|
setPdfPage(pdfPage) {
|
||||||
@ -257,7 +257,7 @@ class PDFThumbnailView {
|
|||||||
this.image = image;
|
this.image = image;
|
||||||
|
|
||||||
this.div.setAttribute("data-loaded", true);
|
this.div.setAttribute("data-loaded", true);
|
||||||
this.ring.appendChild(image);
|
this.ring.append(image);
|
||||||
|
|
||||||
// Zeroing the width and height causes Firefox to release graphics
|
// Zeroing the width and height causes Firefox to release graphics
|
||||||
// resources immediately, which can greatly reduce memory consumption.
|
// resources immediately, which can greatly reduce memory consumption.
|
||||||
|
@ -25,7 +25,7 @@ function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
|||||||
for (const xfaPage of xfaHtml.children) {
|
for (const xfaPage of xfaHtml.children) {
|
||||||
const page = document.createElement("div");
|
const page = document.createElement("div");
|
||||||
page.className = "xfaPrintedPage";
|
page.className = "xfaPrintedPage";
|
||||||
printContainer.appendChild(page);
|
printContainer.append(page);
|
||||||
|
|
||||||
const builder = new XfaLayerBuilder({
|
const builder = new XfaLayerBuilder({
|
||||||
pageDiv: page,
|
pageDiv: page,
|
||||||
|
@ -128,7 +128,7 @@ class StructTreeLayerBuilder {
|
|||||||
this._setAttributes(node.children[0], element);
|
this._setAttributes(node.children[0], element);
|
||||||
} else {
|
} else {
|
||||||
for (const kid of node.children) {
|
for (const kid of node.children) {
|
||||||
element.appendChild(this._walk(kid));
|
element.append(this._walk(kid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ class TextHighlighter {
|
|||||||
if (div.nodeType === Node.TEXT_NODE) {
|
if (div.nodeType === Node.TEXT_NODE) {
|
||||||
const span = document.createElement("span");
|
const span = document.createElement("span");
|
||||||
div.parentNode.insertBefore(span, div);
|
div.parentNode.insertBefore(span, div);
|
||||||
span.appendChild(div);
|
span.append(div);
|
||||||
textDivs[divIdx] = span;
|
textDivs[divIdx] = span;
|
||||||
div = span;
|
div = span;
|
||||||
}
|
}
|
||||||
@ -189,11 +189,11 @@ class TextHighlighter {
|
|||||||
if (className) {
|
if (className) {
|
||||||
const span = document.createElement("span");
|
const span = document.createElement("span");
|
||||||
span.className = `${className} appended`;
|
span.className = `${className} appended`;
|
||||||
span.appendChild(node);
|
span.append(node);
|
||||||
div.appendChild(span);
|
div.append(span);
|
||||||
return className.includes("selected") ? span.offsetLeft : 0;
|
return className.includes("selected") ? span.offsetLeft : 0;
|
||||||
}
|
}
|
||||||
div.appendChild(node);
|
div.append(node);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class TextLayerBuilder {
|
|||||||
if (!this.enhanceTextSelection) {
|
if (!this.enhanceTextSelection) {
|
||||||
const endOfContent = document.createElement("div");
|
const endOfContent = document.createElement("div");
|
||||||
endOfContent.className = "endOfContent";
|
endOfContent.className = "endOfContent";
|
||||||
this.textLayerDiv.appendChild(endOfContent);
|
this.textLayerDiv.append(endOfContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.eventBus.dispatch("textlayerrendered", {
|
this.eventBus.dispatch("textlayerrendered", {
|
||||||
@ -111,7 +111,7 @@ class TextLayerBuilder {
|
|||||||
});
|
});
|
||||||
this.textLayerRenderTask.promise.then(
|
this.textLayerRenderTask.promise.then(
|
||||||
() => {
|
() => {
|
||||||
this.textLayerDiv.appendChild(textLayerFrag);
|
this.textLayerDiv.append(textLayerFrag);
|
||||||
this._finishRendering();
|
this._finishRendering();
|
||||||
this.highlighter?.enable();
|
this.highlighter?.enable();
|
||||||
},
|
},
|
||||||
|
@ -212,7 +212,7 @@ function webViewerLoad() {
|
|||||||
link.rel = "stylesheet";
|
link.rel = "stylesheet";
|
||||||
link.href = "../build/dev-css/viewer.css";
|
link.href = "../build/dev-css/viewer.css";
|
||||||
|
|
||||||
document.head.appendChild(link);
|
document.head.append(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
|
@ -70,7 +70,7 @@ class XfaLayerBuilder {
|
|||||||
|
|
||||||
// Create an xfa layer div and render the form
|
// Create an xfa layer div and render the form
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
this.pageDiv.appendChild(div);
|
this.pageDiv.append(div);
|
||||||
parameters.div = div;
|
parameters.div = div;
|
||||||
|
|
||||||
const result = XfaLayer.render(parameters);
|
const result = XfaLayer.render(parameters);
|
||||||
@ -99,7 +99,7 @@ class XfaLayerBuilder {
|
|||||||
}
|
}
|
||||||
// Create an xfa layer div and render the form
|
// Create an xfa layer div and render the form
|
||||||
this.div = document.createElement("div");
|
this.div = document.createElement("div");
|
||||||
this.pageDiv.appendChild(this.div);
|
this.pageDiv.append(this.div);
|
||||||
parameters.div = this.div;
|
parameters.div = this.div;
|
||||||
return XfaLayer.render(parameters);
|
return XfaLayer.render(parameters);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user