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