Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

919 B
Raw Blame
import { EdgelessClipboardConfig } from '@blocksuite/affine-block-surface';
import { type BlockSnapshot } from '@blocksuite/store';

export class EdgelessClipboardEdgelessTextConfig extends EdgelessClipboardConfig {
  static override readonly key = 'affine:edgeless-text';

  override async createBlock(
    edgelessText: BlockSnapshot
  ): Promise<string | null> {
    const oldId = edgelessText.id;
    delete edgelessText.props.index;
    if (!edgelessText.props.xywh) {
      console.error(
        `EdgelessText block(id: ${oldId}) does not have xywh property`
      );
      return null;
    }
    if (!this.surface) {
      return null;
    }
    const newId = await this.onBlockSnapshotPaste(
      edgelessText,
      this.std.store,
      this.surface.model.id
    );
    if (!newId) {
      console.error(`Failed to paste EdgelessText block(id: ${oldId})`);
      return null;
    }

    return newId;
  }
}