Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/modules/api/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ export default class BlocksAPI extends Module {
* @param {string} data - HTML string to render
* @returns {Promise<void>}
*/
public renderFromHTML(data: string): Promise<void> {
this.Editor.BlockManager.clear();
public async renderFromHTML(data: string): Promise<void> {
await this.Editor.BlockManager.clear();

return this.Editor.Paste.processText(data, true);
}
Expand Down
7 changes: 5 additions & 2 deletions src/components/modules/blockManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ export default class BlockManager extends Module {
throw new Error('Can\'t find a Block to remove');
}

block.destroy();
this._blocks.remove(index);
block.destroy();

/**
* Force call of didMutated event on Block removal
Expand Down Expand Up @@ -894,7 +894,10 @@ export default class BlockManager extends Module {
public async clear(needToAddDefaultBlock = false): Promise<void> {
const queue = new PromiseQueue();

this.blocks.forEach((block) => {
// Create a copy of the blocks array to avoid issues with array modification during iteration
const blocksToRemove = [...this.blocks];

blocksToRemove.forEach((block) => {
queue.add(async () => {
await this.removeBlock(block, false);
});
Expand Down
Loading