Last active
December 21, 2017 20:18
-
-
Save onefriendaday/80dd30c1719ca948d7183bf8dd889978 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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