Last active
April 29, 2020 12:33
-
-
Save onefriendaday/ce705d0fdbdf3ac7dc5ddd0c36029d3c to your computer and use it in GitHub Desktop.
Track changes with get-context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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