Skip to content

Instantly share code, notes, and snippets.

@onefriendaday

onefriendaday/Plugin.js

Last active Apr 29, 2020
Embed
What would you like to do?
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