diff --git a/dist/vue-easy-tinymce.min.js b/dist/vue-easy-tinymce.min.js index d62b293..99d71a4 100644 --- a/dist/vue-easy-tinymce.min.js +++ b/dist/vue-easy-tinymce.min.js @@ -1,7 +1,7 @@ /*! - * vue-easy-tinymce v1.0.1 + * vue-easy-tinymce v1.0.2 * Copyright (c) 2018-present Mehdi Esmaeili (@m3esma) * Released under the MIT License. * Project: https://github.com/m3esma/vue-easy-tinymce */ -var VueEasyTinyMCE={props:{id:{type:String,default:"editor"},value:{default:""},toolbar1:{default:""},toolbar2:{default:""},plugins:{default:function(){return[]},type:Array},other:{default:function(){return{}},type:Object}},data:function(){return{objTinymce:null}},template:'',computed:{computedId:function(){return"editor"===this.id||""===this.id||null===this.id?"editor-"+this.guidGenerator():this.id}},mounted:function(){var t=this,e={target:this.$el,toolbar1:this.toolbar1,toolbar2:this.toolbar2,plugins:this.plugins,init_instance_callback:function(e){e.on("Change KeyUp Undo Redo",function(n){t.value=e.getContent()}),t.objTinymce=e}},n=Object.assign({},e,this.other);tinymce.init(n)},methods:{guidGenerator:function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}},watch:{value:function(t,e){var n=this;n.value!==this.objTinymce.getContent()?this.objTinymce.setContent(n.value):n.$emit("input",t)}}};"undefined"!=typeof module&&module.exports&&(module.exports=VueEasyTinyMCE); \ No newline at end of file +var VueEasyTinyMCE={props:{id:{type:String,default:"editor"},value:{default:""},toolbar1:{default:""},toolbar2:{default:""},plugins:{default:function(){return[]},type:Array},other:{default:function(){return{}},type:Object}},data:function(){return{objTinymce:null}},template:'',computed:{computedId:function(){return"editor"===this.id||""===this.id||null===this.id?"editor-"+this.guidGenerator():this.id}},mounted:function(){var t=this,e={target:this.$el,toolbar1:this.toolbar1,toolbar2:this.toolbar2,plugins:this.plugins,init_instance_callback:function(e){e.on("Change KeyUp Undo Redo",function(n){t.updateValue(e.getContent())}),t.objTinymce=e}},n=Object.assign({},e,this.other);tinymce.init(n)},methods:{guidGenerator:function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},updateValue:function(t){this.$emit("input",t)}},watch:{value:function(t,e){this.value!==this.objTinymce.getContent()&&this.objTinymce.setContent(this.value)}}};"undefined"!=typeof module&&module.exports&&(module.exports=VueEasyTinyMCE); \ No newline at end of file diff --git a/package.json b/package.json index 2e47ec3..901a969 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-easy-tinymce", - "version": "1.0.1", + "version": "1.0.2", "description": "A simple and powerful package for easy usage of tinymce in Vue.js project.", "main": "dist/vue-easy-tinymce.min.js", "scripts": { diff --git a/src/vue-easy-tinymce.js b/src/vue-easy-tinymce.js index f36e64a..3d2fa6c 100644 --- a/src/vue-easy-tinymce.js +++ b/src/vue-easy-tinymce.js @@ -1,5 +1,5 @@ /*! - * vue-easy-tinymce v1.0.1 + * vue-easy-tinymce v1.0.2 * Copyright (c) 2018-present Mehdi Esmaeili (@m3esma) * Released under the MIT License. * Project: https://github.com/m3esma/vue-easy-tinymce @@ -34,7 +34,6 @@ var VueEasyTinyMCE = { //template: '
', //inside a div template: '', - computed: { //for multi instance support computedId: function () { @@ -57,8 +56,7 @@ var VueEasyTinyMCE = { plugins: this.plugins, init_instance_callback: function (editor) { editor.on('Change KeyUp Undo Redo', function (e) { - //component.updateValue(editor.getContent()); - component.value = editor.getContent(); + component.updateValue(editor.getContent()); }); //editor.setContent(component.value); //use instead :value="value" //alert("init"); @@ -77,19 +75,20 @@ var VueEasyTinyMCE = { .toString(16) .substring(1); } + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); + }, + updateValue: function (value) { + this.$emit('input', value); } }, watch: { - value: function(newValue, oldValue) { - var component = this; + value: function (newValue, oldValue) { // if v-model content change programmability - if(component.value !== this.objTinymce.getContent()) - this.objTinymce.setContent(component.value); - else - component.$emit('input', newValue); + if (this.value !== this.objTinymce.getContent()) + this.objTinymce.setContent(this.value); } }