: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
this.disableUserSelect(false);
registerEditorTypes(types) {
this.#editorTypes = types;
for (const editorType of this.#editorTypes) {
this.#dispatchUpdateUI(editorType.defaultPropertiesToUpdate);
return this.#idManager.id;
return this.#allLayers.get(this.#currentPageIndex);
return this.#allLayers.get(pageIndex);
return this.#currentPageIndex;
this.#allLayers.set(layer.pageIndex, layer);
this.#allLayers.delete(layer.pageIndex);
updateMode(mode, editId = null, isFromKeyboard = false) {
if (this.#mode === mode) {
if (mode === AnnotationEditorType.NONE) {
this.setEditingState(false);
this.setEditingState(true);
for (const layer of this.#allLayers.values()) {
if (!editId && isFromKeyboard) {
this.addNewEditorFromKeyboard();
for (const editor of this.#allEditors.values()) {
if (editor.annotationElementId === editId) {
this.setSelected(editor);
editor.enterInEditMode();
addNewEditorFromKeyboard() {
if (this.currentLayer.canCreateNewEmptyEditor()) {
this.currentLayer.addNewEditor();
if (mode === this.#mode) {
this._eventBus.dispatch("switchannotationeditormode", {
updateParams(type, value) {
if (!this.#editorTypes) {
case AnnotationEditorParamsType.CREATE:
this.currentLayer.addNewEditor();
case AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
this.#mainHighlightColorPicker?.updateColor(value);
case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
this._eventBus.dispatch("reporttelemetry", {
action: "toggle_visibility"
(this.#showAllStates ||= new Map()).set(type, value);
this.showAllEditors("highlight", value);
for (const editor of this.#selectedEditors) {
editor.updateParams(type, value);
for (const editorType of this.#editorTypes) {
editorType.updateDefaultParams(type, value);
showAllEditors(type, visible, updateButton = false) {
for (const editor of this.#allEditors.values()) {
if (editor.editorType === type) {
const state = this.#showAllStates?.get(AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL) ?? true;
this.#dispatchUpdateUI([[AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL, visible]]);
enableWaiting(mustWait = false) {
if (this.#isWaiting === mustWait) {
this.#isWaiting = mustWait;
for (const layer of this.#allLayers.values()) {
layer.div.classList.toggle("waiting", mustWait);
for (const layer of this.#allLayers.values()) {
for (const editor of this.#allEditors.values()) {
for (const layer of this.#allLayers.values()) {
for (const editor of this.#allEditors.values()) {
for (const editor of this.#allEditors.values()) {
if (editor.pageIndex === pageIndex) {
return this.#allEditors.get(id);
this.#allEditors.set(editor.id, editor);
if (editor.div.contains(document.activeElement)) {
if (this.#focusMainContainerTimeoutId) {
clearTimeout(this.#focusMainContainerTimeoutId);
this.#focusMainContainerTimeoutId = setTimeout(() => {
this.focusMainContainer();
this.#focusMainContainerTimeoutId = null;
this.#allEditors.delete(editor.id);
if (!editor.annotationElementId || !this.#deletedAnnotationsElementIds.has(editor.annotationElementId)) {
this.#annotationStorage?.remove(editor.id);
addDeletedAnnotationElement(editor) {
this.#deletedAnnotationsElementIds.add(editor.annotationElementId);
this.addChangedExistingAnnotation(editor);
isDeletedAnnotationElement(annotationElementId) {
return this.#deletedAnnotationsElementIds.has(annotationElementId);
removeDeletedAnnotationElement(editor) {
this.#deletedAnnotationsElementIds.delete(editor.annotationElementId);
this.removeChangedExistingAnnotation(editor);
#addEditorToLayer(editor) {
const layer = this.#allLayers.get(editor.pageIndex);
layer.addOrRebuild(editor);
this.addToAnnotationStorage(editor);
setActiveEditor(editor) {
if (this.#activeEditor === editor) {
this.#activeEditor = editor;
this.#dispatchUpdateUI(editor.propertiesToUpdate);
get #lastSelectedEditor() {
for (ed of this.#selectedEditors) {}
if (this.#lastSelectedEditor === editor) {
this.#dispatchUpdateUI(editor.propertiesToUpdate);
if (this.#selectedEditors.has(editor)) {
this.#selectedEditors.delete(editor);
this.#dispatchUpdateStates({
hasSelectedEditor: this.hasSelection
this.#selectedEditors.add(editor);
this.#dispatchUpdateUI(editor.propertiesToUpdate);
this.#dispatchUpdateStates({
for (const ed of this.#selectedEditors) {
this.#selectedEditors.clear();
this.#selectedEditors.add(editor);
this.#dispatchUpdateUI(editor.propertiesToUpdate);
this.#dispatchUpdateStates({
return this.#selectedEditors.has(editor);
get firstSelectedEditor() {
return this.#selectedEditors.values().next().value;
this.#selectedEditors.delete(editor);
this.#dispatchUpdateStates({
hasSelectedEditor: this.hasSelection
return this.#selectedEditors.size !== 0;
return this.#selectedEditors.size === 1 && this.firstSelectedEditor.isEnterHandled;
this.#commandManager.undo();
this.#dispatchUpdateStates({
hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),
hasSomethingToRedo: true,
this.#commandManager.redo();
this.#dispatchUpdateStates({
hasSomethingToUndo: true,
hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),
this.#commandManager.add(params);
this.#dispatchUpdateStates({
hasSomethingToUndo: true,
hasSomethingToRedo: false,
if (this.#allEditors.size === 0) {
if (this.#allEditors.size === 1) {
for (const editor of this.#allEditors.values()) {
if (!this.hasSelection) {
const editors = [...this.#selectedEditors];
for (const editor of editors) {
for (const editor of editors) {
this.#addEditorToLayer(editor);
this.#activeEditor?.commitOrRemove();
hasSomethingToControl() {
return this.#activeEditor || this.hasSelection;
#selectEditors(editors) {
for (const editor of this.#selectedEditors) {
this.#selectedEditors.clear();
for (const editor of editors) {
this.#selectedEditors.add(editor);
this.#dispatchUpdateStates({
hasSelectedEditor: this.hasSelection
for (const editor of this.#selectedEditors) {
this.#selectEditors(this.#allEditors.values());
if (this.#activeEditor) {
this.#activeEditor.commitOrRemove();
if (this.#mode !== AnnotationEditorType.NONE) {
if (!this.hasSelection) {
for (const editor of this.#selectedEditors) {
this.#selectedEditors.clear();
this.#dispatchUpdateStates({
translateSelectedEditors(x, y, noCommit = false) {
if (!this.hasSelection) {
this.#translation[0] += x;
this.#translation[1] += y;
const [totalX, totalY] = this.#translation;
const editors = [...this.#selectedEditors];
const TIME_TO_WAIT = 1000;
if (this.#translationTimeoutId) {
clearTimeout(this.#translationTimeoutId);
this.#translationTimeoutId = setTimeout(() => {
this.#translationTimeoutId = null;
this.#translation[0] = this.#translation[1] = 0;
for (const editor of editors) {
if (this.#allEditors.has(editor.id)) {
editor.translateInPage(totalX, totalY);
for (const editor of editors) {
if (this.#allEditors.has(editor.id)) {
editor.translateInPage(-totalX, -totalY);
for (const editor of editors) {
editor.translateInPage(x, y);
if (!this.hasSelection) {
this.disableUserSelect(true);
this.#draggingEditors = new Map();
for (const editor of this.#selectedEditors) {
this.#draggingEditors.set(editor, {
savedPageIndex: editor.pageIndex,
if (!this.#draggingEditors) {
this.disableUserSelect(false);
const map = this.#draggingEditors;
this.#draggingEditors = null;
let mustBeAddedInUndoStack = false;
value.newPageIndex = pageIndex;
mustBeAddedInUndoStack ||= x !== value.savedX || y !== value.savedY || pageIndex !== value.savedPageIndex;
if (!mustBeAddedInUndoStack) {
const move = (editor, x, y, pageIndex) => {
if (this.#allEditors.has(editor.id)) {
const parent = this.#allLayers.get(pageIndex);
editor._setParentAndPosition(parent, x, y);
editor.pageIndex = pageIndex;
move(editor, newX, newY, newPageIndex);
move(editor, savedX, savedY, savedPageIndex);
dragSelectedEditors(tx, ty) {