mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
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:
commit
399475247f
11 changed files with 170 additions and 75 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue