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.

fix: fix not being able to paste a block with children in it

QiShaoXuanfcabeb919e53
diff --git a/libs/components/editor-core/src/editor/clipboard/paste.ts b/libs/components/editor-core/src/editor/clipboard/paste.ts
index b24d06b23a..8b5ed40ee5 100644
--- a/libs/components/editor-core/src/editor/clipboard/paste.ts
+++ b/libs/components/editor-core/src/editor/clipboard/paste.ts
@@ -377,15 +377,16 @@ export class Paste {
const pasteBlocks = await this._createBlocks(blocks);
let groupBlock: AsyncBlock;
- if (
- selectedBlock?.type === 'group' ||
- selectedBlock?.type === 'page'
- ) {
+ if (selectedBlock?.type === 'page') {
groupBlock = await this._editor.createBlock('group');
await Promise.all(
pasteBlocks.map(block => groupBlock.append(block))
);
await selectedBlock.after(groupBlock);
+ } else if (selectedBlock?.type === 'group') {
+ await Promise.all(
+ pasteBlocks.map(block => selectedBlock.append(block))
+ );
} else {
await Promise.all(
pasteBlocks.map(block => selectedBlock.after(block))
@@ -413,7 +414,11 @@ export class Paste {
clipBlockInfo.type
);
block?.setProperties(clipBlockInfo.properties);
- await this._createBlocks(clipBlockInfo.children, block?.id);
+ const children = await this._createBlocks(
+ clipBlockInfo.children,
+ block?.id
+ );
+ await Promise.all(children.map(child => block?.append(child)));
return block;
})
);