mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-07 12:29:50 +08:00
feat: edgeless dnd (#9988)
### Changed - Support edgelss dnd - Simplify the drag-handle state
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user