chore: remove frame overlay dependency from default-tool (#11762)
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
import { OverlayIdentifier } from '@blocksuite/affine-block-surface';
|
import { OverlayIdentifier } from '@blocksuite/affine-block-surface';
|
||||||
import {
|
import { FrameBlockModel, MindmapElementModel } from '@blocksuite/affine-model';
|
||||||
type FrameBlockModel,
|
|
||||||
MindmapElementModel,
|
|
||||||
} from '@blocksuite/affine-model';
|
|
||||||
import {
|
import {
|
||||||
type DragExtensionInitializeContext,
|
type DragExtensionInitializeContext,
|
||||||
getTopElements,
|
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 {
|
import { isFrameBlock } from '@blocksuite/affine-block-frame';
|
||||||
type FrameOverlay,
|
|
||||||
isFrameBlock,
|
|
||||||
} from '@blocksuite/affine-block-frame';
|
|
||||||
import { OverlayIdentifier } from '@blocksuite/affine-block-surface';
|
|
||||||
import {
|
import {
|
||||||
GroupElementModel,
|
GroupElementModel,
|
||||||
MindmapElementModel,
|
MindmapElementModel,
|
||||||
@@ -186,10 +182,6 @@ export class DefaultTool extends BaseTool {
|
|||||||
return this.std.getOptional(InteractivityIdentifier);
|
return this.std.getOptional(InteractivityIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
private get frameOverlay() {
|
|
||||||
return this.std.get(OverlayIdentifier('frame')) as FrameOverlay;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _cloneContent() {
|
private async _cloneContent() {
|
||||||
const clonedResult = await this.interactivity?.requestElementsClone({
|
const clonedResult = await this.interactivity?.requestElementsClone({
|
||||||
elements: this._toBeMoved,
|
elements: this._toBeMoved,
|
||||||
@@ -364,7 +356,6 @@ export class DefaultTool extends BaseTool {
|
|||||||
if (this.edgelessSelectionManager.editing || !this.dragging) return;
|
if (this.edgelessSelectionManager.editing || !this.dragging) return;
|
||||||
|
|
||||||
this.dragging = false;
|
this.dragging = false;
|
||||||
this.frameOverlay.clear();
|
|
||||||
this._toBeMoved = [];
|
this._toBeMoved = [];
|
||||||
this._clearSelectingState();
|
this._clearSelectingState();
|
||||||
this.dragType = DefaultModeDragType.None;
|
this.dragType = DefaultModeDragType.None;
|
||||||
@@ -470,21 +461,6 @@ export class DefaultTool extends BaseTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override pointerMove(e: PointerEventState) {
|
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);
|
this.interactivity?.dispatchEvent('pointermove', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user