editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

renderFromHTML is not awaiting clear() method

Open mrigne opened this issue 2 years ago • 1 comments

renderFromHTML is not awaiting clear() method. So rendering is started during async clear execution that can cause incorrect results.

Steps to reproduce: await this.api.renderFromHTML(<some_big_html>);

Expected behavior: Internal logic should await clear() method before star rendering blocks

Device, Browser, OS: any

Editor.js version: 2.28.2

mrigne avatar Dec 27 '23 15:12 mrigne

Hey @mrigne,

Does this fix the issue for you in the following situation ->

const editor = new EditorJS( . . . )
await editor.isReady
await editor.blocks.renderFromHTML( . . . )
const saved = await editor.save()
console.log(saved)

I've been testing this one locally and I believe the issue stems further than this function. The above renderFromHTML goes via the processText method to BlockManager's paste. Inside the BlockManager the window.requestIdleCallback method is ran which I found executes after my save is called

image

Thanks!

ThePlayerSD avatar Feb 01 '24 15:02 ThePlayerSD