feat(editor): disable clickToDrag for edgeless toolbar shape and mindmap (#11310)

This commit is contained in:
CatsJuice
2025-04-04 05:10:04 +00:00
parent adbd41130c
commit 46d8d30e62
6 changed files with 51 additions and 5 deletions

View File

@@ -389,6 +389,30 @@ export class EdgelessDraggableElementController<T>
this.options.edgeless.host.dispatchEvent(mouseMoveEvent);
}
dragAndMoveTo(target: HTMLElement, to: { x: number; y: number }) {
const targetRect = target.getBoundingClientRect();
const targetCenter = {
x: targetRect.left + targetRect.width / 2,
y: targetRect.top + targetRect.height / 2,
};
const mouseDownEvent = new MouseEvent('mousedown', {
clientX: targetCenter.x,
clientY: targetCenter.y,
});
const mouseMoveStartEvent = new MouseEvent('mousemove', {
clientX: targetCenter.x,
clientY: targetCenter.y,
});
const mouseMoveToEvent = new MouseEvent('mousemove', {
clientX: to.x,
clientY: to.y,
});
target.dispatchEvent(mouseDownEvent);
this.options.edgeless.host.dispatchEvent(mouseMoveStartEvent);
this.options.edgeless.host.dispatchEvent(mouseMoveToEvent);
}
hostConnected() {
this.host.disposables.add(
this.gfx.viewport.viewportUpdated.subscribe(({ zoom }) => {