autoforma 1.0.57 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -156,4 +156,4 @@ img.ProseMirror-separator {
|
|
|
156
156
|
2. Cannot start or end with "-"
|
|
157
157
|
3. "-" cannot repeat`);ve.customSchemes.push([n,e])}function ux(){ve.scanner=nx(ve.customSchemes);for(let n=0;n<ve.tokenQueue.length;n++)ve.tokenQueue[n][1]({scanner:ve.scanner});ve.parser=ox(ve.scanner.tokens);for(let n=0;n<ve.pluginQueue.length;n++)ve.pluginQueue[n][1]({scanner:ve.scanner,parser:ve.parser});return ve.initialized=!0,ve}function Gl(n){return ve.initialized||ux(),ix(ve.parser.start,n,$f(ve.scanner.start,n))}Gl.scan=$f;function Yf(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Jl(t),s=Gl(n),o=[];for(let i=0;i<s.length;i++){const l=s[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&o.push(l.toFormattedObject(r))}return o}var Xl="[\0- -\u2029 ]",dx=new RegExp(Xl),fx=new RegExp(`${Xl}$`),hx=new RegExp(Xl,"g");function px(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function mx(n){return new Te({key:new _e("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=of(t.doc,[...e]);if(mf(l).forEach(({newRange:c})=>{const u=b0(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!fx.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(dx).filter(Boolean);if(h.length<=0)return!1;const m=h[h.length-1],y=d.pos+f.lastIndexOf(m);if(!m)return!1;const g=Gl(m).map(b=>b.toObject(n.defaultProtocol));if(!px(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:y+b.start+1,to:y+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{zl(b.from,b.to,r.doc).some(k=>k.mark.type===n.type)||i.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!i.steps.length)return i}})}function gx(n){return new Te({key:new _e("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let u=r.target;const d=[];for(;u.nodeName!=="DIV";)d.push(u),u=u.parentNode;i=d.find(f=>f.nodeName==="A")}if(!i)return!1;const l=pf(e.state,n.type.name),a=(s=i==null?void 0:i.href)!=null?s:l.href,c=(o=i==null?void 0:i.target)!=null?o:l.target;return n.enableClickSelection&&n.editor.commands.extendMarkRange(n.type.name),i&&a?(window.open(a,c),!0):!1}}})}function yx(n){return new Te({key:new _e("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:o}=s,{empty:i}=o;if(i)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Yf(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}function an(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(hx,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Uf=St.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){Kc(n);return}Kc(n.scheme,n.optionalSlashes)})},onDestroy(){cx()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!an(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!an(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!an(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Me(this.options.HTMLAttributes,n),0]:["a",Me(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!an(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!an(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Xt({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=Yf(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!an(i,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(mx({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!an(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(gx({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(yx({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),bx=Uf,xx=Object.defineProperty,kx=(n,e)=>{for(var t in e)xx(n,t,{get:e[t],enumerable:!0})},Sx="listItem",Jc="textStyle",Gc=/^\s*([-+*])\s$/,qf=it.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",Me(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Sx,this.editor.getAttributes(Jc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=qn({find:Gc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=qn({find:Gc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Jc),editor:this.editor})),[n]}}),Kf=it.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Me(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),vx={};kx(vx,{findListItemPos:()=>Ir,getNextListDepth:()=>Ql,handleBackspace:()=>rl,handleDelete:()=>sl,hasListBefore:()=>Jf,hasListItemAfter:()=>Cx,hasListItemBefore:()=>Gf,listItemHasSubList:()=>Xf,nextListIsDeeper:()=>Qf,nextListIsHigher:()=>Zf});var Ir=(n,e)=>{const{$from:t}=e.selection,r=Le(n,e.schema);let s=null,o=t.depth,i=t.pos,l=null;for(;o>0&&l===null;)s=t.node(o),s.type===r?l=o:(o-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},Ql=(n,e)=>{const t=Ir(n,e);if(!t)return!1;const[,r]=O0(e,n,t.$pos.pos+4);return r},Jf=(n,e,t)=>{const{$anchor:r}=n.selection,s=Math.max(0,r.pos-2),o=n.doc.resolve(s).node();return!(!o||!t.includes(o.type.name))},Gf=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((t=s.nodeBefore)==null?void 0:t.type.name)!==n)},Xf=(n,e,t)=>{if(!t)return!1;const r=Le(n,e.schema);let s=!1;return t.descendants(o=>{o.type===r&&(s=!0)}),s},rl=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Gt(n.state,e)&&Jf(n.state,e,t)){const{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const u=c.at(-1);if(!u)return!1;const d=n.state.doc.resolve(a.start()+u.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!Gt(n.state,e)||!R0(n.state))return!1;const r=Ir(e,n.state);if(!r)return!1;const o=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=Xf(e,n.state,o);return Gf(e,n.state)&&!i?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},Qf=(n,e)=>{const t=Ql(n,e),r=Ir(n,e);return!r||!t?!1:t>r.depth},Zf=(n,e)=>{const t=Ql(n,e),r=Ir(n,e);return!r||!t?!1:t<r.depth},sl=(n,e)=>{if(!Gt(n.state,e)||!N0(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:s}=t;return!t.empty&&r.sameParent(s)?!1:Qf(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():Zf(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},Cx=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((t=s.nodeAfter)==null?void 0:t.type.name)!==n)},eh=De.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&sl(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&sl(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&rl(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&rl(n,t,r)&&(e=!0)}),e}}}}),Mx="listItem",Xc="textStyle",Qc=/^(\d+)\.\s$/,th=it.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",Me(this.options.HTMLAttributes,t),0]:["ol",Me(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Mx,this.editor.getAttributes(Xc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=qn({find:Qc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=qn({find:Qc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Xc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),wx=/^\s*(\[([( |x])?\])\s$/,Ex=it.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",Me(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var d,f;l.ariaLabel=((f=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:f.call(d,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(n),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:d}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const h=t();if(typeof h!="number")return!1;const m=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...m==null?void 0:m.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{s.setAttribute(u,d)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([u,d])=>{s.setAttribute(u,d)}),{dom:s,contentDOM:a,update:u=>u.type!==this.type?!1:(s.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[qn({find:wx,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),Tx=it.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",Me(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});De.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(qf.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(Kf.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(eh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(th.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Ex.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(Tx.configure(this.options.taskList)),n}});var Ox=it.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Me(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dx=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Ax=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Nx=St.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Me(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Cn({find:Dx,type:this.type})]},addPasteRules(){return[Xt({find:Ax,type:this.type})]}}),Rx=it.create({name:"text",group:"inline"}),nh=St.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Me(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Lx=nh;function Ix(n={}){return new Te({view(e){return new jx(e,n)}})}class jx{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),y=d?m.bottom:m.top;d&&f&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:m.left,right:m.right,top:y-g,bottom:y+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=rd(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Ee extends le{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Ee.valid(r)?new Ee(r):le.near(r)}content(){return V.empty}eq(e){return e instanceof Ee&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Ee(e.resolve(t.pos))}getBookmark(){return new Zl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Px(e)||!_x(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&Ee.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(Ee.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!Q.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(Ee.valid(l))return l}return null}}}Ee.prototype.visible=!1;Ee.findFrom=Ee.findGapCursorFrom;le.jsonID("gapcursor",Ee);class Zl{constructor(e){this.pos=e}map(e){return new Zl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ee.valid(t)?new Ee(t):le.near(t)}}function Px(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function _x(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function Bx(){return new Te({props:{decorations:Hx,createSelectionBetween(n,e,t){return e.pos==t.pos&&Ee.valid(t)?new Ee(t):null},handleClick:zx,handleKeyDown:Fx,handleDOMEvents:{beforeinput:Vx}}})}const Fx=Yd({ArrowLeft:Qr("horiz",-1),ArrowRight:Qr("horiz",1),ArrowUp:Qr("vert",-1),ArrowDown:Qr("vert",1)});function Qr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof ne){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Ee.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new Ee(c))),!0):!1}}function zx(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Ee.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&Q.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Ee(r))),!0)}function Vx(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Ee))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=I.empty;for(let i=r.length-1;i>=0;i--)s=I.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new V(s,0,0));return o.setSelection(ne.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Hx(n){if(!(n.selection instanceof Ee))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Ce.create(n.doc,[Ge.widget(n.selection.head,e,{key:"gapcursor"})])}var ro=200,Pe=function(){};Pe.prototype.append=function(e){return e.length?(e=Pe.from(e),!this.length&&e||e.length<ro&&this.leafAppend(e)||this.length<ro&&e.leafPrepend(this)||this.appendInner(e)):this};Pe.prototype.prepend=function(e){return e.length?Pe.from(e).append(this):this};Pe.prototype.appendInner=function(e){return new $x(this,e)};Pe.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Pe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Pe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Pe.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};Pe.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};Pe.from=function(e){return e instanceof Pe?e:e&&e.length?new rh(e):Pe.empty};var rh=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=ro)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=ro)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(Pe);Pe.empty=new rh([]);var $x=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(Pe);const Wx=500;class ht{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new bt(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new bt(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new ht(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new bt(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>Ux&&(l=Yx(l,c),i-=c),new ht(l.append(o),i)}remapping(e,t){let r=new Sr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new ht(this.items.append(e.map(t=>new bt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let m=o.maps[h];if(f.step){let y=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(o.slice(a+1,h));g&&l++,r.push(new bt(m,y,g))}else r.push(new bt(m))},s);let c=[];for(let f=t;f<i;f++)c.push(new bt(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new ht(u,l);return d.emptyItemCount()>Wx&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&o++;let d=new bt(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new ht(Pe.from(s.reverse()),o)}}ht.empty=new ht(Pe.empty,0);function Yx(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class bt{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new bt(t.getMap().invert(),t,this.selection)}}}class Ft{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const Ux=20;function qx(n,e,t,r){let s=t.getMeta(bn),o;if(s)return s.historyState;t.getMeta(Gx)&&(n=new Ft(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(bn))return i.getMeta(bn).redo?new Ft(n.done.addTransform(t,void 0,r,us(e)),n.undone,Zc(t.mapping.maps),n.prevTime,n.prevComposition):new Ft(n.done,n.undone.addTransform(t,void 0,r,us(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Kx(t,n.prevRanges)),c=i?vi(n.prevRanges,t.mapping):Zc(t.mapping.maps);return new Ft(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,us(e)),ht.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new Ft(n.done.rebased(t,o),n.undone.rebased(t,o),vi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ft(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),vi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Kx(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function Zc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function vi(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function Jx(n,e,t){let r=us(e),s=bn.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new Ft(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(bn,{redo:t,historyState:a})}let Ci=!1,eu=null;function us(n){let e=n.plugins;if(eu!=e){Ci=!1,eu=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ci=!0;break}}return Ci}const bn=new _e("history"),Gx=new _e("closeHistory");function Xx(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Te({key:bn,state:{init(){return new Ft(ht.empty,ht.empty,null,0,-1)},apply(e,t,r){return qx(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?oh:r=="historyRedo"?ih:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function sh(n,e){return(t,r)=>{let s=bn.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=Jx(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const oh=sh(!1,!0),ih=sh(!0,!0);De.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new Te({key:new _e("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var Qx=De.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Ix(this.options)]}});De.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Te({key:new _e("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return Ce.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(Ge.node(c,c+a.nodeSize,{class:this.options.className}))}),Ce.create(n,o)}}})]}});var Zx=De.create({name:"gapCursor",addProseMirrorPlugins(){return[Bx()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=xe(X(n,"allowGapCursor",t)))!=null?e:null}}});De.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Te({key:new _e("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const o=this.editor.isEmpty;return n.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&Ao(i);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const d=Ge.node(l,l+i.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:l,hasAnchor:a}):this.options.placeholder});s.push(d)}return this.options.includeChildren}),Ce.create(n,s)}}})]}});De.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new Te({key:new _e("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||yf(t.selection)||n.view.dragging?null:Ce.create(t.doc,[Ge.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function tu({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}var ek=De.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const n=new _e(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(this.options.node).includes(t.name));return[new Te({key:n,appendTransaction:(t,r,s)=>{const{doc:o,tr:i,schema:l}=s,a=n.getState(s),c=o.content.size,u=l.nodes[this.options.node];if(a)return i.insert(c,u.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!tu({node:s,types:e})},apply:(t,r)=>{if(!t.docChanged)return r;const s=t.doc.lastChild;return!tu({node:s,types:e})}}})]}}),tk=De.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>oh(n,e),redo:()=>({state:n,dispatch:e})=>ih(n,e)}},addProseMirrorPlugins(){return[Xx(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),nk=De.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(R1.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(T1.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(qf.configure(this.options.bulletList)),this.options.code!==!1&&s.push(j1.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(B1.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(F1.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Qx.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Zx.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(z1.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(V1.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(tk.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(H1.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(q1.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Kf.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(eh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(Uf.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(th.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Ox.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Nx.configure(this.options.strike)),this.options.text!==!1&&s.push(Rx.configure(this.options.text)),this.options.underline!==!1&&s.push(nh.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(ek.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),rk=nk,sk=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,ok=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,ik=St.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",Me(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Cn({find:sk,type:this.type})]},addPasteRules(){return[Xt({find:ok,type:this.type})]}}),lk=ik,ak=De.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),ck=ak,uk=St.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",Me(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),dk=uk,fk=St.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",Me(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hk=fk,En={root:"m_dd3f7539",Typography:"m_f2016866",content:"m_c2204cc2",linkEditorDropdown:"m_8a991b4f",control:"m_c2207da6",controlIcon:"m_9cdfeb3f",controlsGroup:"m_2ab47ef2",linkEditor:"m_b67b711e",linkEditorInput:"m_296cf94c",linkEditorExternalControl:"m_cfef614",linkEditorSave:"m_3b28e7bb",toolbar:"m_4574a3c4",taskList:"m_8b44009a"};const pk={linkControlLabel:"Link",colorPickerControlLabel:"Text color",highlightControlLabel:"Highlight text",colorControlLabel:n=>`Set text color ${n}`,boldControlLabel:"Bold",italicControlLabel:"Italic",underlineControlLabel:"Underline",strikeControlLabel:"Strikethrough",clearFormattingControlLabel:"Clear formatting",unlinkControlLabel:"Remove link",bulletListControlLabel:"Bullet list",orderedListControlLabel:"Ordered list",sourceCodeControlLabel:"Switch between text/source code",h1ControlLabel:"Heading 1",h2ControlLabel:"Heading 2",h3ControlLabel:"Heading 3",h4ControlLabel:"Heading 4",h5ControlLabel:"Heading 5",h6ControlLabel:"Heading 6",blockquoteControlLabel:"Blockquote",alignLeftControlLabel:"Align text: left",alignCenterControlLabel:"Align text: center",alignRightControlLabel:"Align text: right",alignJustifyControlLabel:"Align text: justify",codeControlLabel:"Code",codeBlockControlLabel:"Code block",subscriptControlLabel:"Subscript",superscriptControlLabel:"Superscript",unsetColorControlLabel:"Unset color",hrControlLabel:"Horizontal line",undoControlLabel:"Undo",redoControlLabel:"Redo",tasksControlLabel:"Task list",tasksSinkLabel:"Decrease task level",tasksLiftLabel:"Increase task level",linkEditorInputLabel:"Enter URL",linkEditorInputPlaceholder:"https://example.com/",linkEditorExternalLink:"Open link in a new tab",linkEditorInternalLink:"Open link in the same tab",linkEditorSave:"Save",colorPickerCancel:"Cancel",colorPickerClear:"Clear color",colorPickerColorPicker:"Color picker",colorPickerPalette:"Color palette",colorPickerSave:"Save",colorPickerColorLabel:n=>`Set text color ${n}`},[mk,vt]=x.createSafeContext("RichTextEditor component was not found in tree"),ea=x.factory((n,e)=>{const t=x.useProps("RichTextEditorContent",null,n),{classNames:r,className:s,style:o,styles:i,vars:l,...a}=t,c=vt();return c.withTypographyStyles?p.jsx(x.Typography,{...c.getStyles("Typography",{className:s,style:o,styles:i,classNames:r}),unstyled:c.unstyled,ref:e,children:p.jsx(x.Box,{component:zc,editor:c.editor,...c.getStyles("content",{classNames:r,styles:i}),...a})}):p.jsx(x.Box,{component:zc,editor:c.editor,...c.getStyles("content",{classNames:r,styles:i,className:s,style:o}),...a})});ea.classes=En;ea.displayName="@mantine/tiptap/RichTextEditorContent";function he(n){return p.jsx("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}function gk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7h-6z"}),p.jsx("path",{d:"M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7"})]})}function yk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M11 5l6 0"}),p.jsx("path",{d:"M7 19l6 0"}),p.jsx("path",{d:"M14 5l-4 14"})]})}function bk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M7 5v5a5 5 0 0 0 10 0v-5"}),p.jsx("path",{d:"M5 19h14"})]})}function xk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M5 12l14 0"}),p.jsx("path",{d:"M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5"})]})}function kk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M17 15l4 4m0 -4l-4 4"}),p.jsx("path",{d:"M7 6v-1h11v1"}),p.jsx("path",{d:"M7 19l4 0"}),p.jsx("path",{d:"M13 5l-4 14"})]})}function Sk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M19 18v-8l-2 2"}),p.jsx("path",{d:"M4 6v12"}),p.jsx("path",{d:"M12 6v12"}),p.jsx("path",{d:"M11 18h2"}),p.jsx("path",{d:"M3 18h2"}),p.jsx("path",{d:"M4 12h8"}),p.jsx("path",{d:"M3 6h2"}),p.jsx("path",{d:"M11 6h2"})]})}function vk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591 -.417 1.318 -.816 1.858l-3.184 4.143l4 0"}),p.jsx("path",{d:"M4 6v12"}),p.jsx("path",{d:"M12 6v12"}),p.jsx("path",{d:"M11 18h2"}),p.jsx("path",{d:"M3 18h2"}),p.jsx("path",{d:"M4 12h8"}),p.jsx("path",{d:"M3 6h2"}),p.jsx("path",{d:"M11 6h2"})]})}function Ck(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M19 14a2 2 0 1 0 -2 -2"}),p.jsx("path",{d:"M17 16a2 2 0 1 0 2 -2"}),p.jsx("path",{d:"M4 6v12"}),p.jsx("path",{d:"M12 6v12"}),p.jsx("path",{d:"M11 18h2"}),p.jsx("path",{d:"M3 18h2"}),p.jsx("path",{d:"M4 12h8"}),p.jsx("path",{d:"M3 6h2"}),p.jsx("path",{d:"M11 6h2"})]})}function Mk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M20 18v-8l-4 6h5"}),p.jsx("path",{d:"M4 6v12"}),p.jsx("path",{d:"M12 6v12"}),p.jsx("path",{d:"M11 18h2"}),p.jsx("path",{d:"M3 18h2"}),p.jsx("path",{d:"M4 12h8"}),p.jsx("path",{d:"M3 6h2"}),p.jsx("path",{d:"M11 6h2"})]})}function wk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M17 18h2a2 2 0 1 0 0 -4h-2v-4h4"}),p.jsx("path",{d:"M4 6v12"}),p.jsx("path",{d:"M12 6v12"}),p.jsx("path",{d:"M11 18h2"}),p.jsx("path",{d:"M3 18h2"}),p.jsx("path",{d:"M4 12h8"}),p.jsx("path",{d:"M3 6h2"}),p.jsx("path",{d:"M11 6h2"})]})}function Ek(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M19 14a2 2 0 1 0 0 4a2 2 0 0 0 0 -4z"}),p.jsx("path",{d:"M21 12a2 2 0 1 0 -4 0v4"}),p.jsx("path",{d:"M4 6v12"}),p.jsx("path",{d:"M12 6v12"}),p.jsx("path",{d:"M11 18h2"}),p.jsx("path",{d:"M3 18h2"}),p.jsx("path",{d:"M4 12h8"}),p.jsx("path",{d:"M3 6h2"}),p.jsx("path",{d:"M11 6h2"})]})}function Tk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M9 6l11 0"}),p.jsx("path",{d:"M9 12l11 0"}),p.jsx("path",{d:"M9 18l11 0"}),p.jsx("path",{d:"M5 6l0 .01"}),p.jsx("path",{d:"M5 12l0 .01"}),p.jsx("path",{d:"M5 18l0 .01"})]})}function Ok(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M11 6h9"}),p.jsx("path",{d:"M11 12h9"}),p.jsx("path",{d:"M12 18h8"}),p.jsx("path",{d:"M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4"}),p.jsx("path",{d:"M6 10v-6l-2 2"})]})}function Dk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M17 22v-2"}),p.jsx("path",{d:"M9 15l6 -6"}),p.jsx("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),p.jsx("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"}),p.jsx("path",{d:"M20 17h2"}),p.jsx("path",{d:"M2 7h2"}),p.jsx("path",{d:"M7 2v2"})]})}function Ak(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M6 15h15"}),p.jsx("path",{d:"M21 19h-15"}),p.jsx("path",{d:"M15 11h6"}),p.jsx("path",{d:"M21 7h-6"}),p.jsx("path",{d:"M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"}),p.jsx("path",{d:"M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2"})]})}function Nk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M4 6l16 0"}),p.jsx("path",{d:"M4 12l10 0"}),p.jsx("path",{d:"M4 18l14 0"})]})}function Rk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M4 6l16 0"}),p.jsx("path",{d:"M10 12l10 0"}),p.jsx("path",{d:"M6 18l14 0"})]})}function Lk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M4 6l16 0"}),p.jsx("path",{d:"M8 12l8 0"}),p.jsx("path",{d:"M6 18l12 0"})]})}function Ik(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M4 6l16 0"}),p.jsx("path",{d:"M4 12l16 0"}),p.jsx("path",{d:"M4 18l12 0"})]})}function jk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M5 7l8 10m-8 0l8 -10"}),p.jsx("path",{d:"M21 20h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function Pk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M5 7l8 10m-8 0l8 -10"}),p.jsx("path",{d:"M21 11h-4l3.5 -4a1.73 1.73 0 0 0 -3.5 -2"})]})}function lh(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M7 8l-4 4l4 4"}),p.jsx("path",{d:"M17 8l4 4l-4 4"}),p.jsx("path",{d:"M14 4l-4 16"})]})}function _k(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M3 19h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),p.jsx("path",{d:"M12.5 5.5l4 4"}),p.jsx("path",{d:"M4.5 13.5l4 4"}),p.jsx("path",{d:"M21 15v4h-8l4 -4z"})]})}function Bk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M5 12h2"}),p.jsx("path",{d:"M17 12h2"}),p.jsx("path",{d:"M11 12h2"})]})}function ah(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M20.042 16.045a9 9 0 0 0 -12.087 -12.087m-2.318 1.677a9 9 0 1 0 12.725 12.73"}),p.jsx("path",{d:"M3 3l18 18"})]})}function Fk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M11 7l6 6"}),p.jsx("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]})}function zk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M18 6l-12 12"}),p.jsx("path",{d:"M6 6l12 12"})]})}function Vk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25"}),p.jsx("path",{d:"M8.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),p.jsx("path",{d:"M12.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),p.jsx("path",{d:"M16.5 10.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]})}function Hk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M5 12l5 5l10 -10"})]})}function $k(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M9 15l6 -6"}),p.jsx("path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"}),p.jsx("path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"})]})}function Wk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6"}),p.jsx("path",{d:"M11 13l9 -9"}),p.jsx("path",{d:"M15 4h5v5"})]})}function Yk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M9 14l-4 -4l4 -4"}),p.jsx("path",{d:"M5 10h11a4 4 0 1 1 0 8h-1"})]})}function Uk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M15 14l4 -4l-4 -4"}),p.jsx("path",{d:"M19 10h-11a4 4 0 1 0 0 8h1"})]})}function qk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M3.5 5.5l1.5 1.5l2.5 -2.5"}),p.jsx("path",{d:"M3.5 11.5l1.5 1.5l2.5 -2.5"}),p.jsx("path",{d:"M3.5 17.5l1.5 1.5l2.5 -2.5"}),p.jsx("path",{d:"M11 6l9 0"}),p.jsx("path",{d:"M11 12l9 0"}),p.jsx("path",{d:"M11 18l9 0"})]})}function Kk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M20 6l-11 0"}),p.jsx("path",{d:"M20 12l-7 0"}),p.jsx("path",{d:"M20 18l-11 0"}),p.jsx("path",{d:"M4 8l4 4l-4 4"})]})}function Jk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:"M20 6l-7 0"}),p.jsx("path",{d:"M20 12l-9 0"}),p.jsx("path",{d:"M20 18l-7 0"}),p.jsx("path",{d:"M8 8l-4 4l4 4"})]})}function Gk(n){return p.jsxs(he,{...n,children:[p.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p.jsx("path",{d:`M19 3v16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V7.914
|
|
158
158
|
a1 1 0 0 1 .293-.707l3.914-3.914A1 1 0 0 1 9.914 3H18
|
|
159
|
-
a1 1 0 0 1 1 1Z`}),p.jsx("path",{d:"M10 11l-2 2 2 2"}),p.jsx("path",{d:"M14 11l2 2-2 2"})]})}const Xk={interactive:!0},Tn=x.factory((n,e)=>{const t=x.useProps("RichTextEditorControl",Xk,n),{classNames:r,className:s,style:o,styles:i,vars:l,interactive:a,active:c,onMouseDown:u,disabled:d,...f}=t,h=vt();return p.jsx(x.UnstyledButton,{...f,...h.getStyles("control",{className:s,style:o,classNames:r,styles:i}),disabled:d,"data-rich-text-editor-control":!0,tabIndex:a?0:-1,"data-interactive":a||void 0,"data-disabled":d||void 0,"data-active":c||void 0,"aria-pressed":c&&a||void 0,"aria-hidden":!a||void 0,ref:e,unstyled:h.unstyled,variant:h.variant||"default",onMouseDown:m=>{m.preventDefault(),u==null||u(m)}})});Tn.classes=En;Tn.displayName="@mantine/tiptap/RichTextEditorControl";const ta=E.forwardRef(({className:n,icon:e,...t},r)=>{const s=vt();return p.jsx(Tn,{ref:r,...t,children:p.jsx(e,{...s.getStyles("controlIcon")})})});ta.displayName="@mantine/tiptap/RichTextEditorControlBase";function ge({label:n,isActive:e,operation:t,icon:r,isDisabled:s}){const o=E.forwardRef((i,l)=>{const{editor:a,labels:c}=vt(),u=c[n];return p.jsx(ta,{"aria-label":u,title:u,active:e!=null&&e.name?a==null?void 0:a.isActive(e.name,e.attributes):!1,ref:l,onClick:()=>a==null?void 0:a.chain().focus()[t.name](t.attributes).run(),icon:i.icon||r,disabled:(s==null?void 0:s(a))||!1,...i})});return o.displayName=`@mantine/tiptap/${n}`,o}const Qk=ge({label:"boldControlLabel",icon:n=>p.jsx(gk,{...n}),isActive:{name:"bold"},operation:{name:"toggleBold"}}),Zk=ge({label:"italicControlLabel",icon:n=>p.jsx(yk,{...n}),isActive:{name:"italic"},operation:{name:"toggleItalic"}}),eS=ge({label:"underlineControlLabel",icon:n=>p.jsx(bk,{...n}),isActive:{name:"underline"},operation:{name:"toggleUnderline"}}),tS=ge({label:"strikeControlLabel",icon:n=>p.jsx(xk,{...n}),isActive:{name:"strike"},operation:{name:"toggleStrike"}}),nS=ge({label:"clearFormattingControlLabel",icon:n=>p.jsx(kk,{...n}),operation:{name:"unsetAllMarks"}}),rS=ge({label:"unlinkControlLabel",icon:n=>p.jsx(Dk,{...n}),operation:{name:"unsetLink"}}),sS=ge({label:"bulletListControlLabel",icon:n=>p.jsx(Tk,{...n}),isActive:{name:"bulletList"},operation:{name:"toggleBulletList"}}),oS=ge({label:"orderedListControlLabel",icon:n=>p.jsx(Ok,{...n}),isActive:{name:"orderedList"},operation:{name:"toggleOrderedList"}}),iS=ge({label:"h1ControlLabel",icon:n=>p.jsx(Sk,{...n}),isActive:{name:"heading",attributes:{level:1}},operation:{name:"toggleHeading",attributes:{level:1}}}),lS=ge({label:"h2ControlLabel",icon:n=>p.jsx(vk,{...n}),isActive:{name:"heading",attributes:{level:2}},operation:{name:"toggleHeading",attributes:{level:2}}}),aS=ge({label:"h3ControlLabel",icon:n=>p.jsx(Ck,{...n}),isActive:{name:"heading",attributes:{level:3}},operation:{name:"toggleHeading",attributes:{level:3}}}),cS=ge({label:"h4ControlLabel",icon:n=>p.jsx(Mk,{...n}),isActive:{name:"heading",attributes:{level:4}},operation:{name:"toggleHeading",attributes:{level:4}}}),uS=ge({label:"h5ControlLabel",icon:n=>p.jsx(wk,{...n}),isActive:{name:"heading",attributes:{level:5}},operation:{name:"toggleHeading",attributes:{level:5}}}),dS=ge({label:"h6ControlLabel",icon:n=>p.jsx(Ek,{...n}),isActive:{name:"heading",attributes:{level:6}},operation:{name:"toggleHeading",attributes:{level:6}}}),fS=ge({label:"blockquoteControlLabel",icon:n=>p.jsx(Ak,{...n}),isActive:{name:"blockquote"},operation:{name:"toggleBlockquote"}}),hS=ge({label:"alignLeftControlLabel",icon:n=>p.jsx(Nk,{...n}),operation:{name:"setTextAlign",attributes:"left"}}),pS=ge({label:"alignRightControlLabel",icon:n=>p.jsx(Rk,{...n}),operation:{name:"setTextAlign",attributes:"right"}}),mS=ge({label:"alignCenterControlLabel",icon:n=>p.jsx(Lk,{...n}),operation:{name:"setTextAlign",attributes:"center"}}),gS=ge({label:"alignJustifyControlLabel",icon:n=>p.jsx(Ik,{...n}),operation:{name:"setTextAlign",attributes:"justify"}}),yS=ge({label:"subscriptControlLabel",icon:n=>p.jsx(jk,{...n}),isActive:{name:"subscript"},operation:{name:"toggleSubscript"}}),bS=ge({label:"superscriptControlLabel",icon:n=>p.jsx(Pk,{...n}),isActive:{name:"superscript"},operation:{name:"toggleSuperscript"}}),xS=ge({label:"codeControlLabel",icon:n=>p.jsx(lh,{...n}),isActive:{name:"code"},operation:{name:"toggleCode"}}),kS=ge({label:"codeBlockControlLabel",icon:n=>p.jsx(lh,{...n}),isActive:{name:"codeBlock"},operation:{name:"toggleCodeBlock"}}),SS=ge({label:"highlightControlLabel",icon:n=>p.jsx(_k,{...n}),isActive:{name:"highlight"},operation:{name:"toggleHighlight"}}),vS=ge({label:"hrControlLabel",icon:n=>p.jsx(Bk,{...n}),operation:{name:"setHorizontalRule"}}),CS=ge({label:"unsetColorControlLabel",icon:n=>p.jsx(ah,{...n}),operation:{name:"unsetColor"}}),MS=ge({label:"undoControlLabel",icon:n=>p.jsx(Yk,{...n}),isDisabled:n=>!(n!=null&&n.can().undo()),operation:{name:"undo"}}),wS=ge({label:"redoControlLabel",icon:n=>p.jsx(Uk,{...n}),isDisabled:n=>!(n!=null&&n.can().redo()),operation:{name:"redo"}}),ES=ge({label:"tasksControlLabel",icon:n=>p.jsx(qk,{...n}),isActive:{name:"taskList"},operation:{name:"toggleTaskList"}}),TS=ge({label:"tasksSinkLabel",icon:n=>p.jsx(Kk,{...n}),operation:{name:"sinkListItem",attributes:"taskItem"},isDisabled:n=>!(n!=null&&n.can().sinkListItem("taskItem"))}),OS=ge({label:"tasksLiftLabel",icon:n=>p.jsx(Jk,{...n}),operation:{name:"liftListItem",attributes:"taskItem"},isDisabled:n=>!(n!=null&&n.can().liftListItem("taskItem"))}),DS=n=>p.jsx($k,{...n}),na=x.factory((n,e)=>{var $;const t=x.useProps("RichTextEditorLinkControl",null,n),{classNames:r,className:s,style:o,styles:i,vars:l,icon:a,popoverProps:c,disableTooltips:u,initialExternal:d,...f}=t,h=vt(),m={classNames:r,styles:i},[y,g]=ip(""),[b,k]=E.useState(d),[C,{open:T,close:M}]=cl(!1),v=()=>{var K;T();const F=(K=h.editor)==null?void 0:K.getAttributes("link");g((F==null?void 0:F.href)||""),k(F!=null&&F.href?(F==null?void 0:F.target)==="_blank":d)},w=()=>{M(),g(""),k(d)},O=()=>{var F,K;w(),y===""?(F=h.editor)==null||F.chain().focus().extendMarkRange("link").unsetLink().run():(K=h.editor)==null||K.chain().focus().extendMarkRange("link").setLink({href:y,target:b?"_blank":null}).run()},A=F=>{F.key==="Enter"&&(F.preventDefault(),O())};rp("edit-link",v,!1);const{resolvedClassNames:B,resolvedStyles:Y}=x.useResolvedStylesApi({classNames:r,styles:i,props:t});return p.jsxs(x.Popover,{trapFocus:!0,shadow:"md",withinPortal:!0,opened:C,onChange:F=>!F&&w(),offset:-44,zIndex:1e4,...c,children:[p.jsx(x.Popover.Target,{children:p.jsx(ta,{icon:a||DS,...f,"aria-label":h.labels.linkControlLabel,title:h.labels.linkControlLabel,onClick:v,active:($=h.editor)==null?void 0:$.isActive("link"),ref:e,classNames:B,styles:Y,className:s,style:o,variant:h.variant})}),p.jsx(x.Popover.Dropdown,{...h.getStyles("linkEditorDropdown",m),children:p.jsxs("div",{...h.getStyles("linkEditor",m),children:[p.jsx(x.TextInput,{placeholder:h.labels.linkEditorInputPlaceholder,"aria-label":h.labels.linkEditorInputLabel,type:"url",value:y,onChange:g,classNames:{input:h.getStyles("linkEditorInput",m).className},onKeyDown:A,rightSection:p.jsx(x.Tooltip,{label:b?h.labels.linkEditorExternalLink:h.labels.linkEditorInternalLink,events:{hover:!0,focus:!0,touch:!0},withinPortal:!0,withArrow:!0,disabled:u,zIndex:1e4,children:p.jsx(x.UnstyledButton,{onClick:()=>k(F=>!F),"data-active":b||void 0,...h.getStyles("linkEditorExternalControl",m),children:p.jsx(Wk,{style:{width:x.rem(14),height:x.rem(14)}})})})}),p.jsx(x.Button,{variant:"default",onClick:O,...h.getStyles("linkEditorSave",m),children:h.labels.linkEditorSave})]})})]})});na.classes=En;na.displayName="@mantine/tiptap/RichTextEditorLinkControl";const ch=E.forwardRef((n,e)=>{const{popoverProps:t,colors:r,colorPickerProps:s,...o}=x.useProps("RichTextEditorColorPickerControl",null,n),{editor:i,labels:l,getStyles:a,variant:c}=vt(),[u,{toggle:d,close:f}]=cl(!1),[h,m]=E.useState("palette"),y=(i==null?void 0:i.getAttributes("textStyle").color)||"var(--mantine-color-text)",g=(C,T=!0)=>{(i==null?void 0:i.chain()).focus().setColor(C).run(),T&&f()},b=()=>{(i==null?void 0:i.chain()).focus().unsetColor().run(),f()},k=r.map((C,T)=>p.jsx(x.ColorSwatch,{component:"button",color:C,onClick:()=>g(C),size:26,radius:"xs",style:{cursor:"pointer"},title:l.colorPickerColorLabel(C),"aria-label":l.colorPickerColorLabel(C)},T));return p.jsxs(x.Popover,{opened:u,withinPortal:!0,trapFocus:!0,onChange:C=>!C&&f(),...t,children:[p.jsx(x.Popover.Target,{children:p.jsx(Tn,{...o,variant:c,"aria-label":l.colorPickerControlLabel,title:l.colorPickerControlLabel,ref:e,onClick:d,children:p.jsx(x.ColorSwatch,{color:y,size:14})})}),p.jsxs(x.Popover.Dropdown,{...a("linkEditorDropdown"),children:[h==="palette"&&p.jsx(x.SimpleGrid,{cols:7,spacing:2,children:k}),h==="colorPicker"&&p.jsx(x.ColorPicker,{defaultValue:y,onChange:C=>g(C,!1),...s}),p.jsx(x.Tooltip.Group,{closeDelay:200,children:p.jsxs(x.Group,{justify:"flex-end",gap:"xs",mt:"sm",children:[h==="palette"&&p.jsx(x.ActionIcon,{variant:"default",onClick:f,title:l.colorPickerCancel,"aria-label":l.colorPickerCancel,children:p.jsx(zk,{style:{width:x.rem(16),height:x.rem(16)}})}),p.jsx(x.ActionIcon,{variant:"default",onClick:b,title:l.colorPickerClear,"aria-label":l.colorPickerClear,children:p.jsx(ah,{style:{width:x.rem(16),height:x.rem(16)}})}),h==="palette"?p.jsx(x.ActionIcon,{variant:"default",onClick:()=>m("colorPicker"),title:l.colorPickerColorPicker,"aria-label":l.colorPickerColorPicker,children:p.jsx(Fk,{style:{width:x.rem(16),height:x.rem(16)}})}):p.jsx(x.ActionIcon,{variant:"default",onClick:()=>m("palette"),"aria-label":l.colorPickerPalette,title:l.colorPickerPalette,children:p.jsx(Vk,{style:{width:x.rem(16),height:x.rem(16)}})}),h==="colorPicker"&&p.jsx(x.ActionIcon,{variant:"default",onClick:f,title:l.colorPickerSave,"aria-label":l.colorPickerSave,children:p.jsx(Hk,{style:{width:x.rem(16),height:x.rem(16)}})})]})})]})]})});ch.displayName="@mantine/tiptap/ColorPickerControl";const uh=E.forwardRef((n,e)=>{const{color:t,...r}=x.useProps("RichTextEditorColorControl",null,n),{editor:s,labels:o,variant:i}=vt(),l=(s==null?void 0:s.getAttributes("textStyle").color)||null,a=o.colorControlLabel(t);return p.jsx(Tn,{...r,variant:i,active:l===t,"aria-label":a,title:a,onClick:()=>(s==null?void 0:s.chain()).focus().setColor(t).run(),ref:e,children:p.jsx(x.ColorSwatch,{color:t,size:14})})});uh.displayName="@mantine/tiptap/RichTextEditorColorControl";const AS={},dh=E.forwardRef((n,e)=>{const{...t}=x.useProps("RichTextEditorSourceCodeControl",AS,n),{editor:r,labels:s,variant:o,onSourceCodeTextSwitch:i}=vt(),[l,a]=E.useState(!1),c=()=>{l?r==null||r.commands.setContent(r.getText(),{emitUpdate:!0}):r==null||r.commands.setContent(`<textarea>${r.getHTML()}</textarea>`);const u=!l;a(u),i==null||i(u)};return p.jsx(Tn,{...t,variant:o,active:l,"aria-label":s.sourceCodeControlLabel,title:s.sourceCodeControlLabel,onClick:()=>c(),ref:e,children:p.jsx(Gk,{style:{width:x.rem(16),height:x.rem(16)}})})});dh.displayName="@mantine/tiptap/RichTextEditorSourceCodeControl";const ra=x.factory((n,e)=>{const t=x.useProps("RichTextEditorControlsGroup",null,n),{classNames:r,className:s,style:o,styles:i,vars:l,variant:a,...c}=t,u=vt();return p.jsx(x.Box,{ref:e,variant:a||u.variant,...u.getStyles("controlsGroup",{className:s,style:o,styles:i,classNames:r}),...c})});ra.classes=En;ra.displayName="@mantine/tiptap/RichTextEditorControlsGroup";const sa=x.factory((n,e)=>{const t=x.useProps("RichTextEditorToolbar",null,n),{classNames:r,className:s,style:o,styles:i,vars:l,sticky:a,stickyOffset:c,mod:u,variant:d,...f}=t,h=vt();return p.jsx(x.Box,{ref:e,mod:[{sticky:a},u],variant:d||h.variant,...h.getStyles("toolbar",{className:s,style:o,styles:i,classNames:r}),...f,__vars:{"--rte-sticky-offset":x.rem(c)}})});sa.classes=En;sa.displayName="@mantine/tiptap/RichTextEditorToolbar";const NS={withCodeHighlightStyles:!0,withTypographyStyles:!0,variant:"default"},z=x.factory((n,e)=>{const t=x.useProps("RichTextEditor",NS,n),{classNames:r,className:s,style:o,styles:i,unstyled:l,vars:a,editor:c,withCodeHighlightStyles:u,withTypographyStyles:d,onSourceCodeTextSwitch:f,labels:h,children:m,variant:y,attributes:g,...b}=t,k=x.useStyles({name:"RichTextEditor",classes:En,props:t,className:s,style:o,classNames:r,styles:i,unstyled:l,attributes:g,vars:a}),C=E.useMemo(()=>({...pk,...h}),[h]);return p.jsx(mk,{value:{editor:c,getStyles:k,labels:C,withCodeHighlightStyles:u,withTypographyStyles:d,onSourceCodeTextSwitch:f,unstyled:l,variant:y},children:p.jsx(x.Box,{...k("root"),...b,ref:e,children:m})})});z.classes=En;z.displayName="@mantine/tiptap/RichTextEditor";z.Content=ea;z.Control=Tn;z.Toolbar=sa;z.ControlsGroup=ra;z.Bold=Qk;z.Italic=Zk;z.Strikethrough=tS;z.Underline=eS;z.ClearFormatting=nS;z.H1=iS;z.H2=lS;z.H3=aS;z.H4=cS;z.H5=uS;z.H6=dS;z.BulletList=sS;z.OrderedList=oS;z.Link=na;z.Unlink=rS;z.Blockquote=fS;z.AlignLeft=hS;z.AlignRight=pS;z.AlignCenter=mS;z.AlignJustify=gS;z.Superscript=bS;z.Subscript=yS;z.Code=xS;z.CodeBlock=kS;z.ColorPicker=ch;z.Color=uh;z.Highlight=SS;z.Hr=vS;z.UnsetColor=CS;z.Undo=MS;z.Redo=wS;z.TaskList=ES;z.TaskListSink=TS;z.TaskListLift=OS;z.SourceCode=dh;function RS({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0,o=v1({editable:!r&&!s,extensions:[rk,Lx,bx,dk,hk,lk,ck.configure({types:["heading","paragraph"]})],content:t.value||"",onUpdate:({editor:i})=>{t.onChange(i.getHTML())}});return p.jsxs(z,{editor:o,h:400,children:[p.jsxs(z.Toolbar,{sticky:!0,stickyOffset:60,children:[p.jsxs(z.ControlsGroup,{children:[p.jsx(z.Bold,{}),p.jsx(z.Italic,{}),p.jsx(z.Underline,{}),p.jsx(z.Strikethrough,{}),p.jsx(z.ClearFormatting,{}),p.jsx(z.Highlight,{}),p.jsx(z.Code,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.H1,{}),p.jsx(z.H2,{}),p.jsx(z.H3,{}),p.jsx(z.H4,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.Blockquote,{}),p.jsx(z.Hr,{}),p.jsx(z.BulletList,{}),p.jsx(z.OrderedList,{}),p.jsx(z.Subscript,{}),p.jsx(z.Superscript,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.Link,{}),p.jsx(z.Unlink,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.AlignLeft,{}),p.jsx(z.AlignCenter,{}),p.jsx(z.AlignJustify,{}),p.jsx(z.AlignRight,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.Undo,{}),p.jsx(z.Redo,{})]})]}),p.jsx(z.Content,{})]})}function LS({field:n,form:e}){const t=n,r=e.getInputProps(t.name),s=t.readOnly===!0,o=t.disabled===!0;return s||o?p.jsx(x.Select,{data:t.data,value:r.value,disabled:o||s,readOnly:s,placeholder:t.placeholder,required:t.required,variant:s?"filled":"default",error:void 0}):p.jsx(x.Select,{...r,data:t.data,placeholder:t.placeholder,error:void 0,onChange:i=>r.onFieldChange(i)})}function IS({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0;return r||s?p.jsx(x.Switch,{value:t.value,readOnly:r,disabled:s,required:n.required,placeholder:n.placeholder,variant:r?"filled":"default",error:void 0,checked:t.value}):p.jsx(x.Switch,{...t,checked:t.value,onChange:o=>t.onFieldChange(o.target.checked),required:n.required,placeholder:n.placeholder,error:void 0})}function jS({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0;return r||s?p.jsx(x.TagsInput,{value:t.value||[],readOnly:r,disabled:s,required:n.required,placeholder:n.placeholder,variant:r?"filled":"default",error:void 0}):p.jsx(x.TagsInput,{value:t.value||[],onChange:o=>t.onChange(o),required:n.required,placeholder:n.placeholder,error:void 0})}function PS({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0;return r||s?p.jsx(x.TextInput,{value:t.value,readOnly:r,disabled:s,required:n.required,placeholder:n.placeholder,variant:r?"filled":"default",error:void 0}):p.jsx(x.TextInput,{...t,onChange:o=>t.onFieldChange(o.target.value),required:n.required,placeholder:n.placeholder,error:void 0})}function _S({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0,o=typeof t.value=="string"?t.value:"",i=E.useRef(null),l=p.jsx(x.ActionIcon,{variant:"subtle",color:"gray",onClick:()=>{var a;return(a=i.current)==null?void 0:a.showPicker()},children:"⏰"});return r||s?p.jsx(ds,{value:o,readOnly:r,disabled:s,required:n.required,placeholder:n.placeholder,variant:r?"filled":"default",error:void 0}):p.jsx(ds,{value:o,onChange:a=>t.onChange(a.currentTarget.value),required:n.required,placeholder:n.placeholder,error:void 0,ref:i,rightSection:l})}function BS({field:n,form:e,children:t}){const{error:r}=e.getInputProps(n.name);return p.jsxs(x.Stack,{gap:4,children:[n.label&&p.jsxs(x.Text,{fw:500,size:"sm",mb:2,component:"label",htmlFor:n.name,style:{display:"block"},children:[n.label," ",n.required&&p.jsx(x.Text,{component:"span",c:"red",fz:"sm",children:"*"})]}),p.jsx(x.Box,{children:t}),n.description&&p.jsx(x.Text,{size:"xs",c:"dimmed",mt:2,style:{lineHeight:1.4},children:n.description}),r&&p.jsx(x.Text,{size:"xs",c:"red",mt:2,style:{fontWeight:500},children:r})]})}function FS(n){const{layout:e,field:{required:t,...r},form:s}=n;let o=null;switch(r.type){case"text":o=p.jsx(PS,{field:r,form:n.form});break;case"select":o=p.jsx(LS,{field:r,form:n.form});break;case"object":o=p.jsx(cm,{field:r,form:s,layout:e});break;case"array":o=p.jsx(zh,{field:r,form:s,layout:e});break;case"checkbox":o=p.jsx(Vh,{field:r,form:s});break;case"number":o=p.jsx(am,{field:r,form:s});break;case"date":o=p.jsx(im,{field:r,form:s});break;case"datetime":o=p.jsx(lm,{field:r,form:s});break;case"switch":o=p.jsx(IS,{field:r,form:s});break;case"texteditor":o=p.jsx(RS,{field:r,form:s});break;case"time":o=p.jsx(_S,{field:r,form:s});break;case"tags":o=p.jsx(jS,{field:r,form:s});break;default:o=p.jsxs("div",{children:["Unsupported field type: ",r.type]});break}return p.jsx(BS,{field:r,form:s,children:o})}class Io{constructor(){ca(this,"next")}setNext(e){return this.next=e,e}handle(e,t){var r;return this.canHandle(e)?this.render(e,t):((r=this.next)==null?void 0:r.handle(e,t))??null}}class zS extends Io{constructor(e){super(),this.layout=e}canHandle(){return!0}render(e,t){return p.jsx(FS,{field:e,form:t,layout:this.layout})}}class VS extends Io{constructor(e){super(),this.customFieldTypes=e}canHandle(e){return!!this.customFieldTypes[e.type]}render(e,t){return this.customFieldTypes[e.type](e,t)}}class HS extends Io{constructor(e){super(),this.fieldRenderers=e}canHandle(e){return!!this.fieldRenderers[e.name]}render(e,t){return this.fieldRenderers[e.name](e,t)}}class $S extends Io{constructor(e){super(),this.typeRenderers=e}canHandle(e){return!!this.typeRenderers[e.type]}render(e,t){return this.typeRenderers[e.type](e,t)}}const jo=n=>{const{field:e,form:t,customFieldRenderers:r,customTypeRenderers:s,customFieldTypes:o,layout:i="grid"}=n,l=new HS(r??{}),a=new $S(s??{}),c=new zS(i),u=new VS(o??{});return l.setNext(a).setNext(u).setNext(c),l.handle(e,t)},WS=E.createContext(null),YS=({children:n,value:e})=>p.jsx(WS.Provider,{value:e,children:n}),US=E.forwardRef(function({schema:e,values:t,getInitialValues:r,layout:s="vertical",readOnly:o,validate:i,onSubmit:l,onFieldChange:a,updateFieldSchema:c,transformBeforeSubmit:u=k=>k,transformAfterSubmit:d=()=>{},submitButton:f=!0,customFieldRenderers:h,customFieldTypes:m,customTypeRenderers:y,loading:g},b){const[k,C]=E.useState(!0),T=Fh({validate:i,enhanceGetInputProps(O){return{onFieldChange:async A=>{var B;O.inputProps.onChange(A),await((B=a==null?void 0:a[O.field])==null?void 0:B.call(a,A,T))}}}}),M=il[s],v=E.useMemo(()=>{if(!c)return e;const O=T.getValues();return e.map(A=>{const B=c[A.name];return B?B(A,O):A})},[e,T.values,c]),w=T.onSubmit(async O=>{const A=Di(e,O);if(Object.keys(A).length){T.setErrors(A);return}const B=await u(O);await l(B),d(B)});return E.useImperativeHandle(b,()=>({submit:()=>w(),reset:O=>{const A=ar(e,O);T.setValues(A),T.setDirty(A)},validate:()=>{const O=T.validate();return Object.keys(O.errors).length===0},getValues:()=>T.getValues(),setValues:O=>T.setValues(O),getFieldValue:O=>T.getInputProps(O).value,setFieldValue:(O,A)=>T.setFieldValue(O,A),isValid:()=>Object.keys(T.validate().errors).length===0,isDirty:()=>T.isDirty()})),E.useEffect(()=>{if(t){const O=ar(e,t);T.setValues(O),T.resetDirty(O)}},[t,e]),E.useEffect(()=>{async function O(){const A=r?await r():{};T.initialize(ar(e,A)),C(!1)}O()},[e]),p.jsx(YS,{value:{customFieldRenderers:h,customTypeRenderers:y,customFieldTypes:m},children:p.jsxs("form",{onSubmit:w,style:{position:"relative"},children:[p.jsx(x.LoadingOverlay,{visible:k||g}),M(p.jsx(p.Fragment,{children:v.map(O=>{const A={...O,readOnly:O.readOnly||o};return A.visible?p.jsx(so,{field:A,layout:s,children:p.jsx(jo,{field:A,form:T,customFieldRenderers:h,customTypeRenderers:y,customFieldTypes:m,layout:s})},A.name):null})})),typeof f=="boolean"?f?p.jsx(x.Group,{justify:"flex-end",mt:"md",children:p.jsx(x.Button,{type:"submit",loading:g,children:"Submit"})}):null:f]})})});exports.AutoForm=US;exports.FieldLayoutWrapper=so;exports.FieldRendererResolver=jo;
|
|
159
|
+
a1 1 0 0 1 1 1Z`}),p.jsx("path",{d:"M10 11l-2 2 2 2"}),p.jsx("path",{d:"M14 11l2 2-2 2"})]})}const Xk={interactive:!0},Tn=x.factory((n,e)=>{const t=x.useProps("RichTextEditorControl",Xk,n),{classNames:r,className:s,style:o,styles:i,vars:l,interactive:a,active:c,onMouseDown:u,disabled:d,...f}=t,h=vt();return p.jsx(x.UnstyledButton,{...f,...h.getStyles("control",{className:s,style:o,classNames:r,styles:i}),disabled:d,"data-rich-text-editor-control":!0,tabIndex:a?0:-1,"data-interactive":a||void 0,"data-disabled":d||void 0,"data-active":c||void 0,"aria-pressed":c&&a||void 0,"aria-hidden":!a||void 0,ref:e,unstyled:h.unstyled,variant:h.variant||"default",onMouseDown:m=>{m.preventDefault(),u==null||u(m)}})});Tn.classes=En;Tn.displayName="@mantine/tiptap/RichTextEditorControl";const ta=E.forwardRef(({className:n,icon:e,...t},r)=>{const s=vt();return p.jsx(Tn,{ref:r,...t,children:p.jsx(e,{...s.getStyles("controlIcon")})})});ta.displayName="@mantine/tiptap/RichTextEditorControlBase";function ge({label:n,isActive:e,operation:t,icon:r,isDisabled:s}){const o=E.forwardRef((i,l)=>{const{editor:a,labels:c}=vt(),u=c[n];return p.jsx(ta,{"aria-label":u,title:u,active:e!=null&&e.name?a==null?void 0:a.isActive(e.name,e.attributes):!1,ref:l,onClick:()=>a==null?void 0:a.chain().focus()[t.name](t.attributes).run(),icon:i.icon||r,disabled:(s==null?void 0:s(a))||!1,...i})});return o.displayName=`@mantine/tiptap/${n}`,o}const Qk=ge({label:"boldControlLabel",icon:n=>p.jsx(gk,{...n}),isActive:{name:"bold"},operation:{name:"toggleBold"}}),Zk=ge({label:"italicControlLabel",icon:n=>p.jsx(yk,{...n}),isActive:{name:"italic"},operation:{name:"toggleItalic"}}),eS=ge({label:"underlineControlLabel",icon:n=>p.jsx(bk,{...n}),isActive:{name:"underline"},operation:{name:"toggleUnderline"}}),tS=ge({label:"strikeControlLabel",icon:n=>p.jsx(xk,{...n}),isActive:{name:"strike"},operation:{name:"toggleStrike"}}),nS=ge({label:"clearFormattingControlLabel",icon:n=>p.jsx(kk,{...n}),operation:{name:"unsetAllMarks"}}),rS=ge({label:"unlinkControlLabel",icon:n=>p.jsx(Dk,{...n}),operation:{name:"unsetLink"}}),sS=ge({label:"bulletListControlLabel",icon:n=>p.jsx(Tk,{...n}),isActive:{name:"bulletList"},operation:{name:"toggleBulletList"}}),oS=ge({label:"orderedListControlLabel",icon:n=>p.jsx(Ok,{...n}),isActive:{name:"orderedList"},operation:{name:"toggleOrderedList"}}),iS=ge({label:"h1ControlLabel",icon:n=>p.jsx(Sk,{...n}),isActive:{name:"heading",attributes:{level:1}},operation:{name:"toggleHeading",attributes:{level:1}}}),lS=ge({label:"h2ControlLabel",icon:n=>p.jsx(vk,{...n}),isActive:{name:"heading",attributes:{level:2}},operation:{name:"toggleHeading",attributes:{level:2}}}),aS=ge({label:"h3ControlLabel",icon:n=>p.jsx(Ck,{...n}),isActive:{name:"heading",attributes:{level:3}},operation:{name:"toggleHeading",attributes:{level:3}}}),cS=ge({label:"h4ControlLabel",icon:n=>p.jsx(Mk,{...n}),isActive:{name:"heading",attributes:{level:4}},operation:{name:"toggleHeading",attributes:{level:4}}}),uS=ge({label:"h5ControlLabel",icon:n=>p.jsx(wk,{...n}),isActive:{name:"heading",attributes:{level:5}},operation:{name:"toggleHeading",attributes:{level:5}}}),dS=ge({label:"h6ControlLabel",icon:n=>p.jsx(Ek,{...n}),isActive:{name:"heading",attributes:{level:6}},operation:{name:"toggleHeading",attributes:{level:6}}}),fS=ge({label:"blockquoteControlLabel",icon:n=>p.jsx(Ak,{...n}),isActive:{name:"blockquote"},operation:{name:"toggleBlockquote"}}),hS=ge({label:"alignLeftControlLabel",icon:n=>p.jsx(Nk,{...n}),operation:{name:"setTextAlign",attributes:"left"}}),pS=ge({label:"alignRightControlLabel",icon:n=>p.jsx(Rk,{...n}),operation:{name:"setTextAlign",attributes:"right"}}),mS=ge({label:"alignCenterControlLabel",icon:n=>p.jsx(Lk,{...n}),operation:{name:"setTextAlign",attributes:"center"}}),gS=ge({label:"alignJustifyControlLabel",icon:n=>p.jsx(Ik,{...n}),operation:{name:"setTextAlign",attributes:"justify"}}),yS=ge({label:"subscriptControlLabel",icon:n=>p.jsx(jk,{...n}),isActive:{name:"subscript"},operation:{name:"toggleSubscript"}}),bS=ge({label:"superscriptControlLabel",icon:n=>p.jsx(Pk,{...n}),isActive:{name:"superscript"},operation:{name:"toggleSuperscript"}}),xS=ge({label:"codeControlLabel",icon:n=>p.jsx(lh,{...n}),isActive:{name:"code"},operation:{name:"toggleCode"}}),kS=ge({label:"codeBlockControlLabel",icon:n=>p.jsx(lh,{...n}),isActive:{name:"codeBlock"},operation:{name:"toggleCodeBlock"}}),SS=ge({label:"highlightControlLabel",icon:n=>p.jsx(_k,{...n}),isActive:{name:"highlight"},operation:{name:"toggleHighlight"}}),vS=ge({label:"hrControlLabel",icon:n=>p.jsx(Bk,{...n}),operation:{name:"setHorizontalRule"}}),CS=ge({label:"unsetColorControlLabel",icon:n=>p.jsx(ah,{...n}),operation:{name:"unsetColor"}}),MS=ge({label:"undoControlLabel",icon:n=>p.jsx(Yk,{...n}),isDisabled:n=>!(n!=null&&n.can().undo()),operation:{name:"undo"}}),wS=ge({label:"redoControlLabel",icon:n=>p.jsx(Uk,{...n}),isDisabled:n=>!(n!=null&&n.can().redo()),operation:{name:"redo"}}),ES=ge({label:"tasksControlLabel",icon:n=>p.jsx(qk,{...n}),isActive:{name:"taskList"},operation:{name:"toggleTaskList"}}),TS=ge({label:"tasksSinkLabel",icon:n=>p.jsx(Kk,{...n}),operation:{name:"sinkListItem",attributes:"taskItem"},isDisabled:n=>!(n!=null&&n.can().sinkListItem("taskItem"))}),OS=ge({label:"tasksLiftLabel",icon:n=>p.jsx(Jk,{...n}),operation:{name:"liftListItem",attributes:"taskItem"},isDisabled:n=>!(n!=null&&n.can().liftListItem("taskItem"))}),DS=n=>p.jsx($k,{...n}),na=x.factory((n,e)=>{var $;const t=x.useProps("RichTextEditorLinkControl",null,n),{classNames:r,className:s,style:o,styles:i,vars:l,icon:a,popoverProps:c,disableTooltips:u,initialExternal:d,...f}=t,h=vt(),m={classNames:r,styles:i},[y,g]=ip(""),[b,k]=E.useState(d),[C,{open:T,close:M}]=cl(!1),v=()=>{var K;T();const F=(K=h.editor)==null?void 0:K.getAttributes("link");g((F==null?void 0:F.href)||""),k(F!=null&&F.href?(F==null?void 0:F.target)==="_blank":d)},w=()=>{M(),g(""),k(d)},O=()=>{var F,K;w(),y===""?(F=h.editor)==null||F.chain().focus().extendMarkRange("link").unsetLink().run():(K=h.editor)==null||K.chain().focus().extendMarkRange("link").setLink({href:y,target:b?"_blank":null}).run()},A=F=>{F.key==="Enter"&&(F.preventDefault(),O())};rp("edit-link",v,!1);const{resolvedClassNames:B,resolvedStyles:Y}=x.useResolvedStylesApi({classNames:r,styles:i,props:t});return p.jsxs(x.Popover,{trapFocus:!0,shadow:"md",withinPortal:!0,opened:C,onChange:F=>!F&&w(),offset:-44,zIndex:1e4,...c,children:[p.jsx(x.Popover.Target,{children:p.jsx(ta,{icon:a||DS,...f,"aria-label":h.labels.linkControlLabel,title:h.labels.linkControlLabel,onClick:v,active:($=h.editor)==null?void 0:$.isActive("link"),ref:e,classNames:B,styles:Y,className:s,style:o,variant:h.variant})}),p.jsx(x.Popover.Dropdown,{...h.getStyles("linkEditorDropdown",m),children:p.jsxs("div",{...h.getStyles("linkEditor",m),children:[p.jsx(x.TextInput,{placeholder:h.labels.linkEditorInputPlaceholder,"aria-label":h.labels.linkEditorInputLabel,type:"url",value:y,onChange:g,classNames:{input:h.getStyles("linkEditorInput",m).className},onKeyDown:A,rightSection:p.jsx(x.Tooltip,{label:b?h.labels.linkEditorExternalLink:h.labels.linkEditorInternalLink,events:{hover:!0,focus:!0,touch:!0},withinPortal:!0,withArrow:!0,disabled:u,zIndex:1e4,children:p.jsx(x.UnstyledButton,{onClick:()=>k(F=>!F),"data-active":b||void 0,...h.getStyles("linkEditorExternalControl",m),children:p.jsx(Wk,{style:{width:x.rem(14),height:x.rem(14)}})})})}),p.jsx(x.Button,{variant:"default",onClick:O,...h.getStyles("linkEditorSave",m),children:h.labels.linkEditorSave})]})})]})});na.classes=En;na.displayName="@mantine/tiptap/RichTextEditorLinkControl";const ch=E.forwardRef((n,e)=>{const{popoverProps:t,colors:r,colorPickerProps:s,...o}=x.useProps("RichTextEditorColorPickerControl",null,n),{editor:i,labels:l,getStyles:a,variant:c}=vt(),[u,{toggle:d,close:f}]=cl(!1),[h,m]=E.useState("palette"),y=(i==null?void 0:i.getAttributes("textStyle").color)||"var(--mantine-color-text)",g=(C,T=!0)=>{(i==null?void 0:i.chain()).focus().setColor(C).run(),T&&f()},b=()=>{(i==null?void 0:i.chain()).focus().unsetColor().run(),f()},k=r.map((C,T)=>p.jsx(x.ColorSwatch,{component:"button",color:C,onClick:()=>g(C),size:26,radius:"xs",style:{cursor:"pointer"},title:l.colorPickerColorLabel(C),"aria-label":l.colorPickerColorLabel(C)},T));return p.jsxs(x.Popover,{opened:u,withinPortal:!0,trapFocus:!0,onChange:C=>!C&&f(),...t,children:[p.jsx(x.Popover.Target,{children:p.jsx(Tn,{...o,variant:c,"aria-label":l.colorPickerControlLabel,title:l.colorPickerControlLabel,ref:e,onClick:d,children:p.jsx(x.ColorSwatch,{color:y,size:14})})}),p.jsxs(x.Popover.Dropdown,{...a("linkEditorDropdown"),children:[h==="palette"&&p.jsx(x.SimpleGrid,{cols:7,spacing:2,children:k}),h==="colorPicker"&&p.jsx(x.ColorPicker,{defaultValue:y,onChange:C=>g(C,!1),...s}),p.jsx(x.Tooltip.Group,{closeDelay:200,children:p.jsxs(x.Group,{justify:"flex-end",gap:"xs",mt:"sm",children:[h==="palette"&&p.jsx(x.ActionIcon,{variant:"default",onClick:f,title:l.colorPickerCancel,"aria-label":l.colorPickerCancel,children:p.jsx(zk,{style:{width:x.rem(16),height:x.rem(16)}})}),p.jsx(x.ActionIcon,{variant:"default",onClick:b,title:l.colorPickerClear,"aria-label":l.colorPickerClear,children:p.jsx(ah,{style:{width:x.rem(16),height:x.rem(16)}})}),h==="palette"?p.jsx(x.ActionIcon,{variant:"default",onClick:()=>m("colorPicker"),title:l.colorPickerColorPicker,"aria-label":l.colorPickerColorPicker,children:p.jsx(Fk,{style:{width:x.rem(16),height:x.rem(16)}})}):p.jsx(x.ActionIcon,{variant:"default",onClick:()=>m("palette"),"aria-label":l.colorPickerPalette,title:l.colorPickerPalette,children:p.jsx(Vk,{style:{width:x.rem(16),height:x.rem(16)}})}),h==="colorPicker"&&p.jsx(x.ActionIcon,{variant:"default",onClick:f,title:l.colorPickerSave,"aria-label":l.colorPickerSave,children:p.jsx(Hk,{style:{width:x.rem(16),height:x.rem(16)}})})]})})]})]})});ch.displayName="@mantine/tiptap/ColorPickerControl";const uh=E.forwardRef((n,e)=>{const{color:t,...r}=x.useProps("RichTextEditorColorControl",null,n),{editor:s,labels:o,variant:i}=vt(),l=(s==null?void 0:s.getAttributes("textStyle").color)||null,a=o.colorControlLabel(t);return p.jsx(Tn,{...r,variant:i,active:l===t,"aria-label":a,title:a,onClick:()=>(s==null?void 0:s.chain()).focus().setColor(t).run(),ref:e,children:p.jsx(x.ColorSwatch,{color:t,size:14})})});uh.displayName="@mantine/tiptap/RichTextEditorColorControl";const AS={},dh=E.forwardRef((n,e)=>{const{...t}=x.useProps("RichTextEditorSourceCodeControl",AS,n),{editor:r,labels:s,variant:o,onSourceCodeTextSwitch:i}=vt(),[l,a]=E.useState(!1),c=()=>{l?r==null||r.commands.setContent(r.getText(),{emitUpdate:!0}):r==null||r.commands.setContent(`<textarea>${r.getHTML()}</textarea>`);const u=!l;a(u),i==null||i(u)};return p.jsx(Tn,{...t,variant:o,active:l,"aria-label":s.sourceCodeControlLabel,title:s.sourceCodeControlLabel,onClick:()=>c(),ref:e,children:p.jsx(Gk,{style:{width:x.rem(16),height:x.rem(16)}})})});dh.displayName="@mantine/tiptap/RichTextEditorSourceCodeControl";const ra=x.factory((n,e)=>{const t=x.useProps("RichTextEditorControlsGroup",null,n),{classNames:r,className:s,style:o,styles:i,vars:l,variant:a,...c}=t,u=vt();return p.jsx(x.Box,{ref:e,variant:a||u.variant,...u.getStyles("controlsGroup",{className:s,style:o,styles:i,classNames:r}),...c})});ra.classes=En;ra.displayName="@mantine/tiptap/RichTextEditorControlsGroup";const sa=x.factory((n,e)=>{const t=x.useProps("RichTextEditorToolbar",null,n),{classNames:r,className:s,style:o,styles:i,vars:l,sticky:a,stickyOffset:c,mod:u,variant:d,...f}=t,h=vt();return p.jsx(x.Box,{ref:e,mod:[{sticky:a},u],variant:d||h.variant,...h.getStyles("toolbar",{className:s,style:o,styles:i,classNames:r}),...f,__vars:{"--rte-sticky-offset":x.rem(c)}})});sa.classes=En;sa.displayName="@mantine/tiptap/RichTextEditorToolbar";const NS={withCodeHighlightStyles:!0,withTypographyStyles:!0,variant:"default"},z=x.factory((n,e)=>{const t=x.useProps("RichTextEditor",NS,n),{classNames:r,className:s,style:o,styles:i,unstyled:l,vars:a,editor:c,withCodeHighlightStyles:u,withTypographyStyles:d,onSourceCodeTextSwitch:f,labels:h,children:m,variant:y,attributes:g,...b}=t,k=x.useStyles({name:"RichTextEditor",classes:En,props:t,className:s,style:o,classNames:r,styles:i,unstyled:l,attributes:g,vars:a}),C=E.useMemo(()=>({...pk,...h}),[h]);return p.jsx(mk,{value:{editor:c,getStyles:k,labels:C,withCodeHighlightStyles:u,withTypographyStyles:d,onSourceCodeTextSwitch:f,unstyled:l,variant:y},children:p.jsx(x.Box,{...k("root"),...b,ref:e,children:m})})});z.classes=En;z.displayName="@mantine/tiptap/RichTextEditor";z.Content=ea;z.Control=Tn;z.Toolbar=sa;z.ControlsGroup=ra;z.Bold=Qk;z.Italic=Zk;z.Strikethrough=tS;z.Underline=eS;z.ClearFormatting=nS;z.H1=iS;z.H2=lS;z.H3=aS;z.H4=cS;z.H5=uS;z.H6=dS;z.BulletList=sS;z.OrderedList=oS;z.Link=na;z.Unlink=rS;z.Blockquote=fS;z.AlignLeft=hS;z.AlignRight=pS;z.AlignCenter=mS;z.AlignJustify=gS;z.Superscript=bS;z.Subscript=yS;z.Code=xS;z.CodeBlock=kS;z.ColorPicker=ch;z.Color=uh;z.Highlight=SS;z.Hr=vS;z.UnsetColor=CS;z.Undo=MS;z.Redo=wS;z.TaskList=ES;z.TaskListSink=TS;z.TaskListLift=OS;z.SourceCode=dh;function RS({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0,o=v1({editable:!r&&!s,extensions:[rk,Lx,bx,dk,hk,lk,ck.configure({types:["heading","paragraph"]})],content:t.value||"",onUpdate:({editor:i})=>{t.onChange(i.getHTML())}});return p.jsxs(z,{editor:o,h:400,children:[p.jsxs(z.Toolbar,{sticky:!0,stickyOffset:60,children:[p.jsxs(z.ControlsGroup,{children:[p.jsx(z.Bold,{}),p.jsx(z.Italic,{}),p.jsx(z.Underline,{}),p.jsx(z.Strikethrough,{}),p.jsx(z.ClearFormatting,{}),p.jsx(z.Highlight,{}),p.jsx(z.Code,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.H1,{}),p.jsx(z.H2,{}),p.jsx(z.H3,{}),p.jsx(z.H4,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.Blockquote,{}),p.jsx(z.Hr,{}),p.jsx(z.BulletList,{}),p.jsx(z.OrderedList,{}),p.jsx(z.Subscript,{}),p.jsx(z.Superscript,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.Link,{}),p.jsx(z.Unlink,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.AlignLeft,{}),p.jsx(z.AlignCenter,{}),p.jsx(z.AlignJustify,{}),p.jsx(z.AlignRight,{})]}),p.jsxs(z.ControlsGroup,{children:[p.jsx(z.Undo,{}),p.jsx(z.Redo,{})]})]}),p.jsx(z.Content,{})]})}function LS({field:n,form:e}){const t=n,r=e.getInputProps(t.name),s=t.readOnly===!0,o=t.disabled===!0;return s||o?p.jsx(x.Select,{data:t.data,value:r.value,disabled:o||s,readOnly:s,placeholder:t.placeholder,required:t.required,variant:s?"filled":"default",error:void 0}):p.jsx(x.Select,{...r,data:t.data,placeholder:t.placeholder,error:void 0,onChange:i=>r.onFieldChange(i)})}function IS({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0;return r||s?p.jsx(x.Switch,{value:t.value,readOnly:r,disabled:s,required:n.required,placeholder:n.placeholder,variant:r?"filled":"default",error:void 0,checked:t.value}):p.jsx(x.Switch,{...t,checked:t.value,onChange:o=>t.onFieldChange(o.target.checked),required:n.required,placeholder:n.placeholder,error:void 0})}function jS({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0;return r||s?p.jsx(x.TagsInput,{value:t.value||[],readOnly:r,disabled:s,required:n.required,placeholder:n.placeholder,variant:r?"filled":"default",error:void 0}):p.jsx(x.TagsInput,{value:t.value||[],onChange:o=>t.onChange(o),required:n.required,placeholder:n.placeholder,error:void 0})}function PS({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0;return r||s?p.jsx(x.TextInput,{value:t.value,readOnly:r,disabled:s,required:n.required,placeholder:n.placeholder,variant:r?"filled":"default",error:void 0}):p.jsx(x.TextInput,{...t,onChange:o=>t.onFieldChange(o.target.value),required:n.required,placeholder:n.placeholder,error:void 0})}function _S({field:n,form:e}){const t=e.getInputProps(n.name),r=n.readOnly===!0,s=n.disabled===!0,o=typeof t.value=="string"?t.value:"",i=E.useRef(null),l=p.jsx(x.ActionIcon,{variant:"subtle",color:"gray",onClick:()=>{var a;return(a=i.current)==null?void 0:a.showPicker()},children:"⏰"});return r||s?p.jsx(ds,{value:o,readOnly:r,disabled:s,required:n.required,placeholder:n.placeholder,variant:r?"filled":"default",error:void 0}):p.jsx(ds,{value:o,onChange:a=>t.onChange(a.currentTarget.value),required:n.required,placeholder:n.placeholder,error:void 0,ref:i,rightSection:l})}function BS({field:n,form:e,children:t}){const{error:r}=e.getInputProps(n.name);return p.jsxs(x.Stack,{gap:4,children:[n.label&&p.jsxs(x.Text,{fw:500,size:"sm",mb:2,component:"label",htmlFor:n.name,style:{display:"block"},children:[n.label," ",n.required&&p.jsx(x.Text,{component:"span",c:"red",fz:"sm",children:"*"})]}),p.jsx(x.Box,{children:t}),n.description&&p.jsx(x.Text,{size:"xs",c:"dimmed",mt:2,style:{lineHeight:1.4},children:n.description}),r&&p.jsx(x.Text,{size:"xs",c:"red",mt:2,style:{fontWeight:500},children:r})]})}function FS(n){const{layout:e,field:{required:t,...r},form:s}=n;let o=null;switch(r.type){case"text":o=p.jsx(PS,{field:r,form:n.form});break;case"select":o=p.jsx(LS,{field:r,form:n.form});break;case"object":o=p.jsx(cm,{field:r,form:s,layout:e});break;case"array":o=p.jsx(zh,{field:r,form:s,layout:e});break;case"checkbox":o=p.jsx(Vh,{field:r,form:s});break;case"number":o=p.jsx(am,{field:r,form:s});break;case"date":o=p.jsx(im,{field:r,form:s});break;case"datetime":o=p.jsx(lm,{field:r,form:s});break;case"switch":o=p.jsx(IS,{field:r,form:s});break;case"texteditor":o=p.jsx(RS,{field:r,form:s});break;case"time":o=p.jsx(_S,{field:r,form:s});break;case"tags":o=p.jsx(jS,{field:r,form:s});break;default:o=p.jsxs("div",{children:["Unsupported field type: ",r.type]});break}return p.jsx(BS,{field:r,form:s,children:o})}class Io{constructor(){ca(this,"next")}setNext(e){return this.next=e,e}handle(e,t){var r;return this.canHandle(e)?this.render(e,t):((r=this.next)==null?void 0:r.handle(e,t))??null}}class zS extends Io{constructor(e){super(),this.layout=e}canHandle(){return!0}render(e,t){return p.jsx(FS,{field:e,form:t,layout:this.layout})}}class VS extends Io{constructor(e){super(),this.customFieldTypes=e}canHandle(e){return!!this.customFieldTypes[e.type]}render(e,t){return this.customFieldTypes[e.type](e,t)}}class HS extends Io{constructor(e){super(),this.fieldRenderers=e}canHandle(e){return!!this.fieldRenderers[e.name]}render(e,t){return this.fieldRenderers[e.name](e,t)}}class $S extends Io{constructor(e){super(),this.typeRenderers=e}canHandle(e){return!!this.typeRenderers[e.type]}render(e,t){return this.typeRenderers[e.type](e,t)}}const jo=n=>{const{field:e,form:t,customFieldRenderers:r,customTypeRenderers:s,customFieldTypes:o,layout:i="grid"}=n,l=new HS(r??{}),a=new $S(s??{}),c=new zS(i),u=new VS(o??{});return l.setNext(a).setNext(u).setNext(c),l.handle(e,t)},WS=E.createContext(null),YS=({children:n,value:e})=>p.jsx(WS.Provider,{value:e,children:n}),US=E.forwardRef(function({schema:e,values:t,getInitialValues:r,layout:s="vertical",readOnly:o,validate:i,onSubmit:l,onFieldChange:a,updateFieldSchema:c,transformBeforeSubmit:u=k=>k,transformAfterSubmit:d=()=>{},submitButton:f=!0,customFieldRenderers:h,customFieldTypes:m,customTypeRenderers:y,loading:g},b){const[k,C]=E.useState(!0),T=Fh({validate:i,enhanceGetInputProps(O){return{onFieldChange:async A=>{var B;O.inputProps.onChange(A),await((B=a==null?void 0:a[O.field])==null?void 0:B.call(a,A,T))}}}}),M=il[s],v=E.useMemo(()=>{if(!c)return e;const O=T.getValues();return e.map(A=>{const B=c[A.name];return B?B(A,O):A})},[e,T.values,c]),w=T.onSubmit(async O=>{const A=Di(e,O);if(Object.keys(A).length){T.setErrors(A);return}const B=await u(O);await l(B),d(B)});return E.useImperativeHandle(b,()=>({submit:()=>w(),reset:O=>{const A=ar(e,O);T.setValues(A),T.setDirty(A)},validate:()=>{const O=T.validate();return Object.keys(O.errors).length===0},getValues:()=>T.getValues(),setValues:O=>T.setValues(O),getFieldValue:O=>T.getInputProps(O).value,setFieldValue:(O,A)=>T.setFieldValue(O,A),isValid:()=>Object.keys(T.validate().errors).length===0,isDirty:()=>T.isDirty()})),E.useEffect(()=>{if(t){const O=ar(e,t);T.setValues(O),T.resetDirty(O)}},[t,e]),E.useEffect(()=>{async function O(){const A=r?await r():{};T.initialize(ar(e,A)),C(!1)}O()},[e]),p.jsx(YS,{value:{customFieldRenderers:h,customTypeRenderers:y,customFieldTypes:m},children:p.jsxs("form",{onSubmit:w,style:{position:"relative"},children:[p.jsx(x.LoadingOverlay,{visible:k||g}),M(p.jsx(p.Fragment,{children:v.map(O=>{const A={...O,readOnly:O.readOnly||o};return A.visible===!1?null:p.jsx(so,{field:A,layout:s,children:p.jsx(jo,{field:A,form:T,customFieldRenderers:h,customTypeRenderers:y,customFieldTypes:m,layout:s})},A.name)})})),typeof f=="boolean"?f?p.jsx(x.Group,{justify:"flex-end",mt:"md",children:p.jsx(x.Button,{type:"submit",loading:g,children:"Submit"})}):null:f]})})});exports.AutoForm=US;exports.FieldLayoutWrapper=so;exports.FieldRendererResolver=jo;
|
package/dist/index.es.js
CHANGED
|
@@ -22837,7 +22837,7 @@ const ja = (n) => {
|
|
|
22837
22837
|
...T,
|
|
22838
22838
|
readOnly: T.readOnly || o
|
|
22839
22839
|
};
|
|
22840
|
-
return O.visible ? /* @__PURE__ */ p.jsx(
|
|
22840
|
+
return O.visible === !1 ? null : /* @__PURE__ */ p.jsx(
|
|
22841
22841
|
Il,
|
|
22842
22842
|
{
|
|
22843
22843
|
field: O,
|
|
@@ -22855,7 +22855,7 @@ const ja = (n) => {
|
|
|
22855
22855
|
)
|
|
22856
22856
|
},
|
|
22857
22857
|
O.name
|
|
22858
|
-
)
|
|
22858
|
+
);
|
|
22859
22859
|
}) })
|
|
22860
22860
|
),
|
|
22861
22861
|
typeof f == "boolean" ? f ? /* @__PURE__ */ p.jsx(Mo, { justify: "flex-end", mt: "md", children: /* @__PURE__ */ p.jsx(Os, { type: "submit", loading: g, children: "Submit" }) }) : null : f
|