fix: embed block style when dragging doc from sidebar doc list to edgeless (#10122)

This commit is contained in:
doouding
2025-02-13 01:35:33 +00:00
parent 40121b6ad5
commit cf40afb3e4
@@ -37,6 +37,7 @@ import {
type DropPayload, type DropPayload,
} from '@blocksuite/block-std'; } from '@blocksuite/block-std';
import { import {
GfxBlockElementModel,
GfxControllerIdentifier, GfxControllerIdentifier,
GfxGroupLikeElementModel, GfxGroupLikeElementModel,
type GfxModel, type GfxModel,
@@ -55,6 +56,7 @@ import {
import { import {
type BlockModel, type BlockModel,
type BlockSnapshot, type BlockSnapshot,
internalPrimitives,
Slice, Slice,
type SliceSnapshot, type SliceSnapshot,
toDraftModel, toDraftModel,
@@ -893,9 +895,7 @@ export class DragEventWatcher {
point: Point, point: Point,
ignoreOriginalPos: boolean = false ignoreOriginalPos: boolean = false
) => { ) => {
const rect = getSnapshotRect(snapshot); const rect = getSnapshotRect(snapshot) ?? new Bound(0, 0, 0, 0);
if (!rect) return;
const { x: modelX, y: modelY } = point; const { x: modelX, y: modelY } = point;
const rewrite = (block: BlockSnapshot) => { const rewrite = (block: BlockSnapshot) => {
@@ -920,10 +920,23 @@ export class DragEventWatcher {
}); });
} }
block.children.forEach(rewrite); block.children.forEach(rewrite);
} else if (block.props.xywh) { } else {
const blockBound = Bound.deserialize( const schema = this.std.store.schema.get(block.flavour);
block.props.xywh as SerializedXYWH const isGfxModel =
); schema?.model.toModel?.() instanceof GfxBlockElementModel;
if (!isGfxModel) {
return;
}
if (!block.props.xywh) {
block.props.xywh =
schema?.model.props?.(internalPrimitives).xywh ?? '[0,0,100,100]';
}
const blockBound =
Bound.deserialize(block.props.xywh as SerializedXYWH) ??
new Bound(0, 0, 0, 0);
if ( if (
block.flavour === 'affine:attachment' || block.flavour === 'affine:attachment' ||