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

How does one get the already instantiated instance of the Editor JS by its id value when there are two or more instances of editorjs running in the same browser?

Open kibblewhite opened this issue 2 years ago • 2 comments

How does one get the already instantiated instance of the Editor JS by its id value when there are two or more instances of editorjs running in the same browser?

Currently const editor = new EditorJS({ holder: "my-id"}); - I no longer have access to the const editor property, so I would like to use the id "my-id" to get hold of the instance. I'm struggling to find documentation to confirm or reject if this is possible. I do hope it's possible to do this?

Many thanks.

kibblewhite avatar Apr 27 '22 15:04 kibblewhite

If you're using React (Gatsby, NextJS, etc.), you could use a singleton pattern to retain the editor (what we do.)

Example: https://www.npmjs.com/package/react-singleton-hook

AlbinoGeek avatar Apr 30 '22 20:04 AlbinoGeek

Hello, I'm just using straight up editorjs with no react or Nextjs etc and would like to know how to get the editor's instance in other functions.

rookiemann avatar Jun 13 '22 14:06 rookiemann

I am experiencing the same issue !! I used to be able to access the instance the editor using window.editor, before introducing holder to the editor so we can have multiple instances, now it's broken, querySelecting the element id return just the raw html, no editor instance, how can I access the editor instance now ?

CODE-BR3AKER avatar May 04 '23 16:05 CODE-BR3AKER