vue2-tinymce-editor
Version:
A TinyMCE WYSIWYG editor component for your Vue products
1 lines • 4.62 kB
JavaScript
var Vue2TinymceEditor=function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=n(e);function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],i=!0,o=!1,r=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){o=!0,r=t}finally{try{i||null==s.return||s.return()}finally{if(o)throw r}}return n}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function a(t,e,n,i,o,r,a,s,u,l){"boolean"!=typeof a&&(u=s,s=a,a=!1);const c="function"==typeof n?n.options:n;let d;if(t&&t.render&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,o&&(c.functional=!0)),i&&(c._scopeId=i),r?(d=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,u(t)),t&&t._registeredComponents&&t._registeredComponents.add(r)},c._ssrRegister=d):e&&(d=a?function(t){e.call(this,l(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),d)if(c.functional){const t=c.render;c.render=function(e,n){return d.call(n),t(e,n)}}else{const t=c.beforeCreate;c.beforeCreate=t?[].concat(t,d):[d]}return n}var s=a({render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{attrs:{id:t.id}},[n("textarea",{directives:[{name:"model",rawName:"v-model",value:t.content,expression:"content"}],style:{height:t.height+"px",width:t.width<=0?"auto":t.width+"px"},attrs:{id:t.inputId},domProps:{value:t.content},on:{input:function(e){e.target.composing||(t.content=e.target.value)}}})])},staticRenderFns:[]},void 0,{name:"Vue2TinymceEditor",props:{id:{default:"vue2-tinymce-editor-"+(new Date).getTime(),type:String},value:{default:""},options:{default:function(){return{}},type:Object},height:{default:300,type:Number},width:{default:0,type:Number}},data:function(){return{inputId:"editor-"+(new Date).getTime(),content:"",editor:null,checkerTimeout:null,isTyping:!1,plugins:"advlist autolink charmap code codesample directionality emoticons fullscreen help hr image imagetools insertdatetime link lists media nonbreaking pagebreak paste preview print save searchreplace table template textpattern toc visualblocks visualchars wordcount",toolbar:"fontselect fontsizeselect formatselect | bold italic underline strikethrough forecolor backcolor | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | link table removeformat code"}},mounted:function(){this.content=this.value,this.init()},beforeDestroy:function(){this.editor.destroy()},watch:{value:function(t){this.isTyping||(null!==this.editor?this.editor.setContent(t):this.content=t)}},methods:{init:function(){var t={selector:"#"+this.inputId,skin:!1,toolbar:this.toolbar,plugins:this.plugins,init_instance_callback:this.initEditor};for(var e in this.options)"selector"!==e&&"init_instance_callback"!==e&&(t[e]=this.options[e]);i.default.init(t)},initEditor:function(t){var e=this;this.editor=t,t.on("KeyUp",(function(){e.submitContent()})),t.on("Change",(function(t){e.editor.getContent()!==e.value&&e.submitContent(),e.$emit("editorChange",t)})),t.on("init",(function(){t.setContent(e.content),e.$emit("input",e.content)})),this.$emit("editorInit",t)},submitContent:function(){var t=this;this.isTyping=!0,null!==this.checkerTimeout&&clearTimeout(this.checkerTimeout),this.checkerTimeout=setTimeout((function(){t.isTyping=!1}),700),this.$emit("input",this.editor.getContent())}}},"data-v-59c7718a",!1,void 0,!1,void 0,void 0,void 0),u=Object.freeze({__proto__:null,Vue2TinymceEditor:s}),l=function(t){l.installed||(l.installed=!0,Object.entries(u).forEach((function(e){var n=o(e,2),i=n[0],r=n[1];t.component(i,r)})))},c={install:l},d=null;return"undefined"!=typeof window?d=window.Vue:"undefined"!=typeof global&&(d=global.Vue),d&&d.use(c),t.Vue2TinymceEditor=s,t.default=c,Object.defineProperty(t,"__esModule",{value:!0}),t}({},tinymce);