refactor(editor): improve edgeless clipboard config (#11472)

This commit is contained in:
Saul-Mirone
2025-04-05 03:48:26 +00:00
parent 96e860caf3
commit 0fbca31c27
30 changed files with 492 additions and 451 deletions
@@ -0,0 +1,30 @@
import { EdgelessClipboardConfig } from '@blocksuite/affine-block-surface';
import { type BlockSnapshot } from '@blocksuite/store';
export class EdgelessClipboardImageConfig extends EdgelessClipboardConfig {
static override readonly key = 'affine:image';
override async createBlock(image: BlockSnapshot) {
const { xywh, rotate, sourceId, size, width, height, caption } =
image.props;
if (!this.surface) return null;
if (!(await this.std.workspace.blobSync.get(sourceId as string))) {
return null;
}
return this.crud.addBlock(
'affine:image',
{
caption,
sourceId,
xywh,
rotate,
size,
width,
height,
},
this.surface.model.id
);
}
}
@@ -1,5 +1,6 @@
export * from './adapters';
export * from './commands';
export * from './edgeless-clipboard-config';
export * from './image-block';
export * from './image-edgeless-block';
export { ImageProxyService } from './image-proxy-service';