Merge pull request #15970 from calixteman/editor_invisible
[Editor] Make the annotation editor layer invisible when disabled and empty
This commit is contained in:
commit
1bdee0b59b
@ -84,6 +84,10 @@ class AnnotationEditorLayer {
|
|||||||
this.#uiManager.addLayer(this);
|
this.#uiManager.addLayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isEmpty() {
|
||||||
|
return this.#editors.size === 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the toolbar if it's required to reflect the tool currently used.
|
* Update the toolbar if it's required to reflect the tool currently used.
|
||||||
* @param {number} mode
|
* @param {number} mode
|
||||||
@ -107,11 +111,17 @@ class AnnotationEditorLayer {
|
|||||||
}
|
}
|
||||||
this.#uiManager.unselectAll();
|
this.#uiManager.unselectAll();
|
||||||
|
|
||||||
this.div.classList.toggle(
|
if (mode !== AnnotationEditorType.NONE) {
|
||||||
"freeTextEditing",
|
this.div.classList.toggle(
|
||||||
mode === AnnotationEditorType.FREETEXT
|
"freeTextEditing",
|
||||||
);
|
mode === AnnotationEditorType.FREETEXT
|
||||||
this.div.classList.toggle("inkEditing", mode === AnnotationEditorType.INK);
|
);
|
||||||
|
this.div.classList.toggle(
|
||||||
|
"inkEditing",
|
||||||
|
mode === AnnotationEditorType.INK
|
||||||
|
);
|
||||||
|
this.div.hidden = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addInkEditorIfNeeded(isCommitting) {
|
addInkEditorIfNeeded(isCommitting) {
|
||||||
@ -172,6 +182,10 @@ class AnnotationEditorLayer {
|
|||||||
for (const editor of this.#editors.values()) {
|
for (const editor of this.#editors.values()) {
|
||||||
editor.disableEditing();
|
editor.disableEditing();
|
||||||
}
|
}
|
||||||
|
this.#cleanup();
|
||||||
|
if (this.isEmpty) {
|
||||||
|
this.div.hidden = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,6 +75,7 @@ class AnnotationEditorLayerBuilder {
|
|||||||
const div = (this.div = document.createElement("div"));
|
const div = (this.div = document.createElement("div"));
|
||||||
div.className = "annotationEditorLayer";
|
div.className = "annotationEditorLayer";
|
||||||
div.tabIndex = 0;
|
div.tabIndex = 0;
|
||||||
|
div.hidden = true;
|
||||||
this.pageDiv.append(div);
|
this.pageDiv.append(div);
|
||||||
|
|
||||||
this.annotationEditorLayer = new AnnotationEditorLayer({
|
this.annotationEditorLayer = new AnnotationEditorLayer({
|
||||||
@ -94,6 +95,7 @@ class AnnotationEditorLayerBuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.annotationEditorLayer.render(parameters);
|
this.annotationEditorLayer.render(parameters);
|
||||||
|
this.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
@ -115,7 +117,7 @@ class AnnotationEditorLayerBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
if (!this.div) {
|
if (!this.div || this.annotationEditorLayer.isEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.div.hidden = false;
|
this.div.hidden = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user