mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 01:29:31 +08:00
1f45cc5dec
**Directory Structure Changes** - Renamed multiple block-related directories by removing the "block-" prefix: - `block-attachment` → `attachment` - `block-bookmark` → `bookmark` - `block-callout` → `callout` - `block-code` → `code` - `block-data-view` → `data-view` - `block-database` → `database` - `block-divider` → `divider` - `block-edgeless-text` → `edgeless-text` - `block-embed` → `embed`
35 lines
864 B
TypeScript
35 lines
864 B
TypeScript
import { EdgelessClipboardConfig } from '@blocksuite/affine-block-surface';
|
|
import { type BlockSnapshot } from '@blocksuite/store';
|
|
|
|
export class EdgelessClipboardAttachmentConfig extends EdgelessClipboardConfig {
|
|
static override readonly key = 'affine:attachment';
|
|
|
|
override async createBlock(
|
|
attachment: BlockSnapshot
|
|
): Promise<string | null> {
|
|
if (!this.surface) return null;
|
|
|
|
const { xywh, rotate, sourceId, name, size, type, embed, style } =
|
|
attachment.props;
|
|
|
|
if (!(await this.std.workspace.blobSync.get(sourceId as string))) {
|
|
return null;
|
|
}
|
|
const attachmentId = this.crud.addBlock(
|
|
'affine:attachment',
|
|
{
|
|
xywh,
|
|
rotate,
|
|
sourceId,
|
|
name,
|
|
size,
|
|
type,
|
|
embed,
|
|
style,
|
|
},
|
|
this.surface.model.id
|
|
);
|
|
return attachmentId;
|
|
}
|
|
}
|