add basic implementation for node views

This commit is contained in:
Philipp Kühn
2020-10-30 11:08:23 +01:00
parent d43b0d96d6
commit f9089932ff
9 changed files with 47 additions and 163 deletions

View File

@@ -75,8 +75,6 @@ declare module './Editor' {
@magicMethods
export class Editor extends EventEmitter {
public renderer!: any
private proxy!: Editor
private commandManager!: CommandManager
@@ -256,7 +254,6 @@ export class Editor extends EventEmitter {
* Creates a ProseMirror view.
*/
private createView() {
console.log('CREATE VIEW')
this.view = new EditorView(this.options.element, {
state: EditorState.create({
doc: this.createDocument(this.options.content),
@@ -266,10 +263,16 @@ export class Editor extends EventEmitter {
],
}),
dispatchTransaction: this.dispatchTransaction.bind(this),
})
// `editor.view` is not yet available at this time.
// Therefore we will add all node views directly afterwards.
this.view.setProps({
nodeViews: this.extensionManager.nodeViews,
})
// store editor in dom element for better testing
// Lets store the editor instance in the DOM element.
// So well have access to it for tests.
const dom = this.view.dom as HTMLElement
dom.editor = this.proxy
}