fix: fix not being able to paste a block with children in it
This commit is contained in:
@@ -377,15 +377,16 @@ export class Paste {
|
|||||||
const pasteBlocks = await this._createBlocks(blocks);
|
const pasteBlocks = await this._createBlocks(blocks);
|
||||||
|
|
||||||
let groupBlock: AsyncBlock;
|
let groupBlock: AsyncBlock;
|
||||||
if (
|
if (selectedBlock?.type === 'page') {
|
||||||
selectedBlock?.type === 'group' ||
|
|
||||||
selectedBlock?.type === 'page'
|
|
||||||
) {
|
|
||||||
groupBlock = await this._editor.createBlock('group');
|
groupBlock = await this._editor.createBlock('group');
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pasteBlocks.map(block => groupBlock.append(block))
|
pasteBlocks.map(block => groupBlock.append(block))
|
||||||
);
|
);
|
||||||
await selectedBlock.after(groupBlock);
|
await selectedBlock.after(groupBlock);
|
||||||
|
} else if (selectedBlock?.type === 'group') {
|
||||||
|
await Promise.all(
|
||||||
|
pasteBlocks.map(block => selectedBlock.append(block))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pasteBlocks.map(block => selectedBlock.after(block))
|
pasteBlocks.map(block => selectedBlock.after(block))
|
||||||
@@ -413,7 +414,11 @@ export class Paste {
|
|||||||
clipBlockInfo.type
|
clipBlockInfo.type
|
||||||
);
|
);
|
||||||
block?.setProperties(clipBlockInfo.properties);
|
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;
|
return block;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user