mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(editor): cut and paste surface-ref to same doc should remain surface-ref (#11639)
Close [BS-3107](https://linear.app/affine-design/issue/BS-3107/剪切-surface-ref-block-会变成指向当前文档的link-card)
This commit is contained in:
@@ -11,12 +11,16 @@ export const surfaceRefToEmbed =
|
||||
}
|
||||
});
|
||||
slots.beforeImport.subscribe(payload => {
|
||||
// only handle surface-ref block snapshot
|
||||
if (
|
||||
pageId &&
|
||||
payload.type === 'block' &&
|
||||
payload.snapshot.flavour === 'affine:surface-ref' &&
|
||||
!std.store.hasBlock(payload.snapshot.id)
|
||||
) {
|
||||
payload.type !== 'block' ||
|
||||
payload.snapshot.flavour !== 'affine:surface-ref'
|
||||
)
|
||||
return;
|
||||
|
||||
// turn into embed-linked-doc if the current doc is different from the pageId of the surface-ref block
|
||||
const isNotSameDoc = pageId !== std.store.doc.id;
|
||||
if (pageId && isNotSameDoc) {
|
||||
// The blockId of the original surface-ref block
|
||||
const blockId = payload.snapshot.id;
|
||||
payload.snapshot.id = std.workspace.idGenerator();
|
||||
|
||||
Reference in New Issue
Block a user