improve ignoreMutation

This commit is contained in:
Philipp Kühn 2020-11-23 18:31:35 +01:00
parent b4f3f8279e
commit 3128c5eb9d

View File

@ -40,8 +40,8 @@ class VueNodeView implements NodeView {
const { id } = this const { id } = this
const Inner = Vue.extend({ const Inner = Vue.extend({
functional: true, // functional: true,
// inheritAttrs: false, inheritAttrs: false,
props: { props: {
as: { as: {
type: String, type: String,
@ -50,8 +50,8 @@ class VueNodeView implements NodeView {
}, },
render(createElement, context) { render(createElement, context) {
return createElement( return createElement(
context.props.as, { // context.props.as, {
// this.as, { this.as, {
style: { style: {
whiteSpace: 'pre-wrap', whiteSpace: 'pre-wrap',
}, },
@ -114,19 +114,18 @@ class VueNodeView implements NodeView {
} }
ignoreMutation(mutation: MutationRecord | { type: 'selection'; target: Element }) { ignoreMutation(mutation: MutationRecord | { type: 'selection'; target: Element }) {
// return false if (mutation.type === 'selection') {
// if (mutation.type === 'selection') { return true
// console.log({ mutation }) }
// return true
// }
// return true
// console.log({ mutation })
if (!this.contentDOM) { if (!this.contentDOM) {
return true return true
} }
return !this.contentDOM.contains(mutation.target) const contentDOMHasChanged = !this.contentDOM.contains(mutation.target)
|| this.contentDOM === mutation.target
return contentDOMHasChanged
} }
update(node: ProseMirrorNode, decorations: Decoration[]) { update(node: ProseMirrorNode, decorations: Decoration[]) {