Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

doouding1d58792631e3
diff --git a/blocksuite/affine/blocks/frame/src/frame-highlight-manager.ts b/blocksuite/affine/blocks/frame/src/frame-highlight-manager.ts
index e631591a64..d43a68b68f 100644
--- a/blocksuite/affine/blocks/frame/src/frame-highlight-manager.ts
+++ b/blocksuite/affine/blocks/frame/src/frame-highlight-manager.ts
@@ -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();
+ }
+ });
}
}
diff --git a/blocksuite/affine/blocks/root/src/edgeless/gfx-tool/default-tool.ts b/blocksuite/affine/blocks/root/src/edgeless/gfx-tool/default-tool.ts
index 0e66d66d2c..8fe02abe4b 100644
--- a/blocksuite/affine/blocks/root/src/edgeless/gfx-tool/default-tool.ts
+++ b/blocksuite/affine/blocks/root/src/edgeless/gfx-tool/default-tool.ts
@@ -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);
}