Skip to content

Commit 9e8841c

Browse files
Exported Editor class instance (#25)
2 parents c7db3d3 + d4f40c3 commit 9e8841c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/editor/DOMEventHandlers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,23 @@ export class DOMEventHandlers {
2828
container: HTMLDivElement,
2929
data: IEditorData | IElement[],
3030
options: IEditorOption = {}
31-
) {
31+
): Editor {
3232
// if (DOMEventHandlers.instance) {
3333
// console.log('tried to register again. Returning')
3434
// return
3535
// }
36+
if (DOMEventHandlers.instance) {
37+
try {
38+
DOMEventHandlers.instance.destroy();
39+
} catch (e) {
40+
console.warn("Cleaning up old editor instance");
41+
}
42+
}
3643
DOMEventHandlers.instance = new Editor(container, data, options)
3744
DOMEventHandlers.instance.command.executeSetLocale('en')
3845
DOMEventHandlers.instance.register.langMap('en', en)
46+
47+
return DOMEventHandlers.instance;
3948
}
4049

4150
static handleUndo() {

0 commit comments

Comments
 (0)