mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-12 08:49:04 +08:00
unwrap content div
This commit is contained in:
parent
1d7288d08d
commit
a0aef41dab
@ -5,8 +5,16 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render(createElement) {
|
methods: {
|
||||||
return createElement('div')
|
unwrap(element) {
|
||||||
|
const parent = element.parentNode
|
||||||
|
|
||||||
|
while (element.firstChild) {
|
||||||
|
parent.insertBefore(element.firstChild, element)
|
||||||
|
}
|
||||||
|
|
||||||
|
parent.removeChild(element)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'editor.element': {
|
'editor.element': {
|
||||||
@ -15,9 +23,13 @@ export default {
|
|||||||
if (element) {
|
if (element) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$el.append(element)
|
this.$el.append(element)
|
||||||
|
this.unwrap(element)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
render(createElement) {
|
||||||
|
return createElement('div')
|
||||||
|
},
|
||||||
}
|
}
|
@ -137,9 +137,7 @@ export default class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createView() {
|
createView() {
|
||||||
this.element.style.whiteSpace = 'pre-wrap'
|
const view = new EditorView(this.element, {
|
||||||
|
|
||||||
return new EditorView(this.element, {
|
|
||||||
state: this.state,
|
state: this.state,
|
||||||
dispatchTransaction: this.dispatchTransaction.bind(this),
|
dispatchTransaction: this.dispatchTransaction.bind(this),
|
||||||
nodeViews: initNodeViews({
|
nodeViews: initNodeViews({
|
||||||
@ -147,6 +145,10 @@ export default class Editor {
|
|||||||
editable: this.options.editable,
|
editable: this.options.editable,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
view.dom.style.whiteSpace = 'pre-wrap'
|
||||||
|
|
||||||
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchTransaction(transaction) {
|
dispatchTransaction(transaction) {
|
||||||
|
Loading…
Reference in New Issue
Block a user