question-mark

Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue Description

I want to destroy the editor instance manually and then set it again when the component is updated. I am using ReactJs but I am not using the react wrapper. Whenever I try to call the destroy function I got the error that destroy is not a function.

const MyEditor = () => {
  const [editor, setEditor] = useState([]);
  useEffect(() => {
    if (editor.length != 0) { 
      editor.destroy();
    }
    setEditor(
      new EditorJS({
        holder: "editor",
        placeholder: "Insert your text here!",
        tools: {
          header: Header,
          list: List,
          quote: Quote,
          checklist: Checklist,
          code: Code,
          table: Table,
          image: {
            class: ImageTool,
            config: {
              endpoints: {
                byFile: "myFile",
                byUrl: "myUrl"
              }
            }
          }
        },
        data: {
          blocks: myBlocks
        }
      })
    );
  }, [myData]);

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
mohanagycommented, Jan 3, 2020

you can use it inside isReady editor.isReady .then(() => { // editor.destroy(); /** Do anything you need after editor initialization */ });

1reaction
evanjmgcommented, Apr 22, 2021

getting this now with read only mode

Read more comments on GitHub >

github_iconTop Results From Across the Web

Destroyer - Editor.js
You can destroy Editor.js instance by calling a destroy method. /** * Create an instance */ const editor = new EditorJS(); /** *...
Read more >
destroy() - DataTables Editor
Editor instances are no different and this method provides that ability. It will clean up any events added by Editor, fields and DOM...
Read more >
destroy - API Reference - Kendo UI Editor - Documentation
destroy. Prepares the widget for safe removal from DOM. Detaches all event handlers and removes jQuery.data attributes to avoid memory leaks.
Read more >
editor destroy - Gijgo.com
<button class="gj-button-md" onclick="editor.destroy()">Destroy</button><br/> <textarea id="editor"></textarea> <script> var editor = $('#editor').editor(); ...
Read more >
Destroy / Init Editor - Froala
The buttons here will destroy and init the rich text editor again. ... preventDefault(); if (editor) { editor.destroy() } }); // Initialize action....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found