mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-05 04:19:07 +08:00
add setParent method to rerender node views
This commit is contained in:
parent
e1c5bd4eda
commit
fe8a21ce7c
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user