Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I got the change event when I replace the old data using the render method #132

Open
chf-gh opened this issue Aug 23, 2023 · 0 comments
Open

Comments

@chf-gh
Copy link

chf-gh commented Aug 23, 2023

here is my code to reset data, it will replace the old data:

const resetData = async (id:string) => { 
  try {
    await editor.isReady;
    console.log('Editor.js is ready to work!')
    const data = await getNoteById(id)
    if (data) { 
      if (data?.editorBlocks) {
        const editorData = {blocks: data?.editorBlocks ,version: data?.editorVersion,time: data?.editorTime} as OutputData;
        await editor.render( editorData)
      } else {
        //  removes all Blocks and creates new empty initial type Block
        editor.clear()
      } 
    }

  } catch (reason) {
    console.log(`Editor.js initialization failed because of ${reason}`)
  } 
}

if the editor contain the table block, it will trigger change event when I call the resetData method. It will save the wrong data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant