From fcabeb919e53a27b566050930c47ffe3f4c8f30d Mon Sep 17 00:00:00 2001 From: QiShaoXuan Date: Wed, 17 Aug 2022 11:51:03 +0800 Subject: [PATCH] fix: fix not being able to paste a block with children in it --- .../editor-core/src/editor/clipboard/paste.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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; }) );