@wangeditor-next/editor-for-vue2 6.4.3 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
1
1
  import { default as Vue } from 'vue';
2
- declare const _default: import('vue/types/vue').ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, any>>, {
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
4
+ declare const __VLS_export: import('vue/types/vue').ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue>, {
3
5
  curValue: string;
4
6
  editor: null;
5
7
  }, {
@@ -12,4 +14,3 @@ declare const _default: import('vue/types/vue').ExtendedVue<Vue<Record<string, a
12
14
  defaultHtml: string;
13
15
  value: string;
14
16
  }, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin>;
15
- export default _default;
@@ -1,10 +1,11 @@
1
1
  import { IDomEditor } from '@wangeditor-next/editor';
2
2
  import { default as Vue } from 'vue';
3
- declare const _default: import('vue/types/vue').ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, any>>, unknown, {
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
5
+ declare const __VLS_export: import('vue/types/vue').ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue>, unknown, {
4
6
  create(editor: IDomEditor): void;
5
7
  }, unknown, {
6
8
  editor: any;
7
9
  defaultConfig: any;
8
10
  mode: string;
9
11
  }, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin>;
10
- export default _default;
package/dist/index.esm.js CHANGED
@@ -53,7 +53,7 @@ const h = a.extend({
53
53
  // 重置 HTML
54
54
  setHtml(t) {
55
55
  const n = this.editor;
56
- n != null && n.setHtml(t);
56
+ n?.setHtml(t);
57
57
  },
58
58
  // 创建 editor
59
59
  create() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/components/Editor.vue","../src/components/Toolbar.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { createEditor, IDomEditor } from '@wangeditor-next/editor'\nimport Vue from 'vue'\n\ntype AlertType = 'success' | 'info' | 'warning' | 'error'\n\nfunction genErrorInfo(fnName: string) {\n let info = `请使用 '@${fnName}' 事件,不要放在 props 中`\n\n info += `\\nPlease use '@${fnName}' event instead of props`\n return info\n}\n\nexport default Vue.extend({\n //【注意】单独写 <template>...</template> 时,rollup 打包完浏览器运行时报错,所以先在这里写 template\n render(h) {\n return h('div', { ref: 'box' })\n },\n name: 'Editor',\n data() {\n return {\n curValue: '',\n editor: null,\n }\n },\n props: {\n defaultContent: {\n type: Array,\n default: () => [],\n },\n defaultConfig: {\n type: Object,\n default: () => ({}),\n },\n mode: {\n type: String,\n default: 'default',\n },\n defaultHtml: {\n type: String,\n default: '',\n },\n // value 用于自定义 v-model\n value: {\n type: String,\n default: '',\n },\n },\n mounted() {\n this.create()\n },\n watch: {\n // 监听 'value' 属性变化 - value 用于自定义 v-model\n value(newVal: string) {\n const isEqual = newVal === this.curValue\n\n if (isEqual) {\n return\n } // 和当前内容一样,则忽略\n\n // 重置 HTML\n this.setHtml(newVal)\n },\n },\n methods: {\n // 重置 HTML\n setHtml(newHtml: string) {\n const editor = this.editor as any\n\n if (editor == null) {\n return\n }\n editor.setHtml(newHtml)\n },\n\n // 创建 editor\n create() {\n if (this.$refs.box == null) {\n return\n }\n\n const defaultConfig = this.defaultConfig || {}\n\n const defaultContent = JSON.stringify(\n Array.isArray(this.defaultContent) ? this.defaultContent : []\n )\n\n createEditor({\n selector: this.$refs.box as Element,\n html: this.defaultHtml || this.value || '',\n config: {\n ...defaultConfig,\n onCreated: (editor: IDomEditor) => {\n this.editor = Object.seal(editor) as any // 注意,一定要用 Object.seal() 否则会报错\n\n this.$emit('onCreated', editor)\n if (defaultConfig.onCreated) {\n const info = genErrorInfo('onCreated')\n\n throw new Error(info)\n }\n },\n onChange: (editor: IDomEditor) => {\n const editorHtml = editor.getHtml()\n\n this.curValue = editorHtml // 记录当前 html 内容\n this.$emit('input', editorHtml) // 用于自定义 v-model\n\n this.$emit('onChange', editor)\n if (defaultConfig.onChange) {\n const info = genErrorInfo('onChange')\n\n throw new Error(info)\n }\n },\n onDestroyed: (editor: IDomEditor) => {\n this.$emit('onDestroyed', editor)\n if (defaultConfig.onDestroyed) {\n const info = genErrorInfo('onDestroyed')\n\n throw new Error(info)\n }\n },\n onMaxLength: (editor: IDomEditor) => {\n this.$emit('onMaxLength', editor)\n if (defaultConfig.onMaxLength) {\n const info = genErrorInfo('onMaxLength')\n\n throw new Error(info)\n }\n },\n onFocus: (editor: IDomEditor) => {\n this.$emit('onFocus', editor)\n if (defaultConfig.onFocus) {\n const info = genErrorInfo('onFocus')\n\n throw new Error(info)\n }\n },\n onBlur: (editor: IDomEditor) => {\n this.$emit('onBlur', editor)\n if (defaultConfig.onBlur) {\n const info = genErrorInfo('onBlur')\n\n throw new Error(info)\n }\n },\n customAlert: (info: string, type: AlertType) => {\n this.$emit('customAlert', info, type)\n if (defaultConfig.customAlert) {\n const errorInfo = genErrorInfo('customAlert')\n\n throw new Error(errorInfo)\n }\n },\n customPaste: (editor: IDomEditor, event: ClipboardEvent) => {\n if (defaultConfig.customPaste) {\n const info = genErrorInfo('customPaste')\n\n throw new Error(info)\n }\n let res\n\n this.$emit('customPaste', editor, event, (val: any) => {\n res = val\n })\n return res\n },\n },\n content: JSON.parse(defaultContent),\n mode: this.mode || 'default',\n })\n },\n },\n})\n</script>\n","<script lang=\"ts\">\nimport { createToolbar, DomEditor, IDomEditor } from '@wangeditor-next/editor'\nimport Vue from 'vue'\n\nexport default Vue.extend({\n name: 'Toolbar',\n render(h) {\n return h('div', { ref: 'box' })\n },\n props: {\n editor: {\n type: Object,\n default: undefined,\n },\n defaultConfig: {\n type: Object,\n default: () => ({}),\n },\n mode: {\n type: String,\n default: 'default',\n },\n },\n methods: {\n // 创建 toolbar\n create(editor: IDomEditor) {\n if (this.$refs.box == null) {\n return\n }\n if (editor == null) {\n return\n }\n if (DomEditor.getToolbar(editor)) {\n return\n } // 不重复创建\n\n createToolbar({\n editor,\n selector: this.$refs.box as Element,\n config: this.defaultConfig || {},\n mode: this.mode || 'default',\n })\n },\n },\n watch: {\n editor: {\n handler(e: IDomEditor | null) {\n if (e == null) {\n return\n }\n this.create(e)\n },\n immediate: true,\n },\n },\n})\n</script>\n"],"names":["genErrorInfo","fnName","info","_sfc_main$1","Vue","h","newVal","newHtml","editor","defaultConfig","defaultContent","createEditor","editorHtml","type","errorInfo","event","res","val","_sfc_main","DomEditor","createToolbar","e"],"mappings":";;AAMA,SAAAA,EAAAC,GAAA;AACA,MAAAC,IAAA,SAAAD,CAAA;AAEA,SAAAC,KAAA;AAAA,eAAAD,CAAA,4BACAC;AACA;AAEA,MAAAC,IAAAC,EAAA,OAAA;AAAA;AAAA,EAEA,OAAAC,GAAA;AACA,WAAAA,EAAA,OAAA,EAAA,KAAA,OAAA;AAAA,EACA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AACA,WAAA;AAAA,MACA,UAAA;AAAA,MACA,QAAA;AAAA,IAAA;AAAA,EAEA;AAAA,EACA,OAAA;AAAA,IACA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,MAAA,CAAA;AAAA,IAAA;AAAA,IAEA,eAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,OAAA,CAAA;AAAA,IAAA;AAAA,IAEA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IAAA;AAAA,IAEA,aAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IAAA;AAAA;AAAA,IAGA,OAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IAAA;AAAA,EACA;AAAA,EAEA,UAAA;AACA,SAAA,OAAA;AAAA,EACA;AAAA,EACA,O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AAA;AAAA,MACA,SAAA;AAAA,IAAA;AAAA,IAEA,eAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA,OAAA,CAAA;AAAA,IAAA;AAAA,IAEA,MAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IAAA;AAAA,EACA;AAAA,EAEA,SAAA;AAAA;AAAA,IAEA,OAAAG,GAAA;AACA,MAAA,KAAA,MAAA,OAAA,QAGAA,KAAA,SAGAW,EAAA,WAAAX,CAAA,KAIAY,EAAA;AAAA,QACA,QAAAZ;AAAA,QACA,UAAA,KAAA,MAAA;AAAA,QACA,QAAA,KAAA,iBAAA,CAAA;AAAA,QACA,MAAA,KAAA,QAAA;AAAA,MAAA,CACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEA,OAAA;AAAA,IACA,QAAA;AAAA,MACA,QAAAa,GAAA;AACA,QAAAA,KAAA,QAGA,KAAA,OAAAA,CAAA;AAAA,MACA;AAAA,MACA,WAAA;AAAA,IAAA;AAAA,EACA;AAEA,CAAA;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/components/Editor.vue","../src/components/Toolbar.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { createEditor, IDomEditor } from '@wangeditor-next/editor'\nimport Vue from 'vue'\n\ntype AlertType = 'success' | 'info' | 'warning' | 'error'\n\nfunction genErrorInfo(fnName: string) {\n let info = `请使用 '@${fnName}' 事件,不要放在 props 中`\n\n info += `\\nPlease use '@${fnName}' event instead of props`\n return info\n}\n\nexport default Vue.extend({\n //【注意】单独写 <template>...</template> 时,rollup 打包完浏览器运行时报错,所以先在这里写 template\n render(h) {\n return h('div', { ref: 'box' })\n },\n name: 'Editor',\n data() {\n return {\n curValue: '',\n editor: null,\n }\n },\n props: {\n defaultContent: {\n type: Array,\n default: () => [],\n },\n defaultConfig: {\n type: Object,\n default: () => ({}),\n },\n mode: {\n type: String,\n default: 'default',\n },\n defaultHtml: {\n type: String,\n default: '',\n },\n // value 用于自定义 v-model\n value: {\n type: String,\n default: '',\n },\n },\n mounted() {\n this.create()\n },\n watch: {\n // 监听 'value' 属性变化 - value 用于自定义 v-model\n value(newVal: string) {\n const isEqual = newVal === this.curValue\n\n if (isEqual) {\n return\n } // 和当前内容一样,则忽略\n\n // 重置 HTML\n this.setHtml(newVal)\n },\n },\n methods: {\n // 重置 HTML\n setHtml(newHtml: string) {\n const editor = this.editor as any\n\n if (editor == null) {\n return\n }\n editor.setHtml(newHtml)\n },\n\n // 创建 editor\n create() {\n if (this.$refs.box == null) {\n return\n }\n\n const defaultConfig = this.defaultConfig || {}\n\n const defaultContent = JSON.stringify(\n Array.isArray(this.defaultContent) ? this.defaultContent : []\n )\n\n createEditor({\n selector: this.$refs.box as Element,\n html: this.defaultHtml || this.value || '',\n config: {\n ...defaultConfig,\n onCreated: (editor: IDomEditor) => {\n this.editor = Object.seal(editor) as any // 注意,一定要用 Object.seal() 否则会报错\n\n this.$emit('onCreated', editor)\n if (defaultConfig.onCreated) {\n const info = genErrorInfo('onCreated')\n\n throw new Error(info)\n }\n },\n onChange: (editor: IDomEditor) => {\n const editorHtml = editor.getHtml()\n\n this.curValue = editorHtml // 记录当前 html 内容\n this.$emit('input', editorHtml) // 用于自定义 v-model\n\n this.$emit('onChange', editor)\n if (defaultConfig.onChange) {\n const info = genErrorInfo('onChange')\n\n throw new Error(info)\n }\n },\n onDestroyed: (editor: IDomEditor) => {\n this.$emit('onDestroyed', editor)\n if (defaultConfig.onDestroyed) {\n const info = genErrorInfo('onDestroyed')\n\n throw new Error(info)\n }\n },\n onMaxLength: (editor: IDomEditor) => {\n this.$emit('onMaxLength', editor)\n if (defaultConfig.onMaxLength) {\n const info = genErrorInfo('onMaxLength')\n\n throw new Error(info)\n }\n },\n onFocus: (editor: IDomEditor) => {\n this.$emit('onFocus', editor)\n if (defaultConfig.onFocus) {\n const info = genErrorInfo('onFocus')\n\n throw new Error(info)\n }\n },\n onBlur: (editor: IDomEditor) => {\n this.$emit('onBlur', editor)\n if (defaultConfig.onBlur) {\n const info = genErrorInfo('onBlur')\n\n throw new Error(info)\n }\n },\n customAlert: (info: string, type: AlertType) => {\n this.$emit('customAlert', info, type)\n if (defaultConfig.customAlert) {\n const errorInfo = genErrorInfo('customAlert')\n\n throw new Error(errorInfo)\n }\n },\n customPaste: (editor: IDomEditor, event: ClipboardEvent) => {\n if (defaultConfig.customPaste) {\n const info = genErrorInfo('customPaste')\n\n throw new Error(info)\n }\n let res\n\n this.$emit('customPaste', editor, event, (val: any) => {\n res = val\n })\n return res\n },\n },\n content: JSON.parse(defaultContent),\n mode: this.mode || 'default',\n })\n },\n },\n})\n</script>\n","<script lang=\"ts\">\nimport { createToolbar, DomEditor, IDomEditor } from '@wangeditor-next/editor'\nimport Vue from 'vue'\n\nexport default Vue.extend({\n name: 'Toolbar',\n render(h) {\n return h('div', { ref: 'box' })\n },\n props: {\n editor: {\n type: Object,\n default: undefined,\n },\n defaultConfig: {\n type: Object,\n default: () => ({}),\n },\n mode: {\n type: String,\n default: 'default',\n },\n },\n methods: {\n // 创建 toolbar\n create(editor: IDomEditor) {\n if (this.$refs.box == null) {\n return\n }\n if (editor == null) {\n return\n }\n if (DomEditor.getToolbar(editor)) {\n return\n } // 不重复创建\n\n createToolbar({\n editor,\n selector: this.$refs.box as Element,\n config: this.defaultConfig || {},\n mode: this.mode || 'default',\n })\n },\n },\n watch: {\n editor: {\n handler(e: IDomEditor | null) {\n if (e == null) {\n return\n }\n this.create(e)\n },\n immediate: true,\n },\n },\n})\n</script>\n"],"names":["genErrorInfo","fnName","info","_sfc_main$1","Vue","h","newVal","newHtml","editor","defaultConfig","defaultContent","createEditor","editorHtml","type","errorInfo","event","res","val","_sfc_main","DomEditor","createToolbar","e"],"mappings":";;AAMA,SAAAA,EAAAC,GAAA;AACA,MAAAC,IAAA,SAAAD,CAAA;AAEA,SAAAC,KAAA;AAAA,eAAAD,CAAA,4BACAC;AACA;AAEA,MAAAC,IAAAC,EAAA,OAAA;AAAA;AAAA,EAEA,OAAA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index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function(n,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@wangeditor-next/editor"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@wangeditor-next/editor","vue"],s):(n=typeof globalThis<"u"?globalThis:n||self,s(n.WangEditorForVue={},n.wangEditor,n.Vue))})(this,(function(n,s,d){"use strict";function i(t){let r=`请使用 '@${t}' 事件,不要放在 props 中`;return r+=`
2
- Please use '@${t}' event instead of props`,r}const l=d.extend({render(t){return t("div",{ref:"box"})},name:"Editor",data(){return{curValue:"",editor:null}},props:{defaultContent:{type:Array,default:()=>[]},defaultConfig:{type:Object,default:()=>({})},mode:{type:String,default:"default"},defaultHtml:{type:String,default:""},value:{type:String,default:""}},mounted(){this.create()},watch:{value(t){t!==this.curValue&&this.setHtml(t)}},methods:{setHtml(t){const r=this.editor;r!=null&&r.setHtml(t)},create(){if(this.$refs.box==null)return;const t=this.defaultConfig||{},r=JSON.stringify(Array.isArray(this.defaultContent)?this.defaultContent:[]);s.createEditor({selector:this.$refs.box,html:this.defaultHtml||this.value||"",config:{...t,onCreated:e=>{if(this.editor=Object.seal(e),this.$emit("onCreated",e),t.onCreated){const o=i("onCreated");throw new Error(o)}},onChange:e=>{const o=e.getHtml();if(this.curValue=o,this.$emit("input",o),this.$emit("onChange",e),t.onChange){const u=i("onChange");throw new Error(u)}},onDestroyed:e=>{if(this.$emit("onDestroyed",e),t.onDestroyed){const o=i("onDestroyed");throw new Error(o)}},onMaxLength:e=>{if(this.$emit("onMaxLength",e),t.onMaxLength){const o=i("onMaxLength");throw new Error(o)}},onFocus:e=>{if(this.$emit("onFocus",e),t.onFocus){const o=i("onFocus");throw new Error(o)}},onBlur:e=>{if(this.$emit("onBlur",e),t.onBlur){const o=i("onBlur");throw new Error(o)}},customAlert:(e,o)=>{if(this.$emit("customAlert",e,o),t.customAlert){const u=i("customAlert");throw new Error(u)}},customPaste:(e,o)=>{if(t.customPaste){const a=i("customPaste");throw new Error(a)}let u;return this.$emit("customPaste",e,o,a=>{u=a}),u}},content:JSON.parse(r),mode:this.mode||"default"})}}});function f(t,r,e,o,u,a,w,C){var y=typeof t=="function"?t.options:t;return{exports:t,options:y}}var c=f(l);const h=c.exports,m=d.extend({name:"Toolbar",render(t){return t("div",{ref:"box"})},props:{editor:{type:Object,default:void 0},defaultConfig:{type:Object,default:()=>({})},mode:{type:String,default:"default"}},methods:{create(t){this.$refs.box!=null&&t!=null&&(s.DomEditor.getToolbar(t)||s.createToolbar({editor:t,selector:this.$refs.box,config:this.defaultConfig||{},mode:this.mode||"default"}))}},watch:{editor:{handler(t){t!=null&&this.create(t)},immediate:!0}}});var p=f(m);const g=p.exports;n.Editor=h,n.Toolbar=g,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
2
+ Please use '@${t}' event instead of props`,r}const l=d.extend({render(t){return t("div",{ref:"box"})},name:"Editor",data(){return{curValue:"",editor:null}},props:{defaultContent:{type:Array,default:()=>[]},defaultConfig:{type:Object,default:()=>({})},mode:{type:String,default:"default"},defaultHtml:{type:String,default:""},value:{type:String,default:""}},mounted(){this.create()},watch:{value(t){t!==this.curValue&&this.setHtml(t)}},methods:{setHtml(t){const r=this.editor;r?.setHtml(t)},create(){if(this.$refs.box==null)return;const t=this.defaultConfig||{},r=JSON.stringify(Array.isArray(this.defaultContent)?this.defaultContent:[]);s.createEditor({selector:this.$refs.box,html:this.defaultHtml||this.value||"",config:{...t,onCreated:e=>{if(this.editor=Object.seal(e),this.$emit("onCreated",e),t.onCreated){const o=i("onCreated");throw new Error(o)}},onChange:e=>{const o=e.getHtml();if(this.curValue=o,this.$emit("input",o),this.$emit("onChange",e),t.onChange){const u=i("onChange");throw new Error(u)}},onDestroyed:e=>{if(this.$emit("onDestroyed",e),t.onDestroyed){const o=i("onDestroyed");throw new Error(o)}},onMaxLength:e=>{if(this.$emit("onMaxLength",e),t.onMaxLength){const o=i("onMaxLength");throw new Error(o)}},onFocus:e=>{if(this.$emit("onFocus",e),t.onFocus){const o=i("onFocus");throw new Error(o)}},onBlur:e=>{if(this.$emit("onBlur",e),t.onBlur){const o=i("onBlur");throw new Error(o)}},customAlert:(e,o)=>{if(this.$emit("customAlert",e,o),t.customAlert){const u=i("customAlert");throw new Error(u)}},customPaste:(e,o)=>{if(t.customPaste){const a=i("customPaste");throw new Error(a)}let u;return this.$emit("customPaste",e,o,a=>{u=a}),u}},content:JSON.parse(r),mode:this.mode||"default"})}}});function f(t,r,e,o,u,a,w,C){var y=typeof t=="function"?t.options:t;return{exports:t,options:y}}var c=f(l);const h=c.exports,m=d.extend({name:"Toolbar",render(t){return t("div",{ref:"box"})},props:{editor:{type:Object,default:void 0},defaultConfig:{type:Object,default:()=>({})},mode:{type:String,default:"default"}},methods:{create(t){this.$refs.box!=null&&t!=null&&(s.DomEditor.getToolbar(t)||s.createToolbar({editor:t,selector:this.$refs.box,config:this.defaultConfig||{},mode:this.mode||"default"}))}},watch:{editor:{handler(t){t!=null&&this.create(t)},immediate:!0}}});var p=f(m);const g=p.exports;n.Editor=h,n.Toolbar=g,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/components/Editor.vue","../src/components/Toolbar.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { createEditor, IDomEditor } from '@wangeditor-next/editor'\nimport Vue from 'vue'\n\ntype AlertType = 'success' | 'info' | 'warning' | 'error'\n\nfunction genErrorInfo(fnName: string) {\n let info = `请使用 '@${fnName}' 事件,不要放在 props 中`\n\n info += `\\nPlease use '@${fnName}' event instead of props`\n return info\n}\n\nexport default Vue.extend({\n //【注意】单独写 <template>...</template> 时,rollup 打包完浏览器运行时报错,所以先在这里写 template\n render(h) {\n return h('div', { ref: 'box' })\n },\n name: 'Editor',\n data() {\n return {\n curValue: '',\n editor: null,\n }\n },\n props: {\n defaultContent: {\n type: Array,\n default: () => [],\n },\n defaultConfig: {\n type: Object,\n default: () => ({}),\n },\n mode: {\n type: String,\n default: 'default',\n },\n defaultHtml: {\n type: String,\n default: '',\n },\n // value 用于自定义 v-model\n value: {\n type: String,\n default: '',\n },\n },\n mounted() {\n this.create()\n },\n watch: {\n // 监听 'value' 属性变化 - value 用于自定义 v-model\n value(newVal: string) {\n const isEqual = newVal === this.curValue\n\n if (isEqual) {\n return\n } // 和当前内容一样,则忽略\n\n // 重置 HTML\n this.setHtml(newVal)\n },\n },\n methods: {\n // 重置 HTML\n setHtml(newHtml: string) {\n const editor = this.editor as any\n\n if (editor == null) {\n return\n }\n editor.setHtml(newHtml)\n },\n\n // 创建 editor\n create() {\n if (this.$refs.box == null) {\n return\n }\n\n const defaultConfig = this.defaultConfig || {}\n\n const defaultContent = JSON.stringify(\n Array.isArray(this.defaultContent) ? this.defaultContent : []\n )\n\n createEditor({\n selector: this.$refs.box as Element,\n html: this.defaultHtml || this.value || '',\n config: {\n ...defaultConfig,\n onCreated: (editor: IDomEditor) => {\n this.editor = Object.seal(editor) as any // 注意,一定要用 Object.seal() 否则会报错\n\n this.$emit('onCreated', editor)\n if (defaultConfig.onCreated) {\n const info = genErrorInfo('onCreated')\n\n throw new Error(info)\n }\n },\n onChange: (editor: IDomEditor) => {\n const editorHtml = editor.getHtml()\n\n this.curValue = editorHtml // 记录当前 html 内容\n this.$emit('input', editorHtml) // 用于自定义 v-model\n\n this.$emit('onChange', editor)\n if (defaultConfig.onChange) {\n const info = genErrorInfo('onChange')\n\n throw new Error(info)\n }\n },\n onDestroyed: (editor: IDomEditor) => {\n this.$emit('onDestroyed', editor)\n if (defaultConfig.onDestroyed) {\n const info = genErrorInfo('onDestroyed')\n\n throw new Error(info)\n }\n },\n onMaxLength: (editor: IDomEditor) => {\n this.$emit('onMaxLength', editor)\n if (defaultConfig.onMaxLength) {\n const info = genErrorInfo('onMaxLength')\n\n throw new Error(info)\n }\n },\n onFocus: (editor: IDomEditor) => {\n this.$emit('onFocus', editor)\n if (defaultConfig.onFocus) {\n const info = genErrorInfo('onFocus')\n\n throw new Error(info)\n }\n },\n onBlur: (editor: IDomEditor) => {\n this.$emit('onBlur', editor)\n if (defaultConfig.onBlur) {\n const info = genErrorInfo('onBlur')\n\n throw new Error(info)\n }\n },\n customAlert: (info: string, type: AlertType) => {\n this.$emit('customAlert', info, type)\n if (defaultConfig.customAlert) {\n const errorInfo = genErrorInfo('customAlert')\n\n throw new Error(errorInfo)\n }\n },\n customPaste: (editor: IDomEditor, event: ClipboardEvent) => {\n if (defaultConfig.customPaste) {\n const info = genErrorInfo('customPaste')\n\n throw new Error(info)\n }\n let res\n\n this.$emit('customPaste', editor, event, (val: any) => {\n res = val\n })\n return res\n },\n },\n content: JSON.parse(defaultContent),\n mode: this.mode || 'default',\n })\n },\n },\n})\n</script>\n","<script lang=\"ts\">\nimport { createToolbar, DomEditor, IDomEditor } from '@wangeditor-next/editor'\nimport Vue from 'vue'\n\nexport default Vue.extend({\n name: 'Toolbar',\n render(h) {\n return h('div', { ref: 'box' })\n },\n props: {\n editor: {\n type: Object,\n default: undefined,\n },\n defaultConfig: {\n type: Object,\n default: () => ({}),\n },\n mode: {\n type: String,\n default: 'default',\n },\n },\n methods: {\n // 创建 toolbar\n create(editor: IDomEditor) {\n if (this.$refs.box == null) {\n return\n }\n if (editor == null) {\n return\n }\n if (DomEditor.getToolbar(editor)) {\n return\n } // 不重复创建\n\n createToolbar({\n editor,\n selector: this.$refs.box as Element,\n config: this.defaultConfig || {},\n mode: this.mode || 'default',\n })\n },\n },\n watch: {\n editor: {\n handler(e: IDomEditor | null) {\n if (e == null) {\n return\n }\n this.create(e)\n },\n immediate: true,\n },\n },\n})\n</script>\n"],"names":["genErrorInfo","fnName","info","_sfc_main$1","Vue","h","newVal","newHtml","editor","defaultConfig","defaultContent","createEditor","editorHtml","type","errorInfo","event","res","val","_sfc_main","DomEditor","createToolbar","e"],"mappings":"kVAMA,SAAAA,EAAAC,EAAA,CACA,IAAAC,EAAA,S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A,OAAAA,EAAA,MAAA,CAAA,IAAA,MAAA,CACA,EACA,MAAA,CACA,OAAA,CACA,KAAA,OACA,QAAA,MAAA,EAEA,cAAA,CACA,KAAA,OACA,QAAA,KAAA,CAAA,EAAA,EAEA,KAAA,CACA,KAAA,OACA,QAAA,SAAA,CACA,EAEA,QAAA,CAEA,OAAAG,EAAA,CACA,KAAA,MAAA,KAAA,MAGAA,GAAA,OAGAW,EAAAA,UAAA,WAAAX,CAAA,GAIAY,gBAAA,CAAA,OACAZ,EACA,SAAA,KAAA,MAAA,IACA,OAAA,KAAA,eAAA,CAAA,EACA,KAAA,KAAA,MAAA,SAAA,CACA,EACA,CAAA,EAEA,MAAA,CACA,OAAA,CACA,QAAAa,EAAA,CACAA,GAAA,MAGA,KAAA,OAAAA,CAAA,CACA,EACA,UAAA,EAAA,CACA,CAEA,CAAA"}
1
+ {"version":3,"file":"index.js","sources":["../src/components/Editor.vue","../src/components/Toolbar.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { createEditor, IDomEditor } from '@wangeditor-next/editor'\nimport Vue from 'vue'\n\ntype AlertType = 'success' | 'info' | 'warning' | 'error'\n\nfunction genErrorInfo(fnName: string) {\n let info = `请使用 '@${fnName}' 事件,不要放在 props 中`\n\n info += `\\nPlease use '@${fnName}' event instead of props`\n return info\n}\n\nexport default Vue.extend({\n //【注意】单独写 <template>...</template> 时,rollup 打包完浏览器运行时报错,所以先在这里写 template\n render(h) {\n return h('div', { ref: 'box' })\n },\n name: 'Editor',\n data() {\n return {\n curValue: '',\n editor: null,\n }\n },\n props: {\n defaultContent: {\n type: Array,\n default: () => [],\n },\n defaultConfig: {\n type: Object,\n default: () => ({}),\n },\n mode: {\n type: String,\n default: 'default',\n },\n defaultHtml: {\n type: String,\n default: '',\n },\n // value 用于自定义 v-model\n value: {\n type: String,\n default: '',\n },\n },\n mounted() {\n this.create()\n },\n watch: {\n // 监听 'value' 属性变化 - value 用于自定义 v-model\n value(newVal: string) {\n const isEqual = newVal === this.curValue\n\n if (isEqual) {\n return\n } // 和当前内容一样,则忽略\n\n // 重置 HTML\n this.setHtml(newVal)\n },\n },\n methods: {\n // 重置 HTML\n setHtml(newHtml: string) {\n const editor = this.editor as any\n\n if (editor == null) {\n return\n }\n editor.setHtml(newHtml)\n },\n\n // 创建 editor\n create() {\n if (this.$refs.box == null) {\n return\n }\n\n const defaultConfig = this.defaultConfig || {}\n\n const defaultContent = JSON.stringify(\n Array.isArray(this.defaultContent) ? this.defaultContent : []\n )\n\n createEditor({\n selector: this.$refs.box as Element,\n html: this.defaultHtml || this.value || '',\n config: {\n ...defaultConfig,\n onCreated: (editor: IDomEditor) => {\n this.editor = Object.seal(editor) as any // 注意,一定要用 Object.seal() 否则会报错\n\n this.$emit('onCreated', editor)\n if (defaultConfig.onCreated) {\n const info = genErrorInfo('onCreated')\n\n throw new Error(info)\n }\n },\n onChange: (editor: IDomEditor) => {\n const editorHtml = editor.getHtml()\n\n this.curValue = editorHtml // 记录当前 html 内容\n this.$emit('input', editorHtml) // 用于自定义 v-model\n\n this.$emit('onChange', editor)\n if (defaultConfig.onChange) {\n const info = genErrorInfo('onChange')\n\n throw new Error(info)\n }\n },\n onDestroyed: (editor: IDomEditor) => {\n this.$emit('onDestroyed', editor)\n if (defaultConfig.onDestroyed) {\n const info = genErrorInfo('onDestroyed')\n\n throw new Error(info)\n }\n },\n onMaxLength: (editor: IDomEditor) => {\n this.$emit('onMaxLength', editor)\n if (defaultConfig.onMaxLength) {\n const info = genErrorInfo('onMaxLength')\n\n throw new Error(info)\n }\n },\n onFocus: (editor: IDomEditor) => {\n this.$emit('onFocus', editor)\n if (defaultConfig.onFocus) {\n const info = genErrorInfo('onFocus')\n\n throw new Error(info)\n }\n },\n onBlur: (editor: IDomEditor) => {\n this.$emit('onBlur', editor)\n if (defaultConfig.onBlur) {\n const info = genErrorInfo('onBlur')\n\n throw new Error(info)\n }\n },\n customAlert: (info: string, type: AlertType) => {\n this.$emit('customAlert', info, type)\n if (defaultConfig.customAlert) {\n const errorInfo = genErrorInfo('customAlert')\n\n throw new Error(errorInfo)\n }\n },\n customPaste: (editor: IDomEditor, event: ClipboardEvent) => {\n if (defaultConfig.customPaste) {\n const info = genErrorInfo('customPaste')\n\n throw new Error(info)\n }\n let res\n\n this.$emit('customPaste', editor, event, (val: any) => {\n res = val\n })\n return res\n },\n },\n content: JSON.parse(defaultContent),\n mode: this.mode || 'default',\n })\n },\n },\n})\n</script>\n","<script lang=\"ts\">\nimport { createToolbar, DomEditor, IDomEditor } from '@wangeditor-next/editor'\nimport Vue from 'vue'\n\nexport default Vue.extend({\n name: 'Toolbar',\n render(h) {\n return h('div', { ref: 'box' })\n },\n props: {\n editor: {\n type: Object,\n default: undefined,\n },\n defaultConfig: {\n type: Object,\n default: () => ({}),\n },\n mode: {\n type: String,\n default: 'default',\n },\n },\n methods: {\n // 创建 toolbar\n create(editor: IDomEditor) {\n if (this.$refs.box == null) {\n return\n }\n if (editor == null) {\n return\n }\n if (DomEditor.getToolbar(editor)) {\n return\n } // 不重复创建\n\n createToolbar({\n editor,\n selector: this.$refs.box as Element,\n config: this.defaultConfig || {},\n mode: this.mode || 'default',\n })\n },\n },\n watch: {\n editor: {\n handler(e: IDomEditor | null) {\n if (e == null) {\n return\n }\n this.create(e)\n },\n immediate: true,\n },\n },\n})\n</script>\n"],"names":["genErrorInfo","fnName","info","_sfc_main$1","Vue","h","newVal","newHtml","editor","defaultConfig","defaultContent","createEditor","editorHtml","type","errorInfo","event","res","val","_sfc_main","DomEditor","createToolbar","e"],"mappings":"kVAMA,SAAAA,EAAAC,EAAA,CACA,IAAAC,EAAA,SAAAD,CAAA,oBAEA,OAAAC,GAAA;AAAA,eAAAD,CAAA,2BACAC,CACA,CAEA,MAAAC,EAAAC,EAAA,OAAA,CAEA,OAAAC,EAAA,CACA,OAAAA,EAAA,MAAA,CAAA,IAAA,MAAA,CACA,EACA,KAAA,SACA,MAAA,CACA,MAAA,CACA,SAAA,GACA,OAAA,IAAA,CAEA,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A,MAGAA,GAAA,OAGAW,EAAAA,UAAA,WAAAX,CAAA,GAIAY,gBAAA,CAAA,OACAZ,EACA,SAAA,KAAA,MAAA,IACA,OAAA,KAAA,eAAA,CAAA,EACA,KAAA,KAAA,MAAA,SAAA,CACA,EACA,CAAA,EAEA,MAAA,CACA,OAAA,CACA,QAAAa,EAAA,CACAA,GAAA,MAGA,KAAA,OAAAA,CAAA,CACA,EACA,UAAA,EAAA,CACA,CAEA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wangeditor-next/editor-for-vue2",
3
- "version": "6.4.3",
3
+ "version": "6.5.0",
4
4
  "description": "wangEditor component for Vue 2",
5
5
  "author": "cycleccc <ylf2991205548@qq.com>",
6
6
  "homepage": "https://github.com/wangeditor-next/wangEditor-next#readme",
@@ -41,16 +41,16 @@
41
41
  },
42
42
  "peerDependencies": {
43
43
  "vue": "^2.7.16",
44
- "@wangeditor-next/editor": "^6.4.3"
44
+ "@wangeditor-next/editor": "^6.5.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "^20.19.0",
48
48
  "@vitejs/plugin-vue2": "^2.3.4",
49
- "typescript": "5.2.2",
50
- "vite": "^6.4.3",
51
- "vite-plugin-dts": "^5.0.3",
49
+ "typescript": "5.9.3",
50
+ "vite": "^7.3.6",
51
+ "vite-plugin-dts": "^5.1.1",
52
52
  "vue": "^2.7.16",
53
- "@wangeditor-next/editor": "^6.4.3"
53
+ "@wangeditor-next/editor": "^6.5.0"
54
54
  },
55
55
  "scripts": {
56
56
  "dev": "vite",