|
@@ -28,40 +28,16 @@ export default {
|
|
|
editor:{
|
|
|
|
|
|
},
|
|
|
- content:{
|
|
|
- "type": "doc",
|
|
|
- "content": [
|
|
|
- {
|
|
|
- "type": "paragraph",
|
|
|
- "content": [
|
|
|
- {
|
|
|
- "type": "text",
|
|
|
- "text": "fdfcvds"
|
|
|
- },
|
|
|
- {
|
|
|
- "type": "text",
|
|
|
- "marks": [
|
|
|
- {
|
|
|
- "type": "strong"
|
|
|
- }
|
|
|
- ],
|
|
|
- "text": "fdsc"
|
|
|
- },
|
|
|
- {
|
|
|
- "type": "text",
|
|
|
- "text": "dcvd"
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
+ content:this.value||null
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
value(newVal) {
|
|
|
- this.content = newVal
|
|
|
- if (this.editor.view) {
|
|
|
- const newState = this.editor.view.state.apply(this.editor.view.state.tr.setDoc(schema.nodeFromJSON(newVal)));
|
|
|
+ this.content = newVal
|
|
|
+ if (this.editor.view) {
|
|
|
+
|
|
|
+ this.editor.view.state.tr.doc = schema.nodeFromJSON(newVal)
|
|
|
+ const newState = this.editor.view.state.apply(this.editor.view.state.tr);
|
|
|
this.editor.view.updateState(newState);
|
|
|
}
|
|
|
},
|
|
@@ -91,9 +67,11 @@ export default {
|
|
|
}),
|
|
|
parent: this.$refs.editor,
|
|
|
dispatchTransaction(transaction) {
|
|
|
+ console.log(transaction)
|
|
|
let newState = that.editor.view.state.apply(transaction)
|
|
|
console.log(newState.doc.toJSON())
|
|
|
that.editor.view.updateState(newState)
|
|
|
+ that.$emit('input',newState.doc.toJSON())
|
|
|
}
|
|
|
})
|
|
|
// 设置监听器以更新Vue数据
|