chore: remove frame overlay dependency from default-tool (#11762)

This commit is contained in:
doouding
2025-04-22 08:18:25 +00:00
parent e0e84d302d
commit 1d58792631
2 changed files with 19 additions and 29 deletions
@@ -1,8 +1,5 @@
import { OverlayIdentifier } from '@blocksuite/affine-block-surface';
import {
type FrameBlockModel,
MindmapElementModel,
} from '@blocksuite/affine-model';
import { FrameBlockModel, MindmapElementModel } from '@blocksuite/affine-model';
import {
type DragExtensionInitializeContext,
getTopElements,
@@ -78,5 +75,22 @@ export class FrameHighlightManager extends InteractivityExtension {
},
};
});
this.event.on('pointermove', context => {
const [x, y] = this.gfx.viewport.toModelCoord(
context.event.x,
context.event.y
);
const target = this.gfx.getElementByPoint(x, y);
if (
target instanceof FrameBlockModel &&
target.externalBound?.isPointInBound([x, y])
) {
this.frameHighlightOverlay.highlight(target);
} else {
this.frameHighlightOverlay.clear();
}
});
}
}
@@ -1,8 +1,4 @@
import {
type FrameOverlay,
isFrameBlock,
} from '@blocksuite/affine-block-frame';
import { OverlayIdentifier } from '@blocksuite/affine-block-surface';
import { isFrameBlock } from '@blocksuite/affine-block-frame';
import {
GroupElementModel,
MindmapElementModel,
@@ -186,10 +182,6 @@ export class DefaultTool extends BaseTool {
return this.std.getOptional(InteractivityIdentifier);
}
private get frameOverlay() {
return this.std.get(OverlayIdentifier('frame')) as FrameOverlay;
}
private async _cloneContent() {
const clonedResult = await this.interactivity?.requestElementsClone({
elements: this._toBeMoved,
@@ -364,7 +356,6 @@ export class DefaultTool extends BaseTool {
if (this.edgelessSelectionManager.editing || !this.dragging) return;
this.dragging = false;
this.frameOverlay.clear();
this._toBeMoved = [];
this._clearSelectingState();
this.dragType = DefaultModeDragType.None;
@@ -470,21 +461,6 @@ export class DefaultTool extends BaseTool {
}
override pointerMove(e: PointerEventState) {
const hovered = this._pick(e.x, e.y, {
hitThreshold: 10,
});
if (
isFrameBlock(hovered) &&
hovered.externalBound?.isPointInBound(
this.gfx.viewport.toModelCoord(e.x, e.y)
)
) {
this.frameOverlay.highlight(hovered);
} else {
this.frameOverlay.clear();
}
this.interactivity?.dispatchEvent('pointermove', e);
}