codex-team / codex-team/editor.js
How to get instance of editor?
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
# How to get a previously created editor instance?
For logistical reasons I cannot keep a store of editor instances. Is there a way to get a previously created editor instance on an element?
I.e.
```
EditorJS.getEditor(element);
```
My current solution:
```
import EditorJS from '@editorjs/editorjs';
export default {
instances: [],
create(element){
const editor = new EditorJS({
/**
* element
* @type {HtmlElement}
*/
holderId: element,
/**
* Available tools/blocks in the editor
* @type {Array}
*/
tools: [
],
});
this.instances.push({
element,
editor
});
},
destroy(element){
var instance = this.instances.find(instance => instance.element === element);
if (instance == null){
return false;
}
instance.editor.destroy();
return true;
},
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.