@payloadcms/richtext-lexical 3.39.0-canary.3 → 3.39.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";import{b as Re,e as _,g as we,h as Te,i as ve,j as De,k as Me}from"./chunk-DOZWITPU.js";import{a as ke,b as k}from"./chunk-BZZVLW4U.js";import{jsx as O,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as fn,FieldError as mn,FieldLabel as pn,RenderCustomComponent as yt,useEditDepth as gn,useEffectEvent as hn,useField as yn}from"@payloadcms/ui";import{mergeFieldStyles as xn}from"@payloadcms/ui/shared";import xt,{useCallback as Et,useEffect as bt,useMemo as En,useRef as bn,useState as Ct}from"react";import{ErrorBoundary as Cn}from"react-error-boundary";import"./bundled.css";import{jsx as F}from"react/jsx-runtime";import{LexicalComposer as cn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as dn}from"@payloadcms/ui";import*as pt from"react";import{useMemo as un}from"react";import{c as Go}from"react/compiler-runtime";import{jsx as b,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as Uo}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as qo}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Jo}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Qo}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Xo}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Zo,COMMAND_PRIORITY_LOW as ft,FOCUS_COMMAND as en}from"lexical";import*as J from"react";import{useEffect as tn,useState as on}from"react";import{jsx as Le}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Le(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Le(o.Component,{clientProps:e});import{c as kt}from"react/compiler-runtime";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as wt}from"@lexical/utils";import{$createNodeSelection as Tt,$getEditor as X,$getNearestNodeFromDOMNode as vt,$getSelection as re,$isDecoratorNode as H,$isElementNode as xe,$isLineBreakNode as Dt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as Mt,$isTextNode as Lt,$setSelection as Ie,CLICK_COMMAND as Bt,COMMAND_PRIORITY_LOW as Y,KEY_ARROW_DOWN_COMMAND as It,KEY_ARROW_UP_COMMAND as At,KEY_BACKSPACE_COMMAND as _t,KEY_DELETE_COMMAND as Ft,SELECTION_CHANGE_COMMAND as Ot}from"lexical";import{useEffect as $t}from"react";function Ae(){let t=kt(3),[e]=Rt(),o=Vt,r,n;return t[0]!==e?(r=()=>wt(e.registerCommand(Bt,Yt,Y),e.registerCommand(Ft,o,Y),e.registerCommand(_t,o,Y),e.registerCommand(Ot,Wt,Y),e.registerCommand(At,jt,Y),e.registerCommand(It,Kt,Y)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),$t(r,n),null}function Kt(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(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Ht),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 Ht(t){return _e(t)!==null}function jt(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(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,zt),c=n?.getPreviousSibling();if(!n||c!==Fe(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 zt(t){return Fe(t)!==null}function Wt(){let t=qt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function Yt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Ut(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 Vt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Gt),!0):!1}function Gt(t){t.remove()}function Ut(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=vt(e);return H(o)?{element:e,node:o}:void 0}function qt(){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=Tt();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)||Mt(t))return!1;let e=t.getFirstChild(),o=e===null||Dt(e)||Lt(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 Fe(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 to}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as oo,isHTMLElement as no}from"lexical";import*as He from"react";import{useCallback as ro,useEffect as Ke,useRef as io,useState as so}from"react";import{createPortal as lo}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:d,right:y,top:g}=t.getBoundingClientRect(),a=g+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||e<d-n||e>y+n)return-1;(e<d||e>y)&&(i=e<d?e-d: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=(d,y)=>d?parseFloat(window.getComputedStyle(d)[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 Jt}from"lexical";function j(t){return t.getEditorState().read(()=>Jt().getChildrenKeys())}var Qt=1,Xt=-1,Oe=0,B={props:null,result:null};function Zt(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:d=0,useEdgeAsDefault:y=!1}=t;if(o>0&&B.props&&B.result&&B.props.fuzzy===t.fuzzy&&B.props.horizontalOffset===t.horizontalOffset&&B.props.useEdgeAsDefault===t.useEdgeAsDefault&&Zt(B.props.point,t.point,o))return B.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 f=r.getElementByKey(a[0]),h=r.getElementByKey(a[a.length-1]);if(f&&h){let[u,m]=[G(f),G(h)];if(s<u.top?(l.blockElem=f,l.distance=u.top-s,l.blockNode=ae(a[0]),l.foundAtIndex=0):s>m.bottom&&(l.distance=s-m.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=d,x=Oe;for(;p>=0&&p<a.length;){let f=a[p],h=r.getElementByKey(f);if(h===null)break;let u=new _(i+c,s),m=De.fromDOMRect(G(h)),{marginBottom:E,marginTop:w}=le(h),S=m.generateNewRect({bottom:m.bottom+E,left:g.left,right:g.right,top:m.top-w}),{distance:C,isOnBottomSide:R,isOnTopSide:N}=S.distanceFromPoint(u);if(C===0){l.blockElem=h,l.blockNode=ae(f),l.foundAtIndex=p,l.distance=C,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else n&&C<l.distance&&(l.blockElem=h,l.blockNode=ae(f),l.distance=C,l.foundAtIndex=p);x===Oe&&(N?x=Xt:R?x=Qt:x=1/0),p+=x}}),B.props=t,B.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 eo=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function $e(t){if(!t||eo.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function de(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))d=n.top+8-s.top;else{let a=$e(t)?parseInt(c.lineHeight,10):0;d=n.top+(a-i.height)/2-s.top}let g=r;e.style.opacity="1",e.style.transform=`translate(${g}px, ${d}px)`}var ao="add-block-menu",ue=1/0;function co(t){return t===0?1/0:ue>=0&&ue<t?ue:Math.floor(t/2)}function uo(t,e,o){let r=e.parentElement,{editorConfig:n}=k(),c=n?.admin?.hideGutter?-24:12,i=io(null),[s,d]=so(null);Ke(()=>{function g(a){let l=a.target;if(!no(l))return;let p=V(r,a.pageX,a.pageY,l);if(p===-1){d(null);return}if(ce(l,ao))return;let x=j(t),{blockElem:f,blockNode:h,foundAtIndex:u}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:co(x.length),useEdgeAsDefault:!1});ue=u,f&&h&&(s?.node!==h||s?.elem!==f)&&d({elem:f,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[r,e,t,s]),Ke(()=>{i.current&&s?.node&&de(s?.elem,i.current,e,c)},[e,s,c]);let y=ro(g=>{let a=s;a?.node&&(t.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let p=oo();a?.node.insertAfter(p),setTimeout(()=>{a={elem:t.getElementByKey(p.getKey()),node:p},d(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 lo(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]=to();return uo(r,o,r._editable)}import{jsx as fe,jsxs as mo}from"react/jsx-runtime";import{useLexicalComposerContext as po}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ye}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ve,$getNodeByKey as go,isHTMLElement as be}from"lexical";import*as Qe from"react";import{useEffect as Ce,useRef as me,useState as Ge}from"react";import{createPortal as ho}from"react-dom";var ze=0,fo=-24;var z=0;function We(t,e,o,r,n,c,i,s,d,y=!1){let{height:g,top:a}=r.getBoundingClientRect(),{top:l,width:p}=i.getBoundingClientRect(),{marginBottom:x,marginTop:f}=le(r),h=a,u=c>=a+g/2+window.scrollY,m=!1;if(n?.elem)if(r!==n?.elem)(u&&n?.elem&&n?.elem===r.nextElementSibling||!u&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(m=!0));else{z++;let C=n?.boundingBox?.y,R=r.getBoundingClientRect().y;(u===n?.isBelow&&C===R||z<200)&&(m=!1)}if(m)return{isBelow:u,willStayInSamePosition:m};y?h+=g/2:u?h+=g+x/2:h-=f/2;let E=0;y||(u?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?u?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:u,willStayInSamePosition:m}}var yo="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 xo(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 Eo(t,e,o){let r=e.parentElement,n=me(null),c=me(null),i=me(null),s=me(!1),[d,y]=Ge(null),[g,a]=Ge(null),{editorConfig:l}=k(),p=l?.admin?.hideGutter?-44:-8;Ce(()=>{function h(u){let m=u.target;if(!be(m))return;let E=V(r,u.pageX,u.pageY,m);if(E===-1){y(null);return}if(ce(m,yo))return;let w=j(t),{blockElem:S,foundAtIndex:C,isFoundNodeEmptyParagraph:R}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(u.x,u.y),startIndex:qe(w.length),useEdgeAsDefault:!1,verbose:!1});ee=C,!(!S&&!R)&&d!==S&&y(S)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,d]),Ce(()=>{n.current&&de(d,n.current,e,p)},[e,d,p]),Ce(()=>{function h(m){if(!s.current)return!1;let[E]=Ye(m);if(E)return!1;let{pageY:w,target:S}=m;if(!be(S))return!1;let C=V(r,m.pageX,m.pageY,S,100,50),R=j(t),{blockElem:N,foundAtIndex:L,isFoundNodeEmptyParagraph:A}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new _(m.x,m.y),startIndex:qe(R.length),useEdgeAsDefault:!0,verbose:!0});ee=L;let v=c.current;if(N===null||v===null)return!1;if(d!==N){let{isBelow:D,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,m,i,A);m.preventDefault(),Q||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:D})}else g?.elem&&(Je(v,g.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function u(m){if(!s.current)return!1;let[E]=Ye(m);if(E)return!1;let{dataTransfer:w,pageY:S,target:C}=m,R=w?.getData(Ue)||"";return t.update(()=>{let N=go(R);if(!N||!be(C))return!1;let L=V(r,m.pageX,m.pageY,C,100,50),{blockElem:A,isFoundNodeEmptyParagraph:v}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-L,point:new _(m.x,m.y),useEdgeAsDefault:!0});if(!A)return!1;let D=Ve(A);if(!D)return!1;if(D===N)return!0;let{height:Q,top:he}=G(A),W=S>=he+Q/2+window.scrollY;v?(D.insertBefore(N),D.remove()):W?D.insertAfter(N):D.insertBefore(N),d!==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",u),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",u)}},[r,p,e,t,g,d,l?.admin?.hideGutter]);function x(h){let u=h.dataTransfer;if(!u||!d)return;xo(u,d);let m="";t.update(()=>{let E=Ve(d);E&&(m=E.getKey())}),s.current=!0,u.setData(Ue,m)}function f(){s.current=!1,g?.elem&&Je(c.current,g?.elem)}return ho(mo(Qe.Fragment,{children:[fe("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:f,onDragStart:x,ref:n,children:fe("div",{className:o?"icon":""})}),fe("div",{className:"draggable-block-target-line",ref:c}),fe("div",{className:"debug-highlight",ref:i})]}),e)}function Xe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=po();return Eo(r,o,r._editable)}import{c as bo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as Co}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as No,$getRoot as Po}from"lexical";import"react";var Ze="insert-paragraph-at-end",et=()=>{let t=bo(4),[e]=Co(),{editorConfig:o}=k();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(So)},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 So(){let t=No();Po().append(t),t.select()}import{c as ko}from"react/compiler-runtime";import{useLexicalComposerContext as Ro}from"@lexical/react/LexicalComposerContext";import*as tt from"react";var ot=()=>{let t=ko(4),{editorConfig:e}=k(),[o]=Ro(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>Re(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 wo}from"@lexical/react/LexicalComposerContext";import{$getSelection as To,$isRangeSelection as vo,RootNode as Do}from"lexical";import{useEffect as Mo}from"react";function nt(){let[t]=wo();return Mo(()=>t.registerNodeTransform(Do,e=>{let o=To();if(vo(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{jsx as q,jsxs as it}from"react/jsx-runtime";import{useLexicalComposerContext as Bo}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as st}from"@payloadcms/ui";import{useCallback as Io,useMemo as Ao,useState as _o}from"react";import"react";import*as lt from"react-dom";import{c as Lo}from"react/compiler-runtime";import"react";function rt(t,e){let o=Lo(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=d=>{let{query:y}=d,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 Fo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=k(),{i18n:s}=st(),d=`${I}__item ${I}__item-${e.key}`;t&&(d+=` ${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)+"..."),it("button",{"aria-selected":t,className:d,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 at({anchorElem:t=document.body}){let[e]=Bo(),[o,r]=_o(null),{editorConfig:n}=k(),{i18n:c}=st(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=k(),d=rt("/",{minLength:0}),y=Io(()=>{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=Ao(()=>{let a=[];for(let l of n?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(p=>{let x=p.items.filter(f=>{let h=f.key;return f.label&&(h=typeof f.label=="function"?f.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):f.label),new RegExp(o,"gi").exec(h)?!0:f.keywords!=null?f.keywords.some(u=>new RegExp(o,"gi").exec(u)):!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(f=>f.key===p.key);x?a=a.filter(f=>f.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?lt.createPortal(q("div",{className:I,children:g.map(f=>{let h=f.key;return f.label&&i&&(h=typeof f.label=="function"?f.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):f.label),it("div",{className:`${I}__group ${I}__group-${f.key}`,children:[q("div",{className:`${I}__group-title`,children:h}),f.items.map((u,m)=>q(Fo,{index:m,isSelected:l===u.key,item:u,onClick:()=>{x(u.key),p(u)},onMouseEnter:()=>{x(u.key)},ref:E=>{u.ref={current:E}}},u.key))]},f.key)})}),a.current):null,onQueryChange:r,triggerFn:d})}import{c as Oo}from"react/compiler-runtime";import{useLexicalComposerContext as $o}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Ko,TextNode as Ho}from"lexical";import{useEffect as jo}from"react";function ct(t){let e=Oo(6),{features:o}=t,[r]=$o(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=zo(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Ho,s=>{i.forEach(d=>{s.hasFormat(d)&&s.toggleFormat(d)})})},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],jo(n,c),null}function zo(t){let e=Object.keys(Ko),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Wo}from"react/compiler-runtime";import{jsx as dt}from"react/jsx-runtime";import{ContentEditable as Yo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Vo}from"@payloadcms/ui";import"react";function ut(t){let e=Wo(7),{className:o,editorConfig:r}=t,{t:n}=Vo(),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(Yo,{"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 mt=t=>{let e=Go(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=k(),[s]=Uo(),[d,y]=on(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=f=>{f!==null&&y(f)},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 f=()=>{i.focusEditor(i)},h=()=>{i.blurEditor(i)},u=s.registerCommand(en,()=>(f(),!0),ft),m=s.registerCommand(Zo,()=>(h(),!0),ft);return()=>{u(),m(),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]),tn(l,p);let x;if(e[5]!==s||e[6]!==o||e[7]!==r||e[8]!==d||e[9]!==n||e[10]!==c){let f;e[12]!==c?(f=(u,m,E)=>{(!E.has("focus")||E.size>1)&&c?.(u,m,E)},e[12]=c,e[13]=f):f=e[13];let h;e[14]!==s||e[15]!==o.features.plugins||e[16]!==d||e[17]!==n?(h=d&&te(J.Fragment,{children:[!n&&s.isEditable()&&te(J.Fragment,{children:[b(Xe,{anchorElem:d}),b(je,{anchorElem:d})]}),o.features.plugins?.map(u=>{if(u.position==="floatingAnchorElem"&&!(u.desktopOnly===!0&&n))return b(K,{anchorElem:d,clientProps:u.clientProps,plugin:u},u.key)}),s.isEditable()&&b(J.Fragment,{children:b(at,{anchorElem:d})})]}),e[14]=s,e[15]=o.features.plugins,e[16]=d,e[17]=n,e[18]=h):h=e[18],x=te(J.Fragment,{children:[o.features.plugins?.map(nn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(rn),b(Xo,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ut,{editorConfig:o})})}),ErrorBoundary:qo}),b(nt,{}),b(et,{}),b(Ae,{}),b(ct,{features:o.features}),b(Qo,{ignoreSelectionChange:!0,onChange:f}),h,s.isEditable()&&te(J.Fragment,{children:[b(Jo,{}),o?.features?.markdownTransformers?.length>0&&b(ot,{})]}),o.features.plugins?.map(sn),o.features.plugins?.map(ln)]}),o.features.plugins?.map(an)]}),e[5]=s,e[6]=o,e[7]=r,e[8]=d,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function nn(t){if(t.position==="aboveContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function rn(t){if(t.position==="top")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function sn(t){if(t.position==="normal")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function ln(t){if(t.position==="bottom")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function an(t){if(t.position==="belowContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}var gt=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?F(o,{children:F(gt,{providers:e.slice(1),children:t})}):F(o,{children:t})},ht=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:s}=t,d=k(),y=dn(),g=pt.useRef(null),a=un(()=>{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?F(cn,{initialConfig:a,children:F(ke,{editorConfig:o,editorContainerRef:g,fieldProps:r,parentContext:d?.editDepth===y?d:void 0,children:F(gt,{providers:o.features.providers,children:F(mt,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):F("p",{children:"Loading..."})};var pe="rich-text-lexical",Nn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:s,required:d},path:y,readOnly:g,validate:a}=t,l=g||c,p=gn(),x=Et((M,$)=>typeof a=="function"?a(M,{...$,required:d}):!0,[a,d]),{customComponents:{AfterInput:f,BeforeInput:h,Description:u,Error:m,Label:E}={},disabled:w,initialValue:S,path:C,setValue:R,showError:N,value:L}=yn({potentiallyStalePath:y,validate:x}),A=l||w,[v,D]=Ct(!1),[Q,he]=Ct(),ye=xt.useRef(S),W=xt.useRef(L);bt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==v&&D($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[v]);let Pe=[pe,"field-type",r,N&&"error",A&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${C}.${p}`,T=bn(void 0),P=Et(M=>{let $=St=>{let Se=St.toJSON();W.current=Se,R(Se)};typeof window.requestIdleCallback=="function"?(typeof window.cancelIdleCallback=="function"&&T.current&&cancelIdleCallback(T.current),T.current=requestIdleCallback(()=>$(M),{timeout:500})):$(M)},[R]),Nt=En(()=>xn(o),[o]),Pt=hn(M=>{W.current!==L&&JSON.stringify(W.current)!==JSON.stringify(L)&&(ye.current=M,W.current=L,he(new Date))});return bt(()=>{Object.is(S,ye.current)||Pt(S)},[S]),ge("div",{className:Pe,style:Nt,children:[O(yt,{CustomComponent:m,Fallback:O(mn,{path:C,showError:N})}),E||O(pn,{label:i,localized:s,path:C,required:d}),ge("div",{className:`${pe}__wrap`,children:[ge(Cn,{fallbackRender:Pn,onReset:()=>{},children:[h,O(ht,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:A,value:L},JSON.stringify({path:C,rerenderProviderKey:Q})),f]}),u,O(yt,{CustomComponent:u,Fallback:O(fn,{description:n,path:C})})]})]},oe)};function Pn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[O("p",{children:"Something went wrong:"}),O("pre",{style:{color:"red"},children:t.message})]})}var Xi=Nn;export{Xi as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-
|
|
2
|
+
//# sourceMappingURL=Field-DGC4DDYL.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/field/Field.tsx", "../../../src/lexical/LexicalProvider.tsx", "../../../src/lexical/LexicalEditor.tsx", "../../../src/lexical/EditorPlugin.tsx", "../../../src/lexical/plugins/DecoratorPlugin/index.tsx", "../../../src/lexical/plugins/handles/AddBlockHandlePlugin/index.tsx", "../../../src/lexical/plugins/handles/utils/calculateDistanceFromScrollerElem.ts", "../../../src/lexical/plugins/handles/utils/getNodeCloseToPoint.ts", "../../../src/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.ts", "../../../src/lexical/plugins/handles/utils/getCollapsedMargins.ts", "../../../src/lexical/plugins/handles/utils/getTopLevelNodeKeys.ts", "../../../src/lexical/plugins/handles/utils/isOnHandleElement.ts", "../../../src/lexical/plugins/handles/utils/doesLineHeightAffectElement.ts", "../../../src/lexical/plugins/handles/utils/setHandlePosition.ts", "../../../src/lexical/plugins/handles/DraggableBlockPlugin/index.tsx", "../../../src/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.ts", "../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx", "../../../src/lexical/plugins/MarkdownShortcut/index.tsx", "../../../src/lexical/plugins/NormalizeSelection/index.tsx", "../../../src/lexical/plugins/SlashMenu/index.tsx", "../../../src/lexical/plugins/SlashMenu/useMenuTriggerMatch.ts", "../../../src/lexical/plugins/TextPlugin/index.tsx", "../../../src/lexical/ui/ContentEditable.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const dispatchFieldUpdateTask = useRef<number>(undefined)\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n const updateFieldValue = (editorState: EditorState) => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n if (typeof window.requestIdleCallback === 'function') {\n // Cancel earlier scheduled value updates,\n // so that a CPU-limited event loop isn't flooded with n callbacks for n keystrokes into the rich text field,\n // but that there's only ever the latest one state update\n // dispatch task, to be executed with the next idle time,\n // or the deadline of 500ms.\n if (typeof window.cancelIdleCallback === 'function' && dispatchFieldUpdateTask.current) {\n cancelIdleCallback(dispatchFieldUpdateTask.current)\n }\n // Schedule the state update to happen the next time the browser has sufficient resources,\n // or the latest after 500ms.\n dispatchFieldUpdateTask.current = requestIdleCallback(() => updateFieldValue(editorState), {\n timeout: 500,\n })\n } else {\n updateFieldValue(editorState)\n }\n },\n [setValue],\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary\n if (\n prevValueRef.current !== value &&\n JSON.stringify(prevValueRef.current) !== JSON.stringify(value)\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n {Description}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n", "'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { EditorState, LexicalEditor, SerializedEditorState } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport { useEditDepth } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport {\n EditorConfigProvider,\n useEditorConfigContext,\n} from './config/client/EditorConfigProvider.js'\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n composerKey: string\n editorConfig: SanitizedClientEditorConfig\n fieldProps: LexicalRichTextFieldProps\n isSmallWidthViewport: boolean\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n readOnly: boolean\n value: SerializedEditorState\n}\n\nconst NestProviders = ({\n children,\n providers,\n}: {\n children: React.ReactNode\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n providers: any[]\n}) => {\n if (!providers?.length) {\n return children\n }\n const Component = providers[0]\n if (providers.length > 1) {\n return (\n <Component>\n <NestProviders providers={providers.slice(1)}>{children}</NestProviders>\n </Component>\n )\n }\n return <Component>{children}</Component>\n}\n\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { composerKey, editorConfig, fieldProps, isSmallWidthViewport, onChange, readOnly, value } =\n props\n\n const parentContext = useEditorConfigContext()\n\n const editDepth = useEditDepth()\n\n const editorContainerRef = React.useRef<HTMLDivElement>(null)\n\n // useMemo for the initialConfig that depends on readOnly and value\n const initialConfig = useMemo<InitialConfigType>(() => {\n if (value && typeof value !== 'object') {\n throw new Error(\n '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: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n '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',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n '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',\n )\n }\n\n return {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: getEnabledNodes({ editorConfig }),\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n // Important: do not add readOnly and value to the dependencies array. This will cause the entire lexical editor to re-render if the document is saved, which will\n // cause the editor to lose focus.\n }, [editorConfig])\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n // We need to add initialConfig.editable to the key to force a re-render when the readOnly prop changes.\n // Without it, there were cases where lexical editors inside drawers turn readOnly initially - a few miliseconds later they turn editable, but the editor does not re-render and stays readOnly.\n return (\n <LexicalComposer initialConfig={initialConfig} key={composerKey + initialConfig.editable}>\n <EditorConfigProvider\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n fieldProps={fieldProps}\n /**\n * Parent editor is not truly the parent editor, if the current editor is part of a drawer and the parent editor is the main editor.\n */\n parentContext={parentContext?.editDepth === editDepth ? parentContext : undefined}\n >\n <NestProviders providers={editorConfig.features.providers}>\n <LexicalEditorComponent\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n isSmallWidthViewport={isSmallWidthViewport}\n onChange={onChange}\n />\n </NestProviders>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n", "'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n <InsertParagraphAtEndPlugin />\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n", "'use client'\nimport React from 'react'\n\nimport type { SanitizedPlugin } from '../features/typesClient.js'\n\nexport const EditorPlugin: React.FC<{\n anchorElem?: HTMLDivElement\n clientProps: unknown\n plugin: SanitizedPlugin\n}> = ({ anchorElem, clientProps, plugin }) => {\n if (plugin.position === 'floatingAnchorElem' && anchorElem) {\n return (\n plugin.Component && <plugin.Component anchorElem={anchorElem} clientProps={clientProps} />\n )\n }\n\n // @ts-expect-error - ts is not able to infer that plugin.Component is of type PluginComponent\n return plugin.Component && <plugin.Component clientProps={clientProps} />\n}\n", "'use client'\n\nimport type { DecoratorNode, ElementNode, LexicalNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getEditor,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $isTextNode,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.scss'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecoratorByMouseEvent(event)\n if (!decorator) {\n return true\n }\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n $selectDecorator(decorator)\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n const decorator = $getSelectedDecorator()\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n if (decorator) {\n decorator.element?.classList.add('decorator-selected')\n return true\n }\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_UP_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const prevSibling = selection.getNodes()[0]?.getPreviousSibling()\n if ($isDecoratorNode(prevSibling)) {\n const element = $getEditor().getElementByKey(prevSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: prevSibling })\n event.preventDefault()\n return true\n }\n return false\n }\n if (!$isElementNode(prevSibling)) {\n return false\n }\n const lastDescendant = prevSibling.getLastDescendant() ?? prevSibling\n if (!lastDescendant) {\n return false\n }\n const block = $findMatchingParent(lastDescendant, INTERNAL_$isBlock)\n block?.selectStart()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get first selected block\n const firstPoint = selection.isBackward() ? selection.anchor : selection.focus\n const firstNode = firstPoint.getNode()\n const firstSelectedBlock = $findMatchingParent(firstNode, (node) => {\n return findFirstSiblingBlock(node) !== null\n })\n const prevBlock = firstSelectedBlock?.getPreviousSibling()\n if (!firstSelectedBlock || prevBlock !== findFirstSiblingBlock(firstSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(prevBlock)) {\n const prevBlockElement = $getEditor().getElementByKey(prevBlock.getKey())\n if (prevBlockElement) {\n $selectDecorator({ element: prevBlockElement, node: prevBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_DOWN_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n event.preventDefault()\n const nextSibling = selection.getNodes()[0]?.getNextSibling()\n if ($isDecoratorNode(nextSibling)) {\n const element = $getEditor().getElementByKey(nextSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: nextSibling })\n }\n return true\n }\n if (!$isElementNode(nextSibling)) {\n return true\n }\n const firstDescendant = nextSibling.getFirstDescendant() ?? nextSibling\n if (!firstDescendant) {\n return true\n }\n const block = $findMatchingParent(firstDescendant, INTERNAL_$isBlock)\n block?.selectEnd()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get last selected block\n const lastPoint = selection.isBackward() ? selection.anchor : selection.focus\n const lastNode = lastPoint.getNode()\n const lastSelectedBlock = $findMatchingParent(lastNode, (node) => {\n return findLaterSiblingBlock(node) !== null\n })\n const nextBlock = lastSelectedBlock?.getNextSibling()\n if (!lastSelectedBlock || nextBlock !== findLaterSiblingBlock(lastSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(nextBlock)) {\n const nextBlockElement = $getEditor().getElementByKey(nextBlock.getKey())\n if (nextBlockElement) {\n $selectDecorator({ element: nextBlockElement, node: nextBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecoratorByMouseEvent(\n event: MouseEvent,\n): { element: HTMLElement; node: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof HTMLElement)) {\n return undefined\n }\n const element = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!(element instanceof HTMLElement)) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(element)\n return $isDecoratorNode(node) ? { element, node } : undefined\n}\n\nfunction $getSelectedDecorator() {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return undefined\n }\n const nodes = selection.getNodes()\n if (nodes.length !== 1) {\n return undefined\n }\n const node = nodes[0]\n return $isDecoratorNode(node)\n ? {\n decorator: node,\n element: $getEditor().getElementByKey(node.getKey()),\n }\n : undefined\n}\n\nfunction $selectDecorator({\n element,\n node,\n}: {\n element: HTMLElement\n node: DecoratorNode<unknown>\n}) {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const selection = $createNodeSelection()\n selection.add(node.getKey())\n $setSelection(selection)\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' })\n element.classList.add('decorator-selected')\n}\n\n/**\n * Copied from https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalUtils.ts\n *\n * This function returns true for a DecoratorNode that is not inline OR\n * an ElementNode that is:\n * - not a root or shadow root\n * - not inline\n * - can't be empty\n * - has no children or an inline first child\n */\nexport function INTERNAL_$isBlock(node: LexicalNode): node is DecoratorNode<unknown> | ElementNode {\n if ($isDecoratorNode(node) && !node.isInline()) {\n return true\n }\n if (!$isElementNode(node) || $isRootOrShadowRoot(node)) {\n return false\n }\n\n const firstChild = node.getFirstChild()\n const isLeafElement =\n firstChild === null ||\n $isLineBreakNode(firstChild) ||\n $isTextNode(firstChild) ||\n firstChild.isInline()\n\n return !node.isInline() && node.canBeEmpty() !== false && isLeafElement\n}\n\nfunction findLaterSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getNextSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getNextSibling()\n }\n return null\n}\n\nfunction findFirstSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getPreviousSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getPreviousSibling()\n }\n return null\n}\n", "'use client'\nimport type { LexicalEditor, LexicalNode, ParagraphNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, isHTMLElement } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { Point } from '../../../utils/point.js'\nimport { ENABLE_SLASH_MENU_COMMAND } from '../../SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport './index.scss'\n\nconst ADD_BLOCK_MENU_CLASSNAME = 'add-block-menu'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction useAddBlockHandle(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const { editorConfig } = useEditorConfigContext()\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -24 : 12\n\n const menuRef = useRef<HTMLButtonElement>(null)\n const [hoveredElement, setHoveredElement] = useState<{\n elem: HTMLElement\n node: LexicalNode\n } | null>(null)\n\n useEffect(() => {\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n\n if (distanceFromScrollerElem === -1) {\n setHoveredElement(null)\n return\n }\n\n if (isOnHandleElement(target, ADD_BLOCK_MENU_CLASSNAME)) {\n return\n }\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _emptyBlockElem,\n blockNode,\n foundAtIndex,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n returnEmptyParagraphs: true,\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n\n prevIndex = foundAtIndex\n\n if (!_emptyBlockElem) {\n return\n }\n if (\n blockNode &&\n (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem)\n ) {\n setHoveredElement({\n elem: _emptyBlockElem,\n node: blockNode,\n })\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, hoveredElement])\n\n useEffect(() => {\n if (menuRef.current && hoveredElement?.node) {\n setHandlePosition(\n hoveredElement?.elem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, hoveredElement, blockHandleHorizontalOffset])\n\n const handleAddClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n let hoveredElementToUse = hoveredElement\n if (!hoveredElementToUse?.node) {\n return\n }\n\n // 1. Update hoveredElement.node to a new paragraph node if the hoveredElement.node is not a paragraph node\n editor.update(() => {\n // Check if blockNode is an empty text node\n let isEmptyParagraph = true\n if (\n hoveredElementToUse?.node.getType() !== 'paragraph' ||\n hoveredElementToUse.node.getTextContent() !== ''\n ) {\n isEmptyParagraph = false\n }\n\n if (!isEmptyParagraph) {\n const newParagraph = $createParagraphNode()\n hoveredElementToUse?.node.insertAfter(newParagraph)\n\n setTimeout(() => {\n hoveredElementToUse = {\n elem: editor.getElementByKey(newParagraph.getKey())!,\n node: newParagraph,\n }\n setHoveredElement(hoveredElementToUse)\n }, 0)\n }\n })\n\n // 2. Focus on the new paragraph node\n setTimeout(() => {\n editor.update(() => {\n editor.focus()\n\n if (\n hoveredElementToUse?.node &&\n 'select' in hoveredElementToUse.node &&\n typeof hoveredElementToUse.node.select === 'function'\n ) {\n hoveredElementToUse.node.select()\n }\n })\n }, 1)\n\n // Make sure this is called AFTER the focusing has been processed by the browser\n // Otherwise, this won't work\n setTimeout(() => {\n editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {\n node: hoveredElementToUse?.node as ParagraphNode,\n })\n }, 2)\n\n event.stopPropagation()\n event.preventDefault()\n },\n [editor, hoveredElement],\n )\n\n return createPortal(\n <React.Fragment>\n <button\n aria-label=\"Add block\"\n className=\"icon add-block-menu\"\n onClick={(event) => {\n handleAddClick(event)\n }}\n ref={menuRef}\n type=\"button\"\n >\n <div className={isEditable ? 'icon' : ''} />\n </button>\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function AddBlockHandlePlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useAddBlockHandle(editor, anchorElem, editor._editable)\n}\n", "'use client'\n/**\n * Calculate distance between scrollerElem and target if target is not in scrollerElem\n */\nexport const calculateDistanceFromScrollerElem = (\n scrollerElem: HTMLElement | null,\n pageX: number,\n pageY: number,\n target: HTMLElement,\n horizontalBuffer: number = 50,\n verticalBuffer: number = 25,\n): number => {\n let distanceFromScrollerElem = 0\n if (scrollerElem && !scrollerElem.contains(target)) {\n const { bottom, left, right, top } = scrollerElem.getBoundingClientRect()\n\n const adjustedTop = top + window.scrollY\n const adjustedBottom = bottom + window.scrollY\n\n if (\n pageY < adjustedTop - verticalBuffer ||\n pageY > adjustedBottom + verticalBuffer ||\n pageX < left - horizontalBuffer ||\n pageX > right + horizontalBuffer\n ) {\n return -1\n }\n\n // This is used to allow the _draggableBlockElem to be found when the mouse is in the\n // buffer zone around the scrollerElem.\n if (pageX < left || pageX > right) {\n distanceFromScrollerElem = pageX < left ? pageX - left : pageX - right\n }\n }\n return distanceFromScrollerElem\n}\n", "'use client'\nimport type { LexicalEditor, LexicalNode } from 'lexical'\n\nimport { $getNodeByKey } from 'lexical'\n\nimport { Point } from '../../../utils/point.js'\nimport { Rect } from '../../../utils/rect.js'\nimport { getBoundingClientRectWithoutTransform } from '../DraggableBlockPlugin/getBoundingRectWithoutTransform.js'\nimport { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\n\n// Directions\nconst Downward = 1\nconst Upward = -1\nconst Indeterminate = 0\n\ntype Props = {\n anchorElem: HTMLElement\n cache_threshold?: number\n editor: LexicalEditor\n /** fuzzy makes the search not exact. If no exact match found, find the closes node instead of returning null */\n fuzzy?: boolean\n horizontalOffset?: number\n point: Point\n /**\n * By default, empty paragraphs are not returned. Set this to true to return empty paragraphs. @default false\n */\n returnEmptyParagraphs?: boolean\n /**\n * The index to start searching from. It can be a considerable performance optimization to start searching from the index of the\n * previously found node, as the node is likely to be close to the next node.\n */\n startIndex?: number\n useEdgeAsDefault?: boolean\n verbose?: boolean\n}\n\ntype Output = {\n blockElem: HTMLElement | null\n blockNode: LexicalNode | null\n foundAtIndex: number\n isFoundNodeEmptyParagraph: boolean\n}\n\nconst cache = {\n props: null as null | Props,\n result: null as null | Output,\n}\n\nfunction isPointClose(previous: Point, current: Point, threshold: number = 20): boolean {\n const dx = previous.x - current.x\n const dy = previous.y - current.y\n return dx * dx + dy * dy <= threshold * threshold\n}\n\nexport function getNodeCloseToPoint(props: Props): Output {\n const {\n anchorElem,\n cache_threshold = 20,\n editor,\n fuzzy = false,\n horizontalOffset = 0,\n point: { x, y },\n startIndex = 0,\n useEdgeAsDefault = false,\n } = props\n\n // Use cache\n if (\n cache_threshold > 0 &&\n cache.props &&\n cache.result &&\n cache.props.fuzzy === props.fuzzy &&\n cache.props.horizontalOffset === props.horizontalOffset &&\n cache.props.useEdgeAsDefault === props.useEdgeAsDefault &&\n isPointClose(cache.props.point, props.point, cache_threshold)\n ) {\n return cache.result\n }\n\n const anchorElementRect = anchorElem.getBoundingClientRect()\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const closestBlockElem: {\n blockElem: HTMLElement | null\n blockNode: LexicalNode | null\n distance: number\n foundAtIndex: number\n isFoundNodeEmptyParagraph: boolean\n } = {\n blockElem: null,\n blockNode: null,\n distance: Infinity,\n foundAtIndex: -1,\n isFoundNodeEmptyParagraph: false,\n }\n\n // Return null if matching block element is the first or last node\n editor.getEditorState().read(() => {\n if (useEdgeAsDefault) {\n const firstNode = editor.getElementByKey(topLevelNodeKeys[0]!)\n const lastNode = editor.getElementByKey(topLevelNodeKeys[topLevelNodeKeys.length - 1]!)\n\n if (firstNode && lastNode) {\n const [firstNodeRect, lastNodeRect] = [\n getBoundingClientRectWithoutTransform(firstNode),\n getBoundingClientRectWithoutTransform(lastNode),\n ]\n\n if (y < firstNodeRect.top) {\n closestBlockElem.blockElem = firstNode\n closestBlockElem.distance = firstNodeRect.top - y\n closestBlockElem.blockNode = $getNodeByKey(topLevelNodeKeys[0]!)\n closestBlockElem.foundAtIndex = 0\n } else if (y > lastNodeRect.bottom) {\n closestBlockElem.distance = y - lastNodeRect.bottom\n closestBlockElem.blockNode = $getNodeByKey(topLevelNodeKeys[topLevelNodeKeys.length - 1]!)\n closestBlockElem.blockElem = lastNode\n closestBlockElem.foundAtIndex = topLevelNodeKeys.length - 1\n }\n\n if (closestBlockElem?.blockElem) {\n return {\n blockElem: null,\n isFoundNodeEmptyParagraph: false,\n } as Output\n }\n }\n }\n\n // Find matching block element\n let index = startIndex\n let direction = Indeterminate\n\n while (index >= 0 && index < topLevelNodeKeys.length) {\n const key = topLevelNodeKeys[index]!\n const elem = editor.getElementByKey(key)\n if (elem === null) {\n break\n }\n const point = new Point(x + horizontalOffset, y)\n //const domRect = Rect.fromDOM(elem)\n // Do not consider transform of blocks when calculating distance\n const domRect = Rect.fromDOMRect(getBoundingClientRectWithoutTransform(elem))\n\n const { marginBottom, marginTop } = getCollapsedMargins(elem)\n\n const rect = domRect.generateNewRect({\n bottom: domRect.bottom + marginBottom,\n left: anchorElementRect.left,\n right: anchorElementRect.right,\n top: domRect.top - marginTop,\n })\n\n const { distance, isOnBottomSide, isOnTopSide } = rect.distanceFromPoint(point)\n\n if (distance === 0) {\n closestBlockElem.blockElem = elem\n closestBlockElem.blockNode = $getNodeByKey(key)\n closestBlockElem.foundAtIndex = index\n closestBlockElem.distance = distance\n\n // Check if blockNode is an empty text node\n if (\n closestBlockElem.blockNode &&\n closestBlockElem.blockNode.getType() === 'paragraph' &&\n closestBlockElem.blockNode.getTextContent() === ''\n ) {\n if (!fuzzy && !props.returnEmptyParagraphs) {\n closestBlockElem.blockElem = null\n closestBlockElem.blockNode = null\n }\n\n closestBlockElem.isFoundNodeEmptyParagraph = true\n }\n break\n } else if (fuzzy) {\n if (distance < closestBlockElem.distance) {\n closestBlockElem.blockElem = elem\n closestBlockElem.blockNode = $getNodeByKey(key)\n closestBlockElem.distance = distance\n closestBlockElem.foundAtIndex = index\n }\n }\n\n if (direction === Indeterminate) {\n if (isOnTopSide) {\n direction = Upward\n } else if (isOnBottomSide) {\n direction = Downward\n } else {\n // stop search block element\n direction = Infinity\n }\n }\n\n index += direction\n }\n })\n\n // Store in cache before returning\n cache.props = props\n cache.result = {\n blockElem: closestBlockElem.blockElem,\n blockNode: closestBlockElem.blockNode,\n foundAtIndex: closestBlockElem.foundAtIndex,\n isFoundNodeEmptyParagraph: closestBlockElem.isFoundNodeEmptyParagraph,\n }\n\n return {\n blockElem: closestBlockElem.blockElem,\n blockNode: closestBlockElem.blockNode,\n foundAtIndex: closestBlockElem.foundAtIndex,\n isFoundNodeEmptyParagraph: closestBlockElem.isFoundNodeEmptyParagraph,\n }\n}\n", "'use client'\nexport function getBoundingClientRectWithoutTransform(elem: HTMLElement): DOMRect {\n const rect = elem.getBoundingClientRect()\n\n // Extract the translation value from the transform style\n const transformValue = getComputedStyle(elem).getPropertyValue('transform')\n if (!transformValue || transformValue === 'none') {\n return rect\n }\n\n const lastNumberOfTransformValue = transformValue.split(',').pop()\n rect.y = rect.y - Number(lastNumberOfTransformValue?.replace(')', ''))\n\n // Return the original bounding rect if no translation is applied\n return rect\n}\n", "'use client'\nexport function getCollapsedMargins(elem: HTMLElement): {\n marginBottom: number\n marginTop: number\n} {\n const getMargin = (element: Element | null, margin: 'marginBottom' | 'marginTop'): number =>\n element ? parseFloat(window.getComputedStyle(element)[margin]) : 0\n\n const { marginBottom, marginTop } = window.getComputedStyle(elem)\n const prevElemSiblingMarginBottom = getMargin(elem.previousElementSibling, 'marginBottom')\n const nextElemSiblingMarginTop = getMargin(elem.nextElementSibling, 'marginTop')\n const collapsedTopMargin = Math.max(parseFloat(marginTop), prevElemSiblingMarginBottom)\n const collapsedBottomMargin = Math.max(parseFloat(marginBottom), nextElemSiblingMarginTop)\n\n return { marginBottom: collapsedBottomMargin, marginTop: collapsedTopMargin }\n}\n", "'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { $getRoot } from 'lexical'\n\nexport function getTopLevelNodeKeys(editor: LexicalEditor): string[] {\n return editor.getEditorState().read(() => $getRoot().getChildrenKeys())\n}\n", "'use client'\nexport function isOnHandleElement(element: HTMLElement, handleElementClassName: string): boolean {\n return !!element.closest(`.${handleElementClassName}`)\n}\n", "'use client'\nconst replacedElements = [\n 'IMG',\n 'INPUT',\n 'TEXTAREA',\n 'SELECT',\n 'BUTTON',\n 'VIDEO',\n 'OBJECT',\n 'EMBED',\n 'IFRAME',\n 'HR',\n]\n\n/**\n * From ChatGPT, only that verified it works for HR elements.\n *\n * HTML Elements can have CSS lineHeight applied to them, but it doesn't always affect the visual layout.\n * This function checks if the line-height property has an effect on the element's layout.\n * @param htmlElem\n */\nexport function doesLineHeightAffectElement(htmlElem: HTMLElement) {\n if (!htmlElem) {\n return false\n }\n\n // Check for replaced elements, elements that typically don't support line-height adjustments,\n // and elements without visible content\n\n if (\n replacedElements.includes(htmlElem.tagName) ||\n htmlElem.offsetHeight === 0 ||\n htmlElem.offsetWidth === 0\n ) {\n return false\n }\n\n // Check for specific CSS properties that negate line-height's visual effects\n const style = window.getComputedStyle(htmlElem)\n if (\n style.display === 'table-cell' ||\n style.position === 'absolute' ||\n style.visibility === 'hidden' ||\n style.opacity === '0'\n ) {\n return false\n }\n\n // This is a basic check, and there can be more complex scenarios where line-height doesn't have an effect.\n return true\n}\n", "'use client'\nimport { doesLineHeightAffectElement } from './doesLineHeightAffectElement.js'\n\nexport function setHandlePosition(\n targetElem: HTMLElement | null,\n handleElem: HTMLElement,\n anchorElem: HTMLElement,\n leftOffset: number = 0, // SPACE\n) {\n if (!targetElem) {\n handleElem.style.opacity = '0'\n handleElem.style.transform = 'translate(-10000px, -10000px)'\n return\n }\n\n const targetRect = targetElem.getBoundingClientRect()\n const targetStyle = window.getComputedStyle(targetElem)\n const floatingElemRect = handleElem.getBoundingClientRect()\n const anchorElementRect = anchorElem.getBoundingClientRect()\n\n let top: number\n\n const isBlockStyle = ['lexical-block', 'lexical-upload', 'lexical-relationship'].some((classes) =>\n targetElem.firstElementChild?.classList.contains(classes),\n )\n\n if (!isBlockStyle) {\n // No need to let line height affect the re-positioning of the floating element if line height has no\n // visual effect on the element. Otherwise, the floating element will be positioned incorrectly.\n const actualLineHeight = doesLineHeightAffectElement(targetElem)\n ? parseInt(targetStyle.lineHeight, 10)\n : 0\n\n top = targetRect.top + (actualLineHeight - floatingElemRect.height) / 2 - anchorElementRect.top\n } else {\n top = targetRect.top + 8 - anchorElementRect.top\n }\n\n const left = leftOffset\n\n handleElem.style.opacity = '1'\n handleElem.style.transform = `translate(${left}px, ${top}px)`\n}\n", "'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { DragEvent as ReactDragEvent } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { eventFiles } from '@lexical/rich-text'\nimport { $getNearestNodeFromDOMNode, $getNodeByKey, isHTMLElement } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { Point } from '../../../utils/point.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport './index.scss'\nimport { setTargetLine } from './setTargetLine.js'\n\nconst DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu'\nconst DRAG_DATA_FORMAT = 'application/x-lexical-drag-block'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction setDragImage(dataTransfer: DataTransfer, draggableBlockElem: HTMLElement) {\n const { transform } = draggableBlockElem.style\n\n // Remove dragImage borders\n dataTransfer.setDragImage(draggableBlockElem, 0, 0)\n\n setTimeout(() => {\n draggableBlockElem.style.transform = transform\n })\n}\n\nfunction hideTargetLine(\n targetLineElem: HTMLElement | null,\n lastTargetBlockElem: HTMLElement | null,\n) {\n if (targetLineElem) {\n targetLineElem.style.opacity = '0'\n }\n if (lastTargetBlockElem) {\n lastTargetBlockElem.style.opacity = ''\n // Delete marginBottom and marginTop values we set\n lastTargetBlockElem.style.marginBottom = ''\n lastTargetBlockElem.style.marginTop = ''\n //lastTargetBlock.style.border = 'none'\n }\n}\n\nfunction useDraggableBlockMenu(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const menuRef = useRef<HTMLDivElement>(null)\n const targetLineRef = useRef<HTMLDivElement>(null)\n const debugHighlightRef = useRef<HTMLDivElement>(null)\n const isDraggingBlockRef = useRef<boolean>(false)\n const [draggableBlockElem, setDraggableBlockElem] = useState<HTMLElement | null>(null)\n const [lastTargetBlock, setLastTargetBlock] = useState<{\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n } | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -44 : -8\n\n useEffect(() => {\n /**\n * Handles positioning of the drag handle\n */\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n if (distanceFromScrollerElem === -1) {\n setDraggableBlockElem(null)\n return\n }\n\n if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {\n return\n }\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _draggableBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n verbose: false,\n })\n\n prevIndex = foundAtIndex\n\n //if (DEBUG && _draggableBlockElem) {\n //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)\n //}\n\n if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {\n return\n }\n\n if (draggableBlockElem !== _draggableBlockElem) {\n setDraggableBlockElem(_draggableBlockElem)\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, draggableBlockElem])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(\n draggableBlockElem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, draggableBlockElem, blockHandleHorizontalOffset])\n\n useEffect(() => {\n function onDragover(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n\n const { pageY, target } = event\n if (!isHTMLElement(target)) {\n return false\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: targetBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: true,\n verbose: true,\n })\n\n prevIndex = foundAtIndex\n\n const targetLineElem = targetLineRef.current\n // targetBlockElem === null shouldn't happen\n if (targetBlockElem === null || targetLineElem === null) {\n return false\n }\n\n if (draggableBlockElem !== targetBlockElem) {\n const { isBelow, willStayInSamePosition } = setTargetLine(\n editorConfig?.admin?.hideGutter ? '0px' : '3rem',\n blockHandleHorizontalOffset +\n (editorConfig?.admin?.hideGutter\n ? (menuRef?.current?.getBoundingClientRect()?.width ?? 0)\n : -(menuRef?.current?.getBoundingClientRect()?.width ?? 0)),\n targetLineElem,\n targetBlockElem,\n lastTargetBlock!,\n pageY,\n anchorElem,\n event,\n debugHighlightRef,\n isFoundNodeEmptyParagraph,\n )\n\n // Prevent default event to be able to trigger onDrop events\n // Calling preventDefault() adds the green plus icon to the cursor,\n // indicating that the drop is allowed.\n event.preventDefault()\n\n if (!willStayInSamePosition) {\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow,\n })\n }\n } else if (lastTargetBlock?.elem) {\n hideTargetLine(targetLineElem, lastTargetBlock.elem)\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow: false,\n })\n }\n\n return true\n }\n\n function onDrop(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n const { dataTransfer, pageY, target } = event\n const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || ''\n\n editor.update(() => {\n const draggedNode = $getNodeByKey(dragData)\n if (!draggedNode) {\n return false\n }\n if (!isHTMLElement(target)) {\n return false\n }\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const { blockElem: targetBlockElem, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n useEdgeAsDefault: true,\n })\n\n if (!targetBlockElem) {\n return false\n }\n const targetNode = $getNearestNodeFromDOMNode(targetBlockElem)\n if (!targetNode) {\n return false\n }\n if (targetNode === draggedNode) {\n return true\n }\n\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n\n const mouseY = pageY\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n targetNode.insertAfter(draggedNode)\n } else {\n // above targetBlockElem\n targetNode.insertBefore(draggedNode)\n }\n } else {\n //\n targetNode.insertBefore(draggedNode)\n targetNode.remove()\n }\n\n /*\n if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {\n targetNode.insertAfter(draggedNode)\n } else {\n targetNode.insertBefore(draggedNode)\n }*/\n if (draggableBlockElem !== null) {\n setDraggableBlockElem(null)\n }\n\n // find all previous elements with lexical-block-highlighter class and remove them\n const allPrevHighlighters = document.querySelectorAll('.lexical-block-highlighter')\n allPrevHighlighters.forEach((highlighter) => {\n highlighter.remove()\n })\n\n const newInsertedElem = editor.getElementByKey(draggedNode.getKey())\n setTimeout(() => {\n // add new temp html element to newInsertedElem with the same height and width and the class block-selected\n // to highlight the new inserted element\n const newInsertedElemRect = newInsertedElem?.getBoundingClientRect()\n if (!newInsertedElemRect) {\n return\n }\n const highlightElem = document.createElement('div')\n highlightElem.className = 'lexical-block-highlighter'\n\n highlightElem.style.backgroundColor = 'var(--theme-elevation-1000'\n highlightElem.style.transition = 'opacity 0.5s ease-in-out'\n highlightElem.style.zIndex = '1'\n highlightElem.style.pointerEvents = 'none'\n highlightElem.style.boxSizing = 'border-box'\n highlightElem.style.borderRadius = '4px'\n highlightElem.style.position = 'absolute'\n document.body.appendChild(highlightElem)\n\n highlightElem.style.opacity = '0.1'\n\n highlightElem.style.height = `${newInsertedElemRect.height + 8}px`\n highlightElem.style.width = `${newInsertedElemRect.width + 8}px`\n highlightElem.style.top = `${newInsertedElemRect.top + window.scrollY - 4}px`\n highlightElem.style.left = `${newInsertedElemRect.left - 4}px`\n\n setTimeout(() => {\n highlightElem.style.opacity = '0'\n setTimeout(() => {\n highlightElem.remove()\n }, 500)\n }, 1000)\n }, 120)\n })\n\n return true\n }\n\n // register onDragover event listeners:\n document.addEventListener('dragover', onDragover)\n // register onDrop event listeners:\n document.addEventListener('drop', onDrop)\n\n return () => {\n document.removeEventListener('dragover', onDragover)\n document.removeEventListener('drop', onDrop)\n }\n }, [\n scrollerElem,\n blockHandleHorizontalOffset,\n anchorElem,\n editor,\n lastTargetBlock,\n draggableBlockElem,\n editorConfig?.admin?.hideGutter,\n ])\n\n function onDragStart(event: ReactDragEvent<HTMLDivElement>): void {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer || !draggableBlockElem) {\n return\n }\n setDragImage(dataTransfer, draggableBlockElem)\n let nodeKey = ''\n editor.update(() => {\n const node = $getNearestNodeFromDOMNode(draggableBlockElem)\n if (node) {\n nodeKey = node.getKey()\n }\n })\n isDraggingBlockRef.current = true\n dataTransfer.setData(DRAG_DATA_FORMAT, nodeKey)\n }\n\n function onDragEnd(): void {\n isDraggingBlockRef.current = false\n if (lastTargetBlock?.elem) {\n hideTargetLine(targetLineRef.current, lastTargetBlock?.elem)\n }\n }\n\n return createPortal(\n <React.Fragment>\n <div\n className=\"icon draggable-block-menu\"\n draggable\n onDragEnd={onDragEnd}\n onDragStart={onDragStart}\n ref={menuRef}\n >\n <div className={isEditable ? 'icon' : ''} />\n </div>\n <div className=\"draggable-block-target-line\" ref={targetLineRef} />\n <div className=\"debug-highlight\" ref={debugHighlightRef} />\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function DraggableBlockPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useDraggableBlockMenu(editor, anchorElem, editor._editable)\n}\n", "'use client'\nimport { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nconst TARGET_LINE_HALF_HEIGHT = 0\nconst TEXT_BOX_HORIZONTAL_PADDING = -24\nconst DEBUG = false\n\nlet animationTimer = 0\n\nexport function setTargetLine(\n offsetWidth: string,\n offsetLeft: number,\n targetLineElem: HTMLElement,\n targetBlockElem: HTMLElement,\n lastTargetBlock: {\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n },\n mouseY: number,\n anchorElem: HTMLElement,\n event: DragEvent,\n debugHighlightRef: React.RefObject<HTMLDivElement | null>,\n isFoundNodeEmptyParagraph: boolean = false,\n) {\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n targetBlockElem.getBoundingClientRect() // used to be getBoundingClientRectWithoutTransform. Not sure what's better, but the normal getBoundingClientRect seems to work fine\n const { top: anchorTop, width: anchorWidth } = anchorElem.getBoundingClientRect()\n\n const { marginBottom, marginTop } = getCollapsedMargins(targetBlockElem)\n let lineTop = targetBlockElemTop\n\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n let willStayInSamePosition = false\n\n /**\n * Do not run any transform or changes if the actual new line position would be the same (even if it's now inserted BEFORE rather than AFTER - position would still be the same)\n * This prevents unnecessary flickering.\n *\n * We still need to let it run even if the position (IGNORING the transform) would not change, as the transform animation is not finished yet. This is what animationTimer does. Otherwise, the positioning will be inaccurate\n */\n if (lastTargetBlock?.elem) {\n if (targetBlockElem !== lastTargetBlock?.elem) {\n if (\n isBelow &&\n lastTargetBlock?.elem &&\n lastTargetBlock?.elem === targetBlockElem.nextElementSibling\n ) {\n animationTimer++\n\n if (animationTimer < 200) {\n willStayInSamePosition = true\n }\n } else if (\n !isBelow &&\n lastTargetBlock?.elem &&\n lastTargetBlock?.elem === targetBlockElem.previousElementSibling\n ) {\n animationTimer++\n if (animationTimer < 200) {\n willStayInSamePosition = true\n }\n }\n } else {\n animationTimer++\n\n const lastBoundingBoxPosition = lastTargetBlock?.boundingBox?.y\n const currentBoundingBoxPosition = targetBlockElem.getBoundingClientRect().y\n\n if (\n (isBelow === lastTargetBlock?.isBelow &&\n lastBoundingBoxPosition === currentBoundingBoxPosition) ||\n animationTimer < 200\n ) {\n willStayInSamePosition = false\n }\n }\n }\n if (willStayInSamePosition) {\n return {\n isBelow,\n willStayInSamePosition,\n }\n }\n\n /**\n * Paragraphs need no isBelow/above handling,\n */\n if (!isFoundNodeEmptyParagraph) {\n //if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n lineTop += targetBlockElemHeight + marginBottom / 2\n } else {\n // above targetBlockElem\n lineTop -= marginTop / 2\n }\n } else {\n lineTop += targetBlockElemHeight / 2\n }\n\n let targetElemTranslate2 = 0\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n targetElemTranslate2 = -TARGET_LINE_HALF_HEIGHT\n } else {\n targetElemTranslate2 = TARGET_LINE_HALF_HEIGHT\n }\n }\n\n const top = lineTop - anchorTop + targetElemTranslate2\n\n const left = TEXT_BOX_HORIZONTAL_PADDING - offsetLeft\n\n targetLineElem.style.width = `calc(${anchorWidth}px - ${offsetWidth})`\n targetLineElem.style.opacity = '.8'\n\n // if (DEBUG) {\n // //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, targetBlockElem, anchorElem)\n // }\n\n targetLineElem.style.transform = `translate(${left}px, calc(${top}px - ${'2px'}))`\n\n /**\n * Properly reset previous targetBlockElem styles\n */\n if (lastTargetBlock?.elem) {\n lastTargetBlock.elem.style.opacity = ''\n\n if (lastTargetBlock?.elem === targetBlockElem) {\n if (isBelow) {\n lastTargetBlock.elem.style.marginTop = ''\n } else {\n lastTargetBlock.elem.style.marginBottom = ''\n }\n } else {\n lastTargetBlock.elem.style.marginBottom = ''\n lastTargetBlock.elem.style.marginTop = ''\n }\n }\n\n animationTimer = 0\n return {\n isBelow,\n willStayInSamePosition,\n }\n}\n", "/* eslint-disable jsx-a11y/click-events-have-key-events */\n'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $createParagraphNode, $getRoot } from 'lexical'\nimport React from 'react'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nconst baseClass = 'insert-paragraph-at-end'\n\nexport const InsertParagraphAtEndPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const { editorConfig } = useEditorConfigContext()\n\n if (editorConfig?.admin?.hideInsertParagraphAtEnd) {\n return null\n }\n\n const onClick = () => {\n editor.update(() => {\n const paragraphNode = $createParagraphNode()\n $getRoot().append(paragraphNode)\n paragraphNode.select()\n })\n }\n\n return (\n // TODO: convert to button\n <div\n aria-label=\"Insert Paragraph\"\n className={baseClass}\n onClick={onClick}\n role=\"button\"\n tabIndex={0}\n >\n <div className={`${baseClass}-inside`}>\n <span>+</span>\n </div>\n </div>\n )\n}\n", "'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport * as React from 'react'\n\nimport { registerMarkdownShortcuts } from '../../../packages/@lexical/markdown/MarkdownShortcuts.js'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n React.useEffect(() => {\n return registerMarkdownShortcuts(editor, editorConfig.features.markdownTransformers ?? [])\n }, [editor, editorConfig.features.markdownTransformers])\n\n return null\n}\n", "import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $getSelection, $isRangeSelection, RootNode } from 'lexical'\nimport { useEffect } from 'react'\n\n/**\n * By default, Lexical throws an error if the selection ends in deleted nodes.\n * This is very aggressive considering there are reasons why this can happen\n * outside of Payload's control (custom features or conflicting features, for example).\n * In the case of selections on nonexistent nodes, this plugin moves the selection to\n * the end of the editor and displays a warning instead of an error.\n */\nexport function NormalizeSelectionPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerNodeTransform(RootNode, (root) => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode()\n const focusNode = selection.focus.getNode()\n if (!anchorNode.isAttached() || !focusNode.isAttached()) {\n root.selectEnd()\n // eslint-disable-next-line no-console\n console.warn(\n 'updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and ' +\n \"selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node.\",\n )\n }\n }\n return false\n })\n }, [editor])\n\n return null\n}\n", "'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useTranslation } from '@payloadcms/ui'\nimport { useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport type {\n SlashMenuGroup,\n SlashMenuGroupInternal,\n SlashMenuItemInternal,\n SlashMenuItem as SlashMenuItemType,\n} from './LexicalTypeaheadMenuPlugin/types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.js'\nimport { useMenuTriggerMatch } from './useMenuTriggerMatch.js'\n\nconst baseClass = 'slash-menu-popup'\n\nfunction SlashMenuItem({\n isSelected,\n item,\n onClick,\n onMouseEnter,\n ref,\n}: {\n index: number\n isSelected: boolean\n item: SlashMenuItemInternal\n onClick: () => void\n onMouseEnter: () => void\n ref?: React.Ref<HTMLButtonElement>\n}) {\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const { i18n } = useTranslation<{}, string>()\n\n let className = `${baseClass}__item ${baseClass}__item-${item.key}`\n if (isSelected) {\n className += ` ${baseClass}__item--selected`\n }\n\n let title = item.key\n if (item.label) {\n title =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <button\n aria-selected={isSelected}\n className={className}\n id={baseClass + '__item-' + item.key}\n key={item.key}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n ref={ref}\n role=\"option\"\n tabIndex={-1}\n type=\"button\"\n >\n {item?.Icon && <item.Icon />}\n\n <span className={`${baseClass}__item-text`}>{title}</span>\n </button>\n )\n}\n\nexport function SlashMenuPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n const [queryString, setQueryString] = useState<null | string>(null)\n const { editorConfig } = useEditorConfigContext()\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const checkForTriggerMatch = useMenuTriggerMatch('/', {\n minLength: 0,\n })\n\n const getDynamicItems = useCallback(() => {\n let groupWithItems: Array<SlashMenuGroup> = []\n\n for (const dynamicItem of editorConfig.features.slashMenu.dynamicGroups) {\n if (queryString) {\n const dynamicGroupWithItems = dynamicItem({\n editor,\n queryString,\n })\n groupWithItems = groupWithItems.concat(dynamicGroupWithItems)\n }\n }\n\n return groupWithItems\n }, [editor, queryString, editorConfig?.features])\n\n const groups: SlashMenuGroup[] = useMemo(() => {\n let groupsWithItems: SlashMenuGroup[] = []\n for (const groupWithItem of editorConfig?.features.slashMenu.groups ?? []) {\n groupsWithItems.push(groupWithItem)\n }\n\n if (queryString) {\n // Filter current groups first\n // @ts-expect-error - TODO: fix this\n groupsWithItems = groupsWithItems.map((group) => {\n const filteredItems = group.items.filter((item) => {\n let itemTitle = item.key\n if (item.label) {\n itemTitle =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n\n if (new RegExp(queryString, 'gi').exec(itemTitle)) {\n return true\n }\n if (item.keywords != null) {\n return item.keywords.some((keyword) => new RegExp(queryString, 'gi').exec(keyword))\n }\n return false\n })\n if (filteredItems.length) {\n return {\n ...group,\n items: filteredItems,\n }\n }\n return null\n })\n\n groupsWithItems = groupsWithItems.filter((group) => group != null)\n\n // Now add dynamic groups\n const dynamicItemGroups = getDynamicItems()\n\n // merge dynamic items into groups\n for (const dynamicGroup of dynamicItemGroups) {\n // 1. find the group with the same name or create new one\n let group = groupsWithItems.find((group) => group.key === dynamicGroup.key)\n if (!group) {\n group = {\n ...dynamicGroup,\n items: [],\n }\n } else {\n groupsWithItems = groupsWithItems.filter((group) => group.key !== dynamicGroup.key)\n }\n\n // 2. Add items to group items array and add to sanitized.slashMenu.groupsWithItems\n if (group?.items?.length) {\n group.items = group.items.concat(group.items)\n }\n groupsWithItems.push(group)\n }\n }\n\n return groupsWithItems\n }, [\n queryString,\n editorConfig?.features.slashMenu.groups,\n getDynamicItems,\n featureClientSchemaMap,\n i18n,\n schemaPath,\n ])\n\n return (\n <LexicalTypeaheadMenuPlugin\n anchorElem={anchorElem}\n groups={groups as SlashMenuGroupInternal[]}\n menuRenderFn={(\n anchorElementRef,\n { selectedItemKey, selectItemAndCleanUp, setSelectedItemKey },\n ) =>\n anchorElementRef.current && groups.length\n ? ReactDOM.createPortal(\n <div className={baseClass}>\n {groups.map((group) => {\n let groupTitle = group.key\n if (group.label && featureClientSchemaMap) {\n groupTitle =\n typeof group.label === 'function'\n ? group.label({ featureClientSchemaMap, i18n, schemaPath })\n : group.label\n }\n\n return (\n <div\n className={`${baseClass}__group ${baseClass}__group-${group.key}`}\n key={group.key}\n >\n <div className={`${baseClass}__group-title`}>{groupTitle}</div>\n {group.items.map((item, oi: number) => (\n <SlashMenuItem\n index={oi}\n isSelected={selectedItemKey === item.key}\n item={item as SlashMenuItemInternal}\n key={item.key}\n onClick={() => {\n setSelectedItemKey(item.key)\n selectItemAndCleanUp(item)\n }}\n onMouseEnter={() => {\n setSelectedItemKey(item.key)\n }}\n ref={(el) => {\n ;(item as SlashMenuItemInternal).ref = { current: el }\n }}\n />\n ))}\n </div>\n )\n })}\n </div>,\n anchorElementRef.current,\n )\n : null\n }\n onQueryChange={setQueryString}\n triggerFn={checkForTriggerMatch}\n />\n )\n}\n", "'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useCallback } from 'react'\n\nimport { PUNCTUATION } from './LexicalTypeaheadMenuPlugin/index.js'\n\nexport type TriggerFn = ({\n editor,\n query,\n}: {\n editor: LexicalEditor\n /** The query string is the POTENTIAL trigger AND the text after the trigger text. */\n query: string\n}) => MenuTextMatch | null\n\nexport type MenuTextMatch = {\n leadOffset: number\n matchingString: string\n replaceableString: string\n}\n\n/**\n * Returns a function which checks if the trigger (e.g. '/') is present in the query and, if so, returns the matching string (text after the trigger)\n */\nexport function useMenuTriggerMatch(\n /**\n * Text which triggers the menu. Everything after this text will be used as the query.\n */\n trigger: string,\n { maxLength = 75, minLength = 1 }: { maxLength?: number; minLength?: number },\n): TriggerFn {\n return useCallback(\n ({ query }) => {\n const validChars = '[^' + trigger + PUNCTUATION + '\\\\s]'\n const TypeaheadTriggerRegex = new RegExp(\n '(^|\\\\s|\\\\()(' +\n '[' +\n trigger +\n ']' +\n '((?:' +\n validChars +\n '){0,' +\n maxLength +\n '})' +\n ')$',\n )\n const match = TypeaheadTriggerRegex.exec(query)\n if (match !== null) {\n const maybeLeadingWhitespace = match[1]!\n\n /**\n * matchingString is only the text AFTER the trigger text. (So everything after the /)\n */\n const matchingString = match[3]!\n\n if (matchingString.length >= minLength) {\n return {\n leadOffset: match.index + maybeLeadingWhitespace.length,\n matchingString,\n replaceableString: match[2]!, // replaceableString is the trigger text + the matching string\n }\n }\n }\n return null\n },\n [maxLength, minLength, trigger],\n )\n}\n", "'use client'\nimport type { TextFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TEXT_TYPE_TO_FORMAT, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { SanitizedClientFeatures } from '../../../features/typesClient.js'\n\nexport function TextPlugin({ features }: { features: SanitizedClientFeatures }) {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n const disabledFormats = getDisabledFormats(features.enabledFormats as TextFormatType[])\n if (disabledFormats.length === 0) {\n return\n }\n // Ideally override the TextNode with our own TextNode (changing its setFormat or toggleFormat methods),\n // would be more performant. If we find a noticeable perf regression we can switch to that option.\n // Overriding the FORMAT_TEXT_COMMAND and PASTE_COMMAND commands is not an option I considered because\n // there might be other forms of mutation that we might not be considering. For example:\n // browser extensions or Payload/Lexical plugins that have their own commands.\n return editor.registerNodeTransform(TextNode, (textNode) => {\n disabledFormats.forEach((disabledFormat) => {\n if (textNode.hasFormat(disabledFormat)) {\n textNode.toggleFormat(disabledFormat)\n }\n })\n })\n }, [editor, features])\n\n return null\n}\n\nfunction getDisabledFormats(enabledFormats: TextFormatType[]): TextFormatType[] {\n const allFormats = Object.keys(TEXT_TYPE_TO_FORMAT) as TextFormatType[]\n const enabledSet = new Set(enabledFormats)\n\n return allFormats.filter((format) => !enabledSet.has(format))\n}\n", "'use client'\nimport type { JSX } from 'react'\n\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable.js'\nimport { useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\n\nimport './ContentEditable.scss'\nimport type { SanitizedClientEditorConfig } from '../config/types.js'\n\nexport function LexicalContentEditable({\n className,\n editorConfig,\n}: {\n className?: string\n editorConfig: SanitizedClientEditorConfig\n}): JSX.Element {\n const { t } = useTranslation<{}, string>()\n\n return (\n <ContentEditable\n aria-placeholder={t('lexical:general:placeholder')}\n className={className ?? 'ContentEditable__root'}\n placeholder={\n <p className=\"editor-placeholder\">\n {editorConfig?.admin?.placeholder ?? t('lexical:general:placeholder')}\n </p>\n }\n />\n )\n}\n"],
|
|
4
|
+
"sourcesContent": ["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const dispatchFieldUpdateTask = useRef<number>(undefined)\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n const updateFieldValue = (editorState: EditorState) => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n if (typeof window.requestIdleCallback === 'function') {\n // Cancel earlier scheduled value updates,\n // so that a CPU-limited event loop isn't flooded with n callbacks for n keystrokes into the rich text field,\n // but that there's only ever the latest one state update\n // dispatch task, to be executed with the next idle time,\n // or the deadline of 500ms.\n if (typeof window.cancelIdleCallback === 'function' && dispatchFieldUpdateTask.current) {\n cancelIdleCallback(dispatchFieldUpdateTask.current)\n }\n // Schedule the state update to happen the next time the browser has sufficient resources,\n // or the latest after 500ms.\n dispatchFieldUpdateTask.current = requestIdleCallback(() => updateFieldValue(editorState), {\n timeout: 500,\n })\n } else {\n updateFieldValue(editorState)\n }\n },\n [setValue],\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary\n if (\n prevValueRef.current !== value &&\n JSON.stringify(prevValueRef.current) !== JSON.stringify(value)\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n {Description}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n", "'use client'\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { EditorState, LexicalEditor, SerializedEditorState } from 'lexical'\n\nimport { LexicalComposer } from '@lexical/react/LexicalComposer.js'\nimport { useEditDepth } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport {\n EditorConfigProvider,\n useEditorConfigContext,\n} from './config/client/EditorConfigProvider.js'\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n composerKey: string\n editorConfig: SanitizedClientEditorConfig\n fieldProps: LexicalRichTextFieldProps\n isSmallWidthViewport: boolean\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n readOnly: boolean\n value: SerializedEditorState\n}\n\nconst NestProviders = ({\n children,\n providers,\n}: {\n children: React.ReactNode\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n providers: any[]\n}) => {\n if (!providers?.length) {\n return children\n }\n const Component = providers[0]\n if (providers.length > 1) {\n return (\n <Component>\n <NestProviders providers={providers.slice(1)}>{children}</NestProviders>\n </Component>\n )\n }\n return <Component>{children}</Component>\n}\n\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { composerKey, editorConfig, fieldProps, isSmallWidthViewport, onChange, readOnly, value } =\n props\n\n const parentContext = useEditorConfigContext()\n\n const editDepth = useEditDepth()\n\n const editorContainerRef = React.useRef<HTMLDivElement>(null)\n\n // useMemo for the initialConfig that depends on readOnly and value\n const initialConfig = useMemo<InitialConfigType>(() => {\n if (value && typeof value !== 'object') {\n throw new Error(\n '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: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n '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',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n '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',\n )\n }\n\n return {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: getEnabledNodes({ editorConfig }),\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n // Important: do not add readOnly and value to the dependencies array. This will cause the entire lexical editor to re-render if the document is saved, which will\n // cause the editor to lose focus.\n }, [editorConfig])\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n // We need to add initialConfig.editable to the key to force a re-render when the readOnly prop changes.\n // Without it, there were cases where lexical editors inside drawers turn readOnly initially - a few miliseconds later they turn editable, but the editor does not re-render and stays readOnly.\n return (\n <LexicalComposer initialConfig={initialConfig} key={composerKey + initialConfig.editable}>\n <EditorConfigProvider\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n fieldProps={fieldProps}\n /**\n * Parent editor is not truly the parent editor, if the current editor is part of a drawer and the parent editor is the main editor.\n */\n parentContext={parentContext?.editDepth === editDepth ? parentContext : undefined}\n >\n <NestProviders providers={editorConfig.features.providers}>\n <LexicalEditorComponent\n editorConfig={editorConfig}\n editorContainerRef={editorContainerRef}\n isSmallWidthViewport={isSmallWidthViewport}\n onChange={onChange}\n />\n </NestProviders>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n", "'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n <InsertParagraphAtEndPlugin />\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n", "'use client'\nimport React from 'react'\n\nimport type { SanitizedPlugin } from '../features/typesClient.js'\n\nexport const EditorPlugin: React.FC<{\n anchorElem?: HTMLDivElement\n clientProps: unknown\n plugin: SanitizedPlugin\n}> = ({ anchorElem, clientProps, plugin }) => {\n if (plugin.position === 'floatingAnchorElem' && anchorElem) {\n return (\n plugin.Component && <plugin.Component anchorElem={anchorElem} clientProps={clientProps} />\n )\n }\n\n // @ts-expect-error - ts is not able to infer that plugin.Component is of type PluginComponent\n return plugin.Component && <plugin.Component clientProps={clientProps} />\n}\n", "'use client'\n\nimport type { DecoratorNode, ElementNode, LexicalNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getEditor,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $isTextNode,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.scss'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecoratorByMouseEvent(event)\n if (!decorator) {\n return true\n }\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n $selectDecorator(decorator)\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n const decorator = $getSelectedDecorator()\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n if (decorator) {\n decorator.element?.classList.add('decorator-selected')\n return true\n }\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_UP_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const prevSibling = selection.getNodes()[0]?.getPreviousSibling()\n if ($isDecoratorNode(prevSibling)) {\n const element = $getEditor().getElementByKey(prevSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: prevSibling })\n event.preventDefault()\n return true\n }\n return false\n }\n if (!$isElementNode(prevSibling)) {\n return false\n }\n const lastDescendant = prevSibling.getLastDescendant() ?? prevSibling\n if (!lastDescendant) {\n return false\n }\n const block = $findMatchingParent(lastDescendant, INTERNAL_$isBlock)\n block?.selectStart()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get first selected block\n const firstPoint = selection.isBackward() ? selection.anchor : selection.focus\n const firstNode = firstPoint.getNode()\n const firstSelectedBlock = $findMatchingParent(firstNode, (node) => {\n return findFirstSiblingBlock(node) !== null\n })\n const prevBlock = firstSelectedBlock?.getPreviousSibling()\n if (!firstSelectedBlock || prevBlock !== findFirstSiblingBlock(firstSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(prevBlock)) {\n const prevBlockElement = $getEditor().getElementByKey(prevBlock.getKey())\n if (prevBlockElement) {\n $selectDecorator({ element: prevBlockElement, node: prevBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_DOWN_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n event.preventDefault()\n const nextSibling = selection.getNodes()[0]?.getNextSibling()\n if ($isDecoratorNode(nextSibling)) {\n const element = $getEditor().getElementByKey(nextSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: nextSibling })\n }\n return true\n }\n if (!$isElementNode(nextSibling)) {\n return true\n }\n const firstDescendant = nextSibling.getFirstDescendant() ?? nextSibling\n if (!firstDescendant) {\n return true\n }\n const block = $findMatchingParent(firstDescendant, INTERNAL_$isBlock)\n block?.selectEnd()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get last selected block\n const lastPoint = selection.isBackward() ? selection.anchor : selection.focus\n const lastNode = lastPoint.getNode()\n const lastSelectedBlock = $findMatchingParent(lastNode, (node) => {\n return findLaterSiblingBlock(node) !== null\n })\n const nextBlock = lastSelectedBlock?.getNextSibling()\n if (!lastSelectedBlock || nextBlock !== findLaterSiblingBlock(lastSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(nextBlock)) {\n const nextBlockElement = $getEditor().getElementByKey(nextBlock.getKey())\n if (nextBlockElement) {\n $selectDecorator({ element: nextBlockElement, node: nextBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecoratorByMouseEvent(\n event: MouseEvent,\n): { element: HTMLElement; node: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof HTMLElement)) {\n return undefined\n }\n const element = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!(element instanceof HTMLElement)) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(element)\n return $isDecoratorNode(node) ? { element, node } : undefined\n}\n\nfunction $getSelectedDecorator() {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return undefined\n }\n const nodes = selection.getNodes()\n if (nodes.length !== 1) {\n return undefined\n }\n const node = nodes[0]\n return $isDecoratorNode(node)\n ? {\n decorator: node,\n element: $getEditor().getElementByKey(node.getKey()),\n }\n : undefined\n}\n\nfunction $selectDecorator({\n element,\n node,\n}: {\n element: HTMLElement\n node: DecoratorNode<unknown>\n}) {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const selection = $createNodeSelection()\n selection.add(node.getKey())\n $setSelection(selection)\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' })\n element.classList.add('decorator-selected')\n}\n\n/**\n * Copied from https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalUtils.ts\n *\n * This function returns true for a DecoratorNode that is not inline OR\n * an ElementNode that is:\n * - not a root or shadow root\n * - not inline\n * - can't be empty\n * - has no children or an inline first child\n */\nexport function INTERNAL_$isBlock(node: LexicalNode): node is DecoratorNode<unknown> | ElementNode {\n if ($isDecoratorNode(node) && !node.isInline()) {\n return true\n }\n if (!$isElementNode(node) || $isRootOrShadowRoot(node)) {\n return false\n }\n\n const firstChild = node.getFirstChild()\n const isLeafElement =\n firstChild === null ||\n $isLineBreakNode(firstChild) ||\n $isTextNode(firstChild) ||\n firstChild.isInline()\n\n return !node.isInline() && node.canBeEmpty() !== false && isLeafElement\n}\n\nfunction findLaterSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getNextSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getNextSibling()\n }\n return null\n}\n\nfunction findFirstSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getPreviousSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getPreviousSibling()\n }\n return null\n}\n", "'use client'\nimport type { LexicalEditor, LexicalNode, ParagraphNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, isHTMLElement } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { Point } from '../../../utils/point.js'\nimport { ENABLE_SLASH_MENU_COMMAND } from '../../SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport './index.scss'\n\nconst ADD_BLOCK_MENU_CLASSNAME = 'add-block-menu'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction useAddBlockHandle(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const { editorConfig } = useEditorConfigContext()\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -24 : 12\n\n const menuRef = useRef<HTMLButtonElement>(null)\n const [hoveredElement, setHoveredElement] = useState<{\n elem: HTMLElement\n node: LexicalNode\n } | null>(null)\n\n useEffect(() => {\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n\n if (distanceFromScrollerElem === -1) {\n setHoveredElement(null)\n return\n }\n\n if (isOnHandleElement(target, ADD_BLOCK_MENU_CLASSNAME)) {\n return\n }\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _emptyBlockElem,\n blockNode,\n foundAtIndex,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n returnEmptyParagraphs: true,\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n })\n\n prevIndex = foundAtIndex\n\n if (!_emptyBlockElem) {\n return\n }\n if (\n blockNode &&\n (hoveredElement?.node !== blockNode || hoveredElement?.elem !== _emptyBlockElem)\n ) {\n setHoveredElement({\n elem: _emptyBlockElem,\n node: blockNode,\n })\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, hoveredElement])\n\n useEffect(() => {\n if (menuRef.current && hoveredElement?.node) {\n setHandlePosition(\n hoveredElement?.elem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, hoveredElement, blockHandleHorizontalOffset])\n\n const handleAddClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n let hoveredElementToUse = hoveredElement\n if (!hoveredElementToUse?.node) {\n return\n }\n\n // 1. Update hoveredElement.node to a new paragraph node if the hoveredElement.node is not a paragraph node\n editor.update(() => {\n // Check if blockNode is an empty text node\n let isEmptyParagraph = true\n if (\n hoveredElementToUse?.node.getType() !== 'paragraph' ||\n hoveredElementToUse.node.getTextContent() !== ''\n ) {\n isEmptyParagraph = false\n }\n\n if (!isEmptyParagraph) {\n const newParagraph = $createParagraphNode()\n hoveredElementToUse?.node.insertAfter(newParagraph)\n\n setTimeout(() => {\n hoveredElementToUse = {\n elem: editor.getElementByKey(newParagraph.getKey())!,\n node: newParagraph,\n }\n setHoveredElement(hoveredElementToUse)\n }, 0)\n }\n })\n\n // 2. Focus on the new paragraph node\n setTimeout(() => {\n editor.update(() => {\n editor.focus()\n\n if (\n hoveredElementToUse?.node &&\n 'select' in hoveredElementToUse.node &&\n typeof hoveredElementToUse.node.select === 'function'\n ) {\n hoveredElementToUse.node.select()\n }\n })\n }, 1)\n\n // Make sure this is called AFTER the focusing has been processed by the browser\n // Otherwise, this won't work\n setTimeout(() => {\n editor.dispatchCommand(ENABLE_SLASH_MENU_COMMAND, {\n node: hoveredElementToUse?.node as ParagraphNode,\n })\n }, 2)\n\n event.stopPropagation()\n event.preventDefault()\n },\n [editor, hoveredElement],\n )\n\n return createPortal(\n <React.Fragment>\n <button\n aria-label=\"Add block\"\n className=\"icon add-block-menu\"\n onClick={(event) => {\n handleAddClick(event)\n }}\n ref={menuRef}\n type=\"button\"\n >\n <div className={isEditable ? 'icon' : ''} />\n </button>\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function AddBlockHandlePlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useAddBlockHandle(editor, anchorElem, editor._editable)\n}\n", "'use client'\n/**\n * Calculate distance between scrollerElem and target if target is not in scrollerElem\n */\nexport const calculateDistanceFromScrollerElem = (\n scrollerElem: HTMLElement | null,\n pageX: number,\n pageY: number,\n target: HTMLElement,\n horizontalBuffer: number = 50,\n verticalBuffer: number = 25,\n): number => {\n let distanceFromScrollerElem = 0\n if (scrollerElem && !scrollerElem.contains(target)) {\n const { bottom, left, right, top } = scrollerElem.getBoundingClientRect()\n\n const adjustedTop = top + window.scrollY\n const adjustedBottom = bottom + window.scrollY\n\n if (\n pageY < adjustedTop - verticalBuffer ||\n pageY > adjustedBottom + verticalBuffer ||\n pageX < left - horizontalBuffer ||\n pageX > right + horizontalBuffer\n ) {\n return -1\n }\n\n // This is used to allow the _draggableBlockElem to be found when the mouse is in the\n // buffer zone around the scrollerElem.\n if (pageX < left || pageX > right) {\n distanceFromScrollerElem = pageX < left ? pageX - left : pageX - right\n }\n }\n return distanceFromScrollerElem\n}\n", "'use client'\nimport type { LexicalEditor, LexicalNode } from 'lexical'\n\nimport { $getNodeByKey } from 'lexical'\n\nimport { Point } from '../../../utils/point.js'\nimport { Rect } from '../../../utils/rect.js'\nimport { getBoundingClientRectWithoutTransform } from '../DraggableBlockPlugin/getBoundingRectWithoutTransform.js'\nimport { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\n\n// Directions\nconst Downward = 1\nconst Upward = -1\nconst Indeterminate = 0\n\ntype Props = {\n anchorElem: HTMLElement\n cache_threshold?: number\n editor: LexicalEditor\n /** fuzzy makes the search not exact. If no exact match found, find the closes node instead of returning null */\n fuzzy?: boolean\n horizontalOffset?: number\n point: Point\n /**\n * By default, empty paragraphs are not returned. Set this to true to return empty paragraphs. @default false\n */\n returnEmptyParagraphs?: boolean\n /**\n * The index to start searching from. It can be a considerable performance optimization to start searching from the index of the\n * previously found node, as the node is likely to be close to the next node.\n */\n startIndex?: number\n useEdgeAsDefault?: boolean\n verbose?: boolean\n}\n\ntype Output = {\n blockElem: HTMLElement | null\n blockNode: LexicalNode | null\n foundAtIndex: number\n isFoundNodeEmptyParagraph: boolean\n}\n\nconst cache = {\n props: null as null | Props,\n result: null as null | Output,\n}\n\nfunction isPointClose(previous: Point, current: Point, threshold: number = 20): boolean {\n const dx = previous.x - current.x\n const dy = previous.y - current.y\n return dx * dx + dy * dy <= threshold * threshold\n}\n\nexport function getNodeCloseToPoint(props: Props): Output {\n const {\n anchorElem,\n cache_threshold = 20,\n editor,\n fuzzy = false,\n horizontalOffset = 0,\n point: { x, y },\n startIndex = 0,\n useEdgeAsDefault = false,\n } = props\n\n // Use cache\n if (\n cache_threshold > 0 &&\n cache.props &&\n cache.result &&\n cache.props.fuzzy === props.fuzzy &&\n cache.props.horizontalOffset === props.horizontalOffset &&\n cache.props.useEdgeAsDefault === props.useEdgeAsDefault &&\n isPointClose(cache.props.point, props.point, cache_threshold)\n ) {\n return cache.result\n }\n\n const anchorElementRect = anchorElem.getBoundingClientRect()\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const closestBlockElem: {\n blockElem: HTMLElement | null\n blockNode: LexicalNode | null\n distance: number\n foundAtIndex: number\n isFoundNodeEmptyParagraph: boolean\n } = {\n blockElem: null,\n blockNode: null,\n distance: Infinity,\n foundAtIndex: -1,\n isFoundNodeEmptyParagraph: false,\n }\n\n // Return null if matching block element is the first or last node\n editor.getEditorState().read(() => {\n if (useEdgeAsDefault) {\n const firstNode = editor.getElementByKey(topLevelNodeKeys[0]!)\n const lastNode = editor.getElementByKey(topLevelNodeKeys[topLevelNodeKeys.length - 1]!)\n\n if (firstNode && lastNode) {\n const [firstNodeRect, lastNodeRect] = [\n getBoundingClientRectWithoutTransform(firstNode),\n getBoundingClientRectWithoutTransform(lastNode),\n ]\n\n if (y < firstNodeRect.top) {\n closestBlockElem.blockElem = firstNode\n closestBlockElem.distance = firstNodeRect.top - y\n closestBlockElem.blockNode = $getNodeByKey(topLevelNodeKeys[0]!)\n closestBlockElem.foundAtIndex = 0\n } else if (y > lastNodeRect.bottom) {\n closestBlockElem.distance = y - lastNodeRect.bottom\n closestBlockElem.blockNode = $getNodeByKey(topLevelNodeKeys[topLevelNodeKeys.length - 1]!)\n closestBlockElem.blockElem = lastNode\n closestBlockElem.foundAtIndex = topLevelNodeKeys.length - 1\n }\n\n if (closestBlockElem?.blockElem) {\n return {\n blockElem: null,\n isFoundNodeEmptyParagraph: false,\n } as Output\n }\n }\n }\n\n // Find matching block element\n let index = startIndex\n let direction = Indeterminate\n\n while (index >= 0 && index < topLevelNodeKeys.length) {\n const key = topLevelNodeKeys[index]!\n const elem = editor.getElementByKey(key)\n if (elem === null) {\n break\n }\n const point = new Point(x + horizontalOffset, y)\n //const domRect = Rect.fromDOM(elem)\n // Do not consider transform of blocks when calculating distance\n const domRect = Rect.fromDOMRect(getBoundingClientRectWithoutTransform(elem))\n\n const { marginBottom, marginTop } = getCollapsedMargins(elem)\n\n const rect = domRect.generateNewRect({\n bottom: domRect.bottom + marginBottom,\n left: anchorElementRect.left,\n right: anchorElementRect.right,\n top: domRect.top - marginTop,\n })\n\n const { distance, isOnBottomSide, isOnTopSide } = rect.distanceFromPoint(point)\n\n if (distance === 0) {\n closestBlockElem.blockElem = elem\n closestBlockElem.blockNode = $getNodeByKey(key)\n closestBlockElem.foundAtIndex = index\n closestBlockElem.distance = distance\n\n // Check if blockNode is an empty text node\n if (\n closestBlockElem.blockNode &&\n closestBlockElem.blockNode.getType() === 'paragraph' &&\n closestBlockElem.blockNode.getTextContent() === ''\n ) {\n if (!fuzzy && !props.returnEmptyParagraphs) {\n closestBlockElem.blockElem = null\n closestBlockElem.blockNode = null\n }\n\n closestBlockElem.isFoundNodeEmptyParagraph = true\n }\n break\n } else if (fuzzy) {\n if (distance < closestBlockElem.distance) {\n closestBlockElem.blockElem = elem\n closestBlockElem.blockNode = $getNodeByKey(key)\n closestBlockElem.distance = distance\n closestBlockElem.foundAtIndex = index\n }\n }\n\n if (direction === Indeterminate) {\n if (isOnTopSide) {\n direction = Upward\n } else if (isOnBottomSide) {\n direction = Downward\n } else {\n // stop search block element\n direction = Infinity\n }\n }\n\n index += direction\n }\n })\n\n // Store in cache before returning\n cache.props = props\n cache.result = {\n blockElem: closestBlockElem.blockElem,\n blockNode: closestBlockElem.blockNode,\n foundAtIndex: closestBlockElem.foundAtIndex,\n isFoundNodeEmptyParagraph: closestBlockElem.isFoundNodeEmptyParagraph,\n }\n\n return {\n blockElem: closestBlockElem.blockElem,\n blockNode: closestBlockElem.blockNode,\n foundAtIndex: closestBlockElem.foundAtIndex,\n isFoundNodeEmptyParagraph: closestBlockElem.isFoundNodeEmptyParagraph,\n }\n}\n", "'use client'\nexport function getBoundingClientRectWithoutTransform(elem: HTMLElement): DOMRect {\n const rect = elem.getBoundingClientRect()\n\n // Extract the translation value from the transform style\n const transformValue = getComputedStyle(elem).getPropertyValue('transform')\n if (!transformValue || transformValue === 'none') {\n return rect\n }\n\n const lastNumberOfTransformValue = transformValue.split(',').pop()\n rect.y = rect.y - Number(lastNumberOfTransformValue?.replace(')', ''))\n\n // Return the original bounding rect if no translation is applied\n return rect\n}\n", "'use client'\nexport function getCollapsedMargins(elem: HTMLElement): {\n marginBottom: number\n marginTop: number\n} {\n const getMargin = (element: Element | null, margin: 'marginBottom' | 'marginTop'): number =>\n element ? parseFloat(window.getComputedStyle(element)[margin]) : 0\n\n const { marginBottom, marginTop } = window.getComputedStyle(elem)\n const prevElemSiblingMarginBottom = getMargin(elem.previousElementSibling, 'marginBottom')\n const nextElemSiblingMarginTop = getMargin(elem.nextElementSibling, 'marginTop')\n const collapsedTopMargin = Math.max(parseFloat(marginTop), prevElemSiblingMarginBottom)\n const collapsedBottomMargin = Math.max(parseFloat(marginBottom), nextElemSiblingMarginTop)\n\n return { marginBottom: collapsedBottomMargin, marginTop: collapsedTopMargin }\n}\n", "'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { $getRoot } from 'lexical'\n\nexport function getTopLevelNodeKeys(editor: LexicalEditor): string[] {\n return editor.getEditorState().read(() => $getRoot().getChildrenKeys())\n}\n", "'use client'\nexport function isOnHandleElement(element: HTMLElement, handleElementClassName: string): boolean {\n return !!element.closest(`.${handleElementClassName}`)\n}\n", "'use client'\nconst replacedElements = [\n 'IMG',\n 'INPUT',\n 'TEXTAREA',\n 'SELECT',\n 'BUTTON',\n 'VIDEO',\n 'OBJECT',\n 'EMBED',\n 'IFRAME',\n 'HR',\n]\n\n/**\n * From ChatGPT, only that verified it works for HR elements.\n *\n * HTML Elements can have CSS lineHeight applied to them, but it doesn't always affect the visual layout.\n * This function checks if the line-height property has an effect on the element's layout.\n * @param htmlElem\n */\nexport function doesLineHeightAffectElement(htmlElem: HTMLElement) {\n if (!htmlElem) {\n return false\n }\n\n // Check for replaced elements, elements that typically don't support line-height adjustments,\n // and elements without visible content\n\n if (\n replacedElements.includes(htmlElem.tagName) ||\n htmlElem.offsetHeight === 0 ||\n htmlElem.offsetWidth === 0\n ) {\n return false\n }\n\n // Check for specific CSS properties that negate line-height's visual effects\n const style = window.getComputedStyle(htmlElem)\n if (\n style.display === 'table-cell' ||\n style.position === 'absolute' ||\n style.visibility === 'hidden' ||\n style.opacity === '0'\n ) {\n return false\n }\n\n // This is a basic check, and there can be more complex scenarios where line-height doesn't have an effect.\n return true\n}\n", "'use client'\nimport { doesLineHeightAffectElement } from './doesLineHeightAffectElement.js'\n\nexport function setHandlePosition(\n targetElem: HTMLElement | null,\n handleElem: HTMLElement,\n anchorElem: HTMLElement,\n leftOffset: number = 0, // SPACE\n) {\n if (!targetElem) {\n handleElem.style.opacity = '0'\n handleElem.style.transform = 'translate(-10000px, -10000px)'\n return\n }\n\n const targetRect = targetElem.getBoundingClientRect()\n const targetStyle = window.getComputedStyle(targetElem)\n const floatingElemRect = handleElem.getBoundingClientRect()\n const anchorElementRect = anchorElem.getBoundingClientRect()\n\n let top: number\n\n const isBlockStyle = ['lexical-block', 'lexical-upload', 'lexical-relationship'].some((classes) =>\n targetElem.firstElementChild?.classList.contains(classes),\n )\n\n if (!isBlockStyle) {\n // No need to let line height affect the re-positioning of the floating element if line height has no\n // visual effect on the element. Otherwise, the floating element will be positioned incorrectly.\n const actualLineHeight = doesLineHeightAffectElement(targetElem)\n ? parseInt(targetStyle.lineHeight, 10)\n : 0\n\n top = targetRect.top + (actualLineHeight - floatingElemRect.height) / 2 - anchorElementRect.top\n } else {\n top = targetRect.top + 8 - anchorElementRect.top\n }\n\n const left = leftOffset\n\n handleElem.style.opacity = '1'\n handleElem.style.transform = `translate(${left}px, ${top}px)`\n}\n", "'use client'\nimport type { LexicalEditor } from 'lexical'\nimport type { DragEvent as ReactDragEvent } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { eventFiles } from '@lexical/rich-text'\nimport { $getNearestNodeFromDOMNode, $getNodeByKey, isHTMLElement } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../config/client/EditorConfigProvider.js'\nimport { Point } from '../../../utils/point.js'\nimport { calculateDistanceFromScrollerElem } from '../utils/calculateDistanceFromScrollerElem.js'\nimport { getNodeCloseToPoint } from '../utils/getNodeCloseToPoint.js'\nimport { getTopLevelNodeKeys } from '../utils/getTopLevelNodeKeys.js'\nimport { isOnHandleElement } from '../utils/isOnHandleElement.js'\nimport { setHandlePosition } from '../utils/setHandlePosition.js'\nimport { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'\nimport './index.scss'\nimport { setTargetLine } from './setTargetLine.js'\n\nconst DRAGGABLE_BLOCK_MENU_CLASSNAME = 'draggable-block-menu'\nconst DRAG_DATA_FORMAT = 'application/x-lexical-drag-block'\n\nlet prevIndex = Infinity\n\nfunction getCurrentIndex(keysLength: number): number {\n if (keysLength === 0) {\n return Infinity\n }\n if (prevIndex >= 0 && prevIndex < keysLength) {\n return prevIndex\n }\n\n return Math.floor(keysLength / 2)\n}\n\nfunction setDragImage(dataTransfer: DataTransfer, draggableBlockElem: HTMLElement) {\n const { transform } = draggableBlockElem.style\n\n // Remove dragImage borders\n dataTransfer.setDragImage(draggableBlockElem, 0, 0)\n\n setTimeout(() => {\n draggableBlockElem.style.transform = transform\n })\n}\n\nfunction hideTargetLine(\n targetLineElem: HTMLElement | null,\n lastTargetBlockElem: HTMLElement | null,\n) {\n if (targetLineElem) {\n targetLineElem.style.opacity = '0'\n }\n if (lastTargetBlockElem) {\n lastTargetBlockElem.style.opacity = ''\n // Delete marginBottom and marginTop values we set\n lastTargetBlockElem.style.marginBottom = ''\n lastTargetBlockElem.style.marginTop = ''\n //lastTargetBlock.style.border = 'none'\n }\n}\n\nfunction useDraggableBlockMenu(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n isEditable: boolean,\n): React.ReactElement {\n const scrollerElem = anchorElem.parentElement\n\n const menuRef = useRef<HTMLDivElement>(null)\n const targetLineRef = useRef<HTMLDivElement>(null)\n const debugHighlightRef = useRef<HTMLDivElement>(null)\n const isDraggingBlockRef = useRef<boolean>(false)\n const [draggableBlockElem, setDraggableBlockElem] = useState<HTMLElement | null>(null)\n const [lastTargetBlock, setLastTargetBlock] = useState<{\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n } | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const blockHandleHorizontalOffset = editorConfig?.admin?.hideGutter ? -44 : -8\n\n useEffect(() => {\n /**\n * Handles positioning of the drag handle\n */\n function onDocumentMouseMove(event: MouseEvent) {\n const target = event.target\n if (!isHTMLElement(target)) {\n return\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n )\n if (distanceFromScrollerElem === -1) {\n setDraggableBlockElem(null)\n return\n }\n\n if (isOnHandleElement(target, DRAGGABLE_BLOCK_MENU_CLASSNAME)) {\n return\n }\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: _draggableBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n cache_threshold: 0,\n editor,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: false,\n verbose: false,\n })\n\n prevIndex = foundAtIndex\n\n //if (DEBUG && _draggableBlockElem) {\n //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, _draggableBlockElem, anchorElem)\n //}\n\n if (!_draggableBlockElem && !isFoundNodeEmptyParagraph) {\n return\n }\n\n if (draggableBlockElem !== _draggableBlockElem) {\n setDraggableBlockElem(_draggableBlockElem)\n }\n }\n\n // Since the draggableBlockElem is outside the actual editor, we need to listen to the document\n // to be able to detect when the mouse is outside the editor and respect a buffer around\n // the scrollerElem to avoid the draggableBlockElem disappearing too early.\n document?.addEventListener('mousemove', onDocumentMouseMove)\n\n return () => {\n document?.removeEventListener('mousemove', onDocumentMouseMove)\n }\n }, [scrollerElem, anchorElem, editor, draggableBlockElem])\n\n useEffect(() => {\n if (menuRef.current) {\n setHandlePosition(\n draggableBlockElem,\n menuRef.current,\n anchorElem,\n blockHandleHorizontalOffset,\n )\n }\n }, [anchorElem, draggableBlockElem, blockHandleHorizontalOffset])\n\n useEffect(() => {\n function onDragover(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n\n const { pageY, target } = event\n if (!isHTMLElement(target)) {\n return false\n }\n\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const topLevelNodeKeys = getTopLevelNodeKeys(editor)\n\n const {\n blockElem: targetBlockElem,\n foundAtIndex,\n isFoundNodeEmptyParagraph,\n } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n startIndex: getCurrentIndex(topLevelNodeKeys.length),\n useEdgeAsDefault: true,\n verbose: true,\n })\n\n prevIndex = foundAtIndex\n\n const targetLineElem = targetLineRef.current\n // targetBlockElem === null shouldn't happen\n if (targetBlockElem === null || targetLineElem === null) {\n return false\n }\n\n if (draggableBlockElem !== targetBlockElem) {\n const { isBelow, willStayInSamePosition } = setTargetLine(\n editorConfig?.admin?.hideGutter ? '0px' : '3rem',\n blockHandleHorizontalOffset +\n (editorConfig?.admin?.hideGutter\n ? (menuRef?.current?.getBoundingClientRect()?.width ?? 0)\n : -(menuRef?.current?.getBoundingClientRect()?.width ?? 0)),\n targetLineElem,\n targetBlockElem,\n lastTargetBlock!,\n pageY,\n anchorElem,\n event,\n debugHighlightRef,\n isFoundNodeEmptyParagraph,\n )\n\n // Prevent default event to be able to trigger onDrop events\n // Calling preventDefault() adds the green plus icon to the cursor,\n // indicating that the drop is allowed.\n event.preventDefault()\n\n if (!willStayInSamePosition) {\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow,\n })\n }\n } else if (lastTargetBlock?.elem) {\n hideTargetLine(targetLineElem, lastTargetBlock.elem)\n setLastTargetBlock({\n boundingBox: targetBlockElem.getBoundingClientRect(),\n elem: targetBlockElem,\n isBelow: false,\n })\n }\n\n return true\n }\n\n function onDrop(event: DragEvent): boolean {\n if (!isDraggingBlockRef.current) {\n return false\n }\n const [isFileTransfer] = eventFiles(event)\n if (isFileTransfer) {\n return false\n }\n const { dataTransfer, pageY, target } = event\n const dragData = dataTransfer?.getData(DRAG_DATA_FORMAT) || ''\n\n editor.update(() => {\n const draggedNode = $getNodeByKey(dragData)\n if (!draggedNode) {\n return false\n }\n if (!isHTMLElement(target)) {\n return false\n }\n const distanceFromScrollerElem = calculateDistanceFromScrollerElem(\n scrollerElem,\n event.pageX,\n event.pageY,\n target,\n 100,\n 50,\n )\n\n const { blockElem: targetBlockElem, isFoundNodeEmptyParagraph } = getNodeCloseToPoint({\n anchorElem,\n editor,\n fuzzy: true,\n horizontalOffset: -distanceFromScrollerElem,\n point: new Point(event.x, event.y),\n useEdgeAsDefault: true,\n })\n\n if (!targetBlockElem) {\n return false\n }\n const targetNode = $getNearestNodeFromDOMNode(targetBlockElem)\n if (!targetNode) {\n return false\n }\n if (targetNode === draggedNode) {\n return true\n }\n\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n getBoundingClientRectWithoutTransform(targetBlockElem)\n\n const mouseY = pageY\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n targetNode.insertAfter(draggedNode)\n } else {\n // above targetBlockElem\n targetNode.insertBefore(draggedNode)\n }\n } else {\n //\n targetNode.insertBefore(draggedNode)\n targetNode.remove()\n }\n\n /*\n if (pageY >= targetBlockElemTop + targetBlockElemHeight / 2) {\n targetNode.insertAfter(draggedNode)\n } else {\n targetNode.insertBefore(draggedNode)\n }*/\n if (draggableBlockElem !== null) {\n setDraggableBlockElem(null)\n }\n\n // find all previous elements with lexical-block-highlighter class and remove them\n const allPrevHighlighters = document.querySelectorAll('.lexical-block-highlighter')\n allPrevHighlighters.forEach((highlighter) => {\n highlighter.remove()\n })\n\n const newInsertedElem = editor.getElementByKey(draggedNode.getKey())\n setTimeout(() => {\n // add new temp html element to newInsertedElem with the same height and width and the class block-selected\n // to highlight the new inserted element\n const newInsertedElemRect = newInsertedElem?.getBoundingClientRect()\n if (!newInsertedElemRect) {\n return\n }\n const highlightElem = document.createElement('div')\n highlightElem.className = 'lexical-block-highlighter'\n\n highlightElem.style.backgroundColor = 'var(--theme-elevation-1000'\n highlightElem.style.transition = 'opacity 0.5s ease-in-out'\n highlightElem.style.zIndex = '1'\n highlightElem.style.pointerEvents = 'none'\n highlightElem.style.boxSizing = 'border-box'\n highlightElem.style.borderRadius = '4px'\n highlightElem.style.position = 'absolute'\n document.body.appendChild(highlightElem)\n\n highlightElem.style.opacity = '0.1'\n\n highlightElem.style.height = `${newInsertedElemRect.height + 8}px`\n highlightElem.style.width = `${newInsertedElemRect.width + 8}px`\n highlightElem.style.top = `${newInsertedElemRect.top + window.scrollY - 4}px`\n highlightElem.style.left = `${newInsertedElemRect.left - 4}px`\n\n setTimeout(() => {\n highlightElem.style.opacity = '0'\n setTimeout(() => {\n highlightElem.remove()\n }, 500)\n }, 1000)\n }, 120)\n })\n\n return true\n }\n\n // register onDragover event listeners:\n document.addEventListener('dragover', onDragover)\n // register onDrop event listeners:\n document.addEventListener('drop', onDrop)\n\n return () => {\n document.removeEventListener('dragover', onDragover)\n document.removeEventListener('drop', onDrop)\n }\n }, [\n scrollerElem,\n blockHandleHorizontalOffset,\n anchorElem,\n editor,\n lastTargetBlock,\n draggableBlockElem,\n editorConfig?.admin?.hideGutter,\n ])\n\n function onDragStart(event: ReactDragEvent<HTMLDivElement>): void {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer || !draggableBlockElem) {\n return\n }\n setDragImage(dataTransfer, draggableBlockElem)\n let nodeKey = ''\n editor.update(() => {\n const node = $getNearestNodeFromDOMNode(draggableBlockElem)\n if (node) {\n nodeKey = node.getKey()\n }\n })\n isDraggingBlockRef.current = true\n dataTransfer.setData(DRAG_DATA_FORMAT, nodeKey)\n }\n\n function onDragEnd(): void {\n isDraggingBlockRef.current = false\n if (lastTargetBlock?.elem) {\n hideTargetLine(targetLineRef.current, lastTargetBlock?.elem)\n }\n }\n\n return createPortal(\n <React.Fragment>\n <div\n className=\"icon draggable-block-menu\"\n draggable\n onDragEnd={onDragEnd}\n onDragStart={onDragStart}\n ref={menuRef}\n >\n <div className={isEditable ? 'icon' : ''} />\n </div>\n <div className=\"draggable-block-target-line\" ref={targetLineRef} />\n <div className=\"debug-highlight\" ref={debugHighlightRef} />\n </React.Fragment>,\n anchorElem,\n )\n}\n\nexport function DraggableBlockPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n return useDraggableBlockMenu(editor, anchorElem, editor._editable)\n}\n", "'use client'\nimport { getCollapsedMargins } from '../utils/getCollapsedMargins.js'\nconst TARGET_LINE_HALF_HEIGHT = 0\nconst TEXT_BOX_HORIZONTAL_PADDING = -24\nconst DEBUG = false\n\nlet animationTimer = 0\n\nexport function setTargetLine(\n offsetWidth: string,\n offsetLeft: number,\n targetLineElem: HTMLElement,\n targetBlockElem: HTMLElement,\n lastTargetBlock: {\n boundingBox?: DOMRect\n elem: HTMLElement | null\n isBelow: boolean\n },\n mouseY: number,\n anchorElem: HTMLElement,\n event: DragEvent,\n debugHighlightRef: React.RefObject<HTMLDivElement | null>,\n isFoundNodeEmptyParagraph: boolean = false,\n) {\n const { height: targetBlockElemHeight, top: targetBlockElemTop } =\n targetBlockElem.getBoundingClientRect() // used to be getBoundingClientRectWithoutTransform. Not sure what's better, but the normal getBoundingClientRect seems to work fine\n const { top: anchorTop, width: anchorWidth } = anchorElem.getBoundingClientRect()\n\n const { marginBottom, marginTop } = getCollapsedMargins(targetBlockElem)\n let lineTop = targetBlockElemTop\n\n const isBelow = mouseY >= targetBlockElemTop + targetBlockElemHeight / 2 + window.scrollY\n\n let willStayInSamePosition = false\n\n /**\n * Do not run any transform or changes if the actual new line position would be the same (even if it's now inserted BEFORE rather than AFTER - position would still be the same)\n * This prevents unnecessary flickering.\n *\n * We still need to let it run even if the position (IGNORING the transform) would not change, as the transform animation is not finished yet. This is what animationTimer does. Otherwise, the positioning will be inaccurate\n */\n if (lastTargetBlock?.elem) {\n if (targetBlockElem !== lastTargetBlock?.elem) {\n if (\n isBelow &&\n lastTargetBlock?.elem &&\n lastTargetBlock?.elem === targetBlockElem.nextElementSibling\n ) {\n animationTimer++\n\n if (animationTimer < 200) {\n willStayInSamePosition = true\n }\n } else if (\n !isBelow &&\n lastTargetBlock?.elem &&\n lastTargetBlock?.elem === targetBlockElem.previousElementSibling\n ) {\n animationTimer++\n if (animationTimer < 200) {\n willStayInSamePosition = true\n }\n }\n } else {\n animationTimer++\n\n const lastBoundingBoxPosition = lastTargetBlock?.boundingBox?.y\n const currentBoundingBoxPosition = targetBlockElem.getBoundingClientRect().y\n\n if (\n (isBelow === lastTargetBlock?.isBelow &&\n lastBoundingBoxPosition === currentBoundingBoxPosition) ||\n animationTimer < 200\n ) {\n willStayInSamePosition = false\n }\n }\n }\n if (willStayInSamePosition) {\n return {\n isBelow,\n willStayInSamePosition,\n }\n }\n\n /**\n * Paragraphs need no isBelow/above handling,\n */\n if (!isFoundNodeEmptyParagraph) {\n //if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n // below targetBlockElem\n lineTop += targetBlockElemHeight + marginBottom / 2\n } else {\n // above targetBlockElem\n lineTop -= marginTop / 2\n }\n } else {\n lineTop += targetBlockElemHeight / 2\n }\n\n let targetElemTranslate2 = 0\n\n if (!isFoundNodeEmptyParagraph) {\n if (isBelow) {\n targetElemTranslate2 = -TARGET_LINE_HALF_HEIGHT\n } else {\n targetElemTranslate2 = TARGET_LINE_HALF_HEIGHT\n }\n }\n\n const top = lineTop - anchorTop + targetElemTranslate2\n\n const left = TEXT_BOX_HORIZONTAL_PADDING - offsetLeft\n\n targetLineElem.style.width = `calc(${anchorWidth}px - ${offsetWidth})`\n targetLineElem.style.opacity = '.8'\n\n // if (DEBUG) {\n // //targetBlockElem.style.border = '3px solid red'\n // highlightElemOriginalPosition(debugHighlightRef, targetBlockElem, anchorElem)\n // }\n\n targetLineElem.style.transform = `translate(${left}px, calc(${top}px - ${'2px'}))`\n\n /**\n * Properly reset previous targetBlockElem styles\n */\n if (lastTargetBlock?.elem) {\n lastTargetBlock.elem.style.opacity = ''\n\n if (lastTargetBlock?.elem === targetBlockElem) {\n if (isBelow) {\n lastTargetBlock.elem.style.marginTop = ''\n } else {\n lastTargetBlock.elem.style.marginBottom = ''\n }\n } else {\n lastTargetBlock.elem.style.marginBottom = ''\n lastTargetBlock.elem.style.marginTop = ''\n }\n }\n\n animationTimer = 0\n return {\n isBelow,\n willStayInSamePosition,\n }\n}\n", "/* eslint-disable jsx-a11y/click-events-have-key-events */\n'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $createParagraphNode, $getRoot } from 'lexical'\nimport React from 'react'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nconst baseClass = 'insert-paragraph-at-end'\n\nexport const InsertParagraphAtEndPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const { editorConfig } = useEditorConfigContext()\n\n if (editorConfig?.admin?.hideInsertParagraphAtEnd) {\n return null\n }\n\n const onClick = () => {\n editor.update(() => {\n const paragraphNode = $createParagraphNode()\n $getRoot().append(paragraphNode)\n paragraphNode.select()\n })\n }\n\n return (\n // TODO: convert to button\n <div\n aria-label=\"Insert Paragraph\"\n className={baseClass}\n onClick={onClick}\n role=\"button\"\n tabIndex={0}\n >\n <div className={`${baseClass}-inside`}>\n <span>+</span>\n </div>\n </div>\n )\n}\n", "'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport * as React from 'react'\n\nimport { registerMarkdownShortcuts } from '../../../packages/@lexical/markdown/MarkdownShortcuts.js'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n React.useEffect(() => {\n return registerMarkdownShortcuts(editor, editorConfig.features.markdownTransformers ?? [])\n }, [editor, editorConfig.features.markdownTransformers])\n\n return null\n}\n", "import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $getSelection, $isRangeSelection, RootNode } from 'lexical'\nimport { useEffect } from 'react'\n\n/**\n * By default, Lexical throws an error if the selection ends in deleted nodes.\n * This is very aggressive considering there are reasons why this can happen\n * outside of Payload's control (custom features or conflicting features, for example).\n * In the case of selections on nonexistent nodes, this plugin moves the selection to\n * the end of the editor and displays a warning instead of an error.\n */\nexport function NormalizeSelectionPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerNodeTransform(RootNode, (root) => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode()\n const focusNode = selection.focus.getNode()\n if (!anchorNode.isAttached() || !focusNode.isAttached()) {\n root.selectEnd()\n // eslint-disable-next-line no-console\n console.warn(\n 'updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and ' +\n \"selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node.\",\n )\n }\n }\n return false\n })\n }, [editor])\n\n return null\n}\n", "'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useTranslation } from '@payloadcms/ui'\nimport { useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport type {\n SlashMenuGroup,\n SlashMenuGroupInternal,\n SlashMenuItemInternal,\n SlashMenuItem as SlashMenuItemType,\n} from './LexicalTypeaheadMenuPlugin/types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.js'\nimport { useMenuTriggerMatch } from './useMenuTriggerMatch.js'\n\nconst baseClass = 'slash-menu-popup'\n\nfunction SlashMenuItem({\n isSelected,\n item,\n onClick,\n onMouseEnter,\n ref,\n}: {\n index: number\n isSelected: boolean\n item: SlashMenuItemInternal\n onClick: () => void\n onMouseEnter: () => void\n ref?: React.Ref<HTMLButtonElement>\n}) {\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const { i18n } = useTranslation<{}, string>()\n\n let className = `${baseClass}__item ${baseClass}__item-${item.key}`\n if (isSelected) {\n className += ` ${baseClass}__item--selected`\n }\n\n let title = item.key\n if (item.label) {\n title =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n // Crop title to max. 25 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <button\n aria-selected={isSelected}\n className={className}\n id={baseClass + '__item-' + item.key}\n key={item.key}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n ref={ref}\n role=\"option\"\n tabIndex={-1}\n type=\"button\"\n >\n {item?.Icon && <item.Icon />}\n\n <span className={`${baseClass}__item-text`}>{title}</span>\n </button>\n )\n}\n\nexport function SlashMenuPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement {\n const [editor] = useLexicalComposerContext()\n const [queryString, setQueryString] = useState<null | string>(null)\n const { editorConfig } = useEditorConfigContext()\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const checkForTriggerMatch = useMenuTriggerMatch('/', {\n minLength: 0,\n })\n\n const getDynamicItems = useCallback(() => {\n let groupWithItems: Array<SlashMenuGroup> = []\n\n for (const dynamicItem of editorConfig.features.slashMenu.dynamicGroups) {\n if (queryString) {\n const dynamicGroupWithItems = dynamicItem({\n editor,\n queryString,\n })\n groupWithItems = groupWithItems.concat(dynamicGroupWithItems)\n }\n }\n\n return groupWithItems\n }, [editor, queryString, editorConfig?.features])\n\n const groups: SlashMenuGroup[] = useMemo(() => {\n let groupsWithItems: SlashMenuGroup[] = []\n for (const groupWithItem of editorConfig?.features.slashMenu.groups ?? []) {\n groupsWithItems.push(groupWithItem)\n }\n\n if (queryString) {\n // Filter current groups first\n // @ts-expect-error - TODO: fix this\n groupsWithItems = groupsWithItems.map((group) => {\n const filteredItems = group.items.filter((item) => {\n let itemTitle = item.key\n if (item.label) {\n itemTitle =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n\n if (new RegExp(queryString, 'gi').exec(itemTitle)) {\n return true\n }\n if (item.keywords != null) {\n return item.keywords.some((keyword) => new RegExp(queryString, 'gi').exec(keyword))\n }\n return false\n })\n if (filteredItems.length) {\n return {\n ...group,\n items: filteredItems,\n }\n }\n return null\n })\n\n groupsWithItems = groupsWithItems.filter((group) => group != null)\n\n // Now add dynamic groups\n const dynamicItemGroups = getDynamicItems()\n\n // merge dynamic items into groups\n for (const dynamicGroup of dynamicItemGroups) {\n // 1. find the group with the same name or create new one\n let group = groupsWithItems.find((group) => group.key === dynamicGroup.key)\n if (!group) {\n group = {\n ...dynamicGroup,\n items: [],\n }\n } else {\n groupsWithItems = groupsWithItems.filter((group) => group.key !== dynamicGroup.key)\n }\n\n // 2. Add items to group items array and add to sanitized.slashMenu.groupsWithItems\n if (group?.items?.length) {\n group.items = group.items.concat(group.items)\n }\n groupsWithItems.push(group)\n }\n }\n\n return groupsWithItems\n }, [\n queryString,\n editorConfig?.features.slashMenu.groups,\n getDynamicItems,\n featureClientSchemaMap,\n i18n,\n schemaPath,\n ])\n\n return (\n <LexicalTypeaheadMenuPlugin\n anchorElem={anchorElem}\n groups={groups as SlashMenuGroupInternal[]}\n menuRenderFn={(\n anchorElementRef,\n { selectedItemKey, selectItemAndCleanUp, setSelectedItemKey },\n ) =>\n anchorElementRef.current && groups.length\n ? ReactDOM.createPortal(\n <div className={baseClass}>\n {groups.map((group) => {\n let groupTitle = group.key\n if (group.label && featureClientSchemaMap) {\n groupTitle =\n typeof group.label === 'function'\n ? group.label({ featureClientSchemaMap, i18n, schemaPath })\n : group.label\n }\n\n return (\n <div\n className={`${baseClass}__group ${baseClass}__group-${group.key}`}\n key={group.key}\n >\n <div className={`${baseClass}__group-title`}>{groupTitle}</div>\n {group.items.map((item, oi: number) => (\n <SlashMenuItem\n index={oi}\n isSelected={selectedItemKey === item.key}\n item={item as SlashMenuItemInternal}\n key={item.key}\n onClick={() => {\n setSelectedItemKey(item.key)\n selectItemAndCleanUp(item)\n }}\n onMouseEnter={() => {\n setSelectedItemKey(item.key)\n }}\n ref={(el) => {\n ;(item as SlashMenuItemInternal).ref = { current: el }\n }}\n />\n ))}\n </div>\n )\n })}\n </div>,\n anchorElementRef.current,\n )\n : null\n }\n onQueryChange={setQueryString}\n triggerFn={checkForTriggerMatch}\n />\n )\n}\n", "'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useCallback } from 'react'\n\nimport { PUNCTUATION } from './LexicalTypeaheadMenuPlugin/index.js'\n\nexport type TriggerFn = ({\n editor,\n query,\n}: {\n editor: LexicalEditor\n /** The query string is the POTENTIAL trigger AND the text after the trigger text. */\n query: string\n}) => MenuTextMatch | null\n\nexport type MenuTextMatch = {\n leadOffset: number\n matchingString: string\n replaceableString: string\n}\n\n/**\n * Returns a function which checks if the trigger (e.g. '/') is present in the query and, if so, returns the matching string (text after the trigger)\n */\nexport function useMenuTriggerMatch(\n /**\n * Text which triggers the menu. Everything after this text will be used as the query.\n */\n trigger: string,\n { maxLength = 75, minLength = 1 }: { maxLength?: number; minLength?: number },\n): TriggerFn {\n return useCallback(\n ({ query }) => {\n const validChars = '[^' + trigger + PUNCTUATION + '\\\\s]'\n const TypeaheadTriggerRegex = new RegExp(\n '(^|\\\\s|\\\\()(' +\n '[' +\n trigger +\n ']' +\n '((?:' +\n validChars +\n '){0,' +\n maxLength +\n '})' +\n ')$',\n )\n const match = TypeaheadTriggerRegex.exec(query)\n if (match !== null) {\n const maybeLeadingWhitespace = match[1]!\n\n /**\n * matchingString is only the text AFTER the trigger text. (So everything after the /)\n */\n const matchingString = match[3]!\n\n if (matchingString.length >= minLength) {\n return {\n leadOffset: match.index + maybeLeadingWhitespace.length,\n matchingString,\n replaceableString: match[2]!, // replaceableString is the trigger text + the matching string\n }\n }\n }\n return null\n },\n [maxLength, minLength, trigger],\n )\n}\n", "'use client'\nimport type { TextFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TEXT_TYPE_TO_FORMAT, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { SanitizedClientFeatures } from '../../../features/typesClient.js'\n\nexport function TextPlugin({ features }: { features: SanitizedClientFeatures }) {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n const disabledFormats = getDisabledFormats(features.enabledFormats)\n if (disabledFormats.length === 0) {\n return\n }\n // Ideally override the TextNode with our own TextNode (changing its setFormat or toggleFormat methods),\n // would be more performant. If we find a noticeable perf regression we can switch to that option.\n // Overriding the FORMAT_TEXT_COMMAND and PASTE_COMMAND commands is not an option I considered because\n // there might be other forms of mutation that we might not be considering. For example:\n // browser extensions or Payload/Lexical plugins that have their own commands.\n return editor.registerNodeTransform(TextNode, (textNode) => {\n disabledFormats.forEach((disabledFormat) => {\n if (textNode.hasFormat(disabledFormat)) {\n textNode.toggleFormat(disabledFormat)\n }\n })\n })\n }, [editor, features])\n\n return null\n}\n\nfunction getDisabledFormats(enabledFormats: TextFormatType[]): TextFormatType[] {\n const allFormats = Object.keys(TEXT_TYPE_TO_FORMAT) as TextFormatType[]\n const enabledSet = new Set(enabledFormats)\n\n return allFormats.filter((format) => !enabledSet.has(format))\n}\n", "'use client'\nimport type { JSX } from 'react'\n\nimport { ContentEditable } from '@lexical/react/LexicalContentEditable.js'\nimport { useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\n\nimport './ContentEditable.scss'\nimport type { SanitizedClientEditorConfig } from '../config/types.js'\n\nexport function LexicalContentEditable({\n className,\n editorConfig,\n}: {\n className?: string\n editorConfig: SanitizedClientEditorConfig\n}): JSX.Element {\n const { t } = useTranslation<{}, string>()\n\n return (\n <ContentEditable\n aria-placeholder={t('lexical:general:placeholder')}\n className={className ?? 'ContentEditable__root'}\n placeholder={\n <p className=\"editor-placeholder\">\n {editorConfig?.admin?.placeholder ?? t('lexical:general:placeholder')}\n </p>\n }\n />\n )\n}\n"],
|
|
5
5
|
"mappings": "wMAIA,OACEA,oBAAAA,GACAC,cAAAA,GACAC,cAAAA,GACAC,yBAAAA,GACAC,gBAAAA,GACAC,kBAAAA,GACAC,YAAAA,OACK,iBACP,OAASC,oBAAAA,OAAwB,wBACjC,OAAOC,IAASC,eAAAA,GAAaC,aAAAA,GAAWC,WAAAA,GAASC,UAAAA,GAAQC,YAAAA,OAAgB,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AAcA,EACd2F,WAAY5F,EACZmC,qBAAsBA,EAEtB0D,SAAUjC,EACVtD,SAAUsB,EACVR,MAAOA,GAHFsD,KAAKC,UAAU,CAAEhE,KAAAA,EAAM2B,oBAAAA,CAAoB,CAAA,CAAA,EAKjDf,CAAA,IAEFE,EACDwD,EAACC,GAAA,CACCC,gBAAiB1D,EACjB2D,SAAUH,EAACa,GAAA,CAAiBzF,YAAaA,EAAaM,KAAMA,WAxBpC8C,EAAA,CA6BlC,EAEA,SAAS+B,GAAe,CAAEO,MAAAA,CAAK,EAAoB,CAGjD,OACEhB,GAAC,MAAA,CAAI3E,UAAU,gBAAgB4F,KAAK,kBAClCf,EAAC,IAAA,UAAE,0BACHA,EAAC,MAAA,CAAID,MAAO,CAAEiB,MAAO,KAAM,WAAIF,EAAMG,YAG3C,CAEO,IAAMC,GAAqCpG",
|
|
6
6
|
"names": ["FieldDescription", "FieldError", "FieldLabel", "RenderCustomComponent", "useEditDepth", "useEffectEvent", "useField", "mergeFieldStyles", "React", "useCallback", "useEffect", "useMemo", "useRef", "useState", "ErrorBoundary", "LexicalComposer", "useEditDepth", "React", "useMemo", "c", "_c", "useLexicalComposerContext", "LexicalErrorBoundary", "HistoryPlugin", "OnChangePlugin", "RichTextPlugin", "BLUR_COMMAND", "COMMAND_PRIORITY_LOW", "FOCUS_COMMAND", "React", "useEffect", "useState", "EditorPlugin", "anchorElem", "clientProps", "plugin", "position", "Component", "_jsx", "c", "_c", "useLexicalComposerContext", "$findMatchingParent", "mergeRegister", "$createNodeSelection", "$getEditor", "$getNearestNodeFromDOMNode", "$getSelection", "$isDecoratorNode", "$isElementNode", "$isLineBreakNode", "$isNodeSelection", "$isRangeSelection", "$isRootOrShadowRoot", "$isTextNode", "$setSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_ARROW_DOWN_COMMAND", "KEY_ARROW_UP_COMMAND", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "SELECTION_CHANGE_COMMAND", "useEffect", "DecoratorPlugin", "$", "editor", "$onDelete", "_temp2", "t0", "t1", "registerCommand", "_temp3", "_temp4", "_temp6", "_temp8", "event_2", "selection_1", "selection", "event", "preventDefault", "nextSibling", "getNodes", "getNextSibling", "element_0", "getElementByKey", "getKey", "element", "$selectDecorator", "node", "firstDescendant", "getFirstDescendant", "INTERNAL_$isBlock", "selectEnd", "lastNode", "isBackward", "anchor", "focus", "getNode", "lastSelectedBlock", "_temp7", "nextBlock", "findLaterSiblingBlock", "nextBlockElement", "node_1", "event_1", "selection_0", "prevSibling", "getPreviousSibling", "lastDescendant", "getLastDescendant", "selectStart", "firstNode", "firstSelectedBlock", "_temp5", "prevBlock", "findFirstSiblingBlock", "prevBlockElement", "node_0", "decorator_0", "$getSelectedDecorator", "document", "querySelector", "classList", "remove", "decorator", "add", "event_0", "$getDecoratorByMouseEvent", "target", "HTMLElement", "isContentEditable", "closest", "forEach", "_temp", "undefined", "nodes", "length", "scrollIntoView", "behavior", "block", "isInline", "firstChild", "getFirstChild", "isLeafElement", "canBeEmpty", "current", "useLexicalComposerContext", "$createParagraphNode", "isHTMLElement", "React", "useCallback", "useEffect", "useRef", "useState", "createPortal", "calculateDistanceFromScrollerElem", "scrollerElem", "pageX", "pageY", "target", "horizontalBuffer", "verticalBuffer", "distanceFromScrollerElem", "contains", "bottom", "left", "right", "top", "getBoundingClientRect", "adjustedTop", "window", "scrollY", "adjustedBottom", "$getNodeByKey", "getBoundingClientRectWithoutTransform", "elem", "rect", "getBoundingClientRect", "transformValue", "getComputedStyle", "getPropertyValue", "lastNumberOfTransformValue", "split", "pop", "y", "Number", "replace", "getCollapsedMargins", "elem", "getMargin", "element", "margin", "parseFloat", "window", "getComputedStyle", "marginBottom", "marginTop", "prevElemSiblingMarginBottom", "previousElementSibling", "nextElemSiblingMarginTop", "nextElementSibling", "collapsedTopMargin", "Math", "max", "$getRoot", "getTopLevelNodeKeys", "editor", "getEditorState", "read", "getChildrenKeys", "Downward", "Upward", "Indeterminate", "cache", "props", "result", "isPointClose", "previous", "current", "threshold", "dx", "x", "dy", "y", "getNodeCloseToPoint", "anchorElem", "cache_threshold", "editor", "fuzzy", "horizontalOffset", "point", "startIndex", "useEdgeAsDefault", "anchorElementRect", "getBoundingClientRect", "topLevelNodeKeys", "getTopLevelNodeKeys", "closestBlockElem", "blockElem", "blockNode", "distance", "Infinity", "foundAtIndex", "isFoundNodeEmptyParagraph", "getEditorState", "read", "firstNode", "getElementByKey", "lastNode", "length", "firstNodeRect", "lastNodeRect", "getBoundingClientRectWithoutTransform", "top", "$getNodeByKey", "bottom", "index", "direction", "key", "elem", "Point", "domRect", "Rect", "fromDOMRect", "marginBottom", "marginTop", "getCollapsedMargins", "rect", "generateNewRect", "left", "right", "isOnBottomSide", "isOnTopSide", "distanceFromPoint", "getType", "getTextContent", "returnEmptyParagraphs", "isOnHandleElement", "element", "handleElementClassName", "closest", "replacedElements", "doesLineHeightAffectElement", "htmlElem", "includes", "tagName", "offsetHeight", "offsetWidth", "style", "window", "getComputedStyle", "display", "position", "visibility", "opacity", "setHandlePosition", "targetElem", "handleElem", "anchorElem", "leftOffset", "style", "opacity", "transform", "targetRect", "getBoundingClientRect", "targetStyle", "window", "getComputedStyle", "floatingElemRect", "anchorElementRect", "top", "some", "classes", "firstElementChild", "classList", "contains", "actualLineHeight", "doesLineHeightAffectElement", "parseInt", "lineHeight", "height", "left", "ADD_BLOCK_MENU_CLASSNAME", "prevIndex", "Infinity", "getCurrentIndex", "keysLength", "Math", "floor", "useAddBlockHandle", "editor", "anchorElem", "isEditable", "scrollerElem", "parentElement", "editorConfig", "useEditorConfigContext", "blockHandleHorizontalOffset", "admin", "hideGutter", "menuRef", "useRef", "hoveredElement", "setHoveredElement", "useState", "useEffect", "onDocumentMouseMove", "event", "target", "isHTMLElement", "distanceFromScrollerElem", "calculateDistanceFromScrollerElem", "pageX", "pageY", "isOnHandleElement", "topLevelNodeKeys", "getTopLevelNodeKeys", "blockElem", "_emptyBlockElem", "blockNode", "foundAtIndex", "getNodeCloseToPoint", "cache_threshold", "horizontalOffset", "point", "Point", "x", "y", "returnEmptyParagraphs", "startIndex", "length", "useEdgeAsDefault", "node", "elem", "document", "addEventListener", "removeEventListener", "current", "setHandlePosition", "handleAddClick", "useCallback", "hoveredElementToUse", "update", "isEmptyParagraph", "getType", "getTextContent", "newParagraph", "$createParagraphNode", "insertAfter", "setTimeout", "getElementByKey", "getKey", "focus", "select", "dispatchCommand", "ENABLE_SLASH_MENU_COMMAND", "stopPropagation", "preventDefault", "createPortal", "_jsx", "Fragment", "className", "onClick", "ref", "type", "AddBlockHandlePlugin", "t0", "t1", "undefined", "body", "useLexicalComposerContext", "_editable", "useLexicalComposerContext", "eventFiles", "$getNearestNodeFromDOMNode", "$getNodeByKey", "isHTMLElement", "React", "useEffect", "useRef", "useState", "createPortal", "TARGET_LINE_HALF_HEIGHT", "TEXT_BOX_HORIZONTAL_PADDING", "animationTimer", "setTargetLine", "offsetWidth", "offsetLeft", "targetLineElem", "targetBlockElem", "lastTargetBlock", "mouseY", "anchorElem", "event", "debugHighlightRef", "isFoundNodeEmptyParagraph", "height", "targetBlockElemHeight", "top", "targetBlockElemTop", "getBoundingClientRect", "anchorTop", "width", "anchorWidth", "marginBottom", "marginTop", "getCollapsedMargins", "lineTop", "isBelow", "window", "scrollY", "willStayInSamePosition", "elem", "nextElementSibling", "previousElementSibling", "lastBoundingBoxPosition", "boundingBox", "y", "currentBoundingBoxPosition", "targetElemTranslate2", "TARGET_LINE_HALF_HEIGHT", "left", "TEXT_BOX_HORIZONTAL_PADDING", "style", "opacity", "transform", "DRAGGABLE_BLOCK_MENU_CLASSNAME", "DRAG_DATA_FORMAT", "prevIndex", "Infinity", "getCurrentIndex", "keysLength", "Math", "floor", "setDragImage", "dataTransfer", "draggableBlockElem", "transform", "style", "setTimeout", "hideTargetLine", "targetLineElem", "lastTargetBlockElem", "opacity", "marginBottom", "marginTop", "useDraggableBlockMenu", "editor", "anchorElem", "isEditable", "scrollerElem", "parentElement", "menuRef", "useRef", "targetLineRef", "debugHighlightRef", "isDraggingBlockRef", "setDraggableBlockElem", "useState", "lastTargetBlock", "setLastTargetBlock", "editorConfig", "useEditorConfigContext", "blockHandleHorizontalOffset", "admin", "hideGutter", "useEffect", "onDocumentMouseMove", "event", "target", "isHTMLElement", "distanceFromScrollerElem", "calculateDistanceFromScrollerElem", "pageX", "pageY", "isOnHandleElement", "topLevelNodeKeys", "getTopLevelNodeKeys", "blockElem", "_draggableBlockElem", "foundAtIndex", "isFoundNodeEmptyParagraph", "getNodeCloseToPoint", "cache_threshold", "horizontalOffset", "point", "Point", "x", "y", "startIndex", "length", "useEdgeAsDefault", "verbose", "document", "addEventListener", "removeEventListener", "current", "setHandlePosition", "onDragover", "isFileTransfer", "eventFiles", "targetBlockElem", "fuzzy", "isBelow", "willStayInSamePosition", "setTargetLine", "getBoundingClientRect", "width", "preventDefault", "boundingBox", "elem", "onDrop", "dragData", "getData", "update", "draggedNode", "$getNodeByKey", "targetNode", "$getNearestNodeFromDOMNode", "height", "targetBlockElemHeight", "top", "targetBlockElemTop", "getBoundingClientRectWithoutTransform", "window", "scrollY", "insertBefore", "remove", "insertAfter", "querySelectorAll", "forEach", "highlighter", "newInsertedElem", "getElementByKey", "getKey", "newInsertedElemRect", "highlightElem", "createElement", "className", "backgroundColor", "transition", "zIndex", "pointerEvents", "boxSizing", "borderRadius", "position", "body", "appendChild", "left", "onDragStart", "nodeKey", "node", "setData", "onDragEnd", "createPortal", "_jsxs", "Fragment", "_jsx", "draggable", "ref", "DraggableBlockPlugin", "t0", "t1", "undefined", "useLexicalComposerContext", "_editable", "c", "_c", "useLexicalComposerContext", "$createParagraphNode", "$getRoot", "baseClass", "InsertParagraphAtEndPlugin", "$", "_c", "editor", "useLexicalComposerContext", "editorConfig", "useEditorConfigContext", "admin", "hideInsertParagraphAtEnd", "t0", "update", "_temp", "onClick", "t1", "_jsx", "className", "role", "tabIndex", "children", "paragraphNode", "$createParagraphNode", "$getRoot", "append", "select", "c", "_c", "useLexicalComposerContext", "React", "MarkdownShortcutPlugin", "$", "_c", "editorConfig", "useEditorConfigContext", "editor", "useLexicalComposerContext", "t0", "t1", "features", "markdownTransformers", "registerMarkdownShortcuts", "useEffect", "useLexicalComposerContext", "$getSelection", "$isRangeSelection", "RootNode", "useEffect", "NormalizeSelectionPlugin", "editor", "registerNodeTransform", "root", "selection", "anchorNode", "anchor", "getNode", "focusNode", "focus", "isAttached", "selectEnd", "console", "warn", "useLexicalComposerContext", "useTranslation", "useCallback", "useMemo", "useState", "ReactDOM", "c", "_c", "useMenuTriggerMatch", "trigger", "t0", "$", "_c", "maxLength", "t1", "minLength", "t2", "undefined", "t3", "t4", "query", "validChars", "PUNCTUATION", "match", "RegExp", "exec", "maybeLeadingWhitespace", "matchingString", "length", "leadOffset", "index", "replaceableString", "baseClass", "SlashMenuItem", "isSelected", "item", "onClick", "onMouseEnter", "ref", "fieldProps", "featureClientSchemaMap", "schemaPath", "useEditorConfigContext", "i18n", "useTranslation", "className", "key", "title", "label", "length", "substring", "_jsxs", "id", "role", "tabIndex", "type", "Icon", "_jsx", "SlashMenuPlugin", "anchorElem", "document", "body", "editor", "useLexicalComposerContext", "queryString", "setQueryString", "useState", "editorConfig", "checkForTriggerMatch", "useMenuTriggerMatch", "minLength", "getDynamicItems", "useCallback", "groupWithItems", "dynamicItem", "features", "slashMenu", "dynamicGroups", "dynamicGroupWithItems", "concat", "groups", "useMemo", "groupsWithItems", "groupWithItem", "push", "map", "group", "filteredItems", "items", "filter", "itemTitle", "RegExp", "exec", "keywords", "some", "keyword", "dynamicItemGroups", "dynamicGroup", "find", "LexicalTypeaheadMenuPlugin", "menuRenderFn", "anchorElementRef", "selectedItemKey", "selectItemAndCleanUp", "setSelectedItemKey", "current", "createPortal", "groupTitle", "oi", "index", "el", "onQueryChange", "triggerFn", "c", "_c", "useLexicalComposerContext", "TEXT_TYPE_TO_FORMAT", "TextNode", "useEffect", "TextPlugin", "t0", "$", "features", "editor", "t1", "enabledFormats", "disabledFormats", "getDisabledFormats", "length", "registerNodeTransform", "textNode", "forEach", "disabledFormat", "hasFormat", "toggleFormat", "t2", "allFormats", "Object", "keys", "enabledSet", "Set", "filter", "format", "has", "c", "_c", "ContentEditable", "useTranslation", "LexicalContentEditable", "t0", "$", "className", "editorConfig", "t", "t1", "admin", "placeholder", "t2", "_jsx", "children", "LexicalEditor", "props", "$", "_c", "editorConfig", "editorContainerRef", "isSmallWidthViewport", "onChange", "editorConfigContext", "useEditorConfigContext", "editor", "useLexicalComposerContext", "floatingAnchorElem", "setFloatingAnchorElem", "useState", "t0", "Symbol", "for", "_floatingAnchorElem", "onRef", "t1", "t2", "uuid", "console", "error", "parentEditor", "registerChild", "handleFocus", "focusEditor", "handleBlur", "blurEditor", "unregisterFocus", "registerCommand", "FOCUS_COMMAND", "COMMAND_PRIORITY_LOW", "unregisterBlur", "BLUR_COMMAND", "unregisterChild", "useEffect", "t3", "t4", "editorState", "editor_0", "tags", "has", "size", "t5", "features", "plugins", "_jsxs", "Fragment", "children", "isEditable", "_jsx", "DraggableBlockPlugin", "anchorElem", "AddBlockHandlePlugin", "map", "plugin_1", "plugin", "position", "desktopOnly", "EditorPlugin", "clientProps", "key", "SlashMenuPlugin", "_temp", "className", "ref", "_temp2", "RichTextPlugin", "contentEditable", "LexicalContentEditable", "NormalizeSelectionPlugin", "InsertParagraphAtEndPlugin", "DecoratorPlugin", "TextPlugin", "OnChangePlugin", "ignoreSelectionChange", "HistoryPlugin", "markdownTransformers", "length", "MarkdownShortcutPlugin", "_temp3", "_temp4", "_temp5", "plugin_0", "plugin_2", "plugin_3", "plugin_4", "NestProviders", "children", "providers", "length", "Component", "_jsx", "slice", "LexicalProvider", "props", "composerKey", "editorConfig", "fieldProps", "isSmallWidthViewport", "onChange", "readOnly", "value", "parentContext", "useEditorConfigContext", "editDepth", "useEditDepth", "editorContainerRef", "useRef", "initialConfig", "useMemo", "Error", "JSON", "stringify", "Array", "isArray", "editable", "editorState", "undefined", "namespace", "lexical", "nodes", "getEnabledNodes", "onError", "error", "theme", "LexicalComposer", "EditorConfigProvider", "features", "LexicalEditorComponent", "baseClass", "RichTextComponent", "props", "editorConfig", "field", "admin", "className", "description", "readOnly", "readOnlyFromAdmin", "label", "localized", "required", "path", "pathFromProps", "readOnlyFromTopLevelProps", "validate", "readOnlyFromProps", "editDepth", "useEditDepth", "memoizedValidate", "useCallback", "value", "validationOptions", "customComponents", "AfterInput", "BeforeInput", "Description", "Error", "Label", "disabled", "disabledFromField", "initialValue", "setValue", "showError", "useField", "potentiallyStalePath", "isSmallWidthViewport", "setIsSmallWidthViewport", "useState", "rerenderProviderKey", "setRerenderProviderKey", "prevInitialValueRef", "React", "useRef", "prevValueRef", "useEffect", "updateViewPortWidth", "isNextSmallWidthViewport", "window", "matchMedia", "matches", "addEventListener", "removeEventListener", "classes", "hideGutter", "filter", "Boolean", "join", "pathWithEditDepth", "dispatchFieldUpdateTask", "undefined", "handleChange", "editorState", "updateFieldValue", "newState", "toJSON", "current", "requestIdleCallback", "cancelIdleCallback", "timeout", "styles", "useMemo", "mergeFieldStyles", "handleInitialValueChange", "useEffectEvent", "JSON", "stringify", "Date", "Object", "is", "_jsxs", "style", "_jsx", "RenderCustomComponent", "CustomComponent", "Fallback", "FieldError", "FieldLabel", "ErrorBoundary", "fallbackRender", "onReset", "LexicalProvider", "composerKey", "fieldProps", "onChange", "FieldDescription", "error", "role", "color", "message", "RichText"]
|
|
7
7
|
}
|
|
@@ -37,5 +37,5 @@ ${e.map(Mc).join(`
|
|
|
37
37
|
|
|
38
38
|
`,Ol="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",Fl="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C\uFE00-\uFE6F\uFEFD-\uFFFF",Tp=new RegExp("^[^"+Fl+"]*["+Ol+"]"),kp=new RegExp("^[^"+Ol+"]*["+Fl+"]"),wp={bold:O.IS_BOLD,code:O.IS_CODE,highlight:O.IS_HIGHLIGHT,italic:O.IS_ITALIC,strikethrough:O.IS_STRIKETHROUGH,subscript:O.IS_SUBSCRIPT,superscript:O.IS_SUPERSCRIPT,underline:O.IS_UNDERLINE},Ep={directionless:O.IS_DIRECTIONLESS,unmergeable:O.IS_UNMERGEABLE},Np={center:O.IS_ALIGN_CENTER,end:O.IS_ALIGN_END,justify:O.IS_ALIGN_JUSTIFY,left:O.IS_ALIGN_LEFT,right:O.IS_ALIGN_RIGHT,start:O.IS_ALIGN_START},Lp={[O.IS_ALIGN_CENTER]:"center",[O.IS_ALIGN_END]:"end",[O.IS_ALIGN_JUSTIFY]:"justify",[O.IS_ALIGN_LEFT]:"left",[O.IS_ALIGN_RIGHT]:"right",[O.IS_ALIGN_START]:"start"},Sp={normal:O.IS_NORMAL,segmented:O.IS_SEGMENTED,token:O.IS_TOKEN},Ip={[O.IS_NORMAL]:"normal",[O.IS_SEGMENTED]:"segmented",[O.IS_TOKEN]:"token"};var $l={text:({node:t})=>{let e=t.text;return t.format&O.IS_BOLD&&(e=He("strong",{children:e})),t.format&O.IS_ITALIC&&(e=He("em",{children:e})),t.format&O.IS_STRIKETHROUGH&&(e=He("span",{style:{textDecoration:"line-through"},children:e})),t.format&O.IS_UNDERLINE&&(e=He("span",{style:{textDecoration:"underline"},children:e})),t.format&O.IS_CODE&&(e=He("code",{children:e})),t.format&O.IS_SUBSCRIPT&&(e=He("sub",{children:e})),t.format&O.IS_SUPERSCRIPT&&(e=He("sup",{children:e})),e}};import{jsx as Et}from"react/jsx-runtime";var Pl={upload:({node:t})=>{let e=t;if(typeof e.value!="object")return null;let o=e.value,r=o.url;if(!o.mimeType.startsWith("image"))return Et("a",{href:r,rel:"noopener noreferrer",children:o.filename});if(!o.sizes||!Object.keys(o.sizes).length)return Et("img",{alt:o.filename,height:o.height,src:r,width:o.width});let n=[];for(let i in o.sizes){let l=o.sizes[i];if(!l||!l.width||!l.height||!l.mimeType||!l.filesize||!l.filename||!l.url)continue;let s=l?.url;n.push(Et("source",{media:`(max-width: ${l.width}px)`,srcSet:s,type:l.mimeType},i))}return n.push(Et("img",{alt:o?.filename,height:o?.height,src:r,width:o?.width},"image")),Et("picture",{children:n})}};var et={...Ml,...$l,...Il,...Nl,...Dl,...Ll,...Sl,...vl,...Rl({}),...Pl,...Al};import{jsx as Hl,Fragment as yp}from"react/jsx-runtime";import or from"react";function Bl(t){let e=!!t?.root?.children?.length,o=!1;if(t?.root?.children?.length===1&&t?.root?.children[0]?.type==="paragraph"){let r=t?.root?.children[0];if(!r?.children||r?.children?.length===0)o=!0;else if(r?.children?.length===1){let n=r?.children[0];n?.type==="text"&&(n?.text?.length||(o=!0))}}return!(!e||o)}function jl({converters:t,data:e,disableIndent:o,disableTextAlign:r}){return Bl(e)?Ul({converters:t,disableIndent:o,disableTextAlign:r,nodes:e?.root?.children,parent:e?.root}):Hl(yp,{})}function Ul({converters:t,disableIndent:e,disableTextAlign:o,nodes:r,parent:n}){let i=t.unknown;return r.map((s,u)=>{let c;s.type==="block"?(c=t?.blocks?.[s?.fields?.blockType],!c&&!i&&console.error(`Lexical => JSX converter: Blocks converter: found ${s?.fields?.blockType} block, but no converter is provided`)):s.type==="inlineBlock"?(c=t?.inlineBlocks?.[s?.fields?.blockType],!c&&!i&&console.error(`Lexical => JSX converter: Inline Blocks converter: found ${s?.fields?.blockType} inline block, but no converter is provided`)):c=t[s.type];try{!c&&i&&(c=i);let d;c?d=typeof c=="function"?c({childIndex:u,converters:t,node:s,nodesToJSX:m=>Ul({converters:m.converters??t,disableIndent:m.disableIndent??e,disableTextAlign:m.disableTextAlign??o,nodes:m.nodes,parent:m.parent??{...s,parent:n}}),parent:n}):c:d=Hl("span",{children:"unknown node"},u);let a={};if(!o&&(!Array.isArray(o)||!o?.includes(s.type))&&"format"in s&&s.format)switch(s.format){case"center":a.textAlign="center";break;case"end":a.textAlign="right";break;case"justify":a.textAlign="justify";break;case"left":break;case"right":a.textAlign="right";break;case"start":a.textAlign="left";break}if(!e&&(!Array.isArray(e)||!e?.includes(s.type))&&"indent"in s&&s.indent&&s.type!=="listitem"&&(a.paddingInlineStart=`${Number(s.indent)*2}em`),or.isValidElement(d)){if(a.textAlign||a.paddingInlineStart){let p={...a,...d?.props?.style??{}};return or.cloneElement(d,{key:u,style:p})}return or.cloneElement(d,{key:u})}return d}catch(d){return console.error("Error converting lexical node to JSX:",d,"node:",s),null}}).filter(Boolean)}var rr=({className:t,converters:e,data:o,disableContainer:r,disableIndent:n,disableTextAlign:i})=>{if(!o)return null;let l={};e?typeof e=="function"?l=e({defaultConverters:et}):l=e:l=et;let s=o&&!Array.isArray(o)&&typeof o=="object"&&"root"in o&&jl({converters:l,data:o,disableIndent:n,disableTextAlign:i});return r?Gl(Rp,{children:s}):Gl("div",{className:t??"payload-richtext",children:s})};function Wl(){let t=vp(7),[e]=Ap(),o;t[0]!==e?(o=e.getEditorState().toJSON(),t[0]=e,t[1]=o):o=t[1];let[r,n]=Op(o),i,l;t[2]!==e?(i=()=>e.registerUpdateListener(u=>{let{editorState:c}=u;n(c.toJSON())}),l=[e],t[2]=e,t[3]=i,t[4]=l):(i=t[3],l=t[4]),Dp(i,l);let s;return t[5]!==r?(s=Mp(rr,{converters:et,data:r}),t[5]=r,t[6]=s):s=t[6],s}var Fp=R({plugins:[{Component:Wl,position:"bottom"}]});import{$isNodeSelection as Tf}from"lexical";import{jsx as Nt,jsxs as $p}from"react/jsx-runtime";import"react";var nr=()=>$p("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Nt("g",{clipPath:"url(#clip0_4397_10817)",children:Nt("path",{d:"M7.75 12.25L15.25 4.75M15.25 4.75H11.5M15.25 4.75V8.5M13 11.5V13.75C13 14.5784 12.3284 15.25 11.5 15.25H6.25C5.42157 15.25 4.75 14.5784 4.75 13.75V8.5C4.75 7.67157 5.42157 7 6.25 7H8.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})}),Nt("defs",{children:Nt("clipPath",{id:"clip0_4397_10817",children:Nt("rect",{fill:"currentColor",height:"12",transform:"translate(4 4)",width:"12"})})})]});import{jsx as Hp}from"react/jsx-runtime";import*as Kl from"react";import{DecoratorBlockNode as Pp}from"@lexical/react/LexicalDecoratorBlockNode.js";function Bp(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:Vl({relationTo:o,value:e})}:null}var Lt=class extends Pp{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"relationship"}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:Bp,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=Vl(o);return r.setFormat(e.format),r}static isInline(){return!1}decorate(e,o){return null}exportDOM(){let e=document.createElement("div");e.setAttribute("data-lexical-relationship-id",String(typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value)),e.setAttribute("data-lexical-relationship-relationTo",this.__data?.relationTo);let o=document.createTextNode(this.getTextContent());return e.append(o),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"relationship",version:2}}getData(){return this.getLatest().__data}getTextContent(){return`${this.__data?.relationTo} relation to ${typeof this.__data?.value=="object"?this.__data?.value?.id:this.__data?.value}`}setData(e){let o=this.getWritable();o.__data=e}};function Vl(t){return new Lt({data:t})}var jp=Kl.lazy(()=>import("./RelationshipComponent-APF3CN47.js").then(t=>({default:t.RelationshipComponent})));function Up(t){let e=t.getAttribute("data-lexical-relationship-id"),o=t.getAttribute("data-lexical-relationship-relationTo");return e!=null&&o!=null?{node:je({relationTo:o,value:e})}:null}var Ne=class extends Lt{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{div:e=>!e.hasAttribute("data-lexical-relationship-relationTo")||!e.hasAttribute("data-lexical-relationship-id")?null:{conversion:Up,priority:2}}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id);let o={relationTo:e.relationTo,value:e.value},r=je(o);return r.setFormat(e.format),r}decorate(e,o){return Hp(jp,{className:o.theme.relationship??"LexicalEditorTheme__relationship",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function je(t){return new Ne({data:t})}function ir(t){return t instanceof Ne}import{c as sf}from"react/compiler-runtime";import{jsx as af}from"react/jsx-runtime";import{useLexicalComposerContext as cf}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as uf}from"@lexical/utils";import{useConfig as df}from"@payloadcms/ui";import{$getPreviousSelection as mf,$getSelection as pf,$isParagraphNode as ff,$isRangeSelection as hf,COMMAND_PRIORITY_EDITOR as gf,createCommand as Cf}from"lexical";import{useEffect as xf}from"react";import{c as ef}from"react/compiler-runtime";import{jsx as oo}from"react/jsx-runtime";import{useLexicalComposerContext as tf}from"@lexical/react/LexicalComposerContext.js";import{$getNodeByKey as of,COMMAND_PRIORITY_EDITOR as rf}from"lexical";import{useEffect as nf,useState as zl}from"react";import{c as Gp}from"react/compiler-runtime";import{jsx as Wp}from"react/jsx-runtime";import{useLexicalComposerContext as Vp}from"@lexical/react/LexicalComposerContext";import{useListDrawer as Kp,useModal as Jp}from"@payloadcms/ui";import{$getNodeByKey as Jl,$getPreviousSelection as Xp,$getRoot as zp,$getSelection as Zp,$isRangeSelection as Yp,$setSelection as qp}from"lexical";import{useEffect as Qp,useState as Xl}from"react";var St=t=>{let e=Gp(23),[o]=Vp(),[r,n]=Xl(null),[i,l]=Xl(!1),[s,u,c]=Kp(t),{closeDrawer:d,drawerSlug:a,isDrawerOpen:p,openDrawer:m}=c,{modalState:f}=Jp(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{let P=Zp()??Xp();n(P)},e[0]=h):h=e[0];let C=h,_;e[1]!==o||e[2]!==r?(_=()=>{r&&o.update(()=>{if(Yp(r)){let{anchor:P,focus:v}=r;Jl(P.key)&&Jl(v.key)&&qp(r.clone())}else zp().selectEnd()},{discrete:!0,skipTransforms:!0})},e[1]=o,e[2]=r,e[3]=_):_=e[3];let I=_,A;e[4]!==d?(A=()=>{d()},e[4]=d,e[5]=A):A=e[5];let b=A,T,g;e[6]!==a||e[7]!==f||e[8]!==I||e[9]!==i?(T=()=>{if(!i)return;let P=f[a];P&&!P?.isOpen&&(l(!1),setTimeout(()=>{I()},1))},g=[f,a,I,i],e[6]=a,e[7]=f,e[8]=I,e[9]=i,e[10]=T,e[11]=g):(T=e[10],g=e[11]),Qp(T,g);let w;e[12]!==u?(w=P=>Wp(u,{...P,onClick:()=>{C()}}),e[12]=u,e[13]=w):w=e[13];let M;e[14]!==m?(M=()=>{C(),m(),l(!0)},e[14]=m,e[15]=M):M=e[15];let D;return e[16]!==s||e[17]!==b||e[18]!==p||e[19]!==a||e[20]!==w||e[21]!==M?(D={closeListDrawer:b,isListDrawerOpen:p,ListDrawer:s,listDrawerSlug:a,ListDrawerToggler:w,openListDrawer:M},e[16]=s,e[17]=b,e[18]=p,e[19]=a,e[20]=w,e[21]=M,e[22]=D):D=e[22],D};var lf=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=of(o);n&&n.replace(je({relationTo:e,value:r}))}):t.dispatchCommand(lr,{relationTo:e,value:r})},Zl=t=>{let e=ef(16),{enabledCollectionSlugs:o}=t,[r]=tf(),n;e[0]!==o?.[0]?(n=()=>o?.[0],e[0]=o?.[0],e[1]=n):n=e[1];let[i]=zl(n),[l,s]=zl(null),u=o||void 0,c;e[2]!==i||e[3]!==u?(c={collectionSlugs:u,selectedCollection:i},e[2]=i,e[3]=u,e[4]=c):c=e[4];let{closeListDrawer:d,ListDrawer:a,openListDrawer:p}=St(c),m,f;e[5]!==r||e[6]!==p?(m=()=>r.registerCommand(st,I=>(s(I?.replace?I?.replace.nodeKey:null),p(),!0),rf),f=[r,p],e[5]=r,e[6]=p,e[7]=m,e[8]=f):(m=e[7],f=e[8]),nf(m,f);let h;e[9]!==d||e[10]!==r||e[11]!==l?(h=I=>{let{collectionSlug:A,doc:b}=I;lf({editor:r,relationTo:A,replaceNodeKey:l,value:b.id}),d()},e[9]=d,e[10]=r,e[11]=l,e[12]=h):h=e[12];let C=h,_;return e[13]!==a||e[14]!==C?(_=oo(a,{onSelect:C}),e[13]=a,e[14]=C,e[15]=_):_=e[15],_},Yl=t=>(t?.enabledCollectionSlugs?.length??-1)>0?oo(Zl,{...t}):oo(Ot,{...t,children:oo(Zl,{...t})});var lr=Cf("INSERT_RELATIONSHIP_COMMAND"),ql=t=>{let e=sf(10),{clientProps:o}=t,[r]=cf(),{config:n}=df(),{collections:i}=n,l=null;if(o?.enabledCollections)l=o?.enabledCollections;else if(o?.disabledCollections){let d;if(e[0]!==o?.disabledCollections||e[1]!==i){let a;e[3]!==o?.disabledCollections?(a=p=>{let{slug:m}=p;return!o?.disabledCollections?.includes(m)},e[3]=o?.disabledCollections,e[4]=a):a=e[4],d=i.filter(a).map(bf),e[0]=o?.disabledCollections,e[1]=i,e[2]=d}else d=e[2];l=d}let s,u;e[5]!==r?(s=()=>{if(!r.hasNodes([Ne]))throw new Error("RelationshipPlugin: RelationshipNode not registered on editor");return r.registerCommand(lr,_f,gf)},u=[r],e[5]=r,e[6]=s,e[7]=u):(s=e[6],u=e[7]),xf(s,u);let c;return e[8]!==l?(c=af(Yl,{enabledCollectionSlugs:l}),e[8]=l,e[9]=c):c=e[9],c};function bf(t){let{slug:e}=t;return e}function _f(t){let e=pf()||mf();if(hf(e)){let o=je(t),{focus:r}=e,n=r.getNode();uf(o),ff(n)&&!n.__first&&n.remove()}return!0}var kf=R({nodes:[Ne],plugins:[{Component:ql,position:"normal"}],slashMenu:{groups:[Q([{Icon:nr,key:"relationship",keywords:["relationship","relation","rel"],label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(st,{replace:!1})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:nr,isActive:({selection:t})=>{if(!Tf(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return ir(e)},key:"relationship",label:({i18n:t})=>t.t("lexical:relationship:label"),onSelect:({editor:t})=>{t.dispatchCommand(st,{replace:!1})}}])]}});import{c as is}from"react/compiler-runtime";import{jsx as de,jsxs as jf}from"react/jsx-runtime";import{useLexicalComposerContext as Uf}from"@lexical/react/LexicalComposerContext.js";import{useScrollInfo as Gf,useThrottledEffect as Wf,useTranslation as Vf}from"@payloadcms/ui";import*as Le from"react";import{useMemo as Kf}from"react";import{c as wf}from"react/compiler-runtime";import{jsx as Ef}from"react/jsx-runtime";import{mergeRegister as Nf}from"@lexical/utils";import{$addUpdateTag as Lf,$getSelection as Sf}from"lexical";import{useEffect as ro,useState as sr}from"react";var ar="toolbar-popup__button",It=t=>{let e=wf(34),{children:o,editor:r,item:n}=t,[i,l]=sr(!0),[s,u]=sr(!1),[c,d]=sr(ar),a=j(),p;e[0]!==s||e[1]!==r||e[2]!==a||e[3]!==i||e[4]!==n?(p=()=>{r.getEditorState().read(()=>{let M=Sf();if(M){if(n.isActive){let D=n.isActive({editor:r,editorConfigContext:a,selection:M});s!==D&&u(D)}if(n.isEnabled){let D=n.isEnabled({editor:r,editorConfigContext:a,selection:M});i!==D&&l(D)}}})},e[0]=s,e[1]=r,e[2]=a,e[3]=i,e[4]=n,e[5]=p):p=e[5];let m=p,f,h;e[6]!==m?(f=()=>{m()},h=[m],e[6]=m,e[7]=f,e[8]=h):(f=e[7],h=e[8]),ro(f,h);let C,_;e[9]!==m?(C=()=>(document.addEventListener("mouseup",m),()=>{document.removeEventListener("mouseup",m)}),_=[m],e[9]=m,e[10]=C,e[11]=_):(C=e[10],_=e[11]),ro(C,_);let I,A;e[12]!==r||e[13]!==m?(I=()=>Nf(r.registerUpdateListener(()=>{m()})),A=[r,m],e[12]=r,e[13]=m,e[14]=I,e[15]=A):(I=e[14],A=e[15]),ro(I,A);let b;e[16]!==s||e[17]!==i||e[18]!==n.key?(b=()=>{d([ar,i===!1?"disabled":"",s?"active":"",n?.key?`${ar}-`+n.key:""].filter(Boolean).join(" "))},e[16]=s,e[17]=i,e[18]=n.key,e[19]=b):b=e[19];let T;e[20]!==s||e[21]!==c||e[22]!==i||e[23]!==n.key?(T=[i,s,c,n.key],e[20]=s,e[21]=c,e[22]=i,e[23]=n.key,e[24]=T):T=e[24],ro(b,T);let g;e[25]!==s||e[26]!==r||e[27]!==i||e[28]!==n?(g=()=>{if(i!==!1)return r.focus(()=>{r.update(If),n.onSelect?.({editor:r,isActive:s})}),!0},e[25]=s,e[26]=r,e[27]=i,e[28]=n,e[29]=g):g=e[29];let w;return e[30]!==o||e[31]!==c||e[32]!==g?(w=Ef("button",{className:c,onClick:g,onMouseDown:yf,type:"button",children:o}),e[30]=o,e[31]=c,e[32]=g,e[33]=w):w=e[33],w};function If(){Lf("toolbar")}function yf(t){t.preventDefault()}import{c as ns}from"react/compiler-runtime";import{jsx as tt}from"react/jsx-runtime";import dr,{useEffect as rs}from"react";import{mergeRegister as $f}from"@lexical/utils";import{useTranslation as Pf}from"@payloadcms/ui";import{$getSelection as Bf}from"lexical";import{jsx as Me,jsxs as Ql}from"react/jsx-runtime";import{Button as Rf}from"@payloadcms/ui";import{$addUpdateTag as vf,isDOMNode as Mf}from"lexical";import no,{useCallback as Af,useEffect as yt,useMemo as Df,useRef as ur,useState as io}from"react";import{createPortal as Of}from"react-dom";var cr="toolbar-popup__dropdown-item",es=no.createContext(null);function ts({active:t,children:e,editor:o,enabled:r,Icon:n,item:i,tooltip:l}){let[s,u]=io(cr);yt(()=>{u([cr,r===!1?"disabled":"",t?"active":"",i?.key?`${cr}-${i.key}`:""].filter(Boolean).join(" "))},[r,t,s,i.key]);let c=ur(null),d=no.use(es);if(d===null)throw new Error("DropDownItem must be used within a DropDown");let{registerItem:a}=d;return yt(()=>{c?.current!=null&&a(c)},[c,a]),Me(Rf,{"aria-label":l,buttonStyle:"none",className:s,disabled:r===!1,icon:n,iconPosition:"left",iconStyle:"none",onClick:()=>{r!==!1&&o.focus(()=>{o.update(()=>{vf("toolbar")}),i.onSelect?.({editor:o,isActive:t})})},onMouseDown:p=>{p.preventDefault()},ref:c,tooltip:l,type:"button",children:e})}function Ff({children:t,dropDownRef:e,itemsContainerClassNames:o,onClose:r}){let[n,i]=io(),[l,s]=io(),u=Af(a=>{i(p=>p!=null?[...p,a]:[a])},[i]),c=a=>{if(n==null)return;let{key:p}=a;["ArrowDown","ArrowUp","Escape","Tab"].includes(p)&&a.preventDefault(),p==="Escape"||p==="Tab"?r():p==="ArrowUp"?s(m=>{if(m==null)return n[0];let f=n.indexOf(m)-1;return n[f===-1?n.length-1:f]}):p==="ArrowDown"&&s(m=>m==null?n[0]:n[n.indexOf(m)+1])},d=Df(()=>({registerItem:u}),[u]);return yt(()=>{n!=null&&l==null&&s(n[0]),l!=null&&l?.current!=null&&l.current.focus()},[n,l]),Me(es,{value:d,children:Me("div",{className:(o??["toolbar-popup__dropdown-items"]).join(" "),onKeyDown:c,ref:e,children:t})})}function os({buttonAriaLabel:t,buttonClassName:e,children:o,disabled:r=!1,Icon:n,itemsContainerClassNames:i,label:l,stopCloseOnClickSelf:s}){let u=ur(null),c=ur(null),[d,a]=io(!1),p=()=>{a(!1),c?.current!=null&&c.current.focus()};yt(()=>{let f=c.current,h=u.current;if(d&&f!==null&&h!==null){let{left:C,top:_}=f.getBoundingClientRect(),I=window.scrollY||document.documentElement.scrollTop;h.style.top=`${_+I+f.offsetHeight+5}px`,h.style.left=`${Math.min(C-5,window.innerWidth-h.offsetWidth-20)}px`}},[u,c,d]),yt(()=>{let f=c.current;if(f!==null&&d){let h=C=>{let _=C.target;Mf(_)&&(s&&u.current&&u.current.contains(_)||f.contains(_)||a(!1))};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[u,c,d,s]);let m=Of(Me(Ff,{dropDownRef:u,itemsContainerClassNames:i,onClose:p,children:o}),document.body);return Ql(no.Fragment,{children:[Ql("button",{"aria-label":t,className:e+(d?" active":""),disabled:r,onClick:f=>{f.preventDefault(),a(!d)},onMouseDown:f=>{f.preventDefault()},ref:c,type:"button",children:[n&&Me(n,{}),l&&Me("span",{className:"toolbar-popup__dropdown-label",children:l}),Me("i",{className:"toolbar-popup__dropdown-caret"})]}),d&&Me(no.Fragment,{children:m})]})}var mr="toolbar-popup__dropdown",Hf=t=>{let e=ns(18),{active:o,anchorElem:r,editor:n,enabled:i,item:l}=t,{i18n:s}=Pf(),{fieldProps:u}=j(),{featureClientSchemaMap:c,schemaPath:d}=u;if(l.Component){let f;return e[0]!==o||e[1]!==r||e[2]!==n||e[3]!==i||e[4]!==l?(f=l?.Component&&tt(l.Component,{active:o,anchorElem:r,editor:n,enabled:i,item:l},l.key),e[0]=o,e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=f):f=e[5],f}let a=l.key,p;if(l.label){let f;e[6]!==c||e[7]!==s||e[8]!==l||e[9]!==d?(f=typeof l.label=="function"?l.label({featureClientSchemaMap:c,i18n:s,schemaPath:d}):l.label,e[6]=c,e[7]=s,e[8]=l,e[9]=d,e[10]=f):f=e[10],a=f}a.length>25?p=a.substring(0,25)+"...":p=a;let m;return e[11]!==o||e[12]!==p||e[13]!==n||e[14]!==i||e[15]!==l||e[16]!==a?(m=tt(ts,{active:o,editor:n,enabled:i,Icon:l?.ChildComponent?tt(l.ChildComponent,{}):void 0,item:l,tooltip:a,children:tt("span",{className:"text",children:p})},l.key),e[11]=o,e[12]=p,e[13]=n,e[14]=i,e[15]=l,e[16]=a,e[17]=m):m=e[17],m},Ue=t=>{let e=ns(36),{anchorElem:o,classNames:r,editor:n,group:i,Icon:l,itemsContainerClassNames:s,label:u,maxActiveItems:c,onActiveChange:d}=t,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=[],e[0]=a):a=e[0];let[p,m]=dr.useState(a),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[1]=f):f=e[1];let[h,C]=dr.useState(f),[_,I]=dr.useState(!0),A=j(),{items:b,key:T}=i,g;e[2]!==n||e[3]!==A||e[4]!==i||e[5]!==b||e[6]!==c||e[7]!==d?(g=()=>{n.getEditorState().read(()=>{let $=Bf();if(!$)return;let U=[],V=[],pe=[];for(let H of b)H.isActive&&(!c||U.length<c)&&H.isActive({editor:n,editorConfigContext:A,selection:$})&&(U.push(H.key),V.push(H)),H.isEnabled?H.isEnabled({editor:n,editorConfigContext:A,selection:$})&&pe.push(H.key):pe.push(H.key);i.isEnabled&&I(i.isEnabled({editor:n,editorConfigContext:A,selection:$})),m(U),C(pe),d&&d({activeItems:V})})},e[2]=n,e[3]=A,e[4]=i,e[5]=b,e[6]=c,e[7]=d,e[8]=g):g=e[8];let w=g,M,D;e[9]!==w?(M=()=>{w()},D=[w],e[9]=w,e[10]=M,e[11]=D):(M=e[10],D=e[11]),rs(M,D);let P,v;e[12]!==n||e[13]!==w?(P=()=>$f(n.registerUpdateListener(()=>{w()})),v=[n,w],e[12]=n,e[13]=w,e[14]=P,e[15]=v):(P=e[14],v=e[15]),rs(P,v);let N=`${T} dropdown`,x=`${mr}-${T}`,E;e[16]!==r?(E=r||[],e[16]=r,e[17]=E):E=e[17];let S;e[18]!==E||e[19]!==x?(S=[mr,x,...E].filter(Boolean),e[18]=E,e[19]=x,e[20]=S):S=e[20];let L=S.join(" "),y=!_,k;e[21]!==s?(k=s||[],e[21]=s,e[22]=k):k=e[22];let F;return e[23]!==l||e[24]!==p||e[25]!==o||e[26]!==n||e[27]!==h||e[28]!==T||e[29]!==b||e[30]!==u||e[31]!==L||e[32]!==y||e[33]!==k||e[34]!==N?(F=tt(os,{buttonAriaLabel:N,buttonClassName:L,disabled:y,Icon:l,itemsContainerClassNames:[`${mr}-items`,...k],label:u,children:b.length?b.map($=>tt(Hf,{active:p.includes($.key),anchorElem:o,editor:n,enabled:h.includes($.key),item:$},$.key)):null},T),e[23]=l,e[24]=p,e[25]=o,e[26]=n,e[27]=h,e[28]=T,e[29]=b,e[30]=u,e[31]=L,e[32]=y,e[33]=k,e[34]=N,e[35]=F):F=e[35],F};function Jf({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&de(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?de(It,{editor:e,item:o,children:de(o.ChildComponent,{})},o.key):null}function Xf(t){let e=is(23),{anchorElem:o,editor:r,editorConfig:n,group:i,index:l}=t,{i18n:s}=Vf(),{fieldProps:u}=j(),{featureClientSchemaMap:c,schemaPath:d}=u,[a,p]=Le.useState(void 0),[m,f]=Le.useState(void 0),h;e[0]!==i.ChildComponent||e[1]!==i.items||e[2]!==i.type?(h=()=>{i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0)},e[0]=i.ChildComponent,e[1]=i.items,e[2]=i.type,e[3]=h):h=e[3];let C;e[4]!==i?(C=[i],e[4]=i,e[5]=C):C=e[5],Le.useEffect(h,C);let _;e[6]!==c||e[7]!==i.ChildComponent||e[8]!==i.items||e[9]!==i.type||e[10]!==s||e[11]!==d?(_=T=>{let{activeItems:g}=T;if(!g.length){i?.type==="dropdown"&&i.items.length&&i.ChildComponent?(f(()=>i.ChildComponent),p(void 0)):(f(void 0),p(void 0));return}let w=g[0],M=w.key;w.label&&(M=typeof w.label=="function"?w.label({featureClientSchemaMap:c,i18n:s,schemaPath:d}):w.label),M.length>25&&(M=M.substring(0,25)+"..."),g.length===1?(p(M),f(()=>w.ChildComponent)):(p(s.t("lexical:general:toolbarItemsActive",{count:g.length})),i?.type==="dropdown"&&i.items.length&&i.ChildComponent?f(()=>i.ChildComponent):f(void 0))},e[6]=c,e[7]=i.ChildComponent,e[8]=i.items,e[9]=i.type,e[10]=s,e[11]=d,e[12]=_):_=e[12];let I=_,A=`fixed-toolbar__group fixed-toolbar__group-${i.key}`,b;return e[13]!==m||e[14]!==o||e[15]!==a||e[16]!==r||e[17]!==n.features.toolbarFixed?.groups.length||e[18]!==i||e[19]!==l||e[20]!==I||e[21]!==A?(b=jf("div",{className:A,children:[i.type==="dropdown"&&i.items.length?m?de(Ue,{anchorElem:o,editor:r,group:i,Icon:m,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a,maxActiveItems:i.maxActiveItems??1,onActiveChange:I}):de(Ue,{anchorElem:o,editor:r,group:i,itemsContainerClassNames:["fixed-toolbar__dropdown-items"],label:a,maxActiveItems:i.maxActiveItems??1,onActiveChange:I}):null,i.type==="buttons"&&i.items.length?i.items.map(T=>de(Jf,{anchorElem:o,editor:r,item:T},T.key)):null,l<n.features.toolbarFixed?.groups.length-1&&de("div",{className:"divider"})]},i.key),e[13]=m,e[14]=o,e[15]=a,e[16]=r,e[17]=n.features.toolbarFixed?.groups.length,e[18]=i,e[19]=l,e[20]=I,e[21]=A,e[22]=b):b=e[22],b}function zf({anchorElem:t,clientProps:e,editor:o,editorConfig:r,parentWithFixedToolbar:n}){let i=Le.useRef(null),{y:l}=Gf(),s=Kf(()=>{if(!n||e?.disableIfParentHasFixedToolbar)return null;let c=n.editorContainerRef.current.previousElementSibling;for(;c;){if(c.classList.contains("fixed-toolbar"))return c;c=c.previousElementSibling}return null},[e?.disableIfParentHasFixedToolbar,n]);return Wf(()=>{if(!s)return;let u=i.current;if(!u)return;let c=u.getBoundingClientRect(),d=s.getBoundingClientRect();if(!(c.bottom<d.top||c.top>d.bottom))u.classList.remove("fixed-toolbar"),u.classList.add("fixed-toolbar","fixed-toolbar--overlapping"),s.classList.remove("fixed-toolbar"),s.classList.add("fixed-toolbar","fixed-toolbar--hide");else{if(!u.classList.contains("fixed-toolbar--overlapping"))return;u.classList.remove("fixed-toolbar--overlapping"),u.classList.add("fixed-toolbar"),s.classList.remove("fixed-toolbar--hide"),s.classList.add("fixed-toolbar")}},50,[i,s,l]),de("div",{className:"fixed-toolbar",onFocus:u=>{u.stopPropagation()},ref:i,children:o.isEditable()&&de(Le.Fragment,{children:r?.features&&r.features?.toolbarFixed?.groups.map((u,c)=>de(Xf,{anchorElem:t,editor:o,editorConfig:r,group:u,index:c},u.key))})})}var ls=t=>{if(t.parentEditor?.editorConfig){if(t.parentEditor?.editorConfig.resolvedFeatureMap.has("toolbarFixed"))return t.parentEditor;if(t.parentEditor)return ls(t.parentEditor)}return!1},ss=t=>{let e=is(6),{clientProps:o}=t,[r]=Uf(),n=j(),{editorConfig:i}=n,l=o.applyToFocusedEditor&&n.focusedEditor?.editor||r,s=o.applyToFocusedEditor&&n.focusedEditor?.editorConfig||i,u,c;if(e[0]!==o.disableIfParentHasFixedToolbar||e[1]!==l||e[2]!==s||e[3]!==n){c=Symbol.for("react.early_return_sentinel");e:{let d=ls(n);if(o?.disableIfParentHasFixedToolbar&&d){c=null;break e}if(!s?.features?.toolbarFixed?.groups?.length){c=null;break e}u=de(zf,{anchorElem:document.body,editor:l,editorConfig:s,parentWithFixedToolbar:d})}e[0]=o.disableIfParentHasFixedToolbar,e[1]=l,e[2]=s,e[3]=n,e[4]=u,e[5]=c}else u=e[4],c=e[5];return c!==Symbol.for("react.early_return_sentinel")?c:u};var Zf=R({plugins:[{Component:ss,position:"aboveContainer"}]});import{c as us}from"react/compiler-runtime";import{jsx as ge,jsxs as ds}from"react/jsx-runtime";import{useLexicalComposerContext as Yf}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ms}from"@lexical/utils";import{$getSelection as ps,$isRangeSelection as as,$isTextNode as qf,COMMAND_PRIORITY_LOW as Qf,getDOMSelection as fs,SELECTION_CHANGE_COMMAND as e1}from"lexical";import{useCallback as so,useEffect as Rt,useRef as cs,useState as t1}from"react";import*as ao from"react";import{createPortal as o1}from"react-dom";function pr(t,e){let o=t.getRangeAt(0),r;if(t.anchorNode===e){let n=e;for(;n.firstElementChild!=null;)n=n.firstElementChild;r=n.getBoundingClientRect()}else r=o.getBoundingClientRect();return r}function lo(t){let{alwaysDisplayOnTop:e=!1,anchorElem:o,anchorFlippedOffset:r=0,floatingElem:n,horizontalOffset:i=32,horizontalPosition:l="left",specialHandlingForCaret:s=!1,targetRect:u,verticalGap:c=10}=t,d=o.parentElement;if(u===null||d==null){n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)";return}let a=n.getBoundingClientRect(),p=o.getBoundingClientRect(),m=d.getBoundingClientRect(),f=u.top-a.height-c,h=u.left-i;l==="center"&&(h=u.left+u.width/2-a.width/2);let C=0;return!e&&f<m.top&&!s&&(C=a.height+u.height+c*2,f+=C),l==="center"?h+a.width>m.right?h=m.right-a.width-i:h<m.left&&(h=m.left+i):h+a.width>m.right&&(h=m.right-a.width-i),h-=p.left,n.style.opacity="1",s&&r!==0?(f-=p.bottom-r+a.height-3,n.style.transform=`translate(${h}px, ${f}px) rotate(180deg)`):(f-=p.top,n.style.transform=`translate(${h}px, ${f}px)`),C}function r1({anchorElem:t,editor:e,item:o}){return o.Component?o?.Component&&ge(o.Component,{anchorElem:t,editor:e,item:o},o.key):o.ChildComponent?ge(It,{editor:e,item:o,children:ge(o.ChildComponent,{})},o.key):null}function n1(t){let e=us(19),{anchorElem:o,editor:r,group:n,index:i}=t,{editorConfig:l}=j(),[s,u]=ao.useState(),c;e[0]!==n.ChildComponent||e[1]!==n.items||e[2]!==n.type?(c=()=>{n?.type==="dropdown"&&n.items.length&&n.ChildComponent?u(()=>n.ChildComponent):u(void 0)},e[0]=n.ChildComponent,e[1]=n.items,e[2]=n.type,e[3]=c):c=e[3];let d;e[4]!==n?(d=[n],e[4]=n,e[5]=d):d=e[5],ao.useEffect(c,d);let a;e[6]!==n.ChildComponent||e[7]!==n.items||e[8]!==n.type?(a=h=>{let{activeItems:C}=h;if(!C.length){n?.type==="dropdown"&&n.items.length&&n.ChildComponent?u(()=>n.ChildComponent):u(void 0);return}let _=C[0];u(()=>_?.ChildComponent)},e[6]=n.ChildComponent,e[7]=n.items,e[8]=n.type,e[9]=a):a=e[9];let p=a,m=`inline-toolbar-popup__group inline-toolbar-popup__group-${n.key}`,f;return e[10]!==s||e[11]!==o||e[12]!==r||e[13]!==l.features.toolbarInline?.groups.length||e[14]!==n||e[15]!==i||e[16]!==p||e[17]!==m?(f=ds("div",{className:m,children:[n.type==="dropdown"&&n.items.length?s?ge(Ue,{anchorElem:o,editor:r,group:n,Icon:s,maxActiveItems:n.maxActiveItems??1,onActiveChange:p}):ge(Ue,{anchorElem:o,editor:r,group:n,maxActiveItems:n.maxActiveItems??1,onActiveChange:p}):null,n.type==="buttons"&&n.items.length?n.items.map(h=>ge(r1,{anchorElem:o,editor:r,item:h},h.key)):null,i<l.features.toolbarInline?.groups.length-1&&ge("div",{className:"divider"})]},n.key),e[10]=s,e[11]=o,e[12]=r,e[13]=l.features.toolbarInline?.groups.length,e[14]=n,e[15]=i,e[16]=p,e[17]=m,e[18]=f):f=e[18],f}function i1({anchorElem:t,editor:e}){let o=cs(null),r=cs(null),{editorConfig:n}=j(),i=so(()=>{if(o?.current){let c=o.current.style.opacity==="0",d=o.current.style.pointerEvents==="none";c||(o.current.style.opacity="0"),d||(o.current.style.pointerEvents="none")}},[o]),l=so(c=>{if(o?.current&&(c.buttons===1||c.buttons===3)){let d=o.current.style.opacity==="0",a=o.current.style.pointerEvents==="none";if(!d||!a){let p=c.clientX,m=c.clientY,f=document.elementFromPoint(p,m);o.current.contains(f)||i()}}},[i]),s=so(()=>{o?.current&&(o.current.style.opacity!=="1"&&(o.current.style.opacity="1"),o.current.style.pointerEvents!=="auto"&&(o.current.style.pointerEvents="auto"))},[]);Rt(()=>(document.addEventListener("mousemove",l),document.addEventListener("mouseup",s),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",s)}),[o,l,s]);let u=so(()=>{let c=ps(),d=fs(e._window);if(o.current===null)return;let a=t.querySelector(":scope > .link-editor"),p=a!==null&&"style"in a&&a?.style?.opacity==="1",m=e.getRootElement();if(c!==null&&d!==null&&!d.isCollapsed&&m!==null&&m.contains(d.anchorNode)){let f=pr(d,m),h=lo({alwaysDisplayOnTop:p,anchorElem:t,floatingElem:o.current,horizontalPosition:"center",targetRect:f});r.current&&lo({anchorElem:o.current,anchorFlippedOffset:h,floatingElem:r.current,horizontalOffset:5,horizontalPosition:"center",specialHandlingForCaret:!0,targetRect:f,verticalGap:8})}else i()},[e,i,t]);return Rt(()=>{let c=t.parentElement,d=()=>{e.getEditorState().read(()=>{u()})};return window.addEventListener("resize",d),c&&c.addEventListener("scroll",d),()=>{window.removeEventListener("resize",d),c&&c.removeEventListener("scroll",d)}},[e,u,t]),Rt(()=>(e.getEditorState().read(()=>{u()}),ms(e.registerUpdateListener(({editorState:c})=>{c.read(()=>{u()})}),e.registerCommand(e1,()=>(u(),!1),Qf))),[e,u]),ds("div",{className:"inline-toolbar-popup",ref:o,children:[ge("div",{className:"caret",ref:r}),n?.features&&n.features?.toolbarInline?.groups.map((c,d)=>ge(n1,{anchorElem:t,editor:e,group:c,index:d},c.key))]})}function l1(t,e){let o=us(12),[r,n]=t1(!1),i;o[0]!==t?(i=()=>{t.getEditorState().read(()=>{if(t.isComposing())return;let p=ps(),m=fs(t._window),f=t.getRootElement();if(m!==null&&(!as(p)||f===null||!f.contains(m.anchorNode))){n(!1);return}if(!as(p))return;if(p.getTextContent()!==""){let C=p.getNodes(),_=!1;for(let I of C)if(qf(I)){n(!0),_=!0;break}_||n(!1)}else n(!1);let h=p.getTextContent().replace(/\n/g,"");if(!p.isCollapsed()&&h===""){n(!1);return}})},o[0]=t,o[1]=i):i=o[1];let l=i,s,u;o[2]!==l?(s=()=>(document.addEventListener("selectionchange",l),document.addEventListener("mouseup",l),()=>{document.removeEventListener("selectionchange",l),document.removeEventListener("mouseup",l)}),u=[l],o[2]=l,o[3]=s,o[4]=u):(s=o[3],u=o[4]),Rt(s,u);let c,d;if(o[5]!==t||o[6]!==l?(c=()=>ms(t.registerUpdateListener(()=>{l()}),t.registerRootListener(()=>{t.getRootElement()===null&&n(!1)})),d=[t,l],o[5]=t,o[6]=l,o[7]=c,o[8]=d):(c=o[7],d=o[8]),Rt(c,d),!r||!t.isEditable())return null;let a;return o[9]!==e||o[10]!==t?(a=o1(ge(i1,{anchorElem:e,editor:t}),e),o[9]=e,o[10]=t,o[11]=a):a=o[11],a}var hs=t=>{let{anchorElem:e}=t,[o]=Yf();return l1(o,e)};var s1=R({plugins:[{Component:hs,position:"floatingAnchorElem"}]});import{TableCellNode as Yh,TableNode as qh,TableRowNode as Qh}from"@lexical/table";import{jsx as gs}from"react/jsx-runtime";import"react";var fr=()=>gs("svg",{className:"icon",fill:"none",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:gs("path",{clipRule:"evenodd",d:"M5.33333 4.5C4.8731 4.5 4.5 4.8731 4.5 5.33333V7.5H9.5V4.5H5.33333ZM5.33333 3.5C4.32081 3.5 3.5 4.32081 3.5 5.33333V14.6667C3.5 15.6792 4.32081 16.5 5.33333 16.5H14.6667C15.6792 16.5 16.5 15.6792 16.5 14.6667V5.33333C16.5 4.32081 15.6792 3.5 14.6667 3.5H5.33333ZM10.5 4.5V7.5H15.5V5.33333C15.5 4.8731 15.1269 4.5 14.6667 4.5H10.5ZM15.5 8.5H10.5V11.5H15.5V8.5ZM15.5 12.5H10.5V15.5H14.6667C15.1269 15.5 15.5 15.1269 15.5 14.6667V12.5ZM9.5 15.5V12.5H4.5V14.6667C4.5 15.1269 4.8731 15.5 5.33333 15.5H9.5ZM4.5 11.5H9.5V8.5H4.5V11.5Z",fill:"currentColor",fillRule:"evenodd"})});import{$createTableCellNode as a1,$createTableNode as c1,$createTableRowNode as u1,$isTableCellNode as Cs,$isTableNode as hr,$isTableRowNode as gr,TableCellHeaderStates as co,TableCellNode as d1,TableNode as m1,TableRowNode as p1}from"@lexical/table";import{$isParagraphNode as f1,$isTextNode as h1}from"lexical";var bs=/^\|(.+)\|\s?$/,g1=/^(\| ?:?-*:? ?)+\|\s?$/,_s=({allTransformers:t})=>({type:"element",dependencies:[m1,p1,d1],export:e=>{if(!hr(e))return null;let o=[];for(let r of e.getChildren()){let n=[];if(!gr(r))continue;let i=!1;for(let l of r.getChildren())Cs(l)&&(n.push(Br(t,l).replace(/\n/g,"\\n").trim()),l.__headerState===co.ROW&&(i=!0));o.push(`| ${n.join(" | ")} |`),i&&o.push(`| ${n.map(l=>"---").join(" | ")} |`)}return o.join(`
|
|
39
39
|
`)},regExp:bs,replace:(e,o,r)=>{let n=r[0];if(!n)return;if(g1.test(n)){let a=e.getPreviousSibling();if(!a||!hr(a))return;let p=a.getChildren(),m=p[p.length-1];if(!m||!gr(m))return;m.getChildren().forEach(f=>{Cs(f)&&f.setHeaderStyles(co.ROW,co.ROW)}),e.remove();return}let i=xs(n,t);if(i==null)return;let l=[i],s=e.getPreviousSibling(),u=i.length;for(;s&&!(!f1(s)||s.getChildrenSize()!==1);){let a=s.getFirstChild();if(!h1(a))break;let p=xs(a.getTextContent(),t);if(p==null)break;u=Math.max(u,p.length),l.unshift(p);let m=s.getPreviousSibling();s.remove(),s=m}let c=c1();for(let a of l){let p=u1();c.append(p);for(let m=0;m<u;m++)p.append(m<a.length?a[m]:Ts("",t))}let d=e.getPreviousSibling();hr(d)&&C1(d)===u?(d.append(...c.getChildren()),e.remove()):e.replace(c),c.selectEnd()}});function C1(t){let e=t.getFirstChild();return gr(e)?e.getChildrenSize():0}var Ts=(t,e)=>{t=t.replace(/\\n/g,`
|
|
40
|
-
`);let o=a1(co.NO_STATUS);return Pr(t,e,o),o},xs=(t,e)=>{let o=t.match(bs);return!o||!o[1]?null:o[1].split("|").map(r=>Ts(r,e))};import{c as b1}from"react/compiler-runtime";import{jsx as B,jsxs as Se}from"react/jsx-runtime";import{useLexicalComposerContext as Ns}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as _1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as xr,$deleteTableColumn__EXPERIMENTAL as T1,$deleteTableRow__EXPERIMENTAL as k1,$getNodeTriplet as w1,$getTableCellNodeFromLexicalNode as ws,$getTableColumnIndexFromTableCellNode as E1,$getTableNodeFromLexicalNodeOrThrow as Ie,$getTableRowIndexFromTableCellNode as N1,$insertTableColumn__EXPERIMENTAL as L1,$insertTableRow__EXPERIMENTAL as S1,$isTableCellNode as Ls,$isTableSelection as vt,$unmergeCell as I1,getTableElement as br,getTableObserverFromTableElement as _r,TableCellHeaderStates as Ae,TableCellNode as y1}from"@lexical/table";import{mergeRegister as R1}from"@lexical/utils";import{useScrollInfo as v1}from"@payloadcms/ui";import{$createParagraphNode as M1,$getSelection as mo,$isElementNode as A1,$isParagraphNode as D1,$isRangeSelection as Tr,$isTextNode as O1,$setSelection as F1,COMMAND_PRIORITY_CRITICAL as $1,getDOMSelection as P1,isDOMNode as B1,SELECTION_CHANGE_COMMAND as H1}from"lexical";import*as kr from"react";import{useCallback as me,useEffect as ot,useRef as uo,useState as rt}from"react";import{createPortal as Ss}from"react-dom";import{jsx as Cr,jsxs as x1}from"react/jsx-runtime";import"react";var ks=()=>x1("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Cr("path",{d:"M5 11C5.55228 11 6 10.5523 6 10C6 9.44772 5.55228 9 5 9C4.44772 9 4 9.44772 4 10C4 10.5523 4.44772 11 5 11Z",fill:"currentColor"}),Cr("path",{d:"M10 11C10.5523 11 11 10.5523 11 10C11 9.44772 10.5523 9 10 9C9.44772 9 9 9.44772 9 10C9 10.5523 9.44772 11 10 11Z",fill:"currentColor"}),Cr("path",{d:"M15 11C15.5523 11 16 10.5523 16 10C16 9.44772 15.5523 9 15 9C14.4477 9 14 9.44772 14 10C14 10.5523 14.4477 11 15 11Z",fill:"currentColor"})]});function Es(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function j1(){let t=mo();if(Tr(t)&&!t.isCollapsed()||vt(t)&&!t.anchor.is(t.focus)||!Tr(t)&&!vt(t))return!1;let[e]=w1(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function U1(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!D1(e)||!e.isEmpty())}function G1(t){let e=t.getLastDescendant();O1(e)?e.select():A1(e)?e.selectEnd():e!==null&&e.selectNext()}function W1({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[i]=Ns(),l=uo(null),[s,u]=rt(n),[c,d]=rt({columns:1,rows:1}),[a,p]=rt(!1),[m,f]=rt(!1),{y:h}=v1();ot(()=>i.registerMutationListener(y1,x=>{x.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{u(s.getLatest())})},{skipInitialization:!0}),[i,s]),ot(()=>{i.getEditorState().read(()=>{let x=mo();if(vt(x)){let E=Es(x);d(Es(x)),p(E.columns>1||E.rows>1)}f(j1())})},[i]),ot(()=>{let x=e.current,E=l.current,S=i.getRootElement();if(x!=null&&E!=null&&S!=null){let L=S.getBoundingClientRect(),y=x.getBoundingClientRect();E.style.opacity="1";let k=E.getBoundingClientRect(),F=5,$=y.right+F;if($+k.width>window.innerWidth||$+k.width>L.right){let V=y.left-k.width-F;$=(V<0?F:V)+window.pageXOffset}E.style.left=`${$+window.pageXOffset}px`;let U=y.top;if(U+k.height>window.innerHeight){let V=y.bottom-k.height;U=V<0?F:V}E.style.top=`${U}px`}},[e,l,i,h]),ot(()=>{function x(E){l.current!=null&&e.current!=null&&B1(E.target)&&!l.current.contains(E.target)&&!e.current.contains(E.target)&&r(!1)}return window.addEventListener("click",x),()=>window.removeEventListener("click",x)},[r,e]);let C=me(()=>{i.update(()=>{if(s.isAttached()){let x=Ie(s),E=br(x,i.getElementByKey(x.getKey()));if(E===null)throw new Error("Expected to find tableElement in DOM");let S=_r(E);S!==null&&S.$clearHighlight(),x.markDirty(),u(s.getLatest())}F1(null)})},[i,s]),_=()=>{i.update(()=>{let x=mo();if(vt(x)){let S=x.getNodes().filter(Ls);if(S.length===0)return;let L=Ie(S[0]),[y]=xr(L,null,null),k=1/0,F=-1/0,$=1/0,U=-1/0,V=new Set;for(let Y of y)for(let K of Y){if(!K||!K.cell)continue;let oe=K.cell.getKey();if(!V.has(oe)&&S.some(re=>re.is(K.cell))){V.add(oe);let re=K.startRow,le=K.startColumn,De=K.cell.__rowSpan||1,it=K.cell.__colSpan||1;k=Math.min(k,re),F=Math.max(F,re+De-1),$=Math.min($,le),U=Math.max(U,le+it-1)}}if(k===1/0||$===1/0)return;let pe=F-k+1,H=U-$+1,W=y?.[k]?.[$];if(!W?.cell)return;let te=W.cell;te.setColSpan(H),te.setRowSpan(pe);let ce=new Set([te.getKey()]);for(let Y=k;Y<=F;Y++)for(let K=$;K<=U;K++){let oe=y?.[Y]?.[K];if(!oe?.cell)continue;let re=oe.cell,le=re.getKey();ce.has(le)||(ce.add(le),U1(re)||te.append(...re.getChildren()),re.remove())}te.getChildrenSize()===0&&te.append(M1()),G1(te),o()}})},I=()=>{i.update(()=>{I1()})},A=me(x=>{i.update(()=>{for(let E=0;E<c.rows;E++)S1(x);o()})},[i,o,c.rows]),b=me(x=>{i.update(()=>{for(let E=0;E<c.columns;E++)L1(x);o()})},[i,o,c.columns]),T=me(()=>{i.update(()=>{k1(),o()})},[i,o]),g=me(()=>{i.update(()=>{Ie(s).remove(),C(),o()})},[i,s,C,o]),w=me(()=>{i.update(()=>{T1(),o()})},[i,o]),M=me(()=>{i.update(()=>{let x=Ie(s),E=N1(s),[S]=xr(x,null,null),L=new Set,y=s.getHeaderStyles()^Ae.ROW;if(S[E])for(let k=0;k<S[E].length;k++){let F=S[E][k];F?.cell&&(L.has(F.cell)||(L.add(F.cell),F.cell.setHeaderStyles(y,Ae.ROW)))}C(),o()})},[i,s,C,o]),D=me(()=>{i.update(()=>{let x=Ie(s),E=E1(s),[S]=xr(x,null,null),L=new Set,y=s.getHeaderStyles()^Ae.COLUMN;if(S)for(let k=0;k<S.length;k++){let F=S?.[k]?.[E];F?.cell&&(L.has(F.cell)||(L.add(F.cell),F.cell.setHeaderStyles(y,Ae.COLUMN)))}C(),o()})},[i,s,C,o]),P=me(()=>{i.update(()=>{if(s.isAttached()){let x=Ie(s);x&&x.setRowStriping(!x.getRowStriping())}C(),o()})},[i,s,C,o]),v=me(()=>{i.update(()=>{if(s.isAttached()){let x=Ie(s);x&&x.setFrozenColumns(x.getFrozenColumns()===0?1:0)}C(),o()})},[i,s,C,o]),N=null;return t&&(a?N=B("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>_(),type:"button",children:B("span",{className:"text",children:"Merge cells"})}):m&&(N=B("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>I(),type:"button",children:B("span",{className:"text",children:"Unmerge cells"})}))),Ss(Se("div",{className:"table-action-menu-dropdown",onClick:x=>{x.stopPropagation()},ref:l,children:[N?Se(kr.Fragment,{children:[N,B("hr",{})]}):null,B("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>P(),type:"button",children:B("span",{className:"text",children:"Toggle Row Striping"})}),B("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>v(),type:"button",children:B("span",{className:"text",children:"Toggle First Column Freeze"})}),B("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>A(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),B("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>A(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>b(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),B("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>b(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>w(),type:"button",children:B("span",{className:"text",children:"Delete column"})}),B("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>T(),type:"button",children:B("span",{className:"text",children:"Delete row"})}),B("button",{className:"item","data-test-id":"table-delete",onClick:()=>g(),type:"button",children:B("span",{className:"text",children:"Delete table"})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-row-header",onClick:()=>M(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&Ae.ROW)===Ae.ROW?"Remove":"Add"," ","row header"]})}),B("button",{className:"item","data-test-id":"table-column-header",onClick:()=>D(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&Ae.COLUMN)===Ae.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function V1({anchorElem:t,cellMerge:e}){let[o]=Ns(),r=uo(null),n=uo(null),[i,l]=rt(!1),[s,u]=rt(null),c=me(()=>{let a=r.current,p=mo(),m=P1(o._window),f=document.activeElement;function h(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),u(null)}if(p==null||a==null)return h();let C=o.getRootElement(),_=null,I=null;if(Tr(p)&&C!==null&&m!==null&&C.contains(m.anchorNode)){let b=ws(p.anchor.getNode());if(b==null||(I=o.getElementByKey(b.getKey()),I==null||!b.isAttached()))return h();let T=Ie(b),g=br(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");_=_r(g),u(b)}else if(vt(p)){let b=ws(p.anchor.getNode());if(!Ls(b))throw new Error("TableSelection anchorNode must be a TableCellNode");let T=Ie(b),g=br(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");_=_r(g),I=o.getElementByKey(b.getKey())}else if(!f)return h();if(_===null||I===null)return h();let A=!_||!_.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",A),a.classList.toggle("table-cell-action-button-container--inactive",!A),A){let b=I.getBoundingClientRect(),T=t.getBoundingClientRect(),g=b.top-T.top,w=b.right-T.left;a.style.transform=`translate(${w}px, ${g}px)`}},[o,t]);ot(()=>{let a,p=()=>{a=void 0,o.getEditorState().read(c)},m=()=>(a===void 0&&(a=setTimeout(p,0)),!1);return R1(o.registerUpdateListener(m),o.registerCommand(H1,m,$1),o.registerRootListener((f,h)=>{h&&h.removeEventListener("pointerup",m),f&&(f.addEventListener("pointerup",m),m())}),()=>clearTimeout(a))});let d=uo(s);return ot(()=>{d.current!==s&&l(!1),d.current=s},[d,s]),B("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&Se(kr.Fragment,{children:[B("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),l(!i)},ref:n,type:"button",children:B(ks,{})}),i&&B(W1,{cellMerge:e,contextRef:n,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Is=t=>{let e=b1(3),{anchorElem:o}=t,r=_1(),n;return e[0]!==o||e[1]!==r?(n=Ss(r?B(V1,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as K1}from"react/compiler-runtime";import{jsx as fo,jsxs as J1}from"react/jsx-runtime";import{useLexicalComposerContext as X1}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as z1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Z1,$getTableNodeFromLexicalNodeOrThrow as wr,$getTableRowIndexFromTableCellNode as Y1,$isTableCellNode as ys,$isTableRowNode as q1,getDOMCellFromTarget as Q1,getTableElement as eh,TableNode as Rs}from"@lexical/table";import{calculateZoomLevel as vs,mergeRegister as th}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Er,isHTMLElement as oh}from"lexical";import*as As from"react";import{useCallback as Mt,useEffect as Nr,useRef as po,useState as nt}from"react";import{createPortal as rh}from"react-dom";var nh=33,Ms=92;function ih({editor:t}){let e=po(null),o=po(null),r=po(null),[n,i]=nt(!1),l=j(),s=po(null),[u,c]=nt(null),[d,a]=nt(null),[p,m]=nt(!1),[f,h]=nt(null),C=Mt(()=>{a(null),e.current=null,h(null),s.current=null,r.current=null},[]),_=v=>(v.buttons&1)===1;Nr(()=>{let v=new Set;return th(t.registerMutationListener(Rs,N=>{for(let[x,E]of N)E==="destroyed"?v.delete(x):v.add(x);i(v.size>0)}),t.registerNodeTransform(Rs,N=>{if(N.getColWidths())return N;let x=N.getColumnCount(),E=Ms;return N.setColWidths(Array(x).fill(E)),N}))},[t]),Nr(()=>{if(!n)return;let v=S=>{let L=S.target;if(oh(L)){if(f){c({x:S.clientX,y:S.clientY});return}if(m(_(S)),!(o.current&&o.current.contains(L))&&e.current!==L){e.current=L;let y=Q1(L);y&&d!==y?t.getEditorState().read(()=>{let k=Er(y.elem);if(!k)throw new Error("TableCellResizer: Table cell node not found.");let F=wr(k),$=eh(F,t.getElementByKey(F.getKey()));if(!$)throw new Error("TableCellResizer: Table element not found.");e.current=L,r.current=$.getBoundingClientRect(),a(y)},{editor:t}):y==null&&C()}}},N=S=>{m(!0)},x=S=>{m(!1)},E=t.registerRootListener((S,L)=>{L?.removeEventListener("mousemove",v),L?.removeEventListener("mousedown",N),L?.removeEventListener("mouseup",x),S?.addEventListener("mousemove",v),S?.addEventListener("mousedown",N),S?.addEventListener("mouseup",x)});return()=>{E()}},[d,f,t,n,C]);let I=v=>v==="bottom",A=Mt(v=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=Er(d.elem);if(!ys(N))throw new Error("TableCellResizer: Table cell node not found.");let x=wr(N),E=Y1(N),S=x.getChildren(),y=N.getColSpan()===x.getColumnCount()?E:E+N.getRowSpan()-1;if(y>=S.length||y<0)throw new Error("Expected table cell to be inside of table row.");let k=S[y];if(!q1(k))throw new Error("Expected table row");let F=k.getHeight();if(F===void 0){let U=k.getChildren();F=Math.min(...U.map(V=>b(V,t)??1/0))}let $=Math.max(F+v,nh);k.setHeight($)},{tag:"skip-scroll-into-view"})},[d,t]),b=(v,N)=>N.getElementByKey(v.getKey())?.clientHeight,T=(v,N)=>{let x;return N.forEach(E=>{E.forEach((S,L)=>{S.cell===v&&(x=L)})}),x},g=Mt(v=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=Er(d.elem);if(!ys(N))throw new Error("TableCellResizer: Table cell node not found.");let x=wr(N),[E]=Z1(x,null,null),S=T(N,E);if(S===void 0)throw new Error("TableCellResizer: Table column not found.");let L=x.getColWidths();if(!L)return;let y=L[S];if(y===void 0)return;let k=[...L],F=Math.max(y+v,Ms);k[S]=F,x.setColWidths(k)},{tag:"skip-scroll-into-view"})},[d,t]),w=Mt(v=>{let N=x=>{if(x.preventDefault(),x.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");if(s.current){let{x:E,y:S}=s.current;if(d===null)return;let L=vs(x.target);if(I(v)){let y=(x.clientY-S)/L;A(y)}else{let y=(x.clientX-E)/L;g(y)}C(),document.removeEventListener("mouseup",N)}};return N},[d,C,g,A]),M=Mt(v=>N=>{if(N.preventDefault(),N.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");s.current={x:N.clientX,y:N.clientY},c(s.current),h(v),document.addEventListener("mouseup",w(v))},[d,w]),[D,P]=nt({bottom:null,left:null,right:null,top:null});return Nr(()=>{if(d){let{height:v,left:N,top:x,width:E}=d.elem.getBoundingClientRect(),S=vs(d.elem),L=10,y={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${L}px`,left:`${window.scrollX+N}px`,top:`${window.scrollY+x+v-L/2}px`,width:`${E}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${v}px`,left:`${window.scrollX+N+E-L/2}px`,top:`${window.scrollY+x}px`,width:`${L}px`}},k=r.current;f&&u&&k&&(I(f)?(y[f].left=`${window.scrollX+k.left}px`,y[f].top=`${window.scrollY+u.y/S}px`,y[f].height="3px",y[f].width=`${k.width}px`):(y[f].top=`${window.scrollY+k.top}px`,y[f].left=`${window.scrollX+u.x/S}px`,y[f].width="3px",y[f].height=`${k.height}px`),y[f].backgroundColor="#adf"),P(y)}else P({bottom:null,left:null,right:null,top:null})},[d,f,u]),fo("div",{ref:o,children:d!=null&&!p&&J1(As.Fragment,{children:[fo("div",{className:`${l.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:M("right"),style:D.right||void 0}),fo("div",{className:`${l.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:M("bottom"),style:D.bottom||void 0})]})})}var Ds=()=>{let t=K1(3),[e]=X1(),o=z1(),r,n;return t[0]!==e||t[1]!==o?(n=o?rh(fo(ih,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=n):n=t[2],r=n,r};import{c as ph}from"react/compiler-runtime";import{jsx as Lr,jsxs as fh,Fragment as hh}from"react/jsx-runtime";import{useLexicalComposerContext as Us}from"@lexical/react/LexicalComposerContext";import{$getTableAndElementByKey as gh,$getTableColumnIndexFromTableCellNode as Ch,$getTableRowIndexFromTableCellNode as xh,$insertTableColumn__EXPERIMENTAL as bh,$insertTableRow__EXPERIMENTAL as _h,$isTableCellNode as Th,$isTableNode as $s,getTableElement as kh,TableNode as wh}from"@lexical/table";import{$findMatchingParent as Eh,mergeRegister as Nh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Ps,isHTMLElement as Lh}from"lexical";import{useEffect as Bs,useMemo as Sh,useRef as Hs,useState as ho}from"react";import"react";import{createPortal as Ih}from"react-dom";import{c as uh}from"react/compiler-runtime";import{useEffect as dh,useRef as mh}from"react";var lh="Expected a function",sh=Math.max,ah=Math.min;function ch(t,e,o){let r,n,i=0,l,s=!1,u=!1,c,d,a,p=!0;if(typeof t!="function")throw new TypeError(lh);e=e||0,typeof o=="object"&&(s=!!o.leading,u="maxWait"in o,c=u?sh(o.maxWait||0,e):c,p="trailing"in o?!!o.trailing:p);function m(g){let w=r,M=l;return r=l=void 0,i=g,d=t.apply(M,w),d}function f(g){return i=g,a=setTimeout(_,e),s?m(g):d}function h(g){let w=g-n,M=g-i,D=e-w;return u?ah(D,c-M):D}function C(g){let w=g-n,M=g-i;return n===void 0||w>=e||w<0||u&&M>=c}function _(){let g=Date.now();if(C(g))return I(g);a=setTimeout(_,h(g))}function I(g){return a=void 0,p&&r?m(g):(r=l=void 0,d)}function A(){a!==void 0&&clearTimeout(a),i=0,r=n=l=a=void 0}function b(){return a===void 0?d:I(Date.now())}function T(){let g=Date.now(),w=C(g);if(r=arguments,l=this,n=g,w){if(a===void 0)return f(n);if(u)return clearTimeout(a),a=setTimeout(_,e),m(n)}return a===void 0&&(a=setTimeout(_,e)),d}return T.cancel=A,T.flush=b,T}var Os=ch;function Fs(t,e,o){let r=uh(6),n=mh(null),i,l;r[0]!==t||r[1]!==o||r[2]!==e?(i=()=>(n.current=Os(t,e,{maxWait:o}),()=>{n.current?.cancel()}),l=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=i,r[4]=l):(i=r[3],l=r[4]),dh(i,l);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...c)=>{let d=c;n.current&&n.current(...d)},r[5]=s):s=r[5],s}var js=20;function yh({anchorElem:t}){let[e]=Us(),o=j(),[r,n]=ho(!1),[i,l]=ho(!1),[s,u]=ho(!1),[c,d]=ho({}),a=Hs(new Set),p=Hs(null),m=Fs(C=>{let{isOutside:_,tableDOMNode:I}=Rh(C,o.editorConfig?.lexical);if(_){n(!1),l(!1);return}if(!I)return;p.current=I;let A=null,b=null,T=null;if(e.getEditorState().read(()=>{let L=Ps(I);if(Th(L)){let y=Eh(L,k=>$s(k));if(!$s(y))return;if(T=kh(y,e.getElementByKey(y.getKey())),T){let k=y.getChildrenSize(),F=y.getChildAtIndex(0)?.getChildrenSize(),$=xh(L),U=Ch(L);$===k-1?A=L:U===F-1&&(b=L)}}},{editor:e}),!T)return;let g=T.parentElement;if(!g)return;let{bottom:w,height:M,left:D,right:P,width:v,y:N}=T.getBoundingClientRect(),x=!1;g&&g.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(x=g.scrollWidth>g.clientWidth);let{left:E,y:S}=t.getBoundingClientRect();A?(l(!1),n(!0),d({height:js,left:x&&g?g.offsetLeft:D-E,top:w-S+5,width:x&&g?g.offsetWidth:v})):b&&(l(!0),n(!1),d({height:M,left:P-E+5,top:N-S,width:js}))},50,250),f=Sh(()=>new ResizeObserver(()=>{n(!1),l(!1)}),[]);Bs(()=>{if(s)return document.addEventListener("mousemove",m),()=>{n(!1),l(!1),document.removeEventListener("mousemove",m)}},[s,m]),Bs(()=>Nh(e.registerMutationListener(wh,C=>{e.getEditorState().read(()=>{let _=!1;for(let[I,A]of C)switch(A){case"created":{a.current.add(I),_=!0;break}case"destroyed":{a.current.delete(I),_=!0;break}default:break}if(_){f.disconnect();for(let I of a.current){let{tableElement:A}=gh(I);f.observe(A)}u(a.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let h=C=>{e.update(()=>{p.current&&(Ps(p.current)?.selectEnd(),C?(_h(),n(!1)):(bh(),l(!1)))})};return e?.isEditable()?fh(hh,{children:[r&&Lr("button",{"aria-label":"Add Row",className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...c},type:"button"}),i&&Lr("button",{"aria-label":"Add Column",className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...c},type:"button"})]}):null}function Rh(t,e){let o=t.target;if(Lh(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function Gs(t){let e=ph(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=Us();if(!n?.isEditable())return null;let i;return e[0]!==r?(i=Ih(Lr(yh,{anchorElem:r}),r),e[0]=r,e[1]=i):i=e[1],i}import{c as vh}from"react/compiler-runtime";import{jsx as Sr,jsxs as Mh}from"react/jsx-runtime";import{useLexicalComposerContext as Ah}from"@lexical/react/LexicalComposerContext";import{TablePlugin as Dh}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Oh,TableCellNode as Fh,TableNode as $h,TableRowNode as Ph}from"@lexical/table";import{mergeRegister as Bh}from"@lexical/utils";import{formatDrawerSlug as Hh,useEditDepth as jh}from"@payloadcms/ui";import{$getSelection as Uh,$isRangeSelection as Gh,COMMAND_PRIORITY_EDITOR as Wh,createCommand as Vh}from"lexical";import{createContext as Kh,use as Jh,useEffect as Xh,useMemo as zh,useState as Zh}from"react";import*as Ws from"react";var go=Vh("OPEN_EMBED_DRAWER_COMMAND"),Vs=Kh({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function Ks({children:t}){let[e,o]=Zh({cellEditorConfig:null,cellEditorPlugins:null});return Sr(Vs,{value:zh(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Js=()=>{let t=vh(16),[e]=Ah(),o=Jh(Vs),r=jh(),{fieldProps:n,uuid:i}=j(),{schemaPath:l}=n,s="lexical-table-create-"+i,u;t[0]!==r||t[1]!==s?(u=Hh({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=u):u=t[2];let c=u,{toggleDrawer:d}=Ce(c,!0),a;t[3]!==e||t[4]!==d?(a=()=>{if(!e.hasNodes([$h,Ph,Fh]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return Bh(e.registerCommand(go,()=>{let h;return h=null,e.getEditorState().read(()=>{let C=Uh();Gh(C)&&(h=C)}),h&&d(),!0},Wh))},t[3]=e,t[4]=d,t[5]=a):a=t[5];let p;t[6]!==o||t[7]!==e||t[8]!==d?(p=[o,e,d],t[6]=o,t[7]=e,t[8]=d,t[9]=p):p=t[9],Xh(a,p);let m;t[10]!==e?(m=(h,C)=>{!C.columns||!C.rows||e.dispatchCommand(Oh,{columns:String(C.columns),rows:String(C.rows)})},t[10]=e,t[11]=m):m=t[11];let f;return t[12]!==c||t[13]!==l||t[14]!==m?(f=Mh(Ws.Fragment,{children:[Sr(lt,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:m,schemaPath:l,schemaPathSuffix:"fields"}),Sr(Dh,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=l,t[14]=m,t[15]=f):f=t[15],f};var eg=R({markdownTransformers:[_s],nodes:[qh,Yh,Qh],plugins:[{Component:Js,position:"normal"},{Component:Ds,position:"normal"},{Component:Is,position:"floatingAnchorElem"},{Component:Gs,position:"floatingAnchorElem"}],providers:[Ks],slashMenu:{groups:[Q([{Icon:fr,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(go,{})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:fr,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(go,{})}}])]}});import{$isNodeSelection as vg}from"lexical";import{jsx as Ir,jsxs as tg}from"react/jsx-runtime";import"react";var yr=()=>tg("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ir("path",{d:"M14.6667 4H5.33333C4.59695 4 4 4.59695 4 5.33333V14.6667C4 15.403 4.59695 16 5.33333 16H14.6667C15.403 16 16 15.403 16 14.6667V5.33333C16 4.59695 15.403 4 14.6667 4Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),Ir("path",{d:"M7.99984 9.33366C8.73622 9.33366 9.33317 8.73671 9.33317 8.00033C9.33317 7.26395 8.73622 6.66699 7.99984 6.66699C7.26346 6.66699 6.6665 7.26395 6.6665 8.00033C6.6665 8.73671 7.26346 9.33366 7.99984 9.33366Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),Ir("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as lg}from"react/jsx-runtime";import Zs from"bson-objectid";import{$applyNodeReplacement as sg}from"lexical";import*as Ys from"react";import{jsx as og}from"react/jsx-runtime";import{DecoratorBlockNode as rg}from"@lexical/react/LexicalDecoratorBlockNode.js";import Xs from"bson-objectid";import{$applyNodeReplacement as ng}from"lexical";import"react";function Rr(t){return t.parentElement!=null&&t.parentElement.tagName==="LI"&&t.previousSibling===null&&t.getAttribute("aria-roledescription")==="checkbox"}function ig(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:zs({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||Rr(e),null}var At=class extends rg{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:ig,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Xs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=zs({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return og(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let e=document.createElement("img");return e.setAttribute("data-lexical-upload-id",String(this.__data?.value)),e.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function zs({data:t}){return t?.id||(t.id=new Xs.default().toHexString()),ng(new At({data:t}))}var ag=Ys.lazy(()=>import("./component-NNKG7K3O.js").then(t=>({default:t.UploadComponent})));function cg(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:Ge({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||Rr(e),null}var ye=class extends At{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:cg,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Zs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=Ge({data:o});return r.setFormat(e.format),r}decorate(){return lg(ag,{data:this.__data,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ge({data:t}){return t?.id||(t.id=new Zs.default().toHexString()),sg(new ye({data:t}))}function vr(t){return t instanceof ye}import{c as Cg}from"react/compiler-runtime";import{jsx as xg}from"react/jsx-runtime";import{useLexicalComposerContext as bg}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as _g,mergeRegister as Tg}from"@lexical/utils";import{useConfig as kg}from"@payloadcms/ui";import{$getPreviousSelection as wg,$getSelection as Eg,$isParagraphNode as Ng,$isRangeSelection as Lg,COMMAND_PRIORITY_EDITOR as Sg,createCommand as Ig}from"lexical";import{useEffect as yg}from"react";import{c as qs}from"react/compiler-runtime";import{jsx as Mr}from"react/jsx-runtime";import{useLexicalComposerContext as Qs}from"@lexical/react/LexicalComposerContext.js";import{toast as ug}from"@payloadcms/ui";import{$getNodeByKey as dg,COMMAND_PRIORITY_EDITOR as ea}from"lexical";import{useEffect as ta,useState as mg}from"react";var pg=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=dg(o);n&&n.replace(Ge({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Ar,{fields:null,relationTo:e,value:r})},fg=t=>{let e=qs(13),{enabledCollectionSlugs:o}=t,[r]=Qs(),[n,i]=mg(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let{closeListDrawer:s,ListDrawer:u,openListDrawer:c}=St(l),d,a;e[2]!==r||e[3]!==c?(d=()=>r.registerCommand(Ve,h=>(i(h?.replace?h?.replace.nodeKey:null),c(),!0),ea),a=[r,c],e[2]=r,e[3]=c,e[4]=d,e[5]=a):(d=e[4],a=e[5]),ta(d,a);let p;e[6]!==s||e[7]!==r||e[8]!==n?(p=h=>{let{collectionSlug:C,doc:_}=h;s(),pg({editor:r,relationTo:C,replaceNodeKey:n,value:_.id})},e[6]=s,e[7]=r,e[8]=n,e[9]=p):p=e[9];let m=p,f;return e[10]!==u||e[11]!==m?(f=Mr(u,{onSelect:m}),e[10]=u,e[11]=m,e[12]=f):f=e[12],f},hg=()=>{let t=qs(3),[e]=Qs(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Ve,gg,ea),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ta(o,r),null},oa=t=>Mr(Ot,{...t,FallbackComponent:hg,uploads:!0,children:Mr(fg,{...t})});function gg(){return ug.error("No upload collections enabled"),!0}var Ar=Ig("INSERT_UPLOAD_COMMAND"),ra=t=>{let e=Cg(5),[o]=bg(),{config:r}=kg(),{collections:n}=r,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([ye]))throw new Error("UploadPlugin: UploadNode not registered on editor");return Tg(o.registerCommand(Ar,u=>(o.update(()=>{let c=Eg()||wg();if(Lg(c)){let d=Ge({data:{id:u.id,fields:u.fields,relationTo:u.relationTo,value:u.value}}),{focus:a}=c,p=a.getNode();_g(d),Ng(p)&&!p.__first&&p.remove()}}),!0),Sg))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),yg(i,l);let s;return e[3]!==n?(s=xg(oa,{enabledCollectionSlugs:n.map(Rg)}),e[3]=n,e[4]=s):s=e[4],s};function Rg(t){let{slug:e}=t;return e}var Mg=R({nodes:[ye],plugins:[{Component:ra,position:"normal"}],slashMenu:{groups:[Q([{Icon:yr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:yr,isActive:({selection:t})=>{if(!vg(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return vr(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]}});import{c as Dg}from"react/compiler-runtime";import{jsx as Or}from"react/jsx-runtime";import{ShimmerEffect as Og,useConfig as Fg}from"@payloadcms/ui";import{lazy as $g,Suspense as Pg,useEffect as Bg,useState as Hg}from"react";var na={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",hrSelected:"LexicalEditorTheme__hrSelected",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var Co={namespace:"lexical",theme:na};function ia({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:i}){for(let c of i.features)if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");i.features=i.features.sort((c,d)=>c.clientFeatureProps.order-d.clientFeatureProps.order);let l=new Map;for(let c of i.features)l.set(c.clientFeatureProps.featureKey,c);let s=new Map,u=0;for(let c of i.features){let d=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:l,field:r,resolvedFeatures:s,schemaPath:n,unSanitizedEditorConfig:i}):c.feature;d.key=c.clientFeatureProps.featureKey,d.order=u,s.set(c.clientFeatureProps.featureKey,d),u++}return s}import{deepMerge as Ag}from"payload/shared";var la=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}},o={};if(t.forEach(r=>{r.key==="toolbarFixed"&&r.sanitizedClientFeatureProps?.customGroups&&(o={...o,...r.sanitizedClientFeatureProps.customGroups})}),!t?.size)return e;t.forEach(r=>{if(r.providers?.length&&(e.providers=e.providers.concat(r.providers)),r.enableFormats?.length&&e.enabledFormats.push(...r.enableFormats),r.nodes?.length)for(let n of r.nodes)e.nodes.push(n);if(r.plugins?.length&&r.plugins.forEach((n,i)=>{e.plugins?.push({clientProps:r.sanitizedClientFeatureProps,Component:n.Component,key:r.key+i,position:n.position})}),r.toolbarInline?.groups?.length)for(let n of r.toolbarInline.groups){let i=e.toolbarInline.groups.find(l=>l.key===n.key);i?e.toolbarInline.groups=e.toolbarInline.groups.filter(l=>l.key!==n.key):i={...n,items:[]},n?.items?.length&&(i.items=i.items.concat(n.items)),e.toolbarInline?.groups.push(i)}if(r.toolbarFixed?.groups?.length)for(let n of r.toolbarFixed.groups){let i=e.toolbarFixed.groups.find(l=>l.key===n.key);i?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(l=>l.key!==n.key):i={...n,items:[]},n?.items?.length&&(i.items=i.items.concat(n.items)),e.toolbarFixed?.groups.push(i)}if(r.slashMenu?.groups){r.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(r.slashMenu.dynamicGroups));for(let n of r.slashMenu.groups){let i=e.slashMenu.groups.find(l=>l.key===n.key);i?e.slashMenu.groups=e.slashMenu.groups.filter(l=>l.key!==n.key):i={...n,items:[]},n?.items?.length&&(i.items=i.items.concat(n.items)),e.slashMenu.groups.push(i)}}if(r.markdownTransformers?.length)for(let n of r.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(r.key)}),Object.keys(o).length>0&&(e.toolbarFixed.groups=e.toolbarFixed.groups.map(r=>{let n=o[r.key];return n?Ag(r,n):r})),e.toolbarInline.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let r of e.toolbarInline.groups)r.items.sort((n,i)=>n.order&&i.order?n.order-i.order:n.order?-1:i.order?1:0);for(let r of e.toolbarFixed.groups)r.items.sort((n,i)=>n.order&&i.order?n.order-i.order:n.order?-1:i.order?1:0);return e};function Dr(t,e,o){return{admin:o,features:la(t),lexical:e,resolvedFeatureMap:t}}var jg=$g(()=>import("./Field-PWFMMJ4H.js").then(t=>({default:t.RichText}))),Ug=t=>{let e=Dg(16),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:i,field:l,lexicalEditorConfig:s,schemaPath:u}=t,c;e[0]!==o?(c=o===void 0?{}:o,e[0]=o,e[1]=c):c=e[1];let d=c,a=s===void 0?Co:s,{config:p}=Fg(),[m,f]=Hg(null),h,C;e[2]!==d||e[3]!==r||e[4]!==p||e[5]!==n||e[6]!==i||e[7]!==l||e[8]!==m||e[9]!==a||e[10]!==u?(h=()=>{if(m)return;let I=[];for(let[T,g]of Object.entries(r))g.clientFeatureProvider&&I.push(g.clientFeatureProvider(g.clientFeatureProps));let A=a||Co,b=ia({config:p,featureClientImportMap:n,featureClientSchemaMap:i,field:l,schemaPath:u??l.name,unSanitizedEditorConfig:{features:I,lexical:A}});f(Dr(b,A,d))},C=[a,d,m,r,n,i,l,p,u],e[2]=d,e[3]=r,e[4]=p,e[5]=n,e[6]=i,e[7]=l,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=C):(h=e[11],C=e[12]),Bg(h,C);let _;return e[13]!==m||e[14]!==t?(_=Or(Pg,{fallback:Or(Og,{height:"35vh"}),children:m&&Or(jg,{...t,editorConfig:m})}),e[13]=m,e[14]=t,e[15]=_):_=e[15],_};function Gg(t){return t instanceof HTMLElement}function Wg(...t){return t.filter(Boolean).join(" ")}var xo=new WeakMap;function sa(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function bo(t,e){let o=xo.get(t);if(o===void 0){let r=new Set,n=l=>{o!==void 0&&(o.start=sa(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let u=sa(l);for(let c of r)u!==null&&c([u[0]-s[0],u[1]-s[1]],l)};t.addEventListener("touchstart",n),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:n,listeners:r,start:null},xo.set(t,o)}return o.listeners.add(e),()=>{Vg(t,e)}}function Vg(t,e){let o=xo.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(xo.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function Kg(t,e){return bo(t,(o,r)=>{let[n,i]=o;n<0&&-n>Math.abs(i)&&e(n,r)})}function Jg(t,e){return bo(t,(o,r)=>{let[n,i]=o;n>0&&n>Math.abs(i)&&e(n,r)})}function Xg(t,e){return bo(t,(o,r)=>{let[n,i]=o;i<0&&-i>Math.abs(n)&&e(n,r)})}function zg(t,e){return bo(t,(o,r)=>{let[n,i]=o;i>0&&i>Math.abs(n)&&e(n,r)})}import{c as Zg}from"react/compiler-runtime";import{jsx as Yg}from"react/jsx-runtime";import"react";var qg=()=>{let t=Zg(2),{EditButton:e}=xe(),o;return t[0]!==e?(o=e?Yg(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Qg}from"react/compiler-runtime";import{jsx as eC}from"react/jsx-runtime";import"react";var tC=()=>{let t=Qg(2),{RemoveButton:e}=xe(),o;return t[0]!==e?(o=e?eC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as oC}from"react/compiler-runtime";import{jsx as rC}from"react/jsx-runtime";import"react";var nC=()=>{let t=oC(2),{Label:e}=xe(),o;return t[0]!==e?(o=e?rC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as iC}from"react/compiler-runtime";import{jsx as lC}from"react/jsx-runtime";import"react";var sC=t=>{let e=iC(3),{children:o}=t,{InlineBlockContainer:r}=xe(),n;return e[0]!==r||e[1]!==o?(n=r?lC(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as aC}from"react/compiler-runtime";import{jsx as cC}from"react/jsx-runtime";import"react";var uC=t=>{let e=aC(6),{children:o,editButton:r,Label:n,removeButton:i}=t,{BlockCollapsible:l}=Oe(),s;return e[0]!==l||e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==i?(s=l?cC(l,{editButton:r,Label:n,removeButton:i,children:o}):null,e[0]=l,e[1]=n,e[2]=o,e[3]=r,e[4]=i,e[5]=s):s=e[5],s};import{c as dC}from"react/compiler-runtime";import{jsx as mC}from"react/jsx-runtime";import"react";var pC=()=>{let t=dC(2),{EditButton:e}=Oe(),o;return t[0]!==e?(o=e?mC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as fC}from"react/compiler-runtime";import{jsx as hC}from"react/jsx-runtime";import"react";var gC=()=>{let t=fC(2),{RemoveButton:e}=Oe(),o;return t[0]!==e?(o=e?hC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as CC}from"qs-esm";var xC=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:i,collectionSlug:l,select:s})=>{let u=CC({depth:e??0,draft:o??!1,locale:r,select:s},{addQueryPrefix:!0});return await fetch(`${t}/${l}/${i}${u}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(d=>d.json())};export{Ct as $createAutoLinkNode,Vt as $createBlockNode,To as $createInlineBlockNode,Te as $createLinkNode,je as $createRelationshipNode,Ge as $createUploadNode,we as $isAutoLinkNode,pt as $isBlockNode,ko as $isInlineBlockNode,Z as $isLinkNode,ir as $isRelationshipNode,vr as $isUploadNode,_a as AlignFeatureClient,ke as AutoLinkNode,uC as BlockCollapsible,pC as BlockEditButton,be as BlockNode,gC as BlockRemoveButton,Na as BlockquoteFeatureClient,kc as BlocksFeatureClient,Vc as BoldFeatureClient,ae as CAN_USE_DOM,Dm as ChecklistFeatureClient,Ep as DETAIL_TYPE_TO_DETAIL,_p as DOUBLE_LINE_BREAK,Fp as DebugJsxConverterFeatureClient,Lp as ELEMENT_FORMAT_TO_TYPE,Np as ELEMENT_TYPE_TO_FORMAT,pa as ENABLE_SLASH_MENU_COMMAND,ca as EditorConfigProvider,lt as FieldsDrawer,Zf as FixedToolbarFeatureClient,Su as HeadingFeatureClient,Wu as HorizontalRuleFeatureClient,Ke as INSERT_BLOCK_COMMAND,Je as INSERT_INLINE_BLOCK_COMMAND,xp as IS_ALL_FORMATTING,ld as IndentFeatureClient,sC as InlineBlockContainer,qg as InlineBlockEditButton,nC as InlineBlockLabel,_o as InlineBlockNode,tC as InlineBlockRemoveButton,Zc as InlineCodeFeatureClient,s1 as InlineToolbarFeatureClient,eu as ItalicFeatureClient,kp as LTR_REGEX,op as LexicalPluginToLexicalFeatureClient,bm as LinkFeatureClient,ie as LinkNode,bp as NON_BREAKING_SPACE,O as NodeFormat,Um as OrderedListFeatureClient,up as ParagraphFeatureClient,da as Point,Tp as RTL_REGEX,fa as Rect,kf as RelationshipFeatureClient,Ne as RelationshipNode,Ug as RichTextField,ap as SlateToLexicalFeatureClient,iu as StrikethroughFeatureClient,cu as SubscriptFeatureClient,pu as SuperscriptFeatureClient,Sp as TEXT_MODE_TO_TYPE,wp as TEXT_TYPE_TO_FORMAT,Ip as TEXT_TYPE_TO_MODE,he as TOGGLE_LINK_COMMAND,eg as TableFeatureClient,Fc as TestRecorderFeatureClient,It as ToolbarButton,Ue as ToolbarDropdown,jc as TreeViewFeatureClient,xu as UnderlineFeatureClient,Zm as UnorderedListFeatureClient,Mg as UploadFeatureClient,ye as UploadNode,zg as addSwipeDownListener,Kg as addSwipeLeftListener,Jg as addSwipeRightListener,Xg as addSwipeUpListener,$o as createBlockNode,R as createClientFeature,Co as defaultEditorLexicalConfig,pr as getDOMRangeRect,ha as getEnabledNodes,xC as getRestPopulateFn,Xe as getSelectedNode,Gg as isHTMLElement,ma as isPoint,Wg as joinClasses,Dr as sanitizeClientEditorConfig,la as sanitizeClientFeatures,lo as setFloatingElemPosition,Qt as setFloatingElemPositionForLinkEditor,Q as slashMenuBasicGroupWithItems,_e as toolbarAddDropdownGroupWithItems,Bo as toolbarFeatureButtonsGroupWithItems,ee as toolbarFormatGroupWithItems,ne as toolbarTextDropdownGroupWithItems,Oe as useBlockComponentContext,j as useEditorConfigContext,xe as useInlineBlockComponentContext,ua as useLexicalDocumentDrawer,Ce as useLexicalDrawer,St as useLexicalListDrawer};
|
|
40
|
+
`);let o=a1(co.NO_STATUS);return Pr(t,e,o),o},xs=(t,e)=>{let o=t.match(bs);return!o||!o[1]?null:o[1].split("|").map(r=>Ts(r,e))};import{c as b1}from"react/compiler-runtime";import{jsx as B,jsxs as Se}from"react/jsx-runtime";import{useLexicalComposerContext as Ns}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as _1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as xr,$deleteTableColumn__EXPERIMENTAL as T1,$deleteTableRow__EXPERIMENTAL as k1,$getNodeTriplet as w1,$getTableCellNodeFromLexicalNode as ws,$getTableColumnIndexFromTableCellNode as E1,$getTableNodeFromLexicalNodeOrThrow as Ie,$getTableRowIndexFromTableCellNode as N1,$insertTableColumn__EXPERIMENTAL as L1,$insertTableRow__EXPERIMENTAL as S1,$isTableCellNode as Ls,$isTableSelection as vt,$unmergeCell as I1,getTableElement as br,getTableObserverFromTableElement as _r,TableCellHeaderStates as Ae,TableCellNode as y1}from"@lexical/table";import{mergeRegister as R1}from"@lexical/utils";import{useScrollInfo as v1}from"@payloadcms/ui";import{$createParagraphNode as M1,$getSelection as mo,$isElementNode as A1,$isParagraphNode as D1,$isRangeSelection as Tr,$isTextNode as O1,$setSelection as F1,COMMAND_PRIORITY_CRITICAL as $1,getDOMSelection as P1,isDOMNode as B1,SELECTION_CHANGE_COMMAND as H1}from"lexical";import*as kr from"react";import{useCallback as me,useEffect as ot,useRef as uo,useState as rt}from"react";import{createPortal as Ss}from"react-dom";import{jsx as Cr,jsxs as x1}from"react/jsx-runtime";import"react";var ks=()=>x1("svg",{fill:"none",height:"18",viewBox:"0 0 20 20",width:"18",xmlns:"http://www.w3.org/2000/svg",children:[Cr("path",{d:"M5 11C5.55228 11 6 10.5523 6 10C6 9.44772 5.55228 9 5 9C4.44772 9 4 9.44772 4 10C4 10.5523 4.44772 11 5 11Z",fill:"currentColor"}),Cr("path",{d:"M10 11C10.5523 11 11 10.5523 11 10C11 9.44772 10.5523 9 10 9C9.44772 9 9 9.44772 9 10C9 10.5523 9.44772 11 10 11Z",fill:"currentColor"}),Cr("path",{d:"M15 11C15.5523 11 16 10.5523 16 10C16 9.44772 15.5523 9 15 9C14.4477 9 14 9.44772 14 10C14 10.5523 14.4477 11 15 11Z",fill:"currentColor"})]});function Es(t){let e=t.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function j1(){let t=mo();if(Tr(t)&&!t.isCollapsed()||vt(t)&&!t.anchor.is(t.focus)||!Tr(t)&&!vt(t))return!1;let[e]=w1(t.anchor);return e.__colSpan>1||e.__rowSpan>1}function U1(t){if(t.getChildrenSize()!==1)return!1;let e=t.getFirstChildOrThrow();return!(!D1(e)||!e.isEmpty())}function G1(t){let e=t.getLastDescendant();O1(e)?e.select():A1(e)?e.selectEnd():e!==null&&e.selectNext()}function W1({cellMerge:t,contextRef:e,onClose:o,setIsMenuOpen:r,tableCellNode:n}){let[i]=Ns(),l=uo(null),[s,u]=rt(n),[c,d]=rt({columns:1,rows:1}),[a,p]=rt(!1),[m,f]=rt(!1),{y:h}=v1();ot(()=>i.registerMutationListener(y1,x=>{x.get(s.getKey())==="updated"&&i.getEditorState().read(()=>{u(s.getLatest())})},{skipInitialization:!0}),[i,s]),ot(()=>{i.getEditorState().read(()=>{let x=mo();if(vt(x)){let E=Es(x);d(Es(x)),p(E.columns>1||E.rows>1)}f(j1())})},[i]),ot(()=>{let x=e.current,E=l.current,S=i.getRootElement();if(x!=null&&E!=null&&S!=null){let L=S.getBoundingClientRect(),y=x.getBoundingClientRect();E.style.opacity="1";let k=E.getBoundingClientRect(),F=5,$=y.right+F;if($+k.width>window.innerWidth||$+k.width>L.right){let V=y.left-k.width-F;$=(V<0?F:V)+window.pageXOffset}E.style.left=`${$+window.pageXOffset}px`;let U=y.top;if(U+k.height>window.innerHeight){let V=y.bottom-k.height;U=V<0?F:V}E.style.top=`${U}px`}},[e,l,i,h]),ot(()=>{function x(E){l.current!=null&&e.current!=null&&B1(E.target)&&!l.current.contains(E.target)&&!e.current.contains(E.target)&&r(!1)}return window.addEventListener("click",x),()=>window.removeEventListener("click",x)},[r,e]);let C=me(()=>{i.update(()=>{if(s.isAttached()){let x=Ie(s),E=br(x,i.getElementByKey(x.getKey()));if(E===null)throw new Error("Expected to find tableElement in DOM");let S=_r(E);S!==null&&S.$clearHighlight(),x.markDirty(),u(s.getLatest())}F1(null)})},[i,s]),_=()=>{i.update(()=>{let x=mo();if(vt(x)){let S=x.getNodes().filter(Ls);if(S.length===0)return;let L=Ie(S[0]),[y]=xr(L,null,null),k=1/0,F=-1/0,$=1/0,U=-1/0,V=new Set;for(let Y of y)for(let K of Y){if(!K||!K.cell)continue;let oe=K.cell.getKey();if(!V.has(oe)&&S.some(re=>re.is(K.cell))){V.add(oe);let re=K.startRow,le=K.startColumn,De=K.cell.__rowSpan||1,it=K.cell.__colSpan||1;k=Math.min(k,re),F=Math.max(F,re+De-1),$=Math.min($,le),U=Math.max(U,le+it-1)}}if(k===1/0||$===1/0)return;let pe=F-k+1,H=U-$+1,W=y?.[k]?.[$];if(!W?.cell)return;let te=W.cell;te.setColSpan(H),te.setRowSpan(pe);let ce=new Set([te.getKey()]);for(let Y=k;Y<=F;Y++)for(let K=$;K<=U;K++){let oe=y?.[Y]?.[K];if(!oe?.cell)continue;let re=oe.cell,le=re.getKey();ce.has(le)||(ce.add(le),U1(re)||te.append(...re.getChildren()),re.remove())}te.getChildrenSize()===0&&te.append(M1()),G1(te),o()}})},I=()=>{i.update(()=>{I1()})},A=me(x=>{i.update(()=>{for(let E=0;E<c.rows;E++)S1(x);o()})},[i,o,c.rows]),b=me(x=>{i.update(()=>{for(let E=0;E<c.columns;E++)L1(x);o()})},[i,o,c.columns]),T=me(()=>{i.update(()=>{k1(),o()})},[i,o]),g=me(()=>{i.update(()=>{Ie(s).remove(),C(),o()})},[i,s,C,o]),w=me(()=>{i.update(()=>{T1(),o()})},[i,o]),M=me(()=>{i.update(()=>{let x=Ie(s),E=N1(s),[S]=xr(x,null,null),L=new Set,y=s.getHeaderStyles()^Ae.ROW;if(S[E])for(let k=0;k<S[E].length;k++){let F=S[E][k];F?.cell&&(L.has(F.cell)||(L.add(F.cell),F.cell.setHeaderStyles(y,Ae.ROW)))}C(),o()})},[i,s,C,o]),D=me(()=>{i.update(()=>{let x=Ie(s),E=E1(s),[S]=xr(x,null,null),L=new Set,y=s.getHeaderStyles()^Ae.COLUMN;if(S)for(let k=0;k<S.length;k++){let F=S?.[k]?.[E];F?.cell&&(L.has(F.cell)||(L.add(F.cell),F.cell.setHeaderStyles(y,Ae.COLUMN)))}C(),o()})},[i,s,C,o]),P=me(()=>{i.update(()=>{if(s.isAttached()){let x=Ie(s);x&&x.setRowStriping(!x.getRowStriping())}C(),o()})},[i,s,C,o]),v=me(()=>{i.update(()=>{if(s.isAttached()){let x=Ie(s);x&&x.setFrozenColumns(x.getFrozenColumns()===0?1:0)}C(),o()})},[i,s,C,o]),N=null;return t&&(a?N=B("button",{className:"item","data-test-id":"table-merge-cells",onClick:()=>_(),type:"button",children:B("span",{className:"text",children:"Merge cells"})}):m&&(N=B("button",{className:"item","data-test-id":"table-unmerge-cells",onClick:()=>I(),type:"button",children:B("span",{className:"text",children:"Unmerge cells"})}))),Ss(Se("div",{className:"table-action-menu-dropdown",onClick:x=>{x.stopPropagation()},ref:l,children:[N?Se(kr.Fragment,{children:[N,B("hr",{})]}):null,B("button",{className:"item","data-test-id":"table-row-striping",onClick:()=>P(),type:"button",children:B("span",{className:"text",children:"Toggle Row Striping"})}),B("button",{className:"item","data-test-id":"table-freeze-first-column",onClick:()=>v(),type:"button",children:B("span",{className:"text",children:"Toggle First Column Freeze"})}),B("button",{className:"item","data-test-id":"table-insert-row-above",onClick:()=>A(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," above"]})}),B("button",{className:"item","data-test-id":"table-insert-row-below",onClick:()=>A(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.rows===1?"row":`${c.rows} rows`," below"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-insert-column-before",onClick:()=>b(!1),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","left"]})}),B("button",{className:"item","data-test-id":"table-insert-column-after",onClick:()=>b(!0),type:"button",children:Se("span",{className:"text",children:["Insert ",c.columns===1?"column":`${c.columns} columns`," ","right"]})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-delete-columns",onClick:()=>w(),type:"button",children:B("span",{className:"text",children:"Delete column"})}),B("button",{className:"item","data-test-id":"table-delete-rows",onClick:()=>T(),type:"button",children:B("span",{className:"text",children:"Delete row"})}),B("button",{className:"item","data-test-id":"table-delete",onClick:()=>g(),type:"button",children:B("span",{className:"text",children:"Delete table"})}),B("hr",{}),B("button",{className:"item","data-test-id":"table-row-header",onClick:()=>M(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&Ae.ROW)===Ae.ROW?"Remove":"Add"," ","row header"]})}),B("button",{className:"item","data-test-id":"table-column-header",onClick:()=>D(),type:"button",children:Se("span",{className:"text",children:[(s.__headerState&Ae.COLUMN)===Ae.COLUMN?"Remove":"Add"," ","column header"]})})]}),document.body)}function V1({anchorElem:t,cellMerge:e}){let[o]=Ns(),r=uo(null),n=uo(null),[i,l]=rt(!1),[s,u]=rt(null),c=me(()=>{let a=r.current,p=mo(),m=P1(o._window),f=document.activeElement;function h(){a&&(a.classList.remove("table-cell-action-button-container--active"),a.classList.add("table-cell-action-button-container--inactive")),u(null)}if(p==null||a==null)return h();let C=o.getRootElement(),_=null,I=null;if(Tr(p)&&C!==null&&m!==null&&C.contains(m.anchorNode)){let b=ws(p.anchor.getNode());if(b==null||(I=o.getElementByKey(b.getKey()),I==null||!b.isAttached()))return h();let T=Ie(b),g=br(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");_=_r(g),u(b)}else if(vt(p)){let b=ws(p.anchor.getNode());if(!Ls(b))throw new Error("TableSelection anchorNode must be a TableCellNode");let T=Ie(b),g=br(T,o.getElementByKey(T.getKey()));if(g===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");_=_r(g),I=o.getElementByKey(b.getKey())}else if(!f)return h();if(_===null||I===null)return h();let A=!_||!_.isSelecting;if(a.classList.toggle("table-cell-action-button-container--active",A),a.classList.toggle("table-cell-action-button-container--inactive",!A),A){let b=I.getBoundingClientRect(),T=t.getBoundingClientRect(),g=b.top-T.top,w=b.right-T.left;a.style.transform=`translate(${w}px, ${g}px)`}},[o,t]);ot(()=>{let a,p=()=>{a=void 0,o.getEditorState().read(c)},m=()=>(a===void 0&&(a=setTimeout(p,0)),!1);return R1(o.registerUpdateListener(m),o.registerCommand(H1,m,$1),o.registerRootListener((f,h)=>{h&&h.removeEventListener("pointerup",m),f&&(f.addEventListener("pointerup",m),m())}),()=>clearTimeout(a))});let d=uo(s);return ot(()=>{d.current!==s&&l(!1),d.current=s},[d,s]),B("div",{className:"table-cell-action-button-container",ref:r,children:s!=null&&Se(kr.Fragment,{children:[B("button",{className:"table-cell-action-button",onClick:a=>{a.stopPropagation(),l(!i)},ref:n,type:"button",children:B(ks,{})}),i&&B(W1,{cellMerge:e,contextRef:n,onClose:()=>l(!1),setIsMenuOpen:l,tableCellNode:s})]})})}var Is=t=>{let e=b1(3),{anchorElem:o}=t,r=_1(),n;return e[0]!==o||e[1]!==r?(n=Ss(r?B(V1,{anchorElem:o??document.body,cellMerge:!0}):null,o??document.body),e[0]=o,e[1]=r,e[2]=n):n=e[2],n};import{c as K1}from"react/compiler-runtime";import{jsx as fo,jsxs as J1}from"react/jsx-runtime";import{useLexicalComposerContext as X1}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as z1}from"@lexical/react/useLexicalEditable";import{$computeTableMapSkipCellCheck as Z1,$getTableNodeFromLexicalNodeOrThrow as wr,$getTableRowIndexFromTableCellNode as Y1,$isTableCellNode as ys,$isTableRowNode as q1,getDOMCellFromTarget as Q1,getTableElement as eh,TableNode as Rs}from"@lexical/table";import{calculateZoomLevel as vs,mergeRegister as th}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Er,isHTMLElement as oh}from"lexical";import*as As from"react";import{useCallback as Mt,useEffect as Nr,useRef as po,useState as nt}from"react";import{createPortal as rh}from"react-dom";var nh=33,Ms=92;function ih({editor:t}){let e=po(null),o=po(null),r=po(null),[n,i]=nt(!1),l=j(),s=po(null),[u,c]=nt(null),[d,a]=nt(null),[p,m]=nt(!1),[f,h]=nt(null),C=Mt(()=>{a(null),e.current=null,h(null),s.current=null,r.current=null},[]),_=v=>(v.buttons&1)===1;Nr(()=>{let v=new Set;return th(t.registerMutationListener(Rs,N=>{for(let[x,E]of N)E==="destroyed"?v.delete(x):v.add(x);i(v.size>0)}),t.registerNodeTransform(Rs,N=>{if(N.getColWidths())return N;let x=N.getColumnCount(),E=Ms;return N.setColWidths(Array(x).fill(E)),N}))},[t]),Nr(()=>{if(!n)return;let v=S=>{let L=S.target;if(oh(L)){if(f){c({x:S.clientX,y:S.clientY});return}if(m(_(S)),!(o.current&&o.current.contains(L))&&e.current!==L){e.current=L;let y=Q1(L);y&&d!==y?t.getEditorState().read(()=>{let k=Er(y.elem);if(!k)throw new Error("TableCellResizer: Table cell node not found.");let F=wr(k),$=eh(F,t.getElementByKey(F.getKey()));if(!$)throw new Error("TableCellResizer: Table element not found.");e.current=L,r.current=$.getBoundingClientRect(),a(y)},{editor:t}):y==null&&C()}}},N=S=>{m(!0)},x=S=>{m(!1)},E=t.registerRootListener((S,L)=>{L?.removeEventListener("mousemove",v),L?.removeEventListener("mousedown",N),L?.removeEventListener("mouseup",x),S?.addEventListener("mousemove",v),S?.addEventListener("mousedown",N),S?.addEventListener("mouseup",x)});return()=>{E()}},[d,f,t,n,C]);let I=v=>v==="bottom",A=Mt(v=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=Er(d.elem);if(!ys(N))throw new Error("TableCellResizer: Table cell node not found.");let x=wr(N),E=Y1(N),S=x.getChildren(),y=N.getColSpan()===x.getColumnCount()?E:E+N.getRowSpan()-1;if(y>=S.length||y<0)throw new Error("Expected table cell to be inside of table row.");let k=S[y];if(!q1(k))throw new Error("Expected table row");let F=k.getHeight();if(F===void 0){let U=k.getChildren();F=Math.min(...U.map(V=>b(V,t)??1/0))}let $=Math.max(F+v,nh);k.setHeight($)},{tag:"skip-scroll-into-view"})},[d,t]),b=(v,N)=>N.getElementByKey(v.getKey())?.clientHeight,T=(v,N)=>{let x;return N.forEach(E=>{E.forEach((S,L)=>{S.cell===v&&(x=L)})}),x},g=Mt(v=>{if(!d)throw new Error("TableCellResizer: Expected active cell.");t.update(()=>{let N=Er(d.elem);if(!ys(N))throw new Error("TableCellResizer: Table cell node not found.");let x=wr(N),[E]=Z1(x,null,null),S=T(N,E);if(S===void 0)throw new Error("TableCellResizer: Table column not found.");let L=x.getColWidths();if(!L)return;let y=L[S];if(y===void 0)return;let k=[...L],F=Math.max(y+v,Ms);k[S]=F,x.setColWidths(k)},{tag:"skip-scroll-into-view"})},[d,t]),w=Mt(v=>{let N=x=>{if(x.preventDefault(),x.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");if(s.current){let{x:E,y:S}=s.current;if(d===null)return;let L=vs(x.target);if(I(v)){let y=(x.clientY-S)/L;A(y)}else{let y=(x.clientX-E)/L;g(y)}C(),document.removeEventListener("mouseup",N)}};return N},[d,C,g,A]),M=Mt(v=>N=>{if(N.preventDefault(),N.stopPropagation(),!d)throw new Error("TableCellResizer: Expected active cell.");s.current={x:N.clientX,y:N.clientY},c(s.current),h(v),document.addEventListener("mouseup",w(v))},[d,w]),[D,P]=nt({bottom:null,left:null,right:null,top:null});return Nr(()=>{if(d){let{height:v,left:N,top:x,width:E}=d.elem.getBoundingClientRect(),S=vs(d.elem),L=10,y={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${L}px`,left:`${window.scrollX+N}px`,top:`${window.scrollY+x+v-L/2}px`,width:`${E}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${v}px`,left:`${window.scrollX+N+E-L/2}px`,top:`${window.scrollY+x}px`,width:`${L}px`}},k=r.current;f&&u&&k&&(I(f)?(y[f].left=`${window.scrollX+k.left}px`,y[f].top=`${window.scrollY+u.y/S}px`,y[f].height="3px",y[f].width=`${k.width}px`):(y[f].top=`${window.scrollY+k.top}px`,y[f].left=`${window.scrollX+u.x/S}px`,y[f].width="3px",y[f].height=`${k.height}px`),y[f].backgroundColor="#adf"),P(y)}else P({bottom:null,left:null,right:null,top:null})},[d,f,u]),fo("div",{ref:o,children:d!=null&&!p&&J1(As.Fragment,{children:[fo("div",{className:`${l.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:M("right"),style:D.right||void 0}),fo("div",{className:`${l.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`,onMouseDown:M("bottom"),style:D.bottom||void 0})]})})}var Ds=()=>{let t=K1(3),[e]=X1(),o=z1(),r,n;return t[0]!==e||t[1]!==o?(n=o?rh(fo(ih,{editor:e}),document.body):null,t[0]=e,t[1]=o,t[2]=n):n=t[2],r=n,r};import{c as ph}from"react/compiler-runtime";import{jsx as Lr,jsxs as fh,Fragment as hh}from"react/jsx-runtime";import{useLexicalComposerContext as Us}from"@lexical/react/LexicalComposerContext";import{$getTableAndElementByKey as gh,$getTableColumnIndexFromTableCellNode as Ch,$getTableRowIndexFromTableCellNode as xh,$insertTableColumn__EXPERIMENTAL as bh,$insertTableRow__EXPERIMENTAL as _h,$isTableCellNode as Th,$isTableNode as $s,getTableElement as kh,TableNode as wh}from"@lexical/table";import{$findMatchingParent as Eh,mergeRegister as Nh}from"@lexical/utils";import{$getNearestNodeFromDOMNode as Ps,isHTMLElement as Lh}from"lexical";import{useEffect as Bs,useMemo as Sh,useRef as Hs,useState as ho}from"react";import"react";import{createPortal as Ih}from"react-dom";import{c as uh}from"react/compiler-runtime";import{useEffect as dh,useRef as mh}from"react";var lh="Expected a function",sh=Math.max,ah=Math.min;function ch(t,e,o){let r,n,i=0,l,s=!1,u=!1,c,d,a,p=!0;if(typeof t!="function")throw new TypeError(lh);e=e||0,typeof o=="object"&&(s=!!o.leading,u="maxWait"in o,c=u?sh(o.maxWait||0,e):c,p="trailing"in o?!!o.trailing:p);function m(g){let w=r,M=l;return r=l=void 0,i=g,d=t.apply(M,w),d}function f(g){return i=g,a=setTimeout(_,e),s?m(g):d}function h(g){let w=g-n,M=g-i,D=e-w;return u?ah(D,c-M):D}function C(g){let w=g-n,M=g-i;return n===void 0||w>=e||w<0||u&&M>=c}function _(){let g=Date.now();if(C(g))return I(g);a=setTimeout(_,h(g))}function I(g){return a=void 0,p&&r?m(g):(r=l=void 0,d)}function A(){a!==void 0&&clearTimeout(a),i=0,r=n=l=a=void 0}function b(){return a===void 0?d:I(Date.now())}function T(){let g=Date.now(),w=C(g);if(r=arguments,l=this,n=g,w){if(a===void 0)return f(n);if(u)return clearTimeout(a),a=setTimeout(_,e),m(n)}return a===void 0&&(a=setTimeout(_,e)),d}return T.cancel=A,T.flush=b,T}var Os=ch;function Fs(t,e,o){let r=uh(6),n=mh(null),i,l;r[0]!==t||r[1]!==o||r[2]!==e?(i=()=>(n.current=Os(t,e,{maxWait:o}),()=>{n.current?.cancel()}),l=[t,e,o],r[0]=t,r[1]=o,r[2]=e,r[3]=i,r[4]=l):(i=r[3],l=r[4]),dh(i,l);let s;return r[5]===Symbol.for("react.memo_cache_sentinel")?(s=(...c)=>{let d=c;n.current&&n.current(...d)},r[5]=s):s=r[5],s}var js=20;function yh({anchorElem:t}){let[e]=Us(),o=j(),[r,n]=ho(!1),[i,l]=ho(!1),[s,u]=ho(!1),[c,d]=ho({}),a=Hs(new Set),p=Hs(null),m=Fs(C=>{let{isOutside:_,tableDOMNode:I}=Rh(C,o.editorConfig?.lexical);if(_){n(!1),l(!1);return}if(!I)return;p.current=I;let A=null,b=null,T=null;if(e.getEditorState().read(()=>{let L=Ps(I);if(Th(L)){let y=Eh(L,k=>$s(k));if(!$s(y))return;if(T=kh(y,e.getElementByKey(y.getKey())),T){let k=y.getChildrenSize(),F=y.getChildAtIndex(0)?.getChildrenSize(),$=xh(L),U=Ch(L);$===k-1?A=L:U===F-1&&(b=L)}}},{editor:e}),!T)return;let g=T.parentElement;if(!g)return;let{bottom:w,height:M,left:D,right:P,width:v,y:N}=T.getBoundingClientRect(),x=!1;g&&g.classList.contains("LexicalEditorTheme__tableScrollableWrapper")&&(x=g.scrollWidth>g.clientWidth);let{left:E,y:S}=t.getBoundingClientRect();A?(l(!1),n(!0),d({height:js,left:x&&g?g.offsetLeft:D-E,top:w-S+5,width:x&&g?g.offsetWidth:v})):b&&(l(!0),n(!1),d({height:M,left:P-E+5,top:N-S,width:js}))},50,250),f=Sh(()=>new ResizeObserver(()=>{n(!1),l(!1)}),[]);Bs(()=>{if(s)return document.addEventListener("mousemove",m),()=>{n(!1),l(!1),document.removeEventListener("mousemove",m)}},[s,m]),Bs(()=>Nh(e.registerMutationListener(wh,C=>{e.getEditorState().read(()=>{let _=!1;for(let[I,A]of C)switch(A){case"created":{a.current.add(I),_=!0;break}case"destroyed":{a.current.delete(I),_=!0;break}default:break}if(_){f.disconnect();for(let I of a.current){let{tableElement:A}=gh(I);f.observe(A)}u(a.current.size>0)}},{editor:e})},{skipInitialization:!1})),[e,f]);let h=C=>{e.update(()=>{p.current&&(Ps(p.current)?.selectEnd(),C?(_h(),n(!1)):(bh(),l(!1)))})};return e?.isEditable()?fh(hh,{children:[r&&Lr("button",{"aria-label":"Add Row",className:o.editorConfig.lexical.theme.tableAddRows,onClick:()=>h(!0),style:{...c},type:"button"}),i&&Lr("button",{"aria-label":"Add Column",className:o.editorConfig.lexical.theme.tableAddColumns,onClick:()=>h(!1),style:{...c},type:"button"})]}):null}function Rh(t,e){let o=t.target;if(Lh(o)){let r=o.closest(`td.${e.theme.tableCell}, th.${e.theme.tableCell}`);return{isOutside:!(r||o.closest(`button.${e.theme.tableAddRows}`)||o.closest(`button.${e.theme.tableAddColumns}`)||o.closest(`div.${e.theme.tableCellResizer}`)),tableDOMNode:r}}else return{isOutside:!0,tableDOMNode:null}}function Gs(t){let e=ph(2),{anchorElem:o}=t,r=o===void 0?document.body:o,[n]=Us();if(!n?.isEditable())return null;let i;return e[0]!==r?(i=Ih(Lr(yh,{anchorElem:r}),r),e[0]=r,e[1]=i):i=e[1],i}import{c as vh}from"react/compiler-runtime";import{jsx as Sr,jsxs as Mh}from"react/jsx-runtime";import{useLexicalComposerContext as Ah}from"@lexical/react/LexicalComposerContext";import{TablePlugin as Dh}from"@lexical/react/LexicalTablePlugin";import{INSERT_TABLE_COMMAND as Oh,TableCellNode as Fh,TableNode as $h,TableRowNode as Ph}from"@lexical/table";import{mergeRegister as Bh}from"@lexical/utils";import{formatDrawerSlug as Hh,useEditDepth as jh}from"@payloadcms/ui";import{$getSelection as Uh,$isRangeSelection as Gh,COMMAND_PRIORITY_EDITOR as Wh,createCommand as Vh}from"lexical";import{createContext as Kh,use as Jh,useEffect as Xh,useMemo as zh,useState as Zh}from"react";import*as Ws from"react";var go=Vh("OPEN_EMBED_DRAWER_COMMAND"),Vs=Kh({cellEditorConfig:null,cellEditorPlugins:null,set:()=>{}});function Ks({children:t}){let[e,o]=Zh({cellEditorConfig:null,cellEditorPlugins:null});return Sr(Vs,{value:zh(()=>({cellEditorConfig:e.cellEditorConfig,cellEditorPlugins:e.cellEditorPlugins,set:(r,n)=>{o({cellEditorConfig:r,cellEditorPlugins:n})}}),[e.cellEditorConfig,e.cellEditorPlugins]),children:t})}var Js=()=>{let t=vh(16),[e]=Ah(),o=Jh(Vs),r=jh(),{fieldProps:n,uuid:i}=j(),{schemaPath:l}=n,s="lexical-table-create-"+i,u;t[0]!==r||t[1]!==s?(u=Hh({slug:s,depth:r}),t[0]=r,t[1]=s,t[2]=u):u=t[2];let c=u,{toggleDrawer:d}=Ce(c,!0),a;t[3]!==e||t[4]!==d?(a=()=>{if(!e.hasNodes([$h,Ph,Fh]))throw new Error("TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor");return Bh(e.registerCommand(go,()=>{let h;return h=null,e.getEditorState().read(()=>{let C=Uh();Gh(C)&&(h=C)}),h&&d(),!0},Wh))},t[3]=e,t[4]=d,t[5]=a):a=t[5];let p;t[6]!==o||t[7]!==e||t[8]!==d?(p=[o,e,d],t[6]=o,t[7]=e,t[8]=d,t[9]=p):p=t[9],Xh(a,p);let m;t[10]!==e?(m=(h,C)=>{!C.columns||!C.rows||e.dispatchCommand(Oh,{columns:String(C.columns),rows:String(C.rows)})},t[10]=e,t[11]=m):m=t[11];let f;return t[12]!==c||t[13]!==l||t[14]!==m?(f=Mh(Ws.Fragment,{children:[Sr(lt,{drawerSlug:c,drawerTitle:"Create Table",featureKey:"experimental_table",handleDrawerSubmit:m,schemaPath:l,schemaPathSuffix:"fields"}),Sr(Dh,{hasCellBackgroundColor:!1,hasCellMerge:!0,hasHorizontalScroll:!0})]}),t[12]=c,t[13]=l,t[14]=m,t[15]=f):f=t[15],f};var eg=R({markdownTransformers:[_s],nodes:[qh,Yh,Qh],plugins:[{Component:Js,position:"normal"},{Component:Ds,position:"normal"},{Component:Is,position:"floatingAnchorElem"},{Component:Gs,position:"floatingAnchorElem"}],providers:[Ks],slashMenu:{groups:[Q([{Icon:fr,key:"table",keywords:["table"],label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(go,{})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:fr,key:"table",label:"Table",onSelect:({editor:t})=>{t.dispatchCommand(go,{})}}])]}});import{$isNodeSelection as vg}from"lexical";import{jsx as Ir,jsxs as tg}from"react/jsx-runtime";import"react";var yr=()=>tg("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ir("path",{d:"M14.6667 4H5.33333C4.59695 4 4 4.59695 4 5.33333V14.6667C4 15.403 4.59695 16 5.33333 16H14.6667C15.403 16 16 15.403 16 14.6667V5.33333C16 4.59695 15.403 4 14.6667 4Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),Ir("path",{d:"M7.99984 9.33366C8.73622 9.33366 9.33317 8.73671 9.33317 8.00033C9.33317 7.26395 8.73622 6.66699 7.99984 6.66699C7.26346 6.66699 6.6665 7.26395 6.6665 8.00033C6.6665 8.73671 7.26346 9.33366 7.99984 9.33366Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),Ir("path",{d:"M16 11.9995L13.9427 9.94214C13.6926 9.69218 13.3536 9.55176 13 9.55176C12.6464 9.55176 12.3074 9.69218 12.0573 9.94214L6 15.9995",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as lg}from"react/jsx-runtime";import Zs from"bson-objectid";import{$applyNodeReplacement as sg}from"lexical";import*as Ys from"react";import{jsx as og}from"react/jsx-runtime";import{DecoratorBlockNode as rg}from"@lexical/react/LexicalDecoratorBlockNode.js";import Xs from"bson-objectid";import{$applyNodeReplacement as ng}from"lexical";import"react";function Rr(t){return t.parentElement!=null&&t.parentElement.tagName==="LI"&&t.previousSibling===null&&t.getAttribute("aria-roledescription")==="checkbox"}function ig(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:zs({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||Rr(e),null}var At=class extends rg{__data;constructor({data:e,format:o,key:r}){super(o,r),this.__data=e}static clone(e){return new this({data:e.__data,format:e.__format,key:e.__key})}static getType(){return"upload"}static importDOM(){return{img:e=>({conversion:ig,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Xs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=zs({data:o});return r.setFormat(e.format),r}static isInline(){return!1}decorate(){return og(RawUploadComponent,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let e=document.createElement("img");return e.setAttribute("data-lexical-upload-id",String(this.__data?.value)),e.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:e}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(e){let o=this.getWritable();o.__data=e}updateDOM(){return!1}};function zs({data:t}){return t?.id||(t.id=new Xs.default().toHexString()),ng(new At({data:t}))}var ag=Ys.lazy(()=>import("./component-NNKG7K3O.js").then(t=>({default:t.UploadComponent})));function cg(t){if(t.hasAttribute("data-lexical-upload-relation-to")&&t.hasAttribute("data-lexical-upload-id")){let o=t.getAttribute("data-lexical-upload-id"),r=t.getAttribute("data-lexical-upload-relation-to");if(o!=null&&r!=null)return{node:Ge({data:{fields:{},relationTo:r,value:o}})}}let e=t;return e.src.startsWith("file:///")||Rr(e),null}var ye=class extends At{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importDOM(){return{img:e=>({conversion:cg,priority:0})}}static importJSON(e){e.version===1&&e?.value?.id&&(e.value=e.value.id),e.version===2&&!e?.id&&(e.id=new Zs.default().toHexString(),e.version=3);let o={id:e.id,fields:e.fields,relationTo:e.relationTo,value:e.value},r=Ge({data:o});return r.setFormat(e.format),r}decorate(){return lg(ag,{data:this.__data,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Ge({data:t}){return t?.id||(t.id=new Zs.default().toHexString()),sg(new ye({data:t}))}function vr(t){return t instanceof ye}import{c as Cg}from"react/compiler-runtime";import{jsx as xg}from"react/jsx-runtime";import{useLexicalComposerContext as bg}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as _g,mergeRegister as Tg}from"@lexical/utils";import{useConfig as kg}from"@payloadcms/ui";import{$getPreviousSelection as wg,$getSelection as Eg,$isParagraphNode as Ng,$isRangeSelection as Lg,COMMAND_PRIORITY_EDITOR as Sg,createCommand as Ig}from"lexical";import{useEffect as yg}from"react";import{c as qs}from"react/compiler-runtime";import{jsx as Mr}from"react/jsx-runtime";import{useLexicalComposerContext as Qs}from"@lexical/react/LexicalComposerContext.js";import{toast as ug}from"@payloadcms/ui";import{$getNodeByKey as dg,COMMAND_PRIORITY_EDITOR as ea}from"lexical";import{useEffect as ta,useState as mg}from"react";var pg=({editor:t,relationTo:e,replaceNodeKey:o,value:r})=>{o?t.update(()=>{let n=dg(o);n&&n.replace(Ge({data:{fields:null,relationTo:e,value:r}}))}):t.dispatchCommand(Ar,{fields:null,relationTo:e,value:r})},fg=t=>{let e=qs(13),{enabledCollectionSlugs:o}=t,[r]=Qs(),[n,i]=mg(null),l;e[0]!==o?(l={collectionSlugs:o,uploads:!0},e[0]=o,e[1]=l):l=e[1];let{closeListDrawer:s,ListDrawer:u,openListDrawer:c}=St(l),d,a;e[2]!==r||e[3]!==c?(d=()=>r.registerCommand(Ve,h=>(i(h?.replace?h?.replace.nodeKey:null),c(),!0),ea),a=[r,c],e[2]=r,e[3]=c,e[4]=d,e[5]=a):(d=e[4],a=e[5]),ta(d,a);let p;e[6]!==s||e[7]!==r||e[8]!==n?(p=h=>{let{collectionSlug:C,doc:_}=h;s(),pg({editor:r,relationTo:C,replaceNodeKey:n,value:_.id})},e[6]=s,e[7]=r,e[8]=n,e[9]=p):p=e[9];let m=p,f;return e[10]!==u||e[11]!==m?(f=Mr(u,{onSelect:m}),e[10]=u,e[11]=m,e[12]=f):f=e[12],f},hg=()=>{let t=qs(3),[e]=Qs(),o,r;return t[0]!==e?(o=()=>e.registerCommand(Ve,gg,ea),r=[e],t[0]=e,t[1]=o,t[2]=r):(o=t[1],r=t[2]),ta(o,r),null},oa=t=>Mr(Ot,{...t,FallbackComponent:hg,uploads:!0,children:Mr(fg,{...t})});function gg(){return ug.error("No upload collections enabled"),!0}var Ar=Ig("INSERT_UPLOAD_COMMAND"),ra=t=>{let e=Cg(5),[o]=bg(),{config:r}=kg(),{collections:n}=r,i,l;e[0]!==o?(i=()=>{if(!o.hasNodes([ye]))throw new Error("UploadPlugin: UploadNode not registered on editor");return Tg(o.registerCommand(Ar,u=>(o.update(()=>{let c=Eg()||wg();if(Lg(c)){let d=Ge({data:{id:u.id,fields:u.fields,relationTo:u.relationTo,value:u.value}}),{focus:a}=c,p=a.getNode();_g(d),Ng(p)&&!p.__first&&p.remove()}}),!0),Sg))},l=[o],e[0]=o,e[1]=i,e[2]=l):(i=e[1],l=e[2]),yg(i,l);let s;return e[3]!==n?(s=xg(oa,{enabledCollectionSlugs:n.map(Rg)}),e[3]=n,e[4]=s):s=e[4],s};function Rg(t){let{slug:e}=t;return e}var Mg=R({nodes:[ye],plugins:[{Component:ra,position:"normal"}],slashMenu:{groups:[Q([{Icon:yr,key:"upload",keywords:["upload","image","file","img","picture","photo","media"],label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]},toolbarFixed:{groups:[_e([{ChildComponent:yr,isActive:({selection:t})=>{if(!vg(t)||!t.getNodes().length)return!1;let e=t.getNodes()[0];return vr(e)},key:"upload",label:({i18n:t})=>t.t("lexical:upload:label"),onSelect:({editor:t})=>{t.dispatchCommand(Ve,{replace:!1})}}])]}});import{c as Dg}from"react/compiler-runtime";import{jsx as Or}from"react/jsx-runtime";import{ShimmerEffect as Og,useConfig as Fg}from"@payloadcms/ui";import{lazy as $g,Suspense as Pg,useEffect as Bg,useState as Hg}from"react";var na={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",hrSelected:"LexicalEditorTheme__hrSelected",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",tab:"LexicalEditorTheme__tabNode",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableAlignment:{center:"LexicalEditorTheme__tableAlignmentCenter",right:"LexicalEditorTheme__tableAlignmentRight"},tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableFrozenColumn:"LexicalEditorTheme__tableFrozenColumn",tableRowStriping:"LexicalEditorTheme__tableRowStriping",tableScrollableWrapper:"LexicalEditorTheme__tableScrollableWrapper",tableSelected:"LexicalEditorTheme__tableSelected",tableSelection:"LexicalEditorTheme__tableSelection",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var Co={namespace:"lexical",theme:na};function ia({config:t,featureClientImportMap:e,featureClientSchemaMap:o,field:r,schemaPath:n,unSanitizedEditorConfig:i}){for(let c of i.features)if(!c?.clientFeatureProps?.featureKey||c?.clientFeatureProps?.order===void 0||c?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");i.features=i.features.sort((c,d)=>c.clientFeatureProps.order-d.clientFeatureProps.order);let l=new Map;for(let c of i.features)l.set(c.clientFeatureProps.featureKey,c);let s=new Map,u=0;for(let c of i.features){let d=typeof c.feature=="function"?c.feature({config:t,featureClientImportMap:e,featureClientSchemaMap:o,featureProviderMap:l,field:r,resolvedFeatures:s,schemaPath:n,unSanitizedEditorConfig:i}):c.feature;d.key=c.clientFeatureProps.featureKey,d.order=u,s.set(c.clientFeatureProps.featureKey,d),u++}return s}import{deepMerge as Ag}from"payload/shared";var la=t=>{let e={enabledFeatures:[],enabledFormats:[],markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}},o={};if(t.forEach(r=>{r.key==="toolbarFixed"&&r.sanitizedClientFeatureProps?.customGroups&&(o={...o,...r.sanitizedClientFeatureProps.customGroups})}),!t?.size)return e;t.forEach(r=>{if(r.providers?.length&&(e.providers=e.providers.concat(r.providers)),r.enableFormats?.length&&e.enabledFormats.push(...r.enableFormats),r.nodes?.length)for(let n of r.nodes)e.nodes.push(n);if(r.plugins?.length&&r.plugins.forEach((n,i)=>{e.plugins?.push({clientProps:r.sanitizedClientFeatureProps,Component:n.Component,key:r.key+i,position:n.position})}),r.toolbarInline?.groups?.length)for(let n of r.toolbarInline.groups){let i=e.toolbarInline.groups.find(l=>l.key===n.key);i?e.toolbarInline.groups=e.toolbarInline.groups.filter(l=>l.key!==n.key):i={...n,items:[]},n?.items?.length&&(i.items=i.items.concat(n.items)),e.toolbarInline?.groups.push(i)}if(r.toolbarFixed?.groups?.length)for(let n of r.toolbarFixed.groups){let i=e.toolbarFixed.groups.find(l=>l.key===n.key);i?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(l=>l.key!==n.key):i={...n,items:[]},n?.items?.length&&(i.items=i.items.concat(n.items)),e.toolbarFixed?.groups.push(i)}if(r.slashMenu?.groups){r.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(r.slashMenu.dynamicGroups));for(let n of r.slashMenu.groups){let i=e.slashMenu.groups.find(l=>l.key===n.key);i?e.slashMenu.groups=e.slashMenu.groups.filter(l=>l.key!==n.key):i={...n,items:[]},n?.items?.length&&(i.items=i.items.concat(n.items)),e.slashMenu.groups.push(i)}}if(r.markdownTransformers?.length)for(let n of r.markdownTransformers)typeof n=="function"?e.markdownTransformers.push(n({allNodes:e.nodes,allTransformers:e.markdownTransformers})):e.markdownTransformers.push(n);e.enabledFeatures.push(r.key)}),Object.keys(o).length>0&&(e.toolbarFixed.groups=e.toolbarFixed.groups.map(r=>{let n=o[r.key];return n?Ag(r,n):r})),e.toolbarInline.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((r,n)=>r.order&&n.order?r.order-n.order:r.order?-1:n.order?1:0);for(let r of e.toolbarInline.groups)r.items.sort((n,i)=>n.order&&i.order?n.order-i.order:n.order?-1:i.order?1:0);for(let r of e.toolbarFixed.groups)r.items.sort((n,i)=>n.order&&i.order?n.order-i.order:n.order?-1:i.order?1:0);return e};function Dr(t,e,o){return{admin:o,features:la(t),lexical:e,resolvedFeatureMap:t}}var jg=$g(()=>import("./Field-DGC4DDYL.js").then(t=>({default:t.RichText}))),Ug=t=>{let e=Dg(16),{admin:o,clientFeatures:r,featureClientImportMap:n,featureClientSchemaMap:i,field:l,lexicalEditorConfig:s,schemaPath:u}=t,c;e[0]!==o?(c=o===void 0?{}:o,e[0]=o,e[1]=c):c=e[1];let d=c,a=s===void 0?Co:s,{config:p}=Fg(),[m,f]=Hg(null),h,C;e[2]!==d||e[3]!==r||e[4]!==p||e[5]!==n||e[6]!==i||e[7]!==l||e[8]!==m||e[9]!==a||e[10]!==u?(h=()=>{if(m)return;let I=[];for(let[T,g]of Object.entries(r))g.clientFeatureProvider&&I.push(g.clientFeatureProvider(g.clientFeatureProps));let A=a||Co,b=ia({config:p,featureClientImportMap:n,featureClientSchemaMap:i,field:l,schemaPath:u??l.name,unSanitizedEditorConfig:{features:I,lexical:A}});f(Dr(b,A,d))},C=[a,d,m,r,n,i,l,p,u],e[2]=d,e[3]=r,e[4]=p,e[5]=n,e[6]=i,e[7]=l,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=C):(h=e[11],C=e[12]),Bg(h,C);let _;return e[13]!==m||e[14]!==t?(_=Or(Pg,{fallback:Or(Og,{height:"35vh"}),children:m&&Or(jg,{...t,editorConfig:m})}),e[13]=m,e[14]=t,e[15]=_):_=e[15],_};function Gg(t){return t instanceof HTMLElement}function Wg(...t){return t.filter(Boolean).join(" ")}var xo=new WeakMap;function sa(t){let e=t.changedTouches[0];return e===void 0?null:[e.clientX,e.clientY]}function bo(t,e){let o=xo.get(t);if(o===void 0){let r=new Set,n=l=>{o!==void 0&&(o.start=sa(l))},i=l=>{if(o===void 0)return;let{start:s}=o;if(s===null)return;let u=sa(l);for(let c of r)u!==null&&c([u[0]-s[0],u[1]-s[1]],l)};t.addEventListener("touchstart",n),t.addEventListener("touchend",i),o={handleTouchend:i,handleTouchstart:n,listeners:r,start:null},xo.set(t,o)}return o.listeners.add(e),()=>{Vg(t,e)}}function Vg(t,e){let o=xo.get(t);if(o===void 0)return;let{listeners:r}=o;r.delete(e),r.size===0&&(xo.delete(t),t.removeEventListener("touchstart",o.handleTouchstart),t.removeEventListener("touchend",o.handleTouchend))}function Kg(t,e){return bo(t,(o,r)=>{let[n,i]=o;n<0&&-n>Math.abs(i)&&e(n,r)})}function Jg(t,e){return bo(t,(o,r)=>{let[n,i]=o;n>0&&n>Math.abs(i)&&e(n,r)})}function Xg(t,e){return bo(t,(o,r)=>{let[n,i]=o;i<0&&-i>Math.abs(n)&&e(n,r)})}function zg(t,e){return bo(t,(o,r)=>{let[n,i]=o;i>0&&i>Math.abs(n)&&e(n,r)})}import{c as Zg}from"react/compiler-runtime";import{jsx as Yg}from"react/jsx-runtime";import"react";var qg=()=>{let t=Zg(2),{EditButton:e}=xe(),o;return t[0]!==e?(o=e?Yg(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as Qg}from"react/compiler-runtime";import{jsx as eC}from"react/jsx-runtime";import"react";var tC=()=>{let t=Qg(2),{RemoveButton:e}=xe(),o;return t[0]!==e?(o=e?eC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as oC}from"react/compiler-runtime";import{jsx as rC}from"react/jsx-runtime";import"react";var nC=()=>{let t=oC(2),{Label:e}=xe(),o;return t[0]!==e?(o=e?rC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as iC}from"react/compiler-runtime";import{jsx as lC}from"react/jsx-runtime";import"react";var sC=t=>{let e=iC(3),{children:o}=t,{InlineBlockContainer:r}=xe(),n;return e[0]!==r||e[1]!==o?(n=r?lC(r,{children:o}):null,e[0]=r,e[1]=o,e[2]=n):n=e[2],n};import{c as aC}from"react/compiler-runtime";import{jsx as cC}from"react/jsx-runtime";import"react";var uC=t=>{let e=aC(6),{children:o,editButton:r,Label:n,removeButton:i}=t,{BlockCollapsible:l}=Oe(),s;return e[0]!==l||e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==i?(s=l?cC(l,{editButton:r,Label:n,removeButton:i,children:o}):null,e[0]=l,e[1]=n,e[2]=o,e[3]=r,e[4]=i,e[5]=s):s=e[5],s};import{c as dC}from"react/compiler-runtime";import{jsx as mC}from"react/jsx-runtime";import"react";var pC=()=>{let t=dC(2),{EditButton:e}=Oe(),o;return t[0]!==e?(o=e?mC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{c as fC}from"react/compiler-runtime";import{jsx as hC}from"react/jsx-runtime";import"react";var gC=()=>{let t=fC(2),{RemoveButton:e}=Oe(),o;return t[0]!==e?(o=e?hC(e,{}):null,t[0]=e,t[1]=o):o=t[1],o};import{stringify as CC}from"qs-esm";var xC=({apiURL:t,depth:e,draft:o,locale:r})=>async({id:i,collectionSlug:l,select:s})=>{let u=CC({depth:e??0,draft:o??!1,locale:r,select:s},{addQueryPrefix:!0});return await fetch(`${t}/${l}/${i}${u}`,{credentials:"include",headers:{Accept:"application/json","Content-Type":"application/json"},method:"GET"}).then(d=>d.json())};export{Ct as $createAutoLinkNode,Vt as $createBlockNode,To as $createInlineBlockNode,Te as $createLinkNode,je as $createRelationshipNode,Ge as $createUploadNode,we as $isAutoLinkNode,pt as $isBlockNode,ko as $isInlineBlockNode,Z as $isLinkNode,ir as $isRelationshipNode,vr as $isUploadNode,_a as AlignFeatureClient,ke as AutoLinkNode,uC as BlockCollapsible,pC as BlockEditButton,be as BlockNode,gC as BlockRemoveButton,Na as BlockquoteFeatureClient,kc as BlocksFeatureClient,Vc as BoldFeatureClient,ae as CAN_USE_DOM,Dm as ChecklistFeatureClient,Ep as DETAIL_TYPE_TO_DETAIL,_p as DOUBLE_LINE_BREAK,Fp as DebugJsxConverterFeatureClient,Lp as ELEMENT_FORMAT_TO_TYPE,Np as ELEMENT_TYPE_TO_FORMAT,pa as ENABLE_SLASH_MENU_COMMAND,ca as EditorConfigProvider,lt as FieldsDrawer,Zf as FixedToolbarFeatureClient,Su as HeadingFeatureClient,Wu as HorizontalRuleFeatureClient,Ke as INSERT_BLOCK_COMMAND,Je as INSERT_INLINE_BLOCK_COMMAND,xp as IS_ALL_FORMATTING,ld as IndentFeatureClient,sC as InlineBlockContainer,qg as InlineBlockEditButton,nC as InlineBlockLabel,_o as InlineBlockNode,tC as InlineBlockRemoveButton,Zc as InlineCodeFeatureClient,s1 as InlineToolbarFeatureClient,eu as ItalicFeatureClient,kp as LTR_REGEX,op as LexicalPluginToLexicalFeatureClient,bm as LinkFeatureClient,ie as LinkNode,bp as NON_BREAKING_SPACE,O as NodeFormat,Um as OrderedListFeatureClient,up as ParagraphFeatureClient,da as Point,Tp as RTL_REGEX,fa as Rect,kf as RelationshipFeatureClient,Ne as RelationshipNode,Ug as RichTextField,ap as SlateToLexicalFeatureClient,iu as StrikethroughFeatureClient,cu as SubscriptFeatureClient,pu as SuperscriptFeatureClient,Sp as TEXT_MODE_TO_TYPE,wp as TEXT_TYPE_TO_FORMAT,Ip as TEXT_TYPE_TO_MODE,he as TOGGLE_LINK_COMMAND,eg as TableFeatureClient,Fc as TestRecorderFeatureClient,It as ToolbarButton,Ue as ToolbarDropdown,jc as TreeViewFeatureClient,xu as UnderlineFeatureClient,Zm as UnorderedListFeatureClient,Mg as UploadFeatureClient,ye as UploadNode,zg as addSwipeDownListener,Kg as addSwipeLeftListener,Jg as addSwipeRightListener,Xg as addSwipeUpListener,$o as createBlockNode,R as createClientFeature,Co as defaultEditorLexicalConfig,pr as getDOMRangeRect,ha as getEnabledNodes,xC as getRestPopulateFn,Xe as getSelectedNode,Gg as isHTMLElement,ma as isPoint,Wg as joinClasses,Dr as sanitizeClientEditorConfig,la as sanitizeClientFeatures,lo as setFloatingElemPosition,Qt as setFloatingElemPositionForLinkEditor,Q as slashMenuBasicGroupWithItems,_e as toolbarAddDropdownGroupWithItems,Bo as toolbarFeatureButtonsGroupWithItems,ee as toolbarFormatGroupWithItems,ne as toolbarTextDropdownGroupWithItems,Oe as useBlockComponentContext,j as useEditorConfigContext,xe as useInlineBlockComponentContext,ua as useLexicalDocumentDrawer,Ce as useLexicalDrawer,St as useLexicalListDrawer};
|
|
41
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","TEXT_TYPE_TO_FORMAT","TextNode","useEffect","TextPlugin","t0","$","features","editor","t1","enabledFormats","disabledFormats","getDisabledFormats","length","registerNodeTransform","textNode","forEach","disabledFormat","hasFormat","toggleFormat","t2","allFormats","Object","keys","enabledSet","Set","filter","format","has"],"sources":["../../../../src/lexical/plugins/TextPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TEXT_TYPE_TO_FORMAT, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { SanitizedClientFeatures } from '../../../features/typesClient.js'\n\nexport function TextPlugin({ features }: { features: SanitizedClientFeatures }) {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n const disabledFormats = getDisabledFormats(features.enabledFormats
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","TEXT_TYPE_TO_FORMAT","TextNode","useEffect","TextPlugin","t0","$","features","editor","t1","enabledFormats","disabledFormats","getDisabledFormats","length","registerNodeTransform","textNode","forEach","disabledFormat","hasFormat","toggleFormat","t2","allFormats","Object","keys","enabledSet","Set","filter","format","has"],"sources":["../../../../src/lexical/plugins/TextPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TEXT_TYPE_TO_FORMAT, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { SanitizedClientFeatures } from '../../../features/typesClient.js'\n\nexport function TextPlugin({ features }: { features: SanitizedClientFeatures }) {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n const disabledFormats = getDisabledFormats(features.enabledFormats)\n if (disabledFormats.length === 0) {\n return\n }\n // Ideally override the TextNode with our own TextNode (changing its setFormat or toggleFormat methods),\n // would be more performant. If we find a noticeable perf regression we can switch to that option.\n // Overriding the FORMAT_TEXT_COMMAND and PASTE_COMMAND commands is not an option I considered because\n // there might be other forms of mutation that we might not be considering. For example:\n // browser extensions or Payload/Lexical plugins that have their own commands.\n return editor.registerNodeTransform(TextNode, (textNode) => {\n disabledFormats.forEach((disabledFormat) => {\n if (textNode.hasFormat(disabledFormat)) {\n textNode.toggleFormat(disabledFormat)\n }\n })\n })\n }, [editor, features])\n\n return null\n}\n\nfunction getDisabledFormats(enabledFormats: TextFormatType[]): TextFormatType[] {\n const allFormats = Object.keys(TEXT_TYPE_TO_FORMAT) as TextFormatType[]\n const enabledSet = new Set(enabledFormats)\n\n return allFormats.filter((format) => !enabledSet.has(format))\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,mBAAmB,EAAEC,QAAQ,QAAQ;AAC9C,SAASC,SAAS,QAAQ;AAI1B,OAAO,SAAAC,WAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAoB;IAAAQ;EAAA,IAAAF,EAAmD;EAC5E,OAAAG,MAAA,IAAiBR,yBAAA;EAAA,IAAAS,EAAA;EAAA,IAAAH,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,QAAA,CAAAG,cAAA;IAEPD,EAAA,GAAAA,CAAA;MACR,MAAAE,eAAA,GAAwBC,kBAAA,CAAmBL,QAAA,CAAAG,cAAuB;MAAA,IAC9DC,eAAA,CAAAE,MAAA,MAA2B;QAAA;MAAA;MAAA,OAQxBL,MAAA,CAAAM,qBAAA,CAAAZ,QAAA,EAAAa,QAAA;QACLJ,eAAA,CAAAK,OAAA,CAAAC,cAAA;UAAA,IACMF,QAAA,CAAAG,SAAA,CAAmBD,cAAA;YACrBF,QAAA,CAAAI,YAAA,CAAsBF,cAAA;UAAA;QAAA,CAE1B;MAAA,CACF;IAAA;IACFX,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,QAAA,CAAAG,cAAA;IAAAJ,CAAA,MAAAG,EAAA;EAAA;IAAAA,EAAA,GAAAH,CAAA;EAAA;EAAA,IAAAc,EAAA;EAAA,IAAAd,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,QAAA;IAAGa,EAAA,IAACZ,MAAA,EAAQD,QAAA;IAASD,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,QAAA;IAAAD,CAAA,MAAAc,EAAA;EAAA;IAAAA,EAAA,GAAAd,CAAA;EAAA;EAjBrBH,SAAA,CAAUM,EAiBV,EAAGW,EAAkB;EAAA;AAAA;AAKvB,SAASR,mBAAmBF,cAAgC;EAC1D,MAAMW,UAAA,GAAaC,MAAA,CAAOC,IAAI,CAACtB,mBAAA;EAC/B,MAAMuB,UAAA,GAAa,IAAIC,GAAA,CAAIf,cAAA;EAE3B,OAAOW,UAAA,CAAWK,MAAM,CAAEC,MAAA,IAAW,CAACH,UAAA,CAAWI,GAAG,CAACD,MAAA;AACvD","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.39.0-canary.
|
|
3
|
+
"version": "3.39.0-canary.4",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -364,8 +364,8 @@
|
|
|
364
364
|
"react-error-boundary": "4.1.2",
|
|
365
365
|
"ts-essentials": "10.0.3",
|
|
366
366
|
"uuid": "10.0.0",
|
|
367
|
-
"@payloadcms/translations": "3.39.0-canary.
|
|
368
|
-
"@payloadcms/ui": "3.39.0-canary.
|
|
367
|
+
"@payloadcms/translations": "3.39.0-canary.4",
|
|
368
|
+
"@payloadcms/ui": "3.39.0-canary.4"
|
|
369
369
|
},
|
|
370
370
|
"devDependencies": {
|
|
371
371
|
"@babel/cli": "7.26.4",
|
|
@@ -383,18 +383,17 @@
|
|
|
383
383
|
"babel-plugin-transform-remove-imports": "^1.8.0",
|
|
384
384
|
"esbuild": "0.24.2",
|
|
385
385
|
"esbuild-sass-plugin": "3.3.1",
|
|
386
|
-
"eslint-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
|
387
386
|
"swc-plugin-transform-remove-imports": "3.1.0",
|
|
388
387
|
"@payloadcms/eslint-config": "3.28.0",
|
|
389
|
-
"payload": "3.39.0-canary.
|
|
388
|
+
"payload": "3.39.0-canary.4"
|
|
390
389
|
},
|
|
391
390
|
"peerDependencies": {
|
|
392
391
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
393
392
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
394
393
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
395
394
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
396
|
-
"@payloadcms/next": "3.39.0-canary.
|
|
397
|
-
"payload": "3.39.0-canary.
|
|
395
|
+
"@payloadcms/next": "3.39.0-canary.4",
|
|
396
|
+
"payload": "3.39.0-canary.4"
|
|
398
397
|
},
|
|
399
398
|
"engines": {
|
|
400
399
|
"node": "^18.20.2 || >=20.9.0"
|