@frontify/fondue 12.1.13 → 12.1.14

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.d.ts CHANGED
@@ -14147,12 +14147,12 @@ declare namespace PatternImagery {
14147
14147
  }
14148
14148
 
14149
14149
 
14150
- declare namespace PatternTypography {
14150
+ declare namespace PatternSound {
14151
14151
  var displayName: string;
14152
14152
  }
14153
14153
 
14154
14154
 
14155
- declare namespace PatternSound {
14155
+ declare namespace PatternTypography {
14156
14156
  var displayName: string;
14157
14157
  }
14158
14158
 
package/dist/index.umd.js CHANGED
@@ -10,7 +10,7 @@ ${V1("Ctrl+I")}`),nodeType:F.getPluginType(e,l),children:t.jsx(N0,{icon:t.jsx(g4
10
10
  ${V1("Ctrl+.")}`),nodeType:F.getPluginType(e,l),clear:F.getPluginType(e,r0.MARK_SUPERSCRIPT),children:t.jsx(N0,{icon:t.jsx(i4,{})})})}),oP=({attributes:e,children:l})=>t.jsx("sub",{...e,children:l});class nP extends n0{constructor(l=r0.MARK_SUBSCRIPT,c=oP){super(l,c)}}const xL0="subscript-plugin";class bL0 extends o0{constructor(l){super(xL0,{button:yL0,markupElement:new nP,...l})}plugins(){return[r0.createSubscriptPlugin({options:{hotkey:["mod+.","ctrl+."]}})]}}const HL0=({editor:e,id:l})=>t.jsx(M0,{id:l,children:t.jsx(v1,{tooltip:y0(`Superscript
11
11
  ${V1("Ctrl+,")}`),nodeType:F.getPluginType(e,l),clear:F.getPluginType(e,r0.MARK_SUBSCRIPT),children:t.jsx(N0,{icon:t.jsx(d4,{})})})}),cP=({attributes:e,children:l})=>t.jsx("sup",{...e,children:l});class rP extends n0{constructor(l=r0.MARK_SUPERSCRIPT,c=cP){super(l,c)}}const pL0="superscript-plugin";class kL0 extends o0{constructor(l){super(pL0,{button:HL0,markupElement:new rP,...l})}plugins(){return[r0.createSuperscriptPlugin({options:{hotkey:["mod+,","ctrl+,"]}})]}}const TL0=({editor:e,id:l})=>t.jsx(M0,{id:l,children:t.jsx(v1,{tooltip:y0(`Underline
12
12
  ${V1("Ctrl+U")}`),nodeType:F.getPluginType(e,l),children:t.jsx(N0,{icon:t.jsx(C4,{})})})}),B5="tw-underline",sP=({attributes:e,children:l})=>t.jsx("span",{...e,className:B5,children:l});class iP extends n0{constructor(l=r0.MARK_UNDERLINE,c=sP){super(l,c)}}const VL0="underline-plugin",FL0=[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}];class dP extends o0{constructor(l){super(VL0,{button:TL0,markupElement:new iP,...l})}plugins(){return[r0.createUnderlinePlugin({deserializeHtml:{rules:[...FL0,{validNodeName:["SPAN"],validClassName:B5}]},options:{hotkey:["mod+u","ctrl+u"]}})]}}class PL0{constructor(){E(this,"toolbarButtons",{[g0.BOTTOM]:[],[g0.FLOATING]:[],[g0.TOP]:[]})}createGroupOfButtons(l){const c=[],r=[],s=[];for(const{markupElement:i,button:d,id:L,showIn:h}of l){if(!d)continue;const w={id:(i==null?void 0:i.getId())||L,button:d};h.includes(g0.BOTTOM)&&c.push(w),h.includes(g0.TOP)&&r.push(w),h.includes(g0.FLOATING)&&s.push(w)}c.length>0&&this.toolbarButtons[g0.BOTTOM].push(c),r.length>0&&this.toolbarButtons[g0.TOP].push(r),s.length>0&&this.toolbarButtons[g0.FLOATING].push(s)}at(l){return this.toolbarButtons[l]}}class LP{constructor(l){E(this,"platePlugins",new Map);E(this,"markupElements",{});E(this,"inlineElements",[]);E(this,"toolbarButtons",new PL0);E(this,"styles",{});this.props=l}setPlugin(...l){for(const c of l){const r=Array.isArray(c)?c:[c];for(const s of r)this.addElement(s.markupElement),this.addElement(s.markupInputElement),this.addLeafElements(s.leafMarkupElements),this.addPlugin(s),this.addInline(s.inline()),s.styles&&this.addStyles(s.styles,s.id),s.textStyles&&this.addTextStylesOfSubPlugins(s.textStyles);this.hasToolbar&&this.toolbarButtons.createGroupOfButtons(r)}return this}addTextStylesOfSubPlugins(l){for(const c of l)c.styles&&this.addStyles(c.styles,c.id)}addLeafElements(l){if(l===void 0)return;const c=Array.isArray(l)?l:[l];for(const r of c)this.addElement(r)}addElement(l){if(l===void 0)return;const c=l.getId(),r=l.getNode();r&&!this.markupElements[c]&&(this.markupElements[c]=r)}addPlugin(l){l.id&&!this.platePlugins.has(l.id)&&this.platePlugins.set(l.id,l.plugins())}addInline(l){l&&this.inlineElements.push(l)}addStyles(l,c){this.styles[c]=l}get elements(){return{...this.defaultElementsFromPlugins,...this.markupElements}}get defaultElementsFromPlugins(){const l={};for(const c of this.platePlugins.values())for(const r of c){const{key:s,component:i}=r;i&&(l[s]=i)}return l}get plugins(){const l=[];for(const c of this.platePlugins.values())l.push(...c);return l}get buttons(){return this.toolbarButtons}get inline(){return this.inlineElements}get hasToolbar(){var l;return!((l=this.props)!=null&&l.noToolbar)}get getStyles(){return this.styles}}const BL0=e=>{!e||!e.selection||(a1.removeMark(e,{key:[r0.MARK_BOLD,r0.MARK_ITALIC,r0.MARK_CODE,r0.MARK_UNDERLINE,r0.MARK_STRIKETHROUGH]}),J.unwrapList(e,{}),Z.setElements(e,{type:d1.ELEMENT_PARAGRAPH,align:void 0}))},jL0=({id:e,...l})=>{const c=F.useEditorState(F.useEventPlateId(e));return t.jsx(e1,{tooltip:y0("Clear formatting"),onPointerDown:r=>{r.preventDefault(),BL0(c)},...l,children:t.jsx(N0,{icon:t.jsx(t4,{})})})},$L0=({id:e})=>t.jsx(M0,{id:e,children:t.jsx(jL0,{id:e})}),hP="reset-formatting-plugin",wP="reset-formatting",fP=F.createPluginFactory({key:wP,isElement:!1});class uP extends o0{constructor(l){super(hP,{button:$L0,...l})}plugins(){return[fP()]}}const DL0="soft-break-plugin";class mP extends o0{constructor(l){super(DL0,{...l})}plugins(){return[nj.createSoftBreakPlugin()]}}const l2=new LP;l2.setPlugin(new mP).setPlugin(new FF({textStyles:[new pF]})).setPlugin([new QF,new eP,new dP,new aP,new NF,new JF],[new dF,new iF,new hF,new LF,new WF,new sF,new ZF,new uP,new vF]);class b2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=S1(),c=l2){const r=E7(l,c);return this.editor=F.createPlateEditor({id:l,plugins:r.plugins}),this}}E(b2,"editor"),E(b2,"editorId",S1());const OL0=e=>"type"in e[0]?e:[{type:"p",children:e}],vP=[{type:d1.ELEMENT_PARAGRAPH,children:[{text:""}]}],H2=({editorId:e="parseRawValue",raw:l,plugins:c})=>{const r=b2.init(`${e}_parseRawValue`,c).getInstance();let s=vP;if(!l)return s;try{s=JSON.parse(l)}catch{const i=l.trim().replaceAll(/>\s+</g,"><"),d=F.deserializeHtml(r,{element:i});s=OL0(d)}return r.children=s,Z.normalizeEditor(r,{force:!0}),r.children},j5=e=>e&&typeof e=="object"&&!Array.isArray(e),gP=(e,l)=>{if(!j5(e)||!j5(l))return{};const c=Object.assign({},e);for(const r of Object.keys(l)){if(r in e&&j5(l[r])){c[r]=gP(e[r],l[r]);continue}Object.assign(c,{[r]:l[r]})}return c},ZL0=e=>"type"in e&&typeof e.type=="string"&&e.type.length>0,_L0=e=>"children"in e&&Array.isArray(e.children)&&e.children.length===1,qL0=e=>typeof e=="object"&&"text"in e&&typeof e.text=="string"&&e.text.length===0,UL0=e=>_L0(e)&&qL0(e.children[0]),WL0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(ZL0(l)&&UL0(l))return!0}return!1},D4=o.createContext({styles:V0,position:g0.FLOATING,wrapperClassNames:"",editorId:""}),P1=()=>o.useContext(D4),CP=({children:e,styles:l,position:c,border:r,editorId:s})=>{const i=o.useMemo(()=>({styles:l,editorId:s,position:c,wrapperClassNames:Wa(c,r)}),[l,s,c,r]);return t.jsx(D4.Provider,{value:i,children:t.jsx(pP,{children:e})})},IP=o.forwardRef(({children:e},l)=>{const{wrapperClassNames:c,editorId:r}=P1();return t.jsx("div",{"data-editor-id":r,"data-test-id":"rich-text-editor",className:c,ref:l,children:e})});IP.displayName="PlateWrapper";const GL0="autoformat-plugin";class KL0 extends o0{constructor(l){super(GL0,{...l})}plugins(){return[o1.createAutoformatPlugin({options:{rules:[...o1.autoformatPunctuation,...o1.autoformatArrow,...o1.autoformatLegal,...o1.autoformatSubscriptNumbers,...o1.autoformatSubscriptSymbols,...o1.autoformatSuperscriptNumbers,...o1.autoformatSuperscriptSymbols,...o1.autoformatFraction,{mode:"mark",type:[r0.MARK_UNDERLINE],match:["_","_"],ignoreTrim:!0},{mode:"mark",type:[r0.MARK_BOLD],match:["**","**"],ignoreTrim:!0},{mode:"mark",type:[r0.MARK_ITALIC],match:["*","*"],ignoreTrim:!0},{mode:"mark",type:[r0.MARK_STRIKETHROUGH],match:["~~","~~"],ignoreTrim:!0},{mode:"mark",type:[r0.MARK_CODE],match:["`","`"],ignoreTrim:!0},{mode:"block",match:["# "],type:_.heading1},{mode:"block",match:["## "],type:_.heading2},{mode:"block",match:["### "],type:_.heading3},{mode:"block",match:["#### "],type:_.heading4},{mode:"block",type:J.ELEMENT_UL,match:["- "],preFormat:J.unwrapList,format:l=>J.toggleList(l,{type:J.ELEMENT_UL})},{mode:"block",type:J.ELEMENT_OL,match:["1. ","1) "],preFormat:J.unwrapList,format:l=>J.toggleList(l,{type:J.ELEMENT_OL})},{mode:"block",type:t1,match:["[] "]}]}})]}}const NP=e=>Array.from(Z.getNodeEntries(e,{at:[],match:l=>!!l.breakAfterColumn})).length,p2=(e,{key:l=a2,value:c,at:r})=>{const s=i=>Z.isBlock(e,i);c?Z.setElements(e,{[l]:c},{mode:"lowest",match:s,at:r}):Z.unsetNodes(e,l,{match:s,mode:"lowest",at:r})},QL0=(e,l,c)=>{p2(e,{at:l,value:c})},O4=(e,l)=>{const c=Array.from(Z.getNodeEntries(e,{at:[],match:r=>!!r.breakAfterColumn}));for(const[r,[,s]]of c.entries())QL0(e,s,r<l-1?"active":"inactive")},MP=(e,l,c)=>{if(c.preventDefault(),c.stopPropagation(),!!(e!=null&&e.selection)&&Z.someNode(e,{match:s=>!!s.breakAfterColumn}))p2(e,{value:void 0});else{const s=NP(e),i=Math.max(l-s-1,0);if(i===0)return;const d=Array.from(Z.getNodeEntries(e,{at:e.selection,match:L=>Z.isBlock(e,L),mode:"lowest"})).slice(-i);for(const L of d)p2(e,{value:"active",at:L[1]})}O4(e,l)},XL0=(e,{options:{hotkey:l}})=>c=>{var r;if(!c.defaultPrevented&&l&&F.isHotkey(l,c)){const s=e.plugins.find(d=>d.key===a2),i=((r=s==null?void 0:s.options)==null?void 0:r.columns)??1;MP(e,i,c)}},YL0=({id:e,...l})=>{var L,h;const c=F.useEditorState(F.useEventPlateId(e)),r=!!(c!=null&&c.selection)&&Z.someNode(c,{match:w=>!!w.breakAfterColumn}),s=(h=(L=c==null?void 0:c.pluginsByKey.breakAfterColumn)==null?void 0:L.options)==null?void 0:h.columns,i=Number(s)||1,d=JL0(c,i,r);return t.jsx(e1,{disabled:!d,pressed:!r,tooltip:y0(d?`Column Break
13
- Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onPointerDown:w=>w.preventDefault(),onClick:w=>{MP(c,i,w)},...l,children:t.jsx(N0,{icon:t.jsx(b5,{})})})},JL0=(e,l,c)=>NP(e)+1<l||c,zP=({id:e})=>t.jsx(M0,{id:e,children:t.jsx(YL0,{children:t.jsx(N0,{icon:t.jsx(b5,{})})})}),EL0=(e,l)=>{const c=Z.getStartPoint(e,l);setTimeout(()=>{Z.select(e,{anchor:c,focus:c})})},RL0=e=>{var c;const l=e.plugins.find(r=>r.key===a2);return((c=l==null?void 0:l.options)==null?void 0:c.columns)??1},eh0=e=>{const{apply:l}=e,c=RL0(e);e.apply=r=>{switch(r.type){case"split_node":{r.properties={...r.properties,breakAfterColumn:void 0};break}case"merge_node":{const s=Z.getPointBefore(e,r.path);if(!s)break;const i=Z.getParentNode(e,s.path);if(p2(e,{at:s,value:void 0}),O4(e,c),i!=null&&i[0].breakAfterColumn)return EL0(e,r.path),e;break}}l(r)},setTimeout(()=>O4(e,c))},a2="breakAfterColumn",Z4="normal";class th0 extends o0{constructor(c){super("break-after-plugin",{button:zP,...c});E(this,"columns");E(this,"gap");E(this,"customClass");this.columns=(c==null?void 0:c.columns)??1,this.gap=(c==null?void 0:c.gap)??Z4,this.customClass=c==null?void 0:c.customClass}plugins(){return[SP(this.columns,this.gap,this.customClass)]}}const SP=(e,l,c)=>F.createPluginFactory({key:a2,handlers:{onKeyDown:XL0},useHooks:eh0,options:{columns:e,gap:l,customClass:c,hotkey:["shift+ctrl+enter"]}})();var c1=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(c1||{});const lh0=({image:e,category:l,text:c,id:r})=>{if(e)return t.jsx("img",{src:e,alt:`${r}-${l}-${c}`});switch(l){case c1.GROUP:return t.jsx(x5,{});case c1.ALL:return t.jsx(L4,{});default:return t.jsx(s4,{})}},ah0=({item:e})=>{const{data:{image:l,category:c},key:r,text:s}=e;return t.jsxs("div",{className:"tw-flex tw-items-center tw-w-full tw-min-h-[inherit]",children:[t.jsx("span",{className:"tw-flex tw-items-center tw-justify-center tw-rounded-full tw-mr-2.5 tw-bg-base-alt tw-border tw-border-line-weak tw-w-[22px] tw-h-[22px] tw-shrink-0 tw-overflow-hidden group-hover:tw-border-base group-aria-selected:tw-border-base",children:t.jsx(lh0,{image:l,category:c,text:s,id:r})}),t.jsx("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis",children:s})]})};function oh0({pluginKey:e=M1.ELEMENT_MENTION,id:l=e,...c}){const r=F.useEditorRef(),{trigger:s}=F.getPluginOptions(r,e);return t.jsx(mF,{id:l,trigger:s,controlled:!0,onSelectItem:(i,d)=>M1.getMentionOnSelectItem({key:e})(r,d),onRenderItem:ah0,...c})}const nh0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),_4=(e,l)=>`${e}:${l}`,q4=e=>{const l=new Map;for(const c of e){const r=_4(c.data.category,c.data.id),s=c.text;l.set(r,s)}return l},AP=(e,l,c)=>e.get(l)??c,ch0=e=>()=>t.jsx(oh0,{items:e,filter:nh0}),yP=o.forwardRef(({className:e,onClick:l,...c},r)=>{const{children:s,element:i}=c;return t.jsx(t3.PlateElement,{ref:r,asChild:!0,"data-slate-value":i.value,className:v(["tw-inline-block tw-rounded-sm tw-shadow-none tw-font-bold tw-leading-[10px] tw-m-0 tw-py-0.5 tw-px-1.5 tw-text-[rgb(130,95,255)] tw-bg-[rgb(227,232,246)]",e]),onClick:l3.getHandler(l,i),...c,children:t.jsx("span",{children:s})})});yP.displayName="MentionInputElement";const rh0=e=>t.jsx(yP,{...e});class sh0 extends n0{constructor(l=M1.ELEMENT_MENTION_INPUT,c=rh0){super(l,c)}}const U4=({attributes:e,element:l,nodeProps:c,children:r})=>t.jsx("span",{...e,dir:"auto","data-slate-value":l==null?void 0:l.value,"data-slate-key":l==null?void 0:l.key,"data-slate-category":l==null?void 0:l.category,contentEditable:!1,style:{lineHeight:"10px",padding:"1px",margin:"0 1px",fontWeight:"bold",verticalAlign:"baseline",display:"inline-block",borderRadius:"2px",backgroundColor:"rgb(227, 232, 246)",color:"rgb(130, 95, 255)"},...c,children:r}),ih0=({children:e,...l})=>t.jsxs(U4,{...l,children:[t.jsx("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"},children:t.jsx(x5,{})}),e]}),dh0=({children:e,...l})=>t.jsxs(U4,{...l,children:["@",e]}),Lh0=({children:e,...l})=>t.jsx(U4,{...l,children:e}),hh0=({category:e,children:l,...c})=>{const r={[c1.USER]:Lh0,[c1.GROUP]:ih0,[c1.ALL]:dh0},s=r[e]??r[c1.USER];return t.jsx(s,{...c,children:l})},W4=e=>l=>{const{element:c,children:r}=l,s=_4(c==null?void 0:c.category,String(c==null?void 0:c.id));return t.jsxs(hh0,{category:c==null?void 0:c.category,...l,children:[AP(e,s,String(c==null?void 0:c.id)),r]})};class xP extends n0{constructor(l=M1.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=W4(q4(l)),this}}const wh0={options:{trigger:"@",insertSpaceAfterMention:!0,createMentionNode:e=>({value:e.text,category:e.data.category,id:e.data.id})}},fh0="mention-plugin";class uh0 extends o0{constructor(l){super(fh0,{markupElement:new xP().setNodeWithMentionable(l.mentionableItems),markupInputElement:new sh0,...l})}inline(){var l;return ch0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[B0.createComboboxPlugin(),M1.createMentionPlugin(wh0)]}}const mh0=(e,{options:{onBreak:l=()=>{}}})=>c=>{F.Hotkeys.isSplitBlock(c)&&(c.stopPropagation(),c.preventDefault(),_a(),typeof l=="function"&&l(e.children))},vh0=F.createPluginFactory({key:"blurOnBreak",handlers:{onKeyDown:mh0}}),gh0="blur-on-break-plugin";class Ch0 extends o0{constructor(c){super(gh0,{...c});E(this,"onBreak");this.onBreak=c==null?void 0:c.onBreak}plugins(){return[vh0({options:{onBreak:this.onBreak}})]}}const Ih0=({editorId:e,initialValue:l,plugins:c,onTextChange:r,onValueChanged:s})=>{const i=o.useRef(null),d=o.useCallback(u=>{r&&r(JSON.stringify(u))},[r]),L=N5(d,Ka),h=o.useCallback(u=>{L(u),i.current=u,s&&s(u)},[L,i,s]),w=o.useMemo(()=>H2({editorId:e,raw:l,plugins:c}),[e]),f=o.useMemo(()=>E7(e,c),[e,c]);return{localValue:i,onChange:h,memoizedValue:w,config:f}},Nh0=()=>{const[e,l]=o.useState(0),c=o.useRef(Z3(s=>l(s)));return{editorRef:o.useCallback(s=>{if(!s)return;l(s.clientWidth);const i=new ResizeObserver(d=>{if(d.length===0)return;const L=d[0].target.clientWidth;L>0&&c.current(L)});return setTimeout(()=>{i.observe(s)},0),i},[]),editorWidth:e}},bP=o.createContext({editorWidth:0,editorRef:null}),HP=()=>o.useContext(bP),pP=({children:e})=>{const{editorRef:l,editorWidth:c}=Nh0(),r=o.useMemo(()=>({editorWidth:c,editorRef:l}),[c,l]);return t.jsx(bP.Provider,{value:r,children:t.jsx(IP,{ref:l,children:e})})},Mh0=({index:e,children:l})=>t.jsx("div",{"data-test-id":`toolbar-group-${e}`,className:"tw-flex tw-items-center tw-h-9 tw-p-2",children:l}),zh0=12,Sh0=26,Ah0=124,yh0=e=>e.map((l,c)=>({group:l,buttonGroupWidth:l.reduce((r,s)=>s.id===yF?Ah0:Sh0+r,zh0),index:c})),xh0=(e,l)=>l.reduce((c,{group:r,buttonGroupWidth:s,index:i})=>{const d=Math.max(0,c.length-1);return c[d]=c[d]??[],(c[d]??[{actions:[],buttonGroupWidth:0}]).reduce((h,{buttonGroupWidth:w})=>h+w,0)+s<=e?c[d].push({group:r,buttonGroupWidth:s,index:i}):c.push([{group:r,buttonGroupWidth:s,index:i}]),c.filter(h=>h.length)},[]),kP=({toolbarButtons:e,editorId:l,toolbarWidth:c})=>{const r=F.useEditorRef(l),{editorWidth:s}=HP(),{position:i}=P1(),d=c||s||0,L=yh0(e.at(i)),h=xh0(d,L),w=J7[i];return t.jsx(w.ToolbarWrapper,{editorWidth:s,toolbarWidth:c,toolbarButtonGroups:h,children:h.map((f,u)=>t.jsx("div",{className:"tw-divide-x tw-divide-line tw-flex tw-w-full",children:f.map(({group:m,index:C})=>t.jsx(Mh0,{index:C,children:m.map((g,N)=>t.jsx(g.button,{editor:r,editorId:l,id:g.id},N.toString()))},C))},u))})},TP="[data-floating-modal]",G4=({children:e,minWidth:l,padding:c,"data-test-id":r="floating-modal"})=>t.jsx("div",{"data-test-id":r,className:"tw-bg-white tw-rounded tw-shadow tw-overflow-y-auto",style:{minWidth:l,padding:c},"data-floating-modal":!0,children:e}),bh0=({hideExternalFloatingModals:e})=>{const l=F.useEditorRef(),c=t0.useFloatingLinkSelectors().isOpen(l.id),[r,s]=o.useState(!1),i=o.useCallback(()=>{c&&t0.floatingLinkActions.hide(),e&&e(l.id)},[c,e,l]),d=o.useCallback(()=>{l.collapse(),i()},[l,i]);return o.useEffect(()=>{if(!r)return;const L=h=>{const w=`[data-editor-id='${l.id}']`,f="[role='toolbar']",u="[data-is-underlay]",m=h.target,C=m.closest(u),g=m.closest(TP),N=m.closest(w),z=m.closest(f);N&&!g||z?i():!N&&!z&&!C&&(d(),s(!1))};return document.addEventListener("pointerdown",L),document.addEventListener("focusin",L),()=>{document.removeEventListener("focusin",L),document.removeEventListener("pointerdown",L)}},[d,i,l.id,r]),o.useEffect(()=>{const L=document.querySelector(`[data-editor-id='${l.id}']`);if(!L)return;const h=()=>{s(!0)};return L.addEventListener("focusin",h),()=>{L.removeEventListener("focusin",h)}},[l.id]),null},Hh0=({children:e,apply:l})=>{for(const c of e)l({type:"remove_node",path:[0],node:c})},ph0=({value:e})=>{const l=F.useEditorRef();return o.useEffect(()=>{e&&(Hh0(l),Z.insertNodes(l,e))},[l,e]),null},kh0={position:"relative",height:"0"},Th0=({children:e,attributes:l})=>{const c={...l,style:{...l.style,...kh0}};return t.jsx("span",{...c,children:e})},VP=({id:e,value:l,placeholder:c="",readonly:r=!1,onTextChange:s,onBlur:i,padding:d=X7.None,position:L=g0.FLOATING,plugins:h=l2,updateValueOnChange:w=!1,onValueChanged:f,border:u=!0,toolbarWidth:m,hideExternalFloatingModals:C})=>{var b,$,O;const g=C0(e),{localValue:N,onChange:z,memoizedValue:I,config:S}=Ih0({editorId:g,initialValue:l,onTextChange:s,plugins:h,onValueChanged:f}),A=h.plugins.find(B=>B.key===a2),H=(b=A==null?void 0:A.options)==null?void 0:b.customClass,p=H?null:(($=A==null?void 0:A.options)==null?void 0:$.columns)??1,x=((O=A==null?void 0:A.options)==null?void 0:O.gap)??Z4,V=o.useMemo(()=>({columns:p,columnGap:x,outline:"none"}),[p,x]),M=o.useCallback(()=>{i&&i(JSON.stringify(N.current))},[i,N]),T=o.useCallback(B=>{B.code==="Tab"&&Za(B,!B.shiftKey)},[]),y={placeholder:c,renderPlaceholder:Th0,readOnly:r,onBlur:M,className:v([d,H]),style:V,onKeyDown:T,scrollSelectionIntoView:N1.noop};return t.jsx(CP,{styles:S.styles(),position:L,border:u,editorId:g,children:t.jsxs(F.Plate,{id:g,onChange:z,plugins:S.plugins,initialValue:I,children:[t.jsx(F.PlateContent,{...y}),!y.readOnly&&S.toolbar(m),S.inline(),w&&t.jsx(ph0,{value:H2({editorId:g,raw:l,plugins:h})}),L===g0.FLOATING&&t.jsx(bh0,{hideExternalFloatingModals:C})]})})};VP.displayName="FondueRichTextEditor";const Vh0={paragraph:"paragraph",blockQuote:"block_quote",codeBlock:"code_block",link:"link",ulList:"ul_list",olList:"ol_list",listItem:"list_item",listItemChild:"lic",heading:{1:"heading_one",2:"heading_two",3:"heading_three",4:"heading_four",5:"heading_five",6:"heading_six"},emphasisMark:"italic",strongMark:"bold",deleteMark:"strikethrough",inlineCodeMark:"code",thematicBreak:"thematic_break",image:"image",mention:"mention"},$5={Blank:"_blank",Self:"_self"},FP="[\\d=a-z]+",PP=Object.values(c1).join("|"),Fh0=`@\\[(${PP}):${FP}\\]`,BP=`@\\[(${PP}):(${FP})\\]`,Ph0=new RegExp(Fh0,"gi"),Bh0=new RegExp(BP,"i"),jP="<br>",K4={nodeTypes:Vh0,ignoreParagraphNewline:!1,listDepth:0,linkDestinationKey:"link"},$P=e=>{var l;return{...K4,...e,nodeTypes:{...K4.nodeTypes,...e==null?void 0:e.nodeTypes,heading:{...K4.nodeTypes.heading,...(l=e==null?void 0:e.nodeTypes)==null?void 0:l.heading}}}},Q4=e=>/^(javascript:|data:text\/).+/i.test(e),o2=e=>!("type"in e),jh0=e=>`@[${e.category}:${e.id}]`,$h0=e=>`${e}
13
+ Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onPointerDown:w=>w.preventDefault(),onClick:w=>{MP(c,i,w)},...l,children:t.jsx(N0,{icon:t.jsx(b5,{})})})},JL0=(e,l,c)=>NP(e)+1<l||c,zP=({id:e})=>t.jsx(M0,{id:e,children:t.jsx(YL0,{children:t.jsx(N0,{icon:t.jsx(b5,{})})})}),EL0=(e,l)=>{const c=Z.getStartPoint(e,l);setTimeout(()=>{Z.select(e,{anchor:c,focus:c})})},RL0=e=>{var c;const l=e.plugins.find(r=>r.key===a2);return((c=l==null?void 0:l.options)==null?void 0:c.columns)??1},eh0=e=>{const{apply:l}=e,c=RL0(e);e.apply=r=>{switch(r.type){case"split_node":{r.properties={...r.properties,breakAfterColumn:void 0};break}case"merge_node":{const s=Z.getPointBefore(e,r.path);if(!s)break;const i=Z.getParentNode(e,s.path);if(p2(e,{at:s,value:void 0}),O4(e,c),i!=null&&i[0].breakAfterColumn)return EL0(e,r.path),e;break}}l(r)},setTimeout(()=>O4(e,c))},a2="breakAfterColumn",Z4="normal";class th0 extends o0{constructor(c){super("break-after-plugin",{button:zP,...c});E(this,"columns");E(this,"gap");E(this,"customClass");this.columns=(c==null?void 0:c.columns)??1,this.gap=(c==null?void 0:c.gap)??Z4,this.customClass=c==null?void 0:c.customClass}plugins(){return[SP(this.columns,this.gap,this.customClass)]}}const SP=(e,l,c)=>F.createPluginFactory({key:a2,handlers:{onKeyDown:XL0},useHooks:eh0,options:{columns:e,gap:l,customClass:c,hotkey:["shift+ctrl+enter"]}})();var c1=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(c1||{});const lh0=({image:e,category:l,text:c,id:r})=>{if(e)return t.jsx("img",{src:e,alt:`${r}-${l}-${c}`});switch(l){case c1.GROUP:return t.jsx(x5,{});case c1.ALL:return t.jsx(L4,{});default:return t.jsx(s4,{})}},ah0=({item:e})=>{const{data:{image:l,category:c},key:r,text:s}=e;return t.jsxs("div",{className:"tw-flex tw-items-center tw-w-full tw-min-h-[inherit]",children:[t.jsx("span",{className:"tw-flex tw-items-center tw-justify-center tw-rounded-full tw-mr-2.5 tw-bg-base-alt tw-border tw-border-line-weak tw-w-[22px] tw-h-[22px] tw-shrink-0 tw-overflow-hidden group-hover:tw-border-base group-aria-selected:tw-border-base",children:t.jsx(lh0,{image:l,category:c,text:s,id:r})}),t.jsx("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis",children:s})]})};function oh0({pluginKey:e=M1.ELEMENT_MENTION,id:l=e,...c}){const r=F.useEditorRef(),{trigger:s}=F.getPluginOptions(r,e);return t.jsx(mF,{id:l,trigger:s,controlled:!0,onSelectItem:(i,d)=>M1.getMentionOnSelectItem({key:e})(r,d),onRenderItem:ah0,...c})}const nh0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),_4=(e,l)=>`${e}:${l}`,q4=e=>{const l=new Map;for(const c of e){const r=_4(c.data.category,c.data.id),s=c.text;l.set(r,s)}return l},AP=(e,l,c)=>e.get(l)??c,ch0=e=>()=>t.jsx(oh0,{items:e,filter:nh0}),yP=o.forwardRef(({className:e,onClick:l,...c},r)=>{const{children:s,element:i}=c;return t.jsx(t3.PlateElement,{ref:r,asChild:!0,"data-slate-value":i.value,className:v(["tw-inline-block tw-rounded-sm tw-shadow-none tw-font-bold tw-leading-[10px] tw-m-0 tw-py-0.5 tw-px-1.5 tw-text-[rgb(130,95,255)] tw-bg-[rgb(227,232,246)]",e]),onClick:l3.getHandler(l,i),...c,children:t.jsx("span",{children:s})})});yP.displayName="MentionInputElement";const rh0=e=>t.jsx(yP,{...e});class sh0 extends n0{constructor(l=M1.ELEMENT_MENTION_INPUT,c=rh0){super(l,c)}}const U4=({attributes:e,element:l,nodeProps:c,children:r})=>t.jsx("span",{...e,dir:"auto","data-slate-value":l==null?void 0:l.value,"data-slate-key":l==null?void 0:l.key,"data-slate-category":l==null?void 0:l.category,contentEditable:!1,style:{lineHeight:"10px",padding:"1px",margin:"0 1px",fontWeight:"bold",verticalAlign:"baseline",display:"inline-block",borderRadius:"2px",backgroundColor:"rgb(227, 232, 246)",color:"rgb(130, 95, 255)"},...c,children:r}),ih0=({children:e,...l})=>t.jsxs(U4,{...l,children:[t.jsx("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"},children:t.jsx(x5,{})}),e]}),dh0=({children:e,...l})=>t.jsxs(U4,{...l,children:["@",e]}),Lh0=({children:e,...l})=>t.jsx(U4,{...l,children:e}),hh0=({category:e,children:l,...c})=>{const r={[c1.USER]:Lh0,[c1.GROUP]:ih0,[c1.ALL]:dh0},s=r[e]??r[c1.USER];return t.jsx(s,{...c,children:l})},W4=e=>l=>{const{element:c,children:r}=l,s=_4(c==null?void 0:c.category,String(c==null?void 0:c.id));return t.jsxs(hh0,{category:c==null?void 0:c.category,...l,children:[AP(e,s,String(c==null?void 0:c.id)),r]})};class xP extends n0{constructor(l=M1.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=W4(q4(l)),this}}const wh0={options:{trigger:"@",insertSpaceAfterMention:!0,createMentionNode:e=>({value:e.text,category:e.data.category,id:e.data.id})}},fh0="mention-plugin";class uh0 extends o0{constructor(l){super(fh0,{markupElement:new xP().setNodeWithMentionable(l.mentionableItems),markupInputElement:new sh0,...l})}inline(){var l;return ch0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[B0.createComboboxPlugin(),M1.createMentionPlugin(wh0)]}}const mh0=(e,{options:{onBreak:l=()=>{}}})=>c=>{F.Hotkeys.isSplitBlock(c)&&(c.stopPropagation(),c.preventDefault(),_a(),typeof l=="function"&&l(e.children))},vh0=F.createPluginFactory({key:"blurOnBreak",handlers:{onKeyDown:mh0}}),gh0="blur-on-break-plugin";class Ch0 extends o0{constructor(c){super(gh0,{...c});E(this,"onBreak");this.onBreak=c==null?void 0:c.onBreak}plugins(){return[vh0({options:{onBreak:this.onBreak}})]}}const Ih0=({editorId:e,initialValue:l,plugins:c,onTextChange:r,onValueChanged:s})=>{const i=o.useRef(null),d=o.useCallback(u=>{r&&r(JSON.stringify(u))},[r]),L=N5(d,Ka),h=o.useCallback(u=>{L(u),i.current=u,s&&s(u)},[L,i,s]),w=o.useMemo(()=>H2({editorId:e,raw:l,plugins:c}),[e]),f=o.useMemo(()=>E7(e,c),[e,c]);return{localValue:i,onChange:h,memoizedValue:w,config:f}},Nh0=()=>{const[e,l]=o.useState(0),c=o.useRef(Z3(s=>l(s)));return{editorRef:o.useCallback(s=>{if(!s)return;l(s.clientWidth);const i=new ResizeObserver(d=>{if(d.length===0)return;const L=d[0].target.clientWidth;L>0&&c.current(L)});return setTimeout(()=>{i.observe(s)},0),i},[]),editorWidth:e}},bP=o.createContext({editorWidth:0,editorRef:null}),HP=()=>o.useContext(bP),pP=({children:e})=>{const{editorRef:l,editorWidth:c}=Nh0(),r=o.useMemo(()=>({editorWidth:c,editorRef:l}),[c,l]);return t.jsx(bP.Provider,{value:r,children:t.jsx(IP,{ref:l,children:e})})},Mh0=({index:e,children:l})=>t.jsx("div",{"data-test-id":`toolbar-group-${e}`,className:"tw-flex tw-items-center tw-h-9 tw-p-2",children:l}),zh0=12,Sh0=26,Ah0=124,yh0=e=>e.map((l,c)=>({group:l,buttonGroupWidth:l.reduce((r,s)=>s.id===yF?Ah0:Sh0+r,zh0),index:c})),xh0=(e,l)=>l.reduce((c,{group:r,buttonGroupWidth:s,index:i})=>{const d=Math.max(0,c.length-1);return c[d]=c[d]??[],(c[d]??[{actions:[],buttonGroupWidth:0}]).reduce((h,{buttonGroupWidth:w})=>h+w,0)+s<=e?c[d].push({group:r,buttonGroupWidth:s,index:i}):c.push([{group:r,buttonGroupWidth:s,index:i}]),c.filter(h=>h.length)},[]),kP=({toolbarButtons:e,editorId:l,toolbarWidth:c})=>{const r=F.useEditorRef(l),{editorWidth:s}=HP(),{position:i}=P1(),d=c||s||0,L=yh0(e.at(i)),h=xh0(d,L),w=J7[i];return t.jsx(w.ToolbarWrapper,{editorWidth:s,toolbarWidth:c,toolbarButtonGroups:h,children:h.map((f,u)=>t.jsx("div",{className:"tw-divide-x tw-divide-line tw-flex tw-w-full",children:f.map(({group:m,index:C})=>t.jsx(Mh0,{index:C,children:m.map((g,N)=>t.jsx(g.button,{editor:r,editorId:l,id:g.id},N.toString()))},C))},u))})},TP="[data-floating-modal]",G4=({children:e,minWidth:l,padding:c,"data-test-id":r="floating-modal"})=>t.jsx("div",{"data-test-id":r,className:"tw-bg-white tw-rounded tw-shadow tw-overflow-y-auto",style:{minWidth:l,padding:c},"data-floating-modal":!0,children:e}),bh0=({hideExternalFloatingModals:e})=>{const l=F.useEditorRef(),c=t0.useFloatingLinkSelectors().isOpen(l.id),[r,s]=o.useState(!1),i=o.useCallback(()=>{c&&t0.floatingLinkActions.hide(),e&&e(l.id)},[c,e,l]),d=o.useCallback(()=>{i(),l.deselect(),l.collapse()},[l,i]);return o.useEffect(()=>{if(!r)return;const L=h=>{const w=`[data-editor-id='${l.id}']`,f="[role='toolbar']",u="[data-is-underlay]",m=h.target,C=m.closest(u),g=m.closest(TP),N=m.closest(w),z=m.closest(f);N&&!g||z?i():!N&&!z&&!C&&(d(),s(!1))};return document.addEventListener("pointerdown",L),document.addEventListener("focusin",L),()=>{document.removeEventListener("focusin",L),document.removeEventListener("pointerdown",L)}},[d,i,l.id,r]),o.useEffect(()=>{const L=document.querySelector(`[data-editor-id='${l.id}']`);if(!L)return;const h=()=>{s(!0)};return L.addEventListener("focusin",h),()=>{L.removeEventListener("focusin",h)}},[l.id]),null},Hh0=({children:e,apply:l})=>{for(const c of e)l({type:"remove_node",path:[0],node:c})},ph0=({value:e})=>{const l=F.useEditorRef();return o.useEffect(()=>{e&&(Hh0(l),Z.insertNodes(l,e))},[l,e]),null},kh0={position:"relative",height:"0"},Th0=({children:e,attributes:l})=>{const c={...l,style:{...l.style,...kh0}};return t.jsx("span",{...c,children:e})},VP=({id:e,value:l,placeholder:c="",readonly:r=!1,onTextChange:s,onBlur:i,padding:d=X7.None,position:L=g0.FLOATING,plugins:h=l2,updateValueOnChange:w=!1,onValueChanged:f,border:u=!0,toolbarWidth:m,hideExternalFloatingModals:C})=>{var b,$,O;const g=C0(e),{localValue:N,onChange:z,memoizedValue:I,config:S}=Ih0({editorId:g,initialValue:l,onTextChange:s,plugins:h,onValueChanged:f}),A=h.plugins.find(B=>B.key===a2),H=(b=A==null?void 0:A.options)==null?void 0:b.customClass,p=H?null:(($=A==null?void 0:A.options)==null?void 0:$.columns)??1,x=((O=A==null?void 0:A.options)==null?void 0:O.gap)??Z4,V=o.useMemo(()=>({columns:p,columnGap:x,outline:"none"}),[p,x]),M=o.useCallback(()=>{i&&i(JSON.stringify(N.current))},[i,N]),T=o.useCallback(B=>{B.code==="Tab"&&Za(B,!B.shiftKey)},[]),y={placeholder:c,renderPlaceholder:Th0,readOnly:r,onBlur:M,className:v([d,H]),style:V,onKeyDown:T,scrollSelectionIntoView:N1.noop};return t.jsx(CP,{styles:S.styles(),position:L,border:u,editorId:g,children:t.jsxs(F.Plate,{id:g,onChange:z,plugins:S.plugins,initialValue:I,children:[t.jsx(F.PlateContent,{...y}),!y.readOnly&&S.toolbar(m),S.inline(),w&&t.jsx(ph0,{value:H2({editorId:g,raw:l,plugins:h})}),L===g0.FLOATING&&t.jsx(bh0,{hideExternalFloatingModals:C})]})})};VP.displayName="FondueRichTextEditor";const Vh0={paragraph:"paragraph",blockQuote:"block_quote",codeBlock:"code_block",link:"link",ulList:"ul_list",olList:"ol_list",listItem:"list_item",listItemChild:"lic",heading:{1:"heading_one",2:"heading_two",3:"heading_three",4:"heading_four",5:"heading_five",6:"heading_six"},emphasisMark:"italic",strongMark:"bold",deleteMark:"strikethrough",inlineCodeMark:"code",thematicBreak:"thematic_break",image:"image",mention:"mention"},$5={Blank:"_blank",Self:"_self"},FP="[\\d=a-z]+",PP=Object.values(c1).join("|"),Fh0=`@\\[(${PP}):${FP}\\]`,BP=`@\\[(${PP}):(${FP})\\]`,Ph0=new RegExp(Fh0,"gi"),Bh0=new RegExp(BP,"i"),jP="<br>",K4={nodeTypes:Vh0,ignoreParagraphNewline:!1,listDepth:0,linkDestinationKey:"link"},$P=e=>{var l;return{...K4,...e,nodeTypes:{...K4.nodeTypes,...e==null?void 0:e.nodeTypes,heading:{...K4.nodeTypes.heading,...(l=e==null?void 0:e.nodeTypes)==null?void 0:l.heading}}}},Q4=e=>/^(javascript:|data:text\/).+/i.test(e),o2=e=>!("type"in e),jh0=e=>`@[${e.category}:${e.id}]`,$h0=e=>`${e}
14
14
  `,Dh0=(e,l,c,r)=>{const s=c&&c.parentType===e.olList,i=c.children.length===1&&o2(c.children[0]);let d="";for(let L=0;r>L;L++)s?d+=" ":d+=" ";return`${d}${s?"1.":"-"} ${l}${i?`
15
15
  `:""}`},Oh0=(e,l,c,r)=>(r===l.codeBlock||c===l.codeBlock||(e=V2(e)),e),Zh0=(e,l,c,r,s,i)=>{const d=e.nodeTypes;switch(s){case d.heading[1]:return`# ${l}
16
16
  `;case d.heading[2]:return`## ${l}