@wangeditor/editor-for-vue
Version:
wangEditor component for vue2.x
17 lines (14 loc) • 3.77 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue"),require("@wangeditor/editor")):"function"==typeof define&&define.amd?define(["exports","vue","@wangeditor/editor"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).WangEditorForVue={},e.Vue,e.editor)}(this,(function(e,t,o){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t),i=function(){return i=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function u(e){var t="请使用 '@".concat(e,"' 事件,不要放在 props 中");return t+="\nPlease use '@".concat(e,"' event instead of props")}var a=n.default.extend({render:function(e){return e("div",{ref:"box"})},name:"Editor",data:function(){return{curValue:"",editor:null}},props:["defaultContent","defaultConfig","mode","defaultHtml","value"],mounted:function(){this.create()},watch:{value:function(e){e===this.curValue||this.setHtml(e)}},methods:{setHtml:function(e){var t=this.editor;null!=t&&t.setHtml(e)},create:function(){var e=this;if(null!=this.$refs.box){var t=this.defaultConfig||{},r=JSON.stringify(Array.isArray(this.defaultContent)?this.defaultContent:[]);o.createEditor({selector:this.$refs.box,html:this.defaultHtml||this.value||"",config:i(i({},t),{onCreated:function(o){if(e.editor=Object.seal(o),e.$emit("onCreated",o),t.onCreated){var r=u("onCreated");throw new Error(r)}},onChange:function(o){var r=o.getHtml();if(e.curValue=r,e.$emit("input",r),e.$emit("onChange",o),t.onChange){var n=u("onChange");throw new Error(n)}},onDestroyed:function(o){if(e.$emit("onDestroyed",o),t.onDestroyed){var r=u("onDestroyed");throw new Error(r)}},onMaxLength:function(o){if(e.$emit("onMaxLength",o),t.onMaxLength){var r=u("onMaxLength");throw new Error(r)}},onFocus:function(o){if(e.$emit("onFocus",o),t.onFocus){var r=u("onFocus");throw new Error(r)}},onBlur:function(o){if(e.$emit("onBlur",o),t.onBlur){var r=u("onBlur");throw new Error(r)}},customAlert:function(o,r){if(e.$emit("customAlert",o,r),t.customAlert){var n=u("customAlert");throw new Error(n)}},customPaste:function(o,r){if(t.customPaste){var n=u("customPaste");throw new Error(n)}var i;return e.$emit("customPaste",o,r,(function(e){i=e})),i}}),content:JSON.parse(r),mode:this.mode||"default"})}}}}),f=n.default.extend({name:"Toolbar",render:function(e){return e("div",{ref:"box"})},props:["editor","defaultConfig","mode"],methods:{create:function(e){null!=this.$refs.box&&null!=e&&(o.DomEditor.getToolbar(e)||o.createToolbar({editor:e,selector:this.$refs.box,config:this.defaultConfig||{},mode:this.mode||"default"}))}},watch:{editor:{handler:function(e){null!=e&&this.create(e)},immediate:!0}}});e.Editor=a,e.Toolbar=f,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map