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