@payloadcms/richtext-lexical 3.34.0-canary.5 → 3.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,5 +37,5 @@ ${e.map(Mc).join(`
37
37
 
38
38
  `,Dl="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",Ol="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",Ep=new RegExp("^[^"+Ol+"]*["+Dl+"]"),Np=new RegExp("^[^"+Dl+"]*["+Ol+"]"),Lp={bold:O.IS_BOLD,code:O.IS_CODE,highlight:O.IS_HIGHLIGHT,italic:O.IS_ITALIC,strikethrough:O.IS_STRIKETHROUGH,subscript:O.IS_SUBSCRIPT,superscript:O.IS_SUPERSCRIPT,underline:O.IS_UNDERLINE},Sp={directionless:O.IS_DIRECTIONLESS,unmergeable:O.IS_UNMERGEABLE},Rp={center:O.IS_ALIGN_CENTER,end:O.IS_ALIGN_END,justify:O.IS_ALIGN_JUSTIFY,left:O.IS_ALIGN_LEFT,right:O.IS_ALIGN_RIGHT,start:O.IS_ALIGN_START},Ip={[O.IS_ALIGN_CENTER]:"center",[O.IS_ALIGN_END]:"end",[O.IS_ALIGN_JUSTIFY]:"justify",[O.IS_ALIGN_LEFT]:"left",[O.IS_ALIGN_RIGHT]:"right",[O.IS_ALIGN_START]:"start"},yp={normal:O.IS_NORMAL,segmented:O.IS_SEGMENTED,token:O.IS_TOKEN},vp={[O.IS_NORMAL]:"normal",[O.IS_SEGMENTED]:"segmented",[O.IS_TOKEN]:"token"};var Fl={text:({node:t})=>{let e=t.text;return t.format&O.IS_BOLD&&(e=He("strong",{children:e})),t.format&O.IS_ITALIC&&(e=He("em",{children:e})),t.format&O.IS_STRIKETHROUGH&&(e=He("span",{style:{textDecoration:"line-through"},children:e})),t.format&O.IS_UNDERLINE&&(e=He("span",{style:{textDecoration:"underline"},children:e})),t.format&O.IS_CODE&&(e=He("code",{children:e})),t.format&O.IS_SUBSCRIPT&&(e=He("sub",{children:e})),t.format&O.IS_SUPERSCRIPT&&(e=He("sup",{children:e})),e}};import{jsx as Et}from"react/jsx-runtime";var $l={upload:({node:t})=>{let e=t;if(typeof e.value!="object")return null;let o=e.value,r=o.url;if(!o.mimeType.startsWith("image"))return Et("a",{href:r,rel:"noopener noreferrer",children:o.filename});if(!o.sizes||!Object.keys(o.sizes).length)return Et("img",{alt:o.filename,height:o.height,src:r,width:o.width});let n=[];for(let i in o.sizes){let l=o.sizes[i];if(!l||!l.width||!l.height||!l.mimeType||!l.filesize||!l.filename||!l.url)continue;let s=l?.url;n.push(Et("source",{media:`(max-width: ${l.width}px)`,srcSet:s,type:l.mimeType},i))}return n.push(Et("img",{alt:o?.filename,height:o?.height,src:r,width:o?.width},"image")),Et("picture",{children:n})}};var et={...vl,...Fl,...Sl,...El,...Al,...Nl,...Ll,...yl,...Il({}),...$l,...Ml};import{jsx as Bl,Fragment as Mp}from"react/jsx-runtime";import or from"react";function Pl(t){let e=!!t?.root?.children?.length,o=!1;if(t?.root?.children?.length===1&&t?.root?.children[0]?.type==="paragraph"){let r=t?.root?.children[0];if(!r?.children||r?.children?.length===0)o=!0;else if(r?.children?.length===1){let n=r?.children[0];n?.type==="text"&&(n?.text?.length||(o=!0))}}return!(!e||o)}function Hl({converters:t,data:e,disableIndent:o,disableTextAlign:r}){return Pl(e)?jl({converters:t,disableIndent:o,disableTextAlign:r,nodes:e?.root?.children,parent:e?.root}):Bl(Mp,{})}function jl({converters:t,disableIndent:e,disableTextAlign:o,nodes:r,parent:n}){let i=t.unknown;return r.map((s,u)=>{let c;s.type==="block"?(c=t?.blocks?.[s?.fields?.blockType],!c&&!i&&console.error(`Lexical => JSX converter: Blocks converter: found ${s?.fields?.blockType} block, but no converter is provided`)):s.type==="inlineBlock"?(c=t?.inlineBlocks?.[s?.fields?.blockType],!c&&!i&&console.error(`Lexical => JSX converter: Inline Blocks converter: found ${s?.fields?.blockType} inline block, but no converter is provided`)):c=t[s.type];try{!c&&i&&(c=i);let d;c?d=typeof c=="function"?c({childIndex:u,converters:t,node:s,nodesToJSX:m=>jl({converters:m.converters??t,disableIndent:m.disableIndent??e,disableTextAlign:m.disableTextAlign??o,nodes:m.nodes,parent:m.parent??{...s,parent:n}}),parent:n}):c:d=Bl("span",{children:"unknown node"},u);let a={};if(!o&&(!Array.isArray(o)||!o?.includes(s.type))&&"format"in s&&s.format)switch(s.format){case"center":a.textAlign="center";break;case"end":a.textAlign="right";break;case"justify":a.textAlign="justify";break;case"left":break;case"right":a.textAlign="right";break;case"start":a.textAlign="left";break}if(!e&&(!Array.isArray(e)||!e?.includes(s.type))&&"indent"in s&&s.indent&&s.type!=="listitem"&&(a.paddingInlineStart=`${Number(s.indent)*2}em`),or.isValidElement(d)){if(a.textAlign||a.paddingInlineStart){let p={...a,...d?.props?.style??{}};return or.cloneElement(d,{key:u,style:p})}return or.cloneElement(d,{key:u})}return d}catch(d){return console.error("Error converting lexical node to JSX:",d,"node:",s),null}}).filter(Boolean)}var rr=({className:t,converters:e,data:o,disableContainer:r,disableIndent:n,disableTextAlign:i})=>{if(!o)return null;let l={};e?typeof e=="function"?l=e({defaultConverters:et}):l=e:l=et;let s=o&&!Array.isArray(o)&&typeof o=="object"&&"root"in o&&Hl({converters:l,data:o,disableIndent:n,disableTextAlign:i});return r?Ul(Ap,{children:s}):Ul("div",{className:t??"payload-richtext",children:s})};function Gl(){let t=Dp(7),[e]=Fp(),o;t[0]!==e?(o=e.getEditorState().toJSON(),t[0]=e,t[1]=o):o=t[1];let[r,n]=Pp(o),i,l;t[2]!==e?(i=()=>e.registerUpdateListener(u=>{let{editorState:c}=u;n(c.toJSON())}),l=[e],t[2]=e,t[3]=i,t[4]=l):(i=t[3],l=t[4]),$p(i,l);let s;return t[5]!==r?(s=Op(rr,{converters:et,data:r}),t[5]=r,t[6]=s):s=t[6],s}var Bp=y({plugins:[{Component:Gl,position:"bottom"}]});import{$isNodeSelection as Ef}from"lexical";import{jsx as Nt,jsxs as Hp}from"react/jsx-runtime";import"react";var nr=()=>Hp("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Nt("g",{clipPath:"url(#clip0_4397_10817)",children:Nt("path",{d:"M7.75 12.25L15.25 4.75M15.25 4.75H11.5M15.25 4.75V8.5M13 11.5V13.75C13 14.5784 12.3284 15.25 11.5 15.25H6.25C5.42157 15.25 4.75 14.5784 4.75 13.75V8.5C4.75 7.67157 5.42157 7 6.25 7H8.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})}),Nt("defs",{children:Nt("clipPath",{id:"clip0_4397_10817",children:Nt("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{jsx as Gp}from"react/jsx-runtime";import*as Vl from"react";import{DecoratorBlockNode as jp}from"@lexical/react/LexicalDecoratorBlockNode.js";function Up(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:Wl({relationTo:o,value:e})}:null}var Lt=class extends jp{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"relationship"}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:Up,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=Wl(o);return r.setFormat(e.format),r}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div");e.setAttribute("data-lexical-relationship-id",String(typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value)),e.setAttribute("data-lexical-relationship-relationTo",this.__data?.relationTo);let o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"relationship",version:2}}getData(){return this.getLatest().__data}getTextContent(){return`${this.__data?.relationTo} relation to ${typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value}`}setData(e){let o=this.getWritable();o.__data=e}};function Wl(t){return new Lt({data:t})}var Wp=Vl.lazy(()=>import("./RelationshipComponent-APF3CN47.js").then(t=>({default:t.RelationshipComponent})));function Vp(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:je({relationTo:o,value:e})}:null}var Ne=class extends Lt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:Vp,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=je(o);return r.setFormat(e.format),r}decorate(e,o){return Gp(Wp,{className:o.theme.relationship??"LexicalEditorTheme__relationship",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function je(t){return new Ne({data:t})}function ir(t){return t instanceof Ne}import{c as uf}from"react/compiler-runtime";import{jsx as df}from"react/jsx-runtime";import{useLexicalComposerContext as mf}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as pf}from"@lexical/utils";import{useConfig as ff}from"@payloadcms/ui";import{$getPreviousSelection as hf,$getSelection as gf,$isParagraphNode as Yl,$isRangeSelection as Cf,COMMAND_PRIORITY_EDITOR as xf,createCommand as bf}from"lexical";import{useEffect as _f}from"react";import{c as rf}from"react/compiler-runtime";import{jsx as oo}from"react/jsx-runtime";import{useLexicalComposerContext as nf}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as lf,COMMAND_PRIORITY_EDITOR as sf}from"lexical";import{useEffect as af,useState as Xl}from"react";import{c as Kp}from"react/compiler-runtime";import{jsx as Jp}from"react/jsx-runtime";import{useLexicalComposerContext as Xp}from"@lexical/react/LexicalComposerContext";import{useListDrawer as zp,useModal as Zp}from"@payloadcms/ui";import{$getNodeByKey as Kl,$getPreviousSelection as Yp,$getRoot as qp,$getSelection as Qp,$isRangeSelection as ef,$setSelection as tf}from"lexical";import{useEffect as of,useState as Jl}from"react";var St=t=>{let e=Kp(23),[o]=Xp(),[r,n]=Jl(null),[i,l]=Jl(!1),[s,u,c]=zp(t),{closeDrawer:d,drawerSlug:a,isDrawerOpen:p,openDrawer:m}=c,{modalState:f}=Zp(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let P=Qp()??Yp();n(P)},e[0]=h):h=e[0];let C=h,_;e[1]!==o||e[2]!==r?(_=()=>{r&&o.update(()=>{if(ef(r)){let{anchor:P,focus:v}=r;Kl(P.key)&&Kl(v.key)&&tf(r.clone())}else qp().selectEnd()},{discrete:!0,skipTransforms:!0})},e[1]=o,e[2]=r,e[3]=_):_=e[3];let R=_,A;e[4]!==d?(A=()=>{d()},e[4]=d,e[5]=A):A=e[5];let b=A,T,g;e[6]!==a||e[7]!==f||e[8]!==R||e[9]!==i?(T=()=>{if(!i)return;let P=f[a];P&&!P?.isOpen&&(l(!1),setTimeout(()=>{R()},1))},g=[f,a,R,i],e[6]=a,e[7]=f,e[8]=R,e[9]=i,e[10]=T,e[11]=g):(T=e[10],g=e[11]),of(T,g);let k;e[12]!==u?(k=P=>Jp(u,{...P,onClick:()=>{C()}}),e[12]=u,e[13]=k):k=e[13];let M;e[14]!==m?(M=()=>{C(),m(),l(!0)},e[14]=m,e[15]=M):M=e[15];let D;return e[16]!==s||e[17]!==b||e[18]!==p||e[19]!==a||e[20]!==k||e[21]!==M?(D={closeListDrawer:b,isListDrawerOpen:p,ListDrawer:s,listDrawerSlug:a,ListDrawerToggler:k,openListDrawer:M},e[16]=s,e[17]=b,e[18]=p,e[19]=a,e[20]=k,e[21]=M,e[22]=D):D=e[22],D};var cf=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=lf(o);n&&n.replace(je({relationTo:e,value:r}))}):t.dispatchCommand(lr,{relationTo:e,value:r})},zl=t=>{let e=rf(16),{enabledCollectionSlugs:o}=t,[r]=nf(),n;e[0]!==o?.[0]?(n=()=>o?.[0],e[0]=o?.[0],e[1]=n):n=e[1];let[i]=Xl(n),[l,s]=Xl(null),u=o||void 0,c;e[2]!==i||e[3]!==u?(c={collectionSlugs:u,selectedCollection:i},e[2]=i,e[3]=u,e[4]=c):c=e[4];let{closeListDrawer:d,ListDrawer:a,openListDrawer:p}=St(c),m,f;e[5]!==r||e[6]!==p?(m=()=>r.registerCommand(st,R=>(s(R?.replace?R?.replace.nodeKey:null),p(),!0),sf),f=[r,p],e[5]=r,e[6]=p,e[7]=m,e[8]=f):(m=e[7],f=e[8]),af(m,f);let h;e[9]!==d||e[10]!==r||e[11]!==l?(h=R=>{let{collectionSlug:A,doc:b}=R;cf({editor:r,relationTo:A,replaceNodeKey:l,value:b.id}),d()},e[9]=d,e[10]=r,e[11]=l,e[12]=h):h=e[12];let C=h,_;return e[13]!==a||e[14]!==C?(_=oo(a,{onSelect:C}),e[13]=a,e[14]=C,e[15]=_):_=e[15],_},Zl=t=>(t?.enabledCollectionSlugs?.length??-1)>0?oo(zl,{...t}):oo(Ot,{...t,children:oo(zl,{...t})});var lr=bf("INSERT_RELATIONSHIP_COMMAND"),ql=t=>{let e=uf(10),{clientProps:o}=t,[r]=mf(),{config:n}=ff(),{collections:i}=n,l=null;if(o?.enabledCollections)l=o?.enabledCollections;else if(o?.disabledCollections){let d;if(e[0]!==o?.disabledCollections||e[1]!==i){let a;e[3]!==o?.disabledCollections?(a=p=>{let{slug:m}=p;return!o?.disabledCollections?.includes(m)},e[3]=o?.disabledCollections,e[4]=a):a=e[4],d=i.filter(a).map(Tf),e[0]=o?.disabledCollections,e[1]=i,e[2]=d}else d=e[2];l=d}let s,u;e[5]!==r?(s=()=>{if(!r.hasNodes([Ne]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return r.registerCommand(lr,kf,xf)},u=[r],e[5]=r,e[6]=s,e[7]=u):(s=e[6],u=e[7]),_f(s,u);let c;return e[8]!==l?(c=df(Zl,{enabledCollectionSlugs:l}),e[8]=l,e[9]=c):c=e[9],c};function Tf(t){let{slug:e}=t;return e}function wf(t){return Yl(t)}function kf(t){let e=gf()||hf();if(Cf(e)){let o=je(t);pf(o);let{focus:r}=e,n=r.getNode();Yl(n)&&n.getTextContentSize()===0&&n.getParentOrThrow().getChildren().filter(wf).length>1&&n.remove()}return!0}var Nf=y({nodes:[Ne],plugins:[{Component:ql,position:"normal"}],slashMenu:{groups:[Q([{Icon:nr,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(st,{replace:!1})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:nr,isActive:({selection:t})=>{if(!Ef(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return ir(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(st,{replace:!1})}}])]}});import{c as is}from"react/compiler-runtime";import{jsx as de,jsxs as Wf}from"react/jsx-runtime";import{useLexicalComposerContext as Vf}from"@lexical/react/LexicalComposerContext.js";import{useScrollInfo as Kf,useThrottledEffect as Jf,useTranslation as Xf}from"@payloadcms/ui";import*as Le from"react";import{useMemo as zf}from"react";import{c as Lf}from"react/compiler-runtime";import{jsx as Sf}from"react/jsx-runtime";import{mergeRegister as Rf}from"@lexical/utils";import{$addUpdateTag as If,$getSelection as yf}from"lexical";import{useEffect as ro,useState as sr}from"react";var ar="toolbar-popup__button",Rt=t=>{let e=Lf(34),{children:o,editor:r,item:n}=t,[i,l]=sr(!0),[s,u]=sr(!1),[c,d]=sr(ar),a=j(),p;e[0]!==s||e[1]!==r||e[2]!==a||e[3]!==i||e[4]!==n?(p=()=>{r.getEditorState().read(()=>{let M=yf();if(M){if(n.isActive){let D=n.isActive({editor:r,editorConfigContext:a,selection:M});s!==D&&u(D)}if(n.isEnabled){let D=n.isEnabled({editor:r,editorConfigContext:a,selection:M});i!==D&&l(D)}}})},e[0]=s,e[1]=r,e[2]=a,e[3]=i,e[4]=n,e[5]=p):p=e[5];let m=p,f,h;e[6]!==m?(f=()=>{m()},h=[m],e[6]=m,e[7]=f,e[8]=h):(f=e[7],h=e[8]),ro(f,h);let C,_;e[9]!==m?(C=()=>(document.addEventListener("mouseup",m),()=>{document.removeEventListener("mouseup",m)}),_=[m],e[9]=m,e[10]=C,e[11]=_):(C=e[10],_=e[11]),ro(C,_);let R,A;e[12]!==r||e[13]!==m?(R=()=>Rf(r.registerUpdateListener(()=>{m()})),A=[r,m],e[12]=r,e[13]=m,e[14]=R,e[15]=A):(R=e[14],A=e[15]),ro(R,A);let b;e[16]!==s||e[17]!==i||e[18]!==n.key?(b=()=>{d([ar,i===!1?"disabled":"",s?"active":"",n?.key?`${ar}-`+n.key:""].filter(Boolean).join(" "))},e[16]=s,e[17]=i,e[18]=n.key,e[19]=b):b=e[19];let T;e[20]!==s||e[21]!==c||e[22]!==i||e[23]!==n.key?(T=[i,s,c,n.key],e[20]=s,e[21]=c,e[22]=i,e[23]=n.key,e[24]=T):T=e[24],ro(b,T);let g;e[25]!==s||e[26]!==r||e[27]!==i||e[28]!==n?(g=()=>{if(i!==!1)return r.focus(()=>{r.update(vf),n.onSelect?.({editor:r,isActive:s})}),!0},e[25]=s,e[26]=r,e[27]=i,e[28]=n,e[29]=g):g=e[29];let k;return e[30]!==o||e[31]!==c||e[32]!==g?(k=Sf("button",{className:c,onClick:g,onMouseDown:Mf,type:"button",children:o}),e[30]=o,e[31]=c,e[32]=g,e[33]=k):k=e[33],k};function vf(){If("toolbar")}function Mf(t){t.preventDefault()}import{c as ns}from"react/compiler-runtime";import{jsx as tt}from"react/jsx-runtime";import dr,{useEffect as rs}from"react";import{mergeRegister as Hf}from"@lexical/utils";import{useTranslation as jf}from"@payloadcms/ui";import{$getSelection as Uf}from"lexical";import{jsx as Me,jsxs as Ql}from"react/jsx-runtime";import{Button as Af}from"@payloadcms/ui";import{$addUpdateTag as Df,isDOMNode as Of}from"lexical";import no,{useCallback as Ff,useEffect as It,useMemo as $f,useRef as ur,useState as io}from"react";import{createPortal as Pf}from"react-dom";var cr="toolbar-popup__dropdown-item",es=no.createContext(null);function ts({active:t,children:e,editor:o,enabled:r,Icon:n,item:i,tooltip:l}){let[s,u]=io(cr);It(()=>{u([cr,r===!1?"disabled":"",t?"active":"",i?.key?`${cr}-${i.key}`:""].filter(Boolean).join(" "))},[r,t,s,i.key]);let c=ur(null),d=no.use(es);if(d===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:a}=d;return It(()=>{c?.current!=null&&a(c)},[c,a]),Me(Af,{"aria-label":l,buttonStyle:"none",className:s,disabled:r===!1,icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&o.focus(()=>{o.update(()=>{Df("toolbar")}),i.onSelect?.({editor:o,isActive:t})})},onMouseDown:p=>{p.preventDefault()},ref:c,tooltip:l,type:"button",children:e})}function Bf({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,i]=io(),[l,s]=io(),u=Ff(a=>{i(p=>p!=null?[...p,a]:[a])},[i]),c=a=>{if(n==null)return;let{key:p}=a;["ArrowDown","ArrowUp","Escape","Tab"].includes(p)&&a.preventDefault(),p==="Escape"||p==="Tab"?r():p==="ArrowUp"?s(m=>{if(m==null)return n[0];let f=n.indexOf(m)-1;return n[f===-1?n.length-1:f]}):p==="ArrowDown"&&s(m=>m==null?n[0]:n[n.indexOf(m)+1])},d=$f(()=>({registerItem:u}),[u]);return It(()=>{n!=null&&l==null&&s(n[0]),l!=null&&l?.current!=null&&l.current.focus()},[n,l]),Me(es,{value:d,children:Me("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:c,ref:e,children:t})})}function os({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,Icon:n,itemsContainerClassNames:i,label:l,stopCloseOnClickSelf:s}){let u=ur(null),c=ur(null),[d,a]=io(!1),p=()=>{a(!1),c?.current!=null&&c.current.focus()};It(()=>{let f=c.current,h=u.current;if(d&&f!==null&&h!==null){let{left:C,top:_}=f.getBoundingClientRect(),R=window.scrollY||document.documentElement.scrollTop;h.style.top=`${_+R+f.offsetHeight+5}px`,h.style.left=`${Math.min(C-5,window.innerWidth-h.offsetWidth-20)}px`}},[u,c,d]),It(()=>{let f=c.current;if(f!==null&&d){let h=C=>{let _=C.target;Of(_)&&(s&&u.current&&u.current.contains(_)||f.contains(_)||a(!1))};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[u,c,d,s]);let m=Pf(Me(Bf,{dropDownRef:u,itemsContainerClassNames:i,onClose:p,children:o}),document.body);return Ql(no.Fragment,{children:[Ql("button",{"aria-label":t,className:e+(d?" active":""),disabled:r,onClick:f=>{f.preventDefault(),a(!d)},onMouseDown:f=>{f.preventDefault()},ref:c,type:"button",children:[n&&Me(n,{}),l&&Me("span",{className:"toolbar-popup__dropdown-label",children:l}),Me("i",{className:"toolbar-popup__dropdown-caret"})]}),d&&Me(no.Fragment,{children:m})]})}var mr="toolbar-popup__dropdown",Gf=t=>{let e=ns(18),{active:o,anchorElem:r,editor:n,enabled:i,item:l}=t,{i18n:s}=jf(),{fieldProps:u}=j(),{featureClientSchemaMap:c,schemaPath:d}=u;if(l.Component){let f;return e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==i||e[4]!==l?(f=l?.Component&&tt(l.Component,{active:o,anchorElem:r,editor:n,enabled:i,item:l},l.key),e[0]=o,e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=f):f=e[5],f}let a=l.key,p;if(l.label){let f;e[6]!==c||e[7]!==s||e[8]!==l||e[9]!==d?(f=typeof l.label=="function"?l.label({featureClientSchemaMap:c,i18n:s,schemaPath:d}):l.label,e[6]=c,e[7]=s,e[8]=l,e[9]=d,e[10]=f):f=e[10],a=f}a.length>25?p=a.substring(0,25)+"...":p=a;let m;return e[11]!==o||e[12]!==p||e[13]!==n||e[14]!==i||e[15]!==l||e[16]!==a?(m=tt(ts,{active:o,editor:n,enabled:i,Icon:l?.ChildComponent?tt(l.ChildComponent,{}):void 0,item:l,tooltip:a,children:tt("span",{className:"text",children:p})},l.key),e[11]=o,e[12]=p,e[13]=n,e[14]=i,e[15]=l,e[16]=a,e[17]=m):m=e[17],m},Ue=t=>{let e=ns(36),{anchorElem:o,classNames:r,editor:n,group:i,Icon:l,itemsContainerClassNames:s,label:u,maxActiveItems:c,onActiveChange:d}=t,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=[],e[0]=a):a=e[0];let[p,m]=dr.useState(a),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[1]=f):f=e[1];let[h,C]=dr.useState(f),[_,R]=dr.useState(!0),A=j(),{items:b,key:T}=i,g;e[2]!==n||e[3]!==A||e[4]!==i||e[5]!==b||e[6]!==c||e[7]!==d?(g=()=>{n.getEditorState().read(()=>{let $=Uf();if(!$)return;let U=[],V=[],pe=[];for(let H of b)H.isActive&&(!c||U.length<c)&&H.isActive({editor:n,editorConfigContext:A,selection:$})&&(U.push(H.key),V.push(H)),H.isEnabled?H.isEnabled({editor:n,editorConfigContext:A,selection:$})&&pe.push(H.key):pe.push(H.key);i.isEnabled&&R(i.isEnabled({editor:n,editorConfigContext:A,selection:$})),m(U),C(pe),d&&d({activeItems:V})})},e[2]=n,e[3]=A,e[4]=i,e[5]=b,e[6]=c,e[7]=d,e[8]=g):g=e[8];let k=g,M,D;e[9]!==k?(M=()=>{k()},D=[k],e[9]=k,e[10]=M,e[11]=D):(M=e[10],D=e[11]),rs(M,D);let P,v;e[12]!==n||e[13]!==k?(P=()=>Hf(n.registerUpdateListener(()=>{k()})),v=[n,k],e[12]=n,e[13]=k,e[14]=P,e[15]=v):(P=e[14],v=e[15]),rs(P,v);let N=`${T} dropdown`,x=`${mr}-${T}`,E;e[16]!==r?(E=r||[],e[16]=r,e[17]=E):E=e[17];let S;e[18]!==E||e[19]!==x?(S=[mr,x,...E].filter(Boolean),e[18]=E,e[19]=x,e[20]=S):S=e[20];let L=S.join(" "),I=!_,w;e[21]!==s?(w=s||[],e[21]=s,e[22]=w):w=e[22];let F;return e[23]!==l||e[24]!==p||e[25]!==o||e[26]!==n||e[27]!==h||e[28]!==T||e[29]!==b||e[30]!==u||e[31]!==L||e[32]!==I||e[33]!==w||e[34]!==N?(F=tt(os,{buttonAriaLabel:N,buttonClassName:L,disabled:I,Icon:l,itemsContainerClassNames:[`${mr}-items`,...w],label:u,children:b.length?b.map($=>tt(Gf,{active:p.includes($.key),anchorElem:o,editor:n,enabled:h.includes($.key),item:$},$.key)):null},T),e[23]=l,e[24]=p,e[25]=o,e[26]=n,e[27]=h,e[28]=T,e[29]=b,e[30]=u,e[31]=L,e[32]=I,e[33]=w,e[34]=N,e[35]=F):F=e[35],F};function Zf({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&de(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?de(Rt,{editor:e,item:o,children:de(o.ChildComponent,{})},o.key):null}function Yf(t){let e=is(23),{anchorElem:o,editor:r,editorConfig:n,group:i,index:l}=t,{i18n:s}=Xf(),{fieldProps:u}=j(),{featureClientSchemaMap:c,schemaPath:d}=u,[a,p]=Le.useState(void 0),[m,f]=Le.useState(void 0),h;e[0]!==i.ChildComponent||e[1]!==i.items||e[2]!==i.type?(h=()=>{i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0)},e[0]=i.ChildComponent,e[1]=i.items,e[2]=i.type,e[3]=h):h=e[3];let C;e[4]!==i?(C=[i],e[4]=i,e[5]=C):C=e[5],Le.useEffect(h,C);let _;e[6]!==c||e[7]!==i.ChildComponent||e[8]!==i.items||e[9]!==i.type||e[10]!==s||e[11]!==d?(_=T=>{let{activeItems:g}=T;if(!g.length){i?.type==="dropdown"&&i.items.length&&i.ChildComponent?(f(()=>i.ChildComponent),p(void 0)):(f(void 0),p(void 0));return}let k=g[0],M=k.key;k.label&&(M=typeof k.label=="function"?k.label({featureClientSchemaMap:c,i18n:s,schemaPath:d}):k.label),M.length>25&&(M=M.substring(0,25)+"..."),g.length===1?(p(M),f(()=>k.ChildComponent)):(p(s.t("lexical:general:toolbarItemsActive",{count:g.length})),i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0))},e[6]=c,e[7]=i.ChildComponent,e[8]=i.items,e[9]=i.type,e[10]=s,e[11]=d,e[12]=_):_=e[12];let R=_,A=`fixed-toolbar__group fixed-toolbar__group-${i.key}`,b;return e[13]!==m||e[14]!==o||e[15]!==a||e[16]!==r||e[17]!==n.features.toolbarFixed?.groups.length||e[18]!==i||e[19]!==l||e[20]!==R||e[21]!==A?(b=Wf("div",{className:A,children:[i.type==="dropdown"&&i.items.length?m?de(Ue,{anchorElem:o,editor:r,group:i,Icon:m,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a,maxActiveItems:i.maxActiveItems??1,onActiveChange:R}):de(Ue,{anchorElem:o,editor:r,group:i,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a,maxActiveItems:i.maxActiveItems??1,onActiveChange:R}):null,i.type==="buttons"&&i.items.length?i.items.map(T=>de(Zf,{anchorElem:o,editor:r,item:T},T.key)):null,l<n.features.toolbarFixed?.groups.length-1&&de("div",{className:"divider"})]},i.key),e[13]=m,e[14]=o,e[15]=a,e[16]=r,e[17]=n.features.toolbarFixed?.groups.length,e[18]=i,e[19]=l,e[20]=R,e[21]=A,e[22]=b):b=e[22],b}function qf({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let i=Le.useRef(null),{y:l}=Kf(),s=zf(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let c=n.editorContainerRef.current.previousElementSibling;for(;c;){if(c.classList.contains("fixed-toolbar"))return c;c=c.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return Jf(()=>{if(!s)return;let u=i.current;if(!u)return;let c=u.getBoundingClientRect(),d=s.getBoundingClientRect();if(!(c.bottom<d.top||c.top>d.bottom))u.classList.remove("fixed-toolbar"),u.classList.add("fixed-toolbar","fixed-toolbar--overlapping"),s.classList.remove("fixed-toolbar"),s.classList.add("fixed-toolbar","fixed-toolbar--hide");else{if(!u.classList.contains("fixed-toolbar--overlapping"))return;u.classList.remove("fixed-toolbar--overlapping"),u.classList.add("fixed-toolbar"),s.classList.remove("fixed-toolbar--hide"),s.classList.add("fixed-toolbar")}},50,[i,s,l]),de("div",{className:"fixed-toolbar",onFocus:u=>{u.stopPropagation()},ref:i,children:o.isEditable()&&de(Le.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((u,c)=>de(Yf,{anchorElem:t,editor:o,editorConfig:r,group:u,index:c},u.key))})})}var ls=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return ls(t.parentEditor)}return!1},ss=t=>{let e=is(6),{clientProps:o}=t,[r]=Vf(),n=j(),{editorConfig:i}=n,l=o.applyToFocusedEditor&&n.focusedEditor?.editor||r,s=o.applyToFocusedEditor&&n.focusedEditor?.editorConfig||i,u,c;if(e[0]!==o.disableIfParentHasFixedToolbar||e[1]!==l||e[2]!==s||e[3]!==n){c=Symbol.for("react.early_return_sentinel");e:{let d=ls(n);if(o?.disableIfParentHasFixedToolbar&&d){c=null;break e}if(!s?.features?.toolbarFixed?.groups?.length){c=null;break e}u=de(qf,{anchorElem:document.body,editor:l,editorConfig:s,parentWithFixedToolbar:d})}e[0]=o.disableIfParentHasFixedToolbar,e[1]=l,e[2]=s,e[3]=n,e[4]=u,e[5]=c}else u=e[4],c=e[5];return c!==Symbol.for("react.early_return_sentinel")?c:u};var Qf=y({plugins:[{Component:ss,position:"aboveContainer"}]});import{c as us}from"react/compiler-runtime";import{jsx as ge,jsxs as ds}from"react/jsx-runtime";import{useLexicalComposerContext as e1}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ms}from"@lexical/utils";import{$getSelection as ps,$isRangeSelection as as,$isTextNode as t1,COMMAND_PRIORITY_LOW as o1,getDOMSelection as fs,SELECTION_CHANGE_COMMAND as r1}from"lexical";import{useCallback as so,useEffect as yt,useRef as cs,useState as n1}from"react";import*as ao from"react";import{createPortal as i1}from"react-dom";function pr(t,e){let o=t.getRangeAt(0),r;if(t.anchorNode===e){let n=e;for(;n.firstElementChild!=null;)n=n.firstElementChild;r=n.getBoundingClientRect()}else r=o.getBoundingClientRect();return r}function lo(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:i=32,horizontalPosition:l="left",specialHandlingForCaret:s=!1,targetRect:u,verticalGap:c=10}=t,d=o.parentElement;if(u===null||d==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let a=n.getBoundingClientRect(),p=o.getBoundingClientRect(),m=d.getBoundingClientRect(),f=u.top-a.height-c,h=u.left-i;l==="center"&&(h=u.left+u.width/2-a.width/2);let C=0;return!e&&f<m.top&&!s&&(C=a.height+u.height+c*2,f+=C),l==="center"?h+a.width>m.right?h=m.right-a.width-i:h<m.left&&(h=m.left+i):h+a.width>m.right&&(h=m.right-a.width-i),h-=p.left,n.style.opacity="1",s&&r!==0?(f-=p.bottom-r+a.height-3,n.style.transform=`translate(${h}px, ${f}px) rotate(180deg)`):(f-=p.top,n.style.transform=`translate(${h}px, ${f}px)`),C}function l1({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&ge(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?ge(Rt,{editor:e,item:o,children:ge(o.ChildComponent,{})},o.key):null}function s1(t){let e=us(19),{anchorElem:o,editor:r,group:n,index:i}=t,{editorConfig:l}=j(),[s,u]=ao.useState(),c;e[0]!==n.ChildComponent||e[1]!==n.items||e[2]!==n.type?(c=()=>{n?.type==="dropdown"&&n.items.length&&n.ChildComponent?u(()=>n.ChildComponent):u(void 0)},e[0]=n.ChildComponent,e[1]=n.items,e[2]=n.type,e[3]=c):c=e[3];let d;e[4]!==n?(d=[n],e[4]=n,e[5]=d):d=e[5],ao.useEffect(c,d);let a;e[6]!==n.ChildComponent||e[7]!==n.items||e[8]!==n.type?(a=h=>{let{activeItems:C}=h;if(!C.length){n?.type==="dropdown"&&n.items.length&&n.ChildComponent?u(()=>n.ChildComponent):u(void 0);return}let _=C[0];u(()=>_?.ChildComponent)},e[6]=n.ChildComponent,e[7]=n.items,e[8]=n.type,e[9]=a):a=e[9];let p=a,m=`inline-toolbar-popup__group inline-toolbar-popup__group-${n.key}`,f;return e[10]!==s||e[11]!==o||e[12]!==r||e[13]!==l.features.toolbarInline?.groups.length||e[14]!==n||e[15]!==i||e[16]!==p||e[17]!==m?(f=ds("div",{className:m,children:[n.type==="dropdown"&&n.items.length?s?ge(Ue,{anchorElem:o,editor:r,group:n,Icon:s,maxActiveItems:n.maxActiveItems??1,onActiveChange:p}):ge(Ue,{anchorElem:o,editor:r,group:n,maxActiveItems:n.maxActiveItems??1,onActiveChange:p}):null,n.type==="buttons"&&n.items.length?n.items.map(h=>ge(l1,{anchorElem:o,editor:r,item:h},h.key)):null,i<l.features.toolbarInline?.groups.length-1&&ge("div",{className:"divider"})]},n.key),e[10]=s,e[11]=o,e[12]=r,e[13]=l.features.toolbarInline?.groups.length,e[14]=n,e[15]=i,e[16]=p,e[17]=m,e[18]=f):f=e[18],f}function a1({anchorElem:t,editor:e}){let o=cs(null),r=cs(null),{editorConfig:n}=j(),i=so(()=>{if(o?.current){let c=o.current.style.opacity==="0",d=o.current.style.pointerEvents==="none";c||(o.current.style.opacity="0"),d||(o.current.style.pointerEvents="none")}},[o]),l=so(c=>{if(o?.current&&(c.buttons===1||c.buttons===3)){let d=o.current.style.opacity==="0",a=o.current.style.pointerEvents==="none";if(!d||!a){let p=c.clientX,m=c.clientY,f=document.elementFromPoint(p,m);o.current.contains(f)||i()}}},[i]),s=so(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);yt(()=>(document.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}),[o,l,s]);let u=so(()=>{let c=ps(),d=fs(e._window);if(o.current===null)return;let a=t.querySelector(":scope > .link-editor"),p=a!==null&&"style"in a&&a?.style?.opacity==="1",m=e.getRootElement();if(c!==null&&d!==null&&!d.isCollapsed&&m!==null&&m.contains(d.anchorNode)){let f=pr(d,m),h=lo({alwaysDisplayOnTop:p,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&lo({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else i()},[e,i,t]);return yt(()=>{let c=t.parentElement,d=()=>{e.getEditorState().read(()=>{u()})};return window.addEventListener("resize",d),c&&c.addEventListener("scroll",d),()=>{window.removeEventListener("resize",d),c&&c.removeEventListener("scroll",d)}},[e,u,t]),yt(()=>(e.getEditorState().read(()=>{u()}),ms(e.registerUpdateListener(({editorState:c})=>{c.read(()=>{u()})}),e.registerCommand(r1,()=>(u(),!1),o1))),[e,u]),ds("div",{className:"inline-toolbar-popup",ref:o,children:[ge("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((c,d)=>ge(s1,{anchorElem:t,editor:e,group:c,index:d},c.key))]})}function c1(t,e){let o=us(12),[r,n]=n1(!1),i;o[0]!==t?(i=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let p=ps(),m=fs(t._window),f=t.getRootElement();if(m!==null&&(!as(p)||f===null||!f.contains(m.anchorNode))){n(!1);return}if(!as(p))return;if(p.getTextContent()!==""){let C=p.getNodes(),_=!1;for(let R of C)if(t1(R)){n(!0),_=!0;break}_||n(!1)}else n(!1);let h=p.getTextContent().replace(/\n/g,"");if(!p.isCollapsed()&&h===""){n(!1);return}})},o[0]=t,o[1]=i):i=o[1];let l=i,s,u;o[2]!==l?(s=()=>(document.addEventListener("selectionchange",l),document.addEventListener("mouseup",l),()=>{document.removeEventListener("selectionchange",l),document.removeEventListener("mouseup",l)}),u=[l],o[2]=l,o[3]=s,o[4]=u):(s=o[3],u=o[4]),yt(s,u);let c,d;if(o[5]!==t||o[6]!==l?(c=()=>ms(t.registerUpdateListener(()=>{l()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),d=[t,l],o[5]=t,o[6]=l,o[7]=c,o[8]=d):(c=o[7],d=o[8]),yt(c,d),!r||!t.isEditable())return null;let a;return o[9]!==e||o[10]!==t?(a=i1(ge(a1,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=a):a=o[11],a}var hs=t=>{let{anchorElem:e}=t,[o]=e1();return c1(o,e)};var u1=y({plugins:[{Component:hs,position:"floatingAnchorElem"}]});import{TableCellNode as eg,TableNode as tg,TableRowNode as og}from"@lexical/table";import{jsx as gs}from"react/jsx-runtime";import"react";var fr=()=>gs("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:gs("path",{clipRule:"evenodd",d:"M5.33333 4.5C4.8731 4.5 4.5 4.8731 4.5 5.33333V7.5H9.5V4.5H5.33333ZM5.33333 3.5C4.32081 3.5 3.5 4.32081 3.5 5.33333V14.6667C3.5 15.6792 4.32081 16.5 5.33333 16.5H14.6667C15.6792 16.5 16.5 15.6792 16.5 14.6667V5.33333C16.5 4.32081 15.6792 3.5 14.6667 3.5H5.33333ZM10.5 4.5V7.5H15.5V5.33333C15.5 4.8731 15.1269 4.5 14.6667 4.5H10.5ZM15.5 8.5H10.5V11.5H15.5V8.5ZM15.5 12.5H10.5V15.5H14.6667C15.1269 15.5 15.5 15.1269 15.5 14.6667V12.5ZM9.5 15.5V12.5H4.5V14.6667C4.5 15.1269 4.8731 15.5 5.33333 15.5H9.5ZM4.5 11.5H9.5V8.5H4.5V11.5Z",fill:"currentColor",fillRule:"evenodd"})});import{$createTableCellNode as d1,$createTableNode as m1,$createTableRowNode as p1,$isTableCellNode as Cs,$isTableNode as hr,$isTableRowNode as gr,TableCellHeaderStates as co,TableCellNode as f1,TableNode as h1,TableRowNode as g1}from"@lexical/table";import{$isParagraphNode as C1,$isTextNode as x1}from"lexical";var bs=/^\|(.+)\|\s?$/,b1=/^(\| ?:?-*:? ?)+\|\s?$/,_s=({allTransformers:t})=>({type:"element",dependencies:[h1,g1,f1],export:e=>{if(!hr(e))return null;let o=[];for(let r of e.getChildren()){let n=[];if(!gr(r))continue;let i=!1;for(let l of r.getChildren())Cs(l)&&(n.push(Br(t,l).replace(/\n/g,"\\n").trim()),l.__headerState===co.ROW&&(i=!0));o.push(`| ${n.join(" | ")} |`),i&&o.push(`| ${n.map(l=>"---").join(" | ")} |`)}return o.join(`
39
39
  `)},regExp:bs,replace:(e,o,r)=>{let n=r[0];if(!n)return;if(b1.test(n)){let a=e.getPreviousSibling();if(!a||!hr(a))return;let p=a.getChildren(),m=p[p.length-1];if(!m||!gr(m))return;m.getChildren().forEach(f=>{Cs(f)&&f.setHeaderStyles(co.ROW,co.ROW)}),e.remove();return}let i=xs(n,t);if(i==null)return;let l=[i],s=e.getPreviousSibling(),u=i.length;for(;s&&!(!C1(s)||s.getChildrenSize()!==1);){let a=s.getFirstChild();if(!x1(a))break;let p=xs(a.getTextContent(),t);if(p==null)break;u=Math.max(u,p.length),l.unshift(p);let m=s.getPreviousSibling();s.remove(),s=m}let c=m1();for(let a of l){let p=p1();c.append(p);for(let m=0;m<u;m++)p.append(m<a.length?a[m]:Ts("",t))}let d=e.getPreviousSibling();hr(d)&&_1(d)===u?(d.append(...c.getChildren()),e.remove()):e.replace(c),c.selectEnd()}});function _1(t){let e=t.getFirstChild();return gr(e)?e.getChildrenSize():0}var Ts=(t,e)=>{t=t.replace(/\\n/g,`
40
- `);let o=d1(co.NO_STATUS);return Pr(t,e,o),o},xs=(t,e)=>{let o=t.match(bs);return!o||!o[1]?null:o[1].split("|").map(r=>Ts(r,e))};import{c as w1}from"react/compiler-runtime";import{jsx as B,jsxs as Se}from"react/jsx-runtime";import{useLexicalComposerContext as Ns}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as k1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as xr,$deleteTableColumn__EXPERIMENTAL as E1,$deleteTableRow__EXPERIMENTAL as N1,$getNodeTriplet as L1,$getTableCellNodeFromLexicalNode as ks,$getTableColumnIndexFromTableCellNode as S1,$getTableNodeFromLexicalNodeOrThrow as Re,$getTableRowIndexFromTableCellNode as R1,$insertTableColumn__EXPERIMENTAL as I1,$insertTableRow__EXPERIMENTAL as y1,$isTableCellNode as Ls,$isTableSelection as vt,$unmergeCell as v1,getTableElement as br,getTableObserverFromTableElement as _r,TableCellHeaderStates as Ae,TableCellNode as M1}from"@lexical/table";import{mergeRegister as A1}from"@lexical/utils";import{useScrollInfo as D1}from"@payloadcms/ui";import{$createParagraphNode as O1,$getSelection as mo,$isElementNode as F1,$isParagraphNode as $1,$isRangeSelection as Tr,$isTextNode as P1,$setSelection as B1,COMMAND_PRIORITY_CRITICAL as H1,getDOMSelection as j1,isDOMNode as U1,SELECTION_CHANGE_COMMAND as G1}from"lexical";import*as wr from"react";import{useCallback as me,useEffect as ot,useRef as uo,useState as rt}from"react";import{createPortal as Ss}from"react-dom";import{jsx as Cr,jsxs as T1}from"react/jsx-runtime";import"react";var ws=()=>T1("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Cr("path",{d:"M5 11C5.55228 11 6 10.5523 6 10C6 9.44772 5.55228 9 5 9C4.44772 9 4 9.44772 4 10C4 10.5523 4.44772 11 5 11Z",fill:"currentColor"}),Cr("path",{d:"M10 11C10.5523 11 11 10.5523 11 10C11 9.44772 10.5523 9 10 9C9.44772 9 9 9.44772 9 10C9 10.5523 9.44772 11 10 11Z",fill:"currentColor"}),Cr("path",{d:"M15 11C15.5523 11 16 10.5523 16 10C16 9.44772 15.5523 9 15 9C14.4477 9 14 9.44772 14 10C14 10.5523 14.4477 11 15 11Z",fill:"currentColor"})]});function Es(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function W1(){let t=mo();if(Tr(t)&&!t.isCollapsed()||vt(t)&&!t.anchor.is(t.focus)||!Tr(t)&&!vt(t))return!1;let[e]=L1(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function V1(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!$1(e)||!e.isEmpty())}function K1(t){let e=t.getLastDescendant();P1(e)?e.select():F1(e)?e.selectEnd():e!==null&&e.selectNext()}function J1({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[i]=Ns(),l=uo(null),[s,u]=rt(n),[c,d]=rt({columns:1,rows:1}),[a,p]=rt(!1),[m,f]=rt(!1),{y:h}=D1();ot(()=>i.registerMutationListener(M1,x=>{x.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{u(s.getLatest())})},{skipInitialization:!0}),[i,s]),ot(()=>{i.getEditorState().read(()=>{let x=mo();if(vt(x)){let E=Es(x);d(Es(x)),p(E.columns>1||E.rows>1)}f(W1())})},[i]),ot(()=>{let x=e.current,E=l.current,S=i.getRootElement();if(x!=null&&E!=null&&S!=null){let L=S.getBoundingClientRect(),I=x.getBoundingClientRect();E.style.opacity="1";let w=E.getBoundingClientRect(),F=5,$=I.right+F;if($+w.width>window.innerWidth||$+w.width>L.right){let V=I.left-w.width-F;$=(V<0?F:V)+window.pageXOffset}E.style.left=`${$+window.pageXOffset}px`;let U=I.top;if(U+w.height>window.innerHeight){let V=I.bottom-w.height;U=V<0?F:V}E.style.top=`${U}px`}},[e,l,i,h]),ot(()=>{function x(E){l.current!=null&&e.current!=null&&U1(E.target)&&!l.current.contains(E.target)&&!e.current.contains(E.target)&&r(!1)}return window.addEventListener("click",x),()=>window.removeEventListener("click",x)},[r,e]);let C=me(()=>{i.update(()=>{if(s.isAttached()){let x=Re(s),E=br(x,i.getElementByKey(x.getKey()));if(E===null)throw new Error("Expected to find tableElement in DOM");let S=_r(E);S!==null&&S.$clearHighlight(),x.markDirty(),u(s.getLatest())}B1(null)})},[i,s]),_=()=>{i.update(()=>{let x=mo();if(vt(x)){let S=x.getNodes().filter(Ls);if(S.length===0)return;let L=Re(S[0]),[I]=xr(L,null,null),w=1/0,F=-1/0,$=1/0,U=-1/0,V=new Set;for(let Y of I)for(let K of Y){if(!K||!K.cell)continue;let oe=K.cell.getKey();if(!V.has(oe)&&S.some(re=>re.is(K.cell))){V.add(oe);let re=K.startRow,le=K.startColumn,De=K.cell.__rowSpan||1,it=K.cell.__colSpan||1;w=Math.min(w,re),F=Math.max(F,re+De-1),$=Math.min($,le),U=Math.max(U,le+it-1)}}if(w===1/0||$===1/0)return;let pe=F-w+1,H=U-$+1,W=I?.[w]?.[$];if(!W?.cell)return;let te=W.cell;te.setColSpan(H),te.setRowSpan(pe);let ce=new Set([te.getKey()]);for(let Y=w;Y<=F;Y++)for(let K=$;K<=U;K++){let oe=I?.[Y]?.[K];if(!oe?.cell)continue;let re=oe.cell,le=re.getKey();ce.has(le)||(ce.add(le),V1(re)||te.append(...re.getChildren()),re.remove())}te.getChildrenSize()===0&&te.append(O1()),K1(te),o()}})},R=()=>{i.update(()=>{v1()})},A=me(x=>{i.update(()=>{for(let E=0;E<c.rows;E++)y1(x);o()})},[i,o,c.rows]),b=me(x=>{i.update(()=>{for(let E=0;E<c.columns;E++)I1(x);o()})},[i,o,c.columns]),T=me(()=>{i.update(()=>{N1(),o()})},[i,o]),g=me(()=>{i.update(()=>{Re(s).remove(),C(),o()})},[i,s,C,o]),k=me(()=>{i.update(()=>{E1(),o()})},[i,o]),M=me(()=>{i.update(()=>{let x=Re(s),E=R1(s),[S]=xr(x,null,null),L=new Set,I=s.getHeaderStyles()^Ae.ROW;if(S[E])for(let w=0;w<S[E].length;w++){let F=S[E][w];F?.cell&&(L.has(F.cell)||(L.add(F.cell),F.cell.setHeaderStyles(I,Ae.ROW)))}C(),o()})},[i,s,C,o]),D=me(()=>{i.update(()=>{let x=Re(s),E=S1(s),[S]=xr(x,null,null),L=new Set,I=s.getHeaderStyles()^Ae.COLUMN;if(S)for(let w=0;w<S.length;w++){let F=S?.[w]?.[E];F?.cell&&(L.has(F.cell)||(L.add(F.cell),F.cell.setHeaderStyles(I,Ae.COLUMN)))}C(),o()})},[i,s,C,o]),P=me(()=>{i.update(()=>{if(s.isAttached()){let x=Re(s);x&&x.setRowStriping(!x.getRowStriping())}C(),o()})},[i,s,C,o]),v=me(()=>{i.update(()=>{if(s.isAttached()){let x=Re(s);x&&x.setFrozenColumns(x.getFrozenColumns()===0?1:0)}C(),o()})},[i,s,C,o]),N=null;return t&&(a?N=B("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>_(),type:"button",children:B("span",{className:"text",children:"Merge cells"})}):m&&(N=B("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>R(),type:"button",children:B("span",{className:"text",children:"Unmerge cells"})}))),Ss(Se("div",{className:"table-action-menu-dropdown",onClick:x=>{x.stopPropagation()},ref:l,children:[N?Se(wr.Fragment,{children:[N,B("hr",{})]}):null,B("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>P(),type:"button",children:B("span",{className:"text",children:"Toggle Row Striping"})}),B("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>v(),type:"button",children:B("span",{className:"text",children:"Toggle First Column Freeze"})}),B("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>A(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),B("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>A(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>b(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),B("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>b(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>k(),type:"button",children:B("span",{className:"text",children:"Delete column"})}),B("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>T(),type:"button",children:B("span",{className:"text",children:"Delete row"})}),B("button",{className:"item","data-test-id":"table-delete",onClick:()=>g(),type:"button",children:B("span",{className:"text",children:"Delete table"})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-row-header",onClick:()=>M(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&Ae.ROW)===Ae.ROW?"Remove":"Add"," ","row header"]})}),B("button",{className:"item","data-test-id":"table-column-header",onClick:()=>D(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&Ae.COLUMN)===Ae.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function X1({anchorElem:t,cellMerge:e}){let[o]=Ns(),r=uo(null),n=uo(null),[i,l]=rt(!1),[s,u]=rt(null),c=me(()=>{let a=r.current,p=mo(),m=j1(o._window),f=document.activeElement;function h(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),u(null)}if(p==null||a==null)return h();let C=o.getRootElement(),_=null,R=null;if(Tr(p)&&C!==null&&m!==null&&C.contains(m.anchorNode)){let b=ks(p.anchor.getNode());if(b==null||(R=o.getElementByKey(b.getKey()),R==null||!b.isAttached()))return h();let T=Re(b),g=br(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");_=_r(g),u(b)}else if(vt(p)){let b=ks(p.anchor.getNode());if(!Ls(b))throw new Error("TableSelection anchorNode must be a TableCellNode");let T=Re(b),g=br(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");_=_r(g),R=o.getElementByKey(b.getKey())}else if(!f)return h();if(_===null||R===null)return h();let A=!_||!_.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",A),a.classList.toggle("table-cell-action-button-container--inactive",!A),A){let b=R.getBoundingClientRect(),T=t.getBoundingClientRect(),g=b.top-T.top,k=b.right-T.left;a.style.transform=`translate(${k}px, ${g}px)`}},[o,t]);ot(()=>{let a,p=()=>{a=void 0,o.getEditorState().read(c)},m=()=>(a===void 0&&(a=setTimeout(p,0)),!1);return A1(o.registerUpdateListener(m),o.registerCommand(G1,m,H1),o.registerRootListener((f,h)=>{h&&h.removeEventListener("pointerup",m),f&&(f.addEventListener("pointerup",m),m())}),()=>clearTimeout(a))});let d=uo(s);return ot(()=>{d.current!==s&&l(!1),d.current=s},[d,s]),B("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&Se(wr.Fragment,{children:[B("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),l(!i)},ref:n,type:"button",children:B(ws,{})}),i&&B(J1,{cellMerge:e,contextRef:n,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Rs=t=>{let e=w1(3),{anchorElem:o}=t,r=k1(),n;return e[0]!==o||e[1]!==r?(n=Ss(r?B(X1,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as z1}from"react/compiler-runtime";import{jsx as fo,jsxs as Z1}from"react/jsx-runtime";import{useLexicalComposerContext as Y1}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as q1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Q1,$getTableNodeFromLexicalNodeOrThrow as kr,$getTableRowIndexFromTableCellNode as eh,$isTableCellNode as Is,$isTableRowNode as th,getDOMCellFromTarget as oh,getTableElement as rh,TableNode as ys}from"@lexical/table";import{calculateZoomLevel as vs,mergeRegister as nh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Er,isHTMLElement as ih}from"lexical";import*as As from"react";import{useCallback as Mt,useEffect as Nr,useRef as po,useState as nt}from"react";import{createPortal as lh}from"react-dom";var sh=33,Ms=92;function ah({editor:t}){let e=po(null),o=po(null),r=po(null),[n,i]=nt(!1),l=j(),s=po(null),[u,c]=nt(null),[d,a]=nt(null),[p,m]=nt(!1),[f,h]=nt(null),C=Mt(()=>{a(null),e.current=null,h(null),s.current=null,r.current=null},[]),_=v=>(v.buttons&1)===1;Nr(()=>{let v=new Set;return nh(t.registerMutationListener(ys,N=>{for(let[x,E]of N)E==="destroyed"?v.delete(x):v.add(x);i(v.size>0)}),t.registerNodeTransform(ys,N=>{if(N.getColWidths())return N;let x=N.getColumnCount(),E=Ms;return N.setColWidths(Array(x).fill(E)),N}))},[t]),Nr(()=>{if(!n)return;let v=S=>{let L=S.target;if(ih(L)){if(f){c({x:S.clientX,y:S.clientY});return}if(m(_(S)),!(o.current&&o.current.contains(L))&&e.current!==L){e.current=L;let I=oh(L);I&&d!==I?t.getEditorState().read(()=>{let w=Er(I.elem);if(!w)throw new Error("TableCellResizer: Table cell node not found.");let F=kr(w),$=rh(F,t.getElementByKey(F.getKey()));if(!$)throw new Error("TableCellResizer: Table element not found.");e.current=L,r.current=$.getBoundingClientRect(),a(I)},{editor:t}):I==null&&C()}}},N=S=>{m(!0)},x=S=>{m(!1)},E=t.registerRootListener((S,L)=>{L?.removeEventListener("mousemove",v),L?.removeEventListener("mousedown",N),L?.removeEventListener("mouseup",x),S?.addEventListener("mousemove",v),S?.addEventListener("mousedown",N),S?.addEventListener("mouseup",x)});return()=>{E()}},[d,f,t,n,C]);let R=v=>v==="bottom",A=Mt(v=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=Er(d.elem);if(!Is(N))throw new Error("TableCellResizer: Table cell node not found.");let x=kr(N),E=eh(N),S=x.getChildren(),I=N.getColSpan()===x.getColumnCount()?E:E+N.getRowSpan()-1;if(I>=S.length||I<0)throw new Error("Expected table cell to be inside of table row.");let w=S[I];if(!th(w))throw new Error("Expected table row");let F=w.getHeight();if(F===void 0){let U=w.getChildren();F=Math.min(...U.map(V=>b(V,t)??1/0))}let $=Math.max(F+v,sh);w.setHeight($)},{tag:"skip-scroll-into-view"})},[d,t]),b=(v,N)=>N.getElementByKey(v.getKey())?.clientHeight,T=(v,N)=>{let x;return N.forEach(E=>{E.forEach((S,L)=>{S.cell===v&&(x=L)})}),x},g=Mt(v=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=Er(d.elem);if(!Is(N))throw new Error("TableCellResizer: Table cell node not found.");let x=kr(N),[E]=Q1(x,null,null),S=T(N,E);if(S===void 0)throw new Error("TableCellResizer: Table column not found.");let L=x.getColWidths();if(!L)return;let I=L[S];if(I===void 0)return;let w=[...L],F=Math.max(I+v,Ms);w[S]=F,x.setColWidths(w)},{tag:"skip-scroll-into-view"})},[d,t]),k=Mt(v=>{let N=x=>{if(x.preventDefault(),x.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");if(s.current){let{x:E,y:S}=s.current;if(d===null)return;let L=vs(x.target);if(R(v)){let I=(x.clientY-S)/L;A(I)}else{let I=(x.clientX-E)/L;g(I)}C(),document.removeEventListener("mouseup",N)}};return N},[d,C,g,A]),M=Mt(v=>N=>{if(N.preventDefault(),N.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");s.current={x:N.clientX,y:N.clientY},c(s.current),h(v),document.addEventListener("mouseup",k(v))},[d,k]),[D,P]=nt({bottom:null,left:null,right:null,top:null});return Nr(()=>{if(d){let{height:v,left:N,top:x,width:E}=d.elem.getBoundingClientRect(),S=vs(d.elem),L=10,I={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${L}px`,left:`${window.scrollX+N}px`,top:`${window.scrollY+x+v-L/2}px`,width:`${E}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${v}px`,left:`${window.scrollX+N+E-L/2}px`,top:`${window.scrollY+x}px`,width:`${L}px`}},w=r.current;f&&u&&w&&(R(f)?(I[f].left=`${window.scrollX+w.left}px`,I[f].top=`${window.scrollY+u.y/S}px`,I[f].height="3px",I[f].width=`${w.width}px`):(I[f].top=`${window.scrollY+w.top}px`,I[f].left=`${window.scrollX+u.x/S}px`,I[f].width="3px",I[f].height=`${w.height}px`),I[f].backgroundColor="#adf"),P(I)}else P({bottom:null,left:null,right:null,top:null})},[d,f,u]),fo("div",{ref:o,children:d!=null&&!p&&Z1(As.Fragment,{children:[fo("div",{className:`${l.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:M("right"),style:D.right||void 0}),fo("div",{className:`${l.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:M("bottom"),style:D.bottom||void 0})]})})}var Ds=()=>{let t=z1(3),[e]=Y1(),o=q1(),r,n;return t[0]!==e||t[1]!==o?(n=o?lh(fo(ah,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=n):n=t[2],r=n,r};import{c as gh}from"react/compiler-runtime";import{jsx as Lr,jsxs as Ch,Fragment as xh}from"react/jsx-runtime";import{useLexicalComposerContext as Us}from"@lexical/react/LexicalComposerContext";import{$getTableAndElementByKey as bh,$getTableColumnIndexFromTableCellNode as _h,$getTableRowIndexFromTableCellNode as Th,$insertTableColumn__EXPERIMENTAL as wh,$insertTableRow__EXPERIMENTAL as kh,$isTableCellNode as Eh,$isTableNode as $s,getTableElement as Nh,TableNode as Lh}from"@lexical/table";import{$findMatchingParent as Sh,mergeRegister as Rh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Ps,isHTMLElement as Ih}from"lexical";import{useEffect as Bs,useMemo as yh,useRef as Hs,useState as ho}from"react";import"react";import{createPortal as vh}from"react-dom";import{c as ph}from"react/compiler-runtime";import{useEffect as fh,useRef as hh}from"react";var ch="Expected a function",uh=Math.max,dh=Math.min;function mh(t,e,o){let r,n,i=0,l,s=!1,u=!1,c,d,a,p=!0;if(typeof t!="function")throw new TypeError(ch);e=e||0,typeof o=="object"&&(s=!!o.leading,u="maxWait"in o,c=u?uh(o.maxWait||0,e):c,p="trailing"in o?!!o.trailing:p);function m(g){let k=r,M=l;return r=l=void 0,i=g,d=t.apply(M,k),d}function f(g){return i=g,a=setTimeout(_,e),s?m(g):d}function h(g){let k=g-n,M=g-i,D=e-k;return u?dh(D,c-M):D}function C(g){let k=g-n,M=g-i;return n===void 0||k>=e||k<0||u&&M>=c}function _(){let g=Date.now();if(C(g))return R(g);a=setTimeout(_,h(g))}function R(g){return a=void 0,p&&r?m(g):(r=l=void 0,d)}function A(){a!==void 0&&clearTimeout(a),i=0,r=n=l=a=void 0}function b(){return a===void 0?d:R(Date.now())}function T(){let g=Date.now(),k=C(g);if(r=arguments,l=this,n=g,k){if(a===void 0)return f(n);if(u)return clearTimeout(a),a=setTimeout(_,e),m(n)}return a===void 0&&(a=setTimeout(_,e)),d}return T.cancel=A,T.flush=b,T}var Os=mh;function Fs(t,e,o){let r=ph(6),n=hh(null),i,l;r[0]!==t||r[1]!==o||r[2]!==e?(i=()=>(n.current=Os(t,e,{maxWait:o}),()=>{n.current?.cancel()}),l=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=i,r[4]=l):(i=r[3],l=r[4]),fh(i,l);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...c)=>{let d=c;n.current&&n.current(...d)},r[5]=s):s=r[5],s}var js=20;function Mh({anchorElem:t}){let[e]=Us(),o=j(),[r,n]=ho(!1),[i,l]=ho(!1),[s,u]=ho(!1),[c,d]=ho({}),a=Hs(new Set),p=Hs(null),m=Fs(C=>{let{isOutside:_,tableDOMNode:R}=Ah(C,o.editorConfig?.lexical);if(_){n(!1),l(!1);return}if(!R)return;p.current=R;let A=null,b=null,T=null;if(e.getEditorState().read(()=>{let L=Ps(R);if(Eh(L)){let I=Sh(L,w=>$s(w));if(!$s(I))return;if(T=Nh(I,e.getElementByKey(I.getKey())),T){let w=I.getChildrenSize(),F=I.getChildAtIndex(0)?.getChildrenSize(),$=Th(L),U=_h(L);$===w-1?A=L:U===F-1&&(b=L)}}},{editor:e}),!T)return;let g=T.parentElement;if(!g)return;let{bottom:k,height:M,left:D,right:P,width:v,y:N}=T.getBoundingClientRect(),x=!1;g&&g.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(x=g.scrollWidth>g.clientWidth);let{left:E,y:S}=t.getBoundingClientRect();A?(l(!1),n(!0),d({height:js,left:x&&g?g.offsetLeft:D-E,top:k-S+5,width:x&&g?g.offsetWidth:v})):b&&(l(!0),n(!1),d({height:M,left:P-E+5,top:N-S,width:js}))},50,250),f=yh(()=>new ResizeObserver(()=>{n(!1),l(!1)}),[]);Bs(()=>{if(s)return document.addEventListener("mousemove",m),()=>{n(!1),l(!1),document.removeEventListener("mousemove",m)}},[s,m]),Bs(()=>Rh(e.registerMutationListener(Lh,C=>{e.getEditorState().read(()=>{let _=!1;for(let[R,A]of C)switch(A){case"created":{a.current.add(R),_=!0;break}case"destroyed":{a.current.delete(R),_=!0;break}default:break}if(_){f.disconnect();for(let R of a.current){let{tableElement:A}=bh(R);f.observe(A)}u(a.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let h=C=>{e.update(()=>{p.current&&(Ps(p.current)?.selectEnd(),C?(kh(),n(!1)):(wh(),l(!1)))})};return e?.isEditable()?Ch(xh,{children:[r&&Lr("button",{"aria-label":"Add Row",className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...c},type:"button"}),i&&Lr("button",{"aria-label":"Add Column",className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...c},type:"button"})]}):null}function Ah(t,e){let o=t.target;if(Ih(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function Gs(t){let e=gh(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=Us();if(!n?.isEditable())return null;let i;return e[0]!==r?(i=vh(Lr(Mh,{anchorElem:r}),r),e[0]=r,e[1]=i):i=e[1],i}import{c as Dh}from"react/compiler-runtime";import{jsx as Sr,jsxs as Oh}from"react/jsx-runtime";import{useLexicalComposerContext as Fh}from"@lexical/react/LexicalComposerContext";import{TablePlugin as $h}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Ph,TableCellNode as Bh,TableNode as Hh,TableRowNode as jh}from"@lexical/table";import{mergeRegister as Uh}from"@lexical/utils";import{formatDrawerSlug as Gh,useEditDepth as Wh}from"@payloadcms/ui";import{$getSelection as Vh,$isRangeSelection as Kh,COMMAND_PRIORITY_EDITOR as Jh,createCommand as Xh}from"lexical";import{createContext as zh,use as Zh,useEffect as Yh,useMemo as qh,useState as Qh}from"react";import*as Ws from"react";var go=Xh("OPEN_EMBED_DRAWER_COMMAND"),Vs=zh({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function Ks({children:t}){let[e,o]=Qh({cellEditorConfig:null,cellEditorPlugins:null});return Sr(Vs,{value:qh(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Js=()=>{let t=Dh(16),[e]=Fh(),o=Zh(Vs),r=Wh(),{fieldProps:n,uuid:i}=j(),{schemaPath:l}=n,s="lexical-table-create-"+i,u;t[0]!==r||t[1]!==s?(u=Gh({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=u):u=t[2];let c=u,{toggleDrawer:d}=Ce(c,!0),a;t[3]!==e||t[4]!==d?(a=()=>{if(!e.hasNodes([Hh,jh,Bh]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return Uh(e.registerCommand(go,()=>{let h;return h=null,e.getEditorState().read(()=>{let C=Vh();Kh(C)&&(h=C)}),h&&d(),!0},Jh))},t[3]=e,t[4]=d,t[5]=a):a=t[5];let p;t[6]!==o||t[7]!==e||t[8]!==d?(p=[o,e,d],t[6]=o,t[7]=e,t[8]=d,t[9]=p):p=t[9],Yh(a,p);let m;t[10]!==e?(m=(h,C)=>{!C.columns||!C.rows||e.dispatchCommand(Ph,{columns:String(C.columns),rows:String(C.rows)})},t[10]=e,t[11]=m):m=t[11];let f;return t[12]!==c||t[13]!==l||t[14]!==m?(f=Oh(Ws.Fragment,{children:[Sr(lt,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:m,schemaPath:l,schemaPathSuffix:"fields"}),Sr($h,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=l,t[14]=m,t[15]=f):f=t[15],f};var rg=y({markdownTransformers:[_s],nodes:[tg,eg,og],plugins:[{Component:Js,position:"normal"},{Component:Ds,position:"normal"},{Component:Rs,position:"floatingAnchorElem"},{Component:Gs,position:"floatingAnchorElem"}],providers:[Ks],slashMenu:{groups:[Q([{Icon:fr,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(go,{})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:fr,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(go,{})}}])]}});import{$isNodeSelection as Dg}from"lexical";import{jsx as Rr,jsxs as ng}from"react/jsx-runtime";import"react";var Ir=()=>ng("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Rr("path",{d:"M14.6667 4H5.33333C4.59695 4 4 4.59695 4 5.33333V14.6667C4 15.403 4.59695 16 5.33333 16H14.6667C15.403 16 16 15.403 16 14.6667V5.33333C16 4.59695 15.403 4 14.6667 4Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),Rr("path",{d:"M7.99984 9.33366C8.73622 9.33366 9.33317 8.73671 9.33317 8.00033C9.33317 7.26395 8.73622 6.66699 7.99984 6.66699C7.26346 6.66699 6.6665 7.26395 6.6665 8.00033C6.6665 8.73671 7.26346 9.33366 7.99984 9.33366Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),Rr("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as cg}from"react/jsx-runtime";import Zs from"bson-objectid";import{$applyNodeReplacement as ug}from"lexical";import*as Ys from"react";import{jsx as ig}from"react/jsx-runtime";import{DecoratorBlockNode as lg}from"@lexical/react/LexicalDecoratorBlockNode.js";import Xs from"bson-objectid";import{$applyNodeReplacement as sg}from"lexical";import"react";function yr(t){return t.parentElement!=null&&t.parentElement.tagName==="LI"&&t.previousSibling===null&&t.getAttribute("aria-roledescription")==="checkbox"}function ag(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:zs({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||yr(e),null}var At=class extends lg{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:ag,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Xs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=zs({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return ig(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let e=document.createElement("img");return e.setAttribute("data-lexical-upload-id",String(this.__data?.value)),e.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function zs({data:t}){return t?.id||(t.id=new Xs.default().toHexString()),sg(new At({data:t}))}var dg=Ys.lazy(()=>import("./component-NNKG7K3O.js").then(t=>({default:t.UploadComponent})));function mg(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:Ge({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||yr(e),null}var Ie=class extends At{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:mg,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Zs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=Ge({data:o});return r.setFormat(e.format),r}decorate(){return cg(dg,{data:this.__data,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ge({data:t}){return t?.id||(t.id=new Zs.default().toHexString()),ug(new Ie({data:t}))}function vr(t){return t instanceof Ie}import{c as _g}from"react/compiler-runtime";import{jsx as Tg}from"react/jsx-runtime";import{useLexicalComposerContext as wg}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as kg,mergeRegister as Eg}from"@lexical/utils";import{useConfig as Ng}from"@payloadcms/ui";import{$getPreviousSelection as Lg,$getSelection as Sg,$isParagraphNode as Rg,$isRangeSelection as Ig,COMMAND_PRIORITY_EDITOR as yg,createCommand as vg}from"lexical";import{useEffect as Mg}from"react";import{c as qs}from"react/compiler-runtime";import{jsx as Mr}from"react/jsx-runtime";import{useLexicalComposerContext as Qs}from"@lexical/react/LexicalComposerContext.js";import{toast as pg}from"@payloadcms/ui";import{$getNodeByKey as fg,COMMAND_PRIORITY_EDITOR as ea}from"lexical";import{useEffect as ta,useState as hg}from"react";var gg=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=fg(o);n&&n.replace(Ge({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Ar,{fields:null,relationTo:e,value:r})},Cg=t=>{let e=qs(13),{enabledCollectionSlugs:o}=t,[r]=Qs(),[n,i]=hg(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let{closeListDrawer:s,ListDrawer:u,openListDrawer:c}=St(l),d,a;e[2]!==r||e[3]!==c?(d=()=>r.registerCommand(Ve,h=>(i(h?.replace?h?.replace.nodeKey:null),c(),!0),ea),a=[r,c],e[2]=r,e[3]=c,e[4]=d,e[5]=a):(d=e[4],a=e[5]),ta(d,a);let p;e[6]!==s||e[7]!==r||e[8]!==n?(p=h=>{let{collectionSlug:C,doc:_}=h;s(),gg({editor:r,relationTo:C,replaceNodeKey:n,value:_.id})},e[6]=s,e[7]=r,e[8]=n,e[9]=p):p=e[9];let m=p,f;return e[10]!==u||e[11]!==m?(f=Mr(u,{onSelect:m}),e[10]=u,e[11]=m,e[12]=f):f=e[12],f},xg=()=>{let t=qs(3),[e]=Qs(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Ve,bg,ea),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ta(o,r),null},oa=t=>Mr(Ot,{...t,FallbackComponent:xg,uploads:!0,children:Mr(Cg,{...t})});function bg(){return pg.error("No upload collections enabled"),!0}var Ar=vg("INSERT_UPLOAD_COMMAND"),ra=t=>{let e=_g(5),[o]=wg(),{config:r}=Ng(),{collections:n}=r,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([Ie]))throw new Error("UploadPlugin: UploadNode not registered on editor");return Eg(o.registerCommand(Ar,u=>(o.update(()=>{let c=Sg()||Lg();if(Ig(c)){let d=Ge({data:{id:u.id,fields:u.fields,relationTo:u.relationTo,value:u.value}});kg(d);let{focus:a}=c,p=a.getNode();Rg(p)&&!p.__first&&(p.__prev||p.__next)&&p.remove()}}),!0),yg))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),Mg(i,l);let s;return e[3]!==n?(s=Tg(oa,{enabledCollectionSlugs:n.map(Ag)}),e[3]=n,e[4]=s):s=e[4],s};function Ag(t){let{slug:e}=t;return e}var Og=y({nodes:[Ie],plugins:[{Component:ra,position:"normal"}],slashMenu:{groups:[Q([{Icon:Ir,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:Ir,isActive:({selection:t})=>{if(!Dg(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return vr(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]}});import{c as Fg}from"react/compiler-runtime";import{jsx as Or}from"react/jsx-runtime";import{ShimmerEffect as $g,useConfig as Pg}from"@payloadcms/ui";import{lazy as Bg,Suspense as Hg,useEffect as jg,useState as Ug}from"react";var na={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",hrSelected:"LexicalEditorTheme__hrSelected",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var Co={namespace:"lexical",theme:na};function ia({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:i}){for(let c of i.features)if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");i.features=i.features.sort((c,d)=>c.clientFeatureProps.order-d.clientFeatureProps.order);let l=new Map;for(let c of i.features)l.set(c.clientFeatureProps.featureKey,c);let s=new Map,u=0;for(let c of i.features){let d=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:l,field:r,resolvedFeatures:s,schemaPath:n,unSanitizedEditorConfig:i}):c.feature;d.key=c.clientFeatureProps.featureKey,d.order=u,s.set(c.clientFeatureProps.featureKey,d),u++}return s}var la=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}};if(!t?.size)return e;t.forEach(o=>{if(o.providers?.length&&(e.providers=e.providers.concat(o.providers)),o.enableFormats?.length&&e.enabledFormats.push(...o.enableFormats),o.nodes?.length)for(let r of o.nodes)e.nodes.push(r);if(o.plugins?.length&&o.plugins.forEach((r,n)=>{e.plugins?.push({clientProps:o.sanitizedClientFeatureProps,Component:r.Component,key:o.key+n,position:r.position})}),o.toolbarInline?.groups?.length)for(let r of o.toolbarInline.groups){let n=e.toolbarInline.groups.find(i=>i.key===r.key);n?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.toolbarInline?.groups.push(n)}if(o.toolbarFixed?.groups?.length)for(let r of o.toolbarFixed.groups){let n=e.toolbarFixed.groups.find(i=>i.key===r.key);n?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.toolbarFixed?.groups.push(n)}if(o.slashMenu?.groups){o.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(o.slashMenu.dynamicGroups));for(let r of o.slashMenu.groups){let n=e.slashMenu.groups.find(i=>i.key===r.key);n?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.slashMenu.groups.push(n)}}if(o.markdownTransformers?.length)for(let r of o.markdownTransformers)typeof r=="function"?e.markdownTransformers.push(r({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(r);e.enabledFeatures.push(o.key)}),e.toolbarInline.groups.sort((o,r)=>o.order&&r.order?o.order-r.order:o.order?-1:r.order?1:0),e.toolbarFixed.groups.sort((o,r)=>o.order&&r.order?o.order-r.order:o.order?-1:r.order?1:0);for(let o of e.toolbarInline.groups)o.items.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let o of e.toolbarFixed.groups)o.items.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);return e};function Dr(t,e,o){return{admin:o,features:la(t),lexical:e,resolvedFeatureMap:t}}var Gg=Bg(()=>import("./Field-MAUKSOAP.js").then(t=>({default:t.RichText}))),Wg=t=>{let e=Fg(16),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:i,field:l,lexicalEditorConfig:s,schemaPath:u}=t,c;e[0]!==o?(c=o===void 0?{}:o,e[0]=o,e[1]=c):c=e[1];let d=c,a=s===void 0?Co:s,{config:p}=Pg(),[m,f]=Ug(null),h,C;e[2]!==d||e[3]!==r||e[4]!==p||e[5]!==n||e[6]!==i||e[7]!==l||e[8]!==m||e[9]!==a||e[10]!==u?(h=()=>{if(m)return;let R=[];for(let[T,g]of Object.entries(r))g.clientFeatureProvider&&R.push(g.clientFeatureProvider(g.clientFeatureProps));let A=a||Co,b=ia({config:p,featureClientImportMap:n,featureClientSchemaMap:i,field:l,schemaPath:u??l.name,unSanitizedEditorConfig:{features:R,lexical:A}});f(Dr(b,A,d))},C=[a,d,m,r,n,i,l,p,u],e[2]=d,e[3]=r,e[4]=p,e[5]=n,e[6]=i,e[7]=l,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=C):(h=e[11],C=e[12]),jg(h,C);let _;return e[13]!==m||e[14]!==t?(_=Or(Hg,{fallback:Or($g,{height:"35vh"}),children:m&&Or(Gg,{...t,editorConfig:m})}),e[13]=m,e[14]=t,e[15]=_):_=e[15],_};function Vg(t){return t instanceof HTMLElement}function Kg(...t){return t.filter(Boolean).join(" ")}var xo=new WeakMap;function sa(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function bo(t,e){let o=xo.get(t);if(o===void 0){let r=new Set,n=l=>{o!==void 0&&(o.start=sa(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let u=sa(l);for(let c of r)u!==null&&c([u[0]-s[0],u[1]-s[1]],l)};t.addEventListener("touchstart",n),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:n,listeners:r,start:null},xo.set(t,o)}return o.listeners.add(e),()=>{Jg(t,e)}}function Jg(t,e){let o=xo.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(xo.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function Xg(t,e){return bo(t,(o,r)=>{let[n,i]=o;n<0&&-n>Math.abs(i)&&e(n,r)})}function zg(t,e){return bo(t,(o,r)=>{let[n,i]=o;n>0&&n>Math.abs(i)&&e(n,r)})}function Zg(t,e){return bo(t,(o,r)=>{let[n,i]=o;i<0&&-i>Math.abs(n)&&e(n,r)})}function Yg(t,e){return bo(t,(o,r)=>{let[n,i]=o;i>0&&i>Math.abs(n)&&e(n,r)})}import{c as qg}from"react/compiler-runtime";import{jsx as Qg}from"react/jsx-runtime";import"react";var eC=()=>{let t=qg(2),{EditButton:e}=xe(),o;return t[0]!==e?(o=e?Qg(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as tC}from"react/compiler-runtime";import{jsx as oC}from"react/jsx-runtime";import"react";var rC=()=>{let t=tC(2),{RemoveButton:e}=xe(),o;return t[0]!==e?(o=e?oC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as nC}from"react/compiler-runtime";import{jsx as iC}from"react/jsx-runtime";import"react";var lC=()=>{let t=nC(2),{Label:e}=xe(),o;return t[0]!==e?(o=e?iC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as sC}from"react/compiler-runtime";import{jsx as aC}from"react/jsx-runtime";import"react";var cC=t=>{let e=sC(3),{children:o}=t,{InlineBlockContainer:r}=xe(),n;return e[0]!==r||e[1]!==o?(n=r?aC(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as uC}from"react/compiler-runtime";import{jsx as dC}from"react/jsx-runtime";import"react";var mC=t=>{let e=uC(6),{children:o,editButton:r,Label:n,removeButton:i}=t,{BlockCollapsible:l}=Oe(),s;return e[0]!==l||e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==i?(s=l?dC(l,{editButton:r,Label:n,removeButton:i,children:o}):null,e[0]=l,e[1]=n,e[2]=o,e[3]=r,e[4]=i,e[5]=s):s=e[5],s};import{c as pC}from"react/compiler-runtime";import{jsx as fC}from"react/jsx-runtime";import"react";var hC=()=>{let t=pC(2),{EditButton:e}=Oe(),o;return t[0]!==e?(o=e?fC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as gC}from"react/compiler-runtime";import{jsx as CC}from"react/jsx-runtime";import"react";var xC=()=>{let t=gC(2),{RemoveButton:e}=Oe(),o;return t[0]!==e?(o=e?CC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as bC}from"qs-esm";var _C=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:i,collectionSlug:l,select:s})=>{let u=bC({depth:e??0,draft:o??!1,locale:r,select:s},{addQueryPrefix:!0});return await fetch(`${t}/${l}/${i}${u}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(d=>d.json())};export{Ct as $createAutoLinkNode,Vt as $createBlockNode,To as $createInlineBlockNode,Te as $createLinkNode,je as $createRelationshipNode,Ge as $createUploadNode,ke as $isAutoLinkNode,pt as $isBlockNode,wo as $isInlineBlockNode,Z as $isLinkNode,ir as $isRelationshipNode,vr as $isUploadNode,_a as AlignFeatureClient,we as AutoLinkNode,mC as BlockCollapsible,hC as BlockEditButton,be as BlockNode,xC as BlockRemoveButton,Na as BlockquoteFeatureClient,wc as BlocksFeatureClient,Vc as BoldFeatureClient,ae as CAN_USE_DOM,$m as ChecklistFeatureClient,Sp as DETAIL_TYPE_TO_DETAIL,kp as DOUBLE_LINE_BREAK,Bp as DebugJsxConverterFeatureClient,Ip as ELEMENT_FORMAT_TO_TYPE,Rp as ELEMENT_TYPE_TO_FORMAT,pa as ENABLE_SLASH_MENU_COMMAND,ca as EditorConfigProvider,lt as FieldsDrawer,Qf as FixedToolbarFeatureClient,Su as HeadingFeatureClient,Wu as HorizontalRuleFeatureClient,Ke as INSERT_BLOCK_COMMAND,Je as INSERT_INLINE_BLOCK_COMMAND,Tp as IS_ALL_FORMATTING,cd as IndentFeatureClient,cC as InlineBlockContainer,eC as InlineBlockEditButton,lC as InlineBlockLabel,_o as InlineBlockNode,rC as InlineBlockRemoveButton,Zc as InlineCodeFeatureClient,u1 as InlineToolbarFeatureClient,eu as ItalicFeatureClient,Np as LTR_REGEX,ip as LexicalPluginToLexicalFeatureClient,wm as LinkFeatureClient,ie as LinkNode,wp as NON_BREAKING_SPACE,O as NodeFormat,Vm as OrderedListFeatureClient,pp as ParagraphFeatureClient,da as Point,Ep as RTL_REGEX,fa as Rect,Nf as RelationshipFeatureClient,Ne as RelationshipNode,Wg as RichTextField,dp as SlateToLexicalFeatureClient,iu as StrikethroughFeatureClient,cu as SubscriptFeatureClient,pu as SuperscriptFeatureClient,yp as TEXT_MODE_TO_TYPE,Lp as TEXT_TYPE_TO_FORMAT,vp as TEXT_TYPE_TO_MODE,he as TOGGLE_LINK_COMMAND,rg as TableFeatureClient,Fc as TestRecorderFeatureClient,Rt as ToolbarButton,Ue as ToolbarDropdown,jc as TreeViewFeatureClient,xu as UnderlineFeatureClient,Qm as UnorderedListFeatureClient,Og as UploadFeatureClient,Ie as UploadNode,Yg as addSwipeDownListener,Xg as addSwipeLeftListener,zg as addSwipeRightListener,Zg as addSwipeUpListener,$o as createBlockNode,y as createClientFeature,Co as defaultEditorLexicalConfig,pr as getDOMRangeRect,ha as getEnabledNodes,_C as getRestPopulateFn,Xe as getSelectedNode,Vg as isHTMLElement,ma as isPoint,Kg as joinClasses,Dr as sanitizeClientEditorConfig,la as sanitizeClientFeatures,lo as setFloatingElemPosition,Qt as setFloatingElemPositionForLinkEditor,Q as slashMenuBasicGroupWithItems,_e as toolbarAddDropdownGroupWithItems,Bo as toolbarFeatureButtonsGroupWithItems,ee as toolbarFormatGroupWithItems,ne as toolbarTextDropdownGroupWithItems,Oe as useBlockComponentContext,j as useEditorConfigContext,xe as useInlineBlockComponentContext,ua as useLexicalDocumentDrawer,Ce as useLexicalDrawer,St as useLexicalListDrawer};
40
+ `);let o=d1(co.NO_STATUS);return Pr(t,e,o),o},xs=(t,e)=>{let o=t.match(bs);return!o||!o[1]?null:o[1].split("|").map(r=>Ts(r,e))};import{c as w1}from"react/compiler-runtime";import{jsx as B,jsxs as Se}from"react/jsx-runtime";import{useLexicalComposerContext as Ns}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as k1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as xr,$deleteTableColumn__EXPERIMENTAL as E1,$deleteTableRow__EXPERIMENTAL as N1,$getNodeTriplet as L1,$getTableCellNodeFromLexicalNode as ks,$getTableColumnIndexFromTableCellNode as S1,$getTableNodeFromLexicalNodeOrThrow as Re,$getTableRowIndexFromTableCellNode as R1,$insertTableColumn__EXPERIMENTAL as I1,$insertTableRow__EXPERIMENTAL as y1,$isTableCellNode as Ls,$isTableSelection as vt,$unmergeCell as v1,getTableElement as br,getTableObserverFromTableElement as _r,TableCellHeaderStates as Ae,TableCellNode as M1}from"@lexical/table";import{mergeRegister as A1}from"@lexical/utils";import{useScrollInfo as D1}from"@payloadcms/ui";import{$createParagraphNode as O1,$getSelection as mo,$isElementNode as F1,$isParagraphNode as $1,$isRangeSelection as Tr,$isTextNode as P1,$setSelection as B1,COMMAND_PRIORITY_CRITICAL as H1,getDOMSelection as j1,isDOMNode as U1,SELECTION_CHANGE_COMMAND as G1}from"lexical";import*as wr from"react";import{useCallback as me,useEffect as ot,useRef as uo,useState as rt}from"react";import{createPortal as Ss}from"react-dom";import{jsx as Cr,jsxs as T1}from"react/jsx-runtime";import"react";var ws=()=>T1("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Cr("path",{d:"M5 11C5.55228 11 6 10.5523 6 10C6 9.44772 5.55228 9 5 9C4.44772 9 4 9.44772 4 10C4 10.5523 4.44772 11 5 11Z",fill:"currentColor"}),Cr("path",{d:"M10 11C10.5523 11 11 10.5523 11 10C11 9.44772 10.5523 9 10 9C9.44772 9 9 9.44772 9 10C9 10.5523 9.44772 11 10 11Z",fill:"currentColor"}),Cr("path",{d:"M15 11C15.5523 11 16 10.5523 16 10C16 9.44772 15.5523 9 15 9C14.4477 9 14 9.44772 14 10C14 10.5523 14.4477 11 15 11Z",fill:"currentColor"})]});function Es(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function W1(){let t=mo();if(Tr(t)&&!t.isCollapsed()||vt(t)&&!t.anchor.is(t.focus)||!Tr(t)&&!vt(t))return!1;let[e]=L1(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function V1(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!$1(e)||!e.isEmpty())}function K1(t){let e=t.getLastDescendant();P1(e)?e.select():F1(e)?e.selectEnd():e!==null&&e.selectNext()}function J1({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[i]=Ns(),l=uo(null),[s,u]=rt(n),[c,d]=rt({columns:1,rows:1}),[a,p]=rt(!1),[m,f]=rt(!1),{y:h}=D1();ot(()=>i.registerMutationListener(M1,x=>{x.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{u(s.getLatest())})},{skipInitialization:!0}),[i,s]),ot(()=>{i.getEditorState().read(()=>{let x=mo();if(vt(x)){let E=Es(x);d(Es(x)),p(E.columns>1||E.rows>1)}f(W1())})},[i]),ot(()=>{let x=e.current,E=l.current,S=i.getRootElement();if(x!=null&&E!=null&&S!=null){let L=S.getBoundingClientRect(),I=x.getBoundingClientRect();E.style.opacity="1";let w=E.getBoundingClientRect(),F=5,$=I.right+F;if($+w.width>window.innerWidth||$+w.width>L.right){let V=I.left-w.width-F;$=(V<0?F:V)+window.pageXOffset}E.style.left=`${$+window.pageXOffset}px`;let U=I.top;if(U+w.height>window.innerHeight){let V=I.bottom-w.height;U=V<0?F:V}E.style.top=`${U}px`}},[e,l,i,h]),ot(()=>{function x(E){l.current!=null&&e.current!=null&&U1(E.target)&&!l.current.contains(E.target)&&!e.current.contains(E.target)&&r(!1)}return window.addEventListener("click",x),()=>window.removeEventListener("click",x)},[r,e]);let C=me(()=>{i.update(()=>{if(s.isAttached()){let x=Re(s),E=br(x,i.getElementByKey(x.getKey()));if(E===null)throw new Error("Expected to find tableElement in DOM");let S=_r(E);S!==null&&S.$clearHighlight(),x.markDirty(),u(s.getLatest())}B1(null)})},[i,s]),_=()=>{i.update(()=>{let x=mo();if(vt(x)){let S=x.getNodes().filter(Ls);if(S.length===0)return;let L=Re(S[0]),[I]=xr(L,null,null),w=1/0,F=-1/0,$=1/0,U=-1/0,V=new Set;for(let Y of I)for(let K of Y){if(!K||!K.cell)continue;let oe=K.cell.getKey();if(!V.has(oe)&&S.some(re=>re.is(K.cell))){V.add(oe);let re=K.startRow,le=K.startColumn,De=K.cell.__rowSpan||1,it=K.cell.__colSpan||1;w=Math.min(w,re),F=Math.max(F,re+De-1),$=Math.min($,le),U=Math.max(U,le+it-1)}}if(w===1/0||$===1/0)return;let pe=F-w+1,H=U-$+1,W=I?.[w]?.[$];if(!W?.cell)return;let te=W.cell;te.setColSpan(H),te.setRowSpan(pe);let ce=new Set([te.getKey()]);for(let Y=w;Y<=F;Y++)for(let K=$;K<=U;K++){let oe=I?.[Y]?.[K];if(!oe?.cell)continue;let re=oe.cell,le=re.getKey();ce.has(le)||(ce.add(le),V1(re)||te.append(...re.getChildren()),re.remove())}te.getChildrenSize()===0&&te.append(O1()),K1(te),o()}})},R=()=>{i.update(()=>{v1()})},A=me(x=>{i.update(()=>{for(let E=0;E<c.rows;E++)y1(x);o()})},[i,o,c.rows]),b=me(x=>{i.update(()=>{for(let E=0;E<c.columns;E++)I1(x);o()})},[i,o,c.columns]),T=me(()=>{i.update(()=>{N1(),o()})},[i,o]),g=me(()=>{i.update(()=>{Re(s).remove(),C(),o()})},[i,s,C,o]),k=me(()=>{i.update(()=>{E1(),o()})},[i,o]),M=me(()=>{i.update(()=>{let x=Re(s),E=R1(s),[S]=xr(x,null,null),L=new Set,I=s.getHeaderStyles()^Ae.ROW;if(S[E])for(let w=0;w<S[E].length;w++){let F=S[E][w];F?.cell&&(L.has(F.cell)||(L.add(F.cell),F.cell.setHeaderStyles(I,Ae.ROW)))}C(),o()})},[i,s,C,o]),D=me(()=>{i.update(()=>{let x=Re(s),E=S1(s),[S]=xr(x,null,null),L=new Set,I=s.getHeaderStyles()^Ae.COLUMN;if(S)for(let w=0;w<S.length;w++){let F=S?.[w]?.[E];F?.cell&&(L.has(F.cell)||(L.add(F.cell),F.cell.setHeaderStyles(I,Ae.COLUMN)))}C(),o()})},[i,s,C,o]),P=me(()=>{i.update(()=>{if(s.isAttached()){let x=Re(s);x&&x.setRowStriping(!x.getRowStriping())}C(),o()})},[i,s,C,o]),v=me(()=>{i.update(()=>{if(s.isAttached()){let x=Re(s);x&&x.setFrozenColumns(x.getFrozenColumns()===0?1:0)}C(),o()})},[i,s,C,o]),N=null;return t&&(a?N=B("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>_(),type:"button",children:B("span",{className:"text",children:"Merge cells"})}):m&&(N=B("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>R(),type:"button",children:B("span",{className:"text",children:"Unmerge cells"})}))),Ss(Se("div",{className:"table-action-menu-dropdown",onClick:x=>{x.stopPropagation()},ref:l,children:[N?Se(wr.Fragment,{children:[N,B("hr",{})]}):null,B("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>P(),type:"button",children:B("span",{className:"text",children:"Toggle Row Striping"})}),B("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>v(),type:"button",children:B("span",{className:"text",children:"Toggle First Column Freeze"})}),B("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>A(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),B("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>A(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>b(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),B("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>b(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>k(),type:"button",children:B("span",{className:"text",children:"Delete column"})}),B("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>T(),type:"button",children:B("span",{className:"text",children:"Delete row"})}),B("button",{className:"item","data-test-id":"table-delete",onClick:()=>g(),type:"button",children:B("span",{className:"text",children:"Delete table"})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-row-header",onClick:()=>M(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&Ae.ROW)===Ae.ROW?"Remove":"Add"," ","row header"]})}),B("button",{className:"item","data-test-id":"table-column-header",onClick:()=>D(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&Ae.COLUMN)===Ae.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function X1({anchorElem:t,cellMerge:e}){let[o]=Ns(),r=uo(null),n=uo(null),[i,l]=rt(!1),[s,u]=rt(null),c=me(()=>{let a=r.current,p=mo(),m=j1(o._window),f=document.activeElement;function h(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),u(null)}if(p==null||a==null)return h();let C=o.getRootElement(),_=null,R=null;if(Tr(p)&&C!==null&&m!==null&&C.contains(m.anchorNode)){let b=ks(p.anchor.getNode());if(b==null||(R=o.getElementByKey(b.getKey()),R==null||!b.isAttached()))return h();let T=Re(b),g=br(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");_=_r(g),u(b)}else if(vt(p)){let b=ks(p.anchor.getNode());if(!Ls(b))throw new Error("TableSelection anchorNode must be a TableCellNode");let T=Re(b),g=br(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");_=_r(g),R=o.getElementByKey(b.getKey())}else if(!f)return h();if(_===null||R===null)return h();let A=!_||!_.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",A),a.classList.toggle("table-cell-action-button-container--inactive",!A),A){let b=R.getBoundingClientRect(),T=t.getBoundingClientRect(),g=b.top-T.top,k=b.right-T.left;a.style.transform=`translate(${k}px, ${g}px)`}},[o,t]);ot(()=>{let a,p=()=>{a=void 0,o.getEditorState().read(c)},m=()=>(a===void 0&&(a=setTimeout(p,0)),!1);return A1(o.registerUpdateListener(m),o.registerCommand(G1,m,H1),o.registerRootListener((f,h)=>{h&&h.removeEventListener("pointerup",m),f&&(f.addEventListener("pointerup",m),m())}),()=>clearTimeout(a))});let d=uo(s);return ot(()=>{d.current!==s&&l(!1),d.current=s},[d,s]),B("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&Se(wr.Fragment,{children:[B("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),l(!i)},ref:n,type:"button",children:B(ws,{})}),i&&B(J1,{cellMerge:e,contextRef:n,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Rs=t=>{let e=w1(3),{anchorElem:o}=t,r=k1(),n;return e[0]!==o||e[1]!==r?(n=Ss(r?B(X1,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as z1}from"react/compiler-runtime";import{jsx as fo,jsxs as Z1}from"react/jsx-runtime";import{useLexicalComposerContext as Y1}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as q1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Q1,$getTableNodeFromLexicalNodeOrThrow as kr,$getTableRowIndexFromTableCellNode as eh,$isTableCellNode as Is,$isTableRowNode as th,getDOMCellFromTarget as oh,getTableElement as rh,TableNode as ys}from"@lexical/table";import{calculateZoomLevel as vs,mergeRegister as nh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Er,isHTMLElement as ih}from"lexical";import*as As from"react";import{useCallback as Mt,useEffect as Nr,useRef as po,useState as nt}from"react";import{createPortal as lh}from"react-dom";var sh=33,Ms=92;function ah({editor:t}){let e=po(null),o=po(null),r=po(null),[n,i]=nt(!1),l=j(),s=po(null),[u,c]=nt(null),[d,a]=nt(null),[p,m]=nt(!1),[f,h]=nt(null),C=Mt(()=>{a(null),e.current=null,h(null),s.current=null,r.current=null},[]),_=v=>(v.buttons&1)===1;Nr(()=>{let v=new Set;return nh(t.registerMutationListener(ys,N=>{for(let[x,E]of N)E==="destroyed"?v.delete(x):v.add(x);i(v.size>0)}),t.registerNodeTransform(ys,N=>{if(N.getColWidths())return N;let x=N.getColumnCount(),E=Ms;return N.setColWidths(Array(x).fill(E)),N}))},[t]),Nr(()=>{if(!n)return;let v=S=>{let L=S.target;if(ih(L)){if(f){c({x:S.clientX,y:S.clientY});return}if(m(_(S)),!(o.current&&o.current.contains(L))&&e.current!==L){e.current=L;let I=oh(L);I&&d!==I?t.getEditorState().read(()=>{let w=Er(I.elem);if(!w)throw new Error("TableCellResizer: Table cell node not found.");let F=kr(w),$=rh(F,t.getElementByKey(F.getKey()));if(!$)throw new Error("TableCellResizer: Table element not found.");e.current=L,r.current=$.getBoundingClientRect(),a(I)},{editor:t}):I==null&&C()}}},N=S=>{m(!0)},x=S=>{m(!1)},E=t.registerRootListener((S,L)=>{L?.removeEventListener("mousemove",v),L?.removeEventListener("mousedown",N),L?.removeEventListener("mouseup",x),S?.addEventListener("mousemove",v),S?.addEventListener("mousedown",N),S?.addEventListener("mouseup",x)});return()=>{E()}},[d,f,t,n,C]);let R=v=>v==="bottom",A=Mt(v=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=Er(d.elem);if(!Is(N))throw new Error("TableCellResizer: Table cell node not found.");let x=kr(N),E=eh(N),S=x.getChildren(),I=N.getColSpan()===x.getColumnCount()?E:E+N.getRowSpan()-1;if(I>=S.length||I<0)throw new Error("Expected table cell to be inside of table row.");let w=S[I];if(!th(w))throw new Error("Expected table row");let F=w.getHeight();if(F===void 0){let U=w.getChildren();F=Math.min(...U.map(V=>b(V,t)??1/0))}let $=Math.max(F+v,sh);w.setHeight($)},{tag:"skip-scroll-into-view"})},[d,t]),b=(v,N)=>N.getElementByKey(v.getKey())?.clientHeight,T=(v,N)=>{let x;return N.forEach(E=>{E.forEach((S,L)=>{S.cell===v&&(x=L)})}),x},g=Mt(v=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=Er(d.elem);if(!Is(N))throw new Error("TableCellResizer: Table cell node not found.");let x=kr(N),[E]=Q1(x,null,null),S=T(N,E);if(S===void 0)throw new Error("TableCellResizer: Table column not found.");let L=x.getColWidths();if(!L)return;let I=L[S];if(I===void 0)return;let w=[...L],F=Math.max(I+v,Ms);w[S]=F,x.setColWidths(w)},{tag:"skip-scroll-into-view"})},[d,t]),k=Mt(v=>{let N=x=>{if(x.preventDefault(),x.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");if(s.current){let{x:E,y:S}=s.current;if(d===null)return;let L=vs(x.target);if(R(v)){let I=(x.clientY-S)/L;A(I)}else{let I=(x.clientX-E)/L;g(I)}C(),document.removeEventListener("mouseup",N)}};return N},[d,C,g,A]),M=Mt(v=>N=>{if(N.preventDefault(),N.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");s.current={x:N.clientX,y:N.clientY},c(s.current),h(v),document.addEventListener("mouseup",k(v))},[d,k]),[D,P]=nt({bottom:null,left:null,right:null,top:null});return Nr(()=>{if(d){let{height:v,left:N,top:x,width:E}=d.elem.getBoundingClientRect(),S=vs(d.elem),L=10,I={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${L}px`,left:`${window.scrollX+N}px`,top:`${window.scrollY+x+v-L/2}px`,width:`${E}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${v}px`,left:`${window.scrollX+N+E-L/2}px`,top:`${window.scrollY+x}px`,width:`${L}px`}},w=r.current;f&&u&&w&&(R(f)?(I[f].left=`${window.scrollX+w.left}px`,I[f].top=`${window.scrollY+u.y/S}px`,I[f].height="3px",I[f].width=`${w.width}px`):(I[f].top=`${window.scrollY+w.top}px`,I[f].left=`${window.scrollX+u.x/S}px`,I[f].width="3px",I[f].height=`${w.height}px`),I[f].backgroundColor="#adf"),P(I)}else P({bottom:null,left:null,right:null,top:null})},[d,f,u]),fo("div",{ref:o,children:d!=null&&!p&&Z1(As.Fragment,{children:[fo("div",{className:`${l.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:M("right"),style:D.right||void 0}),fo("div",{className:`${l.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:M("bottom"),style:D.bottom||void 0})]})})}var Ds=()=>{let t=z1(3),[e]=Y1(),o=q1(),r,n;return t[0]!==e||t[1]!==o?(n=o?lh(fo(ah,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=n):n=t[2],r=n,r};import{c as gh}from"react/compiler-runtime";import{jsx as Lr,jsxs as Ch,Fragment as xh}from"react/jsx-runtime";import{useLexicalComposerContext as Us}from"@lexical/react/LexicalComposerContext";import{$getTableAndElementByKey as bh,$getTableColumnIndexFromTableCellNode as _h,$getTableRowIndexFromTableCellNode as Th,$insertTableColumn__EXPERIMENTAL as wh,$insertTableRow__EXPERIMENTAL as kh,$isTableCellNode as Eh,$isTableNode as $s,getTableElement as Nh,TableNode as Lh}from"@lexical/table";import{$findMatchingParent as Sh,mergeRegister as Rh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Ps,isHTMLElement as Ih}from"lexical";import{useEffect as Bs,useMemo as yh,useRef as Hs,useState as ho}from"react";import"react";import{createPortal as vh}from"react-dom";import{c as ph}from"react/compiler-runtime";import{useEffect as fh,useRef as hh}from"react";var ch="Expected a function",uh=Math.max,dh=Math.min;function mh(t,e,o){let r,n,i=0,l,s=!1,u=!1,c,d,a,p=!0;if(typeof t!="function")throw new TypeError(ch);e=e||0,typeof o=="object"&&(s=!!o.leading,u="maxWait"in o,c=u?uh(o.maxWait||0,e):c,p="trailing"in o?!!o.trailing:p);function m(g){let k=r,M=l;return r=l=void 0,i=g,d=t.apply(M,k),d}function f(g){return i=g,a=setTimeout(_,e),s?m(g):d}function h(g){let k=g-n,M=g-i,D=e-k;return u?dh(D,c-M):D}function C(g){let k=g-n,M=g-i;return n===void 0||k>=e||k<0||u&&M>=c}function _(){let g=Date.now();if(C(g))return R(g);a=setTimeout(_,h(g))}function R(g){return a=void 0,p&&r?m(g):(r=l=void 0,d)}function A(){a!==void 0&&clearTimeout(a),i=0,r=n=l=a=void 0}function b(){return a===void 0?d:R(Date.now())}function T(){let g=Date.now(),k=C(g);if(r=arguments,l=this,n=g,k){if(a===void 0)return f(n);if(u)return clearTimeout(a),a=setTimeout(_,e),m(n)}return a===void 0&&(a=setTimeout(_,e)),d}return T.cancel=A,T.flush=b,T}var Os=mh;function Fs(t,e,o){let r=ph(6),n=hh(null),i,l;r[0]!==t||r[1]!==o||r[2]!==e?(i=()=>(n.current=Os(t,e,{maxWait:o}),()=>{n.current?.cancel()}),l=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=i,r[4]=l):(i=r[3],l=r[4]),fh(i,l);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...c)=>{let d=c;n.current&&n.current(...d)},r[5]=s):s=r[5],s}var js=20;function Mh({anchorElem:t}){let[e]=Us(),o=j(),[r,n]=ho(!1),[i,l]=ho(!1),[s,u]=ho(!1),[c,d]=ho({}),a=Hs(new Set),p=Hs(null),m=Fs(C=>{let{isOutside:_,tableDOMNode:R}=Ah(C,o.editorConfig?.lexical);if(_){n(!1),l(!1);return}if(!R)return;p.current=R;let A=null,b=null,T=null;if(e.getEditorState().read(()=>{let L=Ps(R);if(Eh(L)){let I=Sh(L,w=>$s(w));if(!$s(I))return;if(T=Nh(I,e.getElementByKey(I.getKey())),T){let w=I.getChildrenSize(),F=I.getChildAtIndex(0)?.getChildrenSize(),$=Th(L),U=_h(L);$===w-1?A=L:U===F-1&&(b=L)}}},{editor:e}),!T)return;let g=T.parentElement;if(!g)return;let{bottom:k,height:M,left:D,right:P,width:v,y:N}=T.getBoundingClientRect(),x=!1;g&&g.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(x=g.scrollWidth>g.clientWidth);let{left:E,y:S}=t.getBoundingClientRect();A?(l(!1),n(!0),d({height:js,left:x&&g?g.offsetLeft:D-E,top:k-S+5,width:x&&g?g.offsetWidth:v})):b&&(l(!0),n(!1),d({height:M,left:P-E+5,top:N-S,width:js}))},50,250),f=yh(()=>new ResizeObserver(()=>{n(!1),l(!1)}),[]);Bs(()=>{if(s)return document.addEventListener("mousemove",m),()=>{n(!1),l(!1),document.removeEventListener("mousemove",m)}},[s,m]),Bs(()=>Rh(e.registerMutationListener(Lh,C=>{e.getEditorState().read(()=>{let _=!1;for(let[R,A]of C)switch(A){case"created":{a.current.add(R),_=!0;break}case"destroyed":{a.current.delete(R),_=!0;break}default:break}if(_){f.disconnect();for(let R of a.current){let{tableElement:A}=bh(R);f.observe(A)}u(a.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let h=C=>{e.update(()=>{p.current&&(Ps(p.current)?.selectEnd(),C?(kh(),n(!1)):(wh(),l(!1)))})};return e?.isEditable()?Ch(xh,{children:[r&&Lr("button",{"aria-label":"Add Row",className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...c},type:"button"}),i&&Lr("button",{"aria-label":"Add Column",className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...c},type:"button"})]}):null}function Ah(t,e){let o=t.target;if(Ih(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function Gs(t){let e=gh(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=Us();if(!n?.isEditable())return null;let i;return e[0]!==r?(i=vh(Lr(Mh,{anchorElem:r}),r),e[0]=r,e[1]=i):i=e[1],i}import{c as Dh}from"react/compiler-runtime";import{jsx as Sr,jsxs as Oh}from"react/jsx-runtime";import{useLexicalComposerContext as Fh}from"@lexical/react/LexicalComposerContext";import{TablePlugin as $h}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Ph,TableCellNode as Bh,TableNode as Hh,TableRowNode as jh}from"@lexical/table";import{mergeRegister as Uh}from"@lexical/utils";import{formatDrawerSlug as Gh,useEditDepth as Wh}from"@payloadcms/ui";import{$getSelection as Vh,$isRangeSelection as Kh,COMMAND_PRIORITY_EDITOR as Jh,createCommand as Xh}from"lexical";import{createContext as zh,use as Zh,useEffect as Yh,useMemo as qh,useState as Qh}from"react";import*as Ws from"react";var go=Xh("OPEN_EMBED_DRAWER_COMMAND"),Vs=zh({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function Ks({children:t}){let[e,o]=Qh({cellEditorConfig:null,cellEditorPlugins:null});return Sr(Vs,{value:qh(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Js=()=>{let t=Dh(16),[e]=Fh(),o=Zh(Vs),r=Wh(),{fieldProps:n,uuid:i}=j(),{schemaPath:l}=n,s="lexical-table-create-"+i,u;t[0]!==r||t[1]!==s?(u=Gh({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=u):u=t[2];let c=u,{toggleDrawer:d}=Ce(c,!0),a;t[3]!==e||t[4]!==d?(a=()=>{if(!e.hasNodes([Hh,jh,Bh]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return Uh(e.registerCommand(go,()=>{let h;return h=null,e.getEditorState().read(()=>{let C=Vh();Kh(C)&&(h=C)}),h&&d(),!0},Jh))},t[3]=e,t[4]=d,t[5]=a):a=t[5];let p;t[6]!==o||t[7]!==e||t[8]!==d?(p=[o,e,d],t[6]=o,t[7]=e,t[8]=d,t[9]=p):p=t[9],Yh(a,p);let m;t[10]!==e?(m=(h,C)=>{!C.columns||!C.rows||e.dispatchCommand(Ph,{columns:String(C.columns),rows:String(C.rows)})},t[10]=e,t[11]=m):m=t[11];let f;return t[12]!==c||t[13]!==l||t[14]!==m?(f=Oh(Ws.Fragment,{children:[Sr(lt,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:m,schemaPath:l,schemaPathSuffix:"fields"}),Sr($h,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=l,t[14]=m,t[15]=f):f=t[15],f};var rg=y({markdownTransformers:[_s],nodes:[tg,eg,og],plugins:[{Component:Js,position:"normal"},{Component:Ds,position:"normal"},{Component:Rs,position:"floatingAnchorElem"},{Component:Gs,position:"floatingAnchorElem"}],providers:[Ks],slashMenu:{groups:[Q([{Icon:fr,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(go,{})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:fr,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(go,{})}}])]}});import{$isNodeSelection as Dg}from"lexical";import{jsx as Rr,jsxs as ng}from"react/jsx-runtime";import"react";var Ir=()=>ng("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Rr("path",{d:"M14.6667 4H5.33333C4.59695 4 4 4.59695 4 5.33333V14.6667C4 15.403 4.59695 16 5.33333 16H14.6667C15.403 16 16 15.403 16 14.6667V5.33333C16 4.59695 15.403 4 14.6667 4Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),Rr("path",{d:"M7.99984 9.33366C8.73622 9.33366 9.33317 8.73671 9.33317 8.00033C9.33317 7.26395 8.73622 6.66699 7.99984 6.66699C7.26346 6.66699 6.6665 7.26395 6.6665 8.00033C6.6665 8.73671 7.26346 9.33366 7.99984 9.33366Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),Rr("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as cg}from"react/jsx-runtime";import Zs from"bson-objectid";import{$applyNodeReplacement as ug}from"lexical";import*as Ys from"react";import{jsx as ig}from"react/jsx-runtime";import{DecoratorBlockNode as lg}from"@lexical/react/LexicalDecoratorBlockNode.js";import Xs from"bson-objectid";import{$applyNodeReplacement as sg}from"lexical";import"react";function yr(t){return t.parentElement!=null&&t.parentElement.tagName==="LI"&&t.previousSibling===null&&t.getAttribute("aria-roledescription")==="checkbox"}function ag(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:zs({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||yr(e),null}var At=class extends lg{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:ag,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Xs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=zs({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return ig(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let e=document.createElement("img");return e.setAttribute("data-lexical-upload-id",String(this.__data?.value)),e.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function zs({data:t}){return t?.id||(t.id=new Xs.default().toHexString()),sg(new At({data:t}))}var dg=Ys.lazy(()=>import("./component-NNKG7K3O.js").then(t=>({default:t.UploadComponent})));function mg(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:Ge({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||yr(e),null}var Ie=class extends At{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:mg,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Zs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=Ge({data:o});return r.setFormat(e.format),r}decorate(){return cg(dg,{data:this.__data,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ge({data:t}){return t?.id||(t.id=new Zs.default().toHexString()),ug(new Ie({data:t}))}function vr(t){return t instanceof Ie}import{c as _g}from"react/compiler-runtime";import{jsx as Tg}from"react/jsx-runtime";import{useLexicalComposerContext as wg}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as kg,mergeRegister as Eg}from"@lexical/utils";import{useConfig as Ng}from"@payloadcms/ui";import{$getPreviousSelection as Lg,$getSelection as Sg,$isParagraphNode as Rg,$isRangeSelection as Ig,COMMAND_PRIORITY_EDITOR as yg,createCommand as vg}from"lexical";import{useEffect as Mg}from"react";import{c as qs}from"react/compiler-runtime";import{jsx as Mr}from"react/jsx-runtime";import{useLexicalComposerContext as Qs}from"@lexical/react/LexicalComposerContext.js";import{toast as pg}from"@payloadcms/ui";import{$getNodeByKey as fg,COMMAND_PRIORITY_EDITOR as ea}from"lexical";import{useEffect as ta,useState as hg}from"react";var gg=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=fg(o);n&&n.replace(Ge({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Ar,{fields:null,relationTo:e,value:r})},Cg=t=>{let e=qs(13),{enabledCollectionSlugs:o}=t,[r]=Qs(),[n,i]=hg(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let{closeListDrawer:s,ListDrawer:u,openListDrawer:c}=St(l),d,a;e[2]!==r||e[3]!==c?(d=()=>r.registerCommand(Ve,h=>(i(h?.replace?h?.replace.nodeKey:null),c(),!0),ea),a=[r,c],e[2]=r,e[3]=c,e[4]=d,e[5]=a):(d=e[4],a=e[5]),ta(d,a);let p;e[6]!==s||e[7]!==r||e[8]!==n?(p=h=>{let{collectionSlug:C,doc:_}=h;s(),gg({editor:r,relationTo:C,replaceNodeKey:n,value:_.id})},e[6]=s,e[7]=r,e[8]=n,e[9]=p):p=e[9];let m=p,f;return e[10]!==u||e[11]!==m?(f=Mr(u,{onSelect:m}),e[10]=u,e[11]=m,e[12]=f):f=e[12],f},xg=()=>{let t=qs(3),[e]=Qs(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Ve,bg,ea),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ta(o,r),null},oa=t=>Mr(Ot,{...t,FallbackComponent:xg,uploads:!0,children:Mr(Cg,{...t})});function bg(){return pg.error("No upload collections enabled"),!0}var Ar=vg("INSERT_UPLOAD_COMMAND"),ra=t=>{let e=_g(5),[o]=wg(),{config:r}=Ng(),{collections:n}=r,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([Ie]))throw new Error("UploadPlugin: UploadNode not registered on editor");return Eg(o.registerCommand(Ar,u=>(o.update(()=>{let c=Sg()||Lg();if(Ig(c)){let d=Ge({data:{id:u.id,fields:u.fields,relationTo:u.relationTo,value:u.value}});kg(d);let{focus:a}=c,p=a.getNode();Rg(p)&&!p.__first&&(p.__prev||p.__next)&&p.remove()}}),!0),yg))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),Mg(i,l);let s;return e[3]!==n?(s=Tg(oa,{enabledCollectionSlugs:n.map(Ag)}),e[3]=n,e[4]=s):s=e[4],s};function Ag(t){let{slug:e}=t;return e}var Og=y({nodes:[Ie],plugins:[{Component:ra,position:"normal"}],slashMenu:{groups:[Q([{Icon:Ir,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:Ir,isActive:({selection:t})=>{if(!Dg(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return vr(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]}});import{c as Fg}from"react/compiler-runtime";import{jsx as Or}from"react/jsx-runtime";import{ShimmerEffect as $g,useConfig as Pg}from"@payloadcms/ui";import{lazy as Bg,Suspense as Hg,useEffect as jg,useState as Ug}from"react";var na={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",hrSelected:"LexicalEditorTheme__hrSelected",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var Co={namespace:"lexical",theme:na};function ia({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:i}){for(let c of i.features)if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");i.features=i.features.sort((c,d)=>c.clientFeatureProps.order-d.clientFeatureProps.order);let l=new Map;for(let c of i.features)l.set(c.clientFeatureProps.featureKey,c);let s=new Map,u=0;for(let c of i.features){let d=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:l,field:r,resolvedFeatures:s,schemaPath:n,unSanitizedEditorConfig:i}):c.feature;d.key=c.clientFeatureProps.featureKey,d.order=u,s.set(c.clientFeatureProps.featureKey,d),u++}return s}var la=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}};if(!t?.size)return e;t.forEach(o=>{if(o.providers?.length&&(e.providers=e.providers.concat(o.providers)),o.enableFormats?.length&&e.enabledFormats.push(...o.enableFormats),o.nodes?.length)for(let r of o.nodes)e.nodes.push(r);if(o.plugins?.length&&o.plugins.forEach((r,n)=>{e.plugins?.push({clientProps:o.sanitizedClientFeatureProps,Component:r.Component,key:o.key+n,position:r.position})}),o.toolbarInline?.groups?.length)for(let r of o.toolbarInline.groups){let n=e.toolbarInline.groups.find(i=>i.key===r.key);n?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.toolbarInline?.groups.push(n)}if(o.toolbarFixed?.groups?.length)for(let r of o.toolbarFixed.groups){let n=e.toolbarFixed.groups.find(i=>i.key===r.key);n?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.toolbarFixed?.groups.push(n)}if(o.slashMenu?.groups){o.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(o.slashMenu.dynamicGroups));for(let r of o.slashMenu.groups){let n=e.slashMenu.groups.find(i=>i.key===r.key);n?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==r.key):n={...r,items:[]},r?.items?.length&&(n.items=n.items.concat(r.items)),e.slashMenu.groups.push(n)}}if(o.markdownTransformers?.length)for(let r of o.markdownTransformers)typeof r=="function"?e.markdownTransformers.push(r({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(r);e.enabledFeatures.push(o.key)}),e.toolbarInline.groups.sort((o,r)=>o.order&&r.order?o.order-r.order:o.order?-1:r.order?1:0),e.toolbarFixed.groups.sort((o,r)=>o.order&&r.order?o.order-r.order:o.order?-1:r.order?1:0);for(let o of e.toolbarInline.groups)o.items.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let o of e.toolbarFixed.groups)o.items.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);return e};function Dr(t,e,o){return{admin:o,features:la(t),lexical:e,resolvedFeatureMap:t}}var Gg=Bg(()=>import("./Field-MM5IRCU2.js").then(t=>({default:t.RichText}))),Wg=t=>{let e=Fg(16),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:i,field:l,lexicalEditorConfig:s,schemaPath:u}=t,c;e[0]!==o?(c=o===void 0?{}:o,e[0]=o,e[1]=c):c=e[1];let d=c,a=s===void 0?Co:s,{config:p}=Pg(),[m,f]=Ug(null),h,C;e[2]!==d||e[3]!==r||e[4]!==p||e[5]!==n||e[6]!==i||e[7]!==l||e[8]!==m||e[9]!==a||e[10]!==u?(h=()=>{if(m)return;let R=[];for(let[T,g]of Object.entries(r))g.clientFeatureProvider&&R.push(g.clientFeatureProvider(g.clientFeatureProps));let A=a||Co,b=ia({config:p,featureClientImportMap:n,featureClientSchemaMap:i,field:l,schemaPath:u??l.name,unSanitizedEditorConfig:{features:R,lexical:A}});f(Dr(b,A,d))},C=[a,d,m,r,n,i,l,p,u],e[2]=d,e[3]=r,e[4]=p,e[5]=n,e[6]=i,e[7]=l,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=C):(h=e[11],C=e[12]),jg(h,C);let _;return e[13]!==m||e[14]!==t?(_=Or(Hg,{fallback:Or($g,{height:"35vh"}),children:m&&Or(Gg,{...t,editorConfig:m})}),e[13]=m,e[14]=t,e[15]=_):_=e[15],_};function Vg(t){return t instanceof HTMLElement}function Kg(...t){return t.filter(Boolean).join(" ")}var xo=new WeakMap;function sa(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function bo(t,e){let o=xo.get(t);if(o===void 0){let r=new Set,n=l=>{o!==void 0&&(o.start=sa(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let u=sa(l);for(let c of r)u!==null&&c([u[0]-s[0],u[1]-s[1]],l)};t.addEventListener("touchstart",n),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:n,listeners:r,start:null},xo.set(t,o)}return o.listeners.add(e),()=>{Jg(t,e)}}function Jg(t,e){let o=xo.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(xo.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function Xg(t,e){return bo(t,(o,r)=>{let[n,i]=o;n<0&&-n>Math.abs(i)&&e(n,r)})}function zg(t,e){return bo(t,(o,r)=>{let[n,i]=o;n>0&&n>Math.abs(i)&&e(n,r)})}function Zg(t,e){return bo(t,(o,r)=>{let[n,i]=o;i<0&&-i>Math.abs(n)&&e(n,r)})}function Yg(t,e){return bo(t,(o,r)=>{let[n,i]=o;i>0&&i>Math.abs(n)&&e(n,r)})}import{c as qg}from"react/compiler-runtime";import{jsx as Qg}from"react/jsx-runtime";import"react";var eC=()=>{let t=qg(2),{EditButton:e}=xe(),o;return t[0]!==e?(o=e?Qg(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as tC}from"react/compiler-runtime";import{jsx as oC}from"react/jsx-runtime";import"react";var rC=()=>{let t=tC(2),{RemoveButton:e}=xe(),o;return t[0]!==e?(o=e?oC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as nC}from"react/compiler-runtime";import{jsx as iC}from"react/jsx-runtime";import"react";var lC=()=>{let t=nC(2),{Label:e}=xe(),o;return t[0]!==e?(o=e?iC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as sC}from"react/compiler-runtime";import{jsx as aC}from"react/jsx-runtime";import"react";var cC=t=>{let e=sC(3),{children:o}=t,{InlineBlockContainer:r}=xe(),n;return e[0]!==r||e[1]!==o?(n=r?aC(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as uC}from"react/compiler-runtime";import{jsx as dC}from"react/jsx-runtime";import"react";var mC=t=>{let e=uC(6),{children:o,editButton:r,Label:n,removeButton:i}=t,{BlockCollapsible:l}=Oe(),s;return e[0]!==l||e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==i?(s=l?dC(l,{editButton:r,Label:n,removeButton:i,children:o}):null,e[0]=l,e[1]=n,e[2]=o,e[3]=r,e[4]=i,e[5]=s):s=e[5],s};import{c as pC}from"react/compiler-runtime";import{jsx as fC}from"react/jsx-runtime";import"react";var hC=()=>{let t=pC(2),{EditButton:e}=Oe(),o;return t[0]!==e?(o=e?fC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as gC}from"react/compiler-runtime";import{jsx as CC}from"react/jsx-runtime";import"react";var xC=()=>{let t=gC(2),{RemoveButton:e}=Oe(),o;return t[0]!==e?(o=e?CC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as bC}from"qs-esm";var _C=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:i,collectionSlug:l,select:s})=>{let u=bC({depth:e??0,draft:o??!1,locale:r,select:s},{addQueryPrefix:!0});return await fetch(`${t}/${l}/${i}${u}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(d=>d.json())};export{Ct as $createAutoLinkNode,Vt as $createBlockNode,To as $createInlineBlockNode,Te as $createLinkNode,je as $createRelationshipNode,Ge as $createUploadNode,ke as $isAutoLinkNode,pt as $isBlockNode,wo as $isInlineBlockNode,Z as $isLinkNode,ir as $isRelationshipNode,vr as $isUploadNode,_a as AlignFeatureClient,we as AutoLinkNode,mC as BlockCollapsible,hC as BlockEditButton,be as BlockNode,xC as BlockRemoveButton,Na as BlockquoteFeatureClient,wc as BlocksFeatureClient,Vc as BoldFeatureClient,ae as CAN_USE_DOM,$m as ChecklistFeatureClient,Sp as DETAIL_TYPE_TO_DETAIL,kp as DOUBLE_LINE_BREAK,Bp as DebugJsxConverterFeatureClient,Ip as ELEMENT_FORMAT_TO_TYPE,Rp as ELEMENT_TYPE_TO_FORMAT,pa as ENABLE_SLASH_MENU_COMMAND,ca as EditorConfigProvider,lt as FieldsDrawer,Qf as FixedToolbarFeatureClient,Su as HeadingFeatureClient,Wu as HorizontalRuleFeatureClient,Ke as INSERT_BLOCK_COMMAND,Je as INSERT_INLINE_BLOCK_COMMAND,Tp as IS_ALL_FORMATTING,cd as IndentFeatureClient,cC as InlineBlockContainer,eC as InlineBlockEditButton,lC as InlineBlockLabel,_o as InlineBlockNode,rC as InlineBlockRemoveButton,Zc as InlineCodeFeatureClient,u1 as InlineToolbarFeatureClient,eu as ItalicFeatureClient,Np as LTR_REGEX,ip as LexicalPluginToLexicalFeatureClient,wm as LinkFeatureClient,ie as LinkNode,wp as NON_BREAKING_SPACE,O as NodeFormat,Vm as OrderedListFeatureClient,pp as ParagraphFeatureClient,da as Point,Ep as RTL_REGEX,fa as Rect,Nf as RelationshipFeatureClient,Ne as RelationshipNode,Wg as RichTextField,dp as SlateToLexicalFeatureClient,iu as StrikethroughFeatureClient,cu as SubscriptFeatureClient,pu as SuperscriptFeatureClient,yp as TEXT_MODE_TO_TYPE,Lp as TEXT_TYPE_TO_FORMAT,vp as TEXT_TYPE_TO_MODE,he as TOGGLE_LINK_COMMAND,rg as TableFeatureClient,Fc as TestRecorderFeatureClient,Rt as ToolbarButton,Ue as ToolbarDropdown,jc as TreeViewFeatureClient,xu as UnderlineFeatureClient,Qm as UnorderedListFeatureClient,Og as UploadFeatureClient,Ie as UploadNode,Yg as addSwipeDownListener,Xg as addSwipeLeftListener,zg as addSwipeRightListener,Zg as addSwipeUpListener,$o as createBlockNode,y as createClientFeature,Co as defaultEditorLexicalConfig,pr as getDOMRangeRect,ha as getEnabledNodes,_C as getRestPopulateFn,Xe as getSelectedNode,Vg as isHTMLElement,ma as isPoint,Kg as joinClasses,Dr as sanitizeClientEditorConfig,la as sanitizeClientFeatures,lo as setFloatingElemPosition,Qt as setFloatingElemPositionForLinkEditor,Q as slashMenuBasicGroupWithItems,_e as toolbarAddDropdownGroupWithItems,Bo as toolbarFeatureButtonsGroupWithItems,ee as toolbarFormatGroupWithItems,ne as toolbarTextDropdownGroupWithItems,Oe as useBlockComponentContext,j as useEditorConfigContext,xe as useInlineBlockComponentContext,ua as useLexicalDocumentDrawer,Ce as useLexicalDrawer,St as useLexicalListDrawer};
41
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAM5D,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CAyJ9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAqC,CAAA"}
1
+ {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAM5D,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CAiK9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAqC,CAAA"}
@@ -81,10 +81,17 @@ const RichTextComponent = props => {
81
81
  }, [isSmallWidthViewport]);
82
82
  const classes = [baseClass, 'field-type', className, showError && 'error', disabled && `${baseClass}--read-only`, editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport ? `${baseClass}--show-gutter` : null].filter(Boolean).join(' ');
83
83
  const pathWithEditDepth = `${path}.${editDepth}`;
84
- const handleChange = useCallback(editorState => {
84
+ const updateFieldValue = editorState => {
85
85
  const newState = editorState.toJSON();
86
86
  prevValueRef.current = newState;
87
87
  setValue(newState);
88
+ };
89
+ const handleChange = useCallback(editorState_0 => {
90
+ if (typeof window.requestIdleCallback === 'function') {
91
+ requestIdleCallback(() => updateFieldValue(editorState_0));
92
+ } else {
93
+ updateFieldValue(editorState_0);
94
+ }
88
95
  }, [setValue]);
89
96
  const styles = useMemo(() => mergeFieldStyles(field), [field]);
90
97
  const handleInitialValueChange = useEffectEvent(initialValue_0 => {
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","names":["FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","baseClass","RichTextComponent","props","editorConfig","field","name","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","handleChange","editorState","newState","toJSON","current","styles","handleInitialValueChange","JSON","stringify","Date","Object","is","_jsxs","style","_jsx","CustomComponent","Fallback","fallbackRender","onReset","composerKey","fieldProps","onChange","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n name,\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n const path = pathFromProps ?? name\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n path,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n },\n [setValue],\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary\n if (\n prevValueRef.current !== value &&\n JSON.stringify(prevValueRef.current) !== JSON.stringify(value)\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n {Description}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"mappings":"AAAA;;;AAIA,SACEA,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,cAAc,EACdC,QAAQ,QACH;AACP,SAASC,gBAAgB,QAAQ;AACjC,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACjE,SAASC,aAAa,QAAQ;AAK9B,OAAO;AAKP,SAASC,eAAe,QAAQ;AAEhC,MAAMC,SAAA,GAAY;AAElB,MAAMC,iBAAA,GAIDC,KAAA;EACH,MAAM;IACJC,YAAY;IACZC,KAAK;IACLA,KAAA,EAAO;MACLC,IAAI;MACJC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,QAAA,EAAUC;MAAiB,CAAE,GAAG,CAAC,CAAC;MACnEC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAA,EAAMC,aAAa;IACnBN,QAAA,EAAUO,yBAAyB;IACnCC;EAAQ,CACT,GAAGf,KAAA;EAEJ,MAAMgB,iBAAA,GAAoBF,yBAAA,IAA6BN,iBAAA;EACvD,MAAMI,IAAA,GAAOC,aAAA,IAAiBV,IAAA;EAE9B,MAAMc,SAAA,GAAY9B,YAAA;EAElB,MAAM+B,gBAAA,GAAmB1B,WAAA,CACvB,CAAC2B,KAAA,EAAOC,iBAAA;IACN,IAAI,OAAOL,QAAA,KAAa,YAAY;MAClC;MACA,OAAOA,QAAA,CAASI,KAAA,EAAO;QAAE,GAAGC,iBAAiB;QAAET;MAAS;IAC1D;IACA,OAAO;EACT;EACA;EACA;EACA;EACA,CAACI,QAAA,EAAUJ,QAAA,CAAS;EAGtB,MAAM;IACJU,gBAAA,EAAkB;MAAEC,UAAU;MAAEC,WAAW;MAAEC,WAAW;MAAEC,KAAK;MAAEC;IAAK,CAAE,GAAG,CAAC,CAAC;IAC7EC,QAAA,EAAUC,iBAAiB;IAC3BC,YAAY;IACZC,QAAQ;IACRC,SAAS;IACTZ,KAAK,EAALA;EAAK,CACN,GAAG9B,QAAA,CAAgC;IAClCuB,IAAA;IACAG,QAAA,EAAUG;EACZ;EAEA,MAAMS,QAAA,GAAWX,iBAAA,IAAqBY,iBAAA;EAEtC,MAAM,CAACI,oBAAA,EAAsBC,uBAAA,CAAwB,GAAGtC,QAAA,CAAkB;EAC1E,MAAM,CAACuC,mBAAA,EAAqBC,sBAAA,CAAuB,GAAGxC,QAAA;EAEtD,MAAMyC,mBAAA,GAAsB7C,KAAA,CAAM8C,MAAM,CAAoCR,YAAA;EAC5E,MAAMS,YAAA,GAAe/C,KAAA,CAAM8C,MAAM,CAAoClB,OAAA;EAErE1B,SAAA,CAAU;IACR,MAAM8C,mBAAA,GAAsBA,CAAA;MAC1B,MAAMC,wBAAA,GAA2BC,MAAA,CAAOC,UAAU,CAAC,sBAAsBC,OAAO;MAEhF,IAAIH,wBAAA,KAA6BR,oBAAA,EAAsB;QACrDC,uBAAA,CAAwBO,wBAAA;MAC1B;IACF;IACAD,mBAAA;IACAE,MAAA,CAAOG,gBAAgB,CAAC,UAAUL,mBAAA;IAElC,OAAO;MACLE,MAAA,CAAOI,mBAAmB,CAAC,UAAUN,mBAAA;IACvC;EACF,GAAG,CAACP,oBAAA,CAAqB;EAEzB,MAAMc,OAAA,GAAU,CACdhD,SAAA,EACA,cACAO,SAAA,EACA0B,SAAA,IAAa,SACbJ,QAAA,IAAY,GAAG7B,SAAA,aAAsB,EACrCG,YAAA,EAAcG,KAAA,EAAO2C,UAAA,KAAe,QAAQ,CAACf,oBAAA,GACzC,GAAGlC,SAAA,eAAwB,GAC3B,KACL,CACEkD,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;EAER,MAAMC,iBAAA,GAAoB,GAAGvC,IAAA,IAAQK,SAAA,EAAW;EAEhD,MAAMmC,YAAA,GAAe5D,WAAA,CAClB6D,WAAA;IACC,MAAMC,QAAA,GAAWD,WAAA,CAAYE,MAAM;IACnCjB,YAAA,CAAakB,OAAO,GAAGF,QAAA;IACvBxB,QAAA,CAASwB,QAAA;EACX,GACA,CAACxB,QAAA,CAAS;EAGZ,MAAM2B,MAAA,GAAS/D,OAAA,CAAQ,MAAMJ,gBAAA,CAAiBY,KAAA,GAAQ,CAACA,KAAA,CAAM;EAE7D,MAAMwD,wBAAA,GAA2BtE,cAAA,CAC9ByC,cAAA;IACC;IACA;IACA,IACES,YAAA,CAAakB,OAAO,KAAKrC,OAAA,IACzBwC,IAAA,CAAKC,SAAS,CAACtB,YAAA,CAAakB,OAAO,MAAMG,IAAA,CAAKC,SAAS,CAACzC,OAAA,GACxD;MACAiB,mBAAA,CAAoBoB,OAAO,GAAG3B,cAAA;MAC9BS,YAAA,CAAakB,OAAO,GAAGrC,OAAA;MACvBgB,sBAAA,CAAuB,IAAI0B,IAAA;IAC7B;EACF;EAGFpE,SAAA,CAAU;IACR;IACA;IACA;IACA;IACA,IAAI,CAACqE,MAAA,CAAOC,EAAE,CAAClC,YAAA,EAAcO,mBAAA,CAAoBoB,OAAO,GAAG;MACzDE,wBAAA,CAAyB7B,YAAA;IAC3B;EACF,GAAG,CAACA,YAAA,CAAa;EAEjB,oBACEmC,KAAA,CAAC;IAAI3D,SAAA,EAAWyC,OAAA;IAAiCmB,KAAA,EAAOR,MAAA;4BACtDS,IAAA,CAAChF,qBAAA;MACCiF,eAAA,EAAiB1C,KAAA;MACjB2C,QAAA,eAAUF,IAAA,CAAClF,UAAA;QAAW4B,IAAA,EAAMA,IAAA;QAAMmB,SAAA,EAAWA;;QAE9CL,KAAA,iBAASwC,IAAA,CAACjF,UAAA;MAAWwB,KAAA,EAAOA,KAAA;MAAOC,SAAA,EAAWA,SAAA;MAAWE,IAAA,EAAMA,IAAA;MAAMD,QAAA,EAAUA;qBAChFqD,KAAA,CAAC;MAAI3D,SAAA,EAAW,GAAGP,SAAA,QAAiB;8BAClCkE,KAAA,CAACpE,aAAA;QAAcyE,cAAA,EAAgBA,cAAA;QAAgBC,OAAA,EAASA,CAAA,MAAO;mBAC5D/C,WAAA,E,aACD2C,IAAA,CAACrE,eAAA;UACC0E,WAAA,EAAapB,iBAAA;UACblD,YAAA,EAAcA,YAAA;UACduE,UAAA,EAAYxE,KAAA;UACZgC,oBAAA,EAAsBA,oBAAA;UAEtByC,QAAA,EAAUrB,YAAA;UACV7C,QAAA,EAAUoB,QAAA;UACVR,KAAA,EAAOA;WAHFwC,IAAA,CAAKC,SAAS,CAAC;UAAEhD,IAAA;UAAMsB;QAAoB,KAKjDZ,UAAA;UAEFE,WAAA,E,aACD0C,IAAA,CAAChF,qBAAA;QACCiF,eAAA,EAAiB3C,WAAA;QACjB4C,QAAA,eAAUF,IAAA,CAACnF,gBAAA;UAAiBuB,WAAA,EAAaA,WAAA;UAAaM,IAAA,EAAMA;;;;KAxBpCuC,iBAAA;AA6BlC;AAEA,SAASkB,eAAe;EAAEK;AAAK,CAAoB;EACjD;EAEA,oBACEV,KAAA,CAAC;IAAI3D,SAAA,EAAU;IAAgBsE,IAAA,EAAK;4BAClCT,IAAA,CAAC;gBAAE;qBACHA,IAAA,CAAC;MAAID,KAAA,EAAO;QAAEW,KAAA,EAAO;MAAM;gBAAIF,KAAA,CAAMG;;;AAG3C;AAEA,OAAO,MAAMC,QAAA,GAAqC/E,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"Field.js","names":["FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","baseClass","RichTextComponent","props","editorConfig","field","name","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","updateFieldValue","editorState","newState","toJSON","current","handleChange","requestIdleCallback","styles","handleInitialValueChange","JSON","stringify","Date","Object","is","_jsxs","style","_jsx","CustomComponent","Fallback","fallbackRender","onReset","composerKey","fieldProps","onChange","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n name,\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n const path = pathFromProps ?? name\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n path,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const updateFieldValue = (editorState: EditorState) => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n if (typeof window.requestIdleCallback === 'function') {\n requestIdleCallback(() => updateFieldValue(editorState))\n } else {\n updateFieldValue(editorState)\n }\n },\n [setValue],\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary\n if (\n prevValueRef.current !== value &&\n JSON.stringify(prevValueRef.current) !== JSON.stringify(value)\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n {Description}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"mappings":"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","ignoreList":[]}