Skip to content

Commit

Permalink
fix(blocks): missing aliases when duplicating linked doc block on edg…
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Dec 11, 2024
1 parent 476c008 commit bf83553
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions packages/blocks/src/root-block/edgeless/clipboard/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
BookmarkStyles,
DEFAULT_NOTE_HEIGHT,
DEFAULT_NOTE_WIDTH,
ReferenceInfoSchema,
} from '@blocksuite/affine-model';
import {
EmbedOptionProvider,
Expand Down Expand Up @@ -426,10 +427,16 @@ export class EdgelessClipboardController extends PageClipboard {
this.registerBlock('affine:image', this._createImageBlock);
this.registerBlock('affine:frame', this._createFrameBlock);
this.registerBlock('affine:attachment', this._createAttachmentBlock);

// external links
this.registerBlock('affine:bookmark', this._createBookmarkBlock);
this.registerBlock('affine:embed-figma', this._createFigmaEmbedBlock);
this.registerBlock('affine:embed-github', this._createGithubEmbedBlock);
this.registerBlock('affine:embed-html', this._createHtmlEmbedBlock);
this.registerBlock('affine:embed-loom', this._createLoomEmbedBlock);
this.registerBlock('affine:embed-youtube', this._createYoutubeEmbedBlock);
this.registerBlock('affine:embed-figma', this._createFigmaEmbedBlock);

// internal links
this.registerBlock(
'affine:embed-linked-doc',
this._createLinkedDocEmbedBlock
Expand All @@ -438,8 +445,6 @@ export class EdgelessClipboardController extends PageClipboard {
'affine:embed-synced-doc',
this._createSyncedDocEmbedBlock
);
this.registerBlock('affine:embed-html', this._createHtmlEmbedBlock);
this.registerBlock('affine:embed-loom', this._createLoomEmbedBlock);
}

private _checkCanContinueToCanvas(
Expand Down Expand Up @@ -743,16 +748,23 @@ export class EdgelessClipboardController extends PageClipboard {
}

private _createLinkedDocEmbedBlock(linkedDocEmbed: BlockSnapshot) {
const { xywh, style, caption, pageId, params } = linkedDocEmbed.props;
const props: Record<string, unknown> = { xywh, style, caption, pageId };

if (params) {
props.params = { ...params };
}
const { xywh, style, caption, pageId, params, title, description } =
linkedDocEmbed.props;
const referenceInfo = ReferenceInfoSchema.parse({
pageId,
params,
title,
description,
});

return this.host.service.addBlock(
'affine:embed-linked-doc',
props,
{
xywh,
style,
caption,
...referenceInfo,
},
this.surface.model.id
);
}
Expand Down Expand Up @@ -801,7 +813,9 @@ export class EdgelessClipboardController extends PageClipboard {
}

private _createSyncedDocEmbedBlock(syncedDocEmbed: BlockSnapshot) {
const { xywh, style, caption, scale, pageId } = syncedDocEmbed.props;
const { xywh, style, caption, scale, pageId, params } =
syncedDocEmbed.props;
const referenceInfo = ReferenceInfoSchema.parse({ pageId, params });

return this.host.service.addBlock(
'affine:embed-synced-doc',
Expand All @@ -810,7 +824,7 @@ export class EdgelessClipboardController extends PageClipboard {
style,
caption,
scale,
pageId,
...referenceInfo,
},
this.surface.model.id
);
Expand Down

0 comments on commit bf83553

Please sign in to comment.