Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Last active December 21, 2017 20:18
Show Gist options
  • Save onefriendaday/80dd30c1719ca948d7183bf8dd889978 to your computer and use it in GitHub Desktop.
Save onefriendaday/80dd30c1719ca948d7183bf8dd889978 to your computer and use it in GitHub Desktop.
module.exports = {
watch: {
'model': {
handler: function (value) {
this.$emit('changed-model', value)
},
deep: true
}
},
created: function() {
jQuery.getScript('https://cloud.tinymce.com/stable/tinymce.min.js', this.initEditor.bind(this))
},
props: ['model'],
methods: {
initEditor: function() {
if (!this.model) {
this.model = ''
}
tinymce.init({
target: this.$el.querySelector('.textarea'),
init_instance_callback: function(editor) {
editor.on('input change undo redo setcontent', function() {
this.$emit('changed-model', editor.getContent())
}.bind(this))
}
})
}
},
template: "<div><textarea v-model=\"model\" rows=\"5\" class=\"textarea uk-width-1-1\"><\/textarea><\/div>"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment