: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
_colorSelectFromKeyboard(event) {
if (event.target === this.#button) {
this.#openDropdown(event);
const color = event.target.getAttribute("data-color");
this.#colorSelect(color, event);
if (!this.#isDropdownVisible) {
this.#openDropdown(event);
if (event.target === this.#button) {
this.#dropdown.firstChild?.focus();
event.target.nextSibling?.focus();
if (event.target === this.#dropdown?.firstChild || event.target === this.#button) {
if (this.#isDropdownVisible) {
this._hideDropdownFromKeyboard();
if (!this.#isDropdownVisible) {
this.#openDropdown(event);
event.target.previousSibling?.focus();
_moveToBeginning(event) {
if (!this.#isDropdownVisible) {
this.#openDropdown(event);
this.#dropdown.firstChild?.focus();
if (!this.#isDropdownVisible) {
this.#openDropdown(event);
this.#dropdown.lastChild?.focus();
ColorPicker._keyboardManager.exec(this, event);
if (this.#isDropdownVisible) {
this.#dropdownWasFromKeyboard = event.detail === 0;
window.addEventListener("pointerdown", this.#boundPointerDown);
this.#dropdown.classList.remove("hidden");
const root = this.#dropdown = this.#getDropdownRoot();
this.#button.append(root);
if (this.#dropdown?.contains(event.target)) {
this.#dropdown?.classList.add("hidden");
window.removeEventListener("pointerdown", this.#boundPointerDown);
get #isDropdownVisible() {
return this.#dropdown && !this.#dropdown.classList.contains("hidden");
_hideDropdownFromKeyboard() {
if (this.#isMainColorPicker) {
if (!this.#isDropdownVisible) {
this.#editor?.unselect();
focusVisible: this.#dropdownWasFromKeyboard
if (this.#buttonSwatch) {
this.#buttonSwatch.style.backgroundColor = color;
const i = this.#uiManager.highlightColors.values();
for (const child of this.#dropdown.children) {
child.setAttribute("aria-selected", i.next().value === color);
this.#buttonSwatch = null;
this.#dropdown?.remove();
;// CONCATENATED MODULE: ./src/display/editor/highlight.js
class HighlightEditor extends AnnotationEditor {
#highlightOutlines = null;
#isFreeHighlight = false;
#boundKeydown = this.#keydown.bind(this);
static _defaultColor = null;
static _defaultOpacity = 1;
static _defaultThickness = 12;
static _type = "highlight";
static _editorType = AnnotationEditorType.HIGHLIGHT;
static _freeHighlightId = -1;
static _freeHighlight = null;
static _freeHighlightClipId = "";
static get _keyboardManager() {
const proto = HighlightEditor.prototype;
return shadow(this, "_keyboardManager", new KeyboardManager([[["ArrowLeft", "mac+ArrowLeft"], proto._moveCaret, {
}], [["ArrowRight", "mac+ArrowRight"], proto._moveCaret, {
}], [["ArrowUp", "mac+ArrowUp"], proto._moveCaret, {
}], [["ArrowDown", "mac+ArrowDown"], proto._moveCaret, {
this.color = params.color || HighlightEditor._defaultColor;
this.#thickness = params.thickness || HighlightEditor._defaultThickness;
this.#opacity = params.opacity || HighlightEditor._defaultOpacity;
this.#boxes = params.boxes || null;
this.#methodOfCreation = params.methodOfCreation || "";
this.#text = params.text || "";
this._isDraggable = false;
if (params.highlightId > -1) {
this.#isFreeHighlight = true;
this.#createFreeOutlines(params);
this.#anchorNode = params.anchorNode;
this.#anchorOffset = params.anchorOffset;
this.#focusNode = params.focusNode;
this.#focusOffset = params.focusOffset;
this.rotate(this.rotation);
get telemetryInitialData() {
type: this.#isFreeHighlight ? "free_highlight" : "highlight",
color: this._uiManager.highlightColorNames.get(this.color),
thickness: this.#thickness,
methodOfCreation: this.#methodOfCreation
get telemetryFinalData() {
color: this._uiManager.highlightColorNames.get(this.color)
static computeTelemetryFinalData(data) {
numberOfColors: data.get("color").size
const outliner = new Outliner(this.#boxes, 0.001);
this.#highlightOutlines = outliner.getOutlines();
} = this.#highlightOutlines.box);
const outlinerForOutline = new Outliner(this.#boxes, 0.0025, 0.001, this._uiManager.direction === "ltr");
this.#focusOutlines = outlinerForOutline.getOutlines();
} = this.#focusOutlines.box;
this.#lastPoint = [(lastPoint[0] - this.x) / this.width, (lastPoint[1] - this.y) / this.height];
this.#highlightOutlines = highlightOutlines;
const extraThickness = 1.5;
this.#focusOutlines = highlightOutlines.getNewOutline(this.#thickness / 2 + extraThickness, 0.0025);
this.#clipPathId = clipPathId;
this.parent.drawLayer.finalizeLine(highlightId, highlightOutlines);
this.#outlineId = this.parent.drawLayer.highlightOutline(this.#focusOutlines);
} else if (this.parent) {
const angle = this.parent.viewport.rotation;
this.parent.drawLayer.updateLine(this.#id, highlightOutlines);
this.parent.drawLayer.updateBox(this.#id, HighlightEditor.#rotateBbox(this.#highlightOutlines.box, (angle - this.rotation + 360) % 360));
this.parent.drawLayer.updateLine(this.#outlineId, this.#focusOutlines);
this.parent.drawLayer.updateBox(this.#outlineId, HighlightEditor.#rotateBbox(this.#focusOutlines.box, angle));
} = highlightOutlines.box;
const [pageWidth, pageHeight] = this.parentDimensions;
this.width = width * pageHeight / pageWidth;
this.height = height * pageWidth / pageHeight;
const [pageWidth, pageHeight] = this.parentDimensions;
this.width = width * pageHeight / pageWidth;
this.height = height * pageWidth / pageHeight;
} = this.#focusOutlines.box;
this.#lastPoint = [(lastPoint[0] - x) / width, (lastPoint[1] - y) / height];
static initialize(l10n, uiManager) {
AnnotationEditor.initialize(l10n, uiManager);
HighlightEditor._defaultColor ||= uiManager.highlightColors?.values().next().value || "#fff066";
static updateDefaultParams(type, value) {
case AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
HighlightEditor._defaultColor = value;
case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
HighlightEditor._defaultThickness = value;
updateParams(type, value) {
case AnnotationEditorParamsType.HIGHLIGHT_COLOR:
this.#updateColor(value);
case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
this.#updateThickness(value);
static get defaultPropertiesToUpdate() {
return [[AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR, HighlightEditor._defaultColor], [AnnotationEditorParamsType.HIGHLIGHT_THICKNESS, HighlightEditor._defaultThickness]];
get propertiesToUpdate() {
return [[AnnotationEditorParamsType.HIGHLIGHT_COLOR, this.color || HighlightEditor._defaultColor], [AnnotationEditorParamsType.HIGHLIGHT_THICKNESS, this.#thickness || HighlightEditor._defaultThickness], [AnnotationEditorParamsType.HIGHLIGHT_FREE, this.#isFreeHighlight]];
const setColor = col => {
this.parent?.drawLayer.changeColor(this.#id, col);
this.#colorPicker?.updateColor(col);
const savedColor = this.color;
cmd: setColor.bind(this, color),
undo: setColor.bind(this, savedColor),
post: this._uiManager.updateUI.bind(this._uiManager, this),
type: AnnotationEditorParamsType.HIGHLIGHT_COLOR,
overwriteIfSameType: true,
color: this._uiManager.highlightColorNames.get(color)
#updateThickness(thickness) {
const savedThickness = this.#thickness;
const setThickness = th => {
this.#changeThickness(th);
cmd: setThickness.bind(this, thickness),
undo: setThickness.bind(this, savedThickness),
post: this._uiManager.updateUI.bind(this._uiManager, this),
type: AnnotationEditorParamsType.INK_THICKNESS,
overwriteIfSameType: true,
action: "thickness_changed",
const toolbar = await super.addEditToolbar();
if (this._uiManager.highlightColors) {
this.#colorPicker = new ColorPicker({
toolbar.addColorPicker(this.#colorPicker);
this.div.classList.toggle("disabled", true);
this.div.classList.toggle("disabled", false);
return super.fixAndSetPosition(this.#getRotation());
return super.getRect(tx, ty, this.#getRotation());
this.parent.addUndoableEditor(this);
if (!this.isAttachedToDOM) {
let mustBeSelected = false;
if (this.parent && !parent) {
this.#addToDrawLayer(parent);
mustBeSelected = !this.parent && this.div?.classList.contains("selectedEditor");
this.show(this._isVisible);
#changeThickness(thickness) {
if (!this.#isFreeHighlight) {
this.#createFreeOutlines({
highlightOutlines: this.#highlightOutlines.getNewOutline(thickness / 2)
this.fixAndSetPosition();
const [parentWidth, parentHeight] = this.parentDimensions;
this.setDims(this.width * parentWidth, this.height * parentHeight);
if (this.#id === null || !this.parent) {
this.parent.drawLayer.remove(this.#id);
this.parent.drawLayer.remove(this.#outlineId);
#addToDrawLayer(parent = this.parent) {
clipPathId: this.#clipPathId
} = parent.drawLayer.highlight(this.#highlightOutlines, this.color, this.#opacity));
this.#outlineId = parent.drawLayer.highlightOutline(this.#focusOutlines);
if (this.#highlightDiv) {
this.#highlightDiv.style.clipPath = this.#clipPathId;