improve updating props for nodeviews

This commit is contained in:
Philipp Kühn
2018-11-14 12:09:07 +01:00
parent 39a8ab6d5b
commit 632c176164
2 changed files with 20 additions and 17 deletions

View File

@@ -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.updateAttrs({
this.url = event.target.value src,
})
this.updateAttrs({ },
src: this.url,
})
}, },
}, },
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>
`, `,
} }

View File

@@ -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
} }