@mpdev_ab/document-creator 0.2.1 → 0.2.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.
@@ -1 +1 @@
1
- (function(x,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@tiptap/vue-3"),require("@tiptap/starter-kit"),require("@tiptap/extension-text-style"),require("@tiptap/extension-font-family"),require("@tiptap/extension-underline"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-color"),require("@tiptap/extension-text-align"),require("@tiptap/extension-link"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-table"),require("@tiptap/extension-table-row"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/core"),require("@tiptap/extension-image")):typeof define=="function"&&define.amd?define(["exports","vue","@tiptap/vue-3","@tiptap/starter-kit","@tiptap/extension-text-style","@tiptap/extension-font-family","@tiptap/extension-underline","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-color","@tiptap/extension-text-align","@tiptap/extension-link","@tiptap/extension-placeholder","@tiptap/extension-table","@tiptap/extension-table-row","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/core","@tiptap/extension-image"],e):(x=typeof globalThis<"u"?globalThis:x||self,e(x.DocumentCreator={},x.Vue,x.vue3,x.StarterKit,x.extensionTextStyle,x.FontFamily,x.Underline,x.Subscript,x.Superscript,x.Color,x.TextAlign,x.Link,x.Placeholder,x.extensionTable,x.TableRow,x.TableCell,x.TableHeader,x.core,x.Image))})(this,(function(x,e,y,A,z,H,F,D,R,I,O,U,q,P,j,G,K,V,W){"use strict";const J=V.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var o;return((o=t.style.fontSize)==null?void 0:o.replace(/['"]+/g,""))||null},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:o})=>o().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),X=V.Extension.create({name:"lineHeight",addOptions(){return{types:["heading","paragraph"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight||null,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({commands:o})=>this.options.types.every(n=>o.updateAttributes(n,{lineHeight:t})),unsetLineHeight:()=>({commands:t})=>this.options.types.every(o=>t.resetAttributes(o,"lineHeight"))}}}),Y=["src","alt"],Z={key:0,class:"absolute -top-10 left-0 flex items-center gap-1 bg-white border border-gray-200 rounded shadow-md p-1 z-10"},Q=["onClick"],v=e.defineComponent({__name:"ImageResizePopover",props:y.nodeViewProps,setup(t){const o=t,n=e.ref(o.node.attrs.width||""),c=e.ref(o.node.attrs.alt||""),l=e.computed(()=>{const d={};return o.node.attrs.width&&(d.width=o.node.attrs.width),o.node.attrs.height&&(d.height=o.node.attrs.height),d}),s=e.computed(()=>{const d=o.node.attrs.align;return d==="center"?"mx-auto block":d==="right"?"ml-auto block":"block"});function m(){const d=o.getPos();d!=null&&o.editor.commands.setNodeSelection(d)}function r(d){o.updateAttributes({width:d}),n.value=d}function f(d){o.updateAttributes({align:d})}function i(){o.updateAttributes({alt:c.value})}return(d,a)=>(e.openBlock(),e.createBlock(e.unref(y.NodeViewWrapper),{class:e.normalizeClass(["relative inline-block",s.value])},{default:e.withCtx(()=>[e.createElementVNode("img",{src:d.node.attrs.src,alt:d.node.attrs.alt||"",style:e.normalizeStyle(l.value),class:e.normalizeClass(["cursor-pointer max-w-full",d.selected?"ring-2 ring-blue-400":""]),onClick:m},null,14,Y),d.selected?(e.openBlock(),e.createElementBlock("div",Z,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(["25%","50%","75%","100%"],p=>e.createElementVNode("button",{key:p,class:"px-2 py-0.5 text-xs rounded hover:bg-gray-100",onClick:g=>r(p)},e.toDisplayString(p),9,Q)),64)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=p=>n.value=p),class:"w-16 border border-gray-300 rounded px-1 py-0.5 text-xs",placeholder:"e.g. 100%",onKeydown:a[1]||(a[1]=e.withKeys(p=>r(n.value),["enter"]))},null,544),[[e.vModelText,n.value]]),a[9]||(a[9]=e.createElementVNode("span",{class:"w-px h-4 bg-gray-300 mx-1"},null,-1)),e.createElementVNode("button",{class:"px-1 py-0.5 text-xs rounded hover:bg-gray-100",title:"Align left",onClick:a[2]||(a[2]=p=>f("left"))},[...a[6]||(a[6]=[e.createElementVNode("svg",{class:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M3 12h10M3 18h14"})],-1)])]),e.createElementVNode("button",{class:"px-1 py-0.5 text-xs rounded hover:bg-gray-100",title:"Align center",onClick:a[3]||(a[3]=p=>f("center"))},[...a[7]||(a[7]=[e.createElementVNode("svg",{class:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M7 12h10M5 18h14"})],-1)])]),e.createElementVNode("button",{class:"px-1 py-0.5 text-xs rounded hover:bg-gray-100",title:"Align right",onClick:a[4]||(a[4]=p=>f("right"))},[...a[8]||(a[8]=[e.createElementVNode("svg",{class:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M11 12h10M7 18h14"})],-1)])]),a[10]||(a[10]=e.createElementVNode("span",{class:"w-px h-4 bg-gray-300 mx-1"},null,-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[5]||(a[5]=p=>c.value=p),class:"w-20 border border-gray-300 rounded px-1 py-0.5 text-xs",placeholder:"Alt text",onBlur:i,onKeydown:e.withKeys(i,["enter"])},null,544),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0)]),_:1},8,["class"]))}}),_=W.extend({name:"image",addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:o=>o.getAttribute("width")||o.style.width||null,renderHTML:o=>o.width?{style:`width: ${o.width}`}:{}},height:{default:null,parseHTML:o=>o.getAttribute("height")||o.style.height||null,renderHTML:o=>o.height?{style:`height: ${o.height}`}:{}},align:{default:null,parseHTML:o=>o.getAttribute("data-align")||null,renderHTML:o=>{if(!o.align)return{};const n={left:"margin-right: auto",center:"margin-left: auto; margin-right: auto",right:"margin-left: auto"};return{"data-align":o.align,style:`display: block; ${n[o.align]||""}`}}}}},addNodeView(){return y.VueNodeViewRenderer(v)}}).configure({allowBase64:!0,inline:!1}),ee=V.Node.create({name:"video",group:"block",atom:!0,addAttributes(){return{src:{default:null},width:{default:"100%"},height:{default:"315"},frameborder:{default:"0"},allowfullscreen:{default:!0}}},parseHTML(){return[{tag:"iframe[src]"}]},renderHTML({HTMLAttributes:t}){return["div",{class:"video-wrapper"},["iframe",V.mergeAttributes(t)]]},addCommands(){return{setVideo:t=>({commands:o})=>o.insertContent({type:this.name,attrs:t})}}}),N={toolbar:"bg-white border-b border-gray-200 p-2 flex flex-wrap items-center gap-1",toolbarButton:"hover:bg-gray-100 rounded p-1.5 text-gray-600 cursor-pointer",toolbarButtonActive:"bg-blue-100 text-blue-600",editor:"bg-white min-h-[400px] p-4 prose max-w-none focus:outline-none",dropdown:"bg-white border border-gray-200 rounded shadow-lg py-1 z-50",modal:"bg-white rounded-lg shadow-xl p-6",saveButton:"bg-blue-600 text-white rounded px-4 py-2 hover:bg-blue-700"},B={maxSize:5*1024*1024,allowedTypes:["image/jpeg","image/png","image/gif"]},$=["Arial","Times New Roman","Courier New","Georgia","Verdana","Trebuchet MS","Comic Sans MS","Impact"],M=["8","10","12","14","16","18","20","24","28","32","36","48","72"],T=["1","1.15","1.5","2","2.5","3"],S=Symbol("document-editor");function te(){const t=e.inject(S);if(!t)throw new Error("useDocumentEditor must be used within a DocumentEditor component");return{editor:t,getHTML:()=>{var o;return((o=t.value)==null?void 0:o.getHTML())??""},getText:()=>{var o;return((o=t.value)==null?void 0:o.getText())??""},setContent:o=>{var n;return(n=t.value)==null?void 0:n.commands.setContent(o)},focus:()=>{var o;return(o=t.value)==null?void 0:o.commands.focus()},isEmpty:()=>{var o;return((o=t.value)==null?void 0:o.isEmpty)??!0}}}const ne=["title","disabled"],k=e.defineComponent({__name:"ToolbarButton",props:{theme:{},title:{},isActive:{type:Boolean},disabled:{type:Boolean}},emits:["click"],setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("button",{type:"button",class:e.normalizeClass([t.theme.toolbarButton,t.isActive&&t.theme.toolbarButtonActive]),title:t.title,disabled:t.disabled,onClick:n[0]||(n[0]=c=>o.$emit("click"))},[e.renderSlot(o.$slots,"default")],10,ne))}}),oe=(t,o)=>{const n=t.__vccOpts||t;for(const[c,l]of o)n[c]=l;return n},le={},re={class:"w-px h-6 bg-gray-300 mx-1"};function ie(t,o){return e.openBlock(),e.createElementBlock("div",re)}const b=oe(le,[["render",ie]]),ae=["title"],C=e.defineComponent({__name:"ToolbarDropdown",props:{theme:{},label:{},title:{}},setup(t){const o=e.ref(!1),n=e.ref(null);function c(){o.value=!1}function l(s){n.value&&!n.value.contains(s.target)&&(o.value=!1)}return e.onMounted(()=>document.addEventListener("click",l)),e.onBeforeUnmount(()=>document.removeEventListener("click",l)),(s,m)=>(e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"dropdownRef",ref:n},[e.createElementVNode("button",{type:"button",class:e.normalizeClass([t.theme.toolbarButton,"flex items-center gap-1 px-2 text-sm"]),title:t.title,onClick:m[0]||(m[0]=r=>o.value=!o.value)},[e.createElementVNode("span",null,e.toDisplayString(t.label),1),m[1]||(m[1]=e.createElementVNode("svg",{class:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor"},[e.createElementVNode("path",{d:"M2 4l4 4 4-4",stroke:"currentColor","stroke-width":"1.5",fill:"none"})],-1))],10,ae),o.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 min-w-[150px] max-h-60 overflow-y-auto"])},[e.renderSlot(s.$slots,"default",{close:c})],2)):e.createCommentVNode("",!0)],512))}}),se=["onClick"],de=e.defineComponent({__name:"HeadingPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=[{label:"Paragraph",value:"paragraph",class:"text-sm"},{label:"Heading 1",value:1,class:"text-2xl font-bold"},{label:"Heading 2",value:2,class:"text-xl font-bold"},{label:"Heading 3",value:3,class:"text-lg font-bold"},{label:"Heading 4",value:4,class:"text-base font-semibold"},{label:"Heading 5",value:5,class:"text-sm font-semibold"},{label:"Heading 6",value:6,class:"text-xs font-semibold"}];function c(m){var r,f;return m.value==="paragraph"?(r=o.editor)==null?void 0:r.isActive("paragraph"):(f=o.editor)==null?void 0:f.isActive("heading",{level:m.value})}const l=e.computed(()=>{const m=n.find(r=>c(r));return(m==null?void 0:m.label)??"Paragraph"});function s(m){var r,f;m.value==="paragraph"?(r=o.editor)==null||r.chain().focus().setParagraph().run():(f=o.editor)==null||f.chain().focus().toggleHeading({level:m.value}).run()}return(m,r)=>(e.openBlock(),e.createBlock(C,{theme:t.theme,label:l.value,title:"Block type"},{default:e.withCtx(({close:f})=>[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,i=>e.createElementVNode("button",{key:i.value,class:e.normalizeClass(["block w-full text-left px-3 py-1.5 hover:bg-gray-100",i.class,c(i)?"bg-gray-50 font-semibold":""]),onClick:d=>{s(i),f()}},e.toDisplayString(i.label),11,se)),64))]),_:1},8,["theme","label"]))}}),ce=["onClick"],me=e.defineComponent({__name:"FontFamilyPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=$,c=e.computed(()=>{var l;for(const s of n)if((l=o.editor)!=null&&l.isActive("textStyle",{fontFamily:s}))return s;return"Font"});return(l,s)=>(e.openBlock(),e.createBlock(C,{theme:t.theme,label:c.value,title:"Font family"},{default:e.withCtx(({close:m})=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),r=>(e.openBlock(),e.createElementBlock("button",{key:r,style:e.normalizeStyle({fontFamily:r}),class:e.normalizeClass(["block w-full text-left px-3 py-1.5 hover:bg-gray-100 text-sm",c.value===r?"bg-gray-50 font-semibold":""]),onClick:f=>{var i;(i=t.editor)==null||i.chain().focus().setFontFamily(r).run(),m()}},e.toDisplayString(r),15,ce))),128))]),_:1},8,["theme","label"]))}}),fe=["onClick"],pe=e.defineComponent({__name:"FontSizePicker",props:{editor:{},theme:{}},setup(t){const o=t,n=M,c=e.computed(()=>{var l;for(const s of n)if((l=o.editor)!=null&&l.isActive("textStyle",{fontSize:s+"px"}))return s;return""});return(l,s)=>(e.openBlock(),e.createBlock(C,{theme:t.theme,label:c.value||"Size",title:"Font size"},{default:e.withCtx(({close:m})=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),r=>(e.openBlock(),e.createElementBlock("button",{key:r,class:e.normalizeClass(["block w-full text-left px-3 py-1.5 hover:bg-gray-100 text-sm",c.value===r?"bg-gray-50 font-semibold":""]),onClick:f=>{var i;(i=t.editor)==null||i.chain().focus().setFontSize(r+"px").run(),m()}},e.toDisplayString(r),11,fe))),128))]),_:1},8,["theme","label"]))}}),ue={class:"grid grid-cols-8 gap-1 mb-2"},he=["title","onClick"],ge={class:"flex items-center gap-2 pt-2 border-t border-gray-100"},xe=["value"],ke=e.defineComponent({__name:"ColorPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=e.ref(!1),c=e.ref(null),l=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd"],s=e.computed(()=>{var f;return((f=o.editor)==null?void 0:f.getAttributes("textStyle").color)||"#000000"});function m(f){var i;(i=o.editor)==null||i.chain().focus().setColor(f).run(),n.value=!1}function r(f){c.value&&!c.value.contains(f.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",r)),e.onBeforeUnmount(()=>document.removeEventListener("click",r)),(f,i)=>(e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"pickerRef",ref:c},[e.createElementVNode("button",{type:"button",class:e.normalizeClass([t.theme.toolbarButton,"flex items-center gap-1 px-2"]),title:"Font color",onClick:i[0]||(i[0]=d=>n.value=!n.value)},[i[2]||(i[2]=e.createElementVNode("span",null,"A",-1)),e.createElementVNode("div",{class:"w-4 h-1 rounded",style:e.normalizeStyle({backgroundColor:s.value})},null,4)],2),n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 p-2 w-48"])},[e.createElementVNode("div",ue,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,d=>e.createElementVNode("button",{key:d,class:"w-5 h-5 rounded border border-gray-200 cursor-pointer hover:scale-110 transition-transform",style:e.normalizeStyle({backgroundColor:d}),title:d,onClick:a=>m(d)},null,12,he)),64))]),e.createElementVNode("div",ge,[i[3]||(i[3]=e.createElementVNode("label",{class:"text-xs text-gray-500"},"Custom:",-1)),e.createElementVNode("input",{type:"color",value:s.value,class:"w-6 h-6 cursor-pointer",onInput:i[1]||(i[1]=d=>m(d.target.value))},null,40,xe)])],2)):e.createCommentVNode("",!0)],512))}}),be=e.defineComponent({__name:"AlignmentButtons",props:{editor:{},theme:{}},setup(t){return(o,n)=>{var c,l,s,m;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(k,{theme:t.theme,title:"Align left","is-active":(c=t.editor)==null?void 0:c.isActive({textAlign:"left"}),onClick:n[0]||(n[0]=r=>{var f;return(f=t.editor)==null?void 0:f.chain().focus().setTextAlign("left").run()})},{default:e.withCtx(()=>[...n[4]||(n[4]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M3 12h10M3 18h14"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Align center","is-active":(l=t.editor)==null?void 0:l.isActive({textAlign:"center"}),onClick:n[1]||(n[1]=r=>{var f;return(f=t.editor)==null?void 0:f.chain().focus().setTextAlign("center").run()})},{default:e.withCtx(()=>[...n[5]||(n[5]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M7 12h10M5 18h14"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Align right","is-active":(s=t.editor)==null?void 0:s.isActive({textAlign:"right"}),onClick:n[2]||(n[2]=r=>{var f;return(f=t.editor)==null?void 0:f.chain().focus().setTextAlign("right").run()})},{default:e.withCtx(()=>[...n[6]||(n[6]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M11 12h10M7 18h14"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Justify","is-active":(m=t.editor)==null?void 0:m.isActive({textAlign:"justify"}),onClick:n[3]||(n[3]=r=>{var f;return(f=t.editor)==null?void 0:f.chain().focus().setTextAlign("justify").run()})},{default:e.withCtx(()=>[...n[7]||(n[7]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M3 12h18M3 18h18"})],-1)])]),_:1},8,["theme","is-active"])],64)}}}),ye=["onClick"],Ee=e.defineComponent({__name:"LineHeightPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=T,c=e.computed(()=>{var l,s;return((l=o.editor)==null?void 0:l.getAttributes("paragraph").lineHeight)||((s=o.editor)==null?void 0:s.getAttributes("heading").lineHeight)||""});return(l,s)=>(e.openBlock(),e.createBlock(C,{theme:t.theme,label:c.value||"Height",title:"Line height"},{default:e.withCtx(({close:m})=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),r=>(e.openBlock(),e.createElementBlock("button",{key:r,class:e.normalizeClass(["block w-full text-left px-3 py-1.5 hover:bg-gray-100 text-sm",c.value===r?"bg-gray-50 font-semibold":""]),onClick:f=>{var i;(i=t.editor)==null||i.chain().focus().setLineHeight(r).run(),m()}},e.toDisplayString(r),11,ye))),128))]),_:1},8,["theme","label"]))}}),Ve={class:"flex gap-2"},Ce=e.defineComponent({__name:"LinkButton",props:{editor:{},theme:{}},setup(t){const o=t,n=e.ref(!1),c=e.ref(""),l=e.ref(null),s=e.ref(null);function m(){var d;c.value=((d=o.editor)==null?void 0:d.getAttributes("link").href)||"",n.value=!n.value,n.value&&e.nextTick(()=>{var a;return(a=s.value)==null?void 0:a.focus()})}function r(){var d;c.value&&((d=o.editor)==null||d.chain().focus().extendMarkRange("link").setLink({href:c.value}).run()),n.value=!1}function f(){var d;(d=o.editor)==null||d.chain().focus().unsetLink().run(),n.value=!1}function i(d){l.value&&!l.value.contains(d.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",i)),e.onBeforeUnmount(()=>document.removeEventListener("click",i)),(d,a)=>{var p,g;return e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"linkRef",ref:l},[e.createVNode(k,{theme:t.theme,title:"Link","is-active":(p=t.editor)==null?void 0:p.isActive("link"),onClick:m},{default:e.withCtx(()=>[...a[2]||(a[2]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.createElementVNode("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)])]),_:1},8,["theme","is-active"]),n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 p-3 w-72"])},[a[3]||(a[3]=e.createElementVNode("label",{class:"block text-xs text-gray-500 mb-1"},"URL",-1)),e.withDirectives(e.createElementVNode("input",{ref_key:"urlInput",ref:s,"onUpdate:modelValue":a[0]||(a[0]=h=>c.value=h),type:"url",placeholder:"https://example.com",class:"w-full border border-gray-300 rounded px-2 py-1 text-sm mb-2",onKeydown:e.withKeys(r,["enter"])},null,544),[[e.vModelText,c.value]]),e.createElementVNode("div",Ve,[e.createElementVNode("button",{class:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700",onClick:r}," Apply "),(g=t.editor)!=null&&g.isActive("link")?(e.openBlock(),e.createElementBlock("button",{key:0,class:"px-3 py-1 text-sm bg-red-100 text-red-600 rounded hover:bg-red-200",onClick:f}," Remove ")):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"px-3 py-1 text-sm text-gray-500 hover:text-gray-700",onClick:a[1]||(a[1]=h=>n.value=!1)}," Cancel ")])],2)):e.createCommentVNode("",!0)],512)}}}),we=["accept"],Ne=e.defineComponent({__name:"ImageUploadButton",props:{editor:{},theme:{},imageConfig:{}},emits:["error"],setup(t,{emit:o}){const n=t,c=o,l=e.ref(null),s=e.computed(()=>({...B,...n.imageConfig})),m=e.computed(()=>s.value.allowedTypes.join(","));function r(){var i;(i=l.value)==null||i.click()}function f(i){var g;const d=i.target,a=(g=d.files)==null?void 0:g[0];if(!a)return;if(!s.value.allowedTypes.includes(a.type)){c("error",{message:`File type ${a.type} is not allowed`,detail:{allowedTypes:s.value.allowedTypes}}),d.value="";return}if(a.size>s.value.maxSize){const h=(s.value.maxSize/1048576).toFixed(1);c("error",{message:`File size exceeds ${h}MB limit`,detail:{maxSize:s.value.maxSize,fileSize:a.size}}),d.value="";return}const p=new FileReader;p.onload=()=>{var u;const h=p.result;(u=n.editor)==null||u.chain().focus().setImage({src:h}).run()},p.readAsDataURL(a),d.value=""}return(i,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(k,{theme:t.theme,title:"Insert image",onClick:r},{default:e.withCtx(()=>[...d[0]||(d[0]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.createElementVNode("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.createElementVNode("path",{d:"M21 15l-5-5L5 21"})],-1)])]),_:1},8,["theme"]),e.createElementVNode("input",{ref_key:"fileInput",ref:l,type:"file",accept:m.value,class:"hidden",onChange:f},null,40,we)],64))}}),Be={class:"mb-1 text-xs text-gray-500 text-center"},$e=["onMouseenter"],Me=8,L=10,Te=e.defineComponent({__name:"TableGridPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=e.ref(!1),c=e.ref(0),l=e.ref(0),s=e.ref(null);function m(f,i){var d;(d=o.editor)==null||d.chain().focus().insertTable({rows:f,cols:i,withHeaderRow:!0}).run(),n.value=!1,c.value=0,l.value=0}function r(f){s.value&&!s.value.contains(f.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",r)),e.onBeforeUnmount(()=>document.removeEventListener("click",r)),(f,i)=>(e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"pickerRef",ref:s},[e.createVNode(k,{theme:t.theme,title:"Insert table",onClick:i[0]||(i[0]=d=>n.value=!n.value)},{default:e.withCtx(()=>[...i[2]||(i[2]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("rect",{x:"3",y:"3",width:"18",height:"18",rx:"1"}),e.createElementVNode("path",{d:"M3 9h18M3 15h18M9 3v18M15 3v18"})],-1)])]),_:1},8,["theme"]),n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 p-2"])},[e.createElementVNode("div",Be,e.toDisplayString(l.value>0?`${l.value} × ${c.value}`:"Select size"),1),e.createElementVNode("div",{class:"grid gap-0.5",style:e.normalizeStyle({gridTemplateColumns:`repeat(${L}, 1fr)`})},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(Me,d=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:"row-"+d},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(L,a=>e.createElementVNode("div",{key:"cell-"+d+"-"+a,class:e.normalizeClass(["w-5 h-5 border cursor-pointer",d<=c.value&&a<=l.value?"bg-blue-200 border-blue-300":"bg-white border-gray-300"]),onMouseenter:p=>{c.value=d,l.value=a},onClick:i[1]||(i[1]=p=>m(c.value,l.value))},null,42,$e)),64))],64))),64))],4)],2)):e.createCommentVNode("",!0)],512))}}),Se={class:"flex gap-2"},Le=e.defineComponent({__name:"VideoEmbedButton",props:{editor:{},theme:{}},setup(t){const o=t,n=e.ref(!1),c=e.ref(""),l=e.ref(null);function s(f){const i=f.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/);if(i)return`https://www.youtube.com/embed/${i[1]}`;const d=f.match(/vimeo\.com\/(\d+)/);return d?`https://player.vimeo.com/video/${d[1]}`:f}function m(){var f;if(c.value){const i=s(c.value);(f=o.editor)==null||f.chain().focus().setVideo({src:i}).run()}n.value=!1,c.value=""}function r(f){l.value&&!l.value.contains(f.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",r)),e.onBeforeUnmount(()=>document.removeEventListener("click",r)),(f,i)=>(e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"videoRef",ref:l},[e.createVNode(k,{theme:t.theme,title:"Embed video",onClick:i[0]||(i[0]=d=>n.value=!n.value)},{default:e.withCtx(()=>[...i[3]||(i[3]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("polygon",{points:"5,3 19,12 5,21"})],-1)])]),_:1},8,["theme"]),n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 p-3 w-80"])},[i[4]||(i[4]=e.createElementVNode("label",{class:"block text-xs text-gray-500 mb-1"},"Video URL (YouTube, Vimeo)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":i[1]||(i[1]=d=>c.value=d),type:"url",placeholder:"https://www.youtube.com/watch?v=...",class:"w-full border border-gray-300 rounded px-2 py-1 text-sm mb-2",onKeydown:e.withKeys(m,["enter"])},null,544),[[e.vModelText,c.value]]),e.createElementVNode("div",Se,[e.createElementVNode("button",{class:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700",onClick:m}," Embed "),e.createElementVNode("button",{class:"px-3 py-1 text-sm text-gray-500 hover:text-gray-700",onClick:i[2]||(i[2]=d=>n.value=!1)}," Cancel ")])],2)):e.createCommentVNode("",!0)],512))}}),Ae=e.defineComponent({__name:"EditorToolbar",props:{editor:{},theme:{},imageConfig:{}},emits:["saveTemplate","loadTemplate","save","error"],setup(t){return(o,n)=>{var c,l,s,m,r,f,i,d,a,p,g;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(t.theme.toolbar)},[e.createVNode(k,{theme:t.theme,title:"Undo",onClick:n[0]||(n[0]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().undo().run()}),disabled:!((c=t.editor)!=null&&c.can().undo())},{default:e.withCtx(()=>[...n[16]||(n[16]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 10h10a5 5 0 0 1 0 10H9"}),e.createElementVNode("path",{d:"M3 10l4-4M3 10l4 4"})],-1)])]),_:1},8,["theme","disabled"]),e.createVNode(k,{theme:t.theme,title:"Redo",onClick:n[1]||(n[1]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().redo().run()}),disabled:!((l=t.editor)!=null&&l.can().redo())},{default:e.withCtx(()=>[...n[17]||(n[17]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M21 10H11a5 5 0 0 0 0 10h4"}),e.createElementVNode("path",{d:"M21 10l-4-4M21 10l-4 4"})],-1)])]),_:1},8,["theme","disabled"]),e.createVNode(b),e.createVNode(de,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(me,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(pe,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(k,{theme:t.theme,title:"Bold","is-active":(s=t.editor)==null?void 0:s.isActive("bold"),onClick:n[2]||(n[2]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleBold().run()})},{default:e.withCtx(()=>[...n[18]||(n[18]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M6 4h8a4 4 0 0 1 0 8H6V4zm0 8h9a4.5 4.5 0 0 1 0 9H6v-9z"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Italic","is-active":(m=t.editor)==null?void 0:m.isActive("italic"),onClick:n[3]||(n[3]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleItalic().run()})},{default:e.withCtx(()=>[...n[19]||(n[19]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M10 4h4M14 4l-4 16M6 20h4"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Underline","is-active":(r=t.editor)==null?void 0:r.isActive("underline"),onClick:n[4]||(n[4]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleUnderline().run()})},{default:e.withCtx(()=>[...n[20]||(n[20]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M6 4v6a6 6 0 0 0 12 0V4M4 20h16"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Strikethrough","is-active":(f=t.editor)==null?void 0:f.isActive("strike"),onClick:n[5]||(n[5]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleStrike().run()})},{default:e.withCtx(()=>[...n[21]||(n[21]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M4 12h16M7 5c0 0 1-1 5-1s5 2 5 4-2 3-5 3M7 19c0 0 1 1 5 1s5-2 5-4"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Subscript","is-active":(i=t.editor)==null?void 0:i.isActive("subscript"),onClick:n[6]||(n[6]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleSubscript().run()})},{default:e.withCtx(()=>[...n[22]||(n[22]=[e.createElementVNode("span",{class:"text-xs font-semibold"},[e.createTextVNode("X"),e.createElementVNode("sub",null,"2")],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Superscript","is-active":(d=t.editor)==null?void 0:d.isActive("superscript"),onClick:n[7]||(n[7]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleSuperscript().run()})},{default:e.withCtx(()=>[...n[23]||(n[23]=[e.createElementVNode("span",{class:"text-xs font-semibold"},[e.createTextVNode("X"),e.createElementVNode("sup",null,"2")],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(ke,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(be,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(Ee,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(k,{theme:t.theme,title:"Bullet list","is-active":(a=t.editor)==null?void 0:a.isActive("bulletList"),onClick:n[8]||(n[8]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleBulletList().run()})},{default:e.withCtx(()=>[...n[24]||(n[24]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("circle",{cx:"4",cy:"6",r:"1.5",fill:"currentColor"}),e.createElementVNode("path",{d:"M9 6h12"}),e.createElementVNode("circle",{cx:"4",cy:"12",r:"1.5",fill:"currentColor"}),e.createElementVNode("path",{d:"M9 12h12"}),e.createElementVNode("circle",{cx:"4",cy:"18",r:"1.5",fill:"currentColor"}),e.createElementVNode("path",{d:"M9 18h12"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Numbered list","is-active":(p=t.editor)==null?void 0:p.isActive("orderedList"),onClick:n[9]||(n[9]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleOrderedList().run()})},{default:e.withCtx(()=>[...n[25]||(n[25]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("text",{x:"2",y:"8","font-size":"7",fill:"currentColor",stroke:"none"},"1"),e.createElementVNode("path",{d:"M9 6h12"}),e.createElementVNode("text",{x:"2",y:"14","font-size":"7",fill:"currentColor",stroke:"none"},"2"),e.createElementVNode("path",{d:"M9 12h12"}),e.createElementVNode("text",{x:"2",y:"20","font-size":"7",fill:"currentColor",stroke:"none"},"3"),e.createElementVNode("path",{d:"M9 18h12"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Blockquote","is-active":(g=t.editor)==null?void 0:g.isActive("blockquote"),onClick:n[10]||(n[10]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleBlockquote().run()})},{default:e.withCtx(()=>[...n[26]||(n[26]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor"},[e.createElementVNode("path",{d:"M3 3h8v8H3zM13 3h8v8h-8zM5 11l-2 6h4l2-6zM15 11l-2 6h4l2-6z",opacity:"0.6"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Horizontal rule",onClick:n[11]||(n[11]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().setHorizontalRule().run()})},{default:e.withCtx(()=>[...n[27]||(n[27]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 12h18"})],-1)])]),_:1},8,["theme"]),e.createVNode(b),e.createVNode(Ce,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(Ne,{editor:t.editor,theme:t.theme,"image-config":t.imageConfig,onError:n[12]||(n[12]=h=>o.$emit("error",h))},null,8,["editor","theme","image-config"]),e.createVNode(Te,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(Le,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(k,{theme:t.theme,title:"Save as template",onClick:n[13]||(n[13]=h=>o.$emit("saveTemplate"))},{default:e.withCtx(()=>[...n[28]||(n[28]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),e.createElementVNode("polyline",{points:"17,21 17,13 7,13 7,21"}),e.createElementVNode("polyline",{points:"7,3 7,8 15,8"})],-1)])]),_:1},8,["theme"]),e.createVNode(k,{theme:t.theme,title:"Load template",onClick:n[14]||(n[14]=h=>o.$emit("loadTemplate"))},{default:e.withCtx(()=>[...n[29]||(n[29]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})],-1)])]),_:1},8,["theme"]),e.createVNode(b),e.createElementVNode("button",{class:e.normalizeClass(t.theme.saveButton),onClick:n[15]||(n[15]=h=>o.$emit("save"))}," Save ",2)],2)}}}),ze={key:0,class:"bg-white border border-gray-200 rounded-lg shadow-lg p-2 flex flex-wrap gap-1 mb-1"},He={class:"flex gap-1"},Fe={class:"flex gap-1"},De={class:"flex gap-1"},Re={class:"flex gap-1 items-center"},Ie=e.defineComponent({__name:"TablePopoverMenu",props:{editor:{}},setup(t){const o=t;function n(c){var l;(l=o.editor)==null||l.chain().focus().setCellAttribute("backgroundColor",c).run()}return(c,l)=>{var s;return(s=t.editor)!=null&&s.isActive("table")?(e.openBlock(),e.createElementBlock("div",ze,[e.createElementVNode("div",He,[e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[0]||(l[0]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().addRowBefore().run()})}," + Row Above "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[1]||(l[1]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().addRowAfter().run()})}," + Row Below "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-red-50 text-red-600",onClick:l[2]||(l[2]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().deleteRow().run()})}," Delete Row ")]),l[12]||(l[12]=e.createElementVNode("span",{class:"w-px h-6 bg-gray-300"},null,-1)),e.createElementVNode("div",Fe,[e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[3]||(l[3]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().addColumnBefore().run()})}," + Col Left "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[4]||(l[4]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().addColumnAfter().run()})}," + Col Right "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-red-50 text-red-600",onClick:l[5]||(l[5]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().deleteColumn().run()})}," Delete Col ")]),l[13]||(l[13]=e.createElementVNode("span",{class:"w-px h-6 bg-gray-300"},null,-1)),e.createElementVNode("div",De,[e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[6]||(l[6]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().mergeCells().run()})}," Merge "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[7]||(l[7]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().splitCell().run()})}," Split ")]),l[14]||(l[14]=e.createElementVNode("span",{class:"w-px h-6 bg-gray-300"},null,-1)),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[8]||(l[8]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().toggleHeaderRow().run()})}," Toggle Header "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-red-50 text-red-600",onClick:l[9]||(l[9]=m=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().deleteTable().run()})}," Delete Table "),l[15]||(l[15]=e.createElementVNode("span",{class:"w-px h-6 bg-gray-300"},null,-1)),e.createElementVNode("div",Re,[l[11]||(l[11]=e.createElementVNode("label",{class:"text-xs text-gray-500"},"Cell BG:",-1)),e.createElementVNode("input",{type:"color",class:"w-5 h-5 cursor-pointer",onInput:l[10]||(l[10]=m=>n(m.target.value))},null,32)])])):e.createCommentVNode("",!0)}}}),Oe={class:"mb-3"},Ue={class:"mb-4"},qe={class:"flex gap-4"},Pe={class:"flex items-center gap-2 text-sm"},je={class:"flex items-center gap-2 text-sm"},Ge={class:"flex justify-end gap-2"},Ke=["disabled"],We=e.defineComponent({__name:"SaveTemplateModal",props:{theme:{}},emits:["save"],setup(t,{expose:o,emit:n}){const c=n,l=e.ref(!1),s=e.ref(""),m=e.ref("document");function r(){s.value="",m.value="document",l.value=!0}function f(){l.value=!1}function i(){c("save",{name:s.value.trim(),type:m.value}),f()}return o({open:r,close:f}),(d,a)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e.withModifiers(f,["self"])},[e.createElementVNode("div",{class:e.normalizeClass([t.theme.modal,"w-96"])},[a[7]||(a[7]=e.createElementVNode("h2",{class:"text-lg font-semibold mb-4"},"Save as Template",-1)),e.createElementVNode("div",Oe,[a[3]||(a[3]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Template Name",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=p=>s.value=p),type:"text",class:"w-full border border-gray-300 rounded px-3 py-2 text-sm",placeholder:"My Template"},null,512),[[e.vModelText,s.value]])]),e.createElementVNode("div",Ue,[a[6]||(a[6]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Type",-1)),e.createElementVNode("div",qe,[e.createElementVNode("label",Pe,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[1]||(a[1]=p=>m.value=p),type:"radio",value:"document"},null,512),[[e.vModelRadio,m.value]]),a[4]||(a[4]=e.createTextVNode(" Full Document ",-1))]),e.createElementVNode("label",je,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[2]||(a[2]=p=>m.value=p),type:"radio",value:"snippet"},null,512),[[e.vModelRadio,m.value]]),a[5]||(a[5]=e.createTextVNode(" Snippet ",-1))])])]),e.createElementVNode("div",Ge,[e.createElementVNode("button",{class:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800",onClick:f},"Cancel"),e.createElementVNode("button",{class:e.normalizeClass(t.theme.saveButton),disabled:!s.value.trim(),onClick:i},"Save",10,Ke)])],2)])):e.createCommentVNode("",!0)]))}}),Je={key:0,class:"text-center py-8 text-gray-500"},Xe={key:1,class:"text-center py-8 text-gray-500"},Ye={key:2,class:"overflow-y-auto flex-1 -mx-6 px-6"},Ze=["onClick"],Qe={class:"font-medium text-sm"},ve=["onClick"],_e=e.defineComponent({__name:"LoadTemplateModal",props:{theme:{},templates:{},loading:{type:Boolean}},emits:["select","delete","load"],setup(t,{expose:o,emit:n}){const c=n,l=e.ref(!1);function s(){l.value=!0,c("load")}function m(){l.value=!1}function r(i){c("select",i),m()}function f(i){confirm(`Delete template "${i.name}"?`)&&c("delete",i)}return o({open:s,close:m}),(i,d)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e.withModifiers(m,["self"])},[e.createElementVNode("div",{class:e.normalizeClass([t.theme.modal,"w-[500px] max-h-[80vh] flex flex-col"])},[d[0]||(d[0]=e.createElementVNode("h2",{class:"text-lg font-semibold mb-4"},"Load Template",-1)),t.loading?(e.openBlock(),e.createElementBlock("div",Je,"Loading templates...")):t.templates.length===0?(e.openBlock(),e.createElementBlock("div",Xe,"No templates found")):(e.openBlock(),e.createElementBlock("div",Ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.templates,a=>(e.openBlock(),e.createElementBlock("div",{key:a.id,class:"flex items-center justify-between p-3 border border-gray-200 rounded mb-2 hover:bg-gray-50 cursor-pointer group",onClick:p=>r(a)},[e.createElementVNode("div",null,[e.createElementVNode("div",Qe,e.toDisplayString(a.name),1),e.createElementVNode("span",{class:e.normalizeClass(["inline-block text-xs px-2 py-0.5 rounded mt-1",a.type==="document"?"bg-blue-100 text-blue-700":"bg-green-100 text-green-700"])},e.toDisplayString(a.type==="document"?"Document":"Snippet"),3)]),e.createElementVNode("button",{class:"text-red-400 hover:text-red-600 opacity-0 group-hover:opacity-100 text-sm px-2",onClick:e.withModifiers(p=>f(a),["stop"])}," Delete ",8,ve)],8,Ze))),128))])),e.createElementVNode("div",{class:"flex justify-end pt-4"},[e.createElementVNode("button",{class:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800",onClick:m},"Cancel")])],2)])):e.createCommentVNode("",!0)]))}}),et={class:"border border-gray-200 rounded-lg overflow-hidden"},tt=e.defineComponent({__name:"DocumentEditor",props:{modelValue:{},templates:{},templatesLoading:{type:Boolean},image:{},theme:{},placeholder:{default:""},readonly:{type:Boolean,default:!1}},emits:["update:modelValue","save","saveTemplate","loadTemplates","deleteTemplate","error"],setup(t,{emit:o}){const n=t,c=o,l=e.computed(()=>({...N,...n.theme})),s=y.useEditor({content:n.modelValue,editable:!n.readonly,extensions:[A,z.TextStyle,H,J,F,D,R,I.configure({types:["textStyle"]}),O.configure({types:["heading","paragraph"]}),X,U.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),_,P.Table.configure({resizable:!0}),j,G,K,ee,q.configure({placeholder:n.placeholder||"Start typing..."})],onUpdate:()=>{var p;c("update:modelValue",((p=s.value)==null?void 0:p.getHTML())??"")}});e.provide(S,s),e.watch(()=>n.modelValue,p=>{var g,h;((g=s.value)==null?void 0:g.getHTML())!==p&&((h=s.value)==null||h.commands.setContent(p,{emitUpdate:!1}))}),e.watch(()=>n.readonly,p=>{var g;(g=s.value)==null||g.setEditable(!p)});function m(p){c("error",p)}const r=e.ref(null),f=e.ref(null);function i(p){var u,E,w;const g=((u=s.value)==null?void 0:u.getHTML())??"",h=p.type==="snippet"&&((E=s.value)!=null&&E.state.selection.content())&&((w=s.value)==null?void 0:w.state.selection.content().content.textBetween(0,s.value.state.selection.content().content.size))||g;c("saveTemplate",{name:p.name,type:p.type,content:h})}function d(p){var g,h,u,E;if(p.type==="document"){if(((g=s.value)==null?void 0:g.getHTML())!=="<p></p>"&&((h=s.value)==null?void 0:h.getHTML())!==""&&!confirm("Replace current content with this template?"))return;(u=s.value)==null||u.commands.setContent(p.content)}else(E=s.value)==null||E.commands.insertContent(p.content)}function a(){var g;const p=((g=s.value)==null?void 0:g.getHTML())??"";c("save",p)}return(p,g)=>(e.openBlock(),e.createElementBlock("div",et,[n.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(Ae,{editor:e.unref(s),theme:l.value,"image-config":n.image,onSaveTemplate:g[0]||(g[0]=h=>{var u;return(u=r.value)==null?void 0:u.open()}),onLoadTemplate:g[1]||(g[1]=h=>{var u;return(u=f.value)==null?void 0:u.open()}),onSave:a,onError:m},null,8,["editor","theme","image-config"]),e.createVNode(Ie,{editor:e.unref(s)},null,8,["editor"])],64)),e.createVNode(e.unref(y.EditorContent),{editor:e.unref(s),class:e.normalizeClass(l.value.editor)},null,8,["editor","class"]),e.createVNode(We,{ref_key:"saveTemplateModal",ref:r,theme:l.value,onSave:i},null,8,["theme"]),e.createVNode(_e,{ref_key:"loadTemplateModal",ref:f,theme:l.value,templates:n.templates??[],loading:n.templatesLoading??!1,onLoad:g[2]||(g[2]=h=>c("loadTemplates")),onSelect:d,onDelete:g[3]||(g[3]=h=>c("deleteTemplate",h))},null,8,["theme","templates","loading"])]))}});x.DEFAULT_IMAGE_CONFIG=B,x.DEFAULT_THEME=N,x.DocumentEditor=tt,x.FONT_SIZES=M,x.LINE_HEIGHTS=T,x.WEB_SAFE_FONTS=$,x.useDocumentEditor=te,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(x,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@tiptap/vue-3"),require("@tiptap/starter-kit"),require("@tiptap/extension-text-style"),require("@tiptap/extension-font-family"),require("@tiptap/extension-underline"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-color"),require("@tiptap/extension-text-align"),require("@tiptap/extension-link"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-table"),require("@tiptap/extension-table-row"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/core"),require("@tiptap/extension-image")):typeof define=="function"&&define.amd?define(["exports","vue","@tiptap/vue-3","@tiptap/starter-kit","@tiptap/extension-text-style","@tiptap/extension-font-family","@tiptap/extension-underline","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-color","@tiptap/extension-text-align","@tiptap/extension-link","@tiptap/extension-placeholder","@tiptap/extension-table","@tiptap/extension-table-row","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/core","@tiptap/extension-image"],e):(x=typeof globalThis<"u"?globalThis:x||self,e(x.DocumentCreator={},x.Vue,x.vue3,x.StarterKit,x.extensionTextStyle,x.FontFamily,x.Underline,x.Subscript,x.Superscript,x.Color,x.TextAlign,x.Link,x.Placeholder,x.extensionTable,x.TableRow,x.TableCell,x.TableHeader,x.core,x.Image))})(this,(function(x,e,y,z,H,F,D,I,R,O,U,q,P,j,G,K,W,C,J){"use strict";const X=K.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),backgroundColor:{default:null,parseHTML:o=>o.style.backgroundColor||o.getAttribute("data-background-color")||null,renderHTML:o=>o.backgroundColor?{style:`background-color: ${o.backgroundColor}`}:{}}}}}),Y=W.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),backgroundColor:{default:null,parseHTML:o=>o.style.backgroundColor||o.getAttribute("data-background-color")||null,renderHTML:o=>o.backgroundColor?{style:`background-color: ${o.backgroundColor}`}:{}}}}}),Z=C.Extension.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var o;return((o=t.style.fontSize)==null?void 0:o.replace(/['"]+/g,""))||null},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:o})=>o().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Q=C.Extension.create({name:"lineHeight",addOptions(){return{types:["heading","paragraph"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight||null,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({commands:o})=>this.options.types.every(n=>o.updateAttributes(n,{lineHeight:t})),unsetLineHeight:()=>({commands:t})=>this.options.types.every(o=>t.resetAttributes(o,"lineHeight"))}}}),v=["src","alt"],_={key:0,class:"absolute -top-10 left-0 flex items-center gap-1 bg-white border border-gray-200 rounded shadow-md p-1 z-10"},ee=["onClick"],te=e.defineComponent({__name:"ImageResizePopover",props:y.nodeViewProps,setup(t){const o=t,n=e.ref(o.node.attrs.width||""),m=e.ref(o.node.attrs.alt||""),l=e.computed(()=>{const a={};return o.node.attrs.width&&(a.width=o.node.attrs.width),o.node.attrs.height&&(a.height=o.node.attrs.height),a}),s=e.computed(()=>{const a=o.node.attrs.align;return a==="center"?"mx-auto block":a==="right"?"ml-auto block":"block"});function d(){const a=o.getPos();a!=null&&o.editor.commands.setNodeSelection(a)}function r(a){o.updateAttributes({width:a}),n.value=a}function f(a){o.updateAttributes({align:a})}function i(){o.updateAttributes({alt:m.value})}return(a,c)=>(e.openBlock(),e.createBlock(e.unref(y.NodeViewWrapper),{class:e.normalizeClass(["relative inline-block",s.value])},{default:e.withCtx(()=>[e.createElementVNode("img",{src:a.node.attrs.src,alt:a.node.attrs.alt||"",style:e.normalizeStyle(l.value),class:e.normalizeClass(["cursor-pointer max-w-full",a.selected?"ring-2 ring-blue-400":""]),onClick:d},null,14,v),a.selected?(e.openBlock(),e.createElementBlock("div",_,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(["25%","50%","75%","100%"],p=>e.createElementVNode("button",{key:p,class:"px-2 py-0.5 text-xs rounded hover:bg-gray-100",onClick:g=>r(p)},e.toDisplayString(p),9,ee)),64)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[0]||(c[0]=p=>n.value=p),class:"w-16 border border-gray-300 rounded px-1 py-0.5 text-xs",placeholder:"e.g. 100%",onKeydown:c[1]||(c[1]=e.withKeys(p=>r(n.value),["enter"]))},null,544),[[e.vModelText,n.value]]),c[9]||(c[9]=e.createElementVNode("span",{class:"w-px h-4 bg-gray-300 mx-1"},null,-1)),e.createElementVNode("button",{class:"px-1 py-0.5 text-xs rounded hover:bg-gray-100",title:"Align left",onClick:c[2]||(c[2]=p=>f("left"))},[...c[6]||(c[6]=[e.createElementVNode("svg",{class:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M3 12h10M3 18h14"})],-1)])]),e.createElementVNode("button",{class:"px-1 py-0.5 text-xs rounded hover:bg-gray-100",title:"Align center",onClick:c[3]||(c[3]=p=>f("center"))},[...c[7]||(c[7]=[e.createElementVNode("svg",{class:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M7 12h10M5 18h14"})],-1)])]),e.createElementVNode("button",{class:"px-1 py-0.5 text-xs rounded hover:bg-gray-100",title:"Align right",onClick:c[4]||(c[4]=p=>f("right"))},[...c[8]||(c[8]=[e.createElementVNode("svg",{class:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M11 12h10M7 18h14"})],-1)])]),c[10]||(c[10]=e.createElementVNode("span",{class:"w-px h-4 bg-gray-300 mx-1"},null,-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[5]||(c[5]=p=>m.value=p),class:"w-20 border border-gray-300 rounded px-1 py-0.5 text-xs",placeholder:"Alt text",onBlur:i,onKeydown:e.withKeys(i,["enter"])},null,544),[[e.vModelText,m.value]])])):e.createCommentVNode("",!0)]),_:1},8,["class"]))}}),ne=J.extend({name:"image",addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:o=>o.getAttribute("width")||o.style.width||null,renderHTML:o=>o.width?{style:`width: ${o.width}`}:{}},height:{default:null,parseHTML:o=>o.getAttribute("height")||o.style.height||null,renderHTML:o=>o.height?{style:`height: ${o.height}`}:{}},align:{default:null,parseHTML:o=>o.getAttribute("data-align")||null,renderHTML:o=>{if(!o.align)return{};const n={left:"margin-right: auto",center:"margin-left: auto; margin-right: auto",right:"margin-left: auto"};return{"data-align":o.align,style:`display: block; ${n[o.align]||""}`}}}}},addNodeView(){return y.VueNodeViewRenderer(te)}}).configure({allowBase64:!0,inline:!1}),oe=C.Node.create({name:"video",group:"block",atom:!0,addAttributes(){return{src:{default:null},width:{default:"100%"},height:{default:"315"},frameborder:{default:"0"},allowfullscreen:{default:!0}}},parseHTML(){return[{tag:"iframe[src]"}]},renderHTML({HTMLAttributes:t}){return["div",{class:"video-wrapper"},["iframe",C.mergeAttributes(t)]]},addCommands(){return{setVideo:t=>({commands:o})=>o.insertContent({type:this.name,attrs:t})}}}),N=40,le=C.Extension.create({name:"indent",addOptions(){return{types:["heading","paragraph"],maxIndent:200}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const o=t.style.paddingLeft;return o&&parseInt(o,10)||0},renderHTML:t=>!t.indent||t.indent===0?{}:{style:`padding-left: ${t.indent}px`}}}}]},addCommands(){return{indent:()=>({tr:t,state:o,dispatch:n})=>{const{selection:m}=o,{from:l,to:s}=m;let d=!1;return o.doc.nodesBetween(l,s,(r,f)=>{if(this.options.types.includes(r.type.name)){const i=r.attrs.indent||0,a=Math.min(i+N,this.options.maxIndent);a!==i&&(t.setNodeMarkup(f,void 0,{...r.attrs,indent:a}),d=!0)}}),d&&n&&n(t),d},outdent:()=>({tr:t,state:o,dispatch:n})=>{const{selection:m}=o,{from:l,to:s}=m;let d=!1;return o.doc.nodesBetween(l,s,(r,f)=>{if(this.options.types.includes(r.type.name)){const i=r.attrs.indent||0,a=Math.max(i-N,0);a!==i&&(t.setNodeMarkup(f,void 0,{...r.attrs,indent:a}),d=!0)}}),d&&n&&n(t),d}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.indent(),"Shift-Tab":()=>this.editor.commands.outdent()}}}),B={toolbar:"bg-white border-b border-gray-200 p-2 flex flex-wrap items-center gap-1",toolbarButton:"hover:bg-gray-100 rounded p-1.5 text-gray-600 cursor-pointer",toolbarButtonActive:"bg-blue-100 text-blue-600",editor:"bg-white min-h-[400px] p-4 prose max-w-none focus:outline-none",dropdown:"bg-white border border-gray-200 rounded shadow-lg py-1 z-50",modal:"bg-white rounded-lg shadow-xl p-6",saveButton:"bg-blue-600 text-white rounded px-4 py-2 hover:bg-blue-700"},M={maxSize:5*1024*1024,allowedTypes:["image/jpeg","image/png","image/gif"]},T=["Arial","Times New Roman","Courier New","Georgia","Verdana","Trebuchet MS","Comic Sans MS","Impact"],$=["8","10","12","14","16","18","20","24","28","32","36","48","72"],S=["1","1.15","1.5","2","2.5","3"],L=Symbol("document-editor");function re(){const t=e.inject(L);if(!t)throw new Error("useDocumentEditor must be used within a DocumentEditor component");return{editor:t,getHTML:()=>{var o;return((o=t.value)==null?void 0:o.getHTML())??""},getText:()=>{var o;return((o=t.value)==null?void 0:o.getText())??""},setContent:o=>{var n;return(n=t.value)==null?void 0:n.commands.setContent(o)},focus:()=>{var o;return(o=t.value)==null?void 0:o.commands.focus()},isEmpty:()=>{var o;return((o=t.value)==null?void 0:o.isEmpty)??!0}}}const ie=["title","disabled"],k=e.defineComponent({__name:"ToolbarButton",props:{theme:{},title:{},isActive:{type:Boolean},disabled:{type:Boolean}},emits:["click"],setup(t){return(o,n)=>(e.openBlock(),e.createElementBlock("button",{type:"button",class:e.normalizeClass([t.theme.toolbarButton,t.isActive&&t.theme.toolbarButtonActive]),title:t.title,disabled:t.disabled,onClick:n[0]||(n[0]=m=>o.$emit("click"))},[e.renderSlot(o.$slots,"default")],10,ie))}}),ae=(t,o)=>{const n=t.__vccOpts||t;for(const[m,l]of o)n[m]=l;return n},se={},de={class:"w-px h-6 bg-gray-300 mx-1"};function ce(t,o){return e.openBlock(),e.createElementBlock("div",de)}const b=ae(se,[["render",ce]]),me=["title"],V=e.defineComponent({__name:"ToolbarDropdown",props:{theme:{},label:{},title:{}},setup(t){const o=e.ref(!1),n=e.ref(null);function m(){o.value=!1}function l(s){n.value&&!n.value.contains(s.target)&&(o.value=!1)}return e.onMounted(()=>document.addEventListener("click",l)),e.onBeforeUnmount(()=>document.removeEventListener("click",l)),(s,d)=>(e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"dropdownRef",ref:n},[e.createElementVNode("button",{type:"button",class:e.normalizeClass([t.theme.toolbarButton,"flex items-center gap-1 px-2 text-sm"]),title:t.title,onClick:d[0]||(d[0]=r=>o.value=!o.value)},[e.createElementVNode("span",null,e.toDisplayString(t.label),1),d[1]||(d[1]=e.createElementVNode("svg",{class:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor"},[e.createElementVNode("path",{d:"M2 4l4 4 4-4",stroke:"currentColor","stroke-width":"1.5",fill:"none"})],-1))],10,me),o.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 min-w-[150px] max-h-60 overflow-y-auto"])},[e.renderSlot(s.$slots,"default",{close:m})],2)):e.createCommentVNode("",!0)],512))}}),fe=["onClick"],ue=e.defineComponent({__name:"HeadingPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=[{label:"Paragraph",value:"paragraph",class:"text-sm"},{label:"Heading 1",value:1,class:"text-2xl font-bold"},{label:"Heading 2",value:2,class:"text-xl font-bold"},{label:"Heading 3",value:3,class:"text-lg font-bold"},{label:"Heading 4",value:4,class:"text-base font-semibold"},{label:"Heading 5",value:5,class:"text-sm font-semibold"},{label:"Heading 6",value:6,class:"text-xs font-semibold"}];function m(d){var r,f;return d.value==="paragraph"?(r=o.editor)==null?void 0:r.isActive("paragraph"):(f=o.editor)==null?void 0:f.isActive("heading",{level:d.value})}const l=e.computed(()=>{const d=n.find(r=>m(r));return(d==null?void 0:d.label)??"Paragraph"});function s(d){var r,f;d.value==="paragraph"?(r=o.editor)==null||r.chain().focus().setParagraph().run():(f=o.editor)==null||f.chain().focus().toggleHeading({level:d.value}).run()}return(d,r)=>(e.openBlock(),e.createBlock(V,{theme:t.theme,label:l.value,title:"Block type"},{default:e.withCtx(({close:f})=>[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,i=>e.createElementVNode("button",{key:i.value,class:e.normalizeClass(["block w-full text-left px-3 py-1.5 hover:bg-gray-100",i.class,m(i)?"bg-gray-50 font-semibold":""]),onClick:a=>{s(i),f()}},e.toDisplayString(i.label),11,fe)),64))]),_:1},8,["theme","label"]))}}),pe=["onClick"],he=e.defineComponent({__name:"FontFamilyPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=T,m=e.computed(()=>{var l;for(const s of n)if((l=o.editor)!=null&&l.isActive("textStyle",{fontFamily:s}))return s;return"Font"});return(l,s)=>(e.openBlock(),e.createBlock(V,{theme:t.theme,label:m.value,title:"Font family"},{default:e.withCtx(({close:d})=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),r=>(e.openBlock(),e.createElementBlock("button",{key:r,style:e.normalizeStyle({fontFamily:r}),class:e.normalizeClass(["block w-full text-left px-3 py-1.5 hover:bg-gray-100 text-sm",m.value===r?"bg-gray-50 font-semibold":""]),onClick:f=>{var i;(i=t.editor)==null||i.chain().focus().setFontFamily(r).run(),d()}},e.toDisplayString(r),15,pe))),128))]),_:1},8,["theme","label"]))}}),ge=["onClick"],xe=e.defineComponent({__name:"FontSizePicker",props:{editor:{},theme:{}},setup(t){const o=t,n=$,m=e.computed(()=>{var l;for(const s of n)if((l=o.editor)!=null&&l.isActive("textStyle",{fontSize:s+"px"}))return s;return""});return(l,s)=>(e.openBlock(),e.createBlock(V,{theme:t.theme,label:m.value||"Size",title:"Font size"},{default:e.withCtx(({close:d})=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),r=>(e.openBlock(),e.createElementBlock("button",{key:r,class:e.normalizeClass(["block w-full text-left px-3 py-1.5 hover:bg-gray-100 text-sm",m.value===r?"bg-gray-50 font-semibold":""]),onClick:f=>{var i;(i=t.editor)==null||i.chain().focus().setFontSize(r+"px").run(),d()}},e.toDisplayString(r),11,ge))),128))]),_:1},8,["theme","label"]))}}),ke={class:"grid grid-cols-8 gap-1 mb-2"},be=["title","onClick"],ye={class:"flex items-center gap-2 pt-2 border-t border-gray-100"},Ce=["value"],Ee=e.defineComponent({__name:"ColorPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=e.ref(!1),m=e.ref(null),l=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd"],s=e.computed(()=>{var f;return((f=o.editor)==null?void 0:f.getAttributes("textStyle").color)||"#000000"});function d(f){var i;(i=o.editor)==null||i.chain().focus().setColor(f).run(),n.value=!1}function r(f){m.value&&!m.value.contains(f.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",r)),e.onBeforeUnmount(()=>document.removeEventListener("click",r)),(f,i)=>(e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"pickerRef",ref:m},[e.createElementVNode("button",{type:"button",class:e.normalizeClass([t.theme.toolbarButton,"flex items-center gap-1 px-2"]),title:"Font color",onClick:i[0]||(i[0]=a=>n.value=!n.value)},[i[2]||(i[2]=e.createElementVNode("span",null,"A",-1)),e.createElementVNode("div",{class:"w-4 h-1 rounded",style:e.normalizeStyle({backgroundColor:s.value})},null,4)],2),n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 p-2 w-48"])},[e.createElementVNode("div",ke,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,a=>e.createElementVNode("button",{key:a,class:"w-5 h-5 rounded border border-gray-200 cursor-pointer hover:scale-110 transition-transform",style:e.normalizeStyle({backgroundColor:a}),title:a,onClick:c=>d(a)},null,12,be)),64))]),e.createElementVNode("div",ye,[i[3]||(i[3]=e.createElementVNode("label",{class:"text-xs text-gray-500"},"Custom:",-1)),e.createElementVNode("input",{type:"color",value:s.value,class:"w-6 h-6 cursor-pointer",onInput:i[1]||(i[1]=a=>d(a.target.value))},null,40,Ce)])],2)):e.createCommentVNode("",!0)],512))}}),Ve=e.defineComponent({__name:"AlignmentButtons",props:{editor:{},theme:{}},setup(t){return(o,n)=>{var m,l,s,d;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(k,{theme:t.theme,title:"Align left","is-active":(m=t.editor)==null?void 0:m.isActive({textAlign:"left"}),onClick:n[0]||(n[0]=r=>{var f;return(f=t.editor)==null?void 0:f.chain().focus().setTextAlign("left").run()})},{default:e.withCtx(()=>[...n[4]||(n[4]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M3 12h10M3 18h14"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Align center","is-active":(l=t.editor)==null?void 0:l.isActive({textAlign:"center"}),onClick:n[1]||(n[1]=r=>{var f;return(f=t.editor)==null?void 0:f.chain().focus().setTextAlign("center").run()})},{default:e.withCtx(()=>[...n[5]||(n[5]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M7 12h10M5 18h14"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Align right","is-active":(s=t.editor)==null?void 0:s.isActive({textAlign:"right"}),onClick:n[2]||(n[2]=r=>{var f;return(f=t.editor)==null?void 0:f.chain().focus().setTextAlign("right").run()})},{default:e.withCtx(()=>[...n[6]||(n[6]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M11 12h10M7 18h14"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Justify","is-active":(d=t.editor)==null?void 0:d.isActive({textAlign:"justify"}),onClick:n[3]||(n[3]=r=>{var f;return(f=t.editor)==null?void 0:f.chain().focus().setTextAlign("justify").run()})},{default:e.withCtx(()=>[...n[7]||(n[7]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 6h18M3 12h18M3 18h18"})],-1)])]),_:1},8,["theme","is-active"])],64)}}}),we=["onClick"],Ne=e.defineComponent({__name:"LineHeightPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=S,m=e.computed(()=>{var l,s;return((l=o.editor)==null?void 0:l.getAttributes("paragraph").lineHeight)||((s=o.editor)==null?void 0:s.getAttributes("heading").lineHeight)||""});return(l,s)=>(e.openBlock(),e.createBlock(V,{theme:t.theme,label:m.value||"Height",title:"Line height"},{default:e.withCtx(({close:d})=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),r=>(e.openBlock(),e.createElementBlock("button",{key:r,class:e.normalizeClass(["block w-full text-left px-3 py-1.5 hover:bg-gray-100 text-sm",m.value===r?"bg-gray-50 font-semibold":""]),onClick:f=>{var i;(i=t.editor)==null||i.chain().focus().setLineHeight(r).run(),d()}},e.toDisplayString(r),11,we))),128))]),_:1},8,["theme","label"]))}}),Be={class:"flex gap-2"},Me=e.defineComponent({__name:"LinkButton",props:{editor:{},theme:{}},setup(t){const o=t,n=e.ref(!1),m=e.ref(""),l=e.ref(null),s=e.ref(null);function d(){var a;m.value=((a=o.editor)==null?void 0:a.getAttributes("link").href)||"",n.value=!n.value,n.value&&e.nextTick(()=>{var c;return(c=s.value)==null?void 0:c.focus()})}function r(){var a;m.value&&((a=o.editor)==null||a.chain().focus().extendMarkRange("link").setLink({href:m.value}).run()),n.value=!1}function f(){var a;(a=o.editor)==null||a.chain().focus().unsetLink().run(),n.value=!1}function i(a){l.value&&!l.value.contains(a.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",i)),e.onBeforeUnmount(()=>document.removeEventListener("click",i)),(a,c)=>{var p,g;return e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"linkRef",ref:l},[e.createVNode(k,{theme:t.theme,title:"Link","is-active":(p=t.editor)==null?void 0:p.isActive("link"),onClick:d},{default:e.withCtx(()=>[...c[2]||(c[2]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.createElementVNode("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)])]),_:1},8,["theme","is-active"]),n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 p-3 w-72"])},[c[3]||(c[3]=e.createElementVNode("label",{class:"block text-xs text-gray-500 mb-1"},"URL",-1)),e.withDirectives(e.createElementVNode("input",{ref_key:"urlInput",ref:s,"onUpdate:modelValue":c[0]||(c[0]=h=>m.value=h),type:"url",placeholder:"https://example.com",class:"w-full border border-gray-300 rounded px-2 py-1 text-sm mb-2",onKeydown:e.withKeys(r,["enter"])},null,544),[[e.vModelText,m.value]]),e.createElementVNode("div",Be,[e.createElementVNode("button",{class:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700",onClick:r}," Apply "),(g=t.editor)!=null&&g.isActive("link")?(e.openBlock(),e.createElementBlock("button",{key:0,class:"px-3 py-1 text-sm bg-red-100 text-red-600 rounded hover:bg-red-200",onClick:f}," Remove ")):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"px-3 py-1 text-sm text-gray-500 hover:text-gray-700",onClick:c[1]||(c[1]=h=>n.value=!1)}," Cancel ")])],2)):e.createCommentVNode("",!0)],512)}}}),Te=["accept"],$e=e.defineComponent({__name:"ImageUploadButton",props:{editor:{},theme:{},imageConfig:{}},emits:["error"],setup(t,{emit:o}){const n=t,m=o,l=e.ref(null),s=e.computed(()=>({...M,...n.imageConfig})),d=e.computed(()=>s.value.allowedTypes.join(","));function r(){var i;(i=l.value)==null||i.click()}function f(i){var g;const a=i.target,c=(g=a.files)==null?void 0:g[0];if(!c)return;if(!s.value.allowedTypes.includes(c.type)){m("error",{message:`File type ${c.type} is not allowed`,detail:{allowedTypes:s.value.allowedTypes}}),a.value="";return}if(c.size>s.value.maxSize){const h=(s.value.maxSize/1048576).toFixed(1);m("error",{message:`File size exceeds ${h}MB limit`,detail:{maxSize:s.value.maxSize,fileSize:c.size}}),a.value="";return}const p=new FileReader;p.onload=()=>{var u;const h=p.result;(u=n.editor)==null||u.chain().focus().setImage({src:h}).run()},p.readAsDataURL(c),a.value=""}return(i,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(k,{theme:t.theme,title:"Insert image",onClick:r},{default:e.withCtx(()=>[...a[0]||(a[0]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.createElementVNode("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.createElementVNode("path",{d:"M21 15l-5-5L5 21"})],-1)])]),_:1},8,["theme"]),e.createElementVNode("input",{ref_key:"fileInput",ref:l,type:"file",accept:d.value,class:"hidden",onChange:f},null,40,Te)],64))}}),Se={class:"mb-1 text-xs text-gray-500 text-center"},Le=["onMouseenter"],Ae=8,A=10,ze=e.defineComponent({__name:"TableGridPicker",props:{editor:{},theme:{}},setup(t){const o=t,n=e.ref(!1),m=e.ref(0),l=e.ref(0),s=e.ref(null);function d(f,i){var a;(a=o.editor)==null||a.chain().focus().insertTable({rows:f,cols:i,withHeaderRow:!0}).run(),n.value=!1,m.value=0,l.value=0}function r(f){s.value&&!s.value.contains(f.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",r)),e.onBeforeUnmount(()=>document.removeEventListener("click",r)),(f,i)=>(e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"pickerRef",ref:s},[e.createVNode(k,{theme:t.theme,title:"Insert table",onClick:i[0]||(i[0]=a=>n.value=!n.value)},{default:e.withCtx(()=>[...i[2]||(i[2]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("rect",{x:"3",y:"3",width:"18",height:"18",rx:"1"}),e.createElementVNode("path",{d:"M3 9h18M3 15h18M9 3v18M15 3v18"})],-1)])]),_:1},8,["theme"]),n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 p-2"])},[e.createElementVNode("div",Se,e.toDisplayString(l.value>0?`${l.value} × ${m.value}`:"Select size"),1),e.createElementVNode("div",{class:"grid gap-0.5",style:e.normalizeStyle({gridTemplateColumns:`repeat(${A}, 1fr)`})},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(Ae,a=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:"row-"+a},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(A,c=>e.createElementVNode("div",{key:"cell-"+a+"-"+c,class:e.normalizeClass(["w-5 h-5 border cursor-pointer",a<=m.value&&c<=l.value?"bg-blue-200 border-blue-300":"bg-white border-gray-300"]),onMouseenter:p=>{m.value=a,l.value=c},onClick:i[1]||(i[1]=p=>d(m.value,l.value))},null,42,Le)),64))],64))),64))],4)],2)):e.createCommentVNode("",!0)],512))}}),He={class:"flex gap-2"},Fe=e.defineComponent({__name:"VideoEmbedButton",props:{editor:{},theme:{}},setup(t){const o=t,n=e.ref(!1),m=e.ref(""),l=e.ref(null);function s(f){const i=f.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/);if(i)return`https://www.youtube.com/embed/${i[1]}`;const a=f.match(/vimeo\.com\/(\d+)/);return a?`https://player.vimeo.com/video/${a[1]}`:f}function d(){var f;if(m.value){const i=s(m.value);(f=o.editor)==null||f.chain().focus().setVideo({src:i}).run()}n.value=!1,m.value=""}function r(f){l.value&&!l.value.contains(f.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("click",r)),e.onBeforeUnmount(()=>document.removeEventListener("click",r)),(f,i)=>(e.openBlock(),e.createElementBlock("div",{class:"relative",ref_key:"videoRef",ref:l},[e.createVNode(k,{theme:t.theme,title:"Embed video",onClick:i[0]||(i[0]=a=>n.value=!n.value)},{default:e.withCtx(()=>[...i[3]||(i[3]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("polygon",{points:"5,3 19,12 5,21"})],-1)])]),_:1},8,["theme"]),n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([t.theme.dropdown,"absolute top-full left-0 mt-1 p-3 w-80"])},[i[4]||(i[4]=e.createElementVNode("label",{class:"block text-xs text-gray-500 mb-1"},"Video URL (YouTube, Vimeo)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":i[1]||(i[1]=a=>m.value=a),type:"url",placeholder:"https://www.youtube.com/watch?v=...",class:"w-full border border-gray-300 rounded px-2 py-1 text-sm mb-2",onKeydown:e.withKeys(d,["enter"])},null,544),[[e.vModelText,m.value]]),e.createElementVNode("div",He,[e.createElementVNode("button",{class:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700",onClick:d}," Embed "),e.createElementVNode("button",{class:"px-3 py-1 text-sm text-gray-500 hover:text-gray-700",onClick:i[2]||(i[2]=a=>n.value=!1)}," Cancel ")])],2)):e.createCommentVNode("",!0)],512))}}),De=e.defineComponent({__name:"EditorToolbar",props:{editor:{},theme:{},imageConfig:{}},emits:["saveTemplate","loadTemplate","save","error"],setup(t){return(o,n)=>{var m,l,s,d,r,f,i,a,c,p,g;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(t.theme.toolbar)},[e.createVNode(k,{theme:t.theme,title:"Undo",onClick:n[0]||(n[0]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().undo().run()}),disabled:!((m=t.editor)!=null&&m.can().undo())},{default:e.withCtx(()=>[...n[18]||(n[18]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 10h10a5 5 0 0 1 0 10H9"}),e.createElementVNode("path",{d:"M3 10l4-4M3 10l4 4"})],-1)])]),_:1},8,["theme","disabled"]),e.createVNode(k,{theme:t.theme,title:"Redo",onClick:n[1]||(n[1]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().redo().run()}),disabled:!((l=t.editor)!=null&&l.can().redo())},{default:e.withCtx(()=>[...n[19]||(n[19]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M21 10H11a5 5 0 0 0 0 10h4"}),e.createElementVNode("path",{d:"M21 10l-4-4M21 10l-4 4"})],-1)])]),_:1},8,["theme","disabled"]),e.createVNode(b),e.createVNode(ue,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(he,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(xe,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(k,{theme:t.theme,title:"Bold","is-active":(s=t.editor)==null?void 0:s.isActive("bold"),onClick:n[2]||(n[2]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleBold().run()})},{default:e.withCtx(()=>[...n[20]||(n[20]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M6 4h8a4 4 0 0 1 0 8H6V4zm0 8h9a4.5 4.5 0 0 1 0 9H6v-9z"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Italic","is-active":(d=t.editor)==null?void 0:d.isActive("italic"),onClick:n[3]||(n[3]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleItalic().run()})},{default:e.withCtx(()=>[...n[21]||(n[21]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M10 4h4M14 4l-4 16M6 20h4"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Underline","is-active":(r=t.editor)==null?void 0:r.isActive("underline"),onClick:n[4]||(n[4]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleUnderline().run()})},{default:e.withCtx(()=>[...n[22]||(n[22]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M6 4v6a6 6 0 0 0 12 0V4M4 20h16"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Strikethrough","is-active":(f=t.editor)==null?void 0:f.isActive("strike"),onClick:n[5]||(n[5]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleStrike().run()})},{default:e.withCtx(()=>[...n[23]||(n[23]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M4 12h16M7 5c0 0 1-1 5-1s5 2 5 4-2 3-5 3M7 19c0 0 1 1 5 1s5-2 5-4"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Subscript","is-active":(i=t.editor)==null?void 0:i.isActive("subscript"),onClick:n[6]||(n[6]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleSubscript().run()})},{default:e.withCtx(()=>[...n[24]||(n[24]=[e.createElementVNode("span",{class:"text-xs font-semibold"},[e.createTextVNode("X"),e.createElementVNode("sub",null,"2")],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Superscript","is-active":(a=t.editor)==null?void 0:a.isActive("superscript"),onClick:n[7]||(n[7]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleSuperscript().run()})},{default:e.withCtx(()=>[...n[25]||(n[25]=[e.createElementVNode("span",{class:"text-xs font-semibold"},[e.createTextVNode("X"),e.createElementVNode("sup",null,"2")],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(Ee,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(Ve,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(k,{theme:t.theme,title:"Indent",onClick:n[8]||(n[8]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().indent().run()})},{default:e.withCtx(()=>[...n[26]||(n[26]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M21 6h-8M21 12h-8M21 18h-8M3 6l4 3-4 3V6z",fill:"currentColor"})],-1)])]),_:1},8,["theme"]),e.createVNode(k,{theme:t.theme,title:"Outdent",onClick:n[9]||(n[9]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().outdent().run()})},{default:e.withCtx(()=>[...n[27]||(n[27]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M21 6h-8M21 12h-8M21 18h-8M7 6L3 9l4 3V6z",fill:"currentColor"})],-1)])]),_:1},8,["theme"]),e.createVNode(Ne,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(k,{theme:t.theme,title:"Bullet list","is-active":(c=t.editor)==null?void 0:c.isActive("bulletList"),onClick:n[10]||(n[10]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleBulletList().run()})},{default:e.withCtx(()=>[...n[28]||(n[28]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("circle",{cx:"4",cy:"6",r:"1.5",fill:"currentColor"}),e.createElementVNode("path",{d:"M9 6h12"}),e.createElementVNode("circle",{cx:"4",cy:"12",r:"1.5",fill:"currentColor"}),e.createElementVNode("path",{d:"M9 12h12"}),e.createElementVNode("circle",{cx:"4",cy:"18",r:"1.5",fill:"currentColor"}),e.createElementVNode("path",{d:"M9 18h12"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Numbered list","is-active":(p=t.editor)==null?void 0:p.isActive("orderedList"),onClick:n[11]||(n[11]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleOrderedList().run()})},{default:e.withCtx(()=>[...n[29]||(n[29]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("text",{x:"2",y:"8","font-size":"7",fill:"currentColor",stroke:"none"},"1"),e.createElementVNode("path",{d:"M9 6h12"}),e.createElementVNode("text",{x:"2",y:"14","font-size":"7",fill:"currentColor",stroke:"none"},"2"),e.createElementVNode("path",{d:"M9 12h12"}),e.createElementVNode("text",{x:"2",y:"20","font-size":"7",fill:"currentColor",stroke:"none"},"3"),e.createElementVNode("path",{d:"M9 18h12"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Blockquote","is-active":(g=t.editor)==null?void 0:g.isActive("blockquote"),onClick:n[12]||(n[12]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().toggleBlockquote().run()})},{default:e.withCtx(()=>[...n[30]||(n[30]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor"},[e.createElementVNode("path",{d:"M3 3h8v8H3zM13 3h8v8h-8zM5 11l-2 6h4l2-6zM15 11l-2 6h4l2-6z",opacity:"0.6"})],-1)])]),_:1},8,["theme","is-active"]),e.createVNode(k,{theme:t.theme,title:"Horizontal rule",onClick:n[13]||(n[13]=h=>{var u;return(u=t.editor)==null?void 0:u.chain().focus().setHorizontalRule().run()})},{default:e.withCtx(()=>[...n[31]||(n[31]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M3 12h18"})],-1)])]),_:1},8,["theme"]),e.createVNode(b),e.createVNode(Me,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode($e,{editor:t.editor,theme:t.theme,"image-config":t.imageConfig,onError:n[14]||(n[14]=h=>o.$emit("error",h))},null,8,["editor","theme","image-config"]),e.createVNode(ze,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(Fe,{editor:t.editor,theme:t.theme},null,8,["editor","theme"]),e.createVNode(b),e.createVNode(k,{theme:t.theme,title:"Save as template",onClick:n[15]||(n[15]=h=>o.$emit("saveTemplate"))},{default:e.withCtx(()=>[...n[32]||(n[32]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),e.createElementVNode("polyline",{points:"17,21 17,13 7,13 7,21"}),e.createElementVNode("polyline",{points:"7,3 7,8 15,8"})],-1)])]),_:1},8,["theme"]),e.createVNode(k,{theme:t.theme,title:"Load template",onClick:n[16]||(n[16]=h=>o.$emit("loadTemplate"))},{default:e.withCtx(()=>[...n[33]||(n[33]=[e.createElementVNode("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})],-1)])]),_:1},8,["theme"]),e.createVNode(b),e.createElementVNode("button",{class:e.normalizeClass(t.theme.saveButton),onClick:n[17]||(n[17]=h=>o.$emit("save"))}," Save ",2)],2)}}}),Ie={key:0,class:"bg-white border border-gray-200 rounded-lg shadow-lg p-2 flex flex-wrap gap-1 mb-1"},Re={class:"flex gap-1"},Oe={class:"flex gap-1"},Ue={class:"flex gap-1"},qe={class:"flex gap-1 items-center"},Pe=e.defineComponent({__name:"TablePopoverMenu",props:{editor:{}},setup(t){const o=t;function n(m){var l;(l=o.editor)==null||l.chain().focus().setCellAttribute("backgroundColor",m).run()}return(m,l)=>{var s;return(s=t.editor)!=null&&s.isActive("table")?(e.openBlock(),e.createElementBlock("div",Ie,[e.createElementVNode("div",Re,[e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[0]||(l[0]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().addRowBefore().run()})}," + Row Above "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[1]||(l[1]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().addRowAfter().run()})}," + Row Below "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-red-50 text-red-600",onClick:l[2]||(l[2]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().deleteRow().run()})}," Delete Row ")]),l[12]||(l[12]=e.createElementVNode("span",{class:"w-px h-6 bg-gray-300"},null,-1)),e.createElementVNode("div",Oe,[e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[3]||(l[3]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().addColumnBefore().run()})}," + Col Left "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[4]||(l[4]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().addColumnAfter().run()})}," + Col Right "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-red-50 text-red-600",onClick:l[5]||(l[5]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().deleteColumn().run()})}," Delete Col ")]),l[13]||(l[13]=e.createElementVNode("span",{class:"w-px h-6 bg-gray-300"},null,-1)),e.createElementVNode("div",Ue,[e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[6]||(l[6]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().mergeCells().run()})}," Merge "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[7]||(l[7]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().splitCell().run()})}," Split ")]),l[14]||(l[14]=e.createElementVNode("span",{class:"w-px h-6 bg-gray-300"},null,-1)),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-gray-100",onClick:l[8]||(l[8]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().toggleHeaderRow().run()})}," Toggle Header "),e.createElementVNode("button",{class:"px-2 py-1 text-xs rounded hover:bg-red-50 text-red-600",onClick:l[9]||(l[9]=d=>{var r;return(r=t.editor)==null?void 0:r.chain().focus().deleteTable().run()})}," Delete Table "),l[15]||(l[15]=e.createElementVNode("span",{class:"w-px h-6 bg-gray-300"},null,-1)),e.createElementVNode("div",qe,[l[11]||(l[11]=e.createElementVNode("label",{class:"text-xs text-gray-500"},"Cell BG:",-1)),e.createElementVNode("input",{type:"color",class:"w-5 h-5 cursor-pointer",onInput:l[10]||(l[10]=d=>n(d.target.value))},null,32)])])):e.createCommentVNode("",!0)}}}),je={class:"mb-3"},Ge={class:"mb-4"},Ke={class:"flex gap-4"},We={class:"flex items-center gap-2 text-sm"},Je={class:"flex items-center gap-2 text-sm"},Xe={class:"flex justify-end gap-2"},Ye=["disabled"],Ze=e.defineComponent({__name:"SaveTemplateModal",props:{theme:{}},emits:["save"],setup(t,{expose:o,emit:n}){const m=n,l=e.ref(!1),s=e.ref(""),d=e.ref("document");function r(){s.value="",d.value="document",l.value=!0}function f(){l.value=!1}function i(){m("save",{name:s.value.trim(),type:d.value}),f()}return o({open:r,close:f}),(a,c)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e.withModifiers(f,["self"])},[e.createElementVNode("div",{class:e.normalizeClass([t.theme.modal,"w-96"])},[c[7]||(c[7]=e.createElementVNode("h2",{class:"text-lg font-semibold mb-4"},"Save as Template",-1)),e.createElementVNode("div",je,[c[3]||(c[3]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Template Name",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[0]||(c[0]=p=>s.value=p),type:"text",class:"w-full border border-gray-300 rounded px-3 py-2 text-sm",placeholder:"My Template"},null,512),[[e.vModelText,s.value]])]),e.createElementVNode("div",Ge,[c[6]||(c[6]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Type",-1)),e.createElementVNode("div",Ke,[e.createElementVNode("label",We,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[1]||(c[1]=p=>d.value=p),type:"radio",value:"document"},null,512),[[e.vModelRadio,d.value]]),c[4]||(c[4]=e.createTextVNode(" Full Document ",-1))]),e.createElementVNode("label",Je,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[2]||(c[2]=p=>d.value=p),type:"radio",value:"snippet"},null,512),[[e.vModelRadio,d.value]]),c[5]||(c[5]=e.createTextVNode(" Snippet ",-1))])])]),e.createElementVNode("div",Xe,[e.createElementVNode("button",{class:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800",onClick:f},"Cancel"),e.createElementVNode("button",{class:e.normalizeClass(t.theme.saveButton),disabled:!s.value.trim(),onClick:i},"Save",10,Ye)])],2)])):e.createCommentVNode("",!0)]))}}),Qe={key:0,class:"text-center py-8 text-gray-500"},ve={key:1,class:"text-center py-8 text-gray-500"},_e={key:2,class:"overflow-y-auto flex-1 -mx-6 px-6"},et=["onClick"],tt={class:"font-medium text-sm"},nt=["onClick"],ot=e.defineComponent({__name:"LoadTemplateModal",props:{theme:{},templates:{},loading:{type:Boolean}},emits:["select","delete","load"],setup(t,{expose:o,emit:n}){const m=n,l=e.ref(!1);function s(){l.value=!0,m("load")}function d(){l.value=!1}function r(i){m("select",i),d()}function f(i){confirm(`Delete template "${i.name}"?`)&&m("delete",i)}return o({open:s,close:d}),(i,a)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e.withModifiers(d,["self"])},[e.createElementVNode("div",{class:e.normalizeClass([t.theme.modal,"w-[500px] max-h-[80vh] flex flex-col"])},[a[0]||(a[0]=e.createElementVNode("h2",{class:"text-lg font-semibold mb-4"},"Load Template",-1)),t.loading?(e.openBlock(),e.createElementBlock("div",Qe,"Loading templates...")):t.templates.length===0?(e.openBlock(),e.createElementBlock("div",ve,"No templates found")):(e.openBlock(),e.createElementBlock("div",_e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.templates,c=>(e.openBlock(),e.createElementBlock("div",{key:c.id,class:"flex items-center justify-between p-3 border border-gray-200 rounded mb-2 hover:bg-gray-50 cursor-pointer group",onClick:p=>r(c)},[e.createElementVNode("div",null,[e.createElementVNode("div",tt,e.toDisplayString(c.name),1),e.createElementVNode("span",{class:e.normalizeClass(["inline-block text-xs px-2 py-0.5 rounded mt-1",c.type==="document"?"bg-blue-100 text-blue-700":"bg-green-100 text-green-700"])},e.toDisplayString(c.type==="document"?"Document":"Snippet"),3)]),e.createElementVNode("button",{class:"text-red-400 hover:text-red-600 opacity-0 group-hover:opacity-100 text-sm px-2",onClick:e.withModifiers(p=>f(c),["stop"])}," Delete ",8,nt)],8,et))),128))])),e.createElementVNode("div",{class:"flex justify-end pt-4"},[e.createElementVNode("button",{class:"px-4 py-2 text-sm text-gray-600 hover:text-gray-800",onClick:d},"Cancel")])],2)])):e.createCommentVNode("",!0)]))}}),lt={class:"border border-gray-200 rounded-lg overflow-hidden"},rt=e.defineComponent({__name:"DocumentEditor",props:{modelValue:{},templates:{},templatesLoading:{type:Boolean},image:{},theme:{},placeholder:{default:""},readonly:{type:Boolean,default:!1}},emits:["update:modelValue","save","saveTemplate","loadTemplates","deleteTemplate","error"],setup(t,{emit:o}){const n=t,m=o,l=e.computed(()=>({...B,...n.theme})),s=y.useEditor({content:n.modelValue,editable:!n.readonly,extensions:[z,H.TextStyle,F,Z,D,I,R,O.configure({types:["textStyle"]}),U.configure({types:["heading","paragraph"]}),Q,le,q.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),ne,j.Table.configure({resizable:!0}),G,X,Y,oe,P.configure({placeholder:n.placeholder||"Start typing..."})],onUpdate:()=>{var p;m("update:modelValue",((p=s.value)==null?void 0:p.getHTML())??"")}});e.provide(L,s),e.watch(()=>n.modelValue,p=>{var g,h;((g=s.value)==null?void 0:g.getHTML())!==p&&((h=s.value)==null||h.commands.setContent(p,{emitUpdate:!1}))}),e.watch(()=>n.readonly,p=>{var g;(g=s.value)==null||g.setEditable(!p)});function d(p){m("error",p)}const r=e.ref(null),f=e.ref(null);function i(p){var u,E,w;const g=((u=s.value)==null?void 0:u.getHTML())??"",h=p.type==="snippet"&&((E=s.value)!=null&&E.state.selection.content())&&((w=s.value)==null?void 0:w.state.selection.content().content.textBetween(0,s.value.state.selection.content().content.size))||g;m("saveTemplate",{name:p.name,type:p.type,content:h})}function a(p){var g,h,u,E;if(p.type==="document"){if(((g=s.value)==null?void 0:g.getHTML())!=="<p></p>"&&((h=s.value)==null?void 0:h.getHTML())!==""&&!confirm("Replace current content with this template?"))return;(u=s.value)==null||u.commands.setContent(p.content)}else(E=s.value)==null||E.commands.insertContent(p.content)}function c(){var g;const p=((g=s.value)==null?void 0:g.getHTML())??"";m("save",p)}return(p,g)=>(e.openBlock(),e.createElementBlock("div",lt,[n.readonly?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(De,{editor:e.unref(s),theme:l.value,"image-config":n.image,onSaveTemplate:g[0]||(g[0]=h=>{var u;return(u=r.value)==null?void 0:u.open()}),onLoadTemplate:g[1]||(g[1]=h=>{var u;return(u=f.value)==null?void 0:u.open()}),onSave:c,onError:d},null,8,["editor","theme","image-config"]),e.createVNode(Pe,{editor:e.unref(s)},null,8,["editor"])],64)),e.createVNode(e.unref(y.EditorContent),{editor:e.unref(s),class:e.normalizeClass(l.value.editor)},null,8,["editor","class"]),e.createVNode(Ze,{ref_key:"saveTemplateModal",ref:r,theme:l.value,onSave:i},null,8,["theme"]),e.createVNode(ot,{ref_key:"loadTemplateModal",ref:f,theme:l.value,templates:n.templates??[],loading:n.templatesLoading??!1,onLoad:g[2]||(g[2]=h=>m("loadTemplates")),onSelect:a,onDelete:g[3]||(g[3]=h=>m("deleteTemplate",h))},null,8,["theme","templates","loading"])]))}});x.DEFAULT_IMAGE_CONFIG=M,x.DEFAULT_THEME=B,x.DocumentEditor=rt,x.FONT_SIZES=$,x.LINE_HEIGHTS=S,x.WEB_SAFE_FONTS=T,x.useDocumentEditor=re,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,10 @@
1
+ import { Extension } from '@tiptap/core';
2
+ declare module '@tiptap/core' {
3
+ interface Commands<ReturnType> {
4
+ indent: {
5
+ indent: () => ReturnType;
6
+ outdent: () => ReturnType;
7
+ };
8
+ }
9
+ }
10
+ export declare const Indent: Extension<any, any>;
@@ -0,0 +1,2 @@
1
+ export declare const CustomTableCell: import('@tiptap/core').Node<import('@tiptap/extension-table').TableCellOptions, any>;
2
+ export declare const CustomTableHeader: import('@tiptap/core').Node<import('@tiptap/extension-table').TableHeaderOptions, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpdev_ab/document-creator",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"