feat: edgeless dnd (#9988)

### Changed
- Support edgelss dnd
- Simplify the drag-handle state
This commit is contained in:
doouding
2025-02-12 12:37:06 +00:00
parent 8129434a2e
commit f89fcf82f8
22 changed files with 1041 additions and 350 deletions
@@ -31,7 +31,8 @@ export const SurfaceBlockSchema = defineBlockSchema({
'affine:edgeless-text',
],
},
transformer: () => new SurfaceBlockTransformer(),
transformer: transformerConfigs =>
new SurfaceBlockTransformer(transformerConfigs),
toModel: () => new SurfaceBlockModel(),
});
@@ -92,9 +92,18 @@ export class SurfaceBlockTransformer extends BaseBlockTransformer<SurfaceBlockPr
const snapshot = super.toSnapshot(payload);
const elementsValue = payload.model.elements.getValue();
const value: Record<string, unknown> = {};
/**
* When the selectedElements is defined, only the selected elements will be serialized.
*/
const selectedElements = this.transformerConfigs.get(
'selectedElements'
) as Set<string>;
if (elementsValue) {
elementsValue.forEach((element, key) => {
value[key] = this._elementToJSON(element as Y.Map<unknown>);
if (selectedElements?.has(key) || !selectedElements) {
value[key] = this._elementToJSON(element as Y.Map<unknown>);
}
});
}
snapshot.props = {