Merge pull request #16781 from calixteman/editor_rewrite_dragging

[Editor] Refactor dragging and dropping an editor (bug 1802895, bug 1844618)
This commit is contained in:
calixteman 2023-08-03 15:38:12 +02:00 committed by GitHub
commit 399475247f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 170 additions and 75 deletions

View file

@ -586,6 +586,8 @@ class AnnotationEditorUIManager {
#container = null;
#viewer = null;
static TRANSLATE_SMALL = 1; // page units.
static TRANSLATE_BIG = 10; // page units.
@ -686,8 +688,9 @@ class AnnotationEditorUIManager {
);
}
constructor(container, eventBus, pdfDocument, pageColors) {
constructor(container, viewer, eventBus, pdfDocument, pageColors) {
this.#container = container;
this.#viewer = viewer;
this.#eventBus = eventBus;
this.#eventBus._on("editingaction", this.#boundOnEditingAction);
this.#eventBus._on("pagechanging", this.#boundOnPageChanging);
@ -740,6 +743,30 @@ class AnnotationEditorUIManager {
this.#container.focus();
}
findParent(x, y) {
for (const layer of this.#allLayers.values()) {
const {
x: layerX,
y: layerY,
width,
height,
} = layer.div.getBoundingClientRect();
if (
x >= layerX &&
x <= layerX + width &&
y >= layerY &&
y <= layerY + height
) {
return layer;
}
}
return null;
}
disableUserSelect(value = false) {
this.#viewer.classList.toggle("noUserSelect", value);
}
addShouldRescale(editor) {
this.#editorsToRescale.add(editor);
}
@ -961,6 +988,7 @@ class AnnotationEditorUIManager {
this.#dispatchUpdateStates({
isEditing: false,
});
this.disableUserSelect(false);
}
}