@payloadcms/richtext-lexical 3.60.0-canary.6 → 3.60.0-canary.7
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-YHS7VMOE.js +2 -0
- package/dist/exports/client/Field-YHS7VMOE.js.map +7 -0
- package/dist/exports/client/index.js +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +2 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/ClipboardPlugin/index.d.ts +2 -0
- package/dist/lexical/plugins/ClipboardPlugin/index.d.ts.map +1 -0
- package/dist/lexical/plugins/ClipboardPlugin/index.js +64 -0
- package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -0
- package/package.json +7 -6
- package/dist/exports/client/Field-CJFETHA3.js +0 -2
- package/dist/exports/client/Field-CJFETHA3.js.map +0 -7
|
@@ -57,7 +57,7 @@ ${e.map(Ju).join(`
|
|
|
57
57
|
|
|
58
58
|
`,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",qf=new RegExp("^[^"+cs+"]*["+as+"]"),Qf=new RegExp("^[^"+as+"]*["+cs+"]"),e0={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},t0={directionless:F.IS_DIRECTIONLESS,unmergeable:F.IS_UNMERGEABLE},o0={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},r0={[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"},n0={normal:F.IS_NORMAL,segmented:F.IS_SEGMENTED,token:F.IS_TOKEN},l0={[F.IS_NORMAL]:"normal",[F.IS_SEGMENTED]:"segmented",[F.IS_TOKEN]:"token"};var us={text:({node:t})=>{let e=t.text;return t.format&F.IS_BOLD&&(e=je("strong",{children:e})),t.format&F.IS_ITALIC&&(e=je("em",{children:e})),t.format&F.IS_STRIKETHROUGH&&(e=je("span",{style:{textDecoration:"line-through"},children:e})),t.format&F.IS_UNDERLINE&&(e=je("span",{style:{textDecoration:"underline"},children:e})),t.format&F.IS_CODE&&(e=je("code",{children:e})),t.format&F.IS_SUBSCRIPT&&(e=je("sub",{children:e})),t.format&F.IS_SUPERSCRIPT&&(e=je("sup",{children:e})),e}};import{jsx as vt}from"react/jsx-runtime";var ds={upload:({node:t})=>{let e=t;if(typeof e.value!="object")return null;let o=e.value,r=o.url;if(!o.mimeType.startsWith("image"))return vt("a",{href:r,rel:"noopener noreferrer",children:o.filename});if(!o.sizes||!Object.keys(o.sizes).length)return vt("img",{alt:o.filename,height:o.height,src:r,width:o.width});let n=[];for(let l in o.sizes){let i=o.sizes[l];if(!i||!i.width||!i.height||!i.mimeType||!i.filesize||!i.filename||!i.url)continue;let s=i?.url;n.push(vt("source",{media:`(max-width: ${i.width}px)`,srcSet:s,type:i.mimeType},l))}return n.push(vt("img",{alt:o?.filename,height:o?.height,src:r,width:o?.width},"image")),vt("picture",{children:n})}};var rt={...ls,...us,...ts,...qi,...ss,...Qi,...es,...ns,...rs({}),...ds,...is};import{jsx as ps,Fragment as i0}from"react/jsx-runtime";import kr from"react";function ms(t){let e=!!t?.root?.children?.length,o=!1;if(t?.root?.children?.length===1&&t?.root?.children[0]?.type==="paragraph"){let r=t?.root?.children[0];if(!r?.children||r?.children?.length===0)o=!0;else if(r?.children?.length===1){let n=r?.children[0];n?.type==="text"&&(n?.text?.length||(o=!0))}}return!(!e||o)}function fs({converters:t,data:e,disableIndent:o,disableTextAlign:r}){return ms(e)?hs({converters:t,disableIndent:o,disableTextAlign:r,nodes:e?.root?.children,parent:e?.root}):ps(i0,{})}function hs({converters:t,disableIndent:e,disableTextAlign:o,nodes:r,parent:n}){let l=t.unknown;return r.map((s,d)=>{let c;s.type==="block"?(c=t?.blocks?.[s?.fields?.blockType],!c&&!l&&console.error(`Lexical => JSX converter: Blocks converter: found ${s?.fields?.blockType} block, but no converter is provided`)):s.type==="inlineBlock"?(c=t?.inlineBlocks?.[s?.fields?.blockType],!c&&!l&&console.error(`Lexical => JSX converter: Inline Blocks converter: found ${s?.fields?.blockType} inline block, but no converter is provided`)):c=t[s.type];try{!c&&l&&(c=l);let u;c?u=typeof c=="function"?c({childIndex:d,converters:t,node:s,nodesToJSX:p=>hs({converters:p.converters??t,disableIndent:p.disableIndent??e,disableTextAlign:p.disableTextAlign??o,nodes:p.nodes,parent:p.parent??{...s,parent:n}}),parent:n}):c:u=ps("span",{children:"unknown node"},d);let a={};if(!o&&(!Array.isArray(o)||!o?.includes(s.type))&&"format"in s&&s.format)switch(s.format){case"center":a.textAlign="center";break;case"end":a.textAlign="right";break;case"justify":a.textAlign="justify";break;case"left":break;case"right":a.textAlign="right";break;case"start":a.textAlign="left";break}if(!e&&(!Array.isArray(e)||!e?.includes(s.type))&&"indent"in s&&s.indent&&s.type!=="listitem"&&(a.paddingInlineStart=`${Number(s.indent)*40}px`),kr.isValidElement(u)){if(a.textAlign||a.paddingInlineStart){let m={...a,...u?.props?.style??{}};return kr.cloneElement(u,{key:d,style:m})}return kr.cloneElement(u,{key:d})}return u}catch(u){return console.error("Error converting lexical node to JSX:",u,"node:",s),null}}).filter(Boolean)}var _r=({className:t,converters:e,data:o,disableContainer:r,disableIndent:n,disableTextAlign:l})=>{if(!o)return null;let i={};e?typeof e=="function"?i=e({defaultConverters:rt}):i=e:i=rt;let s=o&&!Array.isArray(o)&&typeof o=="object"&&"root"in o&&fs({converters:i,data:o,disableIndent:n,disableTextAlign:l});return r?gs(s0,{children:s}):gs("div",{className:t??"payload-richtext",children:s})};function Cs(){let t=a0(7),[e]=c0(),o;t[0]!==e?(o=e.getEditorState().toJSON(),t[0]=e,t[1]=o):o=t[1];let[r,n]=d0(o),l,i;t[2]!==e?(l=()=>e.registerUpdateListener(d=>{let{editorState:c}=d;n(c.toJSON())}),i=[e],t[2]=e,t[3]=l,t[4]=i):(l=t[3],i=t[4]),u0(l,i);let s;return t[5]!==r?(s=xs("div",{className:"debug-jsx-converter",children:xs(_r,{converters:rt,data:r})}),t[5]=r,t[6]=s):s=t[6],s}var m0=M({plugins:[{Component:Cs,position:"bottom"}]});var B={amber:{50:"oklch(0.987 0.022 95.277)",100:"oklch(0.962 0.059 95.617)",200:"oklch(0.924 0.12 95.746)",300:"oklch(0.879 0.169 91.605)",400:"oklch(0.828 0.189 84.429)",500:"oklch(0.769 0.188 70.08)",600:"oklch(0.666 0.179 58.318)",700:"oklch(0.555 0.163 48.998)",800:"oklch(0.473 0.137 46.201)",900:"oklch(0.414 0.112 45.904)",950:"oklch(0.279 0.077 45.635)"},black:"#000",blue:{50:"oklch(0.97 0.014 254.604)",100:"oklch(0.932 0.032 255.585)",200:"oklch(0.882 0.059 254.128)",300:"oklch(0.809 0.105 251.813)",400:"oklch(0.707 0.165 254.624)",500:"oklch(0.623 0.214 259.815)",600:"oklch(0.546 0.245 262.881)",700:"oklch(0.488 0.243 264.376)",800:"oklch(0.424 0.199 265.638)",900:"oklch(0.379 0.146 265.522)",950:"oklch(0.282 0.091 267.935)"},current:"currentColor",cyan:{50:"oklch(0.984 0.019 200.873)",100:"oklch(0.956 0.045 203.388)",200:"oklch(0.917 0.08 205.041)",300:"oklch(0.865 0.127 207.078)",400:"oklch(0.789 0.154 211.53)",500:"oklch(0.715 0.143 215.221)",600:"oklch(0.609 0.126 221.723)",700:"oklch(0.52 0.105 223.128)",800:"oklch(0.45 0.085 224.283)",900:"oklch(0.398 0.07 227.392)",950:"oklch(0.302 0.056 229.695)"},emerald:{50:"oklch(0.979 0.021 166.113)",100:"oklch(0.95 0.052 163.051)",200:"oklch(0.905 0.093 164.15)",300:"oklch(0.845 0.143 164.978)",400:"oklch(0.765 0.177 163.223)",500:"oklch(0.696 0.17 162.48)",600:"oklch(0.596 0.145 163.225)",700:"oklch(0.508 0.118 165.612)",800:"oklch(0.432 0.095 166.913)",900:"oklch(0.378 0.077 168.94)",950:"oklch(0.262 0.051 172.552)"},fuchsia:{50:"oklch(0.977 0.017 320.058)",100:"oklch(0.952 0.037 318.852)",200:"oklch(0.903 0.076 319.62)",300:"oklch(0.833 0.145 321.434)",400:"oklch(0.74 0.238 322.16)",500:"oklch(0.667 0.295 322.15)",600:"oklch(0.591 0.293 322.896)",700:"oklch(0.518 0.253 323.949)",800:"oklch(0.452 0.211 324.591)",900:"oklch(0.401 0.17 325.612)",950:"oklch(0.293 0.136 325.661)"},gray:{50:"oklch(0.985 0.002 247.839)",100:"oklch(0.967 0.003 264.542)",200:"oklch(0.928 0.006 264.531)",300:"oklch(0.872 0.01 258.338)",400:"oklch(0.707 0.022 261.325)",500:"oklch(0.551 0.027 264.364)",600:"oklch(0.446 0.03 256.802)",700:"oklch(0.373 0.034 259.733)",800:"oklch(0.278 0.033 256.848)",900:"oklch(0.21 0.034 264.665)",950:"oklch(0.13 0.028 261.692)"},green:{50:"oklch(0.982 0.018 155.826)",100:"oklch(0.962 0.044 156.743)",200:"oklch(0.925 0.084 155.995)",300:"oklch(0.871 0.15 154.449)",400:"oklch(0.792 0.209 151.711)",500:"oklch(0.723 0.219 149.579)",600:"oklch(0.627 0.194 149.214)",700:"oklch(0.527 0.154 150.069)",800:"oklch(0.448 0.119 151.328)",900:"oklch(0.393 0.095 152.535)",950:"oklch(0.266 0.065 152.934)"},indigo:{50:"oklch(0.962 0.018 272.314)",100:"oklch(0.93 0.034 272.788)",200:"oklch(0.87 0.065 274.039)",300:"oklch(0.785 0.115 274.713)",400:"oklch(0.673 0.182 276.935)",500:"oklch(0.585 0.233 277.117)",600:"oklch(0.511 0.262 276.966)",700:"oklch(0.457 0.24 277.023)",800:"oklch(0.398 0.195 277.366)",900:"oklch(0.359 0.144 278.697)",950:"oklch(0.257 0.09 281.288)"},inherit:"inherit",lime:{50:"oklch(0.986 0.031 120.757)",100:"oklch(0.967 0.067 122.328)",200:"oklch(0.938 0.127 124.321)",300:"oklch(0.897 0.196 126.665)",400:"oklch(0.841 0.238 128.85)",500:"oklch(0.768 0.233 130.85)",600:"oklch(0.648 0.2 131.684)",700:"oklch(0.532 0.157 131.589)",800:"oklch(0.453 0.124 130.933)",900:"oklch(0.405 0.101 131.063)",950:"oklch(0.274 0.072 132.109)"},neutral:{50:"oklch(0.985 0 0)",100:"oklch(0.97 0 0)",200:"oklch(0.922 0 0)",300:"oklch(0.87 0 0)",400:"oklch(0.708 0 0)",500:"oklch(0.556 0 0)",600:"oklch(0.439 0 0)",700:"oklch(0.371 0 0)",800:"oklch(0.269 0 0)",900:"oklch(0.205 0 0)",950:"oklch(0.145 0 0)"},orange:{50:"oklch(0.98 0.016 73.684)",100:"oklch(0.954 0.038 75.164)",200:"oklch(0.901 0.076 70.697)",300:"oklch(0.837 0.128 66.29)",400:"oklch(0.75 0.183 55.934)",500:"oklch(0.705 0.213 47.604)",600:"oklch(0.646 0.222 41.116)",700:"oklch(0.553 0.195 38.402)",800:"oklch(0.47 0.157 37.304)",900:"oklch(0.408 0.123 38.172)",950:"oklch(0.266 0.079 36.259)"},pink:{50:"oklch(0.971 0.014 343.198)",100:"oklch(0.948 0.028 342.258)",200:"oklch(0.899 0.061 343.231)",300:"oklch(0.823 0.12 346.018)",400:"oklch(0.718 0.202 349.761)",500:"oklch(0.656 0.241 354.308)",600:"oklch(0.592 0.249 0.584)",700:"oklch(0.525 0.223 3.958)",800:"oklch(0.459 0.187 3.815)",900:"oklch(0.408 0.153 2.432)",950:"oklch(0.284 0.109 3.907)"},purple:{50:"oklch(0.977 0.014 308.299)",100:"oklch(0.946 0.033 307.174)",200:"oklch(0.902 0.063 306.703)",300:"oklch(0.827 0.119 306.383)",400:"oklch(0.714 0.203 305.504)",500:"oklch(0.627 0.265 303.9)",600:"oklch(0.558 0.288 302.321)",700:"oklch(0.496 0.265 301.924)",800:"oklch(0.438 0.218 303.724)",900:"oklch(0.381 0.176 304.987)",950:"oklch(0.291 0.149 302.717)"},red:{50:"oklch(0.971 0.013 17.38)",100:"oklch(0.936 0.032 17.717)",200:"oklch(0.885 0.062 18.334)",300:"oklch(0.808 0.114 19.571)",400:"oklch(0.704 0.191 22.216)",500:"oklch(0.637 0.237 25.331)",600:"oklch(0.577 0.245 27.325)",700:"oklch(0.505 0.213 27.518)",800:"oklch(0.444 0.177 26.899)",900:"oklch(0.396 0.141 25.723)",950:"oklch(0.258 0.092 26.042)"},rose:{50:"oklch(0.969 0.015 12.422)",100:"oklch(0.941 0.03 12.58)",200:"oklch(0.892 0.058 10.001)",300:"oklch(0.81 0.117 11.638)",400:"oklch(0.712 0.194 13.428)",500:"oklch(0.645 0.246 16.439)",600:"oklch(0.586 0.253 17.585)",700:"oklch(0.514 0.222 16.935)",800:"oklch(0.455 0.188 13.697)",900:"oklch(0.41 0.159 10.272)",950:"oklch(0.271 0.105 12.094)"},sky:{50:"oklch(0.977 0.013 236.62)",100:"oklch(0.951 0.026 236.824)",200:"oklch(0.901 0.058 230.902)",300:"oklch(0.828 0.111 230.318)",400:"oklch(0.746 0.16 232.661)",500:"oklch(0.685 0.169 237.323)",600:"oklch(0.588 0.158 241.966)",700:"oklch(0.5 0.134 242.749)",800:"oklch(0.443 0.11 240.79)",900:"oklch(0.391 0.09 240.876)",950:"oklch(0.293 0.066 243.157)"},slate:{50:"oklch(0.984 0.003 247.858)",100:"oklch(0.968 0.007 247.896)",200:"oklch(0.929 0.013 255.508)",300:"oklch(0.869 0.022 252.894)",400:"oklch(0.704 0.04 256.788)",500:"oklch(0.554 0.046 257.417)",600:"oklch(0.446 0.043 257.281)",700:"oklch(0.372 0.044 257.287)",800:"oklch(0.279 0.041 260.031)",900:"oklch(0.208 0.042 265.755)",950:"oklch(0.129 0.042 264.695)"},stone:{50:"oklch(0.985 0.001 106.423)",100:"oklch(0.97 0.001 106.424)",200:"oklch(0.923 0.003 48.717)",300:"oklch(0.869 0.005 56.366)",400:"oklch(0.709 0.01 56.259)",500:"oklch(0.553 0.013 58.071)",600:"oklch(0.444 0.011 73.639)",700:"oklch(0.374 0.01 67.558)",800:"oklch(0.268 0.007 34.298)",900:"oklch(0.216 0.006 56.043)",950:"oklch(0.147 0.004 49.25)"},teal:{50:"oklch(0.984 0.014 180.72)",100:"oklch(0.953 0.051 180.801)",200:"oklch(0.91 0.096 180.426)",300:"oklch(0.855 0.138 181.071)",400:"oklch(0.777 0.152 181.912)",500:"oklch(0.704 0.14 182.503)",600:"oklch(0.6 0.118 184.704)",700:"oklch(0.511 0.096 186.391)",800:"oklch(0.437 0.078 188.216)",900:"oklch(0.386 0.063 188.416)",950:"oklch(0.277 0.046 192.524)"},transparent:"transparent",violet:{50:"oklch(0.969 0.016 293.756)",100:"oklch(0.943 0.029 294.588)",200:"oklch(0.894 0.057 293.283)",300:"oklch(0.811 0.111 293.571)",400:"oklch(0.702 0.183 293.541)",500:"oklch(0.606 0.25 292.717)",600:"oklch(0.541 0.281 293.009)",700:"oklch(0.491 0.27 292.581)",800:"oklch(0.432 0.232 292.759)",900:"oklch(0.38 0.189 293.745)",950:"oklch(0.283 0.141 291.089)"},white:"#fff",yellow:{50:"oklch(0.987 0.026 102.212)",100:"oklch(0.973 0.071 103.193)",200:"oklch(0.945 0.129 101.54)",300:"oklch(0.905 0.182 98.111)",400:"oklch(0.852 0.199 91.936)",500:"oklch(0.795 0.184 86.047)",600:"oklch(0.681 0.162 75.834)",700:"oklch(0.554 0.135 66.442)",800:"oklch(0.476 0.114 61.907)",900:"oklch(0.421 0.095 57.708)",950:"oklch(0.286 0.066 53.813)"},zinc:{50:"oklch(0.985 0 0)",100:"oklch(0.967 0.001 286.375)",200:"oklch(0.92 0.004 286.32)",300:"oklch(0.871 0.006 286.286)",400:"oklch(0.705 0.015 286.067)",500:"oklch(0.552 0.016 285.938)",600:"oklch(0.442 0.017 285.786)",700:"oklch(0.37 0.013 285.805)",800:"oklch(0.274 0.006 286.033)",900:"oklch(0.21 0.006 285.885)",950:"oklch(0.141 0.005 285.823)"}},p0={text:{"text-red":{css:{color:`light-dark(${B.red[600]}, ${B.red[400]})`},label:"Red"},"text-orange":{css:{color:`light-dark(${B.orange[600]}, ${B.orange[400]})`},label:"Orange"},"text-yellow":{css:{color:`light-dark(${B.yellow[700]}, ${B.yellow[300]})`},label:"Yellow"},"text-green":{css:{color:`light-dark(${B.green[700]}, ${B.green[400]})`},label:"Green"},"text-blue":{css:{color:`light-dark(${B.blue[600]}, ${B.blue[400]})`},label:"Blue"},"text-purple":{css:{color:`light-dark(${B.purple[600]}, ${B.purple[400]})`},label:"Purple"},"text-pink":{css:{color:`light-dark(${B.pink[600]}, ${B.pink[400]})`},label:"Pink"}},background:{"bg-red":{css:{"background-color":`light-dark(${B.red[400]}, ${B.red[600]})`},label:"Red"},"bg-orange":{css:{"background-color":`light-dark(${B.orange[400]}, ${B.orange[600]})`},label:"Orange"},"bg-yellow":{css:{"background-color":`light-dark(${B.yellow[300]}, ${B.yellow[700]})`},label:"Yellow"},"bg-green":{css:{"background-color":`light-dark(${B.green[400]}, ${B.green[700]})`},label:"Green"},"bg-blue":{css:{"background-color":`light-dark(${B.blue[400]}, ${B.blue[600]})`},label:"Blue"},"bg-purple":{css:{"background-color":`light-dark(${B.purple[400]}, ${B.purple[600]})`},label:"Purple"},"bg-pink":{css:{"background-color":`light-dark(${B.pink[400]}, ${B.pink[600]})`},label:"Pink"}}};import{$isNodeSelection as q0}from"lexical";import{jsx as Mt,jsxs as f0}from"react/jsx-runtime";import"react";var Tr=()=>f0("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:[Mt("g",{clipPath:"url(#clip0_4397_10817)",children:Mt("path",{d:"M7.75 12.25L15.25 4.75M15.25 4.75H11.5M15.25 4.75V8.5M13 11.5V13.75C13 14.5784 12.3284 15.25 11.5 15.25H6.25C5.42157 15.25 4.75 14.5784 4.75 13.75V8.5C4.75 7.67157 5.42157 7 6.25 7H8.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})}),Mt("defs",{children:Mt("clipPath",{id:"clip0_4397_10817",children:Mt("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{jsx as x0}from"react/jsx-runtime";import*as ks from"react";import{DecoratorBlockNode as h0}from"@lexical/react/LexicalDecoratorBlockNode.js";function g0(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:bs({relationTo:o,value:e})}:null}var Dt=class extends h0{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"relationship"}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:g0,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=bs(o);return r.setFormat(e.format),r}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div");e.setAttribute("data-lexical-relationship-id",String(typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value)),e.setAttribute("data-lexical-relationship-relationTo",this.__data?.relationTo);let o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"relationship",version:2}}getData(){return this.getLatest().__data}getTextContent(){return`${this.__data?.relationTo} relation to ${typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value}`}setData(e){let o=this.getWritable();o.__data=e}};function bs(t){return new Dt({data:t})}var C0=ks.lazy(()=>import("./RelationshipComponent-JXQOFHXF.js").then(t=>({default:t.RelationshipComponent})));function b0(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:He({relationTo:o,value:e})}:null}var we=class extends Dt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:b0,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=He(o);return r.setFormat(e.format),r}decorate(e,o){return x0(C0,{className:o.theme.relationship??"LexicalEditorTheme__relationship",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function He(t){return new we({data:t})}function wr(t){return t instanceof we}import{c as j0}from"react/compiler-runtime";import{jsx as H0}from"react/jsx-runtime";import{useLexicalComposerContext as U0}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as W0}from"@lexical/utils";import{$getPreviousSelection as G0,$getSelection as V0,$isParagraphNode as K0,$isRangeSelection as J0,COMMAND_PRIORITY_EDITOR as X0,createCommand as z0}from"lexical";import{useEffect as Z0}from"react";import{c as ws}from"react/compiler-runtime";import{jsx as Er}from"react/jsx-runtime";import{useLexicalComposerContext as Es}from"@lexical/react/LexicalComposerContext.js";import{toast as v0}from"@payloadcms/ui";import{$getNodeByKey as M0,COMMAND_PRIORITY_EDITOR as Ss}from"lexical";import{useEffect as Ls,useState as D0}from"react";import{c as k0}from"react/compiler-runtime";import{jsx as _0}from"react/jsx-runtime";import{useLexicalComposerContext as T0}from"@lexical/react/LexicalComposerContext";import{useListDrawer as w0,useModal as E0}from"@payloadcms/ui";import{$getNodeByKey as _s,$getPreviousSelection as S0,$getRoot as L0,$getSelection as N0,$isRangeSelection as y0,$setSelection as R0}from"lexical";import{useEffect as I0,useState as Ts}from"react";var At=t=>{let e=k0(23),[o]=T0(),[r,n]=Ts(null),[l,i]=Ts(!1),[s,d,c]=w0(t),{closeDrawer:u,drawerSlug:a,isDrawerOpen:m,openDrawer:p}=c,{modalState:f}=E0(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let A=N0()??S0();n(A)},e[0]=h):h=e[0];let x=h,T;e[1]!==o||e[2]!==r?(T=()=>{r&&o.update(()=>{if(y0(r)){let{anchor:A,focus:I}=r;_s(A.key)&&_s(I.key)&&R0(r.clone())}else L0().selectEnd()},{discrete:!0,skipTransforms:!0})},e[1]=o,e[2]=r,e[3]=T):T=e[3];let E=T,S;e[4]!==u?(S=()=>{u()},e[4]=u,e[5]=S):S=e[5];let _=S,k,g;e[6]!==a||e[7]!==f||e[8]!==E||e[9]!==l?(k=()=>{if(!l)return;let A=f[a];A&&!A?.isOpen&&(i(!1),setTimeout(()=>{E()},1))},g=[f,a,E,l],e[6]=a,e[7]=f,e[8]=E,e[9]=l,e[10]=k,e[11]=g):(k=e[10],g=e[11]),I0(k,g);let C;e[12]!==d?(C=A=>_0(d,{...A,onClick:()=>{x()}}),e[12]=d,e[13]=C):C=e[13];let b;e[14]!==p?(b=()=>{x(),p(),i(!0)},e[14]=p,e[15]=b):b=e[15];let y;return e[16]!==s||e[17]!==_||e[18]!==m||e[19]!==a||e[20]!==C||e[21]!==b?(y={closeListDrawer:_,isListDrawerOpen:m,ListDrawer:s,listDrawerSlug:a,ListDrawerToggler:C,openListDrawer:b},e[16]=s,e[17]=_,e[18]=m,e[19]=a,e[20]=C,e[21]=b,e[22]=y):y=e[22],y};var A0=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=M0(o);n&&n.replace(He({relationTo:e,value:r}))}):t.dispatchCommand(Sr,{relationTo:e,value:r})},$0=t=>{let e=ws(14),{enabledCollectionSlugs:o}=t,[r]=Es(),[n,l]=D0(null),i=o?.[0],s;e[0]!==o||e[1]!==i?(s={collectionSlugs:o,selectedCollection:i},e[0]=o,e[1]=i,e[2]=s):s=e[2];let{closeListDrawer:d,ListDrawer:c,openListDrawer:u}=At(s),a,m;e[3]!==r||e[4]!==u?(a=()=>r.registerCommand(Je,x=>(l(x?.replace?x?.replace.nodeKey:null),u(),!0),Ss),m=[r,u],e[3]=r,e[4]=u,e[5]=a,e[6]=m):(a=e[5],m=e[6]),Ls(a,m);let p;e[7]!==d||e[8]!==r||e[9]!==n?(p=x=>{let{collectionSlug:T,doc:E}=x;A0({editor:r,relationTo:T,replaceNodeKey:n,value:E.id}),d()},e[7]=d,e[8]=r,e[9]=n,e[10]=p):p=e[10];let f=p,h;return e[11]!==c||e[12]!==f?(h=Er(c,{onSelect:f}),e[11]=c,e[12]=f,e[13]=h):h=e[13],h},O0=()=>{let t=ws(3),[e]=Es(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Je,F0,Ss),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),Ls(o,r),null},Ns=({enabledCollectionSlugs:t})=>t?.length?Er($0,{enabledCollectionSlugs:t}):Er(O0,{});function F0(){return v0.error("No relationship collections enabled"),!0}import{useConfig as P0,useEntityVisibility as B0}from"@payloadcms/ui";import*as ys from"react";var fo=t=>{let{collectionSlugsBlacklist:e,collectionSlugsWhitelist:o,uploads:r=!1}=t||{},{config:{collections:n}}=P0(),{visibleEntities:l}=B0();return ys.useMemo(()=>{let s=[],d=[],c=o?new Set(o):null,u=e?new Set(e):null;for(let a of n){let{slug:m,admin:{enableRichTextRelationship:p},upload:f}=a;if(l?.collections.includes(m)){if(r){if(!p||!f)continue}else if(f||!p)continue;c&&!c.has(m)||u&&u.has(m)||(s.push(m),d.push(a))}}return{enabledCollections:d,enabledCollectionSlugs:s}},[n,l,r,o,e])};var Sr=z0("INSERT_RELATIONSHIP_COMMAND"),Rs=t=>{let e=j0(8),{clientProps:o}=t,[r]=U0(),n=o?.disabledCollections,l=o?.enabledCollections,i;e[0]!==n||e[1]!==l?(i={collectionSlugsBlacklist:n,collectionSlugsWhitelist:l},e[0]=n,e[1]=l,e[2]=i):i=e[2];let{enabledCollectionSlugs:s}=fo(i),d,c;e[3]!==r?(d=()=>{if(!r.hasNodes([we]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return r.registerCommand(Sr,Y0,X0)},c=[r],e[3]=r,e[4]=d,e[5]=c):(d=e[4],c=e[5]),Z0(d,c);let u;return e[6]!==s?(u=H0(Ns,{enabledCollectionSlugs:s}),e[6]=s,e[7]=u):u=e[7],u};function Y0(t){let e=V0()||G0();if(J0(e)){let o=He(t),{focus:r}=e,n=r.getNode();W0(o),K0(n)&&!n.__first&&n.remove()}return!0}var Q0=M({nodes:[we],plugins:[{Component:Rs,position:"normal"}],slashMenu:{groups:[z([{Icon:Tr,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Je,{replace:!1})}}])]},toolbarFixed:{groups:[Ce([{ChildComponent:Tr,isActive:({selection:t})=>{if(!q0(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return wr(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(Je,{replace:!1})}}])]}});import{c as Ps}from"react/compiler-runtime";import{jsx as ae,jsxs as L1}from"react/jsx-runtime";import{useLexicalComposerContext as N1}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as Bs}from"@lexical/react/useLexicalEditable";import{useScrollInfo as y1,useThrottledEffect as R1,useTranslation as I1}from"@payloadcms/ui";import*as Ee from"react";import{useMemo as v1}from"react";import{c as e1}from"react/compiler-runtime";import{jsx as t1}from"react/jsx-runtime";import{mergeRegister as o1}from"@lexical/utils";import{$addUpdateTag as r1,$getSelection as n1}from"lexical";import{useDeferredValue as l1,useEffect as i1,useState as s1}from"react";var Is="toolbar-popup__button",$t=t=>{let e=e1(23),{children:o,editor:r,item:n}=t,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={active:!1,enabled:!0},e[0]=l):l=e[0];let[i,s]=s1(l),d=l1(i),c=j(),u=d.enabled?"":"disabled",a=d.active?"active":"",m=n.key?`${Is}-${n.key}`:"",p;e[1]!==u||e[2]!==a||e[3]!==m?(p=[Is,u,a,m].filter(Boolean),e[1]=u,e[2]=a,e[3]=m,e[4]=p):p=e[4];let f=p.join(" "),h;e[5]!==r||e[6]!==c||e[7]!==n?(h=()=>{r.getEditorState().read(()=>{let b=n1();if(!b)return;let y=n.isActive?n.isActive({editor:r,editorConfigContext:c,selection:b}):!1,A=n.isEnabled?n.isEnabled({editor:r,editorConfigContext:c,selection:b}):!0;s(I=>I.active===y&&I.enabled===A?I:{active:y,enabled:A})})},e[5]=r,e[6]=c,e[7]=n,e[8]=h):h=e[8];let x=h,T=Wt(),E,S;e[9]!==r||e[10]!==T||e[11]!==x?(E=()=>{T(x);let b=()=>T(x),y=o1(r.registerUpdateListener(b));return document.addEventListener("mouseup",b),()=>{y(),document.removeEventListener("mouseup",b)}},S=[r,T,x],e[9]=r,e[10]=T,e[11]=x,e[12]=E,e[13]=S):(E=e[12],S=e[13]),i1(E,S);let _;e[14]!==i||e[15]!==r||e[16]!==n?(_=()=>{i.enabled&&r.focus(()=>{r.update(a1),n.onSelect?.({editor:r,isActive:i.active})})},e[14]=i,e[15]=r,e[16]=n,e[17]=_):_=e[17];let k=_,g=c1,C;return e[18]!==o||e[19]!==f||e[20]!==k||e[21]!==n.key?(C=t1("button",{className:f,"data-button-key":n.key,onClick:k,onMouseDown:g,type:"button",children:o}),e[18]=o,e[19]=f,e[20]=k,e[21]=n.key,e[22]=C):C=e[22],C};function a1(){r1("toolbar")}function c1(t){t.preventDefault()}import{c as g1}from"react/compiler-runtime";import{jsx as nt}from"react/jsx-runtime";import Fs,{useCallback as x1,useDeferredValue as C1,useEffect as b1,useMemo as k1}from"react";import{mergeRegister as _1}from"@lexical/utils";import{useTranslation as T1}from"@payloadcms/ui";import{$getSelection as w1}from"lexical";import{jsx as Ie,jsxs as vs}from"react/jsx-runtime";import{Button as u1}from"@payloadcms/ui";import{$addUpdateTag as d1,isDOMNode as m1}from"lexical";import ho,{useCallback as p1,useEffect as go,useMemo as Ds,useRef as Lr,useState as Nr}from"react";import{createPortal as f1}from"react-dom";var Ms="toolbar-popup__dropdown-item",As=ho.createContext(null);function $s({active:t,children:e,editor:o,enabled:r,Icon:n,item:l,itemKey:i,tooltip:s}){let d=Ds(()=>[Ms,r===!1?"disabled":"",t?"active":"",l?.key?`${Ms}-${l.key}`:""].filter(Boolean).join(" "),[r,t,l.key]),c=Lr(null),u=ho.use(As);if(u===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:a}=u;return go(()=>{c?.current!=null&&a(c)},[c,a]),Ie(u1,{"aria-label":s,buttonStyle:"none",className:d,disabled:r===!1,extraButtonProps:{"data-item-key":i},icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&o.focus(()=>{o.update(()=>{d1("toolbar")}),l.onSelect?.({editor:o,isActive:t})})},onMouseDown:m=>{m.preventDefault()},ref:c,tooltip:s,type:"button",children:e})}function h1({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,l]=Nr(),[i,s]=Nr(),d=p1(a=>{l(m=>m!=null?[...m,a]:[a])},[l]),c=a=>{if(n==null)return;let{key:m}=a;["ArrowDown","ArrowUp","Escape","Tab"].includes(m)&&a.preventDefault(),m==="Escape"||m==="Tab"?r():m==="ArrowUp"?s(p=>{if(p==null)return n[0];let f=n.indexOf(p)-1;return n[f===-1?n.length-1:f]}):m==="ArrowDown"&&s(p=>p==null?n[0]:n[n.indexOf(p)+1])},u=Ds(()=>({registerItem:d}),[d]);return go(()=>{n!=null&&i==null&&s(n[0]),i!=null&&i?.current!=null&&i.current.focus()},[n,i]),Ie(As,{value:u,children:Ie("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:c,ref:e,children:t})})}function Os({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,dropdownKey:n,Icon:l,itemsContainerClassNames:i,label:s,stopCloseOnClickSelf:d}){let c=Lr(null),u=Lr(null),[a,m]=Nr(!1),p=()=>{m(!1),u?.current!=null&&u.current.focus()};go(()=>{let h=u.current,x=c.current;if(a&&h!==null&&x!==null){let{left:T,top:E}=h.getBoundingClientRect(),S=window.scrollY||document.documentElement.scrollTop;x.style.top=`${E+S+h.offsetHeight+5}px`,x.style.left=`${Math.min(T-5,window.innerWidth-x.offsetWidth-20)}px`}},[c,u,a]),go(()=>{let h=u.current;if(h!==null&&a){let x=T=>{let E=T.target;m1(E)&&(d&&c.current&&c.current.contains(E)||h.contains(E)||m(!1))};return document.addEventListener("click",x),()=>{document.removeEventListener("click",x)}}},[c,u,a,d]);let f=f1(Ie(h1,{dropDownRef:c,itemsContainerClassNames:i,onClose:p,children:o}),document.body);return vs(ho.Fragment,{children:[vs("button",{"aria-label":t,className:e+(a?" active":""),"data-dropdown-key":n,disabled:r,onClick:h=>{h.preventDefault(),m(!a)},onMouseDown:h=>{h.preventDefault()},ref:u,type:"button",children:[l&&Ie(l,{}),s&&Ie("span",{className:"toolbar-popup__dropdown-label",children:s}),Ie("i",{className:"toolbar-popup__dropdown-caret"})]}),a&&Ie(ho.Fragment,{children:f})]})}var yr="toolbar-popup__dropdown",E1=t=>{let e=g1(14),{active:o,anchorElem:r,editor:n,enabled:l,item:i}=t,{i18n:s}=T1(),{fieldProps:d}=j(),{featureClientSchemaMap:c,schemaPath:u}=d;if(i.Component){let m;return e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==i?(m=i?.Component&&nt(i.Component,{active:o,anchorElem:r,editor:n,enabled:l,item:i},i.key),e[0]=o,e[1]=r,e[2]=n,e[3]=l,e[4]=i,e[5]=m):m=e[5],m}let a;if(e[6]!==o||e[7]!==n||e[8]!==l||e[9]!==c||e[10]!==s||e[11]!==i||e[12]!==u){let m=i.key,p;i.label&&(m=typeof i.label=="function"?i.label({featureClientSchemaMap:c,i18n:s,schemaPath:u}):i.label),m.length>25?p=m.substring(0,25)+"...":p=m,a=nt($s,{active:o,editor:n,enabled:l,Icon:i?.ChildComponent?nt(i.ChildComponent,{}):void 0,item:i,itemKey:i.key,tooltip:m,children:nt("span",{className:"text",children:p})},i.key),e[6]=o,e[7]=n,e[8]=l,e[9]=c,e[10]=s,e[11]=i,e[12]=u,e[13]=a}else a=e[13];return a},S1=Fs.memo(E1),Ue=({anchorElem:t,classNames:e,editor:o,group:r,Icon:n,itemsContainerClassNames:l,label:i,maxActiveItems:s,onActiveChange:d})=>{let[c,u]=Fs.useState({activeItemKeys:[],enabledGroup:!0,enabledItemKeys:[]}),a=C1(c),m=j(),{items:p,key:f}=r,h=Wt(),x=x1(()=>{o.getEditorState().read(()=>{let E=w1();if(!E)return;let S=[],_=[],k=[];for(let g of p)g.isActive&&(!s||S.length<s)&&g.isActive({editor:o,editorConfigContext:m,selection:E})&&(S.push(g.key),_.push(g)),g.isEnabled?g.isEnabled({editor:o,editorConfigContext:m,selection:E})&&k.push(g.key):k.push(g.key);u({activeItemKeys:S,enabledGroup:r.isEnabled?r.isEnabled({editor:o,editorConfigContext:m,selection:E}):!0,enabledItemKeys:k}),d&&d({activeItems:_})})},[o,m,r,p,s,d]);b1(()=>(h(x),_1(o.registerUpdateListener(async()=>{await h(x)}))),[o,h,x]);let T=k1(()=>p?.length?p.map(E=>nt(S1,{active:a.activeItemKeys.includes(E.key),anchorElem:t,editor:o,enabled:a.enabledItemKeys.includes(E.key),item:E},E.key)):null,[p,a,t,o]);return nt(Os,{buttonAriaLabel:`${f} dropdown`,buttonClassName:[yr,`${yr}-${f}`,...e||[]].filter(Boolean).join(" "),disabled:!a.enabledGroup,dropdownKey:f,Icon:n,itemsContainerClassNames:[`${yr}-items`,...l||[]],label:i,children:T},f)};function M1({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&ae(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?ae($t,{editor:e,item:o,children:ae(o.ChildComponent,{})},o.key):null}function D1(t){let e=Ps(23),{anchorElem:o,editor:r,editorConfig:n,group:l,index:i}=t,{i18n:s}=I1(),{fieldProps:d}=j(),{featureClientSchemaMap:c,schemaPath:u}=d,[a,m]=Ee.useState(void 0),[p,f]=Ee.useState(void 0),h;e[0]!==l.ChildComponent||e[1]!==l.items||e[2]!==l.type?(h=()=>{l?.type==="dropdown"&&l.items.length&&l.ChildComponent?f(()=>l.ChildComponent):f(void 0)},e[0]=l.ChildComponent,e[1]=l.items,e[2]=l.type,e[3]=h):h=e[3];let x;e[4]!==l?(x=[l],e[4]=l,e[5]=x):x=e[5],Ee.useEffect(h,x);let T;e[6]!==c||e[7]!==l.ChildComponent||e[8]!==l.items||e[9]!==l.type||e[10]!==s||e[11]!==u?(T=k=>{let{activeItems:g}=k;if(!g.length){l?.type==="dropdown"&&l.items.length&&l.ChildComponent?(f(()=>l.ChildComponent),m(void 0)):(f(void 0),m(void 0));return}let C=g[0],b=C.key;C.label&&(b=typeof C.label=="function"?C.label({featureClientSchemaMap:c,i18n:s,schemaPath:u}):C.label),b.length>25&&(b=b.substring(0,25)+"..."),g.length===1?(m(b),f(()=>C.ChildComponent)):(m(s.t("lexical:general:toolbarItemsActive",{count:g.length})),l?.type==="dropdown"&&l.items.length&&l.ChildComponent?f(()=>l.ChildComponent):f(void 0))},e[6]=c,e[7]=l.ChildComponent,e[8]=l.items,e[9]=l.type,e[10]=s,e[11]=u,e[12]=T):T=e[12];let E=T,S=`fixed-toolbar__group fixed-toolbar__group-${l.key}`,_;return e[13]!==p||e[14]!==o||e[15]!==a||e[16]!==r||e[17]!==n.features.toolbarFixed?.groups.length||e[18]!==l||e[19]!==i||e[20]!==E||e[21]!==S?(_=L1("div",{className:S,"data-toolbar-group-key":l.key,children:[l.type==="dropdown"&&l.items.length?p?ae(Ue,{anchorElem:o,editor:r,group:l,Icon:p,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a,maxActiveItems:l.maxActiveItems??1,onActiveChange:E}):ae(Ue,{anchorElem:o,editor:r,group:l,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a,maxActiveItems:l.maxActiveItems??1,onActiveChange:E}):null,l.type==="buttons"&&l.items.length?l.items.map(k=>ae(M1,{anchorElem:o,editor:r,item:k},k.key)):null,i<n.features.toolbarFixed?.groups.length-1&&ae("div",{className:"divider"})]},l.key),e[13]=p,e[14]=o,e[15]=a,e[16]=r,e[17]=n.features.toolbarFixed?.groups.length,e[18]=l,e[19]=i,e[20]=E,e[21]=S,e[22]=_):_=e[22],_}function A1({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let l=Ee.useRef(null),i=Bs(),{y:s}=y1(),d=v1(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let u=n.editorContainerRef.current.previousElementSibling;for(;u;){if(u.classList.contains("fixed-toolbar"))return u;u=u.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return R1(()=>{if(!d)return;let c=l.current;if(!c)return;let u=c.getBoundingClientRect(),a=d.getBoundingClientRect();if(!(u.bottom<a.top||u.top>a.bottom))c.classList.remove("fixed-toolbar"),c.classList.add("fixed-toolbar","fixed-toolbar--overlapping"),d.classList.remove("fixed-toolbar"),d.classList.add("fixed-toolbar","fixed-toolbar--hide");else{if(!c.classList.contains("fixed-toolbar--overlapping"))return;c.classList.remove("fixed-toolbar--overlapping"),c.classList.add("fixed-toolbar"),d.classList.remove("fixed-toolbar--hide"),d.classList.add("fixed-toolbar")}},50,[l,d,s]),ae("div",{className:"fixed-toolbar",onFocus:c=>{c.stopPropagation()},ref:l,children:i&&ae(Ee.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((c,u)=>ae(D1,{anchorElem:t,editor:o,editorConfig:r,group:c,index:u},c.key))})})}var js=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return js(t.parentEditor)}return!1},Hs=t=>{let e=Ps(6),{clientProps:o}=t,[r]=N1(),n=j();if(!Bs())return null;let{editorConfig:i}=n,s=o.applyToFocusedEditor&&n.focusedEditor?.editor||r,d=o.applyToFocusedEditor&&n.focusedEditor?.editorConfig||i,c,u;if(e[0]!==o.disableIfParentHasFixedToolbar||e[1]!==s||e[2]!==d||e[3]!==n){u=Symbol.for("react.early_return_sentinel");e:{let a=js(n);if(o?.disableIfParentHasFixedToolbar&&a){u=null;break e}if(!d?.features?.toolbarFixed?.groups?.length){u=null;break e}c=ae(A1,{anchorElem:document.body,editor:s,editorConfig:d,parentWithFixedToolbar:a})}e[0]=o.disableIfParentHasFixedToolbar,e[1]=s,e[2]=d,e[3]=n,e[4]=c,e[5]=u}else c=e[4],u=e[5];return u!==Symbol.for("react.early_return_sentinel")?u:c};var $1=M({plugins:[{Component:Hs,position:"aboveContainer"}]});import{c as Gs}from"react/compiler-runtime";import{jsx as me,jsxs as Vs}from"react/jsx-runtime";import{useLexicalComposerContext as O1}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as F1}from"@lexical/react/useLexicalEditable";import{mergeRegister as Ks}from"@lexical/utils";import{$getSelection as Js,$isRangeSelection as Us,$isTextNode as P1,COMMAND_PRIORITY_LOW as B1,getDOMSelection as Xs,SELECTION_CHANGE_COMMAND as j1}from"lexical";import{useCallback as Co,useEffect as Ot,useRef as Ws,useState as H1}from"react";import*as bo from"react";import{createPortal as U1}from"react-dom";function Rr(t,e){let o=t.getRangeAt(0),r;if(t.anchorNode===e){let n=e;for(;n.firstElementChild!=null;)n=n.firstElementChild;r=n.getBoundingClientRect()}else r=o.getBoundingClientRect();return r}function xo(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:l=32,horizontalPosition:i="left",specialHandlingForCaret:s=!1,targetRect:d,verticalGap:c=10}=t,u=o.parentElement;if(d===null||u==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let a=n.getBoundingClientRect(),m=o.getBoundingClientRect(),p=u.getBoundingClientRect(),f=d.top-a.height-c,h=d.left-l;i==="center"&&(h=d.left+d.width/2-a.width/2);let x=0;return!e&&f<p.top&&!s&&(x=a.height+d.height+c*2,f+=x),i==="center"?h+a.width>p.right?h=p.right-a.width-l:h<p.left&&(h=p.left+l):h+a.width>p.right&&(h=p.right-a.width-l),h-=m.left,n.style.opacity="1",s&&r!==0?(f-=m.bottom-r+a.height-3,n.style.transform=`translate(${h}px, ${f}px) rotate(180deg)`):(f-=m.top,n.style.transform=`translate(${h}px, ${f}px)`),x}function W1({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&me(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?me($t,{editor:e,item:o,children:me(o.ChildComponent,{})},o.key):null}function G1(t){let e=Gs(19),{anchorElem:o,editor:r,group:n,index:l}=t,{editorConfig:i}=j(),[s,d]=bo.useState(),c;e[0]!==n.ChildComponent||e[1]!==n.items||e[2]!==n.type?(c=()=>{n?.type==="dropdown"&&n.items.length&&n.ChildComponent?d(()=>n.ChildComponent):d(void 0)},e[0]=n.ChildComponent,e[1]=n.items,e[2]=n.type,e[3]=c):c=e[3];let u;e[4]!==n?(u=[n],e[4]=n,e[5]=u):u=e[5],bo.useEffect(c,u);let a;e[6]!==n.ChildComponent||e[7]!==n.items||e[8]!==n.type?(a=h=>{let{activeItems:x}=h;if(!x.length){n?.type==="dropdown"&&n.items.length&&n.ChildComponent?d(()=>n.ChildComponent):d(void 0);return}let T=x[0];d(()=>T?.ChildComponent)},e[6]=n.ChildComponent,e[7]=n.items,e[8]=n.type,e[9]=a):a=e[9];let m=a,p=`inline-toolbar-popup__group inline-toolbar-popup__group-${n.key}`,f;return e[10]!==s||e[11]!==o||e[12]!==r||e[13]!==i.features.toolbarInline?.groups.length||e[14]!==n||e[15]!==l||e[16]!==m||e[17]!==p?(f=Vs("div",{className:p,"data-toolbar-group-key":n.key,children:[n.type==="dropdown"&&n.items.length?s?me(Ue,{anchorElem:o,editor:r,group:n,Icon:s,maxActiveItems:n.maxActiveItems??1,onActiveChange:m}):me(Ue,{anchorElem:o,editor:r,group:n,maxActiveItems:n.maxActiveItems??1,onActiveChange:m}):null,n.type==="buttons"&&n.items.length?n.items.map(h=>me(W1,{anchorElem:o,editor:r,item:h},h.key)):null,l<i.features.toolbarInline?.groups.length-1&&me("div",{className:"divider"})]},n.key),e[10]=s,e[11]=o,e[12]=r,e[13]=i.features.toolbarInline?.groups.length,e[14]=n,e[15]=l,e[16]=m,e[17]=p,e[18]=f):f=e[18],f}function V1({anchorElem:t,editor:e}){let o=Ws(null),r=Ws(null),{editorConfig:n}=j(),l=Co(()=>{if(o?.current){let c=o.current.style.opacity==="0",u=o.current.style.pointerEvents==="none";c||(o.current.style.opacity="0"),u||(o.current.style.pointerEvents="none")}},[o]),i=Co(c=>{if(o?.current&&(c.buttons===1||c.buttons===3)){let u=o.current.style.opacity==="0",a=o.current.style.pointerEvents==="none";if(!u||!a){let m=c.clientX,p=c.clientY,f=document.elementFromPoint(m,p);o.current.contains(f)||l()}}},[l]),s=Co(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);Ot(()=>(document.addEventListener("mousemove",i),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)}),[o,i,s]);let d=Co(()=>{let c=Js(),u=Xs(e._window);if(o.current===null)return;let a=t.querySelector(":scope > .link-editor"),m=a!==null&&"style"in a&&a?.style?.opacity==="1",p=e.getRootElement();if(c!==null&&u!==null&&!u.isCollapsed&&p!==null&&p.contains(u.anchorNode)){let f=Rr(u,p),h=xo({alwaysDisplayOnTop:m,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&xo({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else l()},[e,l,t]);return Ot(()=>{let c=t.parentElement,u=()=>{e.getEditorState().read(()=>{d()})};return window.addEventListener("resize",u),c&&c.addEventListener("scroll",u),()=>{window.removeEventListener("resize",u),c&&c.removeEventListener("scroll",u)}},[e,d,t]),Ot(()=>(e.getEditorState().read(()=>{d()}),Ks(e.registerUpdateListener(({editorState:c})=>{c.read(()=>{d()})}),e.registerCommand(j1,()=>(d(),!1),B1))),[e,d]),Vs("div",{className:"inline-toolbar-popup",ref:o,children:[me("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((c,u)=>me(G1,{anchorElem:t,editor:e,group:c,index:u},c.key))]})}function K1(t,e){let o=Gs(12),[r,n]=H1(!1),l=F1(),i;o[0]!==t?(i=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let p=Js(),f=Xs(t._window),h=t.getRootElement();if(f!==null&&(!Us(p)||h===null||!h.contains(f.anchorNode))){n(!1);return}if(!Us(p))return;if(p.getTextContent()!==""){let T=p.getNodes(),E=!1;for(let S of T)if(P1(S)){n(!0),E=!0;break}E||n(!1)}else n(!1);let x=p.getTextContent().replace(/\n/g,"");if(!p.isCollapsed()&&x===""){n(!1);return}})},o[0]=t,o[1]=i):i=o[1];let s=i,d,c;o[2]!==s?(d=()=>(document.addEventListener("selectionchange",s),document.addEventListener("mouseup",s),()=>{document.removeEventListener("selectionchange",s),document.removeEventListener("mouseup",s)}),c=[s],o[2]=s,o[3]=d,o[4]=c):(d=o[3],c=o[4]),Ot(d,c);let u,a;if(o[5]!==t||o[6]!==s?(u=()=>Ks(t.registerUpdateListener(()=>{s()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),a=[t,s],o[5]=t,o[6]=s,o[7]=u,o[8]=a):(u=o[7],a=o[8]),Ot(u,a),!r||!l)return null;let m;return o[9]!==e||o[10]!==t?(m=U1(me(V1,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=m):m=o[11],m}var zs=t=>{let{anchorElem:e}=t,[o]=O1();return K1(o,e)};var J1=M({plugins:[{Component:zs,position:"floatingAnchorElem"}]});import{TableCellNode as Og,TableNode as Fg,TableRowNode as Pg}from"@lexical/table";import{jsx as Zs}from"react/jsx-runtime";import"react";var Ir=()=>Zs("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Zs("path",{clipRule:"evenodd",d:"M5.33333 4.5C4.8731 4.5 4.5 4.8731 4.5 5.33333V7.5H9.5V4.5H5.33333ZM5.33333 3.5C4.32081 3.5 3.5 4.32081 3.5 5.33333V14.6667C3.5 15.6792 4.32081 16.5 5.33333 16.5H14.6667C15.6792 16.5 16.5 15.6792 16.5 14.6667V5.33333C16.5 4.32081 15.6792 3.5 14.6667 3.5H5.33333ZM10.5 4.5V7.5H15.5V5.33333C15.5 4.8731 15.1269 4.5 14.6667 4.5H10.5ZM15.5 8.5H10.5V11.5H15.5V8.5ZM15.5 12.5H10.5V15.5H14.6667C15.1269 15.5 15.5 15.1269 15.5 14.6667V12.5ZM9.5 15.5V12.5H4.5V14.6667C4.5 15.1269 4.8731 15.5 5.33333 15.5H9.5ZM4.5 11.5H9.5V8.5H4.5V11.5Z",fill:"currentColor",fillRule:"evenodd"})});import{$createTableCellNode as X1,$createTableNode as z1,$createTableRowNode as Z1,$isTableCellNode as Ys,$isTableNode as vr,$isTableRowNode as Mr,TableCellHeaderStates as ko,TableCellNode as Y1,TableNode as q1,TableRowNode as Q1}from"@lexical/table";import{$isParagraphNode as eh,$isTextNode as th}from"lexical";var Qs=/^\|(.+)\|\s?$/,oh=/^(\| ?:?-*:? ?)+\|\s?$/,ea=({allTransformers:t})=>({type:"element",dependencies:[q1,Q1,Y1],export:e=>{if(!vr(e))return null;let o=[];for(let r of e.getChildren()){let n=[];if(!Mr(r))continue;let l=!1;for(let i of r.getChildren())Ys(i)&&(n.push(Ut(t,i).replace(/\n/g,"\\n").trim()),i.__headerState===ko.ROW&&(l=!0));o.push(`| ${n.join(" | ")} |`),l&&o.push(`| ${n.map(i=>"---").join(" | ")} |`)}return o.join(`
|
|
59
59
|
`)},regExp:Qs,replace:(e,o,r)=>{let n=r[0];if(!n)return;if(oh.test(n)){let a=e.getPreviousSibling();if(!a||!vr(a))return;let m=a.getChildren(),p=m[m.length-1];if(!p||!Mr(p))return;p.getChildren().forEach(f=>{Ys(f)&&f.setHeaderStyles(ko.ROW,ko.ROW)}),e.remove();return}let l=qs(n,t);if(l==null)return;let i=[l],s=e.getPreviousSibling(),d=l.length;for(;s&&!(!eh(s)||s.getChildrenSize()!==1);){let a=s.getFirstChild();if(!th(a))break;let m=qs(a.getTextContent(),t);if(m==null)break;d=Math.max(d,m.length),i.unshift(m);let p=s.getPreviousSibling();s.remove(),s=p}let c=z1();for(let a of i){let m=Z1();c.append(m);for(let p=0;p<d;p++)m.append(p<a.length?a[p]:ta("",t))}let u=e.getPreviousSibling();vr(u)&&rh(u)===d?(u.append(...c.getChildren()),e.remove()):e.replace(c),c.selectEnd()}});function rh(t){let e=t.getFirstChild();return Mr(e)?e.getChildrenSize():0}var ta=(t,e)=>{t=t.replace(/\\n/g,`
|
|
60
|
-
`);let o=X1(ko.NO_STATUS);return Ht(t,e,o),o},qs=(t,e)=>{let o=t.match(Qs);return!o||!o[1]?null:o[1].split("|").map(r=>ta(r,e))};import{c as lh}from"react/compiler-runtime";import{jsx as P,jsxs as Se}from"react/jsx-runtime";import{useLexicalComposerContext as ia}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as ih}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as ra,$deleteTableColumnAtSelection as sh,$deleteTableRowAtSelection as ah,$getNodeTriplet as ch,$getTableCellNodeFromLexicalNode as na,$getTableColumnIndexFromTableCellNode as uh,$getTableNodeFromLexicalNodeOrThrow as Me,$getTableRowIndexFromTableCellNode as dh,$insertTableColumnAtSelection as mh,$insertTableRowAtSelection as ph,$isTableCellNode as sa,$isTableSelection as Ft,$mergeCells as fh,$unmergeCell as hh,getTableElement as Ar,getTableObserverFromTableElement as $r,TableCellHeaderStates as ve,TableCellNode as gh}from"@lexical/table";import{mergeRegister as xh}from"@lexical/utils";import{useScrollInfo as Ch}from"@payloadcms/ui";import{$getSelection as To,$isElementNode as bh,$isRangeSelection as Or,$isTextNode as kh,$setSelection as _h,COMMAND_PRIORITY_CRITICAL as Th,getDOMSelection as wh,isDOMNode as Eh,SELECTION_CHANGE_COMMAND as Sh}from"lexical";import*as Fr from"react";import{useCallback as ce,useEffect as lt,useRef as _o,useState as it}from"react";import{createPortal as aa}from"react-dom";import{jsx as Dr,jsxs as nh}from"react/jsx-runtime";import"react";var oa=()=>nh("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Dr("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"}),Dr("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"}),Dr("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 la(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function Lh(){let t=To();if(Or(t)&&!t.isCollapsed()||Ft(t)&&!t.anchor.is(t.focus)||!Or(t)&&!Ft(t))return!1;let[e]=ch(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Nh(t){let e=t.getLastDescendant();kh(e)?e.select():bh(e)?e.selectEnd():e!==null&&e.selectNext()}function yh({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[l]=ia(),i=_o(null),[s,d]=it(n),[c,u]=it({columns:1,rows:1}),[a,m]=it(!1),[p,f]=it(!1),{y:h}=Ch();lt(()=>l.registerMutationListener(gh,w=>{w.get(s.getKey())==="updated"&&l.getEditorState().read(()=>{d(s.getLatest())})},{skipInitialization:!0}),[l,s]),lt(()=>{l.getEditorState().read(()=>{let w=To();if(Ft(w)){let N=la(w);u(la(w)),m(N.columns>1||N.rows>1)}f(Lh())})},[l]),lt(()=>{let w=e.current,N=i.current,R=l.getRootElement();if(w!=null&&N!=null&&R!=null){let $=R.getBoundingClientRect(),v=w.getBoundingClientRect();N.style.opacity="1";let O=N.getBoundingClientRect(),D=5,W=v.right+D;if(W+O.width>window.innerWidth||W+O.width>$.right){let J=v.left-O.width-D;W=(J<0?D:J)+window.pageXOffset}N.style.left=`${W+window.pageXOffset}px`;let q=v.top;if(q+O.height>window.innerHeight){let J=v.bottom-O.height;q=J<0?D:J}N.style.top=`${q}px`}},[e,i,l,h]),lt(()=>{function w(N){i.current!=null&&e.current!=null&&Eh(N.target)&&!i.current.contains(N.target)&&!e.current.contains(N.target)&&r(!1)}return window.addEventListener("click",w),()=>window.removeEventListener("click",w)},[r,e]);let x=ce(()=>{l.update(()=>{if(s.isAttached()){let w=Me(s),N=Ar(w,l.getElementByKey(w.getKey()));if(N===null)throw new Error("Expected to find tableElement in DOM");let R=$r(N);R!==null&&R.$clearHighlight(),w.markDirty(),d(s.getLatest())}_h(null)})},[l,s]),T=()=>{l.update(()=>{let w=To();if(!Ft(w))return;let R=w.getNodes().filter(sa),$=fh(R);$&&(Nh($),o())})},E=()=>{l.update(()=>{hh()})},S=ce(w=>{l.update(()=>{for(let N=0;N<c.rows;N++)ph(w);o()})},[l,o,c.rows]),_=ce(w=>{l.update(()=>{for(let N=0;N<c.columns;N++)mh(w);o()})},[l,o,c.columns]),k=ce(()=>{l.update(()=>{ah(),o()})},[l,o]),g=ce(()=>{l.update(()=>{Me(s).remove(),x(),o()})},[l,s,x,o]),C=ce(()=>{l.update(()=>{sh(),o()})},[l,o]),b=ce(()=>{l.update(()=>{let w=Me(s),N=dh(s),[R]=ra(w,null,null),$=new Set,v=s.getHeaderStyles()^ve.ROW;if(R[N])for(let O=0;O<R[N].length;O++){let D=R[N][O];D?.cell&&($.has(D.cell)||($.add(D.cell),D.cell.setHeaderStyles(v,ve.ROW)))}x(),o()})},[l,s,x,o]),y=ce(()=>{l.update(()=>{let w=Me(s),N=uh(s),[R]=ra(w,null,null),$=new Set,v=s.getHeaderStyles()^ve.COLUMN;if(R)for(let O=0;O<R.length;O++){let D=R?.[O]?.[N];D?.cell&&($.has(D.cell)||($.add(D.cell),D.cell.setHeaderStyles(v,ve.COLUMN)))}x(),o()})},[l,s,x,o]),A=ce(()=>{l.update(()=>{if(s.isAttached()){let w=Me(s);w&&w.setRowStriping(!w.getRowStriping())}x(),o()})},[l,s,x,o]),I=ce(()=>{l.update(()=>{if(s.isAttached()){let w=Me(s);w&&w.setFrozenColumns(w.getFrozenColumns()===0?1:0)}x(),o()})},[l,s,x,o]),L=null;return t&&(a?L=P("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>T(),type:"button",children:P("span",{className:"text",children:"Merge cells"})}):p&&(L=P("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>E(),type:"button",children:P("span",{className:"text",children:"Unmerge cells"})}))),aa(Se("div",{className:"table-action-menu-dropdown",onClick:w=>{w.stopPropagation()},ref:i,children:[L?Se(Fr.Fragment,{children:[L,P("hr",{})]}):null,P("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>A(),type:"button",children:P("span",{className:"text",children:"Toggle Row Striping"})}),P("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>I(),type:"button",children:P("span",{className:"text",children:"Toggle First Column Freeze"})}),P("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>S(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),P("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>S(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>_(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),P("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>_(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>C(),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:()=>g(),type:"button",children:P("span",{className:"text",children:"Delete table"})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-row-header",onClick:()=>b(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&ve.ROW)===ve.ROW?"Remove":"Add"," ","row header"]})}),P("button",{className:"item","data-test-id":"table-column-header",onClick:()=>y(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&ve.COLUMN)===ve.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function Rh({anchorElem:t,cellMerge:e}){let[o]=ia(),r=_o(null),n=_o(null),[l,i]=it(!1),[s,d]=it(null),c=ce(()=>{let a=r.current,m=To(),p=wh(o._window),f=document.activeElement;function h(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),d(null)}if(m==null||a==null)return h();let x=o.getRootElement(),T=null,E=null;if(Or(m)&&x!==null&&p!==null&&x.contains(p.anchorNode)){let _=na(m.anchor.getNode());if(_==null||(E=o.getElementByKey(_.getKey()),E==null||!_.isAttached()))return h();let k=Me(_),g=Ar(k,o.getElementByKey(k.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");T=$r(g),d(_)}else if(Ft(m)){let _=na(m.anchor.getNode());if(!sa(_))throw new Error("TableSelection anchorNode must be a TableCellNode");let k=Me(_),g=Ar(k,o.getElementByKey(k.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");T=$r(g),E=o.getElementByKey(_.getKey())}else if(!f)return h();if(T===null||E===null)return h();let S=!T||!T.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",S),a.classList.toggle("table-cell-action-button-container--inactive",!S),S){let _=E.getBoundingClientRect(),k=t.getBoundingClientRect(),g=_.top-k.top,C=_.right-k.left;a.style.transform=`translate(${C}px, ${g}px)`}},[o,t]);lt(()=>{let a,m=()=>{a=void 0,o.getEditorState().read(c)},p=()=>(a===void 0&&(a=setTimeout(m,0)),!1);return xh(o.registerUpdateListener(p),o.registerCommand(Sh,p,Th),o.registerRootListener((f,h)=>{h&&h.removeEventListener("pointerup",p),f&&(f.addEventListener("pointerup",p),p())}),()=>clearTimeout(a))});let u=_o(s);return lt(()=>{u.current!==s&&i(!1),u.current=s},[u,s]),P("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&Se(Fr.Fragment,{children:[P("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),i(!l)},ref:n,type:"button",children:P(oa,{})}),l&&P(yh,{cellMerge:e,contextRef:n,onClose:()=>i(!1),setIsMenuOpen:i,tableCellNode:s})]})})}var ca=t=>{let e=lh(3),{anchorElem:o}=t,r=ih(),n;return e[0]!==o||e[1]!==r?(n=aa(r?P(Rh,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as Ih}from"react/compiler-runtime";import{jsx as Eo,jsxs as vh}from"react/jsx-runtime";import{useLexicalComposerContext as Mh}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Dh}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Ah,$getTableNodeFromLexicalNodeOrThrow as Pr,$getTableRowIndexFromTableCellNode as $h,$isTableCellNode as ua,$isTableRowNode as Oh,getDOMCellFromTarget as Fh,getTableElement as Ph,TableNode as da}from"@lexical/table";import{calculateZoomLevel as ma,mergeRegister as Bh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Br,isHTMLElement as jh,SKIP_SCROLL_INTO_VIEW_TAG as pa}from"lexical";import*as ha from"react";import{useCallback as Pt,useEffect as jr,useRef as wo,useState as st}from"react";import{createPortal as Hh}from"react-dom";var Uh=33,fa=92;function Wh({editor:t}){let e=wo(null),o=wo(null),r=wo(null),[n,l]=st(!1),i=j(),s=wo(null),[d,c]=st(null),[u,a]=st(null),[m,p]=st(!1),[f,h]=st(null),x=Pt(()=>{a(null),e.current=null,h(null),s.current=null,r.current=null},[]),T=I=>(I.buttons&1)===1;jr(()=>{let I=new Set;return Bh(t.registerMutationListener(da,L=>{for(let[w,N]of L)N==="destroyed"?I.delete(w):I.add(w);l(I.size>0)}),t.registerNodeTransform(da,L=>{if(L.getColWidths())return L;let w=L.getColumnCount(),N=fa;return L.setColWidths(Array(w).fill(N)),L}))},[t]),jr(()=>{if(!n)return;let I=R=>{let $=R.target;if(jh($)){if(f){c({x:R.clientX,y:R.clientY});return}if(p(T(R)),!(o.current&&o.current.contains($))&&e.current!==$){e.current=$;let v=Fh($);v&&u!==v?t.getEditorState().read(()=>{let O=Br(v.elem);if(!O)throw new Error("TableCellResizer: Table cell node not found.");let D=Pr(O),W=Ph(D,t.getElementByKey(D.getKey()));if(!W)throw new Error("TableCellResizer: Table element not found.");e.current=$,r.current=W.getBoundingClientRect(),a(v)},{editor:t}):v==null&&x()}}},L=R=>{p(!0)},w=R=>{p(!1)},N=t.registerRootListener((R,$)=>{$?.removeEventListener("mousemove",I),$?.removeEventListener("mousedown",L),$?.removeEventListener("mouseup",w),R?.addEventListener("mousemove",I),R?.addEventListener("mousedown",L),R?.addEventListener("mouseup",w)});return()=>{N()}},[u,f,t,n,x]);let E=I=>I==="bottom",S=Pt(I=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let L=Br(u.elem);if(!ua(L))throw new Error("TableCellResizer: Table cell node not found.");let w=Pr(L),N=$h(L),R=w.getChildren(),v=L.getColSpan()===w.getColumnCount()?N:N+L.getRowSpan()-1;if(v>=R.length||v<0)throw new Error("Expected table cell to be inside of table row.");let O=R[v];if(!Oh(O))throw new Error("Expected table row");let D=O.getHeight();if(D===void 0){let q=O.getChildren();D=Math.min(...q.map(J=>_(J,t)??1/0))}let W=Math.max(D+I,Uh);O.setHeight(W)},{tag:pa})},[u,t]),_=(I,L)=>L.getElementByKey(I.getKey())?.clientHeight,k=(I,L)=>{let w;return L.forEach(N=>{N.forEach((R,$)=>{R.cell===I&&(w=$)})}),w},g=Pt(I=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let L=Br(u.elem);if(!ua(L))throw new Error("TableCellResizer: Table cell node not found.");let w=Pr(L),[N]=Ah(w,null,null),R=k(L,N);if(R===void 0)throw new Error("TableCellResizer: Table column not found.");let $=w.getColWidths();if(!$)return;let v=$[R];if(v===void 0)return;let O=[...$],D=Math.max(v+I,fa);O[R]=D,w.setColWidths(O)},{tag:pa})},[u,t]),C=Pt(I=>{let L=w=>{if(w.preventDefault(),w.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");if(s.current){let{x:N,y:R}=s.current;if(u===null)return;let $=ma(w.target);if(E(I)){let v=(w.clientY-R)/$;S(v)}else{let v=(w.clientX-N)/$;g(v)}x(),document.removeEventListener("mouseup",L)}};return L},[u,x,g,S]),b=Pt(I=>L=>{if(L.preventDefault(),L.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");s.current={x:L.clientX,y:L.clientY},c(s.current),h(I),document.addEventListener("mouseup",C(I))},[u,C]),[y,A]=st({bottom:null,left:null,right:null,top:null});return jr(()=>{if(u){let{height:I,left:L,top:w,width:N}=u.elem.getBoundingClientRect(),R=ma(u.elem),$=10,v={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${$}px`,left:`${window.scrollX+L}px`,top:`${window.scrollY+w+I-$/2}px`,width:`${N}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${I}px`,left:`${window.scrollX+L+N-$/2}px`,top:`${window.scrollY+w}px`,width:`${$}px`}},O=r.current;f&&d&&O&&(E(f)?(v[f].left=`${window.scrollX+O.left}px`,v[f].top=`${window.scrollY+d.y/R}px`,v[f].height="3px",v[f].width=`${O.width}px`):(v[f].top=`${window.scrollY+O.top}px`,v[f].left=`${window.scrollX+d.x/R}px`,v[f].width="3px",v[f].height=`${O.height}px`),v[f].backgroundColor="#adf"),A(v)}else A({bottom:null,left:null,right:null,top:null})},[u,f,d]),Eo("div",{ref:o,children:u!=null&&!m&&vh(ha.Fragment,{children:[Eo("div",{className:`${i.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:b("right"),style:y.right||void 0}),Eo("div",{className:`${i.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:b("bottom"),style:y.bottom||void 0})]})})}var ga=()=>{let t=Ih(3),[e]=Mh(),o=Dh(),r;return t[0]!==e||t[1]!==o?(r=o?Hh(Eo(Wh,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=r):r=t[2],r};import{c as Yh}from"react/compiler-runtime";import{jsx as Hr,jsxs as qh,Fragment as Qh}from"react/jsx-runtime";import{useLexicalComposerContext as eg}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Ea}from"@lexical/react/useLexicalEditable";import{$getTableAndElementByKey as tg,$getTableColumnIndexFromTableCellNode as og,$getTableRowIndexFromTableCellNode as rg,$insertTableColumnAtSelection as ng,$insertTableRowAtSelection as lg,$isTableCellNode as ig,$isTableNode as ba,getTableElement as sg,TableNode as ag}from"@lexical/table";import{$findMatchingParent as cg,mergeRegister as ug}from"@lexical/utils";import{$getNearestNodeFromDOMNode as ka,isHTMLElement as dg}from"lexical";import{useEffect as _a,useMemo as mg,useRef as Ta,useState as So}from"react";import"react";import{createPortal as pg}from"react-dom";import{c as Xh}from"react/compiler-runtime";import{useEffect as zh,useRef as Zh}from"react";var Gh="Expected a function",Vh=Math.max,Kh=Math.min;function Jh(t,e,o){let r,n,l=0,i,s=!1,d=!1,c,u,a,m=!0;if(typeof t!="function")throw new TypeError(Gh);e=e||0,typeof o=="object"&&(s=!!o.leading,d="maxWait"in o,c=d?Vh(o.maxWait||0,e):c,m="trailing"in o?!!o.trailing:m);function p(g){let C=r,b=i;return r=i=void 0,l=g,u=t.apply(b,C),u}function f(g){return l=g,a=setTimeout(T,e),s?p(g):u}function h(g){let C=g-n,b=g-l,y=e-C;return d?Kh(y,c-b):y}function x(g){let C=g-n,b=g-l;return n===void 0||C>=e||C<0||d&&b>=c}function T(){let g=Date.now();if(x(g))return E(g);a=setTimeout(T,h(g))}function E(g){return a=void 0,m&&r?p(g):(r=i=void 0,u)}function S(){a!==void 0&&clearTimeout(a),l=0,r=n=i=a=void 0}function _(){return a===void 0?u:E(Date.now())}function k(){let g=Date.now(),C=x(g);if(r=arguments,i=this,n=g,C){if(a===void 0)return f(n);if(d)return clearTimeout(a),a=setTimeout(T,e),p(n)}return a===void 0&&(a=setTimeout(T,e)),u}return k.cancel=S,k.flush=_,k}var xa=Jh;function Ca(t,e,o){let r=Xh(6),n=Zh(null),l,i;r[0]!==t||r[1]!==o||r[2]!==e?(l=()=>(n.current=xa(t,e,{maxWait:o}),()=>{n.current?.cancel()}),i=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=l,r[4]=i):(l=r[3],i=r[4]),zh(l,i);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...c)=>{let u=c;n.current&&n.current(...u)},r[5]=s):s=r[5],s}var wa=20;function fg({anchorElem:t}){let[e]=eg(),o=Ea(),r=j(),[n,l]=So(!1),[i,s]=So(!1),[d,c]=So(!1),[u,a]=So({}),m=Ta(new Set),p=Ta(null),f=Ca(T=>{let{isOutside:E,tableDOMNode:S}=hg(T,r.editorConfig?.lexical);if(E){l(!1),s(!1);return}if(!S)return;p.current=S;let _=null,k=null,g=null;if(e.getEditorState().read(()=>{let v=ka(S);if(ig(v)){let O=cg(v,D=>ba(D));if(!ba(O))return;if(g=sg(O,e.getElementByKey(O.getKey())),g){let D=O.getChildrenSize(),W=O.getChildAtIndex(0)?.getChildrenSize(),q=rg(v),J=og(v);q===D-1?_=v:J===W-1&&(k=v)}}},{editor:e}),!g)return;let C=g.parentElement;if(!C)return;let{bottom:b,height:y,left:A,right:I,width:L,y:w}=g.getBoundingClientRect(),N=!1;C&&C.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(N=C.scrollWidth>C.clientWidth);let{left:R,y:$}=t.getBoundingClientRect();_?(s(!1),l(!0),a({height:wa,left:N&&C?C.offsetLeft:A-R,top:b-$+5,width:N&&C?C.offsetWidth:L})):k&&(s(!0),l(!1),a({height:y,left:I-R+5,top:w-$,width:wa}))},50,250),h=mg(()=>new ResizeObserver(()=>{l(!1),s(!1)}),[]);_a(()=>{if(d)return document.addEventListener("mousemove",f),()=>{l(!1),s(!1),document.removeEventListener("mousemove",f)}},[d,f]),_a(()=>ug(e.registerMutationListener(ag,T=>{e.getEditorState().read(()=>{let E=!1;for(let[S,_]of T)switch(_){case"created":{m.current.add(S),E=!0;break}case"destroyed":{m.current.delete(S),E=!0;break}default:break}if(E){h.disconnect();for(let S of m.current){let{tableElement:_}=tg(S);h.observe(_)}c(m.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,h]);let x=T=>{e.update(()=>{p.current&&(ka(p.current)?.selectEnd(),T?(lg(),l(!1)):(ng(),s(!1)))})};return o?qh(Qh,{children:[n&&Hr("button",{"aria-label":"Add Row",className:r.editorConfig.lexical.theme.tableAddRows,onClick:()=>x(!0),style:{...u},type:"button"}),i&&Hr("button",{"aria-label":"Add Column",className:r.editorConfig.lexical.theme.tableAddColumns,onClick:()=>x(!1),style:{...u},type:"button"})]}):null}function hg(t,e){let o=t.target;if(dg(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function Sa(t){let e=Yh(2),{anchorElem:o}=t,r=o===void 0?document.body:o;if(!Ea())return null;let l;return e[0]!==r?(l=pg(Hr(fg,{anchorElem:r}),r),e[0]=r,e[1]=l):l=e[1],l}import{c as gg}from"react/compiler-runtime";import{jsx as Ur,jsxs as xg}from"react/jsx-runtime";import{useLexicalComposerContext as Cg}from"@lexical/react/LexicalComposerContext";import{TablePlugin as bg}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as kg,TableCellNode as _g,TableNode as Tg,TableRowNode as wg}from"@lexical/table";import{mergeRegister as Eg}from"@lexical/utils";import{formatDrawerSlug as Sg,useEditDepth as Lg}from"@payloadcms/ui";import{$getSelection as Ng,$isRangeSelection as yg,COMMAND_PRIORITY_EDITOR as Rg,createCommand as Ig}from"lexical";import{createContext as vg,use as Mg,useEffect as Dg,useMemo as Ag,useState as $g}from"react";import*as La from"react";var Lo=Ig("OPEN_EMBED_DRAWER_COMMAND"),Na=vg({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function ya({children:t}){let[e,o]=$g({cellEditorConfig:null,cellEditorPlugins:null});return Ur(Na,{value:Ag(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Ra=()=>{let t=gg(16),[e]=Cg(),o=Mg(Na),r=Lg(),{fieldProps:n,uuid:l}=j(),{schemaPath:i}=n,s="lexical-table-create-"+l,d;t[0]!==r||t[1]!==s?(d=Sg({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=d):d=t[2];let c=d,{toggleDrawer:u}=he(c,!0),a;t[3]!==e||t[4]!==u?(a=()=>{if(!e.hasNodes([Tg,wg,_g]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return Eg(e.registerCommand(Lo,()=>{let h=null;return e.getEditorState().read(()=>{let x=Ng();yg(x)&&(h=x)}),h&&u(),!0},Rg))},t[3]=e,t[4]=u,t[5]=a):a=t[5];let m;t[6]!==o||t[7]!==e||t[8]!==u?(m=[o,e,u],t[6]=o,t[7]=e,t[8]=u,t[9]=m):m=t[9],Dg(a,m);let p;t[10]!==e?(p=(h,x)=>{!x.columns||!x.rows||e.dispatchCommand(kg,{columns:String(x.columns),rows:String(x.rows)})},t[10]=e,t[11]=p):p=t[11];let f;return t[12]!==c||t[13]!==i||t[14]!==p?(f=xg(La.Fragment,{children:[Ur(ft,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:i,schemaPathSuffix:"fields"}),Ur(bg,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=i,t[14]=p,t[15]=f):f=t[15],f};var Bg=M({markdownTransformers:[ea],nodes:[Fg,Og,Pg],plugins:[{Component:Ra,position:"normal"},{Component:ga,position:"normal"},{Component:ca,position:"floatingAnchorElem"},{Component:Sa,position:"floatingAnchorElem"}],providers:[ya],slashMenu:{groups:[z([{Icon:Ir,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Lo,{})}}])]},toolbarFixed:{groups:[Ce([{ChildComponent:Ir,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Lo,{})}}])]}});import{$isNodeSelection as kx}from"lexical";import{jsx as Wr,jsxs as jg}from"react/jsx-runtime";import"react";var Gr=()=>jg("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:[Wr("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"}),Wr("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"}),Wr("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Aa}from"react/jsx-runtime";import $a from"bson-objectid";import{$applyNodeReplacement as Vg}from"lexical";import*as Oa from"react";import Hg from"bson-objectid";function No(t,e){if(t.hasAttribute("data-lexical-pending-upload-form-id")){let r=t.getAttribute("data-lexical-pending-upload-form-id");if(r!=null)return{node:e({data:{pending:{formID:r,src:t.getAttribute("src")||""}}})}}if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let r=t.getAttribute("data-lexical-upload-id"),n=t.getAttribute("data-lexical-upload-relation-to");if(r!=null&&n!=null)return{node:e({data:{fields:{},relationTo:n,value:r}})}}return{node:e({data:{pending:{formID:new Hg.default().toHexString(),src:t.getAttribute("src")||""}}})}}import{DecoratorBlockNode as Ug}from"@lexical/react/LexicalDecoratorBlockNode.js";import va from"bson-objectid";import{$applyNodeReplacement as Wg}from"lexical";var Bt=class extends Ug{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:o=>No(o,Ia),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new va.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=Ia({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return null}exportDOM(){let e=document.createElement("img"),o=this.__data;return o.pending?(e.setAttribute("data-lexical-pending-upload-form-id",String(o?.pending?.formID)),e.setAttribute("src",o?.pending?.src||"")):(e.setAttribute("data-lexical-upload-id",String(o?.value)),e.setAttribute("data-lexical-upload-relation-to",o?.relationTo)),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function Ia({data:t}){return t?.id||(t.id=new va.default().toHexString()),Wg(new Bt({data:t}))}import{jsx as Ma}from"react/jsx-runtime";import{ShimmerEffect as Gg}from"@payloadcms/ui";var Da=()=>Ma("div",{className:"lexical-upload",children:Ma(Gg,{height:"95px",width:"203px"})});var Kg=Oa.lazy(()=>import("./component-WT25HAJA.js").then(t=>({default:t.UploadComponent}))),le=class extends Bt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:o=>No(o,De),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new $a.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=De({data:o});return r.setFormat(e.format),r}decorate(){return this.__data.pending?Aa(Da,{}):Aa(Kg,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function De({data:t}){return t?.id||(t.id=new $a.default().toHexString()),Vg(new le({data:t}))}function at(t){return t instanceof le}import{c as ex}from"react/compiler-runtime";import{jsx as tx}from"react/jsx-runtime";import{useLexicalComposerContext as ox}from"@lexical/react/LexicalComposerContext.js";import{$dfsIterator as Ja,$insertNodeToNearestRoot as Jr,mergeRegister as rx}from"@lexical/utils";import{useBulkUpload as nx,useEffectEvent as lx,useModal as ix}from"@payloadcms/ui";import Xr from"bson-objectid";import{$createRangeSelection as sx,$getPreviousSelection as Ua,$getSelection as Wa,$isParagraphNode as zr,$isRangeSelection as Ga,$setSelection as ax,COMMAND_PRIORITY_EDITOR as cx,COMMAND_PRIORITY_LOW as Va,createCommand as ux,DROP_COMMAND as dx,getDOMSelectionFromTarget as mx,isHTMLElement as Ka,PASTE_COMMAND as px}from"lexical";import{useEffect as fx}from"react";import{c as Fa}from"react/compiler-runtime";import{jsx as Vr}from"react/jsx-runtime";import{useLexicalComposerContext as Pa}from"@lexical/react/LexicalComposerContext.js";import{toast as Jg}from"@payloadcms/ui";import{$getNodeByKey as Xg,COMMAND_PRIORITY_EDITOR as Ba}from"lexical";import{useEffect as ja,useState as zg}from"react";var Zg=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=Xg(o);n&&n.replace(De({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Kr,{fields:null,relationTo:e,value:r})},Yg=t=>{let e=Fa(13),{enabledCollectionSlugs:o}=t,[r]=Pa(),[n,l]=zg(null),i;e[0]!==o?(i={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=i):i=e[1];let{closeListDrawer:s,ListDrawer:d,openListDrawer:c}=At(i),u,a;e[2]!==r||e[3]!==c?(u=()=>r.registerCommand(Xe,h=>(l(h?.replace?h?.replace.nodeKey:null),c(),!0),Ba),a=[r,c],e[2]=r,e[3]=c,e[4]=u,e[5]=a):(u=e[4],a=e[5]),ja(u,a);let m;e[6]!==s||e[7]!==r||e[8]!==n?(m=h=>{let{collectionSlug:x,doc:T}=h;s(),Zg({editor:r,relationTo:x,replaceNodeKey:n,value:T.id})},e[6]=s,e[7]=r,e[8]=n,e[9]=m):m=e[9];let p=m,f;return e[10]!==d||e[11]!==p?(f=Vr(d,{onSelect:p}),e[10]=d,e[11]=p,e[12]=f):f=e[12],f},qg=()=>{let t=Fa(3),[e]=Pa(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Xe,Qg,Ba),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ja(o,r),null},Ha=({enabledCollectionSlugs:t})=>t?.length?Vr(Yg,{enabledCollectionSlugs:t}):Vr(qg,{});function Qg(){return Jg.error("No upload collections enabled"),!0}function hx(t){let e=t.target;return!!(Ka(e)&&!e.closest("code, span.editor-image")&&Ka(e.parentElement)&&e.parentElement.closest("div.ContentEditable__root"))}function gx(t){let e,o=mx(t.target);if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(t.clientX,t.clientY);else if(t.rangeParent&&o!==null)o.collapse(t.rangeParent,t.rangeOffset||0),e=o.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}var Kr=ux("INSERT_UPLOAD_COMMAND"),Xa=t=>{let e=ex(21),{clientProps:o}=t,[r]=ox(),n=o?.disabledCollections,l=o?.enabledCollections,i;e[0]!==n||e[1]!==l?(i={collectionSlugsBlacklist:n,collectionSlugsWhitelist:l,uploads:!0},e[0]=n,e[1]=l,e[2]=i):i=e[2];let{enabledCollectionSlugs:s}=fo(i),{drawerSlug:d,setCollectionSlug:c,setInitialForms:u,setOnCancel:a,setOnSuccess:m,setSelectableCollections:p}=nx(),{isModalOpen:f,openModal:h}=ix(),x;e[3]!==d||e[4]!==r||e[5]!==s||e[6]!==f||e[7]!==h||e[8]!==c||e[9]!==u||e[10]!==a||e[11]!==m||e[12]!==p?(x=k=>{let{files:g}=k;if(g?.length!==0&&(u(C=>[...C??[],...g.map(xx)]),!f(d))){if(!s.length||!s[0])return;c(s[0]),p(s),a(()=>{r.update(Cx)}),m(C=>{let b=new Map(C.map(bx));r.update(()=>{for(let y of Ja()){let A=y.node;if(at(A)){let I=A.getData();if(I?.pending){let L=b.get(I.pending?.formID);L&&A.replace(De({data:{id:new Xr.default().toHexString(),fields:{},relationTo:L.collectionSlug,value:L.doc.id}}))}}}})}),h(d)}},e[3]=d,e[4]=r,e[5]=s,e[6]=f,e[7]=h,e[8]=c,e[9]=u,e[10]=a,e[11]=m,e[12]=p,e[13]=x):x=e[13];let T=lx(x),E;e[14]!==r||e[15]!==T?(E=()=>{if(!r.hasNodes([le]))throw new Error("UploadPlugin: UploadNode not registered on editor");return rx(r.registerNodeTransform(le,k=>{let g=k.getData();if(!g?.pending)return;(async function(){let y=null,A=g?.pending?.src,I=g?.pending?.formID;if(A?.startsWith("data:")){let L=A.match(/data:(image\/[a-zA-Z]+);base64,/),w=L?L[1]:"image/png",N=A.replace(/^data:image\/[a-zA-Z]+;base64,/,""),R=atob(N),$=new Array(R.length);for(let D=0;D<R.length;D++)$[D]=R.charCodeAt(D);let v=new Uint8Array($);y={alt:void 0,file:new File([v],"pasted-image."+w?.split("/")[1],{type:w}),formID:I}}else if(A?.startsWith("http")||A?.startsWith("https")){let w=await(await fetch(A)).blob(),N=A.split("/").pop()||"pasted-image"+w.type.split("/")[1];y={alt:void 0,file:new File([w],N,{type:w.type}),formID:I}}y&&T({files:[y]})})()}),r.registerCommand(Kr,k=>(r.update(()=>{let g=Wa()||Ua();if(Ga(g)){let C=De({data:{id:k.id,fields:k.fields,relationTo:k.relationTo,value:k.value}}),{focus:b}=g,y=b.getNode();Jr(C),zr(y)&&!y.__first&&y.remove()}}),!0),cx),r.registerCommand(px,k=>{if(!(k instanceof ClipboardEvent))return!1;let g=k.clipboardData;if(!g?.types?.length||g?.types?.includes("text/html"))return!1;let C=[];return g?.files?.length&&Array.from(g.files).forEach(b=>{C.push({alt:"",file:b,formID:new Xr.default().toHexString()})}),C.length?(r.update(()=>{let b=Wa()||Ua();if(Ga(b))for(let y of C){let A=new le({data:{pending:{formID:y.formID,src:URL.createObjectURL(y.file)}}}),{focus:I}=b,L=I.getNode();Jr(A),zr(L)&&!L.__first&&L.remove()}}),T({files:C}),!0):!1},Va),r.registerCommand(dx,k=>{if(!(k instanceof DragEvent))return!1;let g=k.dataTransfer;if(!g?.types?.length)return!1;let C=[];return g?.files?.length&&Array.from(g.files).forEach(b=>{C.push({alt:"",file:b,formID:new Xr.default().toHexString()})}),C.length?(k.preventDefault(),k.stopPropagation(),r.update(()=>{if(hx(k)){let b=gx(k),y=sx();b!=null&&y.applyDOMRange(b),ax(y);for(let A of C){let I=new le({data:{pending:{formID:A.formID,src:URL.createObjectURL(A.file)}}}),{focus:L}=y,w=L.getNode();Jr(I),zr(w)&&!w.__first&&w.remove()}}}),T({files:C}),!0):!1},Va))},e[14]=r,e[15]=T,e[16]=E):E=e[16];let S;e[17]!==r?(S=[r],e[17]=r,e[18]=S):S=e[18],fx(E,S);let _;return e[19]!==s?(_=tx(Ha,{enabledCollectionSlugs:s}),e[19]=s,e[20]=_):_=e[20],_};function xx(t){return{file:t.file,formID:t.formID}}function Cx(){for(let t of Ja()){let e=t.node;at(e)&&e.getData()?.pending&&e.remove()}}function bx(t){return[t.formID,t]}var _x=M({nodes:[le],plugins:[{Component:Xa,position:"normal"}],slashMenu:{groups:[z([{Icon:Gr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Xe,{replace:!1})}}])]},toolbarFixed:{groups:[Ce([{ChildComponent:Gr,isActive:({selection:t})=>{if(!kx(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return at(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Xe,{replace:!1})}}])]}});import{c as wx}from"react/compiler-runtime";import{jsx as Yr}from"react/jsx-runtime";import{ShimmerEffect as Ex,useConfig as Sx}from"@payloadcms/ui";import{lazy as Lx,Suspense as Nx,useEffect as yx,useState as Rx}from"react";var za={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",hrSelected:"LexicalEditorTheme__hrSelected",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var yo={namespace:"lexical",theme:za};function Za({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:l}){for(let c of l.features)if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");l.features=l.features.sort((c,u)=>c.clientFeatureProps.order-u.clientFeatureProps.order);let i=new Map;for(let c of l.features)i.set(c.clientFeatureProps.featureKey,c);let s=new Map,d=0;for(let c of l.features){let u=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:i,field:r,resolvedFeatures:s,schemaPath:n,unSanitizedEditorConfig:l}):c.feature;u.key=c.clientFeatureProps.featureKey,u.order=d,s.set(c.clientFeatureProps.featureKey,u),d++}return s}import{deepMerge as Tx}from"payload/shared";var Ya=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}},o={};if(t.forEach(r=>{r.key==="toolbarFixed"&&r.sanitizedClientFeatureProps?.customGroups&&(o={...o,...r.sanitizedClientFeatureProps.customGroups})}),!t?.size)return e;t.forEach(r=>{if(r.providers?.length&&(e.providers=e.providers.concat(r.providers)),r.enableFormats?.length&&e.enabledFormats.push(...r.enableFormats),r.nodes?.length)for(let n of r.nodes)e.nodes.push(n);if(r.plugins?.length&&r.plugins.forEach((n,l)=>{e.plugins?.push({clientProps:r.sanitizedClientFeatureProps,Component:n.Component,key:r.key+l,position:n.position})}),r.toolbarInline?.groups?.length)for(let n of r.toolbarInline.groups){let l=e.toolbarInline.groups.find(i=>i.key===n.key);l?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarInline?.groups.push(l)}if(r.toolbarFixed?.groups?.length)for(let n of r.toolbarFixed.groups){let l=e.toolbarFixed.groups.find(i=>i.key===n.key);l?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarFixed?.groups.push(l)}if(r.slashMenu?.groups){r.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(r.slashMenu.dynamicGroups));for(let n of r.slashMenu.groups){let l=e.slashMenu.groups.find(i=>i.key===n.key);l?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.slashMenu.groups.push(l)}}if(r.markdownTransformers?.length)for(let n of r.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(r.key)}),Object.keys(o).length>0&&(e.toolbarFixed.groups=e.toolbarFixed.groups.map(r=>{let n=o[r.key];return n?Tx(r,n):r})),e.toolbarInline.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let r of e.toolbarInline.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);for(let r of e.toolbarFixed.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);return e};function Zr(t,e,o){return{admin:o,features:Ya(t),lexical:e,resolvedFeatureMap:t}}var Ix=Lx(()=>import("./Field-CJFETHA3.js").then(t=>({default:t.RichText}))),vx=t=>{let e=wx(16),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:l,field:i,lexicalEditorConfig:s,schemaPath:d}=t,c;e[0]!==o?(c=o===void 0?{}:o,e[0]=o,e[1]=c):c=e[1];let u=c,a=s===void 0?yo:s,{config:m}=Sx(),[p,f]=Rx(null),h,x;e[2]!==u||e[3]!==r||e[4]!==m||e[5]!==n||e[6]!==l||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==d?(h=()=>{if(p)return;let E=[];for(let[k,g]of Object.entries(r))g.clientFeatureProvider&&E.push(g.clientFeatureProvider(g.clientFeatureProps));let S=a||yo,_=Za({config:m,featureClientImportMap:n,featureClientSchemaMap:l,field:i,schemaPath:d??i.name,unSanitizedEditorConfig:{features:E,lexical:S}});f(Zr(_,S,u))},x=[a,u,p,r,n,l,i,m,d],e[2]=u,e[3]=r,e[4]=m,e[5]=n,e[6]=l,e[7]=i,e[8]=p,e[9]=a,e[10]=d,e[11]=h,e[12]=x):(h=e[11],x=e[12]),yx(h,x);let T;return e[13]!==p||e[14]!==t?(T=Yr(Nx,{fallback:Yr(Ex,{height:"35vh"}),children:p&&Yr(Ix,{...t,editorConfig:p})}),e[13]=p,e[14]=t,e[15]=T):T=e[15],T};function Mx(t){return t instanceof HTMLElement}function Dx(...t){return t.filter(Boolean).join(" ")}var Ro=new WeakMap;function qa(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function Io(t,e){let o=Ro.get(t);if(o===void 0){let r=new Set,n=i=>{o!==void 0&&(o.start=qa(i))},l=i=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let d=qa(i);for(let c of r)d!==null&&c([d[0]-s[0],d[1]-s[1]],i)};t.addEventListener("touchstart",n),t.addEventListener("touchend",l),o={handleTouchend:l,handleTouchstart:n,listeners:r,start:null},Ro.set(t,o)}return o.listeners.add(e),()=>{Ax(t,e)}}function Ax(t,e){let o=Ro.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(Ro.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function $x(t,e){return Io(t,(o,r)=>{let[n,l]=o;n<0&&-n>Math.abs(l)&&e(n,r)})}function Ox(t,e){return Io(t,(o,r)=>{let[n,l]=o;n>0&&n>Math.abs(l)&&e(n,r)})}function Fx(t,e){return Io(t,(o,r)=>{let[n,l]=o;l<0&&-l>Math.abs(n)&&e(n,r)})}function Px(t,e){return Io(t,(o,r)=>{let[n,l]=o;l>0&&l>Math.abs(n)&&e(n,r)})}import{c as Bx}from"react/compiler-runtime";import{jsx as jx}from"react/jsx-runtime";import"react";var Hx=()=>{let t=Bx(2),{EditButton:e}=ge(),o;return t[0]!==e?(o=e?jx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Ux}from"react/compiler-runtime";import{jsx as Wx}from"react/jsx-runtime";import"react";var Gx=()=>{let t=Ux(2),{RemoveButton:e}=ge(),o;return t[0]!==e?(o=e?Wx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Vx}from"react/compiler-runtime";import{jsx as Kx}from"react/jsx-runtime";import"react";var Jx=()=>{let t=Vx(2),{Label:e}=ge(),o;return t[0]!==e?(o=e?Kx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Xx}from"react/compiler-runtime";import{jsx as zx}from"react/jsx-runtime";import"react";var Zx=t=>{let e=Xx(3),{children:o}=t,{InlineBlockContainer:r}=ge(),n;return e[0]!==r||e[1]!==o?(n=r?zx(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{jsx as Yx}from"react/jsx-runtime";import"react";var qx=t=>{let{children:e,...o}=t,{BlockCollapsible:r}=xe();return r?Yx(r,{...o,children:e}):null};import{c as Qx}from"react/compiler-runtime";import{jsx as eC}from"react/jsx-runtime";import"react";var tC=()=>{let t=Qx(2),{EditButton:e}=xe(),o;return t[0]!==e?(o=e?eC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as oC}from"react/compiler-runtime";import{jsx as rC}from"react/jsx-runtime";import"react";var nC=()=>{let t=oC(2),{RemoveButton:e}=xe(),o;return t[0]!==e?(o=e?rC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as lC}from"qs-esm";var iC=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:l,collectionSlug:i,select:s})=>{let d=lC({depth:e??0,draft:o??!1,locale:r,select:s},{addQueryPrefix:!0});return await fetch(`${t}/${i}/${l}${d}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(u=>u.json())};var Qa={customEndRegex:{optional:!0,regExp:/[ \t]*```$/},customStartRegex:/^[ \t]*```(\w+)?/,doNotTrimChildren:!0,export:({fields:t})=>!t.code.includes(`
|
|
60
|
+
`);let o=X1(ko.NO_STATUS);return Ht(t,e,o),o},qs=(t,e)=>{let o=t.match(Qs);return!o||!o[1]?null:o[1].split("|").map(r=>ta(r,e))};import{c as lh}from"react/compiler-runtime";import{jsx as P,jsxs as Se}from"react/jsx-runtime";import{useLexicalComposerContext as ia}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as ih}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as ra,$deleteTableColumnAtSelection as sh,$deleteTableRowAtSelection as ah,$getNodeTriplet as ch,$getTableCellNodeFromLexicalNode as na,$getTableColumnIndexFromTableCellNode as uh,$getTableNodeFromLexicalNodeOrThrow as Me,$getTableRowIndexFromTableCellNode as dh,$insertTableColumnAtSelection as mh,$insertTableRowAtSelection as ph,$isTableCellNode as sa,$isTableSelection as Ft,$mergeCells as fh,$unmergeCell as hh,getTableElement as Ar,getTableObserverFromTableElement as $r,TableCellHeaderStates as ve,TableCellNode as gh}from"@lexical/table";import{mergeRegister as xh}from"@lexical/utils";import{useScrollInfo as Ch}from"@payloadcms/ui";import{$getSelection as To,$isElementNode as bh,$isRangeSelection as Or,$isTextNode as kh,$setSelection as _h,COMMAND_PRIORITY_CRITICAL as Th,getDOMSelection as wh,isDOMNode as Eh,SELECTION_CHANGE_COMMAND as Sh}from"lexical";import*as Fr from"react";import{useCallback as ce,useEffect as lt,useRef as _o,useState as it}from"react";import{createPortal as aa}from"react-dom";import{jsx as Dr,jsxs as nh}from"react/jsx-runtime";import"react";var oa=()=>nh("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Dr("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"}),Dr("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"}),Dr("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 la(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function Lh(){let t=To();if(Or(t)&&!t.isCollapsed()||Ft(t)&&!t.anchor.is(t.focus)||!Or(t)&&!Ft(t))return!1;let[e]=ch(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function Nh(t){let e=t.getLastDescendant();kh(e)?e.select():bh(e)?e.selectEnd():e!==null&&e.selectNext()}function yh({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[l]=ia(),i=_o(null),[s,d]=it(n),[c,u]=it({columns:1,rows:1}),[a,m]=it(!1),[p,f]=it(!1),{y:h}=Ch();lt(()=>l.registerMutationListener(gh,w=>{w.get(s.getKey())==="updated"&&l.getEditorState().read(()=>{d(s.getLatest())})},{skipInitialization:!0}),[l,s]),lt(()=>{l.getEditorState().read(()=>{let w=To();if(Ft(w)){let N=la(w);u(la(w)),m(N.columns>1||N.rows>1)}f(Lh())})},[l]),lt(()=>{let w=e.current,N=i.current,R=l.getRootElement();if(w!=null&&N!=null&&R!=null){let $=R.getBoundingClientRect(),v=w.getBoundingClientRect();N.style.opacity="1";let O=N.getBoundingClientRect(),D=5,W=v.right+D;if(W+O.width>window.innerWidth||W+O.width>$.right){let J=v.left-O.width-D;W=(J<0?D:J)+window.pageXOffset}N.style.left=`${W+window.pageXOffset}px`;let q=v.top;if(q+O.height>window.innerHeight){let J=v.bottom-O.height;q=J<0?D:J}N.style.top=`${q}px`}},[e,i,l,h]),lt(()=>{function w(N){i.current!=null&&e.current!=null&&Eh(N.target)&&!i.current.contains(N.target)&&!e.current.contains(N.target)&&r(!1)}return window.addEventListener("click",w),()=>window.removeEventListener("click",w)},[r,e]);let x=ce(()=>{l.update(()=>{if(s.isAttached()){let w=Me(s),N=Ar(w,l.getElementByKey(w.getKey()));if(N===null)throw new Error("Expected to find tableElement in DOM");let R=$r(N);R!==null&&R.$clearHighlight(),w.markDirty(),d(s.getLatest())}_h(null)})},[l,s]),T=()=>{l.update(()=>{let w=To();if(!Ft(w))return;let R=w.getNodes().filter(sa),$=fh(R);$&&(Nh($),o())})},E=()=>{l.update(()=>{hh()})},S=ce(w=>{l.update(()=>{for(let N=0;N<c.rows;N++)ph(w);o()})},[l,o,c.rows]),_=ce(w=>{l.update(()=>{for(let N=0;N<c.columns;N++)mh(w);o()})},[l,o,c.columns]),k=ce(()=>{l.update(()=>{ah(),o()})},[l,o]),g=ce(()=>{l.update(()=>{Me(s).remove(),x(),o()})},[l,s,x,o]),C=ce(()=>{l.update(()=>{sh(),o()})},[l,o]),b=ce(()=>{l.update(()=>{let w=Me(s),N=dh(s),[R]=ra(w,null,null),$=new Set,v=s.getHeaderStyles()^ve.ROW;if(R[N])for(let O=0;O<R[N].length;O++){let D=R[N][O];D?.cell&&($.has(D.cell)||($.add(D.cell),D.cell.setHeaderStyles(v,ve.ROW)))}x(),o()})},[l,s,x,o]),y=ce(()=>{l.update(()=>{let w=Me(s),N=uh(s),[R]=ra(w,null,null),$=new Set,v=s.getHeaderStyles()^ve.COLUMN;if(R)for(let O=0;O<R.length;O++){let D=R?.[O]?.[N];D?.cell&&($.has(D.cell)||($.add(D.cell),D.cell.setHeaderStyles(v,ve.COLUMN)))}x(),o()})},[l,s,x,o]),A=ce(()=>{l.update(()=>{if(s.isAttached()){let w=Me(s);w&&w.setRowStriping(!w.getRowStriping())}x(),o()})},[l,s,x,o]),I=ce(()=>{l.update(()=>{if(s.isAttached()){let w=Me(s);w&&w.setFrozenColumns(w.getFrozenColumns()===0?1:0)}x(),o()})},[l,s,x,o]),L=null;return t&&(a?L=P("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>T(),type:"button",children:P("span",{className:"text",children:"Merge cells"})}):p&&(L=P("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>E(),type:"button",children:P("span",{className:"text",children:"Unmerge cells"})}))),aa(Se("div",{className:"table-action-menu-dropdown",onClick:w=>{w.stopPropagation()},ref:i,children:[L?Se(Fr.Fragment,{children:[L,P("hr",{})]}):null,P("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>A(),type:"button",children:P("span",{className:"text",children:"Toggle Row Striping"})}),P("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>I(),type:"button",children:P("span",{className:"text",children:"Toggle First Column Freeze"})}),P("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>S(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),P("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>S(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>_(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),P("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>_(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>C(),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:()=>g(),type:"button",children:P("span",{className:"text",children:"Delete table"})}),P("hr",{}),P("button",{className:"item","data-test-id":"table-row-header",onClick:()=>b(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&ve.ROW)===ve.ROW?"Remove":"Add"," ","row header"]})}),P("button",{className:"item","data-test-id":"table-column-header",onClick:()=>y(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&ve.COLUMN)===ve.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function Rh({anchorElem:t,cellMerge:e}){let[o]=ia(),r=_o(null),n=_o(null),[l,i]=it(!1),[s,d]=it(null),c=ce(()=>{let a=r.current,m=To(),p=wh(o._window),f=document.activeElement;function h(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),d(null)}if(m==null||a==null)return h();let x=o.getRootElement(),T=null,E=null;if(Or(m)&&x!==null&&p!==null&&x.contains(p.anchorNode)){let _=na(m.anchor.getNode());if(_==null||(E=o.getElementByKey(_.getKey()),E==null||!_.isAttached()))return h();let k=Me(_),g=Ar(k,o.getElementByKey(k.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");T=$r(g),d(_)}else if(Ft(m)){let _=na(m.anchor.getNode());if(!sa(_))throw new Error("TableSelection anchorNode must be a TableCellNode");let k=Me(_),g=Ar(k,o.getElementByKey(k.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");T=$r(g),E=o.getElementByKey(_.getKey())}else if(!f)return h();if(T===null||E===null)return h();let S=!T||!T.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",S),a.classList.toggle("table-cell-action-button-container--inactive",!S),S){let _=E.getBoundingClientRect(),k=t.getBoundingClientRect(),g=_.top-k.top,C=_.right-k.left;a.style.transform=`translate(${C}px, ${g}px)`}},[o,t]);lt(()=>{let a,m=()=>{a=void 0,o.getEditorState().read(c)},p=()=>(a===void 0&&(a=setTimeout(m,0)),!1);return xh(o.registerUpdateListener(p),o.registerCommand(Sh,p,Th),o.registerRootListener((f,h)=>{h&&h.removeEventListener("pointerup",p),f&&(f.addEventListener("pointerup",p),p())}),()=>clearTimeout(a))});let u=_o(s);return lt(()=>{u.current!==s&&i(!1),u.current=s},[u,s]),P("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&Se(Fr.Fragment,{children:[P("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),i(!l)},ref:n,type:"button",children:P(oa,{})}),l&&P(yh,{cellMerge:e,contextRef:n,onClose:()=>i(!1),setIsMenuOpen:i,tableCellNode:s})]})})}var ca=t=>{let e=lh(3),{anchorElem:o}=t,r=ih(),n;return e[0]!==o||e[1]!==r?(n=aa(r?P(Rh,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as Ih}from"react/compiler-runtime";import{jsx as Eo,jsxs as vh}from"react/jsx-runtime";import{useLexicalComposerContext as Mh}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Dh}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Ah,$getTableNodeFromLexicalNodeOrThrow as Pr,$getTableRowIndexFromTableCellNode as $h,$isTableCellNode as ua,$isTableRowNode as Oh,getDOMCellFromTarget as Fh,getTableElement as Ph,TableNode as da}from"@lexical/table";import{calculateZoomLevel as ma,mergeRegister as Bh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Br,isHTMLElement as jh,SKIP_SCROLL_INTO_VIEW_TAG as pa}from"lexical";import*as ha from"react";import{useCallback as Pt,useEffect as jr,useRef as wo,useState as st}from"react";import{createPortal as Hh}from"react-dom";var Uh=33,fa=92;function Wh({editor:t}){let e=wo(null),o=wo(null),r=wo(null),[n,l]=st(!1),i=j(),s=wo(null),[d,c]=st(null),[u,a]=st(null),[m,p]=st(!1),[f,h]=st(null),x=Pt(()=>{a(null),e.current=null,h(null),s.current=null,r.current=null},[]),T=I=>(I.buttons&1)===1;jr(()=>{let I=new Set;return Bh(t.registerMutationListener(da,L=>{for(let[w,N]of L)N==="destroyed"?I.delete(w):I.add(w);l(I.size>0)}),t.registerNodeTransform(da,L=>{if(L.getColWidths())return L;let w=L.getColumnCount(),N=fa;return L.setColWidths(Array(w).fill(N)),L}))},[t]),jr(()=>{if(!n)return;let I=R=>{let $=R.target;if(jh($)){if(f){c({x:R.clientX,y:R.clientY});return}if(p(T(R)),!(o.current&&o.current.contains($))&&e.current!==$){e.current=$;let v=Fh($);v&&u!==v?t.getEditorState().read(()=>{let O=Br(v.elem);if(!O)throw new Error("TableCellResizer: Table cell node not found.");let D=Pr(O),W=Ph(D,t.getElementByKey(D.getKey()));if(!W)throw new Error("TableCellResizer: Table element not found.");e.current=$,r.current=W.getBoundingClientRect(),a(v)},{editor:t}):v==null&&x()}}},L=R=>{p(!0)},w=R=>{p(!1)},N=t.registerRootListener((R,$)=>{$?.removeEventListener("mousemove",I),$?.removeEventListener("mousedown",L),$?.removeEventListener("mouseup",w),R?.addEventListener("mousemove",I),R?.addEventListener("mousedown",L),R?.addEventListener("mouseup",w)});return()=>{N()}},[u,f,t,n,x]);let E=I=>I==="bottom",S=Pt(I=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let L=Br(u.elem);if(!ua(L))throw new Error("TableCellResizer: Table cell node not found.");let w=Pr(L),N=$h(L),R=w.getChildren(),v=L.getColSpan()===w.getColumnCount()?N:N+L.getRowSpan()-1;if(v>=R.length||v<0)throw new Error("Expected table cell to be inside of table row.");let O=R[v];if(!Oh(O))throw new Error("Expected table row");let D=O.getHeight();if(D===void 0){let q=O.getChildren();D=Math.min(...q.map(J=>_(J,t)??1/0))}let W=Math.max(D+I,Uh);O.setHeight(W)},{tag:pa})},[u,t]),_=(I,L)=>L.getElementByKey(I.getKey())?.clientHeight,k=(I,L)=>{let w;return L.forEach(N=>{N.forEach((R,$)=>{R.cell===I&&(w=$)})}),w},g=Pt(I=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let L=Br(u.elem);if(!ua(L))throw new Error("TableCellResizer: Table cell node not found.");let w=Pr(L),[N]=Ah(w,null,null),R=k(L,N);if(R===void 0)throw new Error("TableCellResizer: Table column not found.");let $=w.getColWidths();if(!$)return;let v=$[R];if(v===void 0)return;let O=[...$],D=Math.max(v+I,fa);O[R]=D,w.setColWidths(O)},{tag:pa})},[u,t]),C=Pt(I=>{let L=w=>{if(w.preventDefault(),w.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");if(s.current){let{x:N,y:R}=s.current;if(u===null)return;let $=ma(w.target);if(E(I)){let v=(w.clientY-R)/$;S(v)}else{let v=(w.clientX-N)/$;g(v)}x(),document.removeEventListener("mouseup",L)}};return L},[u,x,g,S]),b=Pt(I=>L=>{if(L.preventDefault(),L.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");s.current={x:L.clientX,y:L.clientY},c(s.current),h(I),document.addEventListener("mouseup",C(I))},[u,C]),[y,A]=st({bottom:null,left:null,right:null,top:null});return jr(()=>{if(u){let{height:I,left:L,top:w,width:N}=u.elem.getBoundingClientRect(),R=ma(u.elem),$=10,v={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${$}px`,left:`${window.scrollX+L}px`,top:`${window.scrollY+w+I-$/2}px`,width:`${N}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${I}px`,left:`${window.scrollX+L+N-$/2}px`,top:`${window.scrollY+w}px`,width:`${$}px`}},O=r.current;f&&d&&O&&(E(f)?(v[f].left=`${window.scrollX+O.left}px`,v[f].top=`${window.scrollY+d.y/R}px`,v[f].height="3px",v[f].width=`${O.width}px`):(v[f].top=`${window.scrollY+O.top}px`,v[f].left=`${window.scrollX+d.x/R}px`,v[f].width="3px",v[f].height=`${O.height}px`),v[f].backgroundColor="#adf"),A(v)}else A({bottom:null,left:null,right:null,top:null})},[u,f,d]),Eo("div",{ref:o,children:u!=null&&!m&&vh(ha.Fragment,{children:[Eo("div",{className:`${i.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:b("right"),style:y.right||void 0}),Eo("div",{className:`${i.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:b("bottom"),style:y.bottom||void 0})]})})}var ga=()=>{let t=Ih(3),[e]=Mh(),o=Dh(),r;return t[0]!==e||t[1]!==o?(r=o?Hh(Eo(Wh,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=r):r=t[2],r};import{c as Yh}from"react/compiler-runtime";import{jsx as Hr,jsxs as qh,Fragment as Qh}from"react/jsx-runtime";import{useLexicalComposerContext as eg}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Ea}from"@lexical/react/useLexicalEditable";import{$getTableAndElementByKey as tg,$getTableColumnIndexFromTableCellNode as og,$getTableRowIndexFromTableCellNode as rg,$insertTableColumnAtSelection as ng,$insertTableRowAtSelection as lg,$isTableCellNode as ig,$isTableNode as ba,getTableElement as sg,TableNode as ag}from"@lexical/table";import{$findMatchingParent as cg,mergeRegister as ug}from"@lexical/utils";import{$getNearestNodeFromDOMNode as ka,isHTMLElement as dg}from"lexical";import{useEffect as _a,useMemo as mg,useRef as Ta,useState as So}from"react";import"react";import{createPortal as pg}from"react-dom";import{c as Xh}from"react/compiler-runtime";import{useEffect as zh,useRef as Zh}from"react";var Gh="Expected a function",Vh=Math.max,Kh=Math.min;function Jh(t,e,o){let r,n,l=0,i,s=!1,d=!1,c,u,a,m=!0;if(typeof t!="function")throw new TypeError(Gh);e=e||0,typeof o=="object"&&(s=!!o.leading,d="maxWait"in o,c=d?Vh(o.maxWait||0,e):c,m="trailing"in o?!!o.trailing:m);function p(g){let C=r,b=i;return r=i=void 0,l=g,u=t.apply(b,C),u}function f(g){return l=g,a=setTimeout(T,e),s?p(g):u}function h(g){let C=g-n,b=g-l,y=e-C;return d?Kh(y,c-b):y}function x(g){let C=g-n,b=g-l;return n===void 0||C>=e||C<0||d&&b>=c}function T(){let g=Date.now();if(x(g))return E(g);a=setTimeout(T,h(g))}function E(g){return a=void 0,m&&r?p(g):(r=i=void 0,u)}function S(){a!==void 0&&clearTimeout(a),l=0,r=n=i=a=void 0}function _(){return a===void 0?u:E(Date.now())}function k(){let g=Date.now(),C=x(g);if(r=arguments,i=this,n=g,C){if(a===void 0)return f(n);if(d)return clearTimeout(a),a=setTimeout(T,e),p(n)}return a===void 0&&(a=setTimeout(T,e)),u}return k.cancel=S,k.flush=_,k}var xa=Jh;function Ca(t,e,o){let r=Xh(6),n=Zh(null),l,i;r[0]!==t||r[1]!==o||r[2]!==e?(l=()=>(n.current=xa(t,e,{maxWait:o}),()=>{n.current?.cancel()}),i=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=l,r[4]=i):(l=r[3],i=r[4]),zh(l,i);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...c)=>{let u=c;n.current&&n.current(...u)},r[5]=s):s=r[5],s}var wa=20;function fg({anchorElem:t}){let[e]=eg(),o=Ea(),r=j(),[n,l]=So(!1),[i,s]=So(!1),[d,c]=So(!1),[u,a]=So({}),m=Ta(new Set),p=Ta(null),f=Ca(T=>{let{isOutside:E,tableDOMNode:S}=hg(T,r.editorConfig?.lexical);if(E){l(!1),s(!1);return}if(!S)return;p.current=S;let _=null,k=null,g=null;if(e.getEditorState().read(()=>{let v=ka(S);if(ig(v)){let O=cg(v,D=>ba(D));if(!ba(O))return;if(g=sg(O,e.getElementByKey(O.getKey())),g){let D=O.getChildrenSize(),W=O.getChildAtIndex(0)?.getChildrenSize(),q=rg(v),J=og(v);q===D-1?_=v:J===W-1&&(k=v)}}},{editor:e}),!g)return;let C=g.parentElement;if(!C)return;let{bottom:b,height:y,left:A,right:I,width:L,y:w}=g.getBoundingClientRect(),N=!1;C&&C.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(N=C.scrollWidth>C.clientWidth);let{left:R,y:$}=t.getBoundingClientRect();_?(s(!1),l(!0),a({height:wa,left:N&&C?C.offsetLeft:A-R,top:b-$+5,width:N&&C?C.offsetWidth:L})):k&&(s(!0),l(!1),a({height:y,left:I-R+5,top:w-$,width:wa}))},50,250),h=mg(()=>new ResizeObserver(()=>{l(!1),s(!1)}),[]);_a(()=>{if(d)return document.addEventListener("mousemove",f),()=>{l(!1),s(!1),document.removeEventListener("mousemove",f)}},[d,f]),_a(()=>ug(e.registerMutationListener(ag,T=>{e.getEditorState().read(()=>{let E=!1;for(let[S,_]of T)switch(_){case"created":{m.current.add(S),E=!0;break}case"destroyed":{m.current.delete(S),E=!0;break}default:break}if(E){h.disconnect();for(let S of m.current){let{tableElement:_}=tg(S);h.observe(_)}c(m.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,h]);let x=T=>{e.update(()=>{p.current&&(ka(p.current)?.selectEnd(),T?(lg(),l(!1)):(ng(),s(!1)))})};return o?qh(Qh,{children:[n&&Hr("button",{"aria-label":"Add Row",className:r.editorConfig.lexical.theme.tableAddRows,onClick:()=>x(!0),style:{...u},type:"button"}),i&&Hr("button",{"aria-label":"Add Column",className:r.editorConfig.lexical.theme.tableAddColumns,onClick:()=>x(!1),style:{...u},type:"button"})]}):null}function hg(t,e){let o=t.target;if(dg(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function Sa(t){let e=Yh(2),{anchorElem:o}=t,r=o===void 0?document.body:o;if(!Ea())return null;let l;return e[0]!==r?(l=pg(Hr(fg,{anchorElem:r}),r),e[0]=r,e[1]=l):l=e[1],l}import{c as gg}from"react/compiler-runtime";import{jsx as Ur,jsxs as xg}from"react/jsx-runtime";import{useLexicalComposerContext as Cg}from"@lexical/react/LexicalComposerContext";import{TablePlugin as bg}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as kg,TableCellNode as _g,TableNode as Tg,TableRowNode as wg}from"@lexical/table";import{mergeRegister as Eg}from"@lexical/utils";import{formatDrawerSlug as Sg,useEditDepth as Lg}from"@payloadcms/ui";import{$getSelection as Ng,$isRangeSelection as yg,COMMAND_PRIORITY_EDITOR as Rg,createCommand as Ig}from"lexical";import{createContext as vg,use as Mg,useEffect as Dg,useMemo as Ag,useState as $g}from"react";import*as La from"react";var Lo=Ig("OPEN_EMBED_DRAWER_COMMAND"),Na=vg({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function ya({children:t}){let[e,o]=$g({cellEditorConfig:null,cellEditorPlugins:null});return Ur(Na,{value:Ag(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Ra=()=>{let t=gg(16),[e]=Cg(),o=Mg(Na),r=Lg(),{fieldProps:n,uuid:l}=j(),{schemaPath:i}=n,s="lexical-table-create-"+l,d;t[0]!==r||t[1]!==s?(d=Sg({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=d):d=t[2];let c=d,{toggleDrawer:u}=he(c,!0),a;t[3]!==e||t[4]!==u?(a=()=>{if(!e.hasNodes([Tg,wg,_g]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return Eg(e.registerCommand(Lo,()=>{let h=null;return e.getEditorState().read(()=>{let x=Ng();yg(x)&&(h=x)}),h&&u(),!0},Rg))},t[3]=e,t[4]=u,t[5]=a):a=t[5];let m;t[6]!==o||t[7]!==e||t[8]!==u?(m=[o,e,u],t[6]=o,t[7]=e,t[8]=u,t[9]=m):m=t[9],Dg(a,m);let p;t[10]!==e?(p=(h,x)=>{!x.columns||!x.rows||e.dispatchCommand(kg,{columns:String(x.columns),rows:String(x.rows)})},t[10]=e,t[11]=p):p=t[11];let f;return t[12]!==c||t[13]!==i||t[14]!==p?(f=xg(La.Fragment,{children:[Ur(ft,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:p,schemaPath:i,schemaPathSuffix:"fields"}),Ur(bg,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=i,t[14]=p,t[15]=f):f=t[15],f};var Bg=M({markdownTransformers:[ea],nodes:[Fg,Og,Pg],plugins:[{Component:Ra,position:"normal"},{Component:ga,position:"normal"},{Component:ca,position:"floatingAnchorElem"},{Component:Sa,position:"floatingAnchorElem"}],providers:[ya],slashMenu:{groups:[z([{Icon:Ir,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Lo,{})}}])]},toolbarFixed:{groups:[Ce([{ChildComponent:Ir,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(Lo,{})}}])]}});import{$isNodeSelection as kx}from"lexical";import{jsx as Wr,jsxs as jg}from"react/jsx-runtime";import"react";var Gr=()=>jg("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:[Wr("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"}),Wr("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"}),Wr("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Aa}from"react/jsx-runtime";import $a from"bson-objectid";import{$applyNodeReplacement as Vg}from"lexical";import*as Oa from"react";import Hg from"bson-objectid";function No(t,e){if(t.hasAttribute("data-lexical-pending-upload-form-id")){let r=t.getAttribute("data-lexical-pending-upload-form-id");if(r!=null)return{node:e({data:{pending:{formID:r,src:t.getAttribute("src")||""}}})}}if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let r=t.getAttribute("data-lexical-upload-id"),n=t.getAttribute("data-lexical-upload-relation-to");if(r!=null&&n!=null)return{node:e({data:{fields:{},relationTo:n,value:r}})}}return{node:e({data:{pending:{formID:new Hg.default().toHexString(),src:t.getAttribute("src")||""}}})}}import{DecoratorBlockNode as Ug}from"@lexical/react/LexicalDecoratorBlockNode.js";import va from"bson-objectid";import{$applyNodeReplacement as Wg}from"lexical";var Bt=class extends Ug{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:o=>No(o,Ia),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new va.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=Ia({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return null}exportDOM(){let e=document.createElement("img"),o=this.__data;return o.pending?(e.setAttribute("data-lexical-pending-upload-form-id",String(o?.pending?.formID)),e.setAttribute("src",o?.pending?.src||"")):(e.setAttribute("data-lexical-upload-id",String(o?.value)),e.setAttribute("data-lexical-upload-relation-to",o?.relationTo)),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function Ia({data:t}){return t?.id||(t.id=new va.default().toHexString()),Wg(new Bt({data:t}))}import{jsx as Ma}from"react/jsx-runtime";import{ShimmerEffect as Gg}from"@payloadcms/ui";var Da=()=>Ma("div",{className:"lexical-upload",children:Ma(Gg,{height:"95px",width:"203px"})});var Kg=Oa.lazy(()=>import("./component-WT25HAJA.js").then(t=>({default:t.UploadComponent}))),le=class extends Bt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:o=>No(o,De),priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new $a.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,pending:e.pending,relationTo:e.relationTo,value:e.value},r=De({data:o});return r.setFormat(e.format),r}decorate(){return this.__data.pending?Aa(Da,{}):Aa(Kg,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function De({data:t}){return t?.id||(t.id=new $a.default().toHexString()),Vg(new le({data:t}))}function at(t){return t instanceof le}import{c as ex}from"react/compiler-runtime";import{jsx as tx}from"react/jsx-runtime";import{useLexicalComposerContext as ox}from"@lexical/react/LexicalComposerContext.js";import{$dfsIterator as Ja,$insertNodeToNearestRoot as Jr,mergeRegister as rx}from"@lexical/utils";import{useBulkUpload as nx,useEffectEvent as lx,useModal as ix}from"@payloadcms/ui";import Xr from"bson-objectid";import{$createRangeSelection as sx,$getPreviousSelection as Ua,$getSelection as Wa,$isParagraphNode as zr,$isRangeSelection as Ga,$setSelection as ax,COMMAND_PRIORITY_EDITOR as cx,COMMAND_PRIORITY_LOW as Va,createCommand as ux,DROP_COMMAND as dx,getDOMSelectionFromTarget as mx,isHTMLElement as Ka,PASTE_COMMAND as px}from"lexical";import{useEffect as fx}from"react";import{c as Fa}from"react/compiler-runtime";import{jsx as Vr}from"react/jsx-runtime";import{useLexicalComposerContext as Pa}from"@lexical/react/LexicalComposerContext.js";import{toast as Jg}from"@payloadcms/ui";import{$getNodeByKey as Xg,COMMAND_PRIORITY_EDITOR as Ba}from"lexical";import{useEffect as ja,useState as zg}from"react";var Zg=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=Xg(o);n&&n.replace(De({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Kr,{fields:null,relationTo:e,value:r})},Yg=t=>{let e=Fa(13),{enabledCollectionSlugs:o}=t,[r]=Pa(),[n,l]=zg(null),i;e[0]!==o?(i={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=i):i=e[1];let{closeListDrawer:s,ListDrawer:d,openListDrawer:c}=At(i),u,a;e[2]!==r||e[3]!==c?(u=()=>r.registerCommand(Xe,h=>(l(h?.replace?h?.replace.nodeKey:null),c(),!0),Ba),a=[r,c],e[2]=r,e[3]=c,e[4]=u,e[5]=a):(u=e[4],a=e[5]),ja(u,a);let m;e[6]!==s||e[7]!==r||e[8]!==n?(m=h=>{let{collectionSlug:x,doc:T}=h;s(),Zg({editor:r,relationTo:x,replaceNodeKey:n,value:T.id})},e[6]=s,e[7]=r,e[8]=n,e[9]=m):m=e[9];let p=m,f;return e[10]!==d||e[11]!==p?(f=Vr(d,{onSelect:p}),e[10]=d,e[11]=p,e[12]=f):f=e[12],f},qg=()=>{let t=Fa(3),[e]=Pa(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Xe,Qg,Ba),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ja(o,r),null},Ha=({enabledCollectionSlugs:t})=>t?.length?Vr(Yg,{enabledCollectionSlugs:t}):Vr(qg,{});function Qg(){return Jg.error("No upload collections enabled"),!0}function hx(t){let e=t.target;return!!(Ka(e)&&!e.closest("code, span.editor-image")&&Ka(e.parentElement)&&e.parentElement.closest("div.ContentEditable__root"))}function gx(t){let e,o=mx(t.target);if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(t.clientX,t.clientY);else if(t.rangeParent&&o!==null)o.collapse(t.rangeParent,t.rangeOffset||0),e=o.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}var Kr=ux("INSERT_UPLOAD_COMMAND"),Xa=t=>{let e=ex(21),{clientProps:o}=t,[r]=ox(),n=o?.disabledCollections,l=o?.enabledCollections,i;e[0]!==n||e[1]!==l?(i={collectionSlugsBlacklist:n,collectionSlugsWhitelist:l,uploads:!0},e[0]=n,e[1]=l,e[2]=i):i=e[2];let{enabledCollectionSlugs:s}=fo(i),{drawerSlug:d,setCollectionSlug:c,setInitialForms:u,setOnCancel:a,setOnSuccess:m,setSelectableCollections:p}=nx(),{isModalOpen:f,openModal:h}=ix(),x;e[3]!==d||e[4]!==r||e[5]!==s||e[6]!==f||e[7]!==h||e[8]!==c||e[9]!==u||e[10]!==a||e[11]!==m||e[12]!==p?(x=k=>{let{files:g}=k;if(g?.length!==0&&(u(C=>[...C??[],...g.map(xx)]),!f(d))){if(!s.length||!s[0])return;c(s[0]),p(s),a(()=>{r.update(Cx)}),m(C=>{let b=new Map(C.map(bx));r.update(()=>{for(let y of Ja()){let A=y.node;if(at(A)){let I=A.getData();if(I?.pending){let L=b.get(I.pending?.formID);L&&A.replace(De({data:{id:new Xr.default().toHexString(),fields:{},relationTo:L.collectionSlug,value:L.doc.id}}))}}}})}),h(d)}},e[3]=d,e[4]=r,e[5]=s,e[6]=f,e[7]=h,e[8]=c,e[9]=u,e[10]=a,e[11]=m,e[12]=p,e[13]=x):x=e[13];let T=lx(x),E;e[14]!==r||e[15]!==T?(E=()=>{if(!r.hasNodes([le]))throw new Error("UploadPlugin: UploadNode not registered on editor");return rx(r.registerNodeTransform(le,k=>{let g=k.getData();if(!g?.pending)return;(async function(){let y=null,A=g?.pending?.src,I=g?.pending?.formID;if(A?.startsWith("data:")){let L=A.match(/data:(image\/[a-zA-Z]+);base64,/),w=L?L[1]:"image/png",N=A.replace(/^data:image\/[a-zA-Z]+;base64,/,""),R=atob(N),$=new Array(R.length);for(let D=0;D<R.length;D++)$[D]=R.charCodeAt(D);let v=new Uint8Array($);y={alt:void 0,file:new File([v],"pasted-image."+w?.split("/")[1],{type:w}),formID:I}}else if(A?.startsWith("http")||A?.startsWith("https")){let w=await(await fetch(A)).blob(),N=A.split("/").pop()||"pasted-image"+w.type.split("/")[1];y={alt:void 0,file:new File([w],N,{type:w.type}),formID:I}}y&&T({files:[y]})})()}),r.registerCommand(Kr,k=>(r.update(()=>{let g=Wa()||Ua();if(Ga(g)){let C=De({data:{id:k.id,fields:k.fields,relationTo:k.relationTo,value:k.value}}),{focus:b}=g,y=b.getNode();Jr(C),zr(y)&&!y.__first&&y.remove()}}),!0),cx),r.registerCommand(px,k=>{if(!(k instanceof ClipboardEvent))return!1;let g=k.clipboardData;if(!g?.types?.length||g?.types?.includes("text/html"))return!1;let C=[];return g?.files?.length&&Array.from(g.files).forEach(b=>{C.push({alt:"",file:b,formID:new Xr.default().toHexString()})}),C.length?(r.update(()=>{let b=Wa()||Ua();if(Ga(b))for(let y of C){let A=new le({data:{pending:{formID:y.formID,src:URL.createObjectURL(y.file)}}}),{focus:I}=b,L=I.getNode();Jr(A),zr(L)&&!L.__first&&L.remove()}}),T({files:C}),!0):!1},Va),r.registerCommand(dx,k=>{if(!(k instanceof DragEvent))return!1;let g=k.dataTransfer;if(!g?.types?.length)return!1;let C=[];return g?.files?.length&&Array.from(g.files).forEach(b=>{C.push({alt:"",file:b,formID:new Xr.default().toHexString()})}),C.length?(k.preventDefault(),k.stopPropagation(),r.update(()=>{if(hx(k)){let b=gx(k),y=sx();b!=null&&y.applyDOMRange(b),ax(y);for(let A of C){let I=new le({data:{pending:{formID:A.formID,src:URL.createObjectURL(A.file)}}}),{focus:L}=y,w=L.getNode();Jr(I),zr(w)&&!w.__first&&w.remove()}}}),T({files:C}),!0):!1},Va))},e[14]=r,e[15]=T,e[16]=E):E=e[16];let S;e[17]!==r?(S=[r],e[17]=r,e[18]=S):S=e[18],fx(E,S);let _;return e[19]!==s?(_=tx(Ha,{enabledCollectionSlugs:s}),e[19]=s,e[20]=_):_=e[20],_};function xx(t){return{file:t.file,formID:t.formID}}function Cx(){for(let t of Ja()){let e=t.node;at(e)&&e.getData()?.pending&&e.remove()}}function bx(t){return[t.formID,t]}var _x=M({nodes:[le],plugins:[{Component:Xa,position:"normal"}],slashMenu:{groups:[z([{Icon:Gr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Xe,{replace:!1})}}])]},toolbarFixed:{groups:[Ce([{ChildComponent:Gr,isActive:({selection:t})=>{if(!kx(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return at(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Xe,{replace:!1})}}])]}});import{c as wx}from"react/compiler-runtime";import{jsx as Yr}from"react/jsx-runtime";import{ShimmerEffect as Ex,useConfig as Sx}from"@payloadcms/ui";import{lazy as Lx,Suspense as Nx,useEffect as yx,useState as Rx}from"react";var za={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",hrSelected:"LexicalEditorTheme__hrSelected",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var yo={namespace:"lexical",theme:za};function Za({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:l}){for(let c of l.features)if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");l.features=l.features.sort((c,u)=>c.clientFeatureProps.order-u.clientFeatureProps.order);let i=new Map;for(let c of l.features)i.set(c.clientFeatureProps.featureKey,c);let s=new Map,d=0;for(let c of l.features){let u=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:i,field:r,resolvedFeatures:s,schemaPath:n,unSanitizedEditorConfig:l}):c.feature;u.key=c.clientFeatureProps.featureKey,u.order=d,s.set(c.clientFeatureProps.featureKey,u),d++}return s}import{deepMerge as Tx}from"payload/shared";var Ya=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}},o={};if(t.forEach(r=>{r.key==="toolbarFixed"&&r.sanitizedClientFeatureProps?.customGroups&&(o={...o,...r.sanitizedClientFeatureProps.customGroups})}),!t?.size)return e;t.forEach(r=>{if(r.providers?.length&&(e.providers=e.providers.concat(r.providers)),r.enableFormats?.length&&e.enabledFormats.push(...r.enableFormats),r.nodes?.length)for(let n of r.nodes)e.nodes.push(n);if(r.plugins?.length&&r.plugins.forEach((n,l)=>{e.plugins?.push({clientProps:r.sanitizedClientFeatureProps,Component:n.Component,key:r.key+l,position:n.position})}),r.toolbarInline?.groups?.length)for(let n of r.toolbarInline.groups){let l=e.toolbarInline.groups.find(i=>i.key===n.key);l?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarInline?.groups.push(l)}if(r.toolbarFixed?.groups?.length)for(let n of r.toolbarFixed.groups){let l=e.toolbarFixed.groups.find(i=>i.key===n.key);l?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.toolbarFixed?.groups.push(l)}if(r.slashMenu?.groups){r.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(r.slashMenu.dynamicGroups));for(let n of r.slashMenu.groups){let l=e.slashMenu.groups.find(i=>i.key===n.key);l?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==n.key):l={...n,items:[]},n?.items?.length&&(l.items=l.items.concat(n.items)),e.slashMenu.groups.push(l)}}if(r.markdownTransformers?.length)for(let n of r.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(r.key)}),Object.keys(o).length>0&&(e.toolbarFixed.groups=e.toolbarFixed.groups.map(r=>{let n=o[r.key];return n?Tx(r,n):r})),e.toolbarInline.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let r of e.toolbarInline.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);for(let r of e.toolbarFixed.groups)r.items.sort((n,l)=>n.order&&l.order?n.order-l.order:n.order?-1:l.order?1:0);return e};function Zr(t,e,o){return{admin:o,features:Ya(t),lexical:e,resolvedFeatureMap:t}}var Ix=Lx(()=>import("./Field-YHS7VMOE.js").then(t=>({default:t.RichText}))),vx=t=>{let e=wx(16),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:l,field:i,lexicalEditorConfig:s,schemaPath:d}=t,c;e[0]!==o?(c=o===void 0?{}:o,e[0]=o,e[1]=c):c=e[1];let u=c,a=s===void 0?yo:s,{config:m}=Sx(),[p,f]=Rx(null),h,x;e[2]!==u||e[3]!==r||e[4]!==m||e[5]!==n||e[6]!==l||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==d?(h=()=>{if(p)return;let E=[];for(let[k,g]of Object.entries(r))g.clientFeatureProvider&&E.push(g.clientFeatureProvider(g.clientFeatureProps));let S=a||yo,_=Za({config:m,featureClientImportMap:n,featureClientSchemaMap:l,field:i,schemaPath:d??i.name,unSanitizedEditorConfig:{features:E,lexical:S}});f(Zr(_,S,u))},x=[a,u,p,r,n,l,i,m,d],e[2]=u,e[3]=r,e[4]=m,e[5]=n,e[6]=l,e[7]=i,e[8]=p,e[9]=a,e[10]=d,e[11]=h,e[12]=x):(h=e[11],x=e[12]),yx(h,x);let T;return e[13]!==p||e[14]!==t?(T=Yr(Nx,{fallback:Yr(Ex,{height:"35vh"}),children:p&&Yr(Ix,{...t,editorConfig:p})}),e[13]=p,e[14]=t,e[15]=T):T=e[15],T};function Mx(t){return t instanceof HTMLElement}function Dx(...t){return t.filter(Boolean).join(" ")}var Ro=new WeakMap;function qa(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function Io(t,e){let o=Ro.get(t);if(o===void 0){let r=new Set,n=i=>{o!==void 0&&(o.start=qa(i))},l=i=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let d=qa(i);for(let c of r)d!==null&&c([d[0]-s[0],d[1]-s[1]],i)};t.addEventListener("touchstart",n),t.addEventListener("touchend",l),o={handleTouchend:l,handleTouchstart:n,listeners:r,start:null},Ro.set(t,o)}return o.listeners.add(e),()=>{Ax(t,e)}}function Ax(t,e){let o=Ro.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(Ro.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function $x(t,e){return Io(t,(o,r)=>{let[n,l]=o;n<0&&-n>Math.abs(l)&&e(n,r)})}function Ox(t,e){return Io(t,(o,r)=>{let[n,l]=o;n>0&&n>Math.abs(l)&&e(n,r)})}function Fx(t,e){return Io(t,(o,r)=>{let[n,l]=o;l<0&&-l>Math.abs(n)&&e(n,r)})}function Px(t,e){return Io(t,(o,r)=>{let[n,l]=o;l>0&&l>Math.abs(n)&&e(n,r)})}import{c as Bx}from"react/compiler-runtime";import{jsx as jx}from"react/jsx-runtime";import"react";var Hx=()=>{let t=Bx(2),{EditButton:e}=ge(),o;return t[0]!==e?(o=e?jx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Ux}from"react/compiler-runtime";import{jsx as Wx}from"react/jsx-runtime";import"react";var Gx=()=>{let t=Ux(2),{RemoveButton:e}=ge(),o;return t[0]!==e?(o=e?Wx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Vx}from"react/compiler-runtime";import{jsx as Kx}from"react/jsx-runtime";import"react";var Jx=()=>{let t=Vx(2),{Label:e}=ge(),o;return t[0]!==e?(o=e?Kx(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Xx}from"react/compiler-runtime";import{jsx as zx}from"react/jsx-runtime";import"react";var Zx=t=>{let e=Xx(3),{children:o}=t,{InlineBlockContainer:r}=ge(),n;return e[0]!==r||e[1]!==o?(n=r?zx(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{jsx as Yx}from"react/jsx-runtime";import"react";var qx=t=>{let{children:e,...o}=t,{BlockCollapsible:r}=xe();return r?Yx(r,{...o,children:e}):null};import{c as Qx}from"react/compiler-runtime";import{jsx as eC}from"react/jsx-runtime";import"react";var tC=()=>{let t=Qx(2),{EditButton:e}=xe(),o;return t[0]!==e?(o=e?eC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as oC}from"react/compiler-runtime";import{jsx as rC}from"react/jsx-runtime";import"react";var nC=()=>{let t=oC(2),{RemoveButton:e}=xe(),o;return t[0]!==e?(o=e?rC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as lC}from"qs-esm";var iC=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:l,collectionSlug:i,select:s})=>{let d=lC({depth:e??0,draft:o??!1,locale:r,select:s},{addQueryPrefix:!0});return await fetch(`${t}/${i}/${l}${d}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(u=>u.json())};var Qa={customEndRegex:{optional:!0,regExp:/[ \t]*```$/},customStartRegex:/^[ \t]*```(\w+)?/,doNotTrimChildren:!0,export:({fields:t})=>!t.code.includes(`
|
|
61
61
|
`)&&!t.language?.length?"```"+t.code+"```":"```"+(t.language||"")+(t.code?`
|
|
62
62
|
`+t.code:"")+"\n```",import:({children:t,closeMatch:e,openMatch:o})=>{let r=o?.[1];return t.startsWith(`
|
|
63
63
|
`)&&(t=t.slice(1)),t.endsWith(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAGhE,OAAO,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAGhE,OAAO,sBAAsB,CAAA;AAc7B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC;IACE,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC1D,oBAAoB,EAAE,OAAO,CAAA;CAC9B,GAAG,IAAI,CAAC,oBAAoB,EAAE,cAAc,GAAG,UAAU,CAAC,CAqK5D,CAAA"}
|
|
@@ -13,6 +13,7 @@ import * as React from 'react';
|
|
|
13
13
|
import { useEffect, useState } from 'react';
|
|
14
14
|
import { useEditorConfigContext } from './config/client/EditorConfigProvider.js';
|
|
15
15
|
import { EditorPlugin } from './EditorPlugin.js';
|
|
16
|
+
import { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js';
|
|
16
17
|
import { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js';
|
|
17
18
|
import { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js';
|
|
18
19
|
import { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js';
|
|
@@ -106,7 +107,7 @@ export const LexicalEditor = props => {
|
|
|
106
107
|
})
|
|
107
108
|
}),
|
|
108
109
|
ErrorBoundary: LexicalErrorBoundary
|
|
109
|
-
}), _jsx(NormalizeSelectionPlugin, {}), isEditable && _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(TextPlugin, {
|
|
110
|
+
}), _jsx(NormalizeSelectionPlugin, {}), isEditable && _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(ClipboardPlugin, {}), _jsx(TextPlugin, {
|
|
110
111
|
features: editorConfig.features
|
|
111
112
|
}), _jsx(SelectAllPlugin, {}), isEditable && _jsx(OnChangePlugin, {
|
|
112
113
|
ignoreSelectionChange: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","isEditable","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","_jsxs","Fragment","children","features","plugins","map","_temp","className","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport './LexicalEditor.scss'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n {isEditable && (\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"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","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","isEditable","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","_jsxs","Fragment","children","features","plugins","map","_temp","className","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport './LexicalEditor.scss'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n {isEditable && (\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/ClipboardPlugin/index.tsx"],"names":[],"mappings":"AAcA,wBAAgB,eAAe,SA4D9B"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { copyToClipboard } from '@lexical/clipboard';
|
|
5
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
6
|
+
import { objectKlassEquals } from '@lexical/utils';
|
|
7
|
+
import ObjectID from 'bson-objectid';
|
|
8
|
+
import { COMMAND_PRIORITY_LOW, COPY_COMMAND } from 'lexical';
|
|
9
|
+
import { useEffect } from 'react';
|
|
10
|
+
export function ClipboardPlugin() {
|
|
11
|
+
const $ = _c(3);
|
|
12
|
+
const [editor] = useLexicalComposerContext();
|
|
13
|
+
let t0;
|
|
14
|
+
let t1;
|
|
15
|
+
if ($[0] !== editor) {
|
|
16
|
+
t0 = () => editor.registerCommand(COPY_COMMAND, event => {
|
|
17
|
+
copyToClipboard(editor, objectKlassEquals(event, ClipboardEvent) ? event : null).then(() => {
|
|
18
|
+
if (!(event instanceof ClipboardEvent) || !event.clipboardData) {
|
|
19
|
+
throw new Error("No clipboard event");
|
|
20
|
+
}
|
|
21
|
+
const lexicalStringified = event.clipboardData.getData("application/x-lexical-editor");
|
|
22
|
+
if (!lexicalStringified) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
const lexical = JSON.parse(lexicalStringified);
|
|
26
|
+
const changeIds = node => {
|
|
27
|
+
if ("fields" in node && typeof node.fields === "object" && node.fields !== null && "id" in node.fields) {
|
|
28
|
+
node.fields.id = new ObjectID.default().toHexString();
|
|
29
|
+
} else {
|
|
30
|
+
if ("id" in node) {
|
|
31
|
+
node.id = new ObjectID.default().toHexString();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (node.children) {
|
|
35
|
+
for (const child of node.children) {
|
|
36
|
+
changeIds(child);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
for (const node_0 of lexical.nodes) {
|
|
41
|
+
changeIds(node_0);
|
|
42
|
+
}
|
|
43
|
+
const stringified = JSON.stringify(lexical);
|
|
44
|
+
event.clipboardData.setData("application/x-lexical-editor", stringified);
|
|
45
|
+
}).catch(error => {
|
|
46
|
+
if (event instanceof ClipboardEvent) {
|
|
47
|
+
event.clipboardData?.setData("application/x-lexical-editor", "");
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
});
|
|
51
|
+
return true;
|
|
52
|
+
}, COMMAND_PRIORITY_LOW);
|
|
53
|
+
t1 = [editor];
|
|
54
|
+
$[0] = editor;
|
|
55
|
+
$[1] = t0;
|
|
56
|
+
$[2] = t1;
|
|
57
|
+
} else {
|
|
58
|
+
t0 = $[1];
|
|
59
|
+
t1 = $[2];
|
|
60
|
+
}
|
|
61
|
+
useEffect(t0, t1);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","copyToClipboard","useLexicalComposerContext","objectKlassEquals","ObjectID","COMMAND_PRIORITY_LOW","COPY_COMMAND","useEffect","ClipboardPlugin","$","editor","t0","t1","registerCommand","event","ClipboardEvent","then","clipboardData","Error","lexicalStringified","getData","lexical","JSON","parse","changeIds","node","fields","id","default","toHexString","children","child","node_0","nodes","stringified","stringify","setData","catch","error"],"sources":["../../../../src/lexical/plugins/ClipboardPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { copyToClipboard } from '@lexical/clipboard'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { objectKlassEquals } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { COMMAND_PRIORITY_LOW, COPY_COMMAND } from 'lexical'\nimport { useEffect } from 'react'\n\ntype SerializedUnknownLexicalNode = {\n children?: SerializedUnknownLexicalNode[]\n type: string\n}\n\nexport function ClipboardPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n // Remove duplicated ids from clipboard. We do it here because:\n // 1. Browsers do not allow setting the clipboardData in paste event for security reasons.\n // 2. If you cut instead of paste, the id will be kept, which is a good thing.\n return editor.registerCommand(\n COPY_COMMAND,\n (event) => {\n copyToClipboard(editor, objectKlassEquals(event, ClipboardEvent) ? event : null)\n .then(() => {\n if (!(event instanceof ClipboardEvent) || !event.clipboardData) {\n throw new Error('No clipboard event')\n }\n const lexicalStringified = event.clipboardData.getData('application/x-lexical-editor')\n if (!lexicalStringified) {\n return true\n }\n\n const lexical = JSON.parse(lexicalStringified) as {\n nodes: SerializedUnknownLexicalNode[]\n }\n const changeIds = (node: SerializedUnknownLexicalNode) => {\n if (\n 'fields' in node &&\n typeof node.fields === 'object' &&\n node.fields !== null &&\n 'id' in node.fields\n ) {\n node.fields.id = new ObjectID.default().toHexString()\n } else if ('id' in node) {\n node.id = new ObjectID.default().toHexString()\n }\n\n if (node.children) {\n for (const child of node.children) {\n changeIds(child)\n }\n }\n }\n for (const node of lexical.nodes) {\n changeIds(node)\n }\n const stringified = JSON.stringify(lexical)\n event.clipboardData.setData('application/x-lexical-editor', stringified)\n })\n .catch((error) => {\n if (event instanceof ClipboardEvent) {\n event.clipboardData?.setData('application/x-lexical-editor', '')\n }\n throw error\n })\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n }, [editor])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,eAAe,QAAQ;AAChC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ;AAClC,OAAOC,QAAA,MAAc;AACrB,SAASC,oBAAoB,EAAEC,YAAY,QAAQ;AACnD,SAASC,SAAS,QAAQ;AAO1B,OAAO,SAAAC,gBAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EACL,OAAAU,MAAA,IAAiBR,yBAAA;EAAA,IAAAS,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAH,CAAA,QAAAC,MAAA;IAEPC,EAAA,GAAAA,CAAA,KAIDD,MAAA,CAAAG,eAAA,CAAAP,YAAA,EAAAQ,KAAA;MAGHb,eAAA,CAAgBS,MAAA,EAAQP,iBAAA,CAAkBW,KAAA,EAAAC,cAAO,IAAkBD,KAAA,OAAQ,EAAAE,IAAA;QAAA,IAEnE,EAAEF,KAAA,YAAAC,cAA8B,MAAOD,KAAA,CAAAG,aAAmB;UAAA,UAAAC,KAAA,CAC5C;QAAA;QAElB,MAAAC,kBAAA,GAA2BL,KAAA,CAAAG,aAAA,CAAAG,OAAA,CAA4B;QAAA,KAClDD,kBAAA;UAAA;QAAA;QAIL,MAAAE,OAAA,GAAgBC,IAAA,CAAAC,KAAA,CAAWJ,kBAAA;QAG3B,MAAAK,SAAA,GAAAC,IAAA;UAAA,IAEI,YAAYA,IAAA,IACZ,OAAOA,IAAA,CAAAC,MAAA,KAAgB,YACvBD,IAAA,CAAAC,MAAA,SAAgB,IAChB,QAAQD,IAAA,CAAAC,MAAW;YAEnBD,IAAA,CAAAC,MAAA,CAAAC,EAAA,GAAiB,IAAAvB,QAAA,CAAAwB,OAAA,GAAAC,WAAA,CAAkC;UAAA;YAAA,IAC1C,QAAQJ,IAAA;cACjBA,IAAA,CAAAE,EAAA,GAAU,IAAAvB,QAAA,CAAAwB,OAAA,GAAAC,WAAA,CAAkC;YAAA;UAAA;UAAA,IAG1CJ,IAAA,CAAAK,QAAA;YAAA,KACG,MAAAC,KAAM,IAASN,IAAA,CAAAK,QAAA;cAClBN,SAAA,CAAUO,KAAA;YAAA;UAAA;QAAA;QAGhB,KACK,MAAAC,MAAM,IAAQX,OAAA,CAAAY,KAAA;UACjBT,SAAA,CAAUC,MAAA;QAAA;QAEZ,MAAAS,WAAA,GAAoBZ,IAAA,CAAAa,SAAA,CAAed,OAAA;QACnCP,KAAA,CAAAG,aAAA,CAAAmB,OAAA,CAA4B,gCAAgCF,WAAA;MAAA,CAC9D,EAAAG,KAAA,CAAAC,KAAA;QAAA,IAEMxB,KAAA,YAAAC,cAAiB;UACnBD,KAAA,CAAAG,aAAA,EAAAmB,OAAA,CAA6B,gCAAgC;QAAA;QAAA,MAEzDE,KAAA;MAAA,CACR;MAAA;IAAA,GAAAjC,oBAGJ;IAEDO,EAAA,IAACF,MAAA;IAAOD,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAE,EAAA;IAAAF,CAAA,MAAAG,EAAA;EAAA;IAAAD,EAAA,GAAAF,CAAA;IAAAG,EAAA,GAAAH,CAAA;EAAA;EAtDXF,SAAA,CAAUI,EAsDV,EAAGC,EAAQ;EAAA;AAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.60.0-canary.
|
|
3
|
+
"version": "3.60.0-canary.7",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -348,6 +348,7 @@
|
|
|
348
348
|
]
|
|
349
349
|
},
|
|
350
350
|
"dependencies": {
|
|
351
|
+
"@lexical/clipboard": "0.35.0",
|
|
351
352
|
"@lexical/headless": "0.35.0",
|
|
352
353
|
"@lexical/html": "0.35.0",
|
|
353
354
|
"@lexical/link": "0.35.0",
|
|
@@ -373,8 +374,8 @@
|
|
|
373
374
|
"react-error-boundary": "4.1.2",
|
|
374
375
|
"ts-essentials": "10.0.3",
|
|
375
376
|
"uuid": "10.0.0",
|
|
376
|
-
"@payloadcms/
|
|
377
|
-
"@payloadcms/
|
|
377
|
+
"@payloadcms/translations": "3.60.0-canary.7",
|
|
378
|
+
"@payloadcms/ui": "3.60.0-canary.7"
|
|
378
379
|
},
|
|
379
380
|
"devDependencies": {
|
|
380
381
|
"@babel/cli": "7.27.2",
|
|
@@ -394,15 +395,15 @@
|
|
|
394
395
|
"esbuild-sass-plugin": "3.3.1",
|
|
395
396
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
396
397
|
"@payloadcms/eslint-config": "3.28.0",
|
|
397
|
-
"payload": "3.60.0-canary.
|
|
398
|
+
"payload": "3.60.0-canary.7"
|
|
398
399
|
},
|
|
399
400
|
"peerDependencies": {
|
|
400
401
|
"@faceless-ui/modal": "3.0.0",
|
|
401
402
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
402
403
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
403
404
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
404
|
-
"@payloadcms/next": "3.60.0-canary.
|
|
405
|
-
"payload": "3.60.0-canary.
|
|
405
|
+
"@payloadcms/next": "3.60.0-canary.7",
|
|
406
|
+
"payload": "3.60.0-canary.7"
|
|
406
407
|
},
|
|
407
408
|
"engines": {
|
|
408
409
|
"node": "^18.20.2 || >=20.9.0"
|