store editor in dom element

This commit is contained in:
Philipp Kühn
2020-09-11 18:06:13 +02:00
parent e0993a135a
commit 808b806db8
18 changed files with 45 additions and 58 deletions

View File

@@ -28,6 +28,16 @@ export interface CommandSpec {
type EditorContent = string | JSON | null
// interface Element {
// editor?: Editor
// }
interface HTMLElement {
editor?: Editor
}
// Element.prototype.editor = Editor
interface EditorOptions {
element: Element,
content: EditorContent,
@@ -241,6 +251,10 @@ export class Editor extends EventEmitter {
dispatchTransaction: this.dispatchTransaction.bind(this),
nodeViews: this.extensionManager.nodeViews,
})
// store editor in dom element for better testing
const dom = this.view.dom as HTMLElement
dom.editor = this.proxy
}
/**