123 |
- Vue.component('Redactor',{template:'<textarea ref="redactor" :name="name" :placeholder="placeholder" :value="value" />',redactor:!1,props:{value:{default:'',type:String},placeholder:{type:String,default:null},name:{type:String,default:null},config:{default:{},type:Object}},watch:{value(newValue,oldValue){if(this.redactor.editor.isFocus()||this.redactor.editor.isSourceMode()){return}
- this.redactor.source.setCode(newValue)}},mounted(){this.init()},beforeDestroy(){this.destroy()},methods:{init(){var me=this;var callbacks={changed:function(html){me.handleInput(html);return html}};if(typeof this.config.callbacks==='undefined'){Vue.set(this.config,'callbacks',callbacks)}else{this.config.callbacks.changed=callbacks.changed}
- var app=Redactor(this.$refs.redactor,this.config);this.redactor=app;this.$parent.redactor=app},destroy(){Redactor(this.$refs.redactor,'destroy');this.redactor=null;this.$parent.redactor=null},handleInput(val){this.$emit('input',val)}}})
|