@payloadcms/richtext-lexical 3.64.0-canary.0 → 3.64.0-internal.23abf20

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.
@@ -1,2 +1,2 @@
1
- "use client";import{a as we,e as ke,f as F,h as Te,i as De,j as ve,k as Le,l as Me}from"./chunk-AFXLIYGL.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as B,jsxs as ge}from"react/jsx-runtime";import{BulkUploadProvider as Dn,FieldDescription as vn,FieldError as Ln,FieldLabel as Mn,RenderCustomComponent as bt,useEditDepth as _n,useEffectEvent as An,useField as Bn}from"@payloadcms/ui";import{mergeFieldStyles as In}from"@payloadcms/ui/shared";import{dequal as On}from"dequal/lite";import Nt,{useCallback as Pt,useEffect as St,useMemo as Fn,useState as Rt}from"react";import{ErrorBoundary as $n}from"react-error-boundary";import"./bundled.css";import{jsx as $}from"react/jsx-runtime";import{LexicalComposer as wn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as kn}from"@payloadcms/ui";import*as xt from"react";import{useMemo as Tn}from"react";import{c as dn}from"react/compiler-runtime";import{jsx as E,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as un}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as mn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as fn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as pn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as gn}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as hn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as yn,COMMAND_PRIORITY_LOW as ht,FOCUS_COMMAND as xn}from"lexical";import*as q from"react";import{useEffect as En,useState as Cn}from"react";import{jsx as _e}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&_e(o.Component,{anchorElem:t,clientProps:e}):o.Component&&_e(o.Component,{clientProps:e});import{c as Tt}from"react/compiler-runtime";import{copyToClipboard as Dt}from"@lexical/clipboard";import{useLexicalComposerContext as vt}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Lt}from"@lexical/utils";import Ae from"bson-objectid";import{COMMAND_PRIORITY_LOW as Mt,COPY_COMMAND as _t}from"lexical";import{useEffect as At}from"react";function Be(){let t=Tt(3),[e]=vt(),o,r;return t[0]!==e?(o=()=>e.registerCommand(_t,n=>(Dt(e,Lt(n,ClipboardEvent)?n:null).then(()=>{if(!(n instanceof ClipboardEvent)||!n.clipboardData)throw new Error("No clipboard event");let d=n.clipboardData.getData("application/x-lexical-editor");if(!d)return!0;let i=JSON.parse(d),s=u=>{if("fields"in u&&typeof u.fields=="object"&&u.fields!==null&&"id"in u.fields?u.fields.id=new Ae.default().toHexString():"id"in u&&(u.id=new Ae.default().toHexString()),u.children)for(let y of u.children)s(y)};for(let u of i.nodes)s(u);let c=JSON.stringify(i);n.clipboardData.setData("application/x-lexical-editor",c)}).catch(d=>{throw n instanceof ClipboardEvent&&n.clipboardData?.setData("application/x-lexical-editor",""),d}),!0),Mt),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),At(o,r),null}import{c as Bt}from"react/compiler-runtime";import{useLexicalComposerContext as It}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Ot}from"@lexical/utils";import{$createNodeSelection as Ft,$getEditor as X,$getNearestNodeFromDOMNode as $t,$getSelection as re,$isDecoratorNode as H,$isElementNode as xe,$isLineBreakNode as Kt,$isNodeSelection as ie,$isRangeSelection as Ie,$isRootOrShadowRoot as Ht,$isTextNode as jt,$setSelection as Oe,CLICK_COMMAND as zt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as Wt,KEY_ARROW_UP_COMMAND as Yt,KEY_BACKSPACE_COMMAND as Vt,KEY_DELETE_COMMAND as Gt,SELECTION_CHANGE_COMMAND as Ut}from"lexical";import{useEffect as qt}from"react";function Fe(){let t=Bt(3),[e]=It(),o=oo,r,n;return t[0]!==e?(r=()=>Ot(e.registerCommand(zt,to,W),e.registerCommand(Gt,o,W),e.registerCommand(Vt,o,W),e.registerCommand(Ut,eo,W),e.registerCommand(Yt,Xt,W),e.registerCommand(Wt,Jt,W)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),qt(r,n),null}function Jt(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let u=X().getElementByKey(i.getKey());return u&&Z({element:u,node:i}),!0}if(!xe(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Ie(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Qt),d=n?.getNextSibling();if(!n||d!==$e(n))return!1;if(H(d)){let i=X().getElementByKey(d.getKey());if(i)return Z({element:i,node:d}),t.preventDefault(),!0}return!1}function Qt(t){return $e(t)!==null}function Xt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let u=X().getElementByKey(i.getKey());return u?(Z({element:u,node:i}),t.preventDefault(),!0):!1}if(!xe(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Ie(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Zt),d=n?.getPreviousSibling();if(!n||d!==Ke(n))return!1;if(H(d)){let i=X().getElementByKey(d.getKey());if(i)return Z({element:i,node:d}),t.preventDefault(),!0}return!1}function Zt(t){return Ke(t)!==null}function eo(){let t=io();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function to(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=ro(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Oe(null):Z(e),!0}function oo(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(no),!0):!1}function no(t){t.remove()}function ro(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=$t(e);return H(o)?{element:e,node:o}:void 0}function io(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return H(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Ft();o.add(e.getKey()),Oe(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(H(t)&&!t.isInline())return!0;if(!xe(t)||Ht(t))return!1;let e=t.getFirstChild(),o=e===null||Kt(e)||jt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function $e(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function Ke(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ee}from"react/jsx-runtime";import{useLexicalComposerContext as mo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as fo,isHTMLElement as po}from"lexical";import*as We from"react";import{useCallback as go,useEffect as ze,useRef as ho,useState as yo}from"react";import{createPortal as xo}from"react-dom";var Y=(t,e,o,r,n=50,d=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:c,right:u,top:y}=t.getBoundingClientRect(),l=y+window.scrollY,a=s+window.scrollY;if(o<l-d||o>a+d||e<c-n||e>u+n)return-1;(e<c||e>u)&&(i=e<c?e-c:e-u)}return i};import{$getNodeByKey as ae}from"lexical";function V(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(c,u)=>c?parseFloat(window.getComputedStyle(c)[u]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),d=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),d),marginTop:i}}import{$getRoot as so}from"lexical";function j(t){return t.getEditorState().read(()=>so().getChildrenKeys())}var lo=1,ao=-1,He=0,_={props:null,result:null};function co(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:d=0,point:{x:i,y:s},startIndex:c=0,useEdgeAsDefault:u=!1}=t;if(o>0&&_.props&&_.result&&_.props.fuzzy===t.fuzzy&&_.props.horizontalOffset===t.horizontalOffset&&_.props.useEdgeAsDefault===t.useEdgeAsDefault&&co(_.props.point,t.point,o))return _.result;let y=e.getBoundingClientRect(),l=j(r),a={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(u){let g=r.getElementByKey(l[0]),m=r.getElementByKey(l[l.length-1]);if(g&&m){let[p,f]=[V(g),V(m)];if(s<p.top?(a.blockElem=g,a.distance=p.top-s,a.blockNode=ae(l[0]),a.foundAtIndex=0):s>f.bottom&&(a.distance=s-f.bottom,a.blockNode=ae(l[l.length-1]),a.blockElem=m,a.foundAtIndex=l.length-1),a?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let h=c,x=He;for(;h>=0&&h<l.length;){let g=l[h],m=r.getElementByKey(g);if(m===null)break;let p=new F(i+d,s),f=Le.fromDOMRect(V(m)),{marginBottom:C,marginTop:k}=le(m),S=f.generateNewRect({bottom:f.bottom+C,left:y.left,right:y.right,top:f.top-k}),{distance:b,isOnBottomSide:w,isOnTopSide:N}=S.distanceFromPoint(p);if(b===0){a.blockElem=m,a.blockNode=ae(g),a.foundAtIndex=h,a.distance=b,a.blockNode&&a.blockNode.getType()==="paragraph"&&a.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(a.blockElem=null,a.blockNode=null),a.isFoundNodeEmptyParagraph=!0);break}else n&&b<a.distance&&(a.blockElem=m,a.blockNode=ae(g),a.distance=b,a.foundAtIndex=h);x===He&&(N?x=ao:w?x=lo:x=1/0),h+=x}}),_.props=t,_.result={blockElem:a.blockElem,blockNode:a.blockNode,foundAtIndex:a.foundAtIndex,isFoundNodeEmptyParagraph:a.isFoundNodeEmptyParagraph},{blockElem:a.blockElem,blockNode:a.blockNode,foundAtIndex:a.foundAtIndex,isFoundNodeEmptyParagraph:a.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var uo=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function je(t){if(!t||uo.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function de(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),d=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),c;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(l=>t.classList.contains(l)||t.firstElementChild?.classList.contains(l)))c=n.top+8-s.top;else{let l=je(t)?parseInt(d.lineHeight,10):0;c=n.top+(l-i.height)/2-s.top}let y=r;e.style.opacity="1",e.style.transform=`translate(${y}px, ${c}px)`}var Eo="add-block-menu",ue=1/0;function Co(t){return t===0?1/0:ue>=0&&ue<t?ue:Math.floor(t/2)}function bo(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),d=n?.admin?.hideGutter?-24:12,i=ho(null),[s,c]=yo(null);ze(()=>{function y(l){let a=l.target;if(!po(a))return;let h=Y(r,l.pageX,l.pageY,a);if(h===-1){c(null);return}if(ce(a,Eo))return;let x=j(t),{blockElem:g,blockNode:m,foundAtIndex:p}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-h,point:new F(l.x,l.y),returnEmptyParagraphs:!0,startIndex:Co(x.length),useEdgeAsDefault:!1});ue=p,g&&m&&(s?.node!==m||s?.elem!==g)&&c({elem:g,node:m})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,s]),ze(()=>{i.current&&s?.node&&de(s?.elem,i.current,e,d)},[e,s,d]);let u=go(y=>{let l=s;l?.node&&(t.update(()=>{let a=!0;if((l?.node.getType()!=="paragraph"||l.node.getTextContent()!=="")&&(a=!1),!a){let h=fo();l?.node.insertAfter(h),setTimeout(()=>{l={elem:t.getElementByKey(h.getKey()),node:h},c(l)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),l?.node&&"select"in l.node&&typeof l.node.select=="function"&&l.node.select()})},1),setTimeout(()=>{t.dispatchCommand(De,{node:l?.node})},2),y.stopPropagation(),y.preventDefault())},[t,s]);return xo(Ee(We.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{u(y)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function Ye(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=mo();return bo(r,o,r._editable)}import{jsx as me,jsxs as Po}from"react/jsx-runtime";import{useLexicalComposerContext as So}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ue}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as qe,$getNodeByKey as Ro,isHTMLElement as Ce}from"lexical";import*as et from"react";import{useEffect as be,useRef as fe,useState as Je}from"react";import{createPortal as wo}from"react-dom";var Ve=0,No=-24;var z=0;function Ge(t,e,o,r,n,d,i,s,c,u=!1){let{height:y,top:l}=r.getBoundingClientRect(),{top:a,width:h}=i.getBoundingClientRect(),{marginBottom:x,marginTop:g}=le(r),m=l,p=d>=l+y/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(p&&n?.elem&&n?.elem===r.nextElementSibling||!p&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(f=!0));else{z++;let b=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(p===n?.isBelow&&b===w||z<200)&&(f=!1)}if(f)return{isBelow:p,willStayInSamePosition:f};u?m+=y/2:p?m+=y+x/2:m-=g/2;let C=0;u||(p?C=-Ve:C=Ve);let k=m-a+C,S=No-e;return o.style.width=`calc(${h}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${k}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?p?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:p,willStayInSamePosition:f}}var ko="draggable-block-menu",Qe="application/x-lexical-drag-block",ee=1/0;function Xe(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function To(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Ze(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Do(t,e,o){let r=e.parentElement,n=fe(null),d=fe(null),i=fe(null),s=fe(!1),[c,u]=Je(null),[y,l]=Je(null),{editorConfig:a}=R(),h=a?.admin?.hideGutter?-44:-8;be(()=>{function m(p){let f=p.target;if(!Ce(f))return;let C=Y(r,p.pageX,p.pageY,f);if(C===-1){u(null);return}if(ce(f,ko))return;let k=j(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:w}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-C,point:new F(p.x,p.y),startIndex:Xe(k.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!w)&&c!==S&&u(S)}return document?.addEventListener("mousemove",m),()=>{document?.removeEventListener("mousemove",m)}},[r,e,t,c]),be(()=>{n.current&&de(c,n.current,e,h)},[e,c,h]),be(()=>{function m(f){if(!s.current)return!1;let[C]=Ue(f);if(C)return!1;let{pageY:k,target:S}=f;if(!Ce(S))return!1;let b=Y(r,f.pageX,f.pageY,S,100,50),w=j(t),{blockElem:N,foundAtIndex:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new F(f.x,f.y),startIndex:Xe(w.length),useEdgeAsDefault:!0,verbose:!0});ee=L;let T=d.current;if(N===null||T===null)return!1;if(c!==N){let{isBelow:D,willStayInSamePosition:J}=Ge(a?.admin?.hideGutter?"0px":"3rem",h+(a?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,N,y,k,e,f,i,I);f.preventDefault(),J||l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:D})}else y?.elem&&(Ze(T,y.elem),l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function p(f){if(!s.current)return!1;let[C]=Ue(f);if(C)return!1;let{dataTransfer:k,pageY:S,target:b}=f,w=k?.getData(Qe)||"";return t.update(()=>{let N=Ro(w);if(!N||!Ce(b))return!1;let L=Y(r,f.pageX,f.pageY,b,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-L,point:new F(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let D=qe(I);if(!D)return!1;if(D===N)return!0;let{height:J,top:he}=V(I),O=S>=he+J/2+window.scrollY;T?(D.insertBefore(N),D.remove()):O?D.insertAfter(N):D.insertBefore(N),c!==null&&u(null),document.querySelectorAll(".lexical-block-highlighter").forEach(v=>{v.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let v=oe?.getBoundingClientRect();if(!v)return;let P=document.createElement("div");P.className="lexical-block-highlighter",P.style.backgroundColor="var(--theme-elevation-1000",P.style.transition="opacity 0.5s ease-in-out",P.style.zIndex="1",P.style.pointerEvents="none",P.style.boxSizing="border-box",P.style.borderRadius="4px",P.style.position="absolute",document.body.appendChild(P),P.style.opacity="0.1",P.style.height=`${v.height+8}px`,P.style.width=`${v.width+8}px`,P.style.top=`${v.top+window.scrollY-4}px`,P.style.left=`${v.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",m),document.addEventListener("drop",p),()=>{document.removeEventListener("dragover",m),document.removeEventListener("drop",p)}},[r,h,e,t,y,c,a?.admin?.hideGutter]);function x(m){let p=m.dataTransfer;if(!p||!c)return;To(p,c);let f="";t.update(()=>{let C=qe(c);C&&(f=C.getKey())}),s.current=!0,p.setData(Qe,f)}function g(){s.current=!1,y?.elem&&Ze(d.current,y?.elem)}return wo(Po(et.Fragment,{children:[me("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:g,onDragStart:x,ref:n,type:"button",children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:d}),me("div",{className:"debug-highlight",ref:i})]}),e)}function tt(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=So();return Do(r,o,r._editable)}import{c as vo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as Lo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Mo,$getRoot as _o}from"lexical";import"react";var ot="insert-paragraph-at-end",nt=()=>{let t=vo(2),[e]=Lo(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;return t[0]!==e?(r=Ne("div",{"aria-label":"Insert Paragraph",className:ot,onClick:()=>{e.update(Ao)},role:"button",tabIndex:0,children:Ne("div",{className:`${ot}-inside`,children:Ne("span",{children:"+"})})}),t[0]=e,t[1]=r):r=t[1],r};function Ao(){let t=Mo();_o().append(t),t.select()}import{c as Bo}from"react/compiler-runtime";import{useLexicalComposerContext as Io}from"@lexical/react/LexicalComposerContext";import*as rt from"react";var it=()=>{let t=Bo(4),{editorConfig:e}=R(),[o]=Io(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>we(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),rt.useEffect(r,n),null};import{useLexicalComposerContext as Oo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Fo,$isRangeSelection as $o,RootNode as Ko}from"lexical";import{useEffect as Ho}from"react";function st(){let[t]=Oo();return Ho(()=>t.registerNodeTransform(Ko,e=>{let o=Fo();if($o(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(e.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[t]),null}import{useLexicalComposerContext as jo}from"@lexical/react/LexicalComposerContext";import{$getSelection as zo,COMMAND_PRIORITY_LOW as Wo,SELECT_ALL_COMMAND as Yo}from"lexical";import{useEffect as Vo}from"react";function lt(){let[t]=jo();return Vo(()=>t.registerCommand(Yo,()=>{if(zo())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Wo),[t]),null}import{jsx as U,jsxs as ct}from"react/jsx-runtime";import{useLexicalComposerContext as Uo}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as dt}from"@payloadcms/ui";import{useCallback as qo,useMemo as Jo,useState as Qo}from"react";import"react";import*as ut from"react-dom";import{c as Go}from"react/compiler-runtime";import"react";function at(t,e){let o=Go(4),{maxLength:r,minLength:n}=e,d=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==d||o[1]!==i||o[2]!==t?(s=c=>{let{query:u}=c,y="[^"+t+Te+"\\s]",a=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+d+"}))$").exec(u);if(a!==null){let h=a[1],x=a[3];if(x.length>=i)return{leadOffset:a.index+h.length,matchingString:x,replaceableString:a[2]}}return null},o[0]=d,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var A="slash-menu-popup";function Xo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:d,schemaPath:i}}=R(),{i18n:s}=dt(),c=`${A}__item ${A}__item-${e.key}`;t&&(c+=` ${A}__item--selected`);let u=e.key;return e.label&&(u=typeof e.label=="function"?e.label({featureClientSchemaMap:d,i18n:s,schemaPath:i}):e.label),u.length>25&&(u=u.substring(0,25)+"..."),ct("button",{"aria-selected":t,className:c,id:A+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${A}__item-text`,children:u})]},e.key)}function mt({anchorElem:t=document.body}){let[e]=Uo(),[o,r]=Qo(null),{editorConfig:n}=R(),{i18n:d}=dt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),c=at("/",{minLength:0}),u=qo(()=>{let l=[];for(let a of n.features.slashMenu.dynamicGroups)if(o){let h=a({editor:e,queryString:o});l=l.concat(h)}return l},[e,o,n?.features]),y=Jo(()=>{let l=[];for(let a of n?.features.slashMenu.groups??[])l.push(a);if(o){l=l.map(h=>{let x=h.items.filter(g=>{let m=g.key;return g.label&&(m=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:d,schemaPath:s}):g.label),new RegExp(o,"gi").exec(m)?!0:g.keywords!=null?g.keywords.some(p=>new RegExp(o,"gi").exec(p)):!1});return x.length?{...h,items:x}:null}),l=l.filter(h=>h!=null);let a=u();for(let h of a){let x=l.find(g=>g.key===h.key);x?l=l.filter(g=>g.key!==h.key):x={...h,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),l.push(x)}}return l},[o,n?.features.slashMenu.groups,u,i,d,s]);return U(ve,{anchorElem:t,groups:y,menuRenderFn:(l,{selectedItemKey:a,selectItemAndCleanUp:h,setSelectedItemKey:x})=>l.current&&y.length?ut.createPortal(U("div",{className:A,children:y.map(g=>{let m=g.key;return g.label&&i&&(m=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:d,schemaPath:s}):g.label),ct("div",{className:`${A}__group ${A}__group-${g.key}`,children:[U("div",{className:`${A}__group-title`,children:m}),g.items.map((p,f)=>U(Xo,{index:f,isSelected:a===p.key,item:p,onClick:()=>{x(p.key),h(p)},onMouseEnter:()=>{x(p.key)},ref:C=>{p.ref={current:C}}},p.key))]},g.key)})}),l.current):null,onQueryChange:r,triggerFn:c})}import{c as Zo}from"react/compiler-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as tn,TextNode as on}from"lexical";import{useEffect as nn}from"react";function ft(t){let e=Zo(6),{features:o}=t,[r]=en(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=rn(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(on,s=>{i.forEach(c=>{s.hasFormat(c)&&s.toggleFormat(c)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let d;return e[3]!==r||e[4]!==o?(d=[r,o],e[3]=r,e[4]=o,e[5]=d):d=e[5],nn(n,d),null}function rn(t){let e=Object.keys(tn),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as sn}from"react/compiler-runtime";import{jsx as pt}from"react/jsx-runtime";import{useLexicalComposerContext as ln}from"@lexical/react/LexicalComposerContext";import{ContentEditable as an}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as cn}from"@payloadcms/ui";import"react";function gt(t){let e=sn(5),{className:o,editorConfig:r}=t,{t:n}=cn(),[,d]=ln(),{getTheme:i}=d,s;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==i||e[3]!==n){let c=i();s=pt(an,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:pt("p",{className:c?.placeholder,children:r?.admin?.placeholder??n("lexical:general:placeholder")})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=i,e[3]=n,e[4]=s}else s=e[4];return s}var yt=t=>{let e=dn(12),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:d}=t,i=R(),[s]=un(),c=hn(),[u,y]=Cn(null),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{m!==null&&y(m)},e[0]=l):l=e[0];let a=l,h,x;e[1]!==s||e[2]!==i?(h=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},p=()=>{i.blurEditor(i)},f=s.registerCommand(xn,()=>(m(),!0),ht),C=s.registerCommand(yn,()=>(p(),!0),ht);return()=>{f(),C(),i.parentEditor?.unregisterChild?.(i.uuid)}},x=[s,i],e[1]=s,e[2]=i,e[3]=h,e[4]=x):(h=e[3],x=e[4]),En(h,x);let g;return e[5]!==o||e[6]!==r||e[7]!==u||e[8]!==c||e[9]!==n||e[10]!==d?(g=te(q.Fragment,{children:[o.features.plugins?.map(bn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Nn),E(gn,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:a,children:E(gt,{editorConfig:o})})}),ErrorBoundary:mn}),E(st,{}),c&&E(nt,{}),E(Fe,{}),E(Be,{}),E(ft,{features:o.features}),E(lt,{}),c&&E(pn,{ignoreSelectionChange:!0,onChange:(m,p,f)=>{(!f.has("focus")||f.size>1)&&d?.(m,p,f)}}),u&&te(q.Fragment,{children:[!n&&c&&te(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:E(tt,{anchorElem:u}),o.admin?.hideAddBlockButton?null:E(Ye,{anchorElem:u})]}),o.features.plugins?.map(m=>{if(m.position==="floatingAnchorElem"&&!(m.desktopOnly===!0&&n))return E(K,{anchorElem:u,clientProps:m.clientProps,plugin:m},m.key)}),c&&E(q.Fragment,{children:E(mt,{anchorElem:u})})]}),c&&te(q.Fragment,{children:[E(fn,{}),o?.features?.markdownTransformers?.length>0&&E(it,{})]}),o.features.plugins?.map(Pn),o.features.plugins?.map(Sn)]}),o.features.plugins?.map(Rn)]}),e[5]=o,e[6]=r,e[7]=u,e[8]=c,e[9]=n,e[10]=d,e[11]=g):g=e[11],g};function bn(t){if(t.position==="aboveContainer")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Nn(t){if(t.position==="top")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Pn(t){if(t.position==="normal")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Sn(t){if(t.position==="bottom")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Rn(t){if(t.position==="belowContainer")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}var Et=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?$(o,{children:$(Et,{providers:e.slice(1),children:t})}):$(o,{children:t})},Ct=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:d,readOnly:i,value:s}=t,c=R(),u=kn(),y=xt.useRef(null),l=Tn(()=>{if(s&&typeof s!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(s));if(s&&Array.isArray(s)&&!("root"in s))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(s&&"jsonContent"in s)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:i!==!0,editorState:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Me({editorConfig:o}),onError:a=>{throw a},theme:o.lexical.theme}},[o]);return l?$(wn,{initialConfig:l,children:$(Re,{editorConfig:o,editorContainerRef:y,fieldProps:r,parentContext:c?.editDepth===u?c:void 0,children:$(Et,{providers:o.features.providers,children:$(yt,{editorConfig:o,editorContainerRef:y,isSmallWidthViewport:n,onChange:d})})})},e+l.editable):$("p",{children:"Loading..."})};var pe="rich-text-lexical",Kn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:d}={},label:i,localized:s,required:c},path:u,readOnly:y,validate:l}=t,a=y||d,h=_n(),x=Pt((M,Q)=>typeof l=="function"?l(M,{...Q,required:c}):!0,[l,c]),{customComponents:{AfterInput:g,BeforeInput:m,Description:p,Error:f,Label:C}={},disabled:k,initialValue:S,path:b,setValue:w,showError:N,value:L}=Bn({potentiallyStalePath:u,validate:x}),I=a||k,[T,D]=Rt(!1),[J,he]=Rt(),ye=Nt.useRef(S),O=Nt.useRef(L);St(()=>{let M=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==T&&D(Q)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[T]);let Pe=[pe,"field-type",r,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!T?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${h}`,v=ke(),P=Pt(M=>{v(()=>{let Se=M.toJSON();O.current=Se,w(Se)})},[w,v]),wt=Fn(()=>In(o),[o]),kt=An(M=>{O.current!==L&&!On(O.current!=null?JSON.parse(JSON.stringify(O.current)):O.current,L)&&(ye.current=M,O.current=L,he(new Date))});return St(()=>{Object.is(S,ye.current)||kt(S)},[S]),ge("div",{className:Pe,style:wt,children:[B(bt,{CustomComponent:f,Fallback:B(Ln,{path:b,showError:N})}),C||B(Mn,{label:i,localized:s,path:b,required:c}),ge("div",{className:`${pe}__wrap`,children:[ge($n,{fallbackRender:Hn,onReset:()=>{},children:[m,B(Dn,{drawerSlugPrefix:b,children:B(Ct,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:T,onChange:P,readOnly:I,value:L},JSON.stringify({path:b,rerenderProviderKey:J}))}),g]}),B(bt,{CustomComponent:p,Fallback:B(vn,{description:n,path:b})})]})]},oe)};function Hn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[B("p",{children:"Something went wrong:"}),B("pre",{style:{color:"red"},children:t.message})]})}var As=Kn;export{As as RichText};
2
- //# sourceMappingURL=Field-QUXIGJRC.js.map
1
+ "use client";import{a as we,e as ke,f as F,h as Te,i as De,j as ve,k as Le,l as Me}from"./chunk-EZX4YW7S.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as B,jsxs as ge}from"react/jsx-runtime";import{BulkUploadProvider as Dn,FieldDescription as vn,FieldError as Ln,FieldLabel as Mn,RenderCustomComponent as bt,useEditDepth as _n,useEffectEvent as An,useField as Bn}from"@payloadcms/ui";import{mergeFieldStyles as In}from"@payloadcms/ui/shared";import{dequal as On}from"dequal/lite";import Nt,{useCallback as Pt,useEffect as St,useMemo as Fn,useState as Rt}from"react";import{ErrorBoundary as $n}from"react-error-boundary";import"./bundled.css";import{jsx as $}from"react/jsx-runtime";import{LexicalComposer as wn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as kn}from"@payloadcms/ui";import*as xt from"react";import{useMemo as Tn}from"react";import{c as dn}from"react/compiler-runtime";import{jsx as E,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as un}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as mn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as fn}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as pn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as gn}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as hn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as yn,COMMAND_PRIORITY_LOW as ht,FOCUS_COMMAND as xn}from"lexical";import*as q from"react";import{useEffect as En,useState as Cn}from"react";import{jsx as _e}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&_e(o.Component,{anchorElem:t,clientProps:e}):o.Component&&_e(o.Component,{clientProps:e});import{c as Tt}from"react/compiler-runtime";import{copyToClipboard as Dt}from"@lexical/clipboard";import{useLexicalComposerContext as vt}from"@lexical/react/LexicalComposerContext.js";import{objectKlassEquals as Lt}from"@lexical/utils";import Ae from"bson-objectid";import{COMMAND_PRIORITY_LOW as Mt,COPY_COMMAND as _t}from"lexical";import{useEffect as At}from"react";function Be(){let t=Tt(3),[e]=vt(),o,r;return t[0]!==e?(o=()=>e.registerCommand(_t,n=>(Dt(e,Lt(n,ClipboardEvent)?n:null).then(()=>{if(!(n instanceof ClipboardEvent)||!n.clipboardData)throw new Error("No clipboard event");let d=n.clipboardData.getData("application/x-lexical-editor");if(!d)return!0;let i=JSON.parse(d),s=u=>{if("fields"in u&&typeof u.fields=="object"&&u.fields!==null&&"id"in u.fields?u.fields.id=new Ae.default().toHexString():"id"in u&&(u.id=new Ae.default().toHexString()),u.children)for(let y of u.children)s(y)};for(let u of i.nodes)s(u);let c=JSON.stringify(i);n.clipboardData.setData("application/x-lexical-editor",c)}).catch(d=>{throw n instanceof ClipboardEvent&&n.clipboardData?.setData("application/x-lexical-editor",""),d}),!0),Mt),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),At(o,r),null}import{c as Bt}from"react/compiler-runtime";import{useLexicalComposerContext as It}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Ot}from"@lexical/utils";import{$createNodeSelection as Ft,$getEditor as X,$getNearestNodeFromDOMNode as $t,$getSelection as re,$isDecoratorNode as H,$isElementNode as xe,$isLineBreakNode as Kt,$isNodeSelection as ie,$isRangeSelection as Ie,$isRootOrShadowRoot as Ht,$isTextNode as jt,$setSelection as Oe,CLICK_COMMAND as zt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as Wt,KEY_ARROW_UP_COMMAND as Yt,KEY_BACKSPACE_COMMAND as Vt,KEY_DELETE_COMMAND as Gt,SELECTION_CHANGE_COMMAND as Ut}from"lexical";import{useEffect as qt}from"react";function Fe(){let t=Bt(3),[e]=It(),o=oo,r,n;return t[0]!==e?(r=()=>Ot(e.registerCommand(zt,to,W),e.registerCommand(Gt,o,W),e.registerCommand(Vt,o,W),e.registerCommand(Ut,eo,W),e.registerCommand(Yt,Xt,W),e.registerCommand(Wt,Jt,W)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),qt(r,n),null}function Jt(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let u=X().getElementByKey(i.getKey());return u&&Z({element:u,node:i}),!0}if(!xe(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Ie(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Qt),d=n?.getNextSibling();if(!n||d!==$e(n))return!1;if(H(d)){let i=X().getElementByKey(d.getKey());if(i)return Z({element:i,node:d}),t.preventDefault(),!0}return!1}function Qt(t){return $e(t)!==null}function Xt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let u=X().getElementByKey(i.getKey());return u?(Z({element:u,node:i}),t.preventDefault(),!0):!1}if(!xe(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Ie(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Zt),d=n?.getPreviousSibling();if(!n||d!==Ke(n))return!1;if(H(d)){let i=X().getElementByKey(d.getKey());if(i)return Z({element:i,node:d}),t.preventDefault(),!0}return!1}function Zt(t){return Ke(t)!==null}function eo(){let t=io();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function to(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=ro(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Oe(null):Z(e),!0}function oo(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(no),!0):!1}function no(t){t.remove()}function ro(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=$t(e);return H(o)?{element:e,node:o}:void 0}function io(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return H(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Ft();o.add(e.getKey()),Oe(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(H(t)&&!t.isInline())return!0;if(!xe(t)||Ht(t))return!1;let e=t.getFirstChild(),o=e===null||Kt(e)||jt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function $e(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function Ke(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ee}from"react/jsx-runtime";import{useLexicalComposerContext as mo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as fo,isHTMLElement as po}from"lexical";import*as We from"react";import{useCallback as go,useEffect as ze,useRef as ho,useState as yo}from"react";import{createPortal as xo}from"react-dom";var Y=(t,e,o,r,n=50,d=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:c,right:u,top:y}=t.getBoundingClientRect(),l=y+window.scrollY,a=s+window.scrollY;if(o<l-d||o>a+d||e<c-n||e>u+n)return-1;(e<c||e>u)&&(i=e<c?e-c:e-u)}return i};import{$getNodeByKey as ae}from"lexical";function V(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(c,u)=>c?parseFloat(window.getComputedStyle(c)[u]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),d=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),d),marginTop:i}}import{$getRoot as so}from"lexical";function j(t){return t.getEditorState().read(()=>so().getChildrenKeys())}var lo=1,ao=-1,He=0,_={props:null,result:null};function co(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:d=0,point:{x:i,y:s},startIndex:c=0,useEdgeAsDefault:u=!1}=t;if(o>0&&_.props&&_.result&&_.props.fuzzy===t.fuzzy&&_.props.horizontalOffset===t.horizontalOffset&&_.props.useEdgeAsDefault===t.useEdgeAsDefault&&co(_.props.point,t.point,o))return _.result;let y=e.getBoundingClientRect(),l=j(r),a={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(u){let g=r.getElementByKey(l[0]),m=r.getElementByKey(l[l.length-1]);if(g&&m){let[p,f]=[V(g),V(m)];if(s<p.top?(a.blockElem=g,a.distance=p.top-s,a.blockNode=ae(l[0]),a.foundAtIndex=0):s>f.bottom&&(a.distance=s-f.bottom,a.blockNode=ae(l[l.length-1]),a.blockElem=m,a.foundAtIndex=l.length-1),a?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let h=c,x=He;for(;h>=0&&h<l.length;){let g=l[h],m=r.getElementByKey(g);if(m===null)break;let p=new F(i+d,s),f=Le.fromDOMRect(V(m)),{marginBottom:C,marginTop:k}=le(m),S=f.generateNewRect({bottom:f.bottom+C,left:y.left,right:y.right,top:f.top-k}),{distance:b,isOnBottomSide:w,isOnTopSide:N}=S.distanceFromPoint(p);if(b===0){a.blockElem=m,a.blockNode=ae(g),a.foundAtIndex=h,a.distance=b,a.blockNode&&a.blockNode.getType()==="paragraph"&&a.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(a.blockElem=null,a.blockNode=null),a.isFoundNodeEmptyParagraph=!0);break}else n&&b<a.distance&&(a.blockElem=m,a.blockNode=ae(g),a.distance=b,a.foundAtIndex=h);x===He&&(N?x=ao:w?x=lo:x=1/0),h+=x}}),_.props=t,_.result={blockElem:a.blockElem,blockNode:a.blockNode,foundAtIndex:a.foundAtIndex,isFoundNodeEmptyParagraph:a.isFoundNodeEmptyParagraph},{blockElem:a.blockElem,blockNode:a.blockNode,foundAtIndex:a.foundAtIndex,isFoundNodeEmptyParagraph:a.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var uo=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function je(t){if(!t||uo.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function de(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),d=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),c;if(["LexicalEditorTheme__block","LexicalEditorTheme__upload","LexicalEditorTheme__relationship"].some(l=>t.classList.contains(l)||t.firstElementChild?.classList.contains(l)))c=n.top+8-s.top;else{let l=je(t)?parseInt(d.lineHeight,10):0;c=n.top+(l-i.height)/2-s.top}let y=r;e.style.opacity="1",e.style.transform=`translate(${y}px, ${c}px)`}var Eo="add-block-menu",ue=1/0;function Co(t){return t===0?1/0:ue>=0&&ue<t?ue:Math.floor(t/2)}function bo(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),d=n?.admin?.hideGutter?-24:12,i=ho(null),[s,c]=yo(null);ze(()=>{function y(l){let a=l.target;if(!po(a))return;let h=Y(r,l.pageX,l.pageY,a);if(h===-1){c(null);return}if(ce(a,Eo))return;let x=j(t),{blockElem:g,blockNode:m,foundAtIndex:p}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-h,point:new F(l.x,l.y),returnEmptyParagraphs:!0,startIndex:Co(x.length),useEdgeAsDefault:!1});ue=p,g&&m&&(s?.node!==m||s?.elem!==g)&&c({elem:g,node:m})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,s]),ze(()=>{i.current&&s?.node&&de(s?.elem,i.current,e,d)},[e,s,d]);let u=go(y=>{let l=s;l?.node&&(t.update(()=>{let a=!0;if((l?.node.getType()!=="paragraph"||l.node.getTextContent()!=="")&&(a=!1),!a){let h=fo();l?.node.insertAfter(h),setTimeout(()=>{l={elem:t.getElementByKey(h.getKey()),node:h},c(l)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),l?.node&&"select"in l.node&&typeof l.node.select=="function"&&l.node.select()})},1),setTimeout(()=>{t.dispatchCommand(De,{node:l?.node})},2),y.stopPropagation(),y.preventDefault())},[t,s]);return xo(Ee(We.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{u(y)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function Ye(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=mo();return bo(r,o,r._editable)}import{jsx as me,jsxs as Po}from"react/jsx-runtime";import{useLexicalComposerContext as So}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ue}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as qe,$getNodeByKey as Ro,isHTMLElement as Ce}from"lexical";import*as et from"react";import{useEffect as be,useRef as fe,useState as Je}from"react";import{createPortal as wo}from"react-dom";var Ve=0,No=-24;var z=0;function Ge(t,e,o,r,n,d,i,s,c,u=!1){let{height:y,top:l}=r.getBoundingClientRect(),{top:a,width:h}=i.getBoundingClientRect(),{marginBottom:x,marginTop:g}=le(r),m=l,p=d>=l+y/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(p&&n?.elem&&n?.elem===r.nextElementSibling||!p&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(f=!0));else{z++;let b=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(p===n?.isBelow&&b===w||z<200)&&(f=!1)}if(f)return{isBelow:p,willStayInSamePosition:f};u?m+=y/2:p?m+=y+x/2:m-=g/2;let C=0;u||(p?C=-Ve:C=Ve);let k=m-a+C,S=No-e;return o.style.width=`calc(${h}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${k}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?p?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:p,willStayInSamePosition:f}}var ko="draggable-block-menu",Qe="application/x-lexical-drag-block",ee=1/0;function Xe(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function To(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Ze(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Do(t,e,o){let r=e.parentElement,n=fe(null),d=fe(null),i=fe(null),s=fe(!1),[c,u]=Je(null),[y,l]=Je(null),{editorConfig:a}=R(),h=a?.admin?.hideGutter?-44:-8;be(()=>{function m(p){let f=p.target;if(!Ce(f))return;let C=Y(r,p.pageX,p.pageY,f);if(C===-1){u(null);return}if(ce(f,ko))return;let k=j(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:w}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-C,point:new F(p.x,p.y),startIndex:Xe(k.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!w)&&c!==S&&u(S)}return document?.addEventListener("mousemove",m),()=>{document?.removeEventListener("mousemove",m)}},[r,e,t,c]),be(()=>{n.current&&de(c,n.current,e,h)},[e,c,h]),be(()=>{function m(f){if(!s.current)return!1;let[C]=Ue(f);if(C)return!1;let{pageY:k,target:S}=f;if(!Ce(S))return!1;let b=Y(r,f.pageX,f.pageY,S,100,50),w=j(t),{blockElem:N,foundAtIndex:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new F(f.x,f.y),startIndex:Xe(w.length),useEdgeAsDefault:!0,verbose:!0});ee=L;let T=d.current;if(N===null||T===null)return!1;if(c!==N){let{isBelow:D,willStayInSamePosition:J}=Ge(a?.admin?.hideGutter?"0px":"3rem",h+(a?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,N,y,k,e,f,i,I);f.preventDefault(),J||l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:D})}else y?.elem&&(Ze(T,y.elem),l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function p(f){if(!s.current)return!1;let[C]=Ue(f);if(C)return!1;let{dataTransfer:k,pageY:S,target:b}=f,w=k?.getData(Qe)||"";return t.update(()=>{let N=Ro(w);if(!N||!Ce(b))return!1;let L=Y(r,f.pageX,f.pageY,b,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-L,point:new F(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let D=qe(I);if(!D)return!1;if(D===N)return!0;let{height:J,top:he}=V(I),O=S>=he+J/2+window.scrollY;T?(D.insertBefore(N),D.remove()):O?D.insertAfter(N):D.insertBefore(N),c!==null&&u(null),document.querySelectorAll(".lexical-block-highlighter").forEach(v=>{v.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let v=oe?.getBoundingClientRect();if(!v)return;let P=document.createElement("div");P.className="lexical-block-highlighter",P.style.backgroundColor="var(--theme-elevation-1000",P.style.transition="opacity 0.5s ease-in-out",P.style.zIndex="1",P.style.pointerEvents="none",P.style.boxSizing="border-box",P.style.borderRadius="4px",P.style.position="absolute",document.body.appendChild(P),P.style.opacity="0.1",P.style.height=`${v.height+8}px`,P.style.width=`${v.width+8}px`,P.style.top=`${v.top+window.scrollY-4}px`,P.style.left=`${v.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",m),document.addEventListener("drop",p),()=>{document.removeEventListener("dragover",m),document.removeEventListener("drop",p)}},[r,h,e,t,y,c,a?.admin?.hideGutter]);function x(m){let p=m.dataTransfer;if(!p||!c)return;To(p,c);let f="";t.update(()=>{let C=qe(c);C&&(f=C.getKey())}),s.current=!0,p.setData(Qe,f)}function g(){s.current=!1,y?.elem&&Ze(d.current,y?.elem)}return wo(Po(et.Fragment,{children:[me("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:g,onDragStart:x,ref:n,type:"button",children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:d}),me("div",{className:"debug-highlight",ref:i})]}),e)}function tt(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=So();return Do(r,o,r._editable)}import{c as vo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as Lo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Mo,$getRoot as _o}from"lexical";import"react";var ot="insert-paragraph-at-end",nt=()=>{let t=vo(2),[e]=Lo(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;return t[0]!==e?(r=Ne("div",{"aria-label":"Insert Paragraph",className:ot,onClick:()=>{e.update(Ao)},role:"button",tabIndex:0,children:Ne("div",{className:`${ot}-inside`,children:Ne("span",{children:"+"})})}),t[0]=e,t[1]=r):r=t[1],r};function Ao(){let t=Mo();_o().append(t),t.select()}import{c as Bo}from"react/compiler-runtime";import{useLexicalComposerContext as Io}from"@lexical/react/LexicalComposerContext";import*as rt from"react";var it=()=>{let t=Bo(4),{editorConfig:e}=R(),[o]=Io(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>we(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),rt.useEffect(r,n),null};import{useLexicalComposerContext as Oo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Fo,$isRangeSelection as $o,RootNode as Ko}from"lexical";import{useEffect as Ho}from"react";function st(){let[t]=Oo();return Ho(()=>t.registerNodeTransform(Ko,e=>{let o=Fo();if($o(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(e.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[t]),null}import{useLexicalComposerContext as jo}from"@lexical/react/LexicalComposerContext";import{$getSelection as zo,COMMAND_PRIORITY_LOW as Wo,SELECT_ALL_COMMAND as Yo}from"lexical";import{useEffect as Vo}from"react";function lt(){let[t]=jo();return Vo(()=>t.registerCommand(Yo,()=>{if(zo())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Wo),[t]),null}import{jsx as U,jsxs as ct}from"react/jsx-runtime";import{useLexicalComposerContext as Uo}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as dt}from"@payloadcms/ui";import{useCallback as qo,useMemo as Jo,useState as Qo}from"react";import"react";import*as ut from"react-dom";import{c as Go}from"react/compiler-runtime";import"react";function at(t,e){let o=Go(4),{maxLength:r,minLength:n}=e,d=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==d||o[1]!==i||o[2]!==t?(s=c=>{let{query:u}=c,y="[^"+t+Te+"\\s]",a=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+d+"}))$").exec(u);if(a!==null){let h=a[1],x=a[3];if(x.length>=i)return{leadOffset:a.index+h.length,matchingString:x,replaceableString:a[2]}}return null},o[0]=d,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var A="slash-menu-popup";function Xo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:d,schemaPath:i}}=R(),{i18n:s}=dt(),c=`${A}__item ${A}__item-${e.key}`;t&&(c+=` ${A}__item--selected`);let u=e.key;return e.label&&(u=typeof e.label=="function"?e.label({featureClientSchemaMap:d,i18n:s,schemaPath:i}):e.label),u.length>25&&(u=u.substring(0,25)+"..."),ct("button",{"aria-selected":t,className:c,id:A+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${A}__item-text`,children:u})]},e.key)}function mt({anchorElem:t=document.body}){let[e]=Uo(),[o,r]=Qo(null),{editorConfig:n}=R(),{i18n:d}=dt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),c=at("/",{minLength:0}),u=qo(()=>{let l=[];for(let a of n.features.slashMenu.dynamicGroups)if(o){let h=a({editor:e,queryString:o});l=l.concat(h)}return l},[e,o,n?.features]),y=Jo(()=>{let l=[];for(let a of n?.features.slashMenu.groups??[])l.push(a);if(o){l=l.map(h=>{let x=h.items.filter(g=>{let m=g.key;return g.label&&(m=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:d,schemaPath:s}):g.label),new RegExp(o,"gi").exec(m)?!0:g.keywords!=null?g.keywords.some(p=>new RegExp(o,"gi").exec(p)):!1});return x.length?{...h,items:x}:null}),l=l.filter(h=>h!=null);let a=u();for(let h of a){let x=l.find(g=>g.key===h.key);x?l=l.filter(g=>g.key!==h.key):x={...h,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),l.push(x)}}return l},[o,n?.features.slashMenu.groups,u,i,d,s]);return U(ve,{anchorElem:t,groups:y,menuRenderFn:(l,{selectedItemKey:a,selectItemAndCleanUp:h,setSelectedItemKey:x})=>l.current&&y.length?ut.createPortal(U("div",{className:A,children:y.map(g=>{let m=g.key;return g.label&&i&&(m=typeof g.label=="function"?g.label({featureClientSchemaMap:i,i18n:d,schemaPath:s}):g.label),ct("div",{className:`${A}__group ${A}__group-${g.key}`,children:[U("div",{className:`${A}__group-title`,children:m}),g.items.map((p,f)=>U(Xo,{index:f,isSelected:a===p.key,item:p,onClick:()=>{x(p.key),h(p)},onMouseEnter:()=>{x(p.key)},ref:C=>{p.ref={current:C}}},p.key))]},g.key)})}),l.current):null,onQueryChange:r,triggerFn:c})}import{c as Zo}from"react/compiler-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as tn,TextNode as on}from"lexical";import{useEffect as nn}from"react";function ft(t){let e=Zo(6),{features:o}=t,[r]=en(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=rn(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(on,s=>{i.forEach(c=>{s.hasFormat(c)&&s.toggleFormat(c)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let d;return e[3]!==r||e[4]!==o?(d=[r,o],e[3]=r,e[4]=o,e[5]=d):d=e[5],nn(n,d),null}function rn(t){let e=Object.keys(tn),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as sn}from"react/compiler-runtime";import{jsx as pt}from"react/jsx-runtime";import{useLexicalComposerContext as ln}from"@lexical/react/LexicalComposerContext";import{ContentEditable as an}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as cn}from"@payloadcms/ui";import"react";function gt(t){let e=sn(5),{className:o,editorConfig:r}=t,{t:n}=cn(),[,d]=ln(),{getTheme:i}=d,s;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==i||e[3]!==n){let c=i();s=pt(an,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:pt("p",{className:c?.placeholder,children:r?.admin?.placeholder??n("lexical:general:placeholder")})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=i,e[3]=n,e[4]=s}else s=e[4];return s}var yt=t=>{let e=dn(12),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:d}=t,i=R(),[s]=un(),c=hn(),[u,y]=Cn(null),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{m!==null&&y(m)},e[0]=l):l=e[0];let a=l,h,x;e[1]!==s||e[2]!==i?(h=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},p=()=>{i.blurEditor(i)},f=s.registerCommand(xn,()=>(m(),!0),ht),C=s.registerCommand(yn,()=>(p(),!0),ht);return()=>{f(),C(),i.parentEditor?.unregisterChild?.(i.uuid)}},x=[s,i],e[1]=s,e[2]=i,e[3]=h,e[4]=x):(h=e[3],x=e[4]),En(h,x);let g;return e[5]!==o||e[6]!==r||e[7]!==u||e[8]!==c||e[9]!==n||e[10]!==d?(g=te(q.Fragment,{children:[o.features.plugins?.map(bn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Nn),E(gn,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:a,children:E(gt,{editorConfig:o})})}),ErrorBoundary:mn}),E(st,{}),c&&E(nt,{}),E(Fe,{}),E(Be,{}),E(ft,{features:o.features}),E(lt,{}),c&&E(pn,{ignoreSelectionChange:!0,onChange:(m,p,f)=>{(!f.has("focus")||f.size>1)&&d?.(m,p,f)}}),u&&te(q.Fragment,{children:[!n&&c&&te(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:E(tt,{anchorElem:u}),o.admin?.hideAddBlockButton?null:E(Ye,{anchorElem:u})]}),o.features.plugins?.map(m=>{if(m.position==="floatingAnchorElem"&&!(m.desktopOnly===!0&&n))return E(K,{anchorElem:u,clientProps:m.clientProps,plugin:m},m.key)}),c&&E(q.Fragment,{children:E(mt,{anchorElem:u})})]}),c&&te(q.Fragment,{children:[E(fn,{}),o?.features?.markdownTransformers?.length>0&&E(it,{})]}),o.features.plugins?.map(Pn),o.features.plugins?.map(Sn)]}),o.features.plugins?.map(Rn)]}),e[5]=o,e[6]=r,e[7]=u,e[8]=c,e[9]=n,e[10]=d,e[11]=g):g=e[11],g};function bn(t){if(t.position==="aboveContainer")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Nn(t){if(t.position==="top")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Pn(t){if(t.position==="normal")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Sn(t){if(t.position==="bottom")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}function Rn(t){if(t.position==="belowContainer")return E(K,{clientProps:t.clientProps,plugin:t},t.key)}var Et=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?$(o,{children:$(Et,{providers:e.slice(1),children:t})}):$(o,{children:t})},Ct=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:d,readOnly:i,value:s}=t,c=R(),u=kn(),y=xt.useRef(null),l=Tn(()=>{if(s&&typeof s!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(s));if(s&&Array.isArray(s)&&!("root"in s))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(s&&"jsonContent"in s)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:i!==!0,editorState:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Me({editorConfig:o}),onError:a=>{throw a},theme:o.lexical.theme}},[o]);return l?$(wn,{initialConfig:l,children:$(Re,{editorConfig:o,editorContainerRef:y,fieldProps:r,parentContext:c?.editDepth===u?c:void 0,children:$(Et,{providers:o.features.providers,children:$(yt,{editorConfig:o,editorContainerRef:y,isSmallWidthViewport:n,onChange:d})})})},e+l.editable):$("p",{children:"Loading..."})};var pe="rich-text-lexical",Kn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:d}={},label:i,localized:s,required:c},path:u,readOnly:y,validate:l}=t,a=y||d,h=_n(),x=Pt((M,Q)=>typeof l=="function"?l(M,{...Q,required:c}):!0,[l,c]),{customComponents:{AfterInput:g,BeforeInput:m,Description:p,Error:f,Label:C}={},disabled:k,initialValue:S,path:b,setValue:w,showError:N,value:L}=Bn({potentiallyStalePath:u,validate:x}),I=a||k,[T,D]=Rt(!1),[J,he]=Rt(),ye=Nt.useRef(S),O=Nt.useRef(L);St(()=>{let M=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==T&&D(Q)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[T]);let Pe=[pe,"field-type",r,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!T?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${h}`,v=ke(),P=Pt(M=>{v(()=>{let Se=M.toJSON();O.current=Se,w(Se)})},[w,v]),wt=Fn(()=>In(o),[o]),kt=An(M=>{O.current!==L&&!On(O.current!=null?JSON.parse(JSON.stringify(O.current)):O.current,L)&&(ye.current=M,O.current=L,he(new Date))});return St(()=>{Object.is(S,ye.current)||kt(S)},[S]),ge("div",{className:Pe,style:wt,children:[B(bt,{CustomComponent:f,Fallback:B(Ln,{path:b,showError:N})}),C||B(Mn,{label:i,localized:s,path:b,required:c}),ge("div",{className:`${pe}__wrap`,children:[ge($n,{fallbackRender:Hn,onReset:()=>{},children:[m,B(Dn,{drawerSlugPrefix:b,children:B(Ct,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:T,onChange:P,readOnly:I,value:L},JSON.stringify({path:b,rerenderProviderKey:J}))}),g]}),B(bt,{CustomComponent:p,Fallback:B(vn,{description:n,path:b})})]})]},oe)};function Hn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[B("p",{children:"Something went wrong:"}),B("pre",{style:{color:"red"},children:t.message})]})}var As=Kn;export{As as RichText};
2
+ //# sourceMappingURL=Field-5MPJSBMW.js.map
@@ -9,4 +9,4 @@ var rt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.cre
9
9
  `)},regExp:Yt,replace:(n,t,e,o)=>{if(o){let c=n.getPreviousSibling();if(Pt(c)){c.splice(c.getChildrenSize(),0,[On(),...t]),c.select(0,0),n.remove();return}}let r=Nn();r.append(...t),n.replace(r),r.select(0,0)}},jt={type:"element",dependencies:[tt,J],export:(n,t)=>k(n)?U(n,t,0):null,regExp:zt,replace:et("bullet")},Pn={type:"element",dependencies:[tt,J],export:(n,t)=>k(n)?U(n,t,0):null,regExp:Xt,replace:et("check")},Vt={type:"element",dependencies:[tt,J],export:(n,t)=>k(n)?U(n,t,0):null,regExp:Gt,replace:et("number")},Zt={type:"text-format",format:["code"],tag:"`"},Jt={type:"text-format",format:["highlight"],tag:"=="},te={type:"text-format",format:["bold","italic"],tag:"***"},ee={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},ne={type:"text-format",format:["bold"],tag:"**"},oe={type:"text-format",format:["bold"],intraword:!1,tag:"__"},re={type:"text-format",format:["strikethrough"],tag:"~~"},ie={type:"text-format",format:["italic"],tag:"*"},se={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function ce(n,t){let e=n.split(`
10
10
  `),o=!1,r=[],c=0;for(let s=0;s<e.length;s++){let i=e[s],a=r[r.length-1];if(Mn.test(i)){r.push(i);continue}if(Ht.test(i)){c===0&&(o=!0),c===1&&(o=!1),c>0&&c--,r.push(i);continue}if(kn.test(i)){o=!0,c++,r.push(i);continue}if(o){r.push(i);continue}vt.test(i)||vt.test(a)||!a||Z.test(a)||Z.test(i)||Yt.test(i)||Gt.test(i)||zt.test(i)||Xt.test(i)||Ln.test(i)||$n.test(i)||!t||Kt.test(i)||Ut.test(i)||Kt.test(a)||Ut.test(a)||Ht.test(a)?r.push(i):r[r.length-1]=a+" "+i.trim()}return r.join(`
11
11
  `)}var vn=[qt,Qt,jt,Vt],Hn=[],Kn=[Zt,te,ee,ne,oe,Jt,ie,se,re],Un=[],K=[...vn,...Hn,...Kn,...Un];function Tr(n,t=K,e,o=!1,r=!0){let c=o?n:ce(n,r);return Mt(t,o)(c,e)}function Sr(n=K,t,e=!1){return Nt(n,e)(t)}export{ur as a,Tr as b,Sr as c,rt as d,Wn as e,z as f,it as g,lo as h,Ge as i,fo as j,St as k,po as l};
12
- //# sourceMappingURL=chunk-AFXLIYGL.js.map
12
+ //# sourceMappingURL=chunk-EZX4YW7S.js.map