@progress/kendo-vue-editor 7.0.0 → 7.0.1-develop.2
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.
- package/Editor.js +1 -1
- package/Editor.mjs +293 -269
- package/dist/cdn/js/kendo-vue-editor.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +12 -12
- package/utils/cleanup.js +8 -0
- package/utils/cleanup.mjs +35 -0
package/Editor.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),A=require("@progress/kendo-vue-buttons"),a=require("@progress/kendo-vue-common"),s=require("@progress/kendo-editor-common"),U=require("./config/schema.js"),P=require("./config/defaultStyles.js"),e=require("./config/toolsSettings.js"),_=require("./dialogs/insertLink.js"),b=require("./utils/main.js"),M=require("./utils/props-key.js"),x=require("./utils/controlled-value.js"),F=require("./utils/browser-detection.js"),$=require("./package-metadata.js"),C=require("./tools/align.js"),z=require("./tools/indent.js"),B=require("./tools/lists.js"),W=require("./tools/outdent.js"),E=require("./tools/inlineFormat.js"),R=require("./tools/fontStyle.js"),j=require("./tools/formatBlock.js"),p=require("./tools/proseMirrorTool.js"),I=require("./tools/insertLink.js"),G=require("./tools/unlink.js"),K=require("./tools/cleanFormatting.js"),J=require("./tools/selectAll.js"),Q=require("./tools/insertImage.js"),X=require("./tools/insertTable/tool.js"),Y=require("./tools/viewHtml.js"),Z=require("./tools/pdf.js"),ee=require("./tools/print.js"),te=require("./tools/findReplace.js"),N=require("./tools/applyColor.js"),h=require("./messages/main.js"),oe=require("@progress/kendo-vue-intl"),{link:O,bold:ie,italic:se,underline:re}=e.EditorToolsSettings;function H(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!r.isVNode(t)}const w={Bold:{comp:E.InlineFormat,props:e.EditorToolsSettings.bold},Italic:{comp:E.InlineFormat,props:e.EditorToolsSettings.italic},Underline:{comp:E.InlineFormat,props:e.EditorToolsSettings.underline},Strikethrough:{comp:E.InlineFormat,props:e.EditorToolsSettings.strikethrough},Subscript:{comp:E.InlineFormat,props:e.EditorToolsSettings.subscript},Superscript:{comp:E.InlineFormat,props:e.EditorToolsSettings.superscript},AlignLeft:{comp:C.Align,props:e.EditorToolsSettings.alignLeft},AlignCenter:{comp:C.Align,props:e.EditorToolsSettings.alignCenter},AlignRight:{comp:C.Align,props:e.EditorToolsSettings.alignRight},AlignJustify:{comp:C.Align,props:e.EditorToolsSettings.alignJustify},Indent:{comp:z.Indent,props:e.EditorToolsSettings.indent},Outdent:{comp:W.Outdent,props:e.EditorToolsSettings.outdent},OrderedList:{comp:B.List,props:e.EditorToolsSettings.orderedList},UnorderedList:{comp:B.List,props:e.EditorToolsSettings.bulletList},FontSize:{comp:R.FontName,props:e.EditorToolsSettings.fontSize},FontName:{comp:R.FontName,props:e.EditorToolsSettings.fontName},FormatBlock:{comp:j.FormatBlock,props:e.EditorToolsSettings.formatBlock},Undo:{comp:p.ProseMirror,props:e.EditorToolsSettings.undo},Redo:{comp:p.ProseMirror,props:e.EditorToolsSettings.redo},Link:{comp:I.LinkTool,props:e.EditorToolsSettings.link},Unlink:{comp:G.Unlink,props:e.EditorToolsSettings.unlink},InsertImage:{comp:Q.InsertImage,props:e.EditorToolsSettings.image},ViewHtml:{comp:Y.ViewHtml,props:e.EditorToolsSettings.viewHtml},CleanFormatting:{comp:K.CleanFormatting,props:e.EditorToolsSettings.cleanFormatting},SelectAll:{comp:J.SelectAll,props:e.EditorToolsSettings.selectAll},InsertTable:{comp:X.InsertTable,props:e.EditorToolsSettings.insertTable},MergeCells:{comp:p.ProseMirror,props:e.EditorToolsSettings.mergeCells},SplitCell:{comp:p.ProseMirror,props:e.EditorToolsSettings.splitCell},AddRowBefore:{comp:p.ProseMirror,props:e.EditorToolsSettings.addRowBefore},AddRowAfter:{comp:p.ProseMirror,props:e.EditorToolsSettings.addRowAfter},AddColumnBefore:{comp:p.ProseMirror,props:e.EditorToolsSettings.addColumnBefore},AddColumnAfter:{comp:p.ProseMirror,props:e.EditorToolsSettings.addColumnAfter},DeleteRow:{comp:p.ProseMirror,props:e.EditorToolsSettings.deleteRow},DeleteColumn:{comp:p.ProseMirror,props:e.EditorToolsSettings.deleteColumn},DeleteTable:{comp:p.ProseMirror,props:e.EditorToolsSettings.deleteTable},Print:{comp:ee.Print,props:e.EditorToolsSettings.print},Pdf:{comp:Z.Pdf,props:e.EditorToolsSettings.pdf},InsertFile:{comp:I.LinkTool,props:e.EditorToolsSettings.insertFile},FindAndReplace:{comp:te.FindAndReplace,props:e.EditorToolsSettings.findAndReplace},ForeColor:{comp:N.ApplyColor,props:e.EditorToolsSettings.foreColor},BackColor:{comp:N.ApplyColor,props:e.EditorToolsSettings.backColor}},ne=r.defineComponent({name:"KendoEditor",emits:{focus:null,blur:null,change:null,loaded:null,execute:null},inject:{kendoLocalizationService:{default:null}},props:{defaultContent:String,value:[Object,String],defaultEditMode:{type:String,default:"iframe",validator:function(t){return["iframe","div"].includes(t)}},contentStyle:Object,dir:String,tools:Array,keyboardNavigation:{type:Boolean,default:!0},resizable:Boolean,preserveWhitespace:{type:[String,Boolean],default:"full",validator:function(t){return[!0,!1,"full"].includes(t)}},pasteHtml:Function,extendView:Function,ariaDescribedBy:String,ariaLabelledBy:String,ariaLabel:String},data(){return{updateGuid:a.guid(),view:void 0,linkDialog:!1,showLicenseWatermark:!1,licenseMessage:void 0}},created(){this._view=void 0,this.trOnChange=null,this.valueisUpdated=!1,this._prevValue=this.$props.value,a.validatePackage($.packageMetadata),this.showLicenseWatermark=a.shouldShowValidationUI($.packageMetadata),this.licenseMessage=a.getLicenseMessage($.packageMetadata)},mounted(){this.iframe=a.getRef(this,"iframe"),this.contentElement=a.getRef(this,"contentElement"),(!this.iframe||!F.firefox)&&this.initialize()},watch:{value:function(t,o){this.valueisUpdated=!0,this._prevValue=o}},updated(){const{value:t}=this.$props,o=this.getView();t===void 0||!this.valueisUpdated||!o||(x.updateEditorValue(o,this.computedValue(),this._prevValue,this.trOnChange,this.htmlOnChange),this.valueisUpdated=!1,this.trOnChange=null,this.htmlOnChange=null)},unmounted(){this.getView()&&this.getView().destroy(),this.view=void 0,this._view=void 0},render(){let t=100;const{tools:o=[],defaultEditMode:n="iframe",preserveWhitespace:v="full",style:g,value:y}=this.$props,T=this.getView(),m=oe.provideLocalizationService(this),V=this.showLicenseWatermark?r.createVNode(a.WatermarkOverlay,{message:this.licenseMessage},null):null;if(this.view){const i=M.editorPropsKey.getState(this.view.state);i.preserveWhitespace=v}let S=this.$props.contentStyle;S===void 0&&(g||{}).height===void 0&&(S={height:"300px"});const q=function(){return this.linkDialog&&r.createVNode(_.InsertLinkDialog,{view:T,settings:O,dir:this.$props.dir,onClose:this.handleClose},null)},l=function(i,f){const c=w[i]||i,D=function(){let k;return i==="ForeColor"?k=m.toLanguageString(h.keys.foregroundColorAriaLabel,h.messages[h.keys.foregroundColorAriaLabel]):i==="BackColor"&&(k=m.toLanguageString(h.keys.backgroundColor,h.messages[h.keys.backgroundColor])),k};if(w[i]){t++;const k={view:T,dir:this.$props.dir,key:t,updateGuid:this.updateGuid,settings:w[i].props,...w[i].props,ariaLabel:D()};return r.h(r.markRaw(w[i].comp),k)}else{if(c==="Separator")return r.createVNode(A.ToolbarSeparator,{key:t},null);{const k=a.templateRendering.call(this,c.render,a.getListeners.call(this));return a.getTemplate.call(this,{h:r.h,template:k,defaultRendering:null,additionalListeners:{},additionalProps:{view:T,dir:this.$props.dir,updateGuid:this.updateGuid,key:t,settings:c.props}})}}},u=function(i,f){return i.map(function(c){return l.call(this,c,f)},this)},d=o.map(function(i,f){let c;return Array.isArray(i)?r.createVNode(A.ButtonGroup,{key:f},H(c=u.call(this,i,f))?c:{default:()=>[c]}):l.call(this,i,f)},this);return r.createVNode("div",{class:a.classNames("k-editor",{"k-editor-resizable":this.$props.resizable}),dir:this.$props.dir},[d.length>0&&r.createVNode(A.Toolbar,{overflow:"none",class:"k-editor-toolbar",keyboardNavigation:this.$props.keyboardNavigation},H(d)?d:{default:()=>[d]}),n==="iframe"?r.createVNode("div",{class:"k-editor-content"},[r.createVNode("iframe",{onLoad:this.iframeLoad,ref:a.setRef(this,"iframe"),frameborder:"0",title:m.toLanguageString(h.keys.iframeTitle,h.messages[h.keys.iframeTitle]),style:S,class:"k-iframe"},null)]):r.createVNode("div",{style:S,class:"k-editor-content"},[r.createVNode("div",{ref:a.setRef(this,"contentElement"),role:"textbox","aria-labelledby":this.$props.ariaLabelledBy,"aria-describedby":this.$props.ariaDescribedBy,"aria-label":this.$props.ariaLabel},null)]),q.call(this),V])},methods:{getView(){return this.view},getHTML(){const t=this.getView();return t?b.EditorUtils.getHtml(t.state):""},setHTML(t){const o=this.getView();o&&b.EditorUtils.setHtml(o,t)},focus(){this.getView()&&this.getView().focus()},updateTools(t){this.view=t,this.updateGuid=a.guid()},iframeLoad(){F.firefox&&this.initialize()},initialize(){const t=this.iframe&&this.iframe.contentWindow;if(t){const l=t.document;[P.defaultStyle,P.tablesStyles,this.$props.dir==="rtl"?P.rtlStyles:void 0].forEach(d=>{if(d){const i=l.createElement("style");i.appendChild(l.createTextNode(d)),l.head.appendChild(i)}});const u=l.createElement("meta");u.setAttribute("charset","utf-8"),l.head.appendChild(u),this.contentElement=l.createElement("div"),l.body.appendChild(this.contentElement),this.contentElement.classList.add("k-content"),this.contentElement.setAttribute("role","main")}const o=this.contentElement;if(!o)return;const{preserveWhitespace:n="full"}=this.$props,v=this;let g=[new s.Plugin({view:()=>({update:this.updateTools}),key:new s.PluginKey("toolbar-tools-update-plugin")}),new s.Plugin({filterTransaction:this.filterTransaction,key:new s.PluginKey("onExecute-event-plugin")}),new s.Plugin({key:M.editorPropsKey,state:{init:()=>({preserveWhitespace:n}),apply:(l,u)=>u}}),s.spacesFix(),s.history(),s.dropCursor(),s.gapCursor(),s.tableEditing()],y={...b.EditorUtils.getShortcuts({types:{listItem:"list_item",hardBreak:"hard_break"},toolsSettings:{bold:ie,italic:se,underline:re}}),"Mod-k":()=>{const{linkDialog:l}=this.$data,u=this.getView();if(u){const d=u.state,i=d.selection.empty,f=s.getMark(d,d.schema.marks[O.mark]);!l&&!(i&&!f)&&(this.linkDialog=!0)}return!l}};const{defaultContent:T="",value:m}=this.$props,V=m&&typeof m!="string"?r.toRaw(m):b.EditorUtils.createDocument(new s.Schema({nodes:U.nodes,marks:s.marks}),m||T,{preserveWhitespace:n}),L={state:s.EditorState.create({plugins:[...g,s.keymap(y),s.keymap(s.baseKeymap)],doc:V}),transformPastedHTML:this.onPasteHtml,dispatchTransaction:this.dispatchTransaction,handleDOMEvents:{focus:this.onFocus,blur:this.onBlur,paste:this.onPaste}},S={plugins:g,shortcuts:y,target:v,viewProps:L,dom:o};this.$emit("loaded",S);const q=this.$props.extendView&&this.$props.extendView(S)||new s.EditorView({mount:o},L);this.view=r.markRaw(q)},filterTransaction(t,o){const n={target:this,transaction:t,state:o};return this.$emit("execute",n),!0},onPasteHtml(t){if(this.$props.pasteHtml&&this.pasteEvent){const o={target:this,pastedHtml:t,event:this.pasteEvent},n=this.$props.pasteHtml(o);if(this.pasteEvent=void 0,typeof n=="string")return n}return t},dispatchTransaction(t){const o=t.docChanged;if(o){this.trOnChange=t;const n=t.doc,v=t.doc.type.schema,g=this,y={target:g,value:n,get html(){return g.htmlOnChange=b.EditorUtils.getHtml({doc:n,schema:v}),g.htmlOnChange},transaction:t,schema:v};this.$emit("change",y)}this.getView()&&(this.$props.value===void 0||!o)&&this.getView().updateState(this.getView().state.apply(t))},onFocus(t,o){const n={target:this,event:o};return this.$emit("focus",n),!1},onBlur(t,o){const n={target:this,event:o};return this.$emit("blur",n),!1},onPaste(t,o){return this.$props.pasteHtml&&(this.pasteEvent=o),!1},handleClose(){this.linkDialog=!1},computedValue(){return this.trOnChange!==null?this.trOnChange.doc:this.$props.value!==void 0?this.$props.value:this.getView()?this.getView().state.doc:this.$props.defaultContent||""}}});exports.Editor=ne;exports.allTools=w;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue"),q=require("@progress/kendo-vue-buttons"),d=require("@progress/kendo-vue-common"),r=require("@progress/kendo-editor-common"),_=require("./config/schema.js"),P=require("./config/defaultStyles.js"),t=require("./config/toolsSettings.js"),x=require("./dialogs/insertLink.js"),T=require("./utils/main.js"),O=require("./utils/props-key.js"),z=require("./utils/controlled-value.js"),A=require("./utils/cleanup.js"),B=require("./utils/browser-detection.js"),M=require("./package-metadata.js"),L=require("./tools/align.js"),W=require("./tools/indent.js"),I=require("./tools/lists.js"),G=require("./tools/outdent.js"),y=require("./tools/inlineFormat.js"),N=require("./tools/fontStyle.js"),j=require("./tools/formatBlock.js"),g=require("./tools/proseMirrorTool.js"),R=require("./tools/insertLink.js"),K=require("./tools/unlink.js"),J=require("./tools/cleanFormatting.js"),Q=require("./tools/selectAll.js"),X=require("./tools/insertImage.js"),Y=require("./tools/insertTable/tool.js"),Z=require("./tools/viewHtml.js"),ee=require("./tools/pdf.js"),te=require("./tools/print.js"),ie=require("./tools/findReplace.js"),H=require("./tools/applyColor.js"),v=require("./messages/main.js"),oe=require("@progress/kendo-vue-intl"),{link:D,bold:se,italic:re,underline:ne}=t.EditorToolsSettings;function U(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!n.isVNode(e)}const b={Bold:{comp:y.InlineFormat,props:t.EditorToolsSettings.bold},Italic:{comp:y.InlineFormat,props:t.EditorToolsSettings.italic},Underline:{comp:y.InlineFormat,props:t.EditorToolsSettings.underline},Strikethrough:{comp:y.InlineFormat,props:t.EditorToolsSettings.strikethrough},Subscript:{comp:y.InlineFormat,props:t.EditorToolsSettings.subscript},Superscript:{comp:y.InlineFormat,props:t.EditorToolsSettings.superscript},AlignLeft:{comp:L.Align,props:t.EditorToolsSettings.alignLeft},AlignCenter:{comp:L.Align,props:t.EditorToolsSettings.alignCenter},AlignRight:{comp:L.Align,props:t.EditorToolsSettings.alignRight},AlignJustify:{comp:L.Align,props:t.EditorToolsSettings.alignJustify},Indent:{comp:W.Indent,props:t.EditorToolsSettings.indent},Outdent:{comp:G.Outdent,props:t.EditorToolsSettings.outdent},OrderedList:{comp:I.List,props:t.EditorToolsSettings.orderedList},UnorderedList:{comp:I.List,props:t.EditorToolsSettings.bulletList},FontSize:{comp:N.FontName,props:t.EditorToolsSettings.fontSize},FontName:{comp:N.FontName,props:t.EditorToolsSettings.fontName},FormatBlock:{comp:j.FormatBlock,props:t.EditorToolsSettings.formatBlock},Undo:{comp:g.ProseMirror,props:t.EditorToolsSettings.undo},Redo:{comp:g.ProseMirror,props:t.EditorToolsSettings.redo},Link:{comp:R.LinkTool,props:t.EditorToolsSettings.link},Unlink:{comp:K.Unlink,props:t.EditorToolsSettings.unlink},InsertImage:{comp:X.InsertImage,props:t.EditorToolsSettings.image},ViewHtml:{comp:Z.ViewHtml,props:t.EditorToolsSettings.viewHtml},CleanFormatting:{comp:J.CleanFormatting,props:t.EditorToolsSettings.cleanFormatting},SelectAll:{comp:Q.SelectAll,props:t.EditorToolsSettings.selectAll},InsertTable:{comp:Y.InsertTable,props:t.EditorToolsSettings.insertTable},MergeCells:{comp:g.ProseMirror,props:t.EditorToolsSettings.mergeCells},SplitCell:{comp:g.ProseMirror,props:t.EditorToolsSettings.splitCell},AddRowBefore:{comp:g.ProseMirror,props:t.EditorToolsSettings.addRowBefore},AddRowAfter:{comp:g.ProseMirror,props:t.EditorToolsSettings.addRowAfter},AddColumnBefore:{comp:g.ProseMirror,props:t.EditorToolsSettings.addColumnBefore},AddColumnAfter:{comp:g.ProseMirror,props:t.EditorToolsSettings.addColumnAfter},DeleteRow:{comp:g.ProseMirror,props:t.EditorToolsSettings.deleteRow},DeleteColumn:{comp:g.ProseMirror,props:t.EditorToolsSettings.deleteColumn},DeleteTable:{comp:g.ProseMirror,props:t.EditorToolsSettings.deleteTable},Print:{comp:te.Print,props:t.EditorToolsSettings.print},Pdf:{comp:ee.Pdf,props:t.EditorToolsSettings.pdf},InsertFile:{comp:R.LinkTool,props:t.EditorToolsSettings.insertFile},FindAndReplace:{comp:ie.FindAndReplace,props:t.EditorToolsSettings.findAndReplace},ForeColor:{comp:H.ApplyColor,props:t.EditorToolsSettings.foreColor},BackColor:{comp:H.ApplyColor,props:t.EditorToolsSettings.backColor}},le=n.defineComponent({name:"KendoEditor",emits:{focus:null,blur:null,change:null,loaded:null,execute:null},inject:{kendoLocalizationService:{default:null}},props:{defaultContent:String,value:[Object,String],defaultEditMode:{type:String,default:"iframe",validator:function(e){return["iframe","div"].includes(e)}},contentStyle:Object,dir:String,tools:Array,keyboardNavigation:{type:Boolean,default:!0},resizable:Boolean,preserveWhitespace:{type:[String,Boolean],default:"full",validator:function(e){return[!0,!1,"full"].includes(e)}},pasteHtml:Function,extendView:Function,ariaDescribedBy:String,ariaLabelledBy:String,ariaLabel:String},data(){return{updateGuid:d.guid(),view:void 0,linkDialog:!1,showLicenseWatermark:!1,licenseMessage:void 0}},created(){this._view=void 0,this.trOnChange=null,this.valueisUpdated=!1,this._prevValue=this.$props.value,this.pluginViews=[],d.validatePackage(M.packageMetadata),this.showLicenseWatermark=d.shouldShowValidationUI(M.packageMetadata),this.licenseMessage=d.getLicenseMessage(M.packageMetadata)},mounted(){this.iframe=d.getRef(this,"iframe"),this.contentElement=d.getRef(this,"contentElement"),(!this.iframe||!B.firefox)&&this.initialize()},watch:{value:function(e,i){this.valueisUpdated=!0,this._prevValue=i}},updated(){const{value:e}=this.$props,i=this.getView();e===void 0||!this.valueisUpdated||!i||(z.updateEditorValue(i,this.computedValue(),this._prevValue,this.trOnChange,this.htmlOnChange),this.valueisUpdated=!1,this.trOnChange=null,this.htmlOnChange=null)},beforeUnmount(){var p,m;this.iframe&&(this.iframe.src="about:blank");const e=this.iframe,i=this.contentElement,s=this.getView();if(s){(p=this.pluginViews)==null||p.forEach(c=>{var S;(S=c==null?void 0:c.destroy)==null||S.call(c)});const f=A.cleanupAndDestroyProseMirrorView(s);(m=f==null?void 0:f.parentNode)==null||m.removeChild(f)}this.view&&A.nullifyObjectProperties(this.view),this.view=void 0,this._view=null,this.trOnChange=null,this.htmlOnChange=null,this.pasteEvent=void 0,this.valueisUpdated=!1,this._prevValue=void 0,this.pluginViews&&(this.pluginViews.length=0,this.pluginViews=null),this.iframe=void 0,this.contentElement=void 0,e&&A.cleanupIframe(e,i),this.updateGuid=void 0,this.linkDialog=!1},unmounted(){this.view=void 0,this._view=null,this.iframe=void 0,this.contentElement=void 0,this.pluginViews=null},render(){let e=100;const{tools:i=[],defaultEditMode:s="iframe",preserveWhitespace:p="full",style:m,value:f}=this.$props,c=this.getView(),S=oe.provideLocalizationService(this),E=this.showLicenseWatermark?n.createVNode(d.WatermarkOverlay,{message:this.licenseMessage},null):null;if(this.view){const o=O.editorPropsKey.getState(this.view.state);o.preserveWhitespace=p}let k=this.$props.contentStyle;k===void 0&&(m||{}).height===void 0&&(k={height:"300px"});const C=function(){return this.linkDialog&&n.createVNode(x.InsertLinkDialog,{view:c,settings:D,dir:this.$props.dir,onClose:this.handleClose},null)},V=function(o,u){const h=b[o]||o,F=function(){let w;return o==="ForeColor"?w=S.toLanguageString(v.keys.foregroundColorAriaLabel,v.messages[v.keys.foregroundColorAriaLabel]):o==="BackColor"&&(w=S.toLanguageString(v.keys.backgroundColor,v.messages[v.keys.backgroundColor])),w};if(b[o]){e++;const w={view:c,dir:this.$props.dir,key:e,updateGuid:this.updateGuid,settings:b[o].props,...b[o].props,ariaLabel:F()};return n.h(n.markRaw(b[o].comp),w)}else{if(h==="Separator")return n.createVNode(q.ToolbarSeparator,{key:e},null);{const w=d.templateRendering.call(this,h.render,d.getListeners.call(this));return d.getTemplate.call(this,{h:n.h,template:w,defaultRendering:null,additionalListeners:{},additionalProps:{view:c,dir:this.$props.dir,updateGuid:this.updateGuid,key:e,settings:h.props}})}}},l=function(o,u){return o.map(function(h){return V.call(this,h,u)},this)},a=i.map(function(o,u){let h;return Array.isArray(o)?n.createVNode(q.ButtonGroup,{key:u},U(h=l.call(this,o,u))?h:{default:()=>[h]}):V.call(this,o,u)},this);return n.createVNode("div",{class:d.classNames("k-editor",{"k-editor-resizable":this.$props.resizable}),dir:this.$props.dir},[a.length>0&&n.createVNode(q.Toolbar,{overflow:"none",class:"k-editor-toolbar",keyboardNavigation:this.$props.keyboardNavigation},U(a)?a:{default:()=>[a]}),s==="iframe"?n.createVNode("div",{class:"k-editor-content"},[n.createVNode("iframe",{onLoad:this.iframeLoad,ref:d.setRef(this,"iframe"),frameborder:"0",title:S.toLanguageString(v.keys.iframeTitle,v.messages[v.keys.iframeTitle]),style:k,class:"k-iframe"},null)]):n.createVNode("div",{style:k,class:"k-editor-content"},[n.createVNode("div",{ref:d.setRef(this,"contentElement"),role:"textbox","aria-labelledby":this.$props.ariaLabelledBy,"aria-describedby":this.$props.ariaDescribedBy,"aria-label":this.$props.ariaLabel},null)]),C.call(this),E])},methods:{getView(){return this.view},getHTML(){const e=this.getView();return e?T.EditorUtils.getHtml(e.state):""},setHTML(e){const i=this.getView();i&&T.EditorUtils.setHtml(i,e)},focus(){this.getView()&&this.getView().focus()},updateTools(e){this.view=e,this.updateGuid=d.guid()},iframeLoad(){B.firefox&&this.initialize()},initialize(){const e=this.iframe&&this.iframe.contentWindow;if(e){const l=e.document;[P.defaultStyle,P.tablesStyles,this.$props.dir==="rtl"?P.rtlStyles:void 0].forEach(o=>{if(o){const u=l.createElement("style");u.appendChild(l.createTextNode(o)),l.head.appendChild(u)}});const a=l.createElement("meta");a.setAttribute("charset","utf-8"),l.head.appendChild(a),this.contentElement=l.createElement("div"),l.body.appendChild(this.contentElement),this.contentElement.classList.add("k-content"),this.contentElement.setAttribute("role","main")}const i=this.contentElement;if(!i)return;const{preserveWhitespace:s="full"}=this.$props,p=this,m=function(l){p.view=l,p.updateGuid=d.guid()};let f=[new r.Plugin({view:l=>{const a={update:m,destroy:()=>{const o=p.pluginViews.indexOf(a);o>-1&&p.pluginViews.splice(o,1)}};return p.pluginViews.push(a),a},key:new r.PluginKey("toolbar-tools-update-plugin")}),new r.Plugin({filterTransaction:this.filterTransaction,key:new r.PluginKey("onExecute-event-plugin")}),new r.Plugin({key:O.editorPropsKey,state:{init:()=>({preserveWhitespace:s}),apply:(l,a)=>a}}),r.spacesFix(),r.history(),r.dropCursor(),r.gapCursor(),r.tableEditing()],c={...T.EditorUtils.getShortcuts({types:{listItem:"list_item",hardBreak:"hard_break"},toolsSettings:{bold:se,italic:re,underline:ne}}),"Mod-k":()=>{const{linkDialog:l}=this.$data,a=this.getView();if(a){const o=a.state,u=o.selection.empty,h=r.getMark(o,o.schema.marks[D.mark]);!l&&!(u&&!h)&&(this.linkDialog=!0)}return!l}};const{defaultContent:S="",value:E}=this.$props,$=E&&typeof E!="string"?n.toRaw(E):T.EditorUtils.createDocument(new r.Schema({nodes:_.nodes,marks:r.marks}),E||S,{preserveWhitespace:s}),k={state:r.EditorState.create({plugins:[...f,r.keymap(c),r.keymap(r.baseKeymap)],doc:$}),transformPastedHTML:this.onPasteHtml,dispatchTransaction:this.dispatchTransaction,handleDOMEvents:{focus:this.onFocus,blur:this.onBlur,paste:this.onPaste}},C={plugins:f,shortcuts:c,target:p,viewProps:k,dom:i};this.$emit("loaded",C);const V=this.$props.extendView&&this.$props.extendView(C)||new r.EditorView({mount:i},k);this.view=n.markRaw(V)},filterTransaction(e,i){const s={target:this,transaction:e,state:i};return this.$emit("execute",s),!0},onPasteHtml(e){if(this.$props.pasteHtml&&this.pasteEvent){const i={target:this,pastedHtml:e,event:this.pasteEvent},s=this.$props.pasteHtml(i);if(this.pasteEvent=void 0,typeof s=="string")return s}return e},dispatchTransaction(e){const i=e.docChanged;if(i){this.trOnChange=e;const s=e.doc,p=e.doc.type.schema,m=this,f={target:m,value:s,get html(){return m.htmlOnChange=T.EditorUtils.getHtml({doc:s,schema:p}),m.htmlOnChange},transaction:e,schema:p};this.$emit("change",f)}this.getView()&&(this.$props.value===void 0||!i)&&this.getView().updateState(this.getView().state.apply(e))},onFocus(e,i){const s={target:this,event:i};return this.$emit("focus",s),!1},onBlur(e,i){const s={target:this,event:i};return this.$emit("blur",s),!1},onPaste(e,i){return this.$props.pasteHtml&&(this.pasteEvent=i),!1},handleClose(){this.linkDialog=!1},computedValue(){return this.trOnChange!==null?this.trOnChange.doc:this.$props.value!==void 0?this.$props.value:this.getView()?this.getView().state.doc:this.$props.defaultContent||""}}});exports.Editor=le;exports.allTools=b;
|