Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Last active April 29, 2020 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onefriendaday/ce705d0fdbdf3ac7dc5ddd0c36029d3c to your computer and use it in GitHub Desktop.
Save onefriendaday/ce705d0fdbdf3ac7dc5ddd0c36029d3c to your computer and use it in GitHub Desktop.
Track changes with get-context
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `<div><input class="uk-width-1-1" v-model="model.example" /></div>`,
methods: {
initWith() {
return {
plugin: 'example_plugin',
example: 'Hello world!'
}
},
pluginCreated() {
setInterval(() => {
this.$emit('get-context')
}, 100)
}
},
watch: {
'storyItem': function(old, newVal) {
if (window.JSON.stringify(old) != window.JSON.stringify(newVal)) {
console.log('Story changed', old, newVal)
}
},
'model': {
handler: function (value) {
this.$emit('changed-model', value);
},
deep: true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment