Skip to content

Instantly share code, notes, and snippets.

@DominikAngerer
Created January 17, 2018 01:53
Show Gist options
  • Save DominikAngerer/25a5b4f837f0f60df410a74087670f61 to your computer and use it in GitHub Desktop.
Save DominikAngerer/25a5b4f837f0f60df410a74087670f61 to your computer and use it in GitHub Desktop.
TinyMCE community edition
module.exports = {
watch: {
'model': {
handler: function (value) {
this.$emit('changed-model', value)
},
deep: true
}
},
created: function() {
jQuery.getScript('https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.4/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