improve updating props for nodeviews
This commit is contained in:
@@ -32,24 +32,22 @@ export default class Iframe extends Node {
|
|||||||
get view() {
|
get view() {
|
||||||
return {
|
return {
|
||||||
props: ['node', 'updateAttrs', 'editable'],
|
props: ['node', 'updateAttrs', 'editable'],
|
||||||
data() {
|
computed: {
|
||||||
return {
|
src: {
|
||||||
url: this.node.attrs.src,
|
get() {
|
||||||
}
|
return this.node.attrs.src
|
||||||
},
|
},
|
||||||
methods: {
|
set(src) {
|
||||||
onChange(event) {
|
|
||||||
this.url = event.target.value
|
|
||||||
|
|
||||||
this.updateAttrs({
|
this.updateAttrs({
|
||||||
src: this.url,
|
src,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
template: `
|
template: `
|
||||||
<div class="iframe">
|
<div class="iframe">
|
||||||
<iframe class="iframe__embed" :src="url"></iframe>
|
<iframe class="iframe__embed" :src="src"></iframe>
|
||||||
<input class="iframe__input" type="text" :value="url" @input="onChange" v-if="editable" />
|
<input class="iframe__input" type="text" v-model="src" v-if="editable" />
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,9 +88,14 @@ export default class ComponentView {
|
|||||||
this.node = node
|
this.node = node
|
||||||
this.decorations = decorations
|
this.decorations = decorations
|
||||||
|
|
||||||
// TODO: should be update props? maybe this is required for the collab plugin
|
// Update props in component
|
||||||
// this.vm._props.node = node
|
// TODO: Avoid mutating a prop directly.
|
||||||
// this.vm._props.decorations = decorations
|
// Maybe there is a better way to do this?
|
||||||
|
const originalSilent = Vue.config.silent
|
||||||
|
Vue.config.silent = true
|
||||||
|
this.vm._props.node = node
|
||||||
|
this.vm._props.decorations = decorations
|
||||||
|
Vue.config.silent = originalSilent
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user