add setParent method to rerender node views

This commit is contained in:
Philipp Kühn 2018-11-11 22:44:16 +01:00
parent e1c5bd4eda
commit fe8a21ce7c
4 changed files with 1135 additions and 1038 deletions

View File

@ -86,5 +86,8 @@
"webpack-svgstore-plugin": "^4.1.0",
"zlib": "^1.0.5"
},
"dependencies": {}
"dependencies": {},
"resolutions": {
"prosemirror-view": "git+https://git@github.com/ProseMirror/prosemirror-view.git"
}
}

View File

@ -6,11 +6,14 @@ export default {
},
},
watch: {
'editor.element': {
editor: {
immediate: true,
handler(element) {
if (element) {
this.$nextTick(() => this.$el.append(element.firstChild))
handler(editor) {
if (editor.element) {
this.$nextTick(() => {
this.$el.append(editor.element.firstChild)
editor.setParent(this)
})
}
},
},

View File

@ -155,6 +155,23 @@ export default class Editor {
return view
}
setParent(component = null) {
if (!component) {
return
}
this.view.setProps({
nodeViews: initNodeViews({
parent: component,
extensions: [
...builtInNodes,
...this.options.extensions,
],
editable: this.options.editable,
}),
})
}
dispatchTransaction(transaction) {
this.state = this.state.apply(transaction)
this.view.updateState(this.state)

2140
yarn.lock

File diff suppressed because it is too large Load Diff