: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (!this.#draggingEditors) {
for (const editor of this.#draggingEditors.keys()) {
if (editor.parent === null) {
const parent = this.getLayer(editor.pageIndex);
parent.changeParent(editor);
parent.addOrRebuild(editor);
this.addToAnnotationStorage(editor);
editor.parent.addOrRebuild(editor);
get isEditorHandlingKeyboard() {
return this.getActive()?.shouldGetKeyboardEvents() || this.#selectedEditors.size === 1 && this.firstSelectedEditor.shouldGetKeyboardEvents();
return this.#activeEditor === editor;
return this.#activeEditor;
return shadow(this, "imageManager", new ImageManager());
getSelectionBoxes(textLayer) {
const selection = document.getSelection();
for (let i = 0, ii = selection.rangeCount; i < ii; i++) {
if (!textLayer.contains(selection.getRangeAt(i).commonAncestorContainer)) {
} = textLayer.getBoundingClientRect();
switch (textLayer.getAttribute("data-main-rotation")) {
rotator = (x, y, w, h) => ({
x: (y - layerY) / parentHeight,
y: 1 - (x + w - layerX) / parentWidth,
rotator = (x, y, w, h) => ({
x: 1 - (x + w - layerX) / parentWidth,
y: 1 - (y + h - layerY) / parentHeight,
rotator = (x, y, w, h) => ({
x: 1 - (y + h - layerY) / parentHeight,
y: (x - layerX) / parentWidth,
rotator = (x, y, w, h) => ({
x: (x - layerX) / parentWidth,
y: (y - layerY) / parentHeight,
for (let i = 0, ii = selection.rangeCount; i < ii; i++) {
const range = selection.getRangeAt(i);
} of range.getClientRects()) {
if (width === 0 || height === 0) {
boxes.push(rotator(x, y, width, height));
return boxes.length === 0 ? null : boxes;
addChangedExistingAnnotation({
(this.#changedExistingAnnotations ||= new Map()).set(annotationElementId, id);
removeChangedExistingAnnotation({
this.#changedExistingAnnotations?.delete(annotationElementId);
renderAnnotationElement(annotation) {
const editorId = this.#changedExistingAnnotations?.get(annotation.data.id);
const editor = this.#annotationStorage.getRawValue(editorId);
if (this.#mode === AnnotationEditorType.NONE && !editor.hasBeenModified) {
editor.renderAnnotationElement(annotation);
;// CONCATENATED MODULE: ./src/display/editor/alt_text.js
#altTextDecorative = false;
#altTextTooltipTimeout = null;
#altTextWasFromKeyBoard = false;
static _l10nPromise = null;
static initialize(l10nPromise) {
AltText._l10nPromise ||= l10nPromise;
const altText = this.#altTextButton = document.createElement("button");
altText.className = "altText";
const msg = await AltText._l10nPromise.get("pdfjs-editor-alt-text-button-label");
altText.textContent = msg;
altText.setAttribute("aria-label", msg);
altText.addEventListener("contextmenu", noContextMenu);
altText.addEventListener("pointerdown", event => event.stopPropagation());
const onClick = event => {
this.#editor._uiManager.editAltText(this.#editor);
altText.addEventListener("click", onClick, {
altText.addEventListener("keydown", event => {
if (event.target === altText && event.key === "Enter") {
this.#altTextWasFromKeyBoard = true;
if (!this.#altTextButton) {
this.#altTextButton.focus({
focusVisible: this.#altTextWasFromKeyBoard
this.#altTextWasFromKeyBoard = false;
return !this.#altText && !this.#altTextDecorative;
decorative: this.#altTextDecorative
if (this.#altText === altText && this.#altTextDecorative === decorative) {
this.#altTextDecorative = decorative;
toggle(enabled = false) {
if (!this.#altTextButton) {
if (!enabled && this.#altTextTooltipTimeout) {
clearTimeout(this.#altTextTooltipTimeout);
this.#altTextTooltipTimeout = null;
this.#altTextButton.disabled = !enabled;
this.#altTextButton?.remove();
this.#altTextButton = null;
this.#altTextTooltip = null;
const button = this.#altTextButton;
if (!this.#altText && !this.#altTextDecorative) {
button.classList.remove("done");
this.#altTextTooltip?.remove();
button.classList.add("done");
AltText._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(msg => {
button.setAttribute("aria-label", msg);
let tooltip = this.#altTextTooltip;
this.#altTextTooltip = tooltip = document.createElement("span");
tooltip.className = "tooltip";
tooltip.setAttribute("role", "tooltip");
const id = tooltip.id = `alt-text-tooltip-${this.#editor.id}`;
button.setAttribute("aria-describedby", id);
const DELAY_TO_SHOW_TOOLTIP = 100;
button.addEventListener("mouseenter", () => {
this.#altTextTooltipTimeout = setTimeout(() => {
this.#altTextTooltipTimeout = null;
this.#altTextTooltip.classList.add("show");
this.#editor._reportTelemetry({
action: "alt_text_tooltip"
}, DELAY_TO_SHOW_TOOLTIP);
button.addEventListener("mouseleave", () => {
if (this.#altTextTooltipTimeout) {
clearTimeout(this.#altTextTooltipTimeout);
this.#altTextTooltipTimeout = null;
this.#altTextTooltip?.classList.remove("show");
tooltip.innerText = this.#altTextDecorative ? await AltText._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip") : this.#altText;
if (!tooltip.parentNode) {
const element = this.#editor.getImageForAltText();
element?.setAttribute("aria-describedby", tooltip.id);
;// CONCATENATED MODULE: ./src/display/editor/editor.js
#keepAspectRatio = false;
#boundFocusin = this.focusin.bind(this);
#boundFocusout = this.focusout.bind(this);
#focusedResizerName = "";
#isResizerEnabledForKeyboard = false;
#moveInDOMTimeout = null;
#telemetryTimeouts = null;
_initialOptions = Object.create(null);
_focusEventsAllowed = true;
#zIndex = AnnotationEditor._zIndex++;
static _borderLineWidth = -1;
static _colorManager = new ColorManager();
static _telemetryTimeout = 1000;
static get _resizerKeyboardManager() {
const resize = AnnotationEditor.prototype._resizeWithKeyboard;
const small = AnnotationEditorUIManager.TRANSLATE_SMALL;
const big = AnnotationEditorUIManager.TRANSLATE_BIG;
return shadow(this, "_resizerKeyboardManager", new KeyboardManager([[["ArrowLeft", "mac+ArrowLeft"], resize, {
}], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], resize, {
}], [["ArrowRight", "mac+ArrowRight"], resize, {
}], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], resize, {
}], [["ArrowUp", "mac+ArrowUp"], resize, {
}], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], resize, {
}], [["ArrowDown", "mac+ArrowDown"], resize, {
}], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], resize, {
}], [["Escape", "mac+Escape"], AnnotationEditor.prototype._stopResizingWithKeyboard]]));
constructor(parameters) {
if (this.constructor === AnnotationEditor) {
unreachable("Cannot initialize AnnotationEditor.");
this.parent = parameters.parent;
this.width = this.height = null;
this.pageIndex = parameters.parent.pageIndex;
this.name = parameters.name;
this._uiManager = parameters.uiManager;
this.annotationElementId = null;
this._willKeepAspectRatio = false;
this._initialOptions.isCentered = parameters.isCentered;
this._structTreeParentId = null;
} = this.parent.viewport;
this.rotation = rotation;
this.pageRotation = (360 + rotation - this._uiManager.viewParameters.rotation) % 360;
this.pageDimensions = [pageWidth, pageHeight];
this.pageTranslation = [pageX, pageY];
const [width, height] = this.parentDimensions;
this.x = parameters.x / width;
this.y = parameters.y / height;
this.isAttachedToDOM = false;
return Object.getPrototypeOf(this).constructor._type;
static get _defaultLineColor() {
return shadow(this, "_defaultLineColor", this._colorManager.getHexCode("CanvasText"));
static deleteAnnotationElement(editor) {
const fakeEditor = new FakeEditor({
id: editor.parent.getNextId(),
uiManager: editor._uiManager
fakeEditor.annotationElementId = editor.annotationElementId;
fakeEditor.deleted = true;
fakeEditor._uiManager.addToAnnotationStorage(fakeEditor);
static initialize(l10n, _uiManager, options) {
AnnotationEditor._l10nPromise ||= new Map(["pdfjs-editor-alt-text-button-label", "pdfjs-editor-alt-text-edit-button-label", "pdfjs-editor-alt-text-decorative-tooltip", "pdfjs-editor-resizer-label-topLeft", "pdfjs-editor-resizer-label-topMiddle", "pdfjs-editor-resizer-label-topRight", "pdfjs-editor-resizer-label-middleRight", "pdfjs-editor-resizer-label-bottomRight", "pdfjs-editor-resizer-label-bottomMiddle", "pdfjs-editor-resizer-label-bottomLeft", "pdfjs-editor-resizer-label-middleLeft"].map(str => [str, l10n.get(str.replaceAll(/([A-Z])/g, c => `-${c.toLowerCase()}`))]));
for (const str of options.strings) {
AnnotationEditor._l10nPromise.set(str, l10n.get(str));
if (AnnotationEditor._borderLineWidth !== -1) {
const style = getComputedStyle(document.documentElement);
AnnotationEditor._borderLineWidth = parseFloat(style.getPropertyValue("--outline-width")) || 0;
static updateDefaultParams(_type, _value) {}
static get defaultPropertiesToUpdate() {
static isHandlingMimeForPasting(mime) {
static paste(item, parent) {
unreachable("Not implemented");
get propertiesToUpdate() {
return this.#isDraggable;
set _isDraggable(value) {
this.#isDraggable = value;
this.div?.classList.toggle("draggable", value);
const [pageWidth, pageHeight] = this.pageDimensions;
switch (this.parentRotation) {
this.x -= this.height * pageHeight / (pageWidth * 2);
this.y += this.width * pageWidth / (pageHeight * 2);
this.x += this.width / 2;
this.y += this.height / 2;
this.x += this.height * pageHeight / (pageWidth * 2);
this.y -= this.width * pageWidth / (pageHeight * 2);
this.x -= this.width / 2;
this.y -= this.height / 2;
this.fixAndSetPosition();
this._uiManager.addCommands(params);
return this._uiManager.currentLayer;
this.div.style.zIndex = 0;
this.div.style.zIndex = this.#zIndex;
this.pageIndex = parent.pageIndex;
this.pageDimensions = parent.pageDimensions;
if (!this._focusEventsAllowed) {
if (!this.#hasBeenClicked) {
this.parent.setSelected(this);
this.#hasBeenClicked = false;
if (!this._focusEventsAllowed) {
if (!this.isAttachedToDOM) {
const target = event.relatedTarget;
if (target?.closest(`#${this.id}`)) {
if (!this.parent?.isMultipleSelection) {
this.addToAnnotationStorage();
addToAnnotationStorage() {
this._uiManager.addToAnnotationStorage(this);
const [width, height] = this.parentDimensions;
[tx, ty] = this.screenToPageTranslation(tx, ty);
this.x = (x + tx) / width;