@payloadcms/richtext-lexical 3.41.0-canary.1 → 3.41.0-canary.3
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-EY5V65PS.js → Field-6GAC5Y2D.js} +2 -2
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-DOZWITPU.js → chunk-LUNX5J6B.js} +2 -2
- package/dist/exports/client/{chunk-DOZWITPU.js.map → chunk-LUNX5J6B.js.map} +1 -1
- package/dist/exports/client/index.js +2 -2
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/blocks/client/plugin/index.js +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +1 -2
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +2 -4
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +1 -3
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/package.json +19 -16
- package/dist/scss/custom.css +0 -1
- /package/dist/exports/client/{Field-EY5V65PS.js.map → Field-6GAC5Y2D.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{b as ke,e as _,g as we,h as Te,i as ve,j as Le,k as Me}from"./chunk-DOZWITPU.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as xn,FieldError as En,FieldLabel as Cn,RenderCustomComponent as xt,useEditDepth as bn,useEffectEvent as Nn,useField as Pn}from"@payloadcms/ui";import{mergeFieldStyles as Sn}from"@payloadcms/ui/shared";import Et,{useCallback as Ct,useEffect as bt,useMemo as Rn,useRef as kn,useState as Nt}from"react";import{ErrorBoundary as wn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as gn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as hn}from"@payloadcms/ui";import*as gt from"react";import{useMemo as yn}from"react";import{c as Zo}from"react/compiler-runtime";import{jsx as C,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as tn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as on}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as nn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as rn}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as sn,COMMAND_PRIORITY_LOW as ft,FOCUS_COMMAND as ln}from"lexical";import*as J from"react";import{useEffect as an,useState as cn}from"react";import{jsx as De}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&De(o.Component,{anchorElem:t,clientProps:e}):o.Component&&De(o.Component,{clientProps:e});import{c as kt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Tt}from"@lexical/utils";import{$createNodeSelection as vt,$getEditor as X,$getNearestNodeFromDOMNode as Lt,$getSelection as re,$isDecoratorNode as H,$isElementNode as xe,$isLineBreakNode as Mt,$isNodeSelection as ie,$isRangeSelection as Ae,$isRootOrShadowRoot as Dt,$isTextNode as At,$setSelection as Ie,CLICK_COMMAND as It,COMMAND_PRIORITY_LOW as Y,KEY_ARROW_DOWN_COMMAND as Bt,KEY_ARROW_UP_COMMAND as _t,KEY_BACKSPACE_COMMAND as Ot,KEY_DELETE_COMMAND as Ft,SELECTION_CHANGE_COMMAND as $t}from"lexical";import{useEffect as Kt}from"react";function Be(){let t=kt(3),[e]=wt(),o=Gt,r,n;return t[0]!==e?(r=()=>Tt(e.registerCommand(It,Vt,Y),e.registerCommand(Ft,o,Y),e.registerCommand(Ot,o,Y),e.registerCommand($t,Yt,Y),e.registerCommand(_t,zt,Y),e.registerCommand(Bt,Ht,Y)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Kt(r,n),null}function Ht(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let y=X().getElementByKey(i.getKey());return y&&Z({element:y,node:i}),!0}if(!xe(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,jt),c=n?.getNextSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function jt(t){return _e(t)!==null}function zt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let y=X().getElementByKey(i.getKey());return y?(Z({element:y,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(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Wt),c=n?.getPreviousSibling();if(!n||c!==Oe(n))return!1;if(H(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Wt(t){return Oe(t)!==null}function Yt(){let t=Jt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function Vt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=qt(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"]')?Ie(null):Z(e),!0}function Gt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Ut),!0):!1}function Ut(t){t.remove()}function qt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=Lt(e);return H(o)?{element:e,node:o}:void 0}function Jt(){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=vt();o.add(e.getKey()),Ie(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)||Dt(t))return!1;let e=t.getFirstChild(),o=e===null||Mt(e)||At(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 Oe(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 oo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as no,isHTMLElement as ro}from"lexical";import*as He from"react";import{useCallback as io,useEffect as Ke,useRef as so,useState as lo}from"react";import{createPortal as ao}from"react-dom";var V=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:u,right:y,top:g}=t.getBoundingClientRect(),a=g+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||e<u-n||e>y+n)return-1;(e<u||e>y)&&(i=e<u?e-u:e-y)}return i};import{$getNodeByKey as ae}from"lexical";function G(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=(u,y)=>u?parseFloat(window.getComputedStyle(u)[y]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Qt}from"lexical";function j(t){return t.getEditorState().read(()=>Qt().getChildrenKeys())}var Xt=1,Zt=-1,Fe=0,A={props:null,result:null};function eo(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function U(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:s},startIndex:u=0,useEdgeAsDefault:y=!1}=t;if(o>0&&A.props&&A.result&&A.props.fuzzy===t.fuzzy&&A.props.horizontalOffset===t.horizontalOffset&&A.props.useEdgeAsDefault===t.useEdgeAsDefault&&eo(A.props.point,t.point,o))return A.result;let g=e.getBoundingClientRect(),a=j(r),l={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(y){let m=r.getElementByKey(a[0]),h=r.getElementByKey(a[a.length-1]);if(m&&h){let[d,f]=[G(m),G(h)];if(s<d.top?(l.blockElem=m,l.distance=d.top-s,l.blockNode=ae(a[0]),l.foundAtIndex=0):s>f.bottom&&(l.distance=s-f.bottom,l.blockNode=ae(a[a.length-1]),l.blockElem=h,l.foundAtIndex=a.length-1),l?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=u,x=Fe;for(;p>=0&&p<a.length;){let m=a[p],h=r.getElementByKey(m);if(h===null)break;let d=new _(i+c,s),f=Le.fromDOMRect(G(h)),{marginBottom:E,marginTop:w}=le(h),S=f.generateNewRect({bottom:f.bottom+E,left:g.left,right:g.right,top:f.top-w}),{distance:b,isOnBottomSide:k,isOnTopSide:N}=S.distanceFromPoint(d);if(b===0){l.blockElem=h,l.blockNode=ae(m),l.foundAtIndex=p,l.distance=b,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else n&&b<l.distance&&(l.blockElem=h,l.blockNode=ae(m),l.distance=b,l.foundAtIndex=p);x===Fe&&(N?x=Zt:k?x=Xt:x=1/0),p+=x}}),A.props=t,A.result={blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph},{blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var to=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function $e(t){if(!t||to.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 ue(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=n.top+8-s.top;else{let a=$e(t)?parseInt(c.lineHeight,10):0;u=n.top+(a-i.height)/2-s.top}let g=r;e.style.opacity="1",e.style.transform=`translate(${g}px, ${u}px)`}var co="add-block-menu",de=1/0;function uo(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function mo(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),c=n?.admin?.hideGutter?-24:12,i=so(null),[s,u]=lo(null);Ke(()=>{function g(a){let l=a.target;if(!ro(l))return;let p=V(r,a.pageX,a.pageY,l);if(p===-1){u(null);return}if(ce(l,co))return;let x=j(t),{blockElem:m,blockNode:h,foundAtIndex:d}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:uo(x.length),useEdgeAsDefault:!1});de=d,m&&h&&(s?.node!==h||s?.elem!==m)&&u({elem:m,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[r,e,t,s]),Ke(()=>{i.current&&s?.node&&ue(s?.elem,i.current,e,c)},[e,s,c]);let y=io(g=>{let a=s;a?.node&&(t.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let p=no();a?.node.insertAfter(p),setTimeout(()=>{a={elem:t.getElementByKey(p.getKey()),node:p},u(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(Te,{node:a?.node})},2),g.stopPropagation(),g.preventDefault())},[t,s]);return ao(Ee(He.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:g=>{y(g)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function je(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=oo();return mo(r,o,r._editable)}import{jsx as me,jsxs as po}from"react/jsx-runtime";import{useLexicalComposerContext as go}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ye}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ve,$getNodeByKey as ho,isHTMLElement as Ce}from"lexical";import*as Qe from"react";import{useEffect as be,useRef as fe,useState as Ge}from"react";import{createPortal as yo}from"react-dom";var ze=0,fo=-24;var z=0;function We(t,e,o,r,n,c,i,s,u,y=!1){let{height:g,top:a}=r.getBoundingClientRect(),{top:l,width:p}=i.getBoundingClientRect(),{marginBottom:x,marginTop:m}=le(r),h=a,d=c>=a+g/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(d&&n?.elem&&n?.elem===r.nextElementSibling||!d&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(f=!0));else{z++;let b=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(d===n?.isBelow&&b===k||z<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};y?h+=g/2:d?h+=g+x/2:h-=m/2;let E=0;y||(d?E=-ze:E=ze);let w=h-l+E,S=fo-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${w}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?d?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:d,willStayInSamePosition:f}}var xo="draggable-block-menu",Ue="application/x-lexical-drag-block",ee=1/0;function qe(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function Eo(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Je(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Co(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),s=fe(!1),[u,y]=Ge(null),[g,a]=Ge(null),{editorConfig:l}=R(),p=l?.admin?.hideGutter?-44:-8;be(()=>{function h(d){let f=d.target;if(!Ce(f))return;let E=V(r,d.pageX,d.pageY,f);if(E===-1){y(null);return}if(ce(f,xo))return;let w=j(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:k}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:qe(w.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!k)&&u!==S&&y(S)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,u]),be(()=>{n.current&&ue(u,n.current,e,p)},[e,u,p]),be(()=>{function h(f){if(!s.current)return!1;let[E]=Ye(f);if(E)return!1;let{pageY:w,target:S}=f;if(!Ce(S))return!1;let b=V(r,f.pageX,f.pageY,S,100,50),k=j(t),{blockElem:N,foundAtIndex:D,isFoundNodeEmptyParagraph:B}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new _(f.x,f.y),startIndex:qe(k.length),useEdgeAsDefault:!0,verbose:!0});ee=D;let v=c.current;if(N===null||v===null)return!1;if(u!==N){let{isBelow:L,willStayInSamePosition:Q}=We(l?.admin?.hideGutter?"0px":"3rem",p+(l?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),v,N,g,w,e,f,i,B);f.preventDefault(),Q||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:L})}else g?.elem&&(Je(v,g.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function d(f){if(!s.current)return!1;let[E]=Ye(f);if(E)return!1;let{dataTransfer:w,pageY:S,target:b}=f,k=w?.getData(Ue)||"";return t.update(()=>{let N=ho(k);if(!N||!Ce(b))return!1;let D=V(r,f.pageX,f.pageY,b,100,50),{blockElem:B,isFoundNodeEmptyParagraph:v}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-D,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!B)return!1;let L=Ve(B);if(!L)return!1;if(L===N)return!0;let{height:Q,top:he}=G(B),W=S>=he+Q/2+window.scrollY;v?(L.insertBefore(N),L.remove()):W?L.insertAfter(N):L.insertBefore(N),u!==null&&y(null),document.querySelectorAll(".lexical-block-highlighter").forEach(T=>{T.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let T=oe?.getBoundingClientRect();if(!T)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=`${T.height+8}px`,P.style.width=`${T.width+8}px`,P.style.top=`${T.top+window.scrollY-4}px`,P.style.left=`${T.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",d)}},[r,p,e,t,g,u,l?.admin?.hideGutter]);function x(h){let d=h.dataTransfer;if(!d||!u)return;Eo(d,u);let f="";t.update(()=>{let E=Ve(u);E&&(f=E.getKey())}),s.current=!0,d.setData(Ue,f)}function m(){s.current=!1,g?.elem&&Je(c.current,g?.elem)}return yo(po(Qe.Fragment,{children:[me("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:x,ref:n,children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Xe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=go();return Co(r,o,r._editable)}import{c as bo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as No}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Po,$getRoot as So}from"lexical";import"react";var Ze="insert-paragraph-at-end",et=()=>{let t=bo(4),[e]=No(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(Ro)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:Ze,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${Ze}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function Ro(){let t=Po();So().append(t),t.select()}import{c as ko}from"react/compiler-runtime";import{useLexicalComposerContext as wo}from"@lexical/react/LexicalComposerContext";import*as tt from"react";var ot=()=>{let t=ko(4),{editorConfig:e}=R(),[o]=wo(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>ke(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]),tt.useEffect(r,n),null};import{useLexicalComposerContext as To}from"@lexical/react/LexicalComposerContext";import{$getSelection as vo,$isRangeSelection as Lo,RootNode as Mo}from"lexical";import{useEffect as Do}from"react";function nt(){let[t]=To();return Do(()=>t.registerNodeTransform(Mo,e=>{let o=vo();if(Lo(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 Ao}from"@lexical/react/LexicalComposerContext";import{$getSelection as Io,COMMAND_PRIORITY_LOW as Bo,SELECT_ALL_COMMAND as _o}from"lexical";import{useEffect as Oo}from"react";function rt(){let[t]=Ao();return Oo(()=>t.registerCommand(_o,()=>{if(Io())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Bo),[t]),null}import{jsx as q,jsxs as st}from"react/jsx-runtime";import{useLexicalComposerContext as $o}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as lt}from"@payloadcms/ui";import{useCallback as Ko,useMemo as Ho,useState as jo}from"react";import"react";import*as at from"react-dom";import{c as Fo}from"react/compiler-runtime";import"react";function it(t,e){let o=Fo(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==c||o[1]!==i||o[2]!==t?(s=u=>{let{query:y}=u,g="[^"+t+we+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+c+"}))$").exec(y);if(l!==null){let p=l[1],x=l[3];if(x.length>=i)return{leadOffset:l.index+p.length,matchingString:x,replaceableString:l[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var I="slash-menu-popup";function zo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=R(),{i18n:s}=lt(),u=`${I}__item ${I}__item-${e.key}`;t&&(u+=` ${I}__item--selected`);let y=e.key;return e.label&&(y=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:s,schemaPath:i}):e.label),y.length>25&&(y=y.substring(0,25)+"..."),st("button",{"aria-selected":t,className:u,id:I+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&q(e.Icon,{}),q("span",{className:`${I}__item-text`,children:y})]},e.key)}function ct({anchorElem:t=document.body}){let[e]=$o(),[o,r]=jo(null),{editorConfig:n}=R(),{i18n:c}=lt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),u=it("/",{minLength:0}),y=Ko(()=>{let a=[];for(let l of n.features.slashMenu.dynamicGroups)if(o){let p=l({editor:e,queryString:o});a=a.concat(p)}return a},[e,o,n?.features]),g=Ho(()=>{let a=[];for(let l of n?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(p=>{let x=p.items.filter(m=>{let h=m.key;return m.label&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),new RegExp(o,"gi").exec(h)?!0:m.keywords!=null?m.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...p,items:x}:null}),a=a.filter(p=>p!=null);let l=y();for(let p of l){let x=a.find(m=>m.key===p.key);x?a=a.filter(m=>m.key!==p.key):x={...p,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,y,i,c,s]);return q(ve,{anchorElem:t,groups:g,menuRenderFn:(a,{selectedItemKey:l,selectItemAndCleanUp:p,setSelectedItemKey:x})=>a.current&&g.length?at.createPortal(q("div",{className:I,children:g.map(m=>{let h=m.key;return m.label&&i&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),st("div",{className:`${I}__group ${I}__group-${m.key}`,children:[q("div",{className:`${I}__group-title`,children:h}),m.items.map((d,f)=>q(zo,{index:f,isSelected:l===d.key,item:d,onClick:()=>{x(d.key),p(d)},onMouseEnter:()=>{x(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:u})}import{c as Wo}from"react/compiler-runtime";import{useLexicalComposerContext as Yo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Vo,TextNode as Go}from"lexical";import{useEffect as Uo}from"react";function ut(t){let e=Wo(6),{features:o}=t,[r]=Yo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=qo(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Go,s=>{i.forEach(u=>{s.hasFormat(u)&&s.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Uo(n,c),null}function qo(t){let e=Object.keys(Vo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Jo}from"react/compiler-runtime";import{jsx as dt}from"react/jsx-runtime";import{ContentEditable as Qo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Xo}from"@payloadcms/ui";import"react";function mt(t){let e=Jo(7),{className:o,editorConfig:r}=t,{t:n}=Xo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=dt(Qo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:dt("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var pt=t=>{let e=Zo(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=R(),[s]=en(),[u,y]=cn(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&y(m)},e[0]=g):g=e[0];let a=g,l,p;e[1]!==s||e[2]!==i?(l=()=>{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)},h=()=>{i.blurEditor(i)},d=s.registerCommand(ln,()=>(m(),!0),ft),f=s.registerCommand(sn,()=>(h(),!0),ft);return()=>{d(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},p=[s,i],e[1]=s,e[2]=i,e[3]=l,e[4]=p):(l=e[3],p=e[4]),an(l,p);let x;if(e[5]!==s||e[6]!==o||e[7]!==r||e[8]!==u||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(d,f,E)=>{(!E.has("focus")||E.size>1)&&c?.(d,f,E)},e[12]=c,e[13]=m):m=e[13];let h;e[14]!==s||e[15]!==o.features.plugins||e[16]!==u||e[17]!==n?(h=u&&te(J.Fragment,{children:[!n&&s.isEditable()&&te(J.Fragment,{children:[C(Xe,{anchorElem:u}),C(je,{anchorElem:u})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&n))return C(K,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),s.isEditable()&&C(J.Fragment,{children:C(ct,{anchorElem:u})})]}),e[14]=s,e[15]=o.features.plugins,e[16]=u,e[17]=n,e[18]=h):h=e[18],x=te(J.Fragment,{children:[o.features.plugins?.map(un),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(dn),C(rn,{contentEditable:C("div",{className:"editor-scroller",children:C("div",{className:"editor",ref:a,children:C(mt,{editorConfig:o})})}),ErrorBoundary:tn}),C(nt,{}),C(et,{}),C(Be,{}),C(ut,{features:o.features}),C(rt,{}),C(nn,{ignoreSelectionChange:!0,onChange:m}),h,s.isEditable()&&te(J.Fragment,{children:[C(on,{}),o?.features?.markdownTransformers?.length>0&&C(ot,{})]}),o.features.plugins?.map(mn),o.features.plugins?.map(fn)]}),o.features.plugins?.map(pn)]}),e[5]=s,e[6]=o,e[7]=r,e[8]=u,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function un(t){if(t.position==="aboveContainer")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}function dn(t){if(t.position==="top")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}function mn(t){if(t.position==="normal")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}function fn(t){if(t.position==="bottom")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}function pn(t){if(t.position==="belowContainer")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}var ht=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(ht,{providers:e.slice(1),children:t})}):O(o,{children:t})},yt=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:s}=t,u=R(),y=hn(),g=gt.useRef(null),a=yn(()=>{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:l=>{throw l},theme:o.lexical.theme}},[o]);return a?O(gn,{initialConfig:a,children:O(Re,{editorConfig:o,editorContainerRef:g,fieldProps:r,parentContext:u?.editDepth===y?u:void 0,children:O(ht,{providers:o.features.providers,children:O(pt,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",Tn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:s,required:u},path:y,readOnly:g,validate:a}=t,l=g||c,p=bn(),x=Ct((M,$)=>typeof a=="function"?a(M,{...$,required:u}):!0,[a,u]),{customComponents:{AfterInput:m,BeforeInput:h,Description:d,Error:f,Label:E}={},disabled:w,initialValue:S,path:b,setValue:k,showError:N,value:D}=Pn({potentiallyStalePath:y,validate:x}),B=l||w,[v,L]=Nt(!1),[Q,he]=Nt(),ye=Et.useRef(S),W=Et.useRef(D);bt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==v&&L($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[v]);let Pe=[pe,"field-type",r,N&&"error",B&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${p}`,T=kn(void 0),P=Ct(M=>{let $=Rt=>{let Se=Rt.toJSON();W.current=Se,k(Se)};typeof window.requestIdleCallback=="function"?(typeof window.cancelIdleCallback=="function"&&T.current&&cancelIdleCallback(T.current),T.current=requestIdleCallback(()=>$(M),{timeout:500})):$(M)},[k]),Pt=Rn(()=>Sn(o),[o]),St=Nn(M=>{W.current!==D&&JSON.stringify(W.current)!==JSON.stringify(D)&&(ye.current=M,W.current=D,he(new Date))});return bt(()=>{Object.is(S,ye.current)||St(S)},[S]),ge("div",{className:Pe,style:Pt,children:[F(xt,{CustomComponent:f,Fallback:F(En,{path:b,showError:N})}),E||F(Cn,{label:i,localized:s,path:b,required:u}),ge("div",{className:`${pe}__wrap`,children:[ge(wn,{fallbackRender:vn,onReset:()=>{},children:[h,F(yt,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:B,value:D},JSON.stringify({path:b,rerenderProviderKey:Q})),m]}),d,F(xt,{CustomComponent:d,Fallback:F(xn,{description:n,path:b})})]})]},oe)};function vn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var cs=Tn;export{cs as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-
|
|
1
|
+
"use client";import{b as ke,e as _,g as we,h as Te,i as ve,j as Le,k as Me}from"./chunk-LUNX5J6B.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as xn,FieldError as En,FieldLabel as Cn,RenderCustomComponent as xt,useEditDepth as bn,useEffectEvent as Nn,useField as Pn}from"@payloadcms/ui";import{mergeFieldStyles as Sn}from"@payloadcms/ui/shared";import Et,{useCallback as Ct,useEffect as bt,useMemo as Rn,useRef as kn,useState as Nt}from"react";import{ErrorBoundary as wn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as gn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as hn}from"@payloadcms/ui";import*as gt from"react";import{useMemo as yn}from"react";import{c as Zo}from"react/compiler-runtime";import{jsx as C,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as tn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as on}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as nn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as rn}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as sn,COMMAND_PRIORITY_LOW as ft,FOCUS_COMMAND as ln}from"lexical";import*as J from"react";import{useEffect as an,useState as cn}from"react";import{jsx as De}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&De(o.Component,{anchorElem:t,clientProps:e}):o.Component&&De(o.Component,{clientProps:e});import{c as kt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Tt}from"@lexical/utils";import{$createNodeSelection as vt,$getEditor as X,$getNearestNodeFromDOMNode as Lt,$getSelection as re,$isDecoratorNode as H,$isElementNode as xe,$isLineBreakNode as Mt,$isNodeSelection as ie,$isRangeSelection as Ae,$isRootOrShadowRoot as Dt,$isTextNode as At,$setSelection as Ie,CLICK_COMMAND as It,COMMAND_PRIORITY_LOW as Y,KEY_ARROW_DOWN_COMMAND as Bt,KEY_ARROW_UP_COMMAND as _t,KEY_BACKSPACE_COMMAND as Ot,KEY_DELETE_COMMAND as Ft,SELECTION_CHANGE_COMMAND as $t}from"lexical";import{useEffect as Kt}from"react";function Be(){let t=kt(3),[e]=wt(),o=Gt,r,n;return t[0]!==e?(r=()=>Tt(e.registerCommand(It,Vt,Y),e.registerCommand(Ft,o,Y),e.registerCommand(Ot,o,Y),e.registerCommand($t,Yt,Y),e.registerCommand(_t,zt,Y),e.registerCommand(Bt,Ht,Y)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Kt(r,n),null}function Ht(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let y=X().getElementByKey(i.getKey());return y&&Z({element:y,node:i}),!0}if(!xe(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,jt),c=n?.getNextSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function jt(t){return _e(t)!==null}function zt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let y=X().getElementByKey(i.getKey());return y?(Z({element:y,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(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Wt),c=n?.getPreviousSibling();if(!n||c!==Oe(n))return!1;if(H(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Wt(t){return Oe(t)!==null}function Yt(){let t=Jt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function Vt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=qt(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"]')?Ie(null):Z(e),!0}function Gt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Ut),!0):!1}function Ut(t){t.remove()}function qt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=Lt(e);return H(o)?{element:e,node:o}:void 0}function Jt(){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=vt();o.add(e.getKey()),Ie(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)||Dt(t))return!1;let e=t.getFirstChild(),o=e===null||Mt(e)||At(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 Oe(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 oo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as no,isHTMLElement as ro}from"lexical";import*as He from"react";import{useCallback as io,useEffect as Ke,useRef as so,useState as lo}from"react";import{createPortal as ao}from"react-dom";var V=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:u,right:y,top:g}=t.getBoundingClientRect(),a=g+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||e<u-n||e>y+n)return-1;(e<u||e>y)&&(i=e<u?e-u:e-y)}return i};import{$getNodeByKey as ae}from"lexical";function G(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=(u,y)=>u?parseFloat(window.getComputedStyle(u)[y]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Qt}from"lexical";function j(t){return t.getEditorState().read(()=>Qt().getChildrenKeys())}var Xt=1,Zt=-1,Fe=0,A={props:null,result:null};function eo(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function U(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:s},startIndex:u=0,useEdgeAsDefault:y=!1}=t;if(o>0&&A.props&&A.result&&A.props.fuzzy===t.fuzzy&&A.props.horizontalOffset===t.horizontalOffset&&A.props.useEdgeAsDefault===t.useEdgeAsDefault&&eo(A.props.point,t.point,o))return A.result;let g=e.getBoundingClientRect(),a=j(r),l={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(y){let m=r.getElementByKey(a[0]),h=r.getElementByKey(a[a.length-1]);if(m&&h){let[d,f]=[G(m),G(h)];if(s<d.top?(l.blockElem=m,l.distance=d.top-s,l.blockNode=ae(a[0]),l.foundAtIndex=0):s>f.bottom&&(l.distance=s-f.bottom,l.blockNode=ae(a[a.length-1]),l.blockElem=h,l.foundAtIndex=a.length-1),l?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=u,x=Fe;for(;p>=0&&p<a.length;){let m=a[p],h=r.getElementByKey(m);if(h===null)break;let d=new _(i+c,s),f=Le.fromDOMRect(G(h)),{marginBottom:E,marginTop:w}=le(h),S=f.generateNewRect({bottom:f.bottom+E,left:g.left,right:g.right,top:f.top-w}),{distance:b,isOnBottomSide:k,isOnTopSide:N}=S.distanceFromPoint(d);if(b===0){l.blockElem=h,l.blockNode=ae(m),l.foundAtIndex=p,l.distance=b,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else n&&b<l.distance&&(l.blockElem=h,l.blockNode=ae(m),l.distance=b,l.foundAtIndex=p);x===Fe&&(N?x=Zt:k?x=Xt:x=1/0),p+=x}}),A.props=t,A.result={blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph},{blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var to=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function $e(t){if(!t||to.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 ue(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=n.top+8-s.top;else{let a=$e(t)?parseInt(c.lineHeight,10):0;u=n.top+(a-i.height)/2-s.top}let g=r;e.style.opacity="1",e.style.transform=`translate(${g}px, ${u}px)`}var co="add-block-menu",de=1/0;function uo(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function mo(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),c=n?.admin?.hideGutter?-24:12,i=so(null),[s,u]=lo(null);Ke(()=>{function g(a){let l=a.target;if(!ro(l))return;let p=V(r,a.pageX,a.pageY,l);if(p===-1){u(null);return}if(ce(l,co))return;let x=j(t),{blockElem:m,blockNode:h,foundAtIndex:d}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:uo(x.length),useEdgeAsDefault:!1});de=d,m&&h&&(s?.node!==h||s?.elem!==m)&&u({elem:m,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[r,e,t,s]),Ke(()=>{i.current&&s?.node&&ue(s?.elem,i.current,e,c)},[e,s,c]);let y=io(g=>{let a=s;a?.node&&(t.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let p=no();a?.node.insertAfter(p),setTimeout(()=>{a={elem:t.getElementByKey(p.getKey()),node:p},u(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(Te,{node:a?.node})},2),g.stopPropagation(),g.preventDefault())},[t,s]);return ao(Ee(He.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:g=>{y(g)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function je(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=oo();return mo(r,o,r._editable)}import{jsx as me,jsxs as po}from"react/jsx-runtime";import{useLexicalComposerContext as go}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ye}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ve,$getNodeByKey as ho,isHTMLElement as Ce}from"lexical";import*as Qe from"react";import{useEffect as be,useRef as fe,useState as Ge}from"react";import{createPortal as yo}from"react-dom";var ze=0,fo=-24;var z=0;function We(t,e,o,r,n,c,i,s,u,y=!1){let{height:g,top:a}=r.getBoundingClientRect(),{top:l,width:p}=i.getBoundingClientRect(),{marginBottom:x,marginTop:m}=le(r),h=a,d=c>=a+g/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(d&&n?.elem&&n?.elem===r.nextElementSibling||!d&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(f=!0));else{z++;let b=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(d===n?.isBelow&&b===k||z<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};y?h+=g/2:d?h+=g+x/2:h-=m/2;let E=0;y||(d?E=-ze:E=ze);let w=h-l+E,S=fo-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${w}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?d?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:d,willStayInSamePosition:f}}var xo="draggable-block-menu",Ue="application/x-lexical-drag-block",ee=1/0;function qe(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function Eo(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Je(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Co(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),s=fe(!1),[u,y]=Ge(null),[g,a]=Ge(null),{editorConfig:l}=R(),p=l?.admin?.hideGutter?-44:-8;be(()=>{function h(d){let f=d.target;if(!Ce(f))return;let E=V(r,d.pageX,d.pageY,f);if(E===-1){y(null);return}if(ce(f,xo))return;let w=j(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:k}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:qe(w.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!k)&&u!==S&&y(S)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,u]),be(()=>{n.current&&ue(u,n.current,e,p)},[e,u,p]),be(()=>{function h(f){if(!s.current)return!1;let[E]=Ye(f);if(E)return!1;let{pageY:w,target:S}=f;if(!Ce(S))return!1;let b=V(r,f.pageX,f.pageY,S,100,50),k=j(t),{blockElem:N,foundAtIndex:D,isFoundNodeEmptyParagraph:B}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new _(f.x,f.y),startIndex:qe(k.length),useEdgeAsDefault:!0,verbose:!0});ee=D;let v=c.current;if(N===null||v===null)return!1;if(u!==N){let{isBelow:L,willStayInSamePosition:Q}=We(l?.admin?.hideGutter?"0px":"3rem",p+(l?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),v,N,g,w,e,f,i,B);f.preventDefault(),Q||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:L})}else g?.elem&&(Je(v,g.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function d(f){if(!s.current)return!1;let[E]=Ye(f);if(E)return!1;let{dataTransfer:w,pageY:S,target:b}=f,k=w?.getData(Ue)||"";return t.update(()=>{let N=ho(k);if(!N||!Ce(b))return!1;let D=V(r,f.pageX,f.pageY,b,100,50),{blockElem:B,isFoundNodeEmptyParagraph:v}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-D,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!B)return!1;let L=Ve(B);if(!L)return!1;if(L===N)return!0;let{height:Q,top:he}=G(B),W=S>=he+Q/2+window.scrollY;v?(L.insertBefore(N),L.remove()):W?L.insertAfter(N):L.insertBefore(N),u!==null&&y(null),document.querySelectorAll(".lexical-block-highlighter").forEach(T=>{T.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let T=oe?.getBoundingClientRect();if(!T)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=`${T.height+8}px`,P.style.width=`${T.width+8}px`,P.style.top=`${T.top+window.scrollY-4}px`,P.style.left=`${T.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",d)}},[r,p,e,t,g,u,l?.admin?.hideGutter]);function x(h){let d=h.dataTransfer;if(!d||!u)return;Eo(d,u);let f="";t.update(()=>{let E=Ve(u);E&&(f=E.getKey())}),s.current=!0,d.setData(Ue,f)}function m(){s.current=!1,g?.elem&&Je(c.current,g?.elem)}return yo(po(Qe.Fragment,{children:[me("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:x,ref:n,children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Xe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=go();return Co(r,o,r._editable)}import{c as bo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as No}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Po,$getRoot as So}from"lexical";import"react";var Ze="insert-paragraph-at-end",et=()=>{let t=bo(4),[e]=No(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(Ro)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:Ze,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${Ze}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function Ro(){let t=Po();So().append(t),t.select()}import{c as ko}from"react/compiler-runtime";import{useLexicalComposerContext as wo}from"@lexical/react/LexicalComposerContext";import*as tt from"react";var ot=()=>{let t=ko(4),{editorConfig:e}=R(),[o]=wo(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>ke(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]),tt.useEffect(r,n),null};import{useLexicalComposerContext as To}from"@lexical/react/LexicalComposerContext";import{$getSelection as vo,$isRangeSelection as Lo,RootNode as Mo}from"lexical";import{useEffect as Do}from"react";function nt(){let[t]=To();return Do(()=>t.registerNodeTransform(Mo,e=>{let o=vo();if(Lo(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 Ao}from"@lexical/react/LexicalComposerContext";import{$getSelection as Io,COMMAND_PRIORITY_LOW as Bo,SELECT_ALL_COMMAND as _o}from"lexical";import{useEffect as Oo}from"react";function rt(){let[t]=Ao();return Oo(()=>t.registerCommand(_o,()=>{if(Io())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Bo),[t]),null}import{jsx as q,jsxs as st}from"react/jsx-runtime";import{useLexicalComposerContext as $o}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as lt}from"@payloadcms/ui";import{useCallback as Ko,useMemo as Ho,useState as jo}from"react";import"react";import*as at from"react-dom";import{c as Fo}from"react/compiler-runtime";import"react";function it(t,e){let o=Fo(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==c||o[1]!==i||o[2]!==t?(s=u=>{let{query:y}=u,g="[^"+t+we+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+c+"}))$").exec(y);if(l!==null){let p=l[1],x=l[3];if(x.length>=i)return{leadOffset:l.index+p.length,matchingString:x,replaceableString:l[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var I="slash-menu-popup";function zo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=R(),{i18n:s}=lt(),u=`${I}__item ${I}__item-${e.key}`;t&&(u+=` ${I}__item--selected`);let y=e.key;return e.label&&(y=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:s,schemaPath:i}):e.label),y.length>25&&(y=y.substring(0,25)+"..."),st("button",{"aria-selected":t,className:u,id:I+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&q(e.Icon,{}),q("span",{className:`${I}__item-text`,children:y})]},e.key)}function ct({anchorElem:t=document.body}){let[e]=$o(),[o,r]=jo(null),{editorConfig:n}=R(),{i18n:c}=lt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),u=it("/",{minLength:0}),y=Ko(()=>{let a=[];for(let l of n.features.slashMenu.dynamicGroups)if(o){let p=l({editor:e,queryString:o});a=a.concat(p)}return a},[e,o,n?.features]),g=Ho(()=>{let a=[];for(let l of n?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(p=>{let x=p.items.filter(m=>{let h=m.key;return m.label&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),new RegExp(o,"gi").exec(h)?!0:m.keywords!=null?m.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...p,items:x}:null}),a=a.filter(p=>p!=null);let l=y();for(let p of l){let x=a.find(m=>m.key===p.key);x?a=a.filter(m=>m.key!==p.key):x={...p,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,y,i,c,s]);return q(ve,{anchorElem:t,groups:g,menuRenderFn:(a,{selectedItemKey:l,selectItemAndCleanUp:p,setSelectedItemKey:x})=>a.current&&g.length?at.createPortal(q("div",{className:I,children:g.map(m=>{let h=m.key;return m.label&&i&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),st("div",{className:`${I}__group ${I}__group-${m.key}`,children:[q("div",{className:`${I}__group-title`,children:h}),m.items.map((d,f)=>q(zo,{index:f,isSelected:l===d.key,item:d,onClick:()=>{x(d.key),p(d)},onMouseEnter:()=>{x(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:u})}import{c as Wo}from"react/compiler-runtime";import{useLexicalComposerContext as Yo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Vo,TextNode as Go}from"lexical";import{useEffect as Uo}from"react";function ut(t){let e=Wo(6),{features:o}=t,[r]=Yo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=qo(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Go,s=>{i.forEach(u=>{s.hasFormat(u)&&s.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Uo(n,c),null}function qo(t){let e=Object.keys(Vo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Jo}from"react/compiler-runtime";import{jsx as dt}from"react/jsx-runtime";import{ContentEditable as Qo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Xo}from"@payloadcms/ui";import"react";function mt(t){let e=Jo(7),{className:o,editorConfig:r}=t,{t:n}=Xo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=dt(Qo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:dt("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var pt=t=>{let e=Zo(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=R(),[s]=en(),[u,y]=cn(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&y(m)},e[0]=g):g=e[0];let a=g,l,p;e[1]!==s||e[2]!==i?(l=()=>{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)},h=()=>{i.blurEditor(i)},d=s.registerCommand(ln,()=>(m(),!0),ft),f=s.registerCommand(sn,()=>(h(),!0),ft);return()=>{d(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},p=[s,i],e[1]=s,e[2]=i,e[3]=l,e[4]=p):(l=e[3],p=e[4]),an(l,p);let x;if(e[5]!==s||e[6]!==o||e[7]!==r||e[8]!==u||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(d,f,E)=>{(!E.has("focus")||E.size>1)&&c?.(d,f,E)},e[12]=c,e[13]=m):m=e[13];let h;e[14]!==s||e[15]!==o.features.plugins||e[16]!==u||e[17]!==n?(h=u&&te(J.Fragment,{children:[!n&&s.isEditable()&&te(J.Fragment,{children:[C(Xe,{anchorElem:u}),C(je,{anchorElem:u})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&n))return C(K,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),s.isEditable()&&C(J.Fragment,{children:C(ct,{anchorElem:u})})]}),e[14]=s,e[15]=o.features.plugins,e[16]=u,e[17]=n,e[18]=h):h=e[18],x=te(J.Fragment,{children:[o.features.plugins?.map(un),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(dn),C(rn,{contentEditable:C("div",{className:"editor-scroller",children:C("div",{className:"editor",ref:a,children:C(mt,{editorConfig:o})})}),ErrorBoundary:tn}),C(nt,{}),C(et,{}),C(Be,{}),C(ut,{features:o.features}),C(rt,{}),C(nn,{ignoreSelectionChange:!0,onChange:m}),h,s.isEditable()&&te(J.Fragment,{children:[C(on,{}),o?.features?.markdownTransformers?.length>0&&C(ot,{})]}),o.features.plugins?.map(mn),o.features.plugins?.map(fn)]}),o.features.plugins?.map(pn)]}),e[5]=s,e[6]=o,e[7]=r,e[8]=u,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function un(t){if(t.position==="aboveContainer")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}function dn(t){if(t.position==="top")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}function mn(t){if(t.position==="normal")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}function fn(t){if(t.position==="bottom")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}function pn(t){if(t.position==="belowContainer")return C(K,{clientProps:t.clientProps,plugin:t},t.key)}var ht=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(ht,{providers:e.slice(1),children:t})}):O(o,{children:t})},yt=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:s}=t,u=R(),y=hn(),g=gt.useRef(null),a=yn(()=>{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:l=>{throw l},theme:o.lexical.theme}},[o]);return a?O(gn,{initialConfig:a,children:O(Re,{editorConfig:o,editorContainerRef:g,fieldProps:r,parentContext:u?.editDepth===y?u:void 0,children:O(ht,{providers:o.features.providers,children:O(pt,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",Tn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:s,required:u},path:y,readOnly:g,validate:a}=t,l=g||c,p=bn(),x=Ct((M,$)=>typeof a=="function"?a(M,{...$,required:u}):!0,[a,u]),{customComponents:{AfterInput:m,BeforeInput:h,Description:d,Error:f,Label:E}={},disabled:w,initialValue:S,path:b,setValue:k,showError:N,value:D}=Pn({potentiallyStalePath:y,validate:x}),B=l||w,[v,L]=Nt(!1),[Q,he]=Nt(),ye=Et.useRef(S),W=Et.useRef(D);bt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==v&&L($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[v]);let Pe=[pe,"field-type",r,N&&"error",B&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${p}`,T=kn(void 0),P=Ct(M=>{let $=Rt=>{let Se=Rt.toJSON();W.current=Se,k(Se)};typeof window.requestIdleCallback=="function"?(typeof window.cancelIdleCallback=="function"&&T.current&&cancelIdleCallback(T.current),T.current=requestIdleCallback(()=>$(M),{timeout:500})):$(M)},[k]),Pt=Rn(()=>Sn(o),[o]),St=Nn(M=>{W.current!==D&&JSON.stringify(W.current)!==JSON.stringify(D)&&(ye.current=M,W.current=D,he(new Date))});return bt(()=>{Object.is(S,ye.current)||St(S)},[S]),ge("div",{className:Pe,style:Pt,children:[F(xt,{CustomComponent:f,Fallback:F(En,{path:b,showError:N})}),E||F(Cn,{label:i,localized:s,path:b,required:u}),ge("div",{className:`${pe}__wrap`,children:[ge(wn,{fallbackRender:vn,onReset:()=>{},children:[h,F(yt,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:B,value:D},JSON.stringify({path:b,rerenderProviderKey:Q})),m]}),d,F(xt,{CustomComponent:d,Fallback:F(xn,{description:n,path:b})})]})]},oe)};function vn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var cs=Tn;export{cs as RichText};
|
|
2
|
+
//# sourceMappingURL=Field-6GAC5Y2D.js.map
|