mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-25 21:35:53 +08:00
Merge branch 'master' into feature/suggestions
This commit is contained in:
commit
7f7bc60295
@ -171,10 +171,11 @@ export default {
|
|||||||
this.html = getHTML()
|
this.html = getHTML()
|
||||||
},
|
},
|
||||||
clearContent() {
|
clearContent() {
|
||||||
this.$refs.editor.clearContent()
|
this.$refs.editor.clearContent(true)
|
||||||
this.$refs.editor.focus()
|
this.$refs.editor.focus()
|
||||||
},
|
},
|
||||||
setContent() {
|
setContent() {
|
||||||
|
// you can pass a json document
|
||||||
this.$refs.editor.setContent({
|
this.$refs.editor.setContent({
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
content: [{
|
content: [{
|
||||||
@ -186,7 +187,11 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
})
|
}, true)
|
||||||
|
|
||||||
|
// HTML string is also supported
|
||||||
|
// this.$refs.editor.setContent('<p>This is some inserted text. 👋</p>')
|
||||||
|
|
||||||
this.$refs.editor.focus()
|
this.$refs.editor.focus()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tiptap-extensions",
|
"name": "tiptap-extensions",
|
||||||
"version": "0.14.1",
|
"version": "0.15.0",
|
||||||
"description": "Extensions for tiptap",
|
"description": "Extensions for tiptap",
|
||||||
"homepage": "https://tiptap.scrumpy.io",
|
"homepage": "https://tiptap.scrumpy.io",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -25,7 +25,7 @@
|
|||||||
"prosemirror-history": "^1.0.2",
|
"prosemirror-history": "^1.0.2",
|
||||||
"prosemirror-state": "^1.2.2",
|
"prosemirror-state": "^1.2.2",
|
||||||
"prosemirror-view": "^1.5.1",
|
"prosemirror-view": "^1.5.1",
|
||||||
"tiptap": "^0.12.1",
|
"tiptap": "^0.13.0",
|
||||||
"tiptap-commands": "^0.3.0"
|
"tiptap-commands": "^0.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tiptap",
|
"name": "tiptap",
|
||||||
"version": "0.12.1",
|
"version": "0.13.0",
|
||||||
"description": "A rich-text editor for Vue.js",
|
"description": "A rich-text editor for Vue.js",
|
||||||
"homepage": "https://tiptap.scrumpy.io",
|
"homepage": "https://tiptap.scrumpy.io",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -255,10 +255,25 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDocFromContent(content) {
|
||||||
|
if (typeof content === 'object') {
|
||||||
|
return this.schema.nodeFromJSON(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof content === 'string') {
|
||||||
|
const element = document.createElement('div')
|
||||||
|
element.innerHTML = content.trim()
|
||||||
|
|
||||||
|
return DOMParser.fromSchema(this.schema).parse(element)
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
|
||||||
setContent(content = {}, emitUpdate = false) {
|
setContent(content = {}, emitUpdate = false) {
|
||||||
this.state = EditorState.create({
|
this.state = EditorState.create({
|
||||||
schema: this.state.schema,
|
schema: this.state.schema,
|
||||||
doc: this.schema.nodeFromJSON(content),
|
doc: this.getDocFromContent(content),
|
||||||
plugins: this.state.plugins,
|
plugins: this.state.plugins,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user