@payloadcms/richtext-lexical 3.14.1-canary.a85318b → 3.15.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.
- package/dist/exports/client/{Field-7ROJ5JAM.js → Field-C3BBYNYR.js} +2 -2
- package/dist/exports/client/{chunk-WCORQHZQ.js → chunk-PZPNMC5Y.js} +10 -10
- package/dist/exports/client/chunk-PZPNMC5Y.js.map +7 -0
- package/dist/exports/client/index.js +2 -2
- package/dist/exports/react/components/RichText/index.d.ts +4 -1
- package/dist/exports/react/components/RichText/index.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/index.js +14 -7
- package/dist/exports/react/components/RichText/index.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.js +12 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/chunk-WCORQHZQ.js.map +0 -7
- /package/dist/exports/client/{Field-7ROJ5JAM.js.map → Field-C3BBYNYR.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{a as ue,c as ro,d as no,e as io}from"./chunk-QNRPT52J.js";import{a as He,b as gt,c as Ct,d as xt}from"./chunk-AXXPUMFU.js";import{a as Ge,b as Ue,c as We,d as lo}from"./chunk-PGMIO4IN.js";import{a as je,b as bt,c as Me,d as Ve,e as Ke,f as so}from"./chunk-JSFV2MHZ.js";import{a as ce}from"./chunk-INBEEENE.js";import{a as ms}from"./chunk-F26IQ5RE.js";import{a as ds,b as mr,d as pr,e as fr,f as hr,g as ps,h as fs,i as hs,k as gs,m as Cs,n as xs}from"./chunk-
|
|
1
|
+
"use client";import{a as ue,c as ro,d as no,e as io}from"./chunk-QNRPT52J.js";import{a as He,b as gt,c as Ct,d as xt}from"./chunk-AXXPUMFU.js";import{a as Ge,b as Ue,c as We,d as lo}from"./chunk-PGMIO4IN.js";import{a as je,b as bt,c as Me,d as Ve,e as Ke,f as so}from"./chunk-JSFV2MHZ.js";import{a as ce}from"./chunk-INBEEENE.js";import{a as ms}from"./chunk-F26IQ5RE.js";import{a as ds,b as mr,d as pr,e as fr,f as hr,g as ps,h as fs,i as hs,k as gs,m as Cs,n as xs}from"./chunk-PZPNMC5Y.js";import{a as us,b as B}from"./chunk-CUIBIFW2.js";function Z(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{$isElementNode as _e,$isRangeSelection as Tt,FORMAT_ELEMENT_COMMAND as Et}from"lexical";import{jsx as ao,jsxs as bs}from"react/jsx-runtime";import"react";var gr=()=>bs("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:[ao("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),ao("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),ao("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as co,jsxs as _s}from"react/jsx-runtime";import"react";var Cr=()=>_s("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:[co("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),co("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),co("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as uo,jsxs as Ts}from"react/jsx-runtime";import"react";var _t=()=>Ts("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:[uo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),uo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),uo("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as mo,jsxs as Es}from"react/jsx-runtime";import"react";var xr=()=>Es("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:[mo("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),mo("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),mo("path",{d:"M7.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});var y=t=>o=>{let n={clientFeatureProps:o};if(typeof t=="function")n.feature=({featureClientSchemaMap:r,featureProviderMap:i,field:l,resolvedFeatures:s,schemaPath:a,unSanitizedEditorConfig:d})=>{let c=t({featureClientSchemaMap:r,featureProviderMap:i,field:l,props:o,resolvedFeatures:s,schemaPath:a,unSanitizedEditorConfig:d});return c.sanitizedClientFeatureProps===null&&(c.sanitizedClientFeatureProps=o),c};else{let r={...t};r.sanitizedClientFeatureProps=o,n.feature=r}return n};var br=t=>({type:"dropdown",ChildComponent:_t,items:t,key:"align",order:30});var _r=[br([{ChildComponent:_t,isActive:({selection:t})=>{if(!Tt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="left")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Et,"left")},order:1},{ChildComponent:gr,isActive:({selection:t})=>{if(!Tt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="center")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Et,"center")},order:2},{ChildComponent:xr,isActive:({selection:t})=>{if(!Tt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="right")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Et,"right")},order:3},{ChildComponent:Cr,isActive:({selection:t})=>{if(!Tt(t))return!1;for(let e of t.getNodes()){if(_e(e)&&e.getFormatType()==="justify")continue;let o=e.getParent();if(!(_e(o)&&o.getFormatType()==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(Et,"justify")},order:4}])],ws=y({toolbarFixed:{groups:_r},toolbarInline:{groups:_r}});import{$createQuoteNode as Rr,$isQuoteNode as Nr,QuoteNode as Rs}from"@lexical/rich-text";import{$setBlocksType as Ir}from"@lexical/selection";import{$getSelection as Sr,$isRangeSelection as Is}from"lexical";import{jsx as Tr}from"react/jsx-runtime";import"react";var po=()=>Tr("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:Tr("path",{d:"M13.5353 10.5725C13.5353 9.47709 11.0456 9.99991 11.0456 7.85883C11.0456 6.46464 12.1162 5.61816 13.361 5.61816C14.805 5.61816 16 6.86298 16 8.92937C16 11.2945 14.4564 13.7841 11.1203 14.3816L10.8216 13.1368C12.888 12.4895 13.5353 11.4937 13.5353 10.5725ZM6.71369 10.5725C6.71369 9.47709 4.22407 9.99991 4.22407 7.85883C4.22407 6.46464 5.29461 5.61816 6.53942 5.61816C7.9834 5.61816 9.17842 6.86298 9.17842 8.92937C9.17842 11.2945 7.63485 13.7841 4.29876 14.3816L4 13.1368C6.06639 12.4895 6.71369 11.4937 6.71369 10.5725Z",fill:"currentColor"})});import{jsx as Er}from"react/jsx-runtime";import"react";var ze=()=>Er("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Er("path",{d:"M11.708 14.5H7.79785V13.9414H8.01367C9.00391 13.9414 9.15625 13.9033 9.15625 13.6113V6.70508H8.07715C6.82031 6.70508 6.73145 7.08594 6.28711 8.67285H5.80469L5.91895 6.12109H13.5869L13.7012 8.67285H13.2188C12.7744 7.08594 12.6855 6.70508 11.4287 6.70508H10.3496V13.6113C10.3496 13.9033 10.502 13.9414 11.4922 13.9414H11.708V14.5Z",fill:"currentColor"})});var q=t=>({type:"dropdown",ChildComponent:ze,items:t,key:"text",order:25});import{$createQuoteNode as ks,$isQuoteNode as wr,QuoteNode as Ns}from"@lexical/rich-text";import{$createLineBreakNode as Ls}from"lexical";var kr={type:"element",dependencies:[Ns],export:(t,e)=>{if(!wr(t))return null;let o=e(t).split(`
|
|
2
2
|
`),n=[];for(let r of o)n.push("> "+r);return n.join(`
|
|
3
3
|
`)},regExp:/^>\s/,replace:(t,e,o,n)=>{if(n){let i=t.getPreviousSibling();if(wr(i)){i.splice(i.getChildrenSize(),0,[Ls(),...e]),i.select(0,0),t.remove();return}}let r=ks();r.append(...e),t.replace(r),r.select(0,0)}};var Lr=[q([{ChildComponent:po,isActive:({selection:t})=>{if(!Is(t))return!1;for(let e of t.getNodes())if(!Nr(e)&&!Nr(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Sr();Ir(e,()=>Rr())})},order:20}])],Ss=y({markdownTransformers:[kr],nodes:[Rs],slashMenu:{groups:[Z([{Icon:po,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=Sr();Ir(e,()=>Rr())})}}])]},toolbarFixed:{groups:Lr},toolbarInline:{groups:Lr}});import{getTranslation as St}from"@payloadcms/translations";import{jsx as fo,jsxs as ys}from"react/jsx-runtime";import"react";var wt=()=>ys("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:[fo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),fo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),fo("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as yr}from"react/jsx-runtime";import"react";var kt=()=>yr("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:yr("path",{clipRule:"evenodd",d:"M5.33333 6.5C5.11232 6.5 4.90036 6.5878 4.74408 6.74408C4.5878 6.90036 4.5 7.11232 4.5 7.33333V12.1667C4.5 12.3877 4.5878 12.5996 4.74408 12.7559C4.90036 12.9122 5.11232 13 5.33333 13H14.6667C14.8877 13 15.0996 12.9122 15.2559 12.7559C15.4122 12.5996 15.5 12.3877 15.5 12.1667V11.6667C15.5 11.3905 15.7239 11.1667 16 11.1667C16.2761 11.1667 16.5 11.3905 16.5 11.6667V12.1667C16.5 12.6529 16.3068 13.1192 15.963 13.463C15.6192 13.8068 15.1529 14 14.6667 14H5.33333C4.8471 14 4.38079 13.8068 4.03697 13.463C3.69315 13.1192 3.5 12.6529 3.5 12.1667V7.33333C3.5 6.8471 3.69315 6.38079 4.03697 6.03697C4.38079 5.69315 4.8471 5.5 5.33333 5.5H10.3333C10.6095 5.5 10.8333 5.72386 10.8333 6C10.8333 6.27614 10.6095 6.5 10.3333 6.5H5.33333ZM13 6.5C12.7239 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.7239 5.5 13 5.5H16C16.2761 5.5 16.5 5.72386 16.5 6V9C16.5 9.27614 16.2761 9.5 16 9.5C15.7239 9.5 15.5 9.27614 15.5 9V7.20711L13.3536 9.35355C13.1583 9.54882 12.8417 9.54882 12.6464 9.35355C12.4512 9.15829 12.4512 8.84171 12.6464 8.64645L14.7929 6.5H13ZM6.16699 8.33325C6.16699 8.05711 6.39085 7.83325 6.66699 7.83325H11.0003C11.2765 7.83325 11.5003 8.05711 11.5003 8.33325C11.5003 8.60939 11.2765 8.83325 11.0003 8.83325H6.66699C6.39085 8.83325 6.16699 8.60939 6.16699 8.33325ZM6.16699 10.9999C6.16699 10.7238 6.39085 10.4999 6.66699 10.4999H13.3337C13.6098 10.4999 13.8337 10.7238 13.8337 10.9999C13.8337 11.2761 13.6098 11.4999 13.3337 11.4999H6.66699C6.39085 11.4999 6.16699 11.2761 6.16699 10.9999Z",fill:"currentColor",fillRule:"evenodd"})});import{jsx as la}from"react/jsx-runtime";import sa from"bson-objectid";import"react";import{DecoratorBlockNode as vs}from"@lexical/react/LexicalDecoratorBlockNode.js";import Ms from"bson-objectid";var Ze=class extends vs{__fields;constructor({fields:e,format:o,key:n}){super(o,n),this.__fields=e}static clone(e){return new this({fields:e.__fields,format:e.__format,key:e.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=Ds(e.fields);return o.setFormat(e.format),o}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div"),o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(e){let o=this.getWritable();o.__fields=e}};function Ds(t){return new Ze({fields:{...t,id:t?.id||new Ms.default().toHexString()}})}import{jsx as X,jsxs as Lt,Fragment as Hs}from"react/jsx-runtime";import{Button as Ar,Collapsible as js,Drawer as Gs,EditDepthProvider as Us,ErrorPill as Ws,Form as Vs,formatDrawerSlug as Ks,FormSubmit as zs,Pill as Zs,RenderFields as Xs,SectionTitle as Ys,useDocumentInfo as Fr,useEditDepth as Js,useFormSubmitted as qs,useServerFunctions as Qs,useTranslation as ea}from"@payloadcms/ui";import{abortAndIgnore as ho}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as ta,reduceFieldsToValues as Or}from"payload/shared";import Xe,{useCallback as go,useEffect as $r,useMemo as Ye,useRef as oa}from"react";import{useLexicalComposerContext as ra}from"@lexical/react/LexicalComposerContext";import{getTranslation as na}from"@payloadcms/translations";import{$getNodeByKey as Co}from"lexical";import{v4 as ia}from"uuid";import{c as As}from"react/compiler-runtime";import{jsx as Nt,jsxs as Fs}from"react/jsx-runtime";import{RenderFields as Os,useFormSubmitted as $s}from"@payloadcms/ui";import Ps,{createContext as Bs}from"react";var vr=Bs({initialState:!1}),ke=()=>Ps.useContext(vr),Mr=t=>{let e=As(13),{BlockDrawer:o,Collapsible:n,CustomBlock:r,EditButton:i,errorCount:l,formSchema:s,initialState:a,nodeKey:d,RemoveButton:c}=t,m=$s()&&l>0,p,f;e[0]!==n||e[1]!==l||e[2]!==m?(f=E=>Nt(n,{editButton:E.editButton,errorCount:l,fieldHasErrors:m,Label:E.Label,removeButton:E.removeButton,children:E.children}),e[0]=n,e[1]=l,e[2]=m,e[3]=f):f=e[3],p=f;let h=p,g;return e[4]!==o||e[5]!==h||e[6]!==r||e[7]!==i||e[8]!==c||e[9]!==s||e[10]!==a||e[11]!==d?(g=r?Fs(vr.Provider,{value:{BlockCollapsible:h,EditButton:i,initialState:a,nodeKey:d,RemoveButton:c},children:[r,Nt(o,{})]}):Nt(h,{children:Nt(Os,{fields:s,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})}),e[4]=o,e[5]=h,e[6]=r,e[7]=i,e[8]=c,e[9]=s,e[10]=a,e[11]=d,e[12]=g):g=e[12],g};function Dr({fields:t}){for(let e in t){let o=t[e];Array.isArray(o.rows)&&"value"in o&&(o.disableFormData=!0)}return t}var re="lexical-block",Pr=t=>{let{formData:e,nodeKey:o}=t,n=qs(),{id:r,collectionSlug:i,globalSlug:l}=Fr(),{fieldProps:{featureClientSchemaMap:s,field:a,initialLexicalFormState:d,permissions:c,readOnly:u,schemaPath:m},uuid:p}=B(),f=oa(new AbortController),h=Js(),[g,E]=Xe.useState(0),v=Ks({slug:`lexical-blocks-create-${p}-${e.id}`,depth:h}),{toggleDrawer:D}=ce(v),{getDocPreferences:x,setDocFieldPreferences:k}=Fr(),[C]=ra(),{getFormState:T}=Qs(),L=`${m}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}.fields`,[w,N]=Xe.useState(d?.[e.id]?.formState?{...d?.[e.id]?.formState,blockName:{initialValue:e.blockName,passesCondition:!0,valid:!0,value:e.blockName}}:!1),[I,b]=Xe.useState(w?._components?.customComponents?.BlockLabel),[_,S]=Xe.useState(w?._components?.customComponents?.Block);$r(()=>{let j=new AbortController;return e&&!w&&(async()=>{let{state:K}=await T({id:r,collectionSlug:i,data:e,docPermissions:{fields:!0},docPreferences:await x(),globalSlug:l,operation:"update",renderAllFields:!0,schemaPath:L,signal:j.signal});K&&(K.blockName={initialValue:e.blockName,passesCondition:!0,valid:!0,value:e.blockName},N(K),b(K._components?.customComponents?.BlockLabel),S(K._components?.customComponents?.Block))})(),()=>{ho(j)}},[T,L,r,e,w,i,l,x]);let[R,A]=Xe.useState(d?.[e.id]?.collapsed??!1),M=`${m}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}`,$=s.blocks[M][0].blocks[0],{i18n:W,t:J}=ea(),U=go(async({formState:j,submit:te})=>{ho(f.current);let K=new AbortController;f.current=K;let{state:z}=await T({id:r,collectionSlug:i,docPermissions:{fields:!0},docPreferences:await x(),formState:j,globalSlug:l,operation:"update",renderAllFields:!!te,schemaPath:L,signal:K.signal});if(!z)return j;z.blockName=j.blockName;let oe=Or(Dr({fields:ta(z)}),!0);if(setTimeout(()=>{C.update(()=>{let be=Co(o);if(be&&Rt(be)){let we=oe;we.blockType=e.blockType,be.setFields(we)}})},0),te){b(z._components?.customComponents?.BlockLabel),S(z._components?.customComponents?.Block);let be=0;for(let we of Object.values(z))we?.valid===!1&&be++;E(be)}return z},[T,r,i,x,l,L,e.blockType,C,o]);$r(()=>()=>{ho(f.current)},[]);let H=go(()=>{C.update(()=>{Co(o)?.remove()})},[C,o]),ee=$?.labels?.singular?na($.labels.singular,W):$?.slug,pt=go(j=>{x().then(te=>{let z=te?.fields?.[a.name]?.collapsed,oe=z&&z?.length?z:[];j?oe.includes(e.id)||oe.push(e.id):oe.includes(e.id)&&oe.splice(oe.indexOf(e.id),1),k(a.name,{collapsed:oe,hello:"hi"})})},[x,a.name,k,e.id]),ie=Ye(()=>()=>X(Ar,{buttonStyle:"icon-label",className:`${re}__editButton`,disabled:u,el:"button",icon:"edit",onClick:j=>(j.preventDefault(),j.stopPropagation(),D(),!1),onMouseDown:j=>{j.preventDefault()},round:!0,size:"small",tooltip:J("lexical:blocks:inlineBlocks:edit",{label:ee})}),[ee,u,J,D]),ve=Ye(()=>()=>X(Ar,{buttonStyle:"icon-label",className:`${re}__removeButton`,disabled:a?.admin?.readOnly||!1,icon:"x",onClick:j=>{j.preventDefault(),H()},round:!0,tooltip:"Remove Block"}),[a?.admin?.readOnly,H]),ft=Ye(()=>({children:j,editButton:te,errorCount:K,fieldHasErrors:z,Label:oe,removeButton:be})=>X("div",{className:re+" "+re+"-"+e.blockType,children:X(js,{className:[`${re}__row`,z?`${re}__row--has-errors`:`${re}__row--no-errors`].join(" "),collapsibleStyle:z?"error":"default",header:Lt("div",{className:`${re}__block-header`,children:[oe??I?oe??I:Lt("div",{children:[X(Zs,{className:`${re}__block-pill ${re}__block-pill-${e?.blockType}`,pillStyle:"white",children:ee}),X(Ys,{path:"blockName",readOnly:a?.admin?.readOnly||!1}),z&&X(Ws,{count:K??0,i18n:W,withMessage:!0})]}),Lt("div",{children:[_&&te!==!1||!_&&te?X(ie,{}):null,be!==!1&&C.isEditable()?X(ve,{}):null]})]}),isCollapsed:R,onToggle:we=>{pt(we),A(we)},children:j},0)}),[_,I,ie,ve,ee,C,e.blockType,W,R,pt,a?.admin?.readOnly]),ht=Ye(()=>()=>X(Us,{children:X(Gs,{className:"",slug:v,title:J(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:ee??J("lexical:blocks:inlineBlocks:label")}),children:w?Lt(Hs,{children:[X(Xs,{fields:$.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:L,permissions:c,readOnly:!1}),X(zs,{programmaticSubmit:!0,children:J("fields:saveChanges")})]}):null})}),[w,v,ee,J,$.fields,L,c]);return Ye(()=>w?X(Vs,{beforeSubmit:[async({formState:j})=>await U({formState:j,submit:!0})],fields:$.fields,initialState:w,onChange:[U],onSubmit:j=>{let te=Or(j);te.blockType=e.blockType,C.update(()=>{let K=Co(o);K&&Rt(K)&&K.setFields(te)}),D()},submitted:n,uuid:ia(),children:X(Mr,{baseClass:re,BlockDrawer:ht,Collapsible:ft,CustomBlock:_,EditButton:ie,errorCount:g,formSchema:$.fields,initialState:w,nodeKey:o,RemoveButton:ve})}):null,[ft,ht,_,ve,ie,C,g,D,$.fields,w,o,U,n])};var de=class extends Ze{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){e.version===1&&(e={...e,fields:{...e.fields.data},version:2});let o=It(e.fields);return o.setFormat(e.format),o}decorate(e,o){return la(Pr,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function It(t){return new de({fields:{...t,id:t?.id||new sa.default().toHexString()}})}function Rt(t){return t instanceof de}import{createCommand as Br}from"lexical";var Je=Br("INSERT_BLOCK_COMMAND"),qe=Br("INSERT_INLINE_BLOCK_COMMAND");import{c as aa}from"react/compiler-runtime";import{useLexicalComposerContext as ca}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as ua,$wrapNodeInElement as da,mergeRegister as ma}from"@lexical/utils";import{formatDrawerSlug as pa,useEditDepth as fa}from"@payloadcms/ui";import{$createParagraphNode as ha,$getNodeByKey as ga,$getPreviousSelection as Ca,$getSelection as xa,$insertNodes as ba,$isParagraphNode as jr,$isRangeSelection as _a,$isRootOrShadowRoot as Ta,COMMAND_PRIORITY_EDITOR as Hr}from"lexical";import{useEffect as Ea,useState as wa}from"react";var Gr=()=>{let t=aa(10),[e]=ca(),[o,n]=wa(null),{uuid:r}=B(),i=fa(),l="lexical-inlineBlocks-create-"+r,s;t[0]!==i||t[1]!==l?(s=pa({slug:l,depth:i}),t[0]=i,t[1]=l,t[2]=s):s=t[2];let a=s,{toggleDrawer:d}=ce(a,!0),c;t[3]!==e||t[4]!==o?(c=()=>{if(!e.hasNodes([de]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return ma(e.registerCommand(Je,m=>(e.update(()=>{let p=xa()||Ca();if(_a(p)){let f=It(m);ua(f);let{focus:h}=p,g=h.getNode();jr(g)&&g.getTextContentSize()===0&&g.getParentOrThrow().getChildren().filter(ka).length>1&&g.remove()}}),!0),Hr),e.registerCommand(qe,m=>{if(o){let f=ga(o);return!f||!io(f)?!1:(f.setFields(m),n(null),!0)}let p=no(m);return ba([p]),Ta(p.getParentOrThrow())&&da(p,ha).selectEnd(),!0},Hr))},t[3]=e,t[4]=o,t[5]=c):c=t[5];let u;return t[6]!==e||t[7]!==o||t[8]!==d?(u=[e,o,d],t[6]=e,t[7]=o,t[8]=d,t[9]=u):u=t[9],Ea(c,u),null};function ka(t){return jr(t)}var Na=y(({featureClientSchemaMap:t,props:e,schemaPath:o})=>{let n=`${o}.lexical_internal_feature.blocks.lexical_blocks`,r=`${o}.lexical_internal_feature.blocks.lexical_inline_blocks`,i=t.blocks,l=Object.entries(i).filter(([c])=>c.startsWith(n+".")&&!c.replace(n+".","").includes(".")).map(([c,u])=>u[0]),s=Object.entries(i).filter(([c])=>c.startsWith(r+".")&&!c.replace(r+".","").includes(".")).map(([c,u])=>u[0]),a=l.map(c=>c.blocks[0]),d=s.map(c=>c.blocks[0]);return{nodes:[de,ro],plugins:[{Component:Gr,position:"normal"}],sanitizedClientFeatureProps:e,slashMenu:{groups:[a?.length?{items:a.map(c=>({Icon:wt,key:"block-"+c.slug,keywords:["block","blocks",c.slug],label:({i18n:u})=>c?.labels?.singular?St(c.labels.singular,u):c?.slug,onSelect:({editor:u})=>{u.dispatchCommand(Je,{blockName:"",blockType:c.slug})}})),key:"blocks",label:({i18n:c})=>c.t("lexical:blocks:label")}:null,d?.length?{items:d.map(c=>({Icon:kt,key:"inlineBlocks-"+c.slug,keywords:["inlineBlock","inline block",c.slug],label:({i18n:u})=>c?.labels?.singular?St(c.labels.singular,u):c?.slug,onSelect:({editor:u})=>{u.dispatchCommand(qe,{blockName:"",blockType:c.slug})}})),key:"inlineBlocks",label:({i18n:c})=>c.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[a.length?{type:"dropdown",ChildComponent:wt,items:a.map((c,u)=>({ChildComponent:wt,isActive:void 0,key:"block-"+c.slug,label:({i18n:m})=>c?.labels?.singular?St(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(Je,{blockName:"",blockType:c.slug})},order:u})),key:"blocks",order:20}:null,d?.length?{type:"dropdown",ChildComponent:kt,items:d.map((c,u)=>({ChildComponent:kt,isActive:void 0,key:"inlineBlock-"+c.slug,label:({i18n:m})=>c?.labels?.singular?St(c.labels.singular,m):c?.slug,onSelect:({editor:m})=>{m.dispatchCommand(qe,{blockName:"",blockType:c.slug})},order:u})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}});import{c as La}from"react/compiler-runtime";import{jsx as Le,jsxs as _o}from"react/jsx-runtime";import{useLexicalComposerContext as Ra}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Ia,$createTextNode as Sa,$getRoot as ya}from"lexical";import*as Kr from"react";import{useCallback as Ne,useEffect as xo,useLayoutEffect as Ur,useRef as bo,useState as yt}from"react";var va=t=>{let e=document.createElement("textarea");e.value=t||"",e.style.position="absolute",e.style.opacity="0",document.body?.appendChild(e),e.focus(),e.select();try{let o=document.execCommand("copy");console.log(o)}catch(o){console.error(o)}document.body?.removeChild(e)},Ma=(t,e)=>{let o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e||"")),o.setAttribute("download",t),o.style.display="none",document.body?.appendChild(o),o.click(),document.body?.removeChild(o)},Da=t=>{let o=((n,r)=>{switch(n){case"click":return` await page.mouse.click(${r.x}, ${r.y});`;case"keydown":return` await page.keyboard.keydown('${r}');`;case"keyup":return` await page.keyboard.keyup('${r}');`;case"press":return` await page.keyboard.press('${r}');`;case"selectAll":return" await selectAll(page);";case"snapshot":return` await assertHTMLSnapshot(page);
|
|
4
4
|
await assertSelection(page, {
|
|
@@ -36,7 +36,7 @@ ${e.map(Da).join(`
|
|
|
36
36
|
`),n=!1,r=[];for(let i=0;i<o.length;i++){let l=o[i],s=r[r.length-1];if(_p.test(l)){r.push(l);continue}if(xp.test(l)){n=!0,r.push(l);continue}if(bp.test(l)){n=!1,r.push(l);continue}if(n){r.push(l);continue}Cl.test(l)||Cl.test(s)||!s||xl.test(s)||xl.test(l)||Cp.test(l)||fp.test(l)||hp.test(l)||gp.test(l)||Tp.test(l)||Ep.test(l)||!e||bl.test(l)||_l.test(l)||bl.test(s)||_l.test(s)?r.push(l):r[r.length-1]=s+" "+l.trim()}return r.join(`
|
|
37
37
|
`)}function Tl(t,e=pr,o,n=!1,r=!0){let i=n?t:wp(t,r);return fr(i,e,o)}var kl=/^\|(.+)\|\s?$/,Mp=/^(\| ?:?-*:? ?)+\|\s?$/,Nl=({allTransformers:t})=>({type:"element",dependencies:[Ip,Sp,Rp],export:e=>{if(!Zo(e))return null;let o=[];for(let n of e.getChildren()){let r=[];if(!Xo(n))continue;let i=!1;for(let l of n.getChildren())El(l)&&(r.push(hr(t,l).replace(/\n/g,"\\n")),l.__headerState===Vt.ROW&&(i=!0));o.push(`| ${r.join(" | ")} |`),i&&o.push(`| ${r.map(l=>"---").join(" | ")} |`)}return o.join(`
|
|
38
38
|
`)},regExp:kl,replace:(e,o,n)=>{if(Mp.test(n[0])){let c=e.getPreviousSibling();if(!c||!Zo(c))return;let u=c.getChildren(),m=u[u.length-1];if(!m||!Xo(m))return;m.getChildren().forEach(p=>{El(p)&&p.setHeaderStyles(Vt.ROW,Vt.ROW)}),e.remove();return}let r=wl(n[0],t);if(r==null)return;let i=[r],l=e.getPreviousSibling(),s=r.length;for(;l&&!(!yp(l)||l.getChildrenSize()!==1);){let c=l.getFirstChild();if(!vp(c))break;let u=wl(c.getTextContent(),t);if(u==null)break;s=Math.max(s,u.length),i.unshift(u);let m=l.getPreviousSibling();l.remove(),l=m}let a=Np();for(let c of i){let u=Lp();a.append(u);for(let m=0;m<s;m++)u.append(m<c.length?c[m]:Ll("",t))}let d=e.getPreviousSibling();Zo(d)&&Dp(d)===s?(d.append(...a.getChildren()),e.remove()):e.replace(a),a.selectEnd()}});function Dp(t){let e=t.getFirstChild();return Xo(e)?e.getChildrenSize():0}var Ll=(t,e)=>{t=t.replace(/\\n/g,`
|
|
39
|
-
`);let o=kp(Vt.NO_STATUS);return Tl(t,e,o),o},wl=(t,e)=>{let o=t.match(kl);return!o||!o[1]?null:o[1].split("|").map(n=>Ll(n,e))};import{c as Fp}from"react/compiler-runtime";import{jsx as P,jsxs as xe}from"react/jsx-runtime";import{useLexicalComposerContext as yl}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Op}from"@lexical/react/useLexicalEditable";import{$deleteTableColumn__EXPERIMENTAL as $p,$deleteTableRow__EXPERIMENTAL as Pp,$getNodeTriplet as Bp,$getTableCellNodeFromLexicalNode as Hp,$getTableColumnIndexFromTableCellNode as jp,$getTableNodeFromLexicalNodeOrThrow as ut,$getTableRowIndexFromTableCellNode as Gp,$insertTableColumn__EXPERIMENTAL as Up,$insertTableRow__EXPERIMENTAL as Wp,$isTableCellNode as Kt,$isTableRowNode as Il,$isTableSelection as Zt,$unmergeCell as Vp,getTableObserverFromTableElement as Kp,TableCellHeaderStates as Ee,TableCellNode as zp}from"@lexical/table";import{useScrollInfo as Zp}from"@payloadcms/ui";import{$createParagraphNode as Xp,$getRoot as Yp,$getSelection as Xt,$isElementNode as Jp,$isParagraphNode as vl,$isRangeSelection as qo,$isTextNode as qp}from"lexical";import*as Qo from"react";import{useCallback as ae,useEffect as ye,useRef as zt,useState as Be}from"react";import{createPortal as Ml}from"react-dom";import{jsx as Yo,jsxs as Ap}from"react/jsx-runtime";import"react";var Rl=()=>Ap("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Yo("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"}),Yo("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"}),Yo("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 Jo(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function Qp(){let t=Xt();if(qo(t)&&!t.isCollapsed()||Zt(t)&&!t.anchor.is(t.focus)||!qo(t)&&!Zt(t))return!1;let[e]=Bp(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Sl(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!vl(e)||!e.isEmpty())}function ef(t){let e=t.getLastDescendant();qp(e)?e.select():Jp(e)?e.selectEnd():e!==null&&e.selectNext()}function tf({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:n,tableCellNode:r}){let[i]=yl(),l=zt(null),[s,a]=Be(r),[d,c]=Be({columns:1,rows:1}),[u,m]=Be(!1),[p,f]=Be(!1),{y:h}=Zp();ye(()=>i.registerMutationListener(zp,b=>{b.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{a(s.getLatest())})},{skipInitialization:!0}),[i,s]),ye(()=>{i.getEditorState().read(()=>{let b=Xt();if(Zt(b)){let _=Jo(b);c(Jo(b)),m(_.columns>1||_.rows>1)}f(Qp())})},[i]),ye(()=>{let b=e.current,_=l.current,S=i.getRootElement();if(b!=null&&_!=null&&S!=null){let R=S.getBoundingClientRect(),A=b.getBoundingClientRect();_.style.opacity="1";let M=_.getBoundingClientRect(),O=5,G=A.right+O;if(G+M.width>window.innerWidth||G+M.width>R.right){let W=A.left-M.width-O;G=(W<0?O:W)+window.pageXOffset}_.style.left=`${G+window.pageXOffset}px`;let $=A.top;if($+M.height>window.innerHeight){let W=A.bottom-M.height;$=(W<0?O:W)+window.pageYOffset}_.style.top=`${$}px`}},[e,l,i,h]),ye(()=>{function b(_){l.current!=null&&e.current!=null&&!l.current.contains(_.target)&&!e.current.contains(_.target)&&n(!1)}return window.addEventListener("click",b),()=>window.removeEventListener("click",b)},[n,e]);let g=ae(()=>{i.update(()=>{if(s.isAttached()){let _=ut(s),S=i.getElementByKey(_.getKey());if(!S)throw new Error("Expected to find tableElement in DOM");let R=Kp(S);R!==null&&R.clearHighlight(),_.markDirty(),a(s.getLatest())}Yp().selectStart()})},[i,s]),E=()=>{i.update(()=>{let b=Xt();if(Zt(b)){let{columns:_,rows:S}=Jo(b),R=b.getNodes(),A=null;for(let M=0;M<R.length;M++){let O=R[M];if(Kt(O))if(A===null){O.setColSpan(_).setRowSpan(S),A=O;let G=Sl(O),$;G&&vl($=O.getFirstChild())&&$.remove()}else Kt(A)&&(Sl(O)||A.append(...O.getChildren()),O.remove())}A!==null&&(A.getChildrenSize()===0&&A.append(Xp()),ef(A)),o()}})},v=()=>{i.update(()=>{Vp()})},D=ae(b=>{i.update(()=>{Wp(b),o()})},[i,o]),x=ae(b=>{i.update(()=>{for(let _=0;_<d.columns;_++)Up(b);o()})},[i,o,d.columns]),k=ae(()=>{i.update(()=>{Pp(),o()})},[i,o]),C=ae(()=>{i.update(()=>{ut(s).remove(),g(),o()})},[i,s,g,o]),T=ae(()=>{i.update(()=>{$p(),o()})},[i,o]),L=ae(()=>{i.update(()=>{let b=ut(s),_=Gp(s),S=b.getChildren();if(_>=S.length||_<0)throw new Error("Expected table cell to be inside of table row.");let R=S[_];if(!Il(R))throw new Error("Expected table row");let A=s.getHeaderStyles()^Ee.ROW;R.getChildren().forEach(M=>{if(!Kt(M))throw new Error("Expected table cell");M.setHeaderStyles(A,Ee.ROW)}),g(),o()})},[i,s,g,o]),w=ae(()=>{i.update(()=>{let b=ut(s),_=jp(s),S=b.getChildren(),R=Math.max(...S.map(M=>M.getChildren().length));if(_>=R||_<0)throw new Error("Expected table cell to be inside of table row.");let A=s.getHeaderStyles()^Ee.COLUMN;for(let M=0;M<S.length;M++){let O=S[M];if(!Il(O))throw new Error("Expected table row");let G=O.getChildren();if(_>=G.length)continue;let $=G[_];if(!Kt($))throw new Error("Expected table cell");$.setHeaderStyles(A,Ee.COLUMN)}g(),o()})},[i,s,g,o]),N=ae(()=>{i.update(()=>{if(s.isAttached()){let b=ut(s);b&&b.setRowStriping(!b.getRowStriping())}g(),o()})},[i,s,g,o]),I=null;return t&&(u?I=P("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>E(),type:"button",children:"Merge cells"}):p&&(I=P("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>v(),type:"button",children:"Unmerge cells"}))),Ml(xe("div",{className:"table-action-menu-dropdown",onClick:b=>{b.stopPropagation()},ref:l,children:[I?xe(Qo.Fragment,{children:[I,P("hr",{})]}):null,P("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>N(),type:"button",children:P("span",{className:"text",children:"Toggle Row Striping"})}),P("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>D(!1),type:"button",children:xe("span",{className:"text",children:["Insert ",d.rows===1?"row":`${d.rows} rows`," above"]})}),P("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>D(!0),type:"button",children:xe("span",{className:"text",children:["Insert ",d.rows===1?"row":`${d.rows} rows`," below"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>x(!1),type:"button",children:xe("span",{className:"text",children:["Insert ",d.columns===1?"column":`${d.columns} columns`," ","left"]})}),P("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>x(!0),type:"button",children:xe("span",{className:"text",children:["Insert ",d.columns===1?"column":`${d.columns} columns`," ","right"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>T(),type:"button",children:P("span",{className:"text",children:"Delete column"})}),P("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>k(),type:"button",children:P("span",{className:"text",children:"Delete row"})}),P("button",{className:"item","data-test-id":"table-delete",onClick:()=>C(),type:"button",children:P("span",{className:"text",children:"Delete table"})}),P("hr",{}),P("button",{className:"item",onClick:()=>L(),type:"button",children:xe("span",{className:"text",children:[(s.__headerState&Ee.ROW)===Ee.ROW?"Remove":"Add"," ","row header"]})}),P("button",{className:"item","data-test-id":"table-column-header",onClick:()=>w(),type:"button",children:xe("span",{className:"text",children:[(s.__headerState&Ee.COLUMN)===Ee.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function of({anchorElem:t,cellMerge:e}){let[o]=yl(),n=zt(null),r=zt(null),[i,l]=Be(!1),[s,a]=Be(null),d=ae(()=>{let u=n.current,m=Xt(),p=window.getSelection(),f=document.activeElement;if(m==null||u==null){a(null);return}let h=o.getRootElement();if(qo(m)&&h!==null&&p!==null&&h.contains(p.anchorNode)){let g=Hp(m.anchor.getNode());if(g==null){a(null);return}if(o.getElementByKey(g.getKey())==null){a(null);return}a(g)}else f||a(null)},[o]);ye(()=>o.registerUpdateListener(()=>{o.getEditorState().read(()=>{d()})})),ye(()=>{let u=n.current;if(u!=null&&s!=null){let m=o.getElementByKey(s.getKey());if(m!=null){let p=m.getBoundingClientRect(),f=u.getBoundingClientRect(),h=t.getBoundingClientRect(),g=p.top-h.top+4,E=p.right-f.width-10-h.left;u.style.opacity="1",u.style.transform=`translate(${E}px, ${g}px)`}else u.style.opacity="0",u.style.transform="translate(-10000px, -10000px)"}},[n,s,o,t]);let c=zt(s);return ye(()=>{c.current!==s&&l(!1),c.current=s},[c,s]),P("div",{className:"table-cell-action-button-container",ref:n,children:s!=null&&xe(Qo.Fragment,{children:[P("button",{className:"table-cell-action-button",onClick:u=>{u.stopPropagation(),l(!i)},ref:r,type:"button",children:P(Rl,{})}),i&&P(tf,{cellMerge:e,contextRef:r,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Dl=t=>{let e=Fp(3),{anchorElem:o}=t,n=Op(),r;return e[0]!==o||e[1]!==n?(r=Ml(n?P(of,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=n,e[2]=r):r=e[2],r};import{c as rf}from"react/compiler-runtime";import{jsx as Jt,jsxs as nf}from"react/jsx-runtime";import{useLexicalComposerContext as lf}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as sf}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as af,$getTableNodeFromLexicalNodeOrThrow as er,$getTableRowIndexFromTableCellNode as cf,$isTableCellNode as Al,$isTableRowNode as uf,getDOMCellFromTarget as df,TableNode as mf}from"@lexical/table";import{calculateZoomLevel as Fl}from"@lexical/utils";import{$getNearestNodeFromDOMNode as tr}from"lexical";import*as $l from"react";import{useCallback as dt,useEffect as or,useRef as Yt,useState as mt}from"react";import{createPortal as pf}from"react-dom";var ff=33,Ol=92;function hf({editor:t}){let e=Yt(null),o=Yt(null),n=Yt(null),r=B(),i=Yt(null),[l,s]=mt(null),[a,d]=mt(null),[c,u]=mt(!1),[m,p]=mt(null),f=dt(()=>{d(null),e.current=null,p(null),i.current=null,n.current=null},[]),h=w=>(w.buttons&1)===1;or(()=>t.registerNodeTransform(mf,w=>{if(w.getColWidths())return w;let N=w.getColumnCount(),I=Ol;return w.setColWidths(Array(N).fill(I)),w}),[t]),or(()=>{let w=_=>{setTimeout(()=>{let S=_.target;if(m){s({x:_.clientX,y:_.clientY});return}if(u(h(_)),!(o.current&&o.current.contains(S))&&e.current!==S){e.current=S;let R=df(S);R&&a!==R?t.update(()=>{let A=tr(R.elem);if(!A)throw new Error("TableCellResizer: Table cell node not found.");let M=er(A),O=t.getElementByKey(M.getKey());if(!O)throw new Error("TableCellResizer: Table element not found.");e.current=S,n.current=O.getBoundingClientRect(),d(R)}):R==null&&f()}},0)},N=_=>{setTimeout(()=>{u(!0)},0)},I=_=>{setTimeout(()=>{u(!1)},0)},b=t.registerRootListener((_,S)=>{S?.removeEventListener("mousemove",w),S?.removeEventListener("mousedown",N),S?.removeEventListener("mouseup",I),_?.addEventListener("mousemove",w),_?.addEventListener("mousedown",N),_?.addEventListener("mouseup",I)});return()=>{b()}},[a,m,t,f]);let g=w=>w==="bottom",E=dt(w=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=tr(a.elem);if(!Al(N))throw new Error("TableCellResizer: Table cell node not found.");let I=er(N),b=cf(N)+N.getRowSpan()-1,_=I.getChildren();if(b>=_.length||b<0)throw new Error("Expected table cell to be inside of table row.");let S=_[b];if(!uf(S))throw new Error("Expected table row");let R=S.getHeight();if(R===void 0){let M=S.getChildren();R=Math.min(...M.map(O=>v(O,t)??1/0))}let A=Math.max(R+w,ff);S.setHeight(A)},{tag:"skip-scroll-into-view"})},[a,t]),v=(w,N)=>N.getElementByKey(w.getKey())?.clientHeight,D=(w,N)=>{for(let I=0;I<N.length;I++)for(let b=0;b<N[I].length;b++)if(N[I][b].cell===w)return b},x=dt(w=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=tr(a.elem);if(!Al(N))throw new Error("TableCellResizer: Table cell node not found.");let I=er(N),[b]=af(I,null,null),_=D(N,b);if(_===void 0)throw new Error("TableCellResizer: Table column not found.");let S=I.getColWidths();if(!S)return;let R=S[_];if(R===void 0)return;let A=[...S],M=Math.max(R+w,Ol);A[_]=M,I.setColWidths(A)},{tag:"skip-scroll-into-view"})},[a,t]),k=dt(w=>{let N=I=>{if(I.preventDefault(),I.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:b,y:_}=i.current;if(a===null)return;let S=Fl(I.target);if(g(w)){let R=(I.clientY-_)/S;E(R)}else{let R=(I.clientX-b)/S;x(R)}f(),document.removeEventListener("mouseup",N)}};return N},[a,f,x,E]),C=dt(w=>N=>{if(N.preventDefault(),N.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");i.current={x:N.clientX,y:N.clientY},s(i.current),p(w),document.addEventListener("mouseup",k(w))},[a,k]),[T,L]=mt({bottom:null,left:null,right:null,top:null});return or(()=>{if(a){let{height:w,left:N,top:I,width:b}=a.elem.getBoundingClientRect(),_=Fl(a.elem),S=10,R={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${S}px`,left:`${window.scrollX+N}px`,top:`${window.scrollY+I+w-S/2}px`,width:`${b}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${w}px`,left:`${window.scrollX+N+b-S/2}px`,top:`${window.scrollY+I}px`,width:`${S}px`}},A=n.current;m&&l&&A&&(g(m)?(R[m].left=`${window.scrollX+A.left}px`,R[m].top=`${window.scrollY+l.y/_}px`,R[m].height="3px",R[m].width=`${A.width}px`):(R[m].top=`${window.scrollY+A.top}px`,R[m].left=`${window.scrollX+l.x/_}px`,R[m].width="3px",R[m].height=`${A.height}px`),R[m].backgroundColor="#adf"),L(R)}else L({bottom:null,left:null,right:null,top:null})},[a,m,l]),Jt("div",{ref:o,children:a!=null&&!c&&nf($l.Fragment,{children:[Jt("div",{className:`${r.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:C("right"),style:T.right||void 0}),Jt("div",{className:`${r.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:C("bottom"),style:T.bottom||void 0})]})})}var Pl=()=>{let t=rf(3),[e]=lf(),o=sf(),n,r;return t[0]!==e||t[1]!==o?(r=o?pf(Jt(hf,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=r):r=t[2],n=r,n};import{c as wf}from"react/compiler-runtime";import{jsx as rr,jsxs as kf,Fragment as Nf}from"react/jsx-runtime";import{useLexicalComposerContext as Kl}from"@lexical/react/LexicalComposerContext";import{$getTableColumnIndexFromTableCellNode as Lf,$getTableRowIndexFromTableCellNode as Rf,$insertTableColumn__EXPERIMENTAL as If,$insertTableRow__EXPERIMENTAL as Sf,$isTableCellNode as yf,$isTableNode as jl,TableNode as vf}from"@lexical/table";import{$findMatchingParent as Mf,mergeRegister as Df}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Gl}from"lexical";import{useEffect as Ul,useMemo as Af,useRef as Wl,useState as qt}from"react";import"react";import{createPortal as Ff}from"react-dom";import{c as _f}from"react/compiler-runtime";import{useEffect as Tf,useRef as Ef}from"react";var gf="Expected a function",Cf=Math.max,xf=Math.min;function bf(t,e,o){let n,r,i=0,l,s=!1,a=!1,d,c,u,m=!0;if(typeof t!="function")throw new TypeError(gf);e=e||0,typeof o=="object"&&(s=!!o.leading,a="maxWait"in o,d=a?Cf(o.maxWait||0,e):d,m="trailing"in o?!!o.trailing:m);function p(C){let T=n,L=l;return n=l=void 0,i=C,c=t.apply(L,T),c}function f(C){return i=C,u=setTimeout(E,e),s?p(C):c}function h(C){let T=C-r,L=C-i,w=e-T;return a?xf(w,d-L):w}function g(C){let T=C-r,L=C-i;return r===void 0||T>=e||T<0||a&&L>=d}function E(){let C=Date.now();if(g(C))return v(C);u=setTimeout(E,h(C))}function v(C){return u=void 0,m&&n?p(C):(n=l=void 0,c)}function D(){u!==void 0&&clearTimeout(u),i=0,n=r=l=u=void 0}function x(){return u===void 0?c:v(Date.now())}function k(){let C=Date.now(),T=g(C);if(n=arguments,l=this,r=C,T){if(u===void 0)return f(r);if(a)return clearTimeout(u),u=setTimeout(E,e),p(r)}return u===void 0&&(u=setTimeout(E,e)),c}return k.cancel=D,k.flush=x,k}var Bl=bf;function Hl(t,e,o){let n=_f(6),r=Ef(null),i,l;n[0]!==t||n[1]!==o||n[2]!==e?(i=()=>(r.current=Bl(t,e,{maxWait:o}),()=>{r.current?.cancel()}),l=[t,e,o],n[0]=t,n[1]=o,n[2]=e,n[3]=i,n[4]=l):(i=n[3],l=n[4]),Tf(i,l);let s;return n[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...d)=>{let c=d;r.current&&r.current(...c)},n[5]=s):s=n[5],s}var Vl=20;function Of({anchorElem:t}){let[e]=Kl(),o=B(),[n,r]=qt(!1),[i,l]=qt(!1),[s,a]=qt(!1),[d,c]=qt({}),u=Wl(new Set),m=Wl(null),p=Hl(g=>{let{isOutside:E,tableDOMNode:v}=$f(g,o.editorConfig?.lexical);if(E){r(!1),l(!1);return}if(!v)return;m.current=v;let D=null,x=null,k=null;if(e.update(()=>{let C=Gl(v);if(yf(C)){let T=Mf(C,L=>jl(L));if(!jl(T))return;if(k=e.getElementByKey(T?.getKey()),k){let L=T.getChildrenSize(),w=T.getChildAtIndex(0)?.getChildrenSize(),N=Rf(C),I=Lf(C);N===L-1?D=C:I===w-1&&(x=C)}}}),k){let{bottom:C,height:T,left:L,right:w,width:N,y:I}=k.getBoundingClientRect(),{left:b,y:_}=t.getBoundingClientRect();D?(l(!1),r(!0),c({height:Vl,left:L-b,top:C-_+5,width:N})):x&&(l(!0),r(!1),c({height:T,left:w-b+5,top:I-_,width:Vl}))}},50,250),f=Af(()=>new ResizeObserver(()=>{r(!1),l(!1)}),[]);Ul(()=>{if(s)return document.addEventListener("mousemove",p),()=>{r(!1),l(!1),document.removeEventListener("mousemove",p)}},[s,p]),Ul(()=>Df(e.registerMutationListener(vf,g=>{e.getEditorState().read(()=>{for(let[E,v]of g){let D=e.getElementByKey(E);switch(v){case"created":u.current.add(E),a(u.current.size>0),D&&f.observe(D);break;case"destroyed":u.current.delete(E),a(u.current.size>0),f.disconnect(),u.current.forEach(x=>{let k=e.getElementByKey(x);k&&f.observe(k)});break;default:break}}})},{skipInitialization:!1})),[e,f]);let h=g=>{e.update(()=>{m.current&&(Gl(m.current)?.selectEnd(),g?(Sf(),r(!1)):(If(),l(!1)))})};return e?.isEditable()?kf(Nf,{children:[n&&rr("button",{className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...d},type:"button"}),i&&rr("button",{className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...d},type:"button"})]}):null}function $f(t,e){let o=t.target;if(o&&o instanceof HTMLElement){let n=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(n||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:n}}else return{isOutside:!0,tableDOMNode:null}}function zl(t){let e=wf(2),{anchorElem:o}=t,n=o===void 0?document.body:o,[r]=Kl();if(!r?.isEditable())return null;let i;return e[0]!==n?(i=Ff(rr(Of,{anchorElem:n}),n),e[0]=n,e[1]=i):i=e[1],i}import{c as Pf}from"react/compiler-runtime";import{jsx as nr,jsxs as Bf}from"react/jsx-runtime";import{useLexicalComposerContext as Hf}from"@lexical/react/LexicalComposerContext";import{TablePlugin as jf}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Gf,TableNode as Uf}from"@lexical/table";import{mergeRegister as Wf}from"@lexical/utils";import{formatDrawerSlug as Vf,useEditDepth as Kf}from"@payloadcms/ui";import{$getSelection as zf,$isRangeSelection as Zf,COMMAND_PRIORITY_EDITOR as Xf,createCommand as Yf}from"lexical";import{createContext as Jf,useContext as qf,useEffect as Qf,useMemo as e1,useState as t1}from"react";import*as Zl from"react";var Qt=Yf("OPEN_EMBED_DRAWER_COMMAND"),Xl=Jf({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function Yl({children:t}){let[e,o]=t1({cellEditorConfig:null,cellEditorPlugins:null});return nr(Xl.Provider,{value:e1(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(n,r)=>{o({cellEditorConfig:n,cellEditorPlugins:r})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Jl=()=>{let t=Pf(16),[e]=Hf(),o=qf(Xl),n=Kf(),{fieldProps:r,uuid:i}=B(),{schemaPath:l}=r,s="lexical-table-create-"+i,a;t[0]!==n||t[1]!==s?(a=Vf({slug:s,depth:n}),t[0]=n,t[1]=s,t[2]=a):a=t[2];let d=a,{toggleDrawer:c}=ce(d,!0),u;t[3]!==e||t[4]!==c?(u=()=>{if(!e.hasNodes([Uf]))throw new Error("TablePlugin: TableNode is not registered on editor");return Wf(e.registerCommand(Qt,()=>{let h;return h=null,e.getEditorState().read(()=>{let g=zf();Zf(g)&&(h=g)}),h&&c(),!0},Xf))},t[3]=e,t[4]=c,t[5]=u):u=t[5];let m;t[6]!==o||t[7]!==e||t[8]!==c?(m=[o,e,c],t[6]=o,t[7]=e,t[8]=c,t[9]=m):m=t[9],Qf(u,m);let p;t[10]!==e?(p=(h,g)=>{!g.columns||!g.rows||e.dispatchCommand(Gf,{columns:String(g.columns),rows:String(g.rows)})},t[10]=e,t[11]=p):p=t[11];let f;return t[12]!==d||t[13]!==l||t[14]!==p?(f=Bf(Zl.Fragment,{children:[nr(je,{drawerSlug:d,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:l,schemaPathSuffix:"fields"}),nr(jf,{hasCellBackgroundColor:!1,hasCellMerge:!0})]}),t[12]=d,t[13]=l,t[14]=p,t[15]=f):f=t[15],f};var i1=y({markdownTransformers:[Nl],nodes:[r1,o1,n1],plugins:[{Component:Jl,position:"normal"},{Component:Pl,position:"normal"},{Component:Dl,position:"floatingAnchorElem"},{Component:zl,position:"floatingAnchorElem"}],providers:[Yl],slashMenu:{groups:[Z([{Icon:zo,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Qt,{})}}])]},toolbarFixed:{groups:[me([{ChildComponent:zo,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Qt,{})}}])]}});import{$isNodeSelection as I1}from"lexical";import{jsx as ir,jsxs as l1}from"react/jsx-runtime";import"react";var lr=()=>l1("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:[ir("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"}),ir("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"}),ir("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{c as f1}from"react/compiler-runtime";import{jsx as h1}from"react/jsx-runtime";import{useLexicalComposerContext as g1}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as C1,mergeRegister as x1}from"@lexical/utils";import{useConfig as b1}from"@payloadcms/ui";import{$getPreviousSelection as _1,$getSelection as T1,$isParagraphNode as E1,$isRangeSelection as w1,COMMAND_PRIORITY_EDITOR as k1,createCommand as N1}from"lexical";import{useEffect as L1}from"react";import{c as ql}from"react/compiler-runtime";import{jsx as sr}from"react/jsx-runtime";import{useLexicalComposerContext as Ql}from"@lexical/react/LexicalComposerContext.js";import{toast as s1}from"@payloadcms/ui";import{$getNodeByKey as a1,COMMAND_PRIORITY_EDITOR as es}from"lexical";import{useEffect as ts,useState as c1}from"react";var u1=({editor:t,relationTo:e,replaceNodeKey:o,value:n})=>{o?t.update(()=>{let r=a1(o);r&&r.replace(Ke({data:{fields:null,relationTo:e,value:n}}))}):t.dispatchCommand(ar,{fields:null,relationTo:e,value:n})},d1=t=>{let e=ql(13),{enabledCollectionSlugs:o}=t,[n]=Ql(),[r,i]=c1(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let{closeListDrawer:s,ListDrawer:a,openListDrawer:d}=lt(l),c,u;e[2]!==n||e[3]!==d?(c=()=>n.registerCommand(Me,h=>(i(h?.replace?h?.replace.nodeKey:null),d(),!0),es),u=[n,d],e[2]=n,e[3]=d,e[4]=c,e[5]=u):(c=e[4],u=e[5]),ts(c,u);let m;e[6]!==s||e[7]!==n||e[8]!==r?(m=h=>{let{collectionSlug:g,docID:E}=h;s(),u1({editor:n,relationTo:g,replaceNodeKey:r,value:E})},e[6]=s,e[7]=n,e[8]=r,e[9]=m):m=e[9];let p=m,f;return e[10]!==a||e[11]!==p?(f=sr(a,{onSelect:p}),e[10]=a,e[11]=p,e[12]=f):f=e[12],f},m1=()=>{let t=ql(3),[e]=Ql(),o,n;return t[0]!==e?(o=()=>e.registerCommand(Me,p1,es),n=[e],t[0]=e,t[1]=o,t[2]=n):(o=t[1],n=t[2]),ts(o,n),null},os=t=>sr(bt,{...t,FallbackComponent:m1,uploads:!0,children:sr(d1,{...t})});function p1(){return s1.error("No upload collections enabled"),!0}var ar=N1("INSERT_UPLOAD_COMMAND"),rs=t=>{let e=f1(5),[o]=g1(),{config:n}=b1(),{collections:r}=n,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([Ve]))throw new Error("UploadPlugin: UploadNode not registered on editor");return x1(o.registerCommand(ar,a=>(o.update(()=>{let d=T1()||_1();if(w1(d)){let c=Ke({data:{id:a.id,fields:a.fields,relationTo:a.relationTo,value:a.value}});C1(c);let{focus:u}=d,m=u.getNode();E1(m)&&!m.__first&&(m.__prev||m.__next)&&m.remove()}}),!0),k1))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),L1(i,l);let s;return e[3]!==r?(s=h1(os,{enabledCollectionSlugs:r.map(R1)}),e[3]=r,e[4]=s):s=e[4],s};function R1(t){let{slug:e}=t;return e}var S1=y({nodes:[Ve],plugins:[{Component:rs,position:"normal"}],slashMenu:{groups:[Z([{Icon:lr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Me,{replace:!1})}}])]},toolbarFixed:{groups:[me([{ChildComponent:lr,isActive:({selection:t})=>{if(!I1(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return so(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Me,{replace:!1})}}])]}});import{c as y1}from"react/compiler-runtime";import{jsx as ur}from"react/jsx-runtime";import{ShimmerEffect as v1}from"@payloadcms/ui";import{lazy as M1,Suspense as D1,useEffect as A1,useState as F1}from"react";var ns={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",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",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellEditing:"LexicalEditorTheme__tableCellEditing",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellPrimarySelected:"LexicalEditorTheme__tableCellPrimarySelected",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableCellSortedIndicator:"LexicalEditorTheme__tableCellSortedIndicator",tableResizeRuler:"LexicalEditorTheme__tableCellResizeRuler",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableSelected:"LexicalEditorTheme__tableSelected",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 eo={namespace:"lexical",theme:ns};function is({featureClientSchemaMap:t,field:e,schemaPath:o,unSanitizedEditorConfig:n}){for(let s of n.features)if(!s?.clientFeatureProps?.featureKey||s?.clientFeatureProps?.order===void 0||s?.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.");n.features=n.features.sort((s,a)=>s.clientFeatureProps.order-a.clientFeatureProps.order);let r=new Map;for(let s of n.features)r.set(s.clientFeatureProps.featureKey,s);let i=new Map,l=0;for(let s of n.features){let a=typeof s.feature=="function"?s.feature({featureClientSchemaMap:t,featureProviderMap:r,field:e,resolvedFeatures:i,schemaPath:o,unSanitizedEditorConfig:n}):s.feature;a.key=s.clientFeatureProps.featureKey,a.order=l,i.set(s.clientFeatureProps.featureKey,a),l++}return i}var ls=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 n of o.nodes)e.nodes.push(n);if(o.plugins?.length&&o.plugins.forEach((n,r)=>{e.plugins?.push({clientProps:o.sanitizedClientFeatureProps,Component:n.Component,key:o.key+r,position:n.position})}),o.toolbarInline?.groups?.length)for(let n of o.toolbarInline.groups){let r=e.toolbarInline.groups.find(i=>i.key===n.key);r?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.toolbarInline?.groups.push(r)}if(o.toolbarFixed?.groups?.length)for(let n of o.toolbarFixed.groups){let r=e.toolbarFixed.groups.find(i=>i.key===n.key);r?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.toolbarFixed?.groups.push(r)}if(o.slashMenu?.groups){o.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(o.slashMenu.dynamicGroups));for(let n of o.slashMenu.groups){let r=e.slashMenu.groups.find(i=>i.key===n.key);r?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.slashMenu.groups.push(r)}}if(o.markdownTransformers?.length)for(let n of o.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(o.key)}),e.toolbarInline.groups.sort((o,n)=>o.order&&n.order?o.order-n.order:o.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((o,n)=>o.order&&n.order?o.order-n.order:o.order?-1:n.order?1:0);for(let o of e.toolbarInline.groups)o.items.sort((n,r)=>n.order&&r.order?n.order-r.order:n.order?-1:r.order?1:0);for(let o of e.toolbarFixed.groups)o.items.sort((n,r)=>n.order&&r.order?n.order-r.order:n.order?-1:r.order?1:0);return e};function cr(t,e,o){return{admin:o,features:ls(t),lexical:e,resolvedFeatureMap:t}}var O1=M1(()=>import("./Field-7ROJ5JAM.js").then(t=>({default:t.RichText}))),$1=t=>{let e=y1(14),{admin:o,clientFeatures:n,featureClientSchemaMap:r,field:i,lexicalEditorConfig:l,schemaPath:s}=t,a;e[0]!==o?(a=o===void 0?{}:o,e[0]=o,e[1]=a):a=e[1];let d=a,c=l===void 0?eo:l,[u,m]=F1(null),p,f;e[2]!==d||e[3]!==n||e[4]!==r||e[5]!==i||e[6]!==u||e[7]!==c||e[8]!==s?(p=()=>{if(u)return;let g=[];for(let[D,x]of Object.entries(n))x.clientFeatureProvider&&g.push(x.clientFeatureProvider(x.clientFeatureProps));let E=c||eo,v=is({featureClientSchemaMap:r,field:i,schemaPath:s??i.name,unSanitizedEditorConfig:{features:g,lexical:E}});m(cr(v,E,d))},f=[c,d,u,n,r,i,s],e[2]=d,e[3]=n,e[4]=r,e[5]=i,e[6]=u,e[7]=c,e[8]=s,e[9]=p,e[10]=f):(p=e[9],f=e[10]),A1(p,f);let h;return e[11]!==u||e[12]!==t?(h=ur(D1,{fallback:ur(v1,{height:"35vh"}),children:u&&ur(O1,{...t,editorConfig:u})}),e[11]=u,e[12]=t,e[13]=h):h=e[13],h};function P1(...t){return t.filter(Boolean).join(" ")}var to=new WeakMap;function ss(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function oo(t,e){let o=to.get(t);if(o===void 0){let n=new Set,r=l=>{o!==void 0&&(o.start=ss(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let a=ss(l);for(let d of n)a!==null&&d([a[0]-s[0],a[1]-s[1]],l)};t.addEventListener("touchstart",r),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:r,listeners:n,start:null},to.set(t,o)}return o.listeners.add(e),()=>{B1(t,e)}}function B1(t,e){let o=to.get(t);if(o===void 0)return;let{listeners:n}=o;n.delete(e),n.size===0&&(to.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function H1(t,e){return oo(t,(o,n)=>{let[r,i]=o;r<0&&-r>Math.abs(i)&&e(r,n)})}function j1(t,e){return oo(t,(o,n)=>{let[r,i]=o;r>0&&r>Math.abs(i)&&e(r,n)})}function G1(t,e){return oo(t,(o,n)=>{let[r,i]=o;i<0&&-i>Math.abs(r)&&e(r,n)})}function U1(t,e){return oo(t,(o,n)=>{let[r,i]=o;i>0&&i>Math.abs(r)&&e(r,n)})}var F={DOM_ELEMENT_TYPE:1,DOM_TEXT_TYPE:3,NO_DIRTY_NODES:0,HAS_DIRTY_NODES:1,FULL_RECONCILE:2,IS_NORMAL:0,IS_TOKEN:1,IS_SEGMENTED:2,IS_INERT:3,IS_BOLD:1,IS_ITALIC:2,IS_STRIKETHROUGH:4,IS_UNDERLINE:8,IS_CODE:16,IS_SUBSCRIPT:32,IS_SUPERSCRIPT:64,IS_HIGHLIGHT:128,IS_DIRECTIONLESS:1,IS_UNMERGEABLE:2,IS_ALIGN_LEFT:1,IS_ALIGN_CENTER:2,IS_ALIGN_RIGHT:3,IS_ALIGN_JUSTIFY:4,IS_ALIGN_START:5,IS_ALIGN_END:6},W1=F.IS_BOLD|F.IS_ITALIC|F.IS_STRIKETHROUGH|F.IS_UNDERLINE|F.IS_CODE|F.IS_SUBSCRIPT|F.IS_SUPERSCRIPT|F.IS_HIGHLIGHT,V1="\xA0",K1=`
|
|
39
|
+
`);let o=kp(Vt.NO_STATUS);return Tl(t,e,o),o},wl=(t,e)=>{let o=t.match(kl);return!o||!o[1]?null:o[1].split("|").map(n=>Ll(n,e))};import{c as Fp}from"react/compiler-runtime";import{jsx as P,jsxs as xe}from"react/jsx-runtime";import{useLexicalComposerContext as yl}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Op}from"@lexical/react/useLexicalEditable";import{$deleteTableColumn__EXPERIMENTAL as $p,$deleteTableRow__EXPERIMENTAL as Pp,$getNodeTriplet as Bp,$getTableCellNodeFromLexicalNode as Hp,$getTableColumnIndexFromTableCellNode as jp,$getTableNodeFromLexicalNodeOrThrow as ut,$getTableRowIndexFromTableCellNode as Gp,$insertTableColumn__EXPERIMENTAL as Up,$insertTableRow__EXPERIMENTAL as Wp,$isTableCellNode as Kt,$isTableRowNode as Il,$isTableSelection as Zt,$unmergeCell as Vp,getTableObserverFromTableElement as Kp,TableCellHeaderStates as Ee,TableCellNode as zp}from"@lexical/table";import{useScrollInfo as Zp}from"@payloadcms/ui";import{$createParagraphNode as Xp,$getRoot as Yp,$getSelection as Xt,$isElementNode as Jp,$isParagraphNode as vl,$isRangeSelection as qo,$isTextNode as qp}from"lexical";import*as Qo from"react";import{useCallback as ae,useEffect as ye,useRef as zt,useState as Be}from"react";import{createPortal as Ml}from"react-dom";import{jsx as Yo,jsxs as Ap}from"react/jsx-runtime";import"react";var Rl=()=>Ap("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Yo("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"}),Yo("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"}),Yo("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 Jo(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function Qp(){let t=Xt();if(qo(t)&&!t.isCollapsed()||Zt(t)&&!t.anchor.is(t.focus)||!qo(t)&&!Zt(t))return!1;let[e]=Bp(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Sl(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!vl(e)||!e.isEmpty())}function ef(t){let e=t.getLastDescendant();qp(e)?e.select():Jp(e)?e.selectEnd():e!==null&&e.selectNext()}function tf({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:n,tableCellNode:r}){let[i]=yl(),l=zt(null),[s,a]=Be(r),[d,c]=Be({columns:1,rows:1}),[u,m]=Be(!1),[p,f]=Be(!1),{y:h}=Zp();ye(()=>i.registerMutationListener(zp,b=>{b.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{a(s.getLatest())})},{skipInitialization:!0}),[i,s]),ye(()=>{i.getEditorState().read(()=>{let b=Xt();if(Zt(b)){let _=Jo(b);c(Jo(b)),m(_.columns>1||_.rows>1)}f(Qp())})},[i]),ye(()=>{let b=e.current,_=l.current,S=i.getRootElement();if(b!=null&&_!=null&&S!=null){let R=S.getBoundingClientRect(),A=b.getBoundingClientRect();_.style.opacity="1";let M=_.getBoundingClientRect(),O=5,G=A.right+O;if(G+M.width>window.innerWidth||G+M.width>R.right){let W=A.left-M.width-O;G=(W<0?O:W)+window.pageXOffset}_.style.left=`${G+window.pageXOffset}px`;let $=A.top;if($+M.height>window.innerHeight){let W=A.bottom-M.height;$=(W<0?O:W)+window.pageYOffset}_.style.top=`${$}px`}},[e,l,i,h]),ye(()=>{function b(_){l.current!=null&&e.current!=null&&!l.current.contains(_.target)&&!e.current.contains(_.target)&&n(!1)}return window.addEventListener("click",b),()=>window.removeEventListener("click",b)},[n,e]);let g=ae(()=>{i.update(()=>{if(s.isAttached()){let _=ut(s),S=i.getElementByKey(_.getKey());if(!S)throw new Error("Expected to find tableElement in DOM");let R=Kp(S);R!==null&&R.clearHighlight(),_.markDirty(),a(s.getLatest())}Yp().selectStart()})},[i,s]),E=()=>{i.update(()=>{let b=Xt();if(Zt(b)){let{columns:_,rows:S}=Jo(b),R=b.getNodes(),A=null;for(let M=0;M<R.length;M++){let O=R[M];if(Kt(O))if(A===null){O.setColSpan(_).setRowSpan(S),A=O;let G=Sl(O),$;G&&vl($=O.getFirstChild())&&$.remove()}else Kt(A)&&(Sl(O)||A.append(...O.getChildren()),O.remove())}A!==null&&(A.getChildrenSize()===0&&A.append(Xp()),ef(A)),o()}})},v=()=>{i.update(()=>{Vp()})},D=ae(b=>{i.update(()=>{Wp(b),o()})},[i,o]),x=ae(b=>{i.update(()=>{for(let _=0;_<d.columns;_++)Up(b);o()})},[i,o,d.columns]),k=ae(()=>{i.update(()=>{Pp(),o()})},[i,o]),C=ae(()=>{i.update(()=>{ut(s).remove(),g(),o()})},[i,s,g,o]),T=ae(()=>{i.update(()=>{$p(),o()})},[i,o]),L=ae(()=>{i.update(()=>{let b=ut(s),_=Gp(s),S=b.getChildren();if(_>=S.length||_<0)throw new Error("Expected table cell to be inside of table row.");let R=S[_];if(!Il(R))throw new Error("Expected table row");let A=s.getHeaderStyles()^Ee.ROW;R.getChildren().forEach(M=>{if(!Kt(M))throw new Error("Expected table cell");M.setHeaderStyles(A,Ee.ROW)}),g(),o()})},[i,s,g,o]),w=ae(()=>{i.update(()=>{let b=ut(s),_=jp(s),S=b.getChildren(),R=Math.max(...S.map(M=>M.getChildren().length));if(_>=R||_<0)throw new Error("Expected table cell to be inside of table row.");let A=s.getHeaderStyles()^Ee.COLUMN;for(let M=0;M<S.length;M++){let O=S[M];if(!Il(O))throw new Error("Expected table row");let G=O.getChildren();if(_>=G.length)continue;let $=G[_];if(!Kt($))throw new Error("Expected table cell");$.setHeaderStyles(A,Ee.COLUMN)}g(),o()})},[i,s,g,o]),N=ae(()=>{i.update(()=>{if(s.isAttached()){let b=ut(s);b&&b.setRowStriping(!b.getRowStriping())}g(),o()})},[i,s,g,o]),I=null;return t&&(u?I=P("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>E(),type:"button",children:"Merge cells"}):p&&(I=P("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>v(),type:"button",children:"Unmerge cells"}))),Ml(xe("div",{className:"table-action-menu-dropdown",onClick:b=>{b.stopPropagation()},ref:l,children:[I?xe(Qo.Fragment,{children:[I,P("hr",{})]}):null,P("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>N(),type:"button",children:P("span",{className:"text",children:"Toggle Row Striping"})}),P("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>D(!1),type:"button",children:xe("span",{className:"text",children:["Insert ",d.rows===1?"row":`${d.rows} rows`," above"]})}),P("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>D(!0),type:"button",children:xe("span",{className:"text",children:["Insert ",d.rows===1?"row":`${d.rows} rows`," below"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>x(!1),type:"button",children:xe("span",{className:"text",children:["Insert ",d.columns===1?"column":`${d.columns} columns`," ","left"]})}),P("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>x(!0),type:"button",children:xe("span",{className:"text",children:["Insert ",d.columns===1?"column":`${d.columns} columns`," ","right"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>T(),type:"button",children:P("span",{className:"text",children:"Delete column"})}),P("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>k(),type:"button",children:P("span",{className:"text",children:"Delete row"})}),P("button",{className:"item","data-test-id":"table-delete",onClick:()=>C(),type:"button",children:P("span",{className:"text",children:"Delete table"})}),P("hr",{}),P("button",{className:"item",onClick:()=>L(),type:"button",children:xe("span",{className:"text",children:[(s.__headerState&Ee.ROW)===Ee.ROW?"Remove":"Add"," ","row header"]})}),P("button",{className:"item","data-test-id":"table-column-header",onClick:()=>w(),type:"button",children:xe("span",{className:"text",children:[(s.__headerState&Ee.COLUMN)===Ee.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function of({anchorElem:t,cellMerge:e}){let[o]=yl(),n=zt(null),r=zt(null),[i,l]=Be(!1),[s,a]=Be(null),d=ae(()=>{let u=n.current,m=Xt(),p=window.getSelection(),f=document.activeElement;if(m==null||u==null){a(null);return}let h=o.getRootElement();if(qo(m)&&h!==null&&p!==null&&h.contains(p.anchorNode)){let g=Hp(m.anchor.getNode());if(g==null){a(null);return}if(o.getElementByKey(g.getKey())==null){a(null);return}a(g)}else f||a(null)},[o]);ye(()=>o.registerUpdateListener(()=>{o.getEditorState().read(()=>{d()})})),ye(()=>{let u=n.current;if(u!=null&&s!=null){let m=o.getElementByKey(s.getKey());if(m!=null){let p=m.getBoundingClientRect(),f=u.getBoundingClientRect(),h=t.getBoundingClientRect(),g=p.top-h.top+4,E=p.right-f.width-10-h.left;u.style.opacity="1",u.style.transform=`translate(${E}px, ${g}px)`}else u.style.opacity="0",u.style.transform="translate(-10000px, -10000px)"}},[n,s,o,t]);let c=zt(s);return ye(()=>{c.current!==s&&l(!1),c.current=s},[c,s]),P("div",{className:"table-cell-action-button-container",ref:n,children:s!=null&&xe(Qo.Fragment,{children:[P("button",{className:"table-cell-action-button",onClick:u=>{u.stopPropagation(),l(!i)},ref:r,type:"button",children:P(Rl,{})}),i&&P(tf,{cellMerge:e,contextRef:r,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Dl=t=>{let e=Fp(3),{anchorElem:o}=t,n=Op(),r;return e[0]!==o||e[1]!==n?(r=Ml(n?P(of,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=n,e[2]=r):r=e[2],r};import{c as rf}from"react/compiler-runtime";import{jsx as Jt,jsxs as nf}from"react/jsx-runtime";import{useLexicalComposerContext as lf}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as sf}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as af,$getTableNodeFromLexicalNodeOrThrow as er,$getTableRowIndexFromTableCellNode as cf,$isTableCellNode as Al,$isTableRowNode as uf,getDOMCellFromTarget as df,TableNode as mf}from"@lexical/table";import{calculateZoomLevel as Fl}from"@lexical/utils";import{$getNearestNodeFromDOMNode as tr}from"lexical";import*as $l from"react";import{useCallback as dt,useEffect as or,useRef as Yt,useState as mt}from"react";import{createPortal as pf}from"react-dom";var ff=33,Ol=92;function hf({editor:t}){let e=Yt(null),o=Yt(null),n=Yt(null),r=B(),i=Yt(null),[l,s]=mt(null),[a,d]=mt(null),[c,u]=mt(!1),[m,p]=mt(null),f=dt(()=>{d(null),e.current=null,p(null),i.current=null,n.current=null},[]),h=w=>(w.buttons&1)===1;or(()=>t.registerNodeTransform(mf,w=>{if(w.getColWidths())return w;let N=w.getColumnCount(),I=Ol;return w.setColWidths(Array(N).fill(I)),w}),[t]),or(()=>{let w=_=>{setTimeout(()=>{let S=_.target;if(m){s({x:_.clientX,y:_.clientY});return}if(u(h(_)),!(o.current&&o.current.contains(S))&&e.current!==S){e.current=S;let R=df(S);R&&a!==R?t.update(()=>{let A=tr(R.elem);if(!A)throw new Error("TableCellResizer: Table cell node not found.");let M=er(A),O=t.getElementByKey(M.getKey());if(!O)throw new Error("TableCellResizer: Table element not found.");e.current=S,n.current=O.getBoundingClientRect(),d(R)}):R==null&&f()}},0)},N=_=>{setTimeout(()=>{u(!0)},0)},I=_=>{setTimeout(()=>{u(!1)},0)},b=t.registerRootListener((_,S)=>{S?.removeEventListener("mousemove",w),S?.removeEventListener("mousedown",N),S?.removeEventListener("mouseup",I),_?.addEventListener("mousemove",w),_?.addEventListener("mousedown",N),_?.addEventListener("mouseup",I)});return()=>{b()}},[a,m,t,f]);let g=w=>w==="bottom",E=dt(w=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=tr(a.elem);if(!Al(N))throw new Error("TableCellResizer: Table cell node not found.");let I=er(N),b=cf(N)+N.getRowSpan()-1,_=I.getChildren();if(b>=_.length||b<0)throw new Error("Expected table cell to be inside of table row.");let S=_[b];if(!uf(S))throw new Error("Expected table row");let R=S.getHeight();if(R===void 0){let M=S.getChildren();R=Math.min(...M.map(O=>v(O,t)??1/0))}let A=Math.max(R+w,ff);S.setHeight(A)},{tag:"skip-scroll-into-view"})},[a,t]),v=(w,N)=>N.getElementByKey(w.getKey())?.clientHeight,D=(w,N)=>{for(let I=0;I<N.length;I++)for(let b=0;b<N[I].length;b++)if(N[I][b].cell===w)return b},x=dt(w=>{if(!a)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=tr(a.elem);if(!Al(N))throw new Error("TableCellResizer: Table cell node not found.");let I=er(N),[b]=af(I,null,null),_=D(N,b);if(_===void 0)throw new Error("TableCellResizer: Table column not found.");let S=I.getColWidths();if(!S)return;let R=S[_];if(R===void 0)return;let A=[...S],M=Math.max(R+w,Ol);A[_]=M,I.setColWidths(A)},{tag:"skip-scroll-into-view"})},[a,t]),k=dt(w=>{let N=I=>{if(I.preventDefault(),I.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");if(i.current){let{x:b,y:_}=i.current;if(a===null)return;let S=Fl(I.target);if(g(w)){let R=(I.clientY-_)/S;E(R)}else{let R=(I.clientX-b)/S;x(R)}f(),document.removeEventListener("mouseup",N)}};return N},[a,f,x,E]),C=dt(w=>N=>{if(N.preventDefault(),N.stopPropagation(),!a)throw new Error("TableCellResizer: Expected active cell.");i.current={x:N.clientX,y:N.clientY},s(i.current),p(w),document.addEventListener("mouseup",k(w))},[a,k]),[T,L]=mt({bottom:null,left:null,right:null,top:null});return or(()=>{if(a){let{height:w,left:N,top:I,width:b}=a.elem.getBoundingClientRect(),_=Fl(a.elem),S=10,R={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${S}px`,left:`${window.scrollX+N}px`,top:`${window.scrollY+I+w-S/2}px`,width:`${b}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${w}px`,left:`${window.scrollX+N+b-S/2}px`,top:`${window.scrollY+I}px`,width:`${S}px`}},A=n.current;m&&l&&A&&(g(m)?(R[m].left=`${window.scrollX+A.left}px`,R[m].top=`${window.scrollY+l.y/_}px`,R[m].height="3px",R[m].width=`${A.width}px`):(R[m].top=`${window.scrollY+A.top}px`,R[m].left=`${window.scrollX+l.x/_}px`,R[m].width="3px",R[m].height=`${A.height}px`),R[m].backgroundColor="#adf"),L(R)}else L({bottom:null,left:null,right:null,top:null})},[a,m,l]),Jt("div",{ref:o,children:a!=null&&!c&&nf($l.Fragment,{children:[Jt("div",{className:`${r.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:C("right"),style:T.right||void 0}),Jt("div",{className:`${r.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:C("bottom"),style:T.bottom||void 0})]})})}var Pl=()=>{let t=rf(3),[e]=lf(),o=sf(),n,r;return t[0]!==e||t[1]!==o?(r=o?pf(Jt(hf,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=r):r=t[2],n=r,n};import{c as wf}from"react/compiler-runtime";import{jsx as rr,jsxs as kf,Fragment as Nf}from"react/jsx-runtime";import{useLexicalComposerContext as Kl}from"@lexical/react/LexicalComposerContext";import{$getTableColumnIndexFromTableCellNode as Lf,$getTableRowIndexFromTableCellNode as Rf,$insertTableColumn__EXPERIMENTAL as If,$insertTableRow__EXPERIMENTAL as Sf,$isTableCellNode as yf,$isTableNode as jl,TableNode as vf}from"@lexical/table";import{$findMatchingParent as Mf,mergeRegister as Df}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Gl}from"lexical";import{useEffect as Ul,useMemo as Af,useRef as Wl,useState as qt}from"react";import"react";import{createPortal as Ff}from"react-dom";import{c as _f}from"react/compiler-runtime";import{useEffect as Tf,useRef as Ef}from"react";var gf="Expected a function",Cf=Math.max,xf=Math.min;function bf(t,e,o){let n,r,i=0,l,s=!1,a=!1,d,c,u,m=!0;if(typeof t!="function")throw new TypeError(gf);e=e||0,typeof o=="object"&&(s=!!o.leading,a="maxWait"in o,d=a?Cf(o.maxWait||0,e):d,m="trailing"in o?!!o.trailing:m);function p(C){let T=n,L=l;return n=l=void 0,i=C,c=t.apply(L,T),c}function f(C){return i=C,u=setTimeout(E,e),s?p(C):c}function h(C){let T=C-r,L=C-i,w=e-T;return a?xf(w,d-L):w}function g(C){let T=C-r,L=C-i;return r===void 0||T>=e||T<0||a&&L>=d}function E(){let C=Date.now();if(g(C))return v(C);u=setTimeout(E,h(C))}function v(C){return u=void 0,m&&n?p(C):(n=l=void 0,c)}function D(){u!==void 0&&clearTimeout(u),i=0,n=r=l=u=void 0}function x(){return u===void 0?c:v(Date.now())}function k(){let C=Date.now(),T=g(C);if(n=arguments,l=this,r=C,T){if(u===void 0)return f(r);if(a)return clearTimeout(u),u=setTimeout(E,e),p(r)}return u===void 0&&(u=setTimeout(E,e)),c}return k.cancel=D,k.flush=x,k}var Bl=bf;function Hl(t,e,o){let n=_f(6),r=Ef(null),i,l;n[0]!==t||n[1]!==o||n[2]!==e?(i=()=>(r.current=Bl(t,e,{maxWait:o}),()=>{r.current?.cancel()}),l=[t,e,o],n[0]=t,n[1]=o,n[2]=e,n[3]=i,n[4]=l):(i=n[3],l=n[4]),Tf(i,l);let s;return n[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...d)=>{let c=d;r.current&&r.current(...c)},n[5]=s):s=n[5],s}var Vl=20;function Of({anchorElem:t}){let[e]=Kl(),o=B(),[n,r]=qt(!1),[i,l]=qt(!1),[s,a]=qt(!1),[d,c]=qt({}),u=Wl(new Set),m=Wl(null),p=Hl(g=>{let{isOutside:E,tableDOMNode:v}=$f(g,o.editorConfig?.lexical);if(E){r(!1),l(!1);return}if(!v)return;m.current=v;let D=null,x=null,k=null;if(e.update(()=>{let C=Gl(v);if(yf(C)){let T=Mf(C,L=>jl(L));if(!jl(T))return;if(k=e.getElementByKey(T?.getKey()),k){let L=T.getChildrenSize(),w=T.getChildAtIndex(0)?.getChildrenSize(),N=Rf(C),I=Lf(C);N===L-1?D=C:I===w-1&&(x=C)}}}),k){let{bottom:C,height:T,left:L,right:w,width:N,y:I}=k.getBoundingClientRect(),{left:b,y:_}=t.getBoundingClientRect();D?(l(!1),r(!0),c({height:Vl,left:L-b,top:C-_+5,width:N})):x&&(l(!0),r(!1),c({height:T,left:w-b+5,top:I-_,width:Vl}))}},50,250),f=Af(()=>new ResizeObserver(()=>{r(!1),l(!1)}),[]);Ul(()=>{if(s)return document.addEventListener("mousemove",p),()=>{r(!1),l(!1),document.removeEventListener("mousemove",p)}},[s,p]),Ul(()=>Df(e.registerMutationListener(vf,g=>{e.getEditorState().read(()=>{for(let[E,v]of g){let D=e.getElementByKey(E);switch(v){case"created":u.current.add(E),a(u.current.size>0),D&&f.observe(D);break;case"destroyed":u.current.delete(E),a(u.current.size>0),f.disconnect(),u.current.forEach(x=>{let k=e.getElementByKey(x);k&&f.observe(k)});break;default:break}}})},{skipInitialization:!1})),[e,f]);let h=g=>{e.update(()=>{m.current&&(Gl(m.current)?.selectEnd(),g?(Sf(),r(!1)):(If(),l(!1)))})};return e?.isEditable()?kf(Nf,{children:[n&&rr("button",{className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...d},type:"button"}),i&&rr("button",{className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...d},type:"button"})]}):null}function $f(t,e){let o=t.target;if(o&&o instanceof HTMLElement){let n=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(n||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:n}}else return{isOutside:!0,tableDOMNode:null}}function zl(t){let e=wf(2),{anchorElem:o}=t,n=o===void 0?document.body:o,[r]=Kl();if(!r?.isEditable())return null;let i;return e[0]!==n?(i=Ff(rr(Of,{anchorElem:n}),n),e[0]=n,e[1]=i):i=e[1],i}import{c as Pf}from"react/compiler-runtime";import{jsx as nr,jsxs as Bf}from"react/jsx-runtime";import{useLexicalComposerContext as Hf}from"@lexical/react/LexicalComposerContext";import{TablePlugin as jf}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Gf,TableNode as Uf}from"@lexical/table";import{mergeRegister as Wf}from"@lexical/utils";import{formatDrawerSlug as Vf,useEditDepth as Kf}from"@payloadcms/ui";import{$getSelection as zf,$isRangeSelection as Zf,COMMAND_PRIORITY_EDITOR as Xf,createCommand as Yf}from"lexical";import{createContext as Jf,useContext as qf,useEffect as Qf,useMemo as e1,useState as t1}from"react";import*as Zl from"react";var Qt=Yf("OPEN_EMBED_DRAWER_COMMAND"),Xl=Jf({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function Yl({children:t}){let[e,o]=t1({cellEditorConfig:null,cellEditorPlugins:null});return nr(Xl.Provider,{value:e1(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(n,r)=>{o({cellEditorConfig:n,cellEditorPlugins:r})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Jl=()=>{let t=Pf(16),[e]=Hf(),o=qf(Xl),n=Kf(),{fieldProps:r,uuid:i}=B(),{schemaPath:l}=r,s="lexical-table-create-"+i,a;t[0]!==n||t[1]!==s?(a=Vf({slug:s,depth:n}),t[0]=n,t[1]=s,t[2]=a):a=t[2];let d=a,{toggleDrawer:c}=ce(d,!0),u;t[3]!==e||t[4]!==c?(u=()=>{if(!e.hasNodes([Uf]))throw new Error("TablePlugin: TableNode is not registered on editor");return Wf(e.registerCommand(Qt,()=>{let h;return h=null,e.getEditorState().read(()=>{let g=zf();Zf(g)&&(h=g)}),h&&c(),!0},Xf))},t[3]=e,t[4]=c,t[5]=u):u=t[5];let m;t[6]!==o||t[7]!==e||t[8]!==c?(m=[o,e,c],t[6]=o,t[7]=e,t[8]=c,t[9]=m):m=t[9],Qf(u,m);let p;t[10]!==e?(p=(h,g)=>{!g.columns||!g.rows||e.dispatchCommand(Gf,{columns:String(g.columns),rows:String(g.rows)})},t[10]=e,t[11]=p):p=t[11];let f;return t[12]!==d||t[13]!==l||t[14]!==p?(f=Bf(Zl.Fragment,{children:[nr(je,{drawerSlug:d,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:l,schemaPathSuffix:"fields"}),nr(jf,{hasCellBackgroundColor:!1,hasCellMerge:!0})]}),t[12]=d,t[13]=l,t[14]=p,t[15]=f):f=t[15],f};var i1=y({markdownTransformers:[Nl],nodes:[r1,o1,n1],plugins:[{Component:Jl,position:"normal"},{Component:Pl,position:"normal"},{Component:Dl,position:"floatingAnchorElem"},{Component:zl,position:"floatingAnchorElem"}],providers:[Yl],slashMenu:{groups:[Z([{Icon:zo,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Qt,{})}}])]},toolbarFixed:{groups:[me([{ChildComponent:zo,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Qt,{})}}])]}});import{$isNodeSelection as I1}from"lexical";import{jsx as ir,jsxs as l1}from"react/jsx-runtime";import"react";var lr=()=>l1("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:[ir("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"}),ir("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"}),ir("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{c as f1}from"react/compiler-runtime";import{jsx as h1}from"react/jsx-runtime";import{useLexicalComposerContext as g1}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as C1,mergeRegister as x1}from"@lexical/utils";import{useConfig as b1}from"@payloadcms/ui";import{$getPreviousSelection as _1,$getSelection as T1,$isParagraphNode as E1,$isRangeSelection as w1,COMMAND_PRIORITY_EDITOR as k1,createCommand as N1}from"lexical";import{useEffect as L1}from"react";import{c as ql}from"react/compiler-runtime";import{jsx as sr}from"react/jsx-runtime";import{useLexicalComposerContext as Ql}from"@lexical/react/LexicalComposerContext.js";import{toast as s1}from"@payloadcms/ui";import{$getNodeByKey as a1,COMMAND_PRIORITY_EDITOR as es}from"lexical";import{useEffect as ts,useState as c1}from"react";var u1=({editor:t,relationTo:e,replaceNodeKey:o,value:n})=>{o?t.update(()=>{let r=a1(o);r&&r.replace(Ke({data:{fields:null,relationTo:e,value:n}}))}):t.dispatchCommand(ar,{fields:null,relationTo:e,value:n})},d1=t=>{let e=ql(13),{enabledCollectionSlugs:o}=t,[n]=Ql(),[r,i]=c1(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let{closeListDrawer:s,ListDrawer:a,openListDrawer:d}=lt(l),c,u;e[2]!==n||e[3]!==d?(c=()=>n.registerCommand(Me,h=>(i(h?.replace?h?.replace.nodeKey:null),d(),!0),es),u=[n,d],e[2]=n,e[3]=d,e[4]=c,e[5]=u):(c=e[4],u=e[5]),ts(c,u);let m;e[6]!==s||e[7]!==n||e[8]!==r?(m=h=>{let{collectionSlug:g,docID:E}=h;s(),u1({editor:n,relationTo:g,replaceNodeKey:r,value:E})},e[6]=s,e[7]=n,e[8]=r,e[9]=m):m=e[9];let p=m,f;return e[10]!==a||e[11]!==p?(f=sr(a,{onSelect:p}),e[10]=a,e[11]=p,e[12]=f):f=e[12],f},m1=()=>{let t=ql(3),[e]=Ql(),o,n;return t[0]!==e?(o=()=>e.registerCommand(Me,p1,es),n=[e],t[0]=e,t[1]=o,t[2]=n):(o=t[1],n=t[2]),ts(o,n),null},os=t=>sr(bt,{...t,FallbackComponent:m1,uploads:!0,children:sr(d1,{...t})});function p1(){return s1.error("No upload collections enabled"),!0}var ar=N1("INSERT_UPLOAD_COMMAND"),rs=t=>{let e=f1(5),[o]=g1(),{config:n}=b1(),{collections:r}=n,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([Ve]))throw new Error("UploadPlugin: UploadNode not registered on editor");return x1(o.registerCommand(ar,a=>(o.update(()=>{let d=T1()||_1();if(w1(d)){let c=Ke({data:{id:a.id,fields:a.fields,relationTo:a.relationTo,value:a.value}});C1(c);let{focus:u}=d,m=u.getNode();E1(m)&&!m.__first&&(m.__prev||m.__next)&&m.remove()}}),!0),k1))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),L1(i,l);let s;return e[3]!==r?(s=h1(os,{enabledCollectionSlugs:r.map(R1)}),e[3]=r,e[4]=s):s=e[4],s};function R1(t){let{slug:e}=t;return e}var S1=y({nodes:[Ve],plugins:[{Component:rs,position:"normal"}],slashMenu:{groups:[Z([{Icon:lr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Me,{replace:!1})}}])]},toolbarFixed:{groups:[me([{ChildComponent:lr,isActive:({selection:t})=>{if(!I1(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return so(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Me,{replace:!1})}}])]}});import{c as y1}from"react/compiler-runtime";import{jsx as ur}from"react/jsx-runtime";import{ShimmerEffect as v1}from"@payloadcms/ui";import{lazy as M1,Suspense as D1,useEffect as A1,useState as F1}from"react";var ns={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",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",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellEditing:"LexicalEditorTheme__tableCellEditing",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellPrimarySelected:"LexicalEditorTheme__tableCellPrimarySelected",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableCellSortedIndicator:"LexicalEditorTheme__tableCellSortedIndicator",tableResizeRuler:"LexicalEditorTheme__tableCellResizeRuler",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableSelected:"LexicalEditorTheme__tableSelected",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 eo={namespace:"lexical",theme:ns};function is({featureClientSchemaMap:t,field:e,schemaPath:o,unSanitizedEditorConfig:n}){for(let s of n.features)if(!s?.clientFeatureProps?.featureKey||s?.clientFeatureProps?.order===void 0||s?.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.");n.features=n.features.sort((s,a)=>s.clientFeatureProps.order-a.clientFeatureProps.order);let r=new Map;for(let s of n.features)r.set(s.clientFeatureProps.featureKey,s);let i=new Map,l=0;for(let s of n.features){let a=typeof s.feature=="function"?s.feature({featureClientSchemaMap:t,featureProviderMap:r,field:e,resolvedFeatures:i,schemaPath:o,unSanitizedEditorConfig:n}):s.feature;a.key=s.clientFeatureProps.featureKey,a.order=l,i.set(s.clientFeatureProps.featureKey,a),l++}return i}var ls=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 n of o.nodes)e.nodes.push(n);if(o.plugins?.length&&o.plugins.forEach((n,r)=>{e.plugins?.push({clientProps:o.sanitizedClientFeatureProps,Component:n.Component,key:o.key+r,position:n.position})}),o.toolbarInline?.groups?.length)for(let n of o.toolbarInline.groups){let r=e.toolbarInline.groups.find(i=>i.key===n.key);r?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.toolbarInline?.groups.push(r)}if(o.toolbarFixed?.groups?.length)for(let n of o.toolbarFixed.groups){let r=e.toolbarFixed.groups.find(i=>i.key===n.key);r?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.toolbarFixed?.groups.push(r)}if(o.slashMenu?.groups){o.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(o.slashMenu.dynamicGroups));for(let n of o.slashMenu.groups){let r=e.slashMenu.groups.find(i=>i.key===n.key);r?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.slashMenu.groups.push(r)}}if(o.markdownTransformers?.length)for(let n of o.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(o.key)}),e.toolbarInline.groups.sort((o,n)=>o.order&&n.order?o.order-n.order:o.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((o,n)=>o.order&&n.order?o.order-n.order:o.order?-1:n.order?1:0);for(let o of e.toolbarInline.groups)o.items.sort((n,r)=>n.order&&r.order?n.order-r.order:n.order?-1:r.order?1:0);for(let o of e.toolbarFixed.groups)o.items.sort((n,r)=>n.order&&r.order?n.order-r.order:n.order?-1:r.order?1:0);return e};function cr(t,e,o){return{admin:o,features:ls(t),lexical:e,resolvedFeatureMap:t}}var O1=M1(()=>import("./Field-C3BBYNYR.js").then(t=>({default:t.RichText}))),$1=t=>{let e=y1(14),{admin:o,clientFeatures:n,featureClientSchemaMap:r,field:i,lexicalEditorConfig:l,schemaPath:s}=t,a;e[0]!==o?(a=o===void 0?{}:o,e[0]=o,e[1]=a):a=e[1];let d=a,c=l===void 0?eo:l,[u,m]=F1(null),p,f;e[2]!==d||e[3]!==n||e[4]!==r||e[5]!==i||e[6]!==u||e[7]!==c||e[8]!==s?(p=()=>{if(u)return;let g=[];for(let[D,x]of Object.entries(n))x.clientFeatureProvider&&g.push(x.clientFeatureProvider(x.clientFeatureProps));let E=c||eo,v=is({featureClientSchemaMap:r,field:i,schemaPath:s??i.name,unSanitizedEditorConfig:{features:g,lexical:E}});m(cr(v,E,d))},f=[c,d,u,n,r,i,s],e[2]=d,e[3]=n,e[4]=r,e[5]=i,e[6]=u,e[7]=c,e[8]=s,e[9]=p,e[10]=f):(p=e[9],f=e[10]),A1(p,f);let h;return e[11]!==u||e[12]!==t?(h=ur(D1,{fallback:ur(v1,{height:"35vh"}),children:u&&ur(O1,{...t,editorConfig:u})}),e[11]=u,e[12]=t,e[13]=h):h=e[13],h};function P1(...t){return t.filter(Boolean).join(" ")}var to=new WeakMap;function ss(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function oo(t,e){let o=to.get(t);if(o===void 0){let n=new Set,r=l=>{o!==void 0&&(o.start=ss(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let a=ss(l);for(let d of n)a!==null&&d([a[0]-s[0],a[1]-s[1]],l)};t.addEventListener("touchstart",r),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:r,listeners:n,start:null},to.set(t,o)}return o.listeners.add(e),()=>{B1(t,e)}}function B1(t,e){let o=to.get(t);if(o===void 0)return;let{listeners:n}=o;n.delete(e),n.size===0&&(to.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function H1(t,e){return oo(t,(o,n)=>{let[r,i]=o;r<0&&-r>Math.abs(i)&&e(r,n)})}function j1(t,e){return oo(t,(o,n)=>{let[r,i]=o;r>0&&r>Math.abs(i)&&e(r,n)})}function G1(t,e){return oo(t,(o,n)=>{let[r,i]=o;i<0&&-i>Math.abs(r)&&e(r,n)})}function U1(t,e){return oo(t,(o,n)=>{let[r,i]=o;i>0&&i>Math.abs(r)&&e(r,n)})}var F={DOM_ELEMENT_TYPE:1,DOM_TEXT_TYPE:3,NO_DIRTY_NODES:0,HAS_DIRTY_NODES:1,FULL_RECONCILE:2,IS_NORMAL:0,IS_TOKEN:1,IS_SEGMENTED:2,IS_INERT:3,IS_BOLD:1,IS_ITALIC:2,IS_STRIKETHROUGH:4,IS_UNDERLINE:8,IS_CODE:16,IS_SUBSCRIPT:32,IS_SUPERSCRIPT:64,IS_HIGHLIGHT:128,IS_DIRECTIONLESS:1,IS_UNMERGEABLE:2,IS_ALIGN_LEFT:1,IS_ALIGN_CENTER:2,IS_ALIGN_RIGHT:3,IS_ALIGN_JUSTIFY:4,IS_ALIGN_START:5,IS_ALIGN_END:6},W1=F.IS_BOLD|F.IS_ITALIC|F.IS_STRIKETHROUGH|F.IS_UNDERLINE|F.IS_CODE|F.IS_SUBSCRIPT|F.IS_SUPERSCRIPT|F.IS_HIGHLIGHT,V1="\xA0",K1=`
|
|
40
40
|
|
|
41
41
|
`,as="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",cs="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",z1=new RegExp("^[^"+cs+"]*["+as+"]"),Z1=new RegExp("^[^"+as+"]*["+cs+"]"),X1={bold:F.IS_BOLD,code:F.IS_CODE,highlight:F.IS_HIGHLIGHT,italic:F.IS_ITALIC,strikethrough:F.IS_STRIKETHROUGH,subscript:F.IS_SUBSCRIPT,superscript:F.IS_SUPERSCRIPT,underline:F.IS_UNDERLINE},Y1={directionless:F.IS_DIRECTIONLESS,unmergeable:F.IS_UNMERGEABLE},J1={center:F.IS_ALIGN_CENTER,end:F.IS_ALIGN_END,justify:F.IS_ALIGN_JUSTIFY,left:F.IS_ALIGN_LEFT,right:F.IS_ALIGN_RIGHT,start:F.IS_ALIGN_START},q1={[F.IS_ALIGN_CENTER]:"center",[F.IS_ALIGN_END]:"end",[F.IS_ALIGN_JUSTIFY]:"justify",[F.IS_ALIGN_LEFT]:"left",[F.IS_ALIGN_RIGHT]:"right",[F.IS_ALIGN_START]:"start"},Q1={normal:F.IS_NORMAL,segmented:F.IS_SEGMENTED,token:F.IS_TOKEN},eh={[F.IS_NORMAL]:"normal",[F.IS_SEGMENTED]:"segmented",[F.IS_TOKEN]:"token"};import{c as th}from"react/compiler-runtime";import{jsx as oh}from"react/jsx-runtime";import"react";var rh=()=>{let t=th(2),{EditButton:e}=ue(),o;return t[0]!==e?(o=e?oh(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as nh}from"react/compiler-runtime";import{jsx as ih}from"react/jsx-runtime";import"react";var lh=()=>{let t=nh(2),{RemoveButton:e}=ue(),o;return t[0]!==e?(o=e?ih(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as sh}from"react/compiler-runtime";import{jsx as ah}from"react/jsx-runtime";import"react";var ch=()=>{let t=sh(2),{Label:e}=ue(),o;return t[0]!==e?(o=e?ah(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as uh}from"react/compiler-runtime";import{jsx as dh}from"react/jsx-runtime";import"react";var mh=t=>{let e=uh(3),{children:o}=t,{InlineBlockContainer:n}=ue(),r;return e[0]!==n||e[1]!==o?(r=n?dh(n,{children:o}):null,e[0]=n,e[1]=o,e[2]=r):r=e[2],r};import{c as ph}from"react/compiler-runtime";import{jsx as fh}from"react/jsx-runtime";import"react";var hh=t=>{let e=ph(6),{children:o,editButton:n,Label:r,removeButton:i}=t,{BlockCollapsible:l}=ke(),s;return e[0]!==l||e[1]!==r||e[2]!==o||e[3]!==n||e[4]!==i?(s=l?fh(l,{editButton:n,Label:r,removeButton:i,children:o}):null,e[0]=l,e[1]=r,e[2]=o,e[3]=n,e[4]=i,e[5]=s):s=e[5],s};import{c as gh}from"react/compiler-runtime";import{jsx as Ch}from"react/jsx-runtime";import"react";var xh=()=>{let t=gh(2),{EditButton:e}=ke(),o;return t[0]!==e?(o=e?Ch(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as bh}from"react/compiler-runtime";import{jsx as _h}from"react/jsx-runtime";import"react";var Th=()=>{let t=bh(2),{RemoveButton:e}=ke(),o;return t[0]!==e?(o=e?_h(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};export{Qe as $createAutoLinkNode,It as $createBlockNode,no as $createInlineBlockNode,pe as $createLinkNode,We as $createRelationshipNode,Ke as $createUploadNode,he as $isAutoLinkNode,Rt as $isBlockNode,io as $isInlineBlockNode,V as $isLinkNode,lo as $isRelationshipNode,so as $isUploadNode,ws as AlignFeatureClient,fe as AutoLinkNode,hh as BlockCollapsible,xh as BlockEditButton,de as BlockNode,Th as BlockRemoveButton,Ss as BlockquoteFeatureClient,Na as BlocksFeatureClient,Ka as BoldFeatureClient,ds as CAN_USE_DOM,bd as ChecklistFeatureClient,Y1 as DETAIL_TYPE_TO_DETAIL,K1 as DOUBLE_LINE_BREAK,q1 as ELEMENT_FORMAT_TO_TYPE,J1 as ELEMENT_TYPE_TO_FORMAT,gs as ENABLE_SLASH_MENU_COMMAND,us as EditorConfigProvider,je as FieldsDrawer,op as FixedToolbarFeatureClient,Ic as HeadingFeatureClient,Bc as HorizontalRuleFeatureClient,W1 as IS_ALL_FORMATTING,Vc as IndentFeatureClient,mh as InlineBlockContainer,rh as InlineBlockEditButton,ch as InlineBlockLabel,ro as InlineBlockNode,lh as InlineBlockRemoveButton,Ja as InlineCodeFeatureClient,pp as InlineToolbarFeatureClient,tc as ItalicFeatureClient,Z1 as LTR_REGEX,jd as LexicalPluginToLexicalFeatureClient,nd as LinkFeatureClient,Q as LinkNode,V1 as NON_BREAKING_SPACE,F as NodeFormat,Rd as OrderedListFeatureClient,Xd as ParagraphFeatureClient,fs as Point,z1 as RTL_REGEX,Cs as Rect,Sm as RelationshipFeatureClient,Ue as RelationshipNode,$1 as RichTextField,zd as SlateToLexicalFeatureClient,lc as StrikethroughFeatureClient,uc as SubscriptFeatureClient,fc as SuperscriptFeatureClient,Q1 as TEXT_MODE_TO_TYPE,X1 as TEXT_TYPE_TO_FORMAT,eh as TEXT_TYPE_TO_MODE,le as TOGGLE_LINK_COMMAND,i1 as TableFeatureClient,$a as TestRecorderFeatureClient,st as ToolbarButton,Se as ToolbarDropdown,Ga as TreeViewFeatureClient,bc as UnderlineFeatureClient,Fd as UnorderedListFeatureClient,S1 as UploadFeatureClient,Ve as UploadNode,U1 as addSwipeDownListener,H1 as addSwipeLeftListener,j1 as addSwipeRightListener,G1 as addSwipeUpListener,To as createBlockNode,y as createClientFeature,eo as defaultEditorLexicalConfig,Ko as getDOMRangeRect,xs as getEnabledNodes,De as getSelectedNode,ps as isHTMLElement,hs as isPoint,P1 as joinClasses,cr as sanitizeClientEditorConfig,ls as sanitizeClientFeatures,Gt as setFloatingElemPosition,Ft as setFloatingElemPositionForLinkEditor,Z as slashMenuBasicGroupWithItems,me as toolbarAddDropdownGroupWithItems,wo as toolbarFeatureButtonsGroupWithItems,Y as toolbarFormatGroupWithItems,q as toolbarTextDropdownGroupWithItems,ke as useBlockComponentContext,B as useEditorConfigContext,ue as useInlineBlockComponentContext,ms as useLexicalDocumentDrawer,ce as useLexicalDrawer,lt as useLexicalListDrawer};
|
|
42
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -8,7 +8,6 @@ export type JSXConvertersFunction<T extends {
|
|
|
8
8
|
type?: string;
|
|
9
9
|
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
10
10
|
blockName?: null | string;
|
|
11
|
-
blockType: string;
|
|
12
11
|
}> | SerializedInlineBlockNode<{
|
|
13
12
|
blockName?: null | string;
|
|
14
13
|
blockType: string;
|
|
@@ -28,6 +27,10 @@ type RichTextProps = {
|
|
|
28
27
|
* Serialized editor state to render.
|
|
29
28
|
*/
|
|
30
29
|
data: SerializedEditorState;
|
|
30
|
+
/**
|
|
31
|
+
* If true, removes the container div wrapper.
|
|
32
|
+
*/
|
|
33
|
+
disableContainer?: boolean;
|
|
31
34
|
/**
|
|
32
35
|
* If true, disables indentation globally. If an array, disables for specific node `type` values.
|
|
33
36
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exports/react/components/RichText/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB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G;IACH,UAAU,CAAC,EAAE,aAAa,GAAG,qBAAqB,CAAA;IAClD;;OAEG;IACH,IAAI,EAAE,qBAAqB,CAAA;IAC3B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAwC5C,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { defaultJSXConverters } from './converter/defaultConverters.js';
|
|
4
4
|
import { convertLexicalToJSX } from './converter/index.js';
|
|
@@ -7,6 +7,7 @@ export const RichText = ({
|
|
|
7
7
|
className,
|
|
8
8
|
converters,
|
|
9
9
|
data: editorState,
|
|
10
|
+
disableContainer,
|
|
10
11
|
disableIndent,
|
|
11
12
|
disableTextAlign
|
|
12
13
|
}) => {
|
|
@@ -25,14 +26,20 @@ export const RichText = ({
|
|
|
25
26
|
} else {
|
|
26
27
|
finalConverters = defaultJSXConverters;
|
|
27
28
|
}
|
|
29
|
+
const content = editorState && !Array.isArray(editorState) && typeof editorState === 'object' && 'root' in editorState && convertLexicalToJSX({
|
|
30
|
+
converters: finalConverters,
|
|
31
|
+
data: editorState,
|
|
32
|
+
disableIndent,
|
|
33
|
+
disableTextAlign
|
|
34
|
+
});
|
|
35
|
+
if (disableContainer) {
|
|
36
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
37
|
+
children: content
|
|
38
|
+
});
|
|
39
|
+
}
|
|
28
40
|
return /*#__PURE__*/_jsx("div", {
|
|
29
41
|
className: className ?? 'payload-richtext',
|
|
30
|
-
children:
|
|
31
|
-
converters: finalConverters,
|
|
32
|
-
data: editorState,
|
|
33
|
-
disableIndent,
|
|
34
|
-
disableTextAlign
|
|
35
|
-
})
|
|
42
|
+
children: content
|
|
36
43
|
});
|
|
37
44
|
};
|
|
38
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableIndent","disableTextAlign","finalConverters","defaultConverters","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableContainer","disableIndent","disableTextAlign","finalConverters","defaultConverters","content","Array","isArray","_jsx","_Fragment"],"sources":["../../../../../src/exports/react/components/RichText/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\n\nimport React from 'react'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../nodeTypes.js'\nimport type { JSXConverters } from './converter/types.js'\n\nimport { defaultJSXConverters } from './converter/defaultConverters.js'\nimport { convertLexicalToJSX } from './converter/index.js'\nimport './index.css'\n\nexport type JSXConvertersFunction<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string }>\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>,\n> = (args: { defaultConverters: JSXConverters<DefaultNodeTypes> }) => JSXConverters<T>\n\ntype RichTextProps = {\n /**\n * Additional class names for the container.\n */\n className?: string\n /**\n * Custom converters to transform your nodes to JSX. Can be an object or a function that receives the default converters.\n */\n converters?: JSXConverters | JSXConvertersFunction\n /**\n * Serialized editor state to render.\n */\n data: SerializedEditorState\n /**\n * If true, removes the container div wrapper.\n */\n disableContainer?: boolean\n /**\n * If true, disables indentation globally. If an array, disables for specific node `type` values.\n */\n disableIndent?: boolean | string[]\n /**\n * If true, disables text alignment globally. If an array, disables for specific node `type` values.\n */\n disableTextAlign?: boolean | string[]\n}\n\nexport const RichText: React.FC<RichTextProps> = ({\n className,\n converters,\n data: editorState,\n disableContainer,\n disableIndent,\n disableTextAlign,\n}) => {\n if (!editorState) {\n return null\n }\n\n let finalConverters: JSXConverters = {}\n if (converters) {\n if (typeof converters === 'function') {\n finalConverters = converters({ defaultConverters: defaultJSXConverters })\n } else {\n finalConverters = converters\n }\n } else {\n finalConverters = defaultJSXConverters\n }\n\n const content =\n editorState &&\n !Array.isArray(editorState) &&\n typeof editorState === 'object' &&\n 'root' in editorState &&\n convertLexicalToJSX({\n converters: finalConverters,\n data: editorState,\n disableIndent,\n disableTextAlign,\n })\n\n if (disableContainer) {\n return <>{content}</>\n }\n\n return <div className={className ?? 'payload-richtext'}>{content}</div>\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AASlB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,mBAAmB,QAAQ;AACpC,OAAO;AAoCP,OAAO,MAAMC,QAAA,GAAoCA,CAAC;EAChDC,SAAS;EACTC,UAAU;EACVC,IAAA,EAAMC,WAAW;EACjBC,gBAAgB;EAChBC,aAAa;EACbC;AAAgB,CACjB;EACC,IAAI,CAACH,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAII,eAAA,GAAiC,CAAC;EACtC,IAAIN,UAAA,EAAY;IACd,IAAI,OAAOA,UAAA,KAAe,YAAY;MACpCM,eAAA,GAAkBN,UAAA,CAAW;QAAEO,iBAAA,EAAmBX;MAAqB;IACzE,OAAO;MACLU,eAAA,GAAkBN,UAAA;IACpB;EACF,OAAO;IACLM,eAAA,GAAkBV,oBAAA;EACpB;EAEA,MAAMY,OAAA,GACJN,WAAA,IACA,CAACO,KAAA,CAAMC,OAAO,CAACR,WAAA,KACf,OAAOA,WAAA,KAAgB,YACvB,UAAUA,WAAA,IACVL,mBAAA,CAAoB;IAClBG,UAAA,EAAYM,eAAA;IACZL,IAAA,EAAMC,WAAA;IACNE,aAAA;IACAC;EACF;EAEF,IAAIF,gBAAA,EAAkB;IACpB,oBAAOQ,IAAA,CAAAC,SAAA;gBAAGJ;;EACZ;EAEA,oBAAOG,IAAA,CAAC;IAAIZ,SAAA,EAAWA,SAAA,IAAa;cAAqBS;;AAC3D","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownExport.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/MarkdownExport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAyC,MAAM,SAAS,CAAA;AAIjF,OAAO,KAAK,EAKV,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAIlC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,EAChC,sBAAsB,GAAE,OAAe,GACtC,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"MarkdownExport.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/MarkdownExport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAyC,MAAM,SAAS,CAAA;AAIjF,OAAO,KAAK,EAKV,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAIlC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,EAChC,sBAAsB,GAAE,OAAe,GACtC,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,MAAM,CAmDhC"}
|
|
@@ -15,7 +15,18 @@ export function createMarkdownExport(transformers, shouldPreserveNewLines = fals
|
|
|
15
15
|
const isNewlineDelimited = !shouldPreserveNewLines;
|
|
16
16
|
// Export only uses text formats that are responsible for single format
|
|
17
17
|
// e.g. it will filter out *** (bold, italic) and instead use separate ** and *
|
|
18
|
-
const textFormatTransformers = byType.textFormat.filter(transformer => transformer.format.length === 1)
|
|
18
|
+
const textFormatTransformers = byType.textFormat.filter(transformer => transformer.format.length === 1) // Make sure all text transformers that contain 'code' in their format are at the end of the array. Otherwise, formatted code like
|
|
19
|
+
// <strong><code>code</code></strong> will be exported as `**Bold Code**`, as the code format will be applied first, and the bold format
|
|
20
|
+
// will be applied second and thus skipped entirely, as the code format will prevent any further formatting.
|
|
21
|
+
.sort((a, b) => {
|
|
22
|
+
if (a.format.includes('code') && !b.format.includes('code')) {
|
|
23
|
+
return 1;
|
|
24
|
+
} else if (!a.format.includes('code') && b.format.includes('code')) {
|
|
25
|
+
return -1;
|
|
26
|
+
} else {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
19
30
|
return node => {
|
|
20
31
|
const output = [];
|
|
21
32
|
const children = (node || $getRoot()).getChildren();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownExport.js","names":["$getRoot","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isTextNode","isEmptyParagraph","transformersByType","createMarkdownExport","transformers","shouldPreserveNewLines","byType","elementTransformers","multilineElement","element","isNewlineDelimited","textFormatTransformers","textFormat","filter","transformer","format","length","node","output","children","getChildren","i","child","result","exportTopLevelElements","textMatch","push","concat","join","textTransformersIndex","textMatchTransformers","export","_node","exportChildren","getTextContent","unclosedTags","unclosableTags","mainLoop","parentNode","textNode","textContent","exportTextFormat","textTransformers","frozenString","trim","openingTags","closingTagsBefore","closingTagsAfter","prevNode","getTextSibling","nextNode","applied","Set","tag","hasFormat","has","add","find","nodeHasFormat","nextNodeHasFormat","unhandledUnclosedTags","unclosedTag","pop","replace","backward","sibling","getPreviousSibling","getNextSibling","parent","getParentOrThrow","isInline","descendant","getLastDescendant","getFirstDescendant"],"sources":["../../../../src/packages/@lexical/markdown/MarkdownExport.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ElementNode, LexicalNode, TextFormatType, TextNode } from 'lexical'\n\nimport { $getRoot, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isTextNode } from 'lexical'\n\nimport type {\n ElementTransformer,\n MultilineElementTransformer,\n TextFormatTransformer,\n TextMatchTransformer,\n Transformer,\n} from './MarkdownTransformers.js'\n\nimport { isEmptyParagraph, transformersByType } from './utils.js'\n\n/**\n * Renders string from markdown. The selection is moved to the start after the operation.\n */\nexport function createMarkdownExport(\n transformers: Array<Transformer>,\n shouldPreserveNewLines: boolean = false,\n): (node?: ElementNode) => string {\n const byType = transformersByType(transformers)\n const elementTransformers = [...byType.multilineElement, ...byType.element]\n const isNewlineDelimited = !shouldPreserveNewLines\n\n // Export only uses text formats that are responsible for single format\n // e.g. it will filter out *** (bold, italic) and instead use separate ** and *\n const textFormatTransformers = byType.textFormat.filter(\n (transformer) => transformer.format.length === 1,\n )\n\n return (node) => {\n const output = []\n const children = (node || $getRoot()).getChildren()\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n const result = exportTopLevelElements(\n child,\n elementTransformers,\n textFormatTransformers,\n byType.textMatch,\n )\n\n if (result != null) {\n output.push(\n // separate consecutive group of texts with a line break: eg. [\"hello\", \"world\"] -> [\"hello\", \"/nworld\"]\n isNewlineDelimited &&\n i > 0 &&\n !isEmptyParagraph(child) &&\n !isEmptyParagraph(children[i - 1])\n ? '\\n'.concat(result)\n : result,\n )\n }\n }\n // Ensure consecutive groups of texts are at least \\n\\n apart while each empty paragraph render as a newline.\n // Eg. [\"hello\", \"\", \"\", \"hi\", \"\\nworld\"] -> \"hello\\n\\n\\nhi\\n\\nworld\"\n return output.join('\\n')\n }\n}\n\nfunction exportTopLevelElements(\n node: LexicalNode,\n elementTransformers: Array<ElementTransformer | MultilineElementTransformer>,\n textTransformersIndex: Array<TextFormatTransformer>,\n textMatchTransformers: Array<TextMatchTransformer>,\n): null | string {\n for (const transformer of elementTransformers) {\n if (!transformer.export) {\n continue\n }\n const result = transformer.export(node, (_node) =>\n exportChildren(_node, textTransformersIndex, textMatchTransformers),\n )\n\n if (result != null) {\n return result\n }\n }\n\n if ($isElementNode(node)) {\n return exportChildren(node, textTransformersIndex, textMatchTransformers)\n } else if ($isDecoratorNode(node)) {\n return node.getTextContent()\n } else {\n return null\n }\n}\n\nfunction exportChildren(\n node: ElementNode,\n textTransformersIndex: Array<TextFormatTransformer>,\n textMatchTransformers: Array<TextMatchTransformer>,\n unclosedTags?: Array<{ format: TextFormatType; tag: string }>,\n unclosableTags?: Array<{ format: TextFormatType; tag: string }>,\n): string {\n const output = []\n const children = node.getChildren()\n // keep track of unclosed tags from the very beginning\n if (!unclosedTags) {\n unclosedTags = []\n }\n if (!unclosableTags) {\n unclosableTags = []\n }\n\n mainLoop: for (const child of children) {\n for (const transformer of textMatchTransformers) {\n if (!transformer.export) {\n continue\n }\n\n const result = transformer.export(\n child,\n (parentNode) =>\n exportChildren(\n parentNode,\n textTransformersIndex,\n textMatchTransformers,\n unclosedTags,\n // Add current unclosed tags to the list of unclosable tags - we don't want nested tags from\n // textmatch transformers to close the outer ones, as that may result in invalid markdown.\n // E.g. **text [text**](https://lexical.io)\n // is invalid markdown, as the closing ** is inside the link.\n //\n [...unclosableTags, ...unclosedTags],\n ),\n (textNode, textContent) =>\n exportTextFormat(\n textNode,\n textContent,\n textTransformersIndex,\n unclosedTags,\n unclosableTags,\n ),\n )\n\n if (result != null) {\n output.push(result)\n continue mainLoop\n }\n }\n\n if ($isLineBreakNode(child)) {\n output.push('\\n')\n } else if ($isTextNode(child)) {\n output.push(\n exportTextFormat(\n child,\n child.getTextContent(),\n textTransformersIndex,\n unclosedTags,\n unclosableTags,\n ),\n )\n } else if ($isElementNode(child)) {\n // empty paragraph returns \"\"\n output.push(\n exportChildren(\n child,\n textTransformersIndex,\n textMatchTransformers,\n unclosedTags,\n unclosableTags,\n ),\n )\n } else if ($isDecoratorNode(child)) {\n output.push(child.getTextContent())\n }\n }\n\n return output.join('')\n}\n\nfunction exportTextFormat(\n node: TextNode,\n textContent: string,\n textTransformers: Array<TextFormatTransformer>,\n // unclosed tags include the markdown tags that haven't been closed yet, and their associated formats\n unclosedTags: Array<{ format: TextFormatType; tag: string }>,\n unclosableTags?: Array<{ format: TextFormatType; tag: string }>,\n): string {\n // This function handles the case of a string looking like this: \" foo \"\n // Where it would be invalid markdown to generate: \"** foo **\"\n // We instead want to trim the whitespace out, apply formatting, and then\n // bring the whitespace back. So our returned string looks like this: \" **foo** \"\n const frozenString = textContent.trim()\n let output = frozenString\n // the opening tags to be added to the result\n let openingTags = ''\n // the closing tags to be added to the result\n let closingTagsBefore = ''\n let closingTagsAfter = ''\n\n const prevNode = getTextSibling(node, true)\n const nextNode = getTextSibling(node, false)\n\n const applied = new Set()\n\n for (const transformer of textTransformers) {\n const format = transformer.format[0]\n const tag = transformer.tag\n\n // dedup applied formats\n if (hasFormat(node, format) && !applied.has(format)) {\n // Multiple tags might be used for the same format (*, _)\n applied.add(format)\n\n // append the tag to openningTags, if it's not applied to the previous nodes,\n // or the nodes before that (which would result in an unclosed tag)\n if (!hasFormat(prevNode, format) || !unclosedTags.find((element) => element.tag === tag)) {\n unclosedTags.push({ format, tag })\n openingTags += tag\n }\n }\n }\n\n // close any tags in the same order they were applied, if necessary\n for (let i = 0; i < unclosedTags.length; i++) {\n const nodeHasFormat = hasFormat(node, unclosedTags[i].format)\n const nextNodeHasFormat = hasFormat(nextNode, unclosedTags[i].format)\n\n // prevent adding closing tag if next sibling will do it\n if (nodeHasFormat && nextNodeHasFormat) {\n continue\n }\n\n const unhandledUnclosedTags = [...unclosedTags] // Shallow copy to avoid modifying the original array\n\n while (unhandledUnclosedTags.length > i) {\n const unclosedTag = unhandledUnclosedTags.pop()\n\n // If tag is unclosable, don't close it and leave it in the original array,\n // So that it can be closed when it's no longer unclosable\n if (\n unclosableTags &&\n unclosedTag &&\n unclosableTags.find((element) => element.tag === unclosedTag.tag)\n ) {\n continue\n }\n\n if (unclosedTag && typeof unclosedTag.tag === 'string') {\n if (!nodeHasFormat) {\n // Handles cases where the tag has not been closed before, e.g. if the previous node\n // was a text match transformer that did not account for closing tags of the next node (e.g. a link)\n closingTagsBefore += unclosedTag.tag\n } else if (!nextNodeHasFormat) {\n closingTagsAfter += unclosedTag.tag\n }\n }\n // Mutate the original array to remove the closed tag\n unclosedTags.pop()\n }\n break\n }\n\n output = openingTags + output + closingTagsAfter\n // Replace trimmed version of textContent ensuring surrounding whitespace is not modified\n return closingTagsBefore + textContent.replace(frozenString, () => output)\n}\n\n// Get next or previous text sibling a text node, including cases\n// when it's a child of inline element (e.g. link)\nfunction getTextSibling(node: TextNode, backward: boolean): null | TextNode {\n let sibling = backward ? node.getPreviousSibling() : node.getNextSibling()\n\n if (!sibling) {\n const parent = node.getParentOrThrow()\n\n if (parent.isInline()) {\n sibling = backward ? parent.getPreviousSibling() : parent.getNextSibling()\n }\n }\n\n while (sibling) {\n if ($isElementNode(sibling)) {\n if (!sibling.isInline()) {\n break\n }\n\n const descendant = backward ? sibling.getLastDescendant() : sibling.getFirstDescendant()\n\n if ($isTextNode(descendant)) {\n return descendant\n } else {\n sibling = backward ? sibling.getPreviousSibling() : sibling.getNextSibling()\n }\n }\n\n if ($isTextNode(sibling)) {\n return sibling\n }\n\n if (!$isElementNode(sibling)) {\n return null\n }\n }\n\n return null\n}\n\nfunction hasFormat(node: LexicalNode | null | undefined, format: TextFormatType): boolean {\n return $isTextNode(node) && node.hasFormat(format)\n}\n"],"mappings":"AAAA;;;;;;GAUA,SAASA,QAAQ,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ;AAU1F,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ;AAErD;;;AAGA,OAAO,SAASC,qBACdC,YAAgC,EAChCC,sBAAA,GAAkC,KAAK;EAEvC,MAAMC,MAAA,GAASJ,kBAAA,CAAmBE,YAAA;EAClC,MAAMG,mBAAA,GAAsB,C,GAAID,MAAA,CAAOE,gBAAgB,E,GAAKF,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A,GAAoBN,WAAA,CAAYuB,OAAO,CAACpB,YAAA,EAAc,MAAMzB,MAAA;AACrE;AAEA;AACA;AACA,SAAS+B,eAAehC,IAAc,EAAE+C,QAAiB;EACvD,IAAIC,OAAA,GAAUD,QAAA,GAAW/C,IAAA,CAAKiD,kBAAkB,KAAKjD,IAAA,CAAKkD,cAAc;EAExE,IAAI,CAACF,OAAA,EAAS;IACZ,MAAMG,MAAA,GAASnD,IAAA,CAAKoD,gBAAgB;IAEpC,IAAID,MAAA,CAAOE,QAAQ,IAAI;MACrBL,OAAA,GAAUD,QAAA,GAAWI,MAAA,CAAOF,kBAAkB,KAAKE,MAAA,CAAOD,cAAc;IAC1E;EACF;EAEA,OAAOF,OAAA,EAAS;IACd,IAAInE,cAAA,CAAemE,OAAA,GAAU;MAC3B,IAAI,CAACA,OAAA,CAAQK,QAAQ,IAAI;QACvB;MACF;MAEA,MAAMC,UAAA,GAAaP,QAAA,GAAWC,OAAA,CAAQO,iBAAiB,KAAKP,OAAA,CAAQQ,kBAAkB;MAEtF,IAAIzE,WAAA,CAAYuE,UAAA,GAAa;QAC3B,OAAOA,UAAA;MACT,OAAO;QACLN,OAAA,GAAUD,QAAA,GAAWC,OAAA,CAAQC,kBAAkB,KAAKD,OAAA,CAAQE,cAAc;MAC5E;IACF;IAEA,IAAInE,WAAA,CAAYiE,OAAA,GAAU;MACxB,OAAOA,OAAA;IACT;IAEA,IAAI,CAACnE,cAAA,CAAemE,OAAA,GAAU;MAC5B,OAAO;IACT;EACF;EAEA,OAAO;AACT;AAEA,SAASX,UAAUrC,IAAoC,EAAEF,MAAsB;EAC7E,OAAOf,WAAA,CAAYiB,IAAA,KAASA,IAAA,CAAKqC,SAAS,CAACvC,MAAA;AAC7C","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MarkdownExport.js","names":["$getRoot","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isTextNode","isEmptyParagraph","transformersByType","createMarkdownExport","transformers","shouldPreserveNewLines","byType","elementTransformers","multilineElement","element","isNewlineDelimited","textFormatTransformers","textFormat","filter","transformer","format","length","sort","a","b","includes","node","output","children","getChildren","i","child","result","exportTopLevelElements","textMatch","push","concat","join","textTransformersIndex","textMatchTransformers","export","_node","exportChildren","getTextContent","unclosedTags","unclosableTags","mainLoop","parentNode","textNode","textContent","exportTextFormat","textTransformers","frozenString","trim","openingTags","closingTagsBefore","closingTagsAfter","prevNode","getTextSibling","nextNode","applied","Set","tag","hasFormat","has","add","find","nodeHasFormat","nextNodeHasFormat","unhandledUnclosedTags","unclosedTag","pop","replace","backward","sibling","getPreviousSibling","getNextSibling","parent","getParentOrThrow","isInline","descendant","getLastDescendant","getFirstDescendant"],"sources":["../../../../src/packages/@lexical/markdown/MarkdownExport.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ElementNode, LexicalNode, TextFormatType, TextNode } from 'lexical'\n\nimport { $getRoot, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isTextNode } from 'lexical'\n\nimport type {\n ElementTransformer,\n MultilineElementTransformer,\n TextFormatTransformer,\n TextMatchTransformer,\n Transformer,\n} from './MarkdownTransformers.js'\n\nimport { isEmptyParagraph, transformersByType } from './utils.js'\n\n/**\n * Renders string from markdown. The selection is moved to the start after the operation.\n */\nexport function createMarkdownExport(\n transformers: Array<Transformer>,\n shouldPreserveNewLines: boolean = false,\n): (node?: ElementNode) => string {\n const byType = transformersByType(transformers)\n const elementTransformers = [...byType.multilineElement, ...byType.element]\n const isNewlineDelimited = !shouldPreserveNewLines\n\n // Export only uses text formats that are responsible for single format\n // e.g. it will filter out *** (bold, italic) and instead use separate ** and *\n const textFormatTransformers = byType.textFormat\n .filter((transformer) => transformer.format.length === 1)\n // Make sure all text transformers that contain 'code' in their format are at the end of the array. Otherwise, formatted code like\n // <strong><code>code</code></strong> will be exported as `**Bold Code**`, as the code format will be applied first, and the bold format\n // will be applied second and thus skipped entirely, as the code format will prevent any further formatting.\n .sort((a, b) => {\n if (a.format.includes('code') && !b.format.includes('code')) {\n return 1\n } else if (!a.format.includes('code') && b.format.includes('code')) {\n return -1\n } else {\n return 0\n }\n })\n\n return (node) => {\n const output = []\n const children = (node || $getRoot()).getChildren()\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n const result = exportTopLevelElements(\n child,\n elementTransformers,\n textFormatTransformers,\n byType.textMatch,\n )\n\n if (result != null) {\n output.push(\n // separate consecutive group of texts with a line break: eg. [\"hello\", \"world\"] -> [\"hello\", \"/nworld\"]\n isNewlineDelimited &&\n i > 0 &&\n !isEmptyParagraph(child) &&\n !isEmptyParagraph(children[i - 1])\n ? '\\n'.concat(result)\n : result,\n )\n }\n }\n // Ensure consecutive groups of texts are at least \\n\\n apart while each empty paragraph render as a newline.\n // Eg. [\"hello\", \"\", \"\", \"hi\", \"\\nworld\"] -> \"hello\\n\\n\\nhi\\n\\nworld\"\n return output.join('\\n')\n }\n}\n\nfunction exportTopLevelElements(\n node: LexicalNode,\n elementTransformers: Array<ElementTransformer | MultilineElementTransformer>,\n textTransformersIndex: Array<TextFormatTransformer>,\n textMatchTransformers: Array<TextMatchTransformer>,\n): null | string {\n for (const transformer of elementTransformers) {\n if (!transformer.export) {\n continue\n }\n const result = transformer.export(node, (_node) =>\n exportChildren(_node, textTransformersIndex, textMatchTransformers),\n )\n\n if (result != null) {\n return result\n }\n }\n\n if ($isElementNode(node)) {\n return exportChildren(node, textTransformersIndex, textMatchTransformers)\n } else if ($isDecoratorNode(node)) {\n return node.getTextContent()\n } else {\n return null\n }\n}\n\nfunction exportChildren(\n node: ElementNode,\n textTransformersIndex: Array<TextFormatTransformer>,\n textMatchTransformers: Array<TextMatchTransformer>,\n unclosedTags?: Array<{ format: TextFormatType; tag: string }>,\n unclosableTags?: Array<{ format: TextFormatType; tag: string }>,\n): string {\n const output = []\n const children = node.getChildren()\n // keep track of unclosed tags from the very beginning\n if (!unclosedTags) {\n unclosedTags = []\n }\n if (!unclosableTags) {\n unclosableTags = []\n }\n\n mainLoop: for (const child of children) {\n for (const transformer of textMatchTransformers) {\n if (!transformer.export) {\n continue\n }\n\n const result = transformer.export(\n child,\n (parentNode) =>\n exportChildren(\n parentNode,\n textTransformersIndex,\n textMatchTransformers,\n unclosedTags,\n // Add current unclosed tags to the list of unclosable tags - we don't want nested tags from\n // textmatch transformers to close the outer ones, as that may result in invalid markdown.\n // E.g. **text [text**](https://lexical.io)\n // is invalid markdown, as the closing ** is inside the link.\n //\n [...unclosableTags, ...unclosedTags],\n ),\n (textNode, textContent) =>\n exportTextFormat(\n textNode,\n textContent,\n textTransformersIndex,\n unclosedTags,\n unclosableTags,\n ),\n )\n\n if (result != null) {\n output.push(result)\n continue mainLoop\n }\n }\n\n if ($isLineBreakNode(child)) {\n output.push('\\n')\n } else if ($isTextNode(child)) {\n output.push(\n exportTextFormat(\n child,\n child.getTextContent(),\n textTransformersIndex,\n unclosedTags,\n unclosableTags,\n ),\n )\n } else if ($isElementNode(child)) {\n // empty paragraph returns \"\"\n output.push(\n exportChildren(\n child,\n textTransformersIndex,\n textMatchTransformers,\n unclosedTags,\n unclosableTags,\n ),\n )\n } else if ($isDecoratorNode(child)) {\n output.push(child.getTextContent())\n }\n }\n\n return output.join('')\n}\n\nfunction exportTextFormat(\n node: TextNode,\n textContent: string,\n textTransformers: Array<TextFormatTransformer>,\n // unclosed tags include the markdown tags that haven't been closed yet, and their associated formats\n unclosedTags: Array<{ format: TextFormatType; tag: string }>,\n unclosableTags?: Array<{ format: TextFormatType; tag: string }>,\n): string {\n // This function handles the case of a string looking like this: \" foo \"\n // Where it would be invalid markdown to generate: \"** foo **\"\n // We instead want to trim the whitespace out, apply formatting, and then\n // bring the whitespace back. So our returned string looks like this: \" **foo** \"\n const frozenString = textContent.trim()\n let output = frozenString\n // the opening tags to be added to the result\n let openingTags = ''\n // the closing tags to be added to the result\n let closingTagsBefore = ''\n let closingTagsAfter = ''\n\n const prevNode = getTextSibling(node, true)\n const nextNode = getTextSibling(node, false)\n\n const applied = new Set()\n\n for (const transformer of textTransformers) {\n const format = transformer.format[0]\n const tag = transformer.tag\n\n // dedup applied formats\n if (hasFormat(node, format) && !applied.has(format)) {\n // Multiple tags might be used for the same format (*, _)\n applied.add(format)\n\n // append the tag to openningTags, if it's not applied to the previous nodes,\n // or the nodes before that (which would result in an unclosed tag)\n if (!hasFormat(prevNode, format) || !unclosedTags.find((element) => element.tag === tag)) {\n unclosedTags.push({ format, tag })\n openingTags += tag\n }\n }\n }\n\n // close any tags in the same order they were applied, if necessary\n for (let i = 0; i < unclosedTags.length; i++) {\n const nodeHasFormat = hasFormat(node, unclosedTags[i].format)\n const nextNodeHasFormat = hasFormat(nextNode, unclosedTags[i].format)\n\n // prevent adding closing tag if next sibling will do it\n if (nodeHasFormat && nextNodeHasFormat) {\n continue\n }\n\n const unhandledUnclosedTags = [...unclosedTags] // Shallow copy to avoid modifying the original array\n\n while (unhandledUnclosedTags.length > i) {\n const unclosedTag = unhandledUnclosedTags.pop()\n\n // If tag is unclosable, don't close it and leave it in the original array,\n // So that it can be closed when it's no longer unclosable\n if (\n unclosableTags &&\n unclosedTag &&\n unclosableTags.find((element) => element.tag === unclosedTag.tag)\n ) {\n continue\n }\n\n if (unclosedTag && typeof unclosedTag.tag === 'string') {\n if (!nodeHasFormat) {\n // Handles cases where the tag has not been closed before, e.g. if the previous node\n // was a text match transformer that did not account for closing tags of the next node (e.g. a link)\n closingTagsBefore += unclosedTag.tag\n } else if (!nextNodeHasFormat) {\n closingTagsAfter += unclosedTag.tag\n }\n }\n // Mutate the original array to remove the closed tag\n unclosedTags.pop()\n }\n break\n }\n\n output = openingTags + output + closingTagsAfter\n // Replace trimmed version of textContent ensuring surrounding whitespace is not modified\n return closingTagsBefore + textContent.replace(frozenString, () => output)\n}\n\n// Get next or previous text sibling a text node, including cases\n// when it's a child of inline element (e.g. link)\nfunction getTextSibling(node: TextNode, backward: boolean): null | TextNode {\n let sibling = backward ? node.getPreviousSibling() : node.getNextSibling()\n\n if (!sibling) {\n const parent = node.getParentOrThrow()\n\n if (parent.isInline()) {\n sibling = backward ? parent.getPreviousSibling() : parent.getNextSibling()\n }\n }\n\n while (sibling) {\n if ($isElementNode(sibling)) {\n if (!sibling.isInline()) {\n break\n }\n\n const descendant = backward ? sibling.getLastDescendant() : sibling.getFirstDescendant()\n\n if ($isTextNode(descendant)) {\n return descendant\n } else {\n sibling = backward ? sibling.getPreviousSibling() : sibling.getNextSibling()\n }\n }\n\n if ($isTextNode(sibling)) {\n return sibling\n }\n\n if (!$isElementNode(sibling)) {\n return null\n }\n }\n\n return null\n}\n\nfunction hasFormat(node: LexicalNode | null | undefined, format: TextFormatType): boolean {\n return $isTextNode(node) && node.hasFormat(format)\n}\n"],"mappings":"AAAA;;;;;;GAUA,SAASA,QAAQ,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ;AAU1F,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ;AAErD;;;AAGA,OAAO,SAASC,qBACdC,YAAgC,EAChCC,sBAAA,GAAkC,KAAK;EAEvC,MAAMC,MAAA,GAASJ,kBAAA,CAAmBE,YAAA;EAClC,MAAMG,mBAAA,GAAsB,C,GAAID,MAAA,CAAOE,gBAAgB,E,GAAKF,MAAA,CAAOG,OAAO,CAAC;EAC3E,MAAMC,kBAAA,GAAqB,CAACL,sBAAA;EAE5B;EACA;EACA,MAAMM,sBAAA,GAAyBL,MAAA,CAAOM,UAAU,CAC7CC,MAAM,CAAEC,WAAA,IAAgBA,WAAA,CAAYC,MAAM,CAACC,MAAM,KAAK,EACvD;EACA;EACA;EAAA,CACCC,IAAI,CAAC,CAACC,CAAA,EAAGC,CAAA;IACR,IAAID,CAAA,CAAEH,MAAM,CAACK,QAAQ,CAAC,WAAW,CAACD,CAAA,CAAEJ,MAAM,CAACK,QAAQ,CAAC,SAAS;MAC3D,OAAO;IACT,OAAO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YAAA,EAAc,MAAMzB,MAAA;AACrE;AAEA;AACA;AACA,SAAS+B,eAAehC,IAAc,EAAE+C,QAAiB;EACvD,IAAIC,OAAA,GAAUD,QAAA,GAAW/C,IAAA,CAAKiD,kBAAkB,KAAKjD,IAAA,CAAKkD,cAAc;EAExE,IAAI,CAACF,OAAA,EAAS;IACZ,MAAMG,MAAA,GAASnD,IAAA,CAAKoD,gBAAgB;IAEpC,IAAID,MAAA,CAAOE,QAAQ,IAAI;MACrBL,OAAA,GAAUD,QAAA,GAAWI,MAAA,CAAOF,kBAAkB,KAAKE,MAAA,CAAOD,cAAc;IAC1E;EACF;EAEA,OAAOF,OAAA,EAAS;IACd,IAAIvE,cAAA,CAAeuE,OAAA,GAAU;MAC3B,IAAI,CAACA,OAAA,CAAQK,QAAQ,IAAI;QACvB;MACF;MAEA,MAAMC,UAAA,GAAaP,QAAA,GAAWC,OAAA,CAAQO,iBAAiB,KAAKP,OAAA,CAAQQ,kBAAkB;MAEtF,IAAI7E,WAAA,CAAY2E,UAAA,GAAa;QAC3B,OAAOA,UAAA;MACT,OAAO;QACLN,OAAA,GAAUD,QAAA,GAAWC,OAAA,CAAQC,kBAAkB,KAAKD,OAAA,CAAQE,cAAc;MAC5E;IACF;IAEA,IAAIvE,WAAA,CAAYqE,OAAA,GAAU;MACxB,OAAOA,OAAA;IACT;IAEA,IAAI,CAACvE,cAAA,CAAeuE,OAAA,GAAU;MAC5B,OAAO;IACT;EACF;EAEA,OAAO;AACT;AAEA,SAASX,UAAUrC,IAAoC,EAAEN,MAAsB;EAC7E,OAAOf,WAAA,CAAYqB,IAAA,KAASA,IAAA,CAAKqC,SAAS,CAAC3C,MAAA;AAC7C","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -352,8 +352,8 @@
|
|
|
352
352
|
"react-error-boundary": "4.1.2",
|
|
353
353
|
"ts-essentials": "10.0.3",
|
|
354
354
|
"uuid": "10.0.0",
|
|
355
|
-
"@payloadcms/translations": "3.
|
|
356
|
-
"@payloadcms/ui": "3.
|
|
355
|
+
"@payloadcms/translations": "3.15.0",
|
|
356
|
+
"@payloadcms/ui": "3.15.0"
|
|
357
357
|
},
|
|
358
358
|
"devDependencies": {
|
|
359
359
|
"@babel/cli": "7.25.9",
|
|
@@ -374,7 +374,7 @@
|
|
|
374
374
|
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
|
|
375
375
|
"swc-plugin-transform-remove-imports": "2.0.0",
|
|
376
376
|
"@payloadcms/eslint-config": "3.9.0",
|
|
377
|
-
"payload": "3.
|
|
377
|
+
"payload": "3.15.0"
|
|
378
378
|
},
|
|
379
379
|
"peerDependencies": {
|
|
380
380
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
@@ -392,8 +392,8 @@
|
|
|
392
392
|
"lexical": "0.20.0",
|
|
393
393
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
394
394
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
395
|
-
"@payloadcms/next": "3.
|
|
396
|
-
"payload": "3.
|
|
395
|
+
"@payloadcms/next": "3.15.0",
|
|
396
|
+
"payload": "3.15.0"
|
|
397
397
|
},
|
|
398
398
|
"engines": {
|
|
399
399
|
"node": "^18.20.2 || >=20.9.0"
|