@payloadcms/richtext-lexical 3.14.0 → 3.14.1-canary.2776826

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.
Files changed (29) hide show
  1. package/dist/exports/client/{Field-7ROJ5JAM.js → Field-JQ7ZTTEA.js} +2 -2
  2. package/dist/exports/client/chunk-QNRPT52J.js +2 -0
  3. package/dist/exports/client/chunk-QNRPT52J.js.map +7 -0
  4. package/dist/exports/client/{chunk-WCORQHZQ.js → chunk-ZD5FCKFR.js} +2 -2
  5. package/dist/exports/client/chunk-ZD5FCKFR.js.map +7 -0
  6. package/dist/exports/client/componentInline-TPGMZRGQ.js +2 -0
  7. package/dist/exports/client/index.js +11 -11
  8. package/dist/exports/client/index.js.map +3 -3
  9. package/dist/exports/react/components/RichText/index.d.ts +0 -1
  10. package/dist/exports/react/components/RichText/index.d.ts.map +1 -1
  11. package/dist/exports/react/components/RichText/index.js.map +1 -1
  12. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  13. package/dist/features/blocks/client/componentInline/index.js +9 -0
  14. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  15. package/dist/features/blocks/server/validate.js +1 -1
  16. package/dist/features/blocks/server/validate.js.map +1 -1
  17. package/dist/features/relationship/client/drawer/index.d.ts.map +1 -1
  18. package/dist/features/relationship/client/drawer/index.js +9 -30
  19. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  20. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -1
  21. package/dist/packages/@lexical/markdown/MarkdownExport.js +12 -1
  22. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -1
  23. package/package.json +6 -6
  24. package/dist/exports/client/chunk-4J2ONJMB.js +0 -2
  25. package/dist/exports/client/chunk-4J2ONJMB.js.map +0 -7
  26. package/dist/exports/client/chunk-WCORQHZQ.js.map +0 -7
  27. package/dist/exports/client/componentInline-B5YNOX32.js +0 -2
  28. /package/dist/exports/client/{Field-7ROJ5JAM.js.map → Field-JQ7ZTTEA.js.map} +0 -0
  29. /package/dist/exports/client/{componentInline-B5YNOX32.js.map → componentInline-TPGMZRGQ.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- "use client";import{c as fe,g as j,h as B,j as pe,k as ge,l as he,m as ye,n as xe}from"./chunk-WCORQHZQ.js";import{a as ue,b as R}from"./chunk-CUIBIFW2.js";import{jsx as F,jsxs as se}from"react/jsx-runtime";import{FieldDescription as eo,FieldError as to,FieldLabel as oo,RenderCustomComponent as Ze,useEditDepth as no,useField as ro}from"@payloadcms/ui";import{mergeFieldStyles as io}from"@payloadcms/ui/shared";import{useCallback as et,useMemo as so}from"react";import{ErrorBoundary as lo}from"react-error-boundary";import"./bundled.css";import{jsx as A}from"react/jsx-runtime";import{LexicalComposer as Xt}from"@lexical/react/LexicalComposer.js";import*as Je from"react";import{useMemo as Zt}from"react";import{c as $t}from"react/compiler-runtime";import{jsx as w,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Ht}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as jt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as zt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Kt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Gt}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Wt,COMMAND_PRIORITY_LOW as Ye,FOCUS_COMMAND as Yt}from"lexical";import*as Y from"react";import{useEffect as Ue,useState as Ve}from"react";import{jsx as Ee}from"react/jsx-runtime";import"react";var O=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ee(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ee(o.Component,{clientProps:e});import{jsx as ce}from"react/jsx-runtime";import{useLexicalComposerContext as st}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as lt}from"lexical";import*as Pe from"react";import{useCallback as at,useEffect as Ne,useRef as ct,useState as mt}from"react";import{createPortal as dt}from"react-dom";var z=(t,e,o,r,n=50,a=25)=>{let l=0;if(t&&!t.contains(r)){let{bottom:c,left:u,right:g,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,i=c+window.scrollY;if(o<s-a||o>i+a||e<u-n||e>g+n)return-1;(e<u||e>g)&&(l=e<u?e-u:e-g)}return l};import{$getNodeByKey as Z}from"lexical";function K(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 X(t){let e=(u,g)=>u?parseFloat(window.getComputedStyle(u)[g]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),a=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),a),marginTop:l}}import{$getRoot as tt}from"lexical";function _(t){return t.getEditorState().read(()=>tt().getChildrenKeys())}var ot=1,nt=-1,be=0,v={props:null,result:null};function rt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:a=0,point:{x:l,y:c},startIndex:u=0,useEdgeAsDefault:g=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&rt(v.props.point,t.point,o))return v.result;let y=e.getBoundingClientRect(),s=_(r),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(g){let[p,h]=[r.getElementByKey(s[0]),r.getElementByKey(s[s.length-1])];if(p&&h){let[f,m]=[K(p),K(h)];if(c<f.top?(i.blockElem=p,i.distance=f.top-c,i.blockNode=Z(s[0]),i.foundAtIndex=0):c>m.bottom&&(i.distance=c-m.bottom,i.blockNode=Z(s[s.length-1]),i.blockElem=h,i.foundAtIndex=s.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let d=u,x=be;for(;d>=0&&d<s.length;){let p=s[d],h=r.getElementByKey(p);if(h===null)break;let f=new B(l+a,c),m=ye.fromDOMRect(K(h)),{marginBottom:E,marginTop:b}=X(h),N=m.generateNewRect({bottom:m.bottom+E,left:y.left,right:y.right,top:m.top-b}),{distance:C,isOnBottomSide:k,isOnTopSide:P}=N.distanceFromPoint(f);if(C===0){i.blockElem=h,i.blockNode=Z(p),i.foundAtIndex=d,i.distance=C,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else n&&C<i.distance&&(i.blockElem=h,i.blockNode=Z(p),i.distance=C,i.foundAtIndex=d);x===be&&(P?x=nt:k?x=ot:x=1/0),d+=x}}),v.props=t,v.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var it=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ce(t){if(!t||it.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 te(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),a=window.getComputedStyle(t),l=e.getBoundingClientRect(),c=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))u=n.top+8-c.top;else{let s=Ce(t)?parseInt(a.lineHeight,10):0;u=n.top+(s-l.height)/2-c.top}let y=r;e.style.opacity="1",e.style.transform=`translate(${y}px, ${u}px)`}var ut="add-block-menu",oe=1/0;function ft(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function pt(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),a=n?.admin?.hideGutter?-24:12,l=ct(null),[c,u]=mt(null);Ne(()=>{function y(s){let i=s.target;if(!j(i))return;let d=z(r,s.pageX,s.pageY,i);if(d===-1){u(null);return}if(ee(i,ut))return;let x=_(t),{blockElem:p,blockNode:h,foundAtIndex:f}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-d,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:ft(x.length),useEdgeAsDefault:!1});oe=f,p&&h&&(c?.node!==h||c?.elem!==p)&&u({elem:p,node:h})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,c]),Ne(()=>{l.current&&c?.node&&te(c?.elem,l.current,e,a)},[e,c,a]);let g=at(y=>{let s=c;s?.node&&(t.update(()=>{let i=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(i=!1),!i){let d=lt();s?.node.insertAfter(d),setTimeout(()=>{s={elem:t.getElementByKey(d.getKey()),node:d},u(s)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),s?.node&&"select"in s.node&&typeof s.node.select=="function"&&s.node.select()})},1),setTimeout(()=>{t.dispatchCommand(ge,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,c]);return dt(ce(Pe.Fragment,{children:ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{g(y)},ref:l,type:"button",children:ce("div",{className:o?"icon":""})})}),e)}function we(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=st();return pt(r,o,r._editable)}import{jsx as ne,jsxs as ht}from"react/jsx-runtime";import{useLexicalComposerContext as yt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Se,$getNodeByKey as xt}from"lexical";import*as Ae from"react";import{useEffect as me,useRef as re,useState as ve}from"react";import{createPortal as Et}from"react-dom";var Te=0,gt=-24;var $=0;function Re(t,e,o,r,n,a,l,c,u,g=!1){let{height:y,top:s}=r.getBoundingClientRect(),{top:i,width:d}=l.getBoundingClientRect(),{marginBottom:x,marginTop:p}=X(r),h=s,f=a>=s+y/2+window.scrollY,m=!1;if(n?.elem)if(r!==n?.elem)(f&&n?.elem&&n?.elem===r.nextElementSibling||!f&&n?.elem&&n?.elem===r.previousElementSibling)&&($++,$<200&&(m=!0));else{$++;let C=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(f===n?.isBelow&&C===k||$<200)&&(m=!1)}if(m)return{isBelow:f,willStayInSamePosition:m};g?h+=y/2:f?h+=y+x/2:h-=p/2;let E=0;g||(f?E=-Te:E=Te);let b=h-i+E,N=gt-e;return o.style.width=`calc(${d}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?f?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),$=0,{isBelow:f,willStayInSamePosition:m}}var bt="draggable-block-menu",Me="application/x-lexical-drag-block",V=1/0;function Le(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function Ct(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Be(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Nt(t,e,o){let r=e.parentElement,n=re(null),a=re(null),l=re(null),c=re(!1),[u,g]=ve(null),[y,s]=ve(null),{editorConfig:i}=R(),d=i?.admin?.hideGutter?-44:-8;me(()=>{function h(f){let m=f.target;if(!j(m))return;let E=z(r,f.pageX,f.pageY,m);if(E===-1){g(null);return}if(ee(m,bt))return;let b=_(t),{blockElem:N,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(f.x,f.y),startIndex:Le(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!N&&!k)&&u!==N&&g(N)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,u]),me(()=>{n.current&&te(u,n.current,e,d)},[e,u,d]),me(()=>{function h(m){if(!c.current)return!1;let[E]=ke(m);if(E)return!1;let{pageY:b,target:N}=m;if(!j(N))return!1;let C=z(r,m.pageX,m.pageY,N,100,50),k=_(t),{blockElem:P,foundAtIndex:H,isFoundNodeEmptyParagraph:L}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(m.x,m.y),startIndex:Le(k.length),useEdgeAsDefault:!0,verbose:!0});V=H;let I=a.current;if(P===null||I===null)return!1;if(u!==P){let{isBelow:S,willStayInSamePosition:U}=Re(i?.admin?.hideGutter?"0px":"3rem",d+(i?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),I,P,y,b,e,m,l,L);m.preventDefault(),U||s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:S})}else y?.elem&&(Be(I,y.elem),s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:!1}));return!0}function f(m){if(!c.current)return!1;let[E]=ke(m);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=m,k=b?.getData(Me)||"";return t.update(()=>{let P=xt(k);if(!P||!j(C))return!1;let H=z(r,m.pageX,m.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-H,point:new B(m.x,m.y),useEdgeAsDefault:!0});if(!L)return!1;let S=Se(L);if(!S)return!1;if(S===P)return!0;let{height:U,top:J}=K(L),le=N>=J+U/2+window.scrollY;I?(S.insertBefore(P),S.remove()):le?S.insertAfter(P):S.insertBefore(P),u!==null&&g(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let ae=t.getElementByKey(P.getKey());setTimeout(()=>{let D=ae?.getBoundingClientRect();if(!D)return;let T=document.createElement("div");T.className="lexical-block-highlighter",T.style.backgroundColor="var(--theme-elevation-1000",T.style.transition="opacity 0.5s ease-in-out",T.style.zIndex="1",T.style.pointerEvents="none",T.style.boxSizing="border-box",T.style.borderRadius="4px",T.style.position="absolute",document.body.appendChild(T),T.style.opacity="0.1",T.style.height=`${D.height+8}px`,T.style.width=`${D.width+8}px`,T.style.top=`${D.top+window.scrollY-4}px`,T.style.left=`${D.left-4}px`,setTimeout(()=>{T.style.opacity="0",setTimeout(()=>{T.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",f)}},[r,d,e,t,y,u,i?.admin?.hideGutter]);function x(h){let f=h.dataTransfer;if(!f||!u)return;Ct(f,u);let m="";t.update(()=>{let E=Se(u);E&&(m=E.getKey())}),c.current=!0,f.setData(Me,m)}function p(){c.current=!1,y?.elem&&Be(a.current,y?.elem)}return Et(ht(Ae.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:p,onDragStart:x,ref:n,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:a}),ne("div",{className:"debug-highlight",ref:l})]}),e)}function Fe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=yt();return Nt(r,o,r._editable)}import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import*as Ie from"react";var De=()=>{let t=Pt(4),{editorConfig:e}=R(),[o]=wt(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>fe(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]),Ie.useEffect(r,n),null};import{jsx as W,jsxs as _e}from"react/jsx-runtime";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as $e}from"@payloadcms/ui";import{useCallback as kt,useMemo as St,useState as vt}from"react";import"react";import*as He from"react-dom";import{c as Tt}from"react/compiler-runtime";import"react";function Oe(t,e){let o=Tt(4),{maxLength:r,minLength:n}=e,a=r===void 0?75:r,l=n===void 0?1:n,c;return o[0]!==a||o[1]!==l||o[2]!==t?(c=u=>{let{query:g}=u,y="[^"+t+pe+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+a+"}))$").exec(g);if(i!==null){let d=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+d.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=a,o[1]=l,o[2]=t,o[3]=c):c=o[3],c}var M="slash-menu-popup";function Mt({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:a,schemaPath:l}}=R(),{i18n:c}=$e(),u=`${M}__item ${M}__item-${e.key}`;t&&(u+=` ${M}__item--selected`);let g=e.key;return e.label&&(g=typeof e.label=="function"?e.label({featureClientSchemaMap:a,i18n:c,schemaPath:l}):e.label),g.length>25&&(g=g.substring(0,25)+"..."),_e("button",{"aria-selected":t,className:u,id:M+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&W(e.Icon,{}),W("span",{className:`${M}__item-text`,children:g})]},e.key)}function je({anchorElem:t=document.body}){let[e]=Rt(),[o,r]=vt(null),{editorConfig:n}=R(),{i18n:a}=$e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:c}}=R(),u=Oe("/",{minLength:0}),g=kt(()=>{let s=[];for(let i of n.features.slashMenu.dynamicGroups)if(o){let d=i({editor:e,queryString:o});s=s.concat(d)}return s},[e,o,n?.features]),y=St(()=>{let s=[];for(let i of n?.features.slashMenu.groups??[])s.push(i);if(o){s=s.map(d=>{let x=d.items.filter(p=>{let h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:a,schemaPath:c}):p.label),new RegExp(o,"gi").exec(h)?!0:p.keywords!=null?p.keywords.some(f=>new RegExp(o,"gi").exec(f)):!1});return x.length?{...d,items:x}:null}),s=s.filter(d=>d!=null);let i=g();for(let d of i){let x=s.find(p=>p.key===d.key);x?s=s.filter(p=>p.key!==d.key):x={...d,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,n?.features.slashMenu.groups,g,l,a,c]);return W(he,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:i,selectItemAndCleanUp:d,setSelectedItemKey:x})=>s.current&&y.length?He.createPortal(W("div",{className:M,children:y.map(p=>{let h=p.key;return p.label&&l&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:a,schemaPath:c}):p.label),_e("div",{className:`${M}__group ${M}__group-${p.key}`,children:[W("div",{className:`${M}__group-title`,children:h}),p.items.map((f,m)=>W(Mt,{index:m,isSelected:i===f.key,item:f,onClick:()=>{x(f.key),d(f)},onMouseEnter:()=>{x(f.key)},ref:E=>{f.ref={current:E}}},f.key))]},p.key)})}),s.current):null,onQueryChange:r,triggerFn:u})}import{c as Lt}from"react/compiler-runtime";import{useLexicalComposerContext as Bt}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as ze,TextNode as At}from"lexical";import{useEffect as Ft}from"react";function Ke(t){let e=Lt(6),{features:o}=t,[r]=Bt(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let l=It(o.enabledFormats);if(l.length!==0)return r.registerNodeTransform(At,c=>{l.forEach(u=>{c.hasFormat(u)&&c.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let a;return e[3]!==r||e[4]!==o?(a=[r,o],e[3]=r,e[4]=o,e[5]=a):a=e[5],Ft(n,a),null}function It(t){delete ze.highlight;let e=Object.keys(ze),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Dt}from"react/compiler-runtime";import{jsx as Ge}from"react/jsx-runtime";import{ContentEditable as Ot}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as _t}from"@payloadcms/ui";import"react";function We(t){let e=Dt(7),{className:o,editorConfig:r}=t,{t:n}=_t(),a;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let l;e[4]!==r?.admin?.placeholder||e[5]!==n?(l=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=l):l=e[6],a=Ge(Ot,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ge("p",{className:"editor-placeholder",children:l})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=a}else a=e[3];return a}var qe=t=>{let e=$t(22),{editorConfig:o,editorContainerRef:r,onChange:n}=t,a=R(),[l]=Ht(),[c,u]=Ve(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&u(m)},e[0]=g):g=e[0];let y=g,s,i;e[1]!==l||e[2]!==a?(s=()=>{if(!a?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}a?.parentEditor?.uuid&&a.parentEditor?.registerChild(a.uuid,a);let m=()=>{a.focusEditor(a)},E=()=>{a.blurEditor(a)},b=l.registerCommand(Yt,()=>(m(),!0),Ye),N=l.registerCommand(Wt,()=>(E(),!0),Ye);return()=>{b(),N(),a.parentEditor?.unregisterChild?.(a.uuid)}},i=[l,a],e[1]=l,e[2]=a,e[3]=s,e[4]=i):(s=e[3],i=e[4]),Ue(s,i);let[d,x]=Ve(!1),p,h;e[5]!==d?(p=()=>{let m=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==d&&x(E)};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},h=[d],e[5]=d,e[6]=p,e[7]=h):(p=e[6],h=e[7]),Ue(p,h);let f;if(e[8]!==l||e[9]!==o||e[10]!==r||e[11]!==c||e[12]!==d||e[13]!==n){let m;e[15]!==n?(m=(b,N,C)=>{(!C.has("focus")||C.size>1)&&n?.(b,N,C)},e[15]=n,e[16]=m):m=e[16];let E;e[17]!==l||e[18]!==o.features.plugins||e[19]!==c||e[20]!==d?(E=c&&q(Y.Fragment,{children:[!d&&l.isEditable()&&q(Y.Fragment,{children:[w(Fe,{anchorElem:c}),w(we,{anchorElem:c})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&d))return w(O,{anchorElem:c,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&w(Y.Fragment,{children:w(je,{anchorElem:c})})]}),e[17]=l,e[18]=o.features.plugins,e[19]=c,e[20]=d,e[21]=E):E=e[21],f=q(Y.Fragment,{children:[o.features.plugins?.map(Ut),q("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Vt),w(Gt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:y,children:w(We,{editorConfig:o})})}),ErrorBoundary:jt}),w(Ke,{features:o.features}),w(Kt,{ignoreSelectionChange:!0,onChange:m}),E,l.isEditable()&&q(Y.Fragment,{children:[w(zt,{}),o?.features?.markdownTransformers?.length>0&&w(De,{})]}),o.features.plugins?.map(qt),o.features.plugins?.map(Jt)]}),o.features.plugins?.map(Qt)]}),e[8]=l,e[9]=o,e[10]=r,e[11]=c,e[12]=d,e[13]=n,e[14]=f}else f=e[14];return f};function Ut(t){if(t.position==="aboveContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Vt(t){if(t.position==="top")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function qt(t){if(t.position==="normal")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Jt(t){if(t.position==="bottom")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Qt(t){if(t.position==="belowContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}var Qe=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?A(o,{children:A(Qe,{providers:e.slice(1),children:t})}):A(o,{children:t})},Xe=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,onChange:n,readOnly:a,value:l}=t,c=R(),u=Je.useRef(null),g=Zt(()=>{if(l&&typeof l!="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(l));if(l&&Array.isArray(l)&&!("root"in l))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(l&&"jsonContent"in l)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:a!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:xe({editorConfig:o}),onError:y=>{throw y},theme:o.lexical.theme}},[o]);return g?A(Xt,{initialConfig:g,children:A(ue,{editorConfig:o,editorContainerRef:u,fieldProps:r,parentContext:c,children:A(Qe,{providers:o.features.providers,children:A(qe,{editorConfig:o,editorContainerRef:u,onChange:n})})})},e+g.editable):A("p",{children:"Loading..."})};var ie="rich-text-lexical",ao=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:a,readOnly:l}={},label:c,localized:u,required:g},path:y,readOnly:s,validate:i}=t,d=s||l,x=y??r,p=no(),h=et((Q,ae)=>typeof i=="function"?i(Q,{...ae,required:g}):!0,[i,g]),{customComponents:{AfterInput:f,BeforeInput:m,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:k,initialValue:P,setValue:H,showError:L,value:I}=ro({path:x,validate:h}),S=d||k||C,U=[ie,"field-type",n,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${p}`,de=et(Q=>{H(Q.toJSON())},[H]),le=so(()=>io(o),[o]);return se("div",{className:U,style:le,children:[F(Ze,{CustomComponent:b,Fallback:F(to,{path:x,showError:L})}),N||F(oo,{label:c,localized:u,path:x,required:g}),se("div",{className:`${ie}__wrap`,children:[se(lo,{fallbackRender:co,onReset:()=>{},children:[m,F(Xe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:de,readOnly:S,value:I},JSON.stringify({initialValue:P,path:x})),f]}),E,F(Ze,{CustomComponent:E,Fallback:F(eo,{description:a,path:x})})]})]},J)};function co({error:t}){return se("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Cr=ao;export{Cr as RichText};
2
- //# sourceMappingURL=Field-7ROJ5JAM.js.map
1
+ "use client";import{c as fe,g as j,h as B,j as pe,k as ge,l as he,m as ye,n as xe}from"./chunk-ZD5FCKFR.js";import{a as ue,b as R}from"./chunk-CUIBIFW2.js";import{jsx as F,jsxs as se}from"react/jsx-runtime";import{FieldDescription as eo,FieldError as to,FieldLabel as oo,RenderCustomComponent as Ze,useEditDepth as no,useField as ro}from"@payloadcms/ui";import{mergeFieldStyles as io}from"@payloadcms/ui/shared";import{useCallback as et,useMemo as so}from"react";import{ErrorBoundary as lo}from"react-error-boundary";import"./bundled.css";import{jsx as A}from"react/jsx-runtime";import{LexicalComposer as Xt}from"@lexical/react/LexicalComposer.js";import*as Je from"react";import{useMemo as Zt}from"react";import{c as $t}from"react/compiler-runtime";import{jsx as w,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Ht}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as jt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as zt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Kt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Gt}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Wt,COMMAND_PRIORITY_LOW as Ye,FOCUS_COMMAND as Yt}from"lexical";import*as Y from"react";import{useEffect as Ue,useState as Ve}from"react";import{jsx as Ee}from"react/jsx-runtime";import"react";var O=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ee(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ee(o.Component,{clientProps:e});import{jsx as ce}from"react/jsx-runtime";import{useLexicalComposerContext as st}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as lt}from"lexical";import*as Pe from"react";import{useCallback as at,useEffect as Ne,useRef as ct,useState as mt}from"react";import{createPortal as dt}from"react-dom";var z=(t,e,o,r,n=50,a=25)=>{let l=0;if(t&&!t.contains(r)){let{bottom:c,left:u,right:g,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,i=c+window.scrollY;if(o<s-a||o>i+a||e<u-n||e>g+n)return-1;(e<u||e>g)&&(l=e<u?e-u:e-g)}return l};import{$getNodeByKey as Z}from"lexical";function K(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 X(t){let e=(u,g)=>u?parseFloat(window.getComputedStyle(u)[g]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),a=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),a),marginTop:l}}import{$getRoot as tt}from"lexical";function _(t){return t.getEditorState().read(()=>tt().getChildrenKeys())}var ot=1,nt=-1,be=0,v={props:null,result:null};function rt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:a=0,point:{x:l,y:c},startIndex:u=0,useEdgeAsDefault:g=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&rt(v.props.point,t.point,o))return v.result;let y=e.getBoundingClientRect(),s=_(r),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(g){let[p,h]=[r.getElementByKey(s[0]),r.getElementByKey(s[s.length-1])];if(p&&h){let[f,m]=[K(p),K(h)];if(c<f.top?(i.blockElem=p,i.distance=f.top-c,i.blockNode=Z(s[0]),i.foundAtIndex=0):c>m.bottom&&(i.distance=c-m.bottom,i.blockNode=Z(s[s.length-1]),i.blockElem=h,i.foundAtIndex=s.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let d=u,x=be;for(;d>=0&&d<s.length;){let p=s[d],h=r.getElementByKey(p);if(h===null)break;let f=new B(l+a,c),m=ye.fromDOMRect(K(h)),{marginBottom:E,marginTop:b}=X(h),N=m.generateNewRect({bottom:m.bottom+E,left:y.left,right:y.right,top:m.top-b}),{distance:C,isOnBottomSide:k,isOnTopSide:P}=N.distanceFromPoint(f);if(C===0){i.blockElem=h,i.blockNode=Z(p),i.foundAtIndex=d,i.distance=C,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else n&&C<i.distance&&(i.blockElem=h,i.blockNode=Z(p),i.distance=C,i.foundAtIndex=d);x===be&&(P?x=nt:k?x=ot:x=1/0),d+=x}}),v.props=t,v.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var it=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ce(t){if(!t||it.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 te(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),a=window.getComputedStyle(t),l=e.getBoundingClientRect(),c=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))u=n.top+8-c.top;else{let s=Ce(t)?parseInt(a.lineHeight,10):0;u=n.top+(s-l.height)/2-c.top}let y=r;e.style.opacity="1",e.style.transform=`translate(${y}px, ${u}px)`}var ut="add-block-menu",oe=1/0;function ft(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function pt(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),a=n?.admin?.hideGutter?-24:12,l=ct(null),[c,u]=mt(null);Ne(()=>{function y(s){let i=s.target;if(!j(i))return;let d=z(r,s.pageX,s.pageY,i);if(d===-1){u(null);return}if(ee(i,ut))return;let x=_(t),{blockElem:p,blockNode:h,foundAtIndex:f}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-d,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:ft(x.length),useEdgeAsDefault:!1});oe=f,p&&h&&(c?.node!==h||c?.elem!==p)&&u({elem:p,node:h})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,c]),Ne(()=>{l.current&&c?.node&&te(c?.elem,l.current,e,a)},[e,c,a]);let g=at(y=>{let s=c;s?.node&&(t.update(()=>{let i=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(i=!1),!i){let d=lt();s?.node.insertAfter(d),setTimeout(()=>{s={elem:t.getElementByKey(d.getKey()),node:d},u(s)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),s?.node&&"select"in s.node&&typeof s.node.select=="function"&&s.node.select()})},1),setTimeout(()=>{t.dispatchCommand(ge,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,c]);return dt(ce(Pe.Fragment,{children:ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{g(y)},ref:l,type:"button",children:ce("div",{className:o?"icon":""})})}),e)}function we(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=st();return pt(r,o,r._editable)}import{jsx as ne,jsxs as ht}from"react/jsx-runtime";import{useLexicalComposerContext as yt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as ke}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Se,$getNodeByKey as xt}from"lexical";import*as Ae from"react";import{useEffect as me,useRef as re,useState as ve}from"react";import{createPortal as Et}from"react-dom";var Te=0,gt=-24;var $=0;function Re(t,e,o,r,n,a,l,c,u,g=!1){let{height:y,top:s}=r.getBoundingClientRect(),{top:i,width:d}=l.getBoundingClientRect(),{marginBottom:x,marginTop:p}=X(r),h=s,f=a>=s+y/2+window.scrollY,m=!1;if(n?.elem)if(r!==n?.elem)(f&&n?.elem&&n?.elem===r.nextElementSibling||!f&&n?.elem&&n?.elem===r.previousElementSibling)&&($++,$<200&&(m=!0));else{$++;let C=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(f===n?.isBelow&&C===k||$<200)&&(m=!1)}if(m)return{isBelow:f,willStayInSamePosition:m};g?h+=y/2:f?h+=y+x/2:h-=p/2;let E=0;g||(f?E=-Te:E=Te);let b=h-i+E,N=gt-e;return o.style.width=`calc(${d}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${N}px, calc(${b}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?f?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),$=0,{isBelow:f,willStayInSamePosition:m}}var bt="draggable-block-menu",Me="application/x-lexical-drag-block",V=1/0;function Le(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function Ct(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Be(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Nt(t,e,o){let r=e.parentElement,n=re(null),a=re(null),l=re(null),c=re(!1),[u,g]=ve(null),[y,s]=ve(null),{editorConfig:i}=R(),d=i?.admin?.hideGutter?-44:-8;me(()=>{function h(f){let m=f.target;if(!j(m))return;let E=z(r,f.pageX,f.pageY,m);if(E===-1){g(null);return}if(ee(m,bt))return;let b=_(t),{blockElem:N,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(f.x,f.y),startIndex:Le(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!N&&!k)&&u!==N&&g(N)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,u]),me(()=>{n.current&&te(u,n.current,e,d)},[e,u,d]),me(()=>{function h(m){if(!c.current)return!1;let[E]=ke(m);if(E)return!1;let{pageY:b,target:N}=m;if(!j(N))return!1;let C=z(r,m.pageX,m.pageY,N,100,50),k=_(t),{blockElem:P,foundAtIndex:H,isFoundNodeEmptyParagraph:L}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(m.x,m.y),startIndex:Le(k.length),useEdgeAsDefault:!0,verbose:!0});V=H;let I=a.current;if(P===null||I===null)return!1;if(u!==P){let{isBelow:S,willStayInSamePosition:U}=Re(i?.admin?.hideGutter?"0px":"3rem",d+(i?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),I,P,y,b,e,m,l,L);m.preventDefault(),U||s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:S})}else y?.elem&&(Be(I,y.elem),s({boundingBox:P.getBoundingClientRect(),elem:P,isBelow:!1}));return!0}function f(m){if(!c.current)return!1;let[E]=ke(m);if(E)return!1;let{dataTransfer:b,pageY:N,target:C}=m,k=b?.getData(Me)||"";return t.update(()=>{let P=xt(k);if(!P||!j(C))return!1;let H=z(r,m.pageX,m.pageY,C,100,50),{blockElem:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-H,point:new B(m.x,m.y),useEdgeAsDefault:!0});if(!L)return!1;let S=Se(L);if(!S)return!1;if(S===P)return!0;let{height:U,top:J}=K(L),le=N>=J+U/2+window.scrollY;I?(S.insertBefore(P),S.remove()):le?S.insertAfter(P):S.insertBefore(P),u!==null&&g(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let ae=t.getElementByKey(P.getKey());setTimeout(()=>{let D=ae?.getBoundingClientRect();if(!D)return;let T=document.createElement("div");T.className="lexical-block-highlighter",T.style.backgroundColor="var(--theme-elevation-1000",T.style.transition="opacity 0.5s ease-in-out",T.style.zIndex="1",T.style.pointerEvents="none",T.style.boxSizing="border-box",T.style.borderRadius="4px",T.style.position="absolute",document.body.appendChild(T),T.style.opacity="0.1",T.style.height=`${D.height+8}px`,T.style.width=`${D.width+8}px`,T.style.top=`${D.top+window.scrollY-4}px`,T.style.left=`${D.left-4}px`,setTimeout(()=>{T.style.opacity="0",setTimeout(()=>{T.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",f)}},[r,d,e,t,y,u,i?.admin?.hideGutter]);function x(h){let f=h.dataTransfer;if(!f||!u)return;Ct(f,u);let m="";t.update(()=>{let E=Se(u);E&&(m=E.getKey())}),c.current=!0,f.setData(Me,m)}function p(){c.current=!1,y?.elem&&Be(a.current,y?.elem)}return Et(ht(Ae.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:p,onDragStart:x,ref:n,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:a}),ne("div",{className:"debug-highlight",ref:l})]}),e)}function Fe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=yt();return Nt(r,o,r._editable)}import{c as Pt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import*as Ie from"react";var De=()=>{let t=Pt(4),{editorConfig:e}=R(),[o]=wt(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>fe(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]),Ie.useEffect(r,n),null};import{jsx as W,jsxs as _e}from"react/jsx-runtime";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as $e}from"@payloadcms/ui";import{useCallback as kt,useMemo as St,useState as vt}from"react";import"react";import*as He from"react-dom";import{c as Tt}from"react/compiler-runtime";import"react";function Oe(t,e){let o=Tt(4),{maxLength:r,minLength:n}=e,a=r===void 0?75:r,l=n===void 0?1:n,c;return o[0]!==a||o[1]!==l||o[2]!==t?(c=u=>{let{query:g}=u,y="[^"+t+pe+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+a+"}))$").exec(g);if(i!==null){let d=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+d.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=a,o[1]=l,o[2]=t,o[3]=c):c=o[3],c}var M="slash-menu-popup";function Mt({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:a,schemaPath:l}}=R(),{i18n:c}=$e(),u=`${M}__item ${M}__item-${e.key}`;t&&(u+=` ${M}__item--selected`);let g=e.key;return e.label&&(g=typeof e.label=="function"?e.label({featureClientSchemaMap:a,i18n:c,schemaPath:l}):e.label),g.length>25&&(g=g.substring(0,25)+"..."),_e("button",{"aria-selected":t,className:u,id:M+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&W(e.Icon,{}),W("span",{className:`${M}__item-text`,children:g})]},e.key)}function je({anchorElem:t=document.body}){let[e]=Rt(),[o,r]=vt(null),{editorConfig:n}=R(),{i18n:a}=$e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:c}}=R(),u=Oe("/",{minLength:0}),g=kt(()=>{let s=[];for(let i of n.features.slashMenu.dynamicGroups)if(o){let d=i({editor:e,queryString:o});s=s.concat(d)}return s},[e,o,n?.features]),y=St(()=>{let s=[];for(let i of n?.features.slashMenu.groups??[])s.push(i);if(o){s=s.map(d=>{let x=d.items.filter(p=>{let h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:a,schemaPath:c}):p.label),new RegExp(o,"gi").exec(h)?!0:p.keywords!=null?p.keywords.some(f=>new RegExp(o,"gi").exec(f)):!1});return x.length?{...d,items:x}:null}),s=s.filter(d=>d!=null);let i=g();for(let d of i){let x=s.find(p=>p.key===d.key);x?s=s.filter(p=>p.key!==d.key):x={...d,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,n?.features.slashMenu.groups,g,l,a,c]);return W(he,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:i,selectItemAndCleanUp:d,setSelectedItemKey:x})=>s.current&&y.length?He.createPortal(W("div",{className:M,children:y.map(p=>{let h=p.key;return p.label&&l&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:a,schemaPath:c}):p.label),_e("div",{className:`${M}__group ${M}__group-${p.key}`,children:[W("div",{className:`${M}__group-title`,children:h}),p.items.map((f,m)=>W(Mt,{index:m,isSelected:i===f.key,item:f,onClick:()=>{x(f.key),d(f)},onMouseEnter:()=>{x(f.key)},ref:E=>{f.ref={current:E}}},f.key))]},p.key)})}),s.current):null,onQueryChange:r,triggerFn:u})}import{c as Lt}from"react/compiler-runtime";import{useLexicalComposerContext as Bt}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as ze,TextNode as At}from"lexical";import{useEffect as Ft}from"react";function Ke(t){let e=Lt(6),{features:o}=t,[r]=Bt(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let l=It(o.enabledFormats);if(l.length!==0)return r.registerNodeTransform(At,c=>{l.forEach(u=>{c.hasFormat(u)&&c.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let a;return e[3]!==r||e[4]!==o?(a=[r,o],e[3]=r,e[4]=o,e[5]=a):a=e[5],Ft(n,a),null}function It(t){delete ze.highlight;let e=Object.keys(ze),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Dt}from"react/compiler-runtime";import{jsx as Ge}from"react/jsx-runtime";import{ContentEditable as Ot}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as _t}from"@payloadcms/ui";import"react";function We(t){let e=Dt(7),{className:o,editorConfig:r}=t,{t:n}=_t(),a;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let l;e[4]!==r?.admin?.placeholder||e[5]!==n?(l=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=l):l=e[6],a=Ge(Ot,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ge("p",{className:"editor-placeholder",children:l})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=a}else a=e[3];return a}var qe=t=>{let e=$t(22),{editorConfig:o,editorContainerRef:r,onChange:n}=t,a=R(),[l]=Ht(),[c,u]=Ve(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&u(m)},e[0]=g):g=e[0];let y=g,s,i;e[1]!==l||e[2]!==a?(s=()=>{if(!a?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}a?.parentEditor?.uuid&&a.parentEditor?.registerChild(a.uuid,a);let m=()=>{a.focusEditor(a)},E=()=>{a.blurEditor(a)},b=l.registerCommand(Yt,()=>(m(),!0),Ye),N=l.registerCommand(Wt,()=>(E(),!0),Ye);return()=>{b(),N(),a.parentEditor?.unregisterChild?.(a.uuid)}},i=[l,a],e[1]=l,e[2]=a,e[3]=s,e[4]=i):(s=e[3],i=e[4]),Ue(s,i);let[d,x]=Ve(!1),p,h;e[5]!==d?(p=()=>{let m=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==d&&x(E)};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},h=[d],e[5]=d,e[6]=p,e[7]=h):(p=e[6],h=e[7]),Ue(p,h);let f;if(e[8]!==l||e[9]!==o||e[10]!==r||e[11]!==c||e[12]!==d||e[13]!==n){let m;e[15]!==n?(m=(b,N,C)=>{(!C.has("focus")||C.size>1)&&n?.(b,N,C)},e[15]=n,e[16]=m):m=e[16];let E;e[17]!==l||e[18]!==o.features.plugins||e[19]!==c||e[20]!==d?(E=c&&q(Y.Fragment,{children:[!d&&l.isEditable()&&q(Y.Fragment,{children:[w(Fe,{anchorElem:c}),w(we,{anchorElem:c})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&d))return w(O,{anchorElem:c,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&w(Y.Fragment,{children:w(je,{anchorElem:c})})]}),e[17]=l,e[18]=o.features.plugins,e[19]=c,e[20]=d,e[21]=E):E=e[21],f=q(Y.Fragment,{children:[o.features.plugins?.map(Ut),q("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Vt),w(Gt,{contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:y,children:w(We,{editorConfig:o})})}),ErrorBoundary:jt}),w(Ke,{features:o.features}),w(Kt,{ignoreSelectionChange:!0,onChange:m}),E,l.isEditable()&&q(Y.Fragment,{children:[w(zt,{}),o?.features?.markdownTransformers?.length>0&&w(De,{})]}),o.features.plugins?.map(qt),o.features.plugins?.map(Jt)]}),o.features.plugins?.map(Qt)]}),e[8]=l,e[9]=o,e[10]=r,e[11]=c,e[12]=d,e[13]=n,e[14]=f}else f=e[14];return f};function Ut(t){if(t.position==="aboveContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Vt(t){if(t.position==="top")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function qt(t){if(t.position==="normal")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Jt(t){if(t.position==="bottom")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}function Qt(t){if(t.position==="belowContainer")return w(O,{clientProps:t.clientProps,plugin:t},t.key)}var Qe=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?A(o,{children:A(Qe,{providers:e.slice(1),children:t})}):A(o,{children:t})},Xe=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,onChange:n,readOnly:a,value:l}=t,c=R(),u=Je.useRef(null),g=Zt(()=>{if(l&&typeof l!="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(l));if(l&&Array.isArray(l)&&!("root"in l))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(l&&"jsonContent"in l)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:a!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:xe({editorConfig:o}),onError:y=>{throw y},theme:o.lexical.theme}},[o]);return g?A(Xt,{initialConfig:g,children:A(ue,{editorConfig:o,editorContainerRef:u,fieldProps:r,parentContext:c,children:A(Qe,{providers:o.features.providers,children:A(qe,{editorConfig:o,editorContainerRef:u,onChange:n})})})},e+g.editable):A("p",{children:"Loading..."})};var ie="rich-text-lexical",ao=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:a,readOnly:l}={},label:c,localized:u,required:g},path:y,readOnly:s,validate:i}=t,d=s||l,x=y??r,p=no(),h=et((Q,ae)=>typeof i=="function"?i(Q,{...ae,required:g}):!0,[i,g]),{customComponents:{AfterInput:f,BeforeInput:m,Description:E,Error:b,Label:N}={},formInitializing:C,formProcessing:k,initialValue:P,setValue:H,showError:L,value:I}=ro({path:x,validate:h}),S=d||k||C,U=[ie,"field-type",n,L&&"error",S&&`${ie}--read-only`,e?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" "),J=`${x}.${p}`,de=et(Q=>{H(Q.toJSON())},[H]),le=so(()=>io(o),[o]);return se("div",{className:U,style:le,children:[F(Ze,{CustomComponent:b,Fallback:F(to,{path:x,showError:L})}),N||F(oo,{label:c,localized:u,path:x,required:g}),se("div",{className:`${ie}__wrap`,children:[se(lo,{fallbackRender:co,onReset:()=>{},children:[m,F(Xe,{composerKey:J,editorConfig:e,fieldProps:t,onChange:de,readOnly:S,value:I},JSON.stringify({initialValue:P,path:x})),f]}),E,F(Ze,{CustomComponent:E,Fallback:F(eo,{description:a,path:x})})]})]},J)};function co({error:t}){return se("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var Cr=ao;export{Cr as RichText};
2
+ //# sourceMappingURL=Field-JQ7ZTTEA.js.map
@@ -0,0 +1,2 @@
1
+ import{a as te}from"./chunk-INBEEENE.js";import{b as ee}from"./chunk-CUIBIFW2.js";import{jsx as i,jsxs as N,Fragment as _e}from"react/jsx-runtime";import F,{createContext as Be,useCallback as k,useEffect as w,useMemo as v,useRef as A}from"react";import{useLexicalComposerContext as De}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as ye}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as Ie}from"@lexical/utils";import{getTranslation as ne}from"@payloadcms/translations";import{Button as oe,Drawer as Ne,EditDepthProvider as we,Form as ve,formatDrawerSlug as Fe,FormSubmit as Oe,RenderFields as $e,ShimmerEffect as Ee,useDocumentInfo as Me,useEditDepth as Pe,useServerFunctions as Le,useTranslation as Te}from"@payloadcms/ui";import{abortAndIgnore as R}from"@payloadcms/ui/shared";import{$getNodeByKey as re,$getSelection as Ae,$isNodeSelection as Re,CLICK_COMMAND as je,COMMAND_PRIORITY_LOW as j,KEY_BACKSPACE_COMMAND as Ke,KEY_DELETE_COMMAND as Je}from"lexical";import{reduceFieldsToValues as ze}from"payload/shared";import{v4 as Ye}from"uuid";import{jsx as ke}from"react/jsx-runtime";import Ce from"bson-objectid";import he from"react";import pe from"bson-objectid";import{DecoratorNode as be}from"lexical";var g=class extends be{__fields;constructor({fields:e,key:n}){super(n),this.__fields=e}static clone(e){return new this({fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return ge(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(){let e=document.createElement("span");return e.classList.add("inline-block-container"),e}decorate(e,n){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let n=document.createTextNode(this.getTextContent());return e.append(n),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e){let n=this.getWritable();n.__fields=e}updateDOM(){return!1}};function ge(r){return new g({fields:{...r,id:r?.id||new pe.default().toHexString()}})}var xe=he.lazy(()=>import("./componentInline-TPGMZRGQ.js").then(r=>({default:r.InlineBlockComponent}))),I=class extends g{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return Se(e.fields)}decorate(e,n){return ke(xe,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Se(r){return new I({fields:{...r,id:r?.id||new Ce.default().toHexString()}})}function T(r){return r instanceof I}var m="inline-block",le=Be({initialState:!1}),bt=()=>F.useContext(le),gt=r=>{let{formData:e,nodeKey:n}=r,[s]=De(),{i18n:O,t:d}=Te(),{fieldProps:{featureClientSchemaMap:ie,initialLexicalFormState:se,permissions:ce,readOnly:C,schemaPath:K},uuid:ae}=ee(),{getFormState:h}=Le(),ue=Pe(),J=A(!1),[a,de]=F.useState(se?.[e.id]?.formState),[$,z]=F.useState(a?._components?.customComponents?.BlockLabel),[Y,H]=F.useState(a?._components?.customComponents?.Block),V=Fe({slug:`lexical-inlineBlocks-create-${ae}-${e.id}`,depth:ue}),{toggleDrawer:f}=te(V,!0),E=A(null),[u,x,M]=ye(n),{id:S,collectionSlug:_,getDocPreferences:B,globalSlug:D}=Me(),me=`${K}.lexical_internal_feature.blocks.lexical_inline_blocks.${e.blockType}`,c=ie.blocks[me][0].blocks[0];w(()=>{!J.current&&c.fields.length>2&&(f(),J.current=!0)},[c,f]);let W=k(()=>{s.update(()=>{re(n)?.remove()})},[s,n]),P=k(t=>{let l=Ae();return u&&Re(l)&&(t.preventDefault(),s.update(()=>{l.getNodes().forEach(o=>{T(o)&&o.remove()})})),!1},[s,u]),q=k(t=>{let l=t;return l.target===E.current||E.current?.contains(l.target)?(l.shiftKey?x(!u):u||(M(),x(!0)),!0):!1},[u,x,M]);w(()=>Ie(s.registerCommand(je,q,j),s.registerCommand(Je,P,j),s.registerCommand(Ke,P,j)),[M,s,u,n,P,x,q]);let p=c?.labels?.singular?ne(c.labels.singular,O):c?.slug,L=A(new AbortController),b=`${K}.lexical_internal_feature.blocks.lexical_inline_blocks.${c?.slug}.fields`;w(()=>{let t=new AbortController;return e&&!a&&(async()=>{let{state:o}=await h({id:S,collectionSlug:_,data:e,docPermissions:{fields:!0},docPreferences:await B(),globalSlug:D,operation:"update",renderAllFields:!0,schemaPath:b,signal:t.signal});o&&(de(o),z(o._components?.customComponents?.BlockLabel),H(o._components?.customComponents?.Block))})(),()=>{R(t)}},[h,b,S,e,a,_,D,B]);let G=k(async({formState:t,submit:l})=>{R(L.current);let o=new AbortController;L.current=o;let{state:y}=await h({id:S,collectionSlug:_,docPermissions:{fields:!0},docPreferences:await B(),formState:t,globalSlug:D,operation:"update",renderAllFields:!!l,schemaPath:b,signal:o.signal});return y?(l&&(z(y._components?.customComponents?.BlockLabel),H(y._components?.customComponents?.Block)),y):t},[h,S,_,B,D,b]);w(()=>()=>{R(L.current)},[]);let fe=k(t=>{let l=ze(t);l.blockType=e.blockType,s.update(()=>{let o=re(n);o&&T(o)&&o.setFields(l)})},[s,n,e]),Q=v(()=>()=>i(oe,{buttonStyle:"icon-label",className:`${m}__removeButton`,disabled:C,icon:"x",onClick:t=>{t.preventDefault(),W()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:remove",{label:p})}),[p,C,W,d]),U=v(()=>()=>i(oe,{buttonStyle:"icon-label",className:`${m}__editButton`,disabled:C,el:"button",icon:"edit",onClick:()=>{f()},round:!0,size:"small",tooltip:d("lexical:blocks:inlineBlocks:edit",{label:p})}),[p,C,d,f]),X=v(()=>({children:t})=>i("div",{className:[m,m+"-"+e.blockType,u&&`${m}--selected`].filter(Boolean).join(" "),ref:E,children:t}),[e.blockType,u]),Z=v(()=>$?()=>$:()=>i("div",{children:ne(c.labels.singular,O)}),[$,c.labels,O]);return N(ve,{beforeSubmit:[async({formState:t})=>await G({formState:t,submit:!0})],disableValidationOnSubmit:!0,fields:c.fields,initialState:a||{},onChange:[G],onSubmit:t=>{fe(t),f()},uuid:Ye(),children:[i(we,{children:i(Ne,{className:"",slug:V,title:d(`lexical:blocks:inlineBlocks:${e?.id?"edit":"create"}`,{label:p??d("lexical:blocks:inlineBlocks:label")}),children:a?N(_e,{children:[i($e,{fields:c.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:b,permissions:ce,readOnly:!1}),i(Oe,{programmaticSubmit:!0,children:d("fields:saveChanges")})]}):null})}),Y?i(le.Provider,{value:{EditButton:U,initialState:a,InlineBlockContainer:X,Label:Z,nodeKey:n,RemoveButton:Q},children:Y}):N(X,{children:[a?i(Z,{}):i(Ee,{height:"15px",width:"40px"}),s.isEditable()?N("div",{className:`${m}__actions`,children:[i(U,{}),i(Q,{})]}):null]})]})};export{bt as a,gt as b,I as c,Se as d,T as e};
2
+ //# sourceMappingURL=chunk-QNRPT52J.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
4
+ "sourcesContent": ["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const hasMounted = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[\n componentMapRenderedBlockPath\n ][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n // Open drawer on mount\n useEffect(() => {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (!hasMounted.current && clientBlock.fields.length > 2) {\n toggleDrawer()\n hasMounted.current = true\n }\n }, [clientBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, 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 )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n formState: prevFormState,\n globalSlug,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n fields={clientBlock.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport type { EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields<TBlockFields>\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const writable = this.getWritable()\n writable.__fields = fields\n }\n\n updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
5
+ "mappings": "mJAEA,OAAOA,GAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,MAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,2BAAAA,OAA+B,yCACxC,OAASC,iBAAAA,OAAqB,iBAC9B,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAA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 "names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "useLexicalNodeSelection", "mergeRegister", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "$getSelection", "$isNodeSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "React", "ObjectID", "DecoratorNode", "ServerInlineBlockNode", "__fields", "constructor", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getLatest", "setFields", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "editor", "config", "_jsx", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "useContext", "InlineBlockComponent", "props", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "permissions", "readOnly", "schemaPath", "uuid", "uuidFromContext", "useEditorConfigContext", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "hasMounted", "useRef", "setInitialState", "useState", "id", "formState", "CustomLabel", "setCustomLabel", "customComponents", "BlockLabel", "CustomBlock", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "isSelected", "setSelected", "clearSelection", "useLexicalNodeSelection", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "componentMapRenderedBlockPath", "blockType", "clientBlock", "blocks", "useEffect", "current", "fields", "length", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "$onDelete", "event", "deleteSelection", "$getSelection", "$isNodeSelection", "preventDefault", "getNodes", "forEach", "node", "$isInlineBlockNode", "onClick", "payload", "target", "contains", "shiftKey", "mergeRegister", "registerCommand", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_DELETE_COMMAND", "KEY_BACKSPACE_COMMAND", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "docPreferences", "operation", "renderAllFields", "signal", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "onFormSubmit", "newData", "reduceFieldsToValues", "setFields", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "e", "round", "size", "tooltip", "label", "EditButton", "el", "InlineBlockContainer", "children", "filter", "Boolean", "join", "ref", "Label", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "title", "_Fragment", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "FormSubmit", "programmaticSubmit", "Provider", "value", "ShimmerEffect", "height", "width", "isEditable"]
7
+ }
@@ -1,5 +1,5 @@
1
1
  var C=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pn(r){return r instanceof HTMLElement}var j=class{_x;_y;constructor(t,e){this._x=t,this._y=e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}equals({x:t,y:e}){return this.x===t&&this.y===e}get x(){return this._x}get y(){return this._y}};function ft(r){return r instanceof j}import{c as Ce}from"react/compiler-runtime";import{jsx as Re}from"react/jsx-runtime";import{useLexicalComposerContext as Ie}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Fe}from"@lexical/utils";import{$getSelection as Z,$isRangeSelection as J,$isTextNode as Ne,COMMAND_PRIORITY_LOW as Ae,createCommand as ye}from"lexical";import{useEffect as _t,useState as Oe}from"react";import*as V from"react";import{c as pt}from"react/compiler-runtime";import{useLexicalComposerContext as ht}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ut}from"@lexical/utils";import{$getSelection as se,$isRangeSelection as ae,COMMAND_PRIORITY_LOW as M,createCommand as ce,KEY_ARROW_DOWN_COMMAND as le,KEY_ARROW_UP_COMMAND as fe,KEY_ENTER_COMMAND as ue,KEY_ESCAPE_COMMAND as de,KEY_TAB_COMMAND as me}from"lexical";import{useCallback as q,useEffect as L,useLayoutEffect as ge,useMemo as pe,useRef as he,useState as xe}from"react";var Ee="slash-menu-popup",dt=r=>{let t=document.getElementById("slash-menu");if(!t)return;let e=t.getBoundingClientRect();e.top+e.height>window.innerHeight&&t.scrollIntoView({block:"center"}),e.top<0&&t.scrollIntoView({block:"center"}),r.scrollIntoView({block:"nearest"})};function _e(r,t,e){let n=e;for(let o=n;o<=t.length;o++)r.substring(r.length-o)===t.substring(0,o)&&(n=o);return n}function Te(r){let t=se();if(!ae(t)||!t.isCollapsed())return null;let e=t.anchor;if(e.type!=="text")return null;let n=e.getNode();if(!n.isSimpleText())return null;let o=e.offset,i=n.getTextContent().slice(0,o),s=r.replaceableString.length,a=_e(i,r.matchingString,s),c=o-a;if(c<0)return null;let l;return c===0?[l]=n.splitText(o):[,l]=n.splitText(c,o),l}function Se(r,t){let e=getComputedStyle(r),n=e.position==="absolute",o=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let i=r;i=i.parentElement;)if(e=getComputedStyle(i),!(n&&e.position==="static")&&o.test(e.overflow+e.overflowY+e.overflowX))return i;return document.body}function mt(r,t){let e=r.getBoundingClientRect(),n=t.getBoundingClientRect();return e.top>n.top&&e.top<n.bottom}function we(r,t,e,n){let o=pt(12),[i]=ht(),s;o[0]!==i||o[1]!==e||o[2]!==n||o[3]!==r||o[4]!==t.current?(s=()=>{let c=t.current;if(c!=null&&r!=null){let l=i.getRootElement(),f=l!=null?Se(l,!1):document.body,m;m=!1;let g;g=mt(c,f);let p=function(){m||(window.requestAnimationFrame(function(){e(),m=!1}),m=!0);let d=mt(c,f);d!==g&&(g=d,n?.(d))},u=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",p,{capture:!0,passive:!0}),u.observe(c),()=>{u.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",p,!0)}}},o[0]=i,o[1]=e,o[2]=n,o[3]=r,o[4]=t.current,o[5]=s):s=o[5];let a;o[6]!==i||o[7]!==e||o[8]!==n||o[9]!==r||o[10]!==t?(a=[i,n,e,r,t],o[6]=i,o[7]=e,o[8]=n,o[9]=r,o[10]=t,o[11]=a):a=o[11],L(s,a)}var gt=ce("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function xt({anchorElementRef:r,close:t,editor:e,groups:n,menuRenderFn:o,resolution:i,shouldSplitNodeWithQuery:s=!1}){let[a,c]=xe(null),l=i.match&&i.match.matchingString||"",f=q(u=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${Ee}__item-${u.key}`),c(u.key))},[e]),m=q(()=>{if(n!==null&&l!=null){let u=n.flatMap(d=>d.items);if(u.length){let d=u[0];f(d)}}},[n,f,l]);L(()=>{m()},[l,m]);let g=q(u=>{t(),e.update(()=>{let d=i.match!=null&&s?Te(i.match):null;d&&d.remove()}),setTimeout(()=>{u.onSelect({editor:e,queryString:i.match?i.match.matchingString:""})},0)},[e,s,i.match,t]);L(()=>()=>{let u=e.getRootElement();u!==null&&u.removeAttribute("aria-activedescendant")},[e]),ge(()=>{n===null?c(null):a===null&&m()},[n,a,f,m]),L(()=>ut(e.registerCommand(gt,({item:u})=>u.ref&&u.ref.current!=null?(dt(u.ref.current),!0):!1,M)),[e,f]),L(()=>ut(e.registerCommand(le,u=>{let d=u;if(n!==null&&n.length&&a!==null){let x=n.flatMap(_=>_.items),h=x.findIndex(_=>_.key===a),T=h!==x.length-1?h+1:0,E=x[T];f(E),E.ref!=null&&E.ref.current&&e.dispatchCommand(gt,{index:T,item:E}),d.preventDefault(),d.stopImmediatePropagation()}return!0},M),e.registerCommand(fe,u=>{let d=u;if(n!==null&&n.length&&a!==null){let x=n.flatMap(_=>_.items),h=x.findIndex(_=>_.key===a),T=h!==0?h-1:x.length-1,E=x[T];f(E),E.ref!=null&&E.ref.current&&dt(E.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},M),e.registerCommand(de,u=>{let d=u;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},M),e.registerCommand(me,u=>{let d=u;if(n===null||a===null)return!1;let h=n.flatMap(T=>T.items).find(T=>T.key===a);return h?(d.preventDefault(),d.stopImmediatePropagation(),g(h),!0):!1},M),e.registerCommand(ue,u=>{if(n===null||a===null)return!1;let x=n.flatMap(h=>h.items).find(h=>h.key===a);return x?(u!==null&&(u.preventDefault(),u.stopImmediatePropagation()),g(x),!0):!1},M)),[g,t,e,n,a,f]);let p=pe(()=>({groups:n,selectedItemKey:a,selectItemAndCleanUp:g,setSelectedItemKey:c}),[g,a,n]);return o(r,p,i.match?i.match.matchingString:"")}function Et(r,t,e,n){let o=pt(14),[i]=ht(),s;o[0]===Symbol.for("react.memo_cache_sentinel")?(s=C?document.createElement("div"):null,o[0]=s):s=o[0];let a=he(s),c;o[1]!==r||o[2]!==n||o[3]!==i||o[4]!==t?(c=()=>{if(a.current===null||parent===void 0)return;let u=i.getRootElement(),d=a.current,x=d.firstChild;if(u!==null&&t!==null){let{height:h,width:T}=t.getRect(),{left:E,top:_}=t.getRect(),N=_;if(_=_-(r.getBoundingClientRect().top+window.scrollY),E=E-(r.getBoundingClientRect().left+window.scrollX),d.style.left=`${E+window.scrollX}px`,d.style.height=`${h}px`,d.style.width=`${T}px`,x!==null){let S=x.getBoundingClientRect(),F=S.height,w=S.width,A=u.getBoundingClientRect();E+w>A.right&&(d.style.left=`${A.right-w+window.scrollX}px`);let y=N+F+32>window.innerHeight,b=N<0;y&&!b?d.style.top=`${_+32-F+window.scrollY-(h+24)}px`:d.style.top=`${_+window.scrollY+32}px`}d.isConnected||(n!=null&&(d.className=n),d.setAttribute("aria-label","Slash menu"),d.setAttribute("id","slash-menu"),d.setAttribute("role","listbox"),d.style.display="block",d.style.position="absolute",r.append(d)),a.current=d,u.setAttribute("aria-controls","slash-menu")}},o[1]=r,o[2]=n,o[3]=i,o[4]=t,o[5]=c):c=o[5];let l=c,f,m;o[6]!==i||o[7]!==l||o[8]!==t?(f=()=>{let u=i.getRootElement();if(t!==null)return l(),()=>{u!==null&&u.removeAttribute("aria-controls");let d=a.current;d!==null&&d.isConnected&&d.remove()}},m=[i,l,t],o[6]=i,o[7]=l,o[8]=t,o[9]=f,o[10]=m):(f=o[9],m=o[10]),L(f,m);let g;return o[11]!==t||o[12]!==e?(g=u=>{t!==null&&(u||e(null))},o[11]=t,o[12]=e,o[13]=g):g=o[13],we(t,a,l,g),a}var no=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function be(r){let t=r.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let n=t.offset;return e.getTextContent().slice(0,n)}function Tt(r,t,e){let n=e.getSelection();if(n===null||!n.isCollapsed)return!1;let o=n.anchorNode,i=r,s=n.anchorOffset;if(o==null||s==null)return!1;try{t.setStart(o,i),t.setEnd(o,s>1?s:1)}catch{return!1}return!0}function ke(r){let t;return r.getEditorState().read(()=>{let e=Z();J(e)&&(t=be(e))}),t}function St(r,t){return t!==0?!1:r.getEditorState().read(()=>{let e=Z();if(J(e)){let i=e.anchor.getNode().getPreviousSibling();return Ne(i)&&i.isTextEntity()}return!1})}function wt(r){V.startTransition?V.startTransition(r):r()}var Me=ye("ENABLE_SLASH_MENU_COMMAND");function oo(r){let t=Ce(30),{anchorClassName:e,anchorElem:n,groups:o,menuRenderFn:i,onClose:s,onOpen:a,onQueryChange:c,triggerFn:l}=r,[f]=Ie(),[m,g]=Oe(null),p=Et(n,m,g,e),u;t[0]!==s||t[1]!==m?(u=()=>{g(null),s!=null&&m!==null&&s()},t[0]=s,t[1]=m,t[2]=u):u=t[2];let d=u,x;t[3]!==a||t[4]!==m?(x=F=>{g(F),a!=null&&m===null&&a(F)},t[3]=a,t[4]=m,t[5]=x):x=t[5];let h=x,T,E;t[6]!==f||t[7]!==h?(T=()=>Fe(f.registerCommand(Me,F=>{let{node:w}=F;return f.getEditorState().read(()=>{let A={leadOffset:0,matchingString:"",replaceableString:""};if(!St(f,A.leadOffset)&&w!==null){let y=f._window??window,b=y.document.createRange();Tt(A.leadOffset,b,y)!==null&&wt(()=>h({getRect:()=>b.getBoundingClientRect(),match:A}));return}}),!0},Ae)),E=[f,h],t[6]=f,t[7]=h,t[8]=T,t[9]=E):(T=t[8],E=t[9]),_t(T,E);let _;t[10]!==d||t[11]!==f||t[12]!==c||t[13]!==h||t[14]!==l?(_=()=>{let F=()=>{f.getEditorState().read(()=>{let A=f._window??window,y=A.document.createRange(),b=Z(),Q=ke(f);if(!J(b)||!b.isCollapsed()||Q===void 0||y===null){d();return}let k=l({editor:f,query:Q});if(c(k?k.matchingString:null),k!==null&&!St(f,k.leadOffset)&&Tt(k.leadOffset,y,A)!==null){wt(()=>h({getRect:()=>y.getBoundingClientRect(),match:k}));return}d()})},w=f.registerUpdateListener(F);return()=>{w()}},t[10]=d,t[11]=f,t[12]=c,t[13]=h,t[14]=l,t[15]=_):_=t[15];let N;t[16]!==d||t[17]!==f||t[18]!==c||t[19]!==h||t[20]!==m||t[21]!==l?(N=[f,l,c,m,d,h],t[16]=d,t[17]=f,t[18]=c,t[19]=h,t[20]=m,t[21]=l,t[22]=N):N=t[22],_t(_,N);let S;return t[23]!==p||t[24]!==d||t[25]!==f||t[26]!==o||t[27]!==i||t[28]!==m?(S=p.current===null||m===null||f===null?null:Re(xt,{anchorElementRef:p,close:d,editor:f,groups:o,menuRenderFn:i,resolution:m,shouldSplitNodeWithQuery:!0}),t[23]=p,t[24]=d,t[25]=f,t[26]=o,t[27]=i,t[28]=m,t[29]=S):S=t[29],S}var Ct=class r{_bottom;_left;_right;_top;constructor(t,e,n,o){let[i,s]=e<=o?[e,o]:[o,e],[a,c]=t<=n?[t,n]:[n,t];this._top=i,this._right=c,this._left=a,this._bottom=s}static fromDOM(t){let{height:e,left:n,top:o,width:i}=t.getBoundingClientRect();return r.fromLWTH(n,i,o,e)}static fromDOMRect(t){let{height:e,left:n,top:o,width:i}=t;return r.fromLWTH(n,i,o,e)}static fromLTRB(t,e,n,o){return new r(t,e,n,o)}static fromLWTH(t,e,n,o){return new r(t,n,t+e,n+o)}static fromPoints(t,e){let{x:n,y:o}=t,{x:i,y:s}=e;return r.fromLTRB(n,o,i,s)}contains(t){if(ft(t)){let{x:s,y:a}=t,c=a<this._top,l=a>this._bottom,f=s<this._left,m=s>this._right;return{reason:{isOnBottomSide:l,isOnLeftSide:f,isOnRightSide:m,isOnTopSide:c},result:!c&&!l&&!f&&!m}}let{bottom:e,left:n,right:o,top:i}=t;return i>=this._top&&i<=this._bottom&&e>=this._top&&e<=this._bottom&&n>=this._left&&n<=this._right&&o>=this._left&&o<=this._right}distanceFromPoint(t){let e=this.contains(t);if(e.result)return{distance:0,isOnBottomSide:e.reason.isOnBottomSide,isOnLeftSide:e.reason.isOnLeftSide,isOnRightSide:e.reason.isOnRightSide,isOnTopSide:e.reason.isOnTopSide};let n=0,o=0;return t.x<this._left?n=this._left-t.x:t.x>this._right&&(n=t.x-this._right),t.y<this._top?o=this._top-t.y:t.y>this._bottom&&(o=t.y-this._bottom),{distance:Math.sqrt(n*n+o*o),isOnBottomSide:t.y>this._bottom,isOnLeftSide:t.x<this._left,isOnRightSide:t.x>this._right,isOnTopSide:t.y<this._top}}equals({bottom:t,left:e,right:n,top:o}){return o===this._top&&t===this._bottom&&e===this._left&&n===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:n=this.right,top:o=this.top}){return new r(e,o,n,t)}intersectsWith(t){let{height:e,left:n,top:o,width:i}=t,{height:s,left:a,top:c,width:l}=this,f=n+i>=a+l?n+i:a+l,m=o+e>=c+s?o+e:c+s,g=n<=a?n:a,p=o<=c?o:c;return f-g<=i+l&&m-p<=e+s}get bottom(){return this._bottom}get height(){return Math.abs(this._bottom-this._top)}get left(){return this._left}get right(){return this._right}get top(){return this._top}get width(){return Math.abs(this._left-this._right)}};function ao({editorConfig:r}){return Le({nodes:r.features.nodes})}function Le({nodes:r}){return r.map(t=>"node"in t?t.node:t)}var $e=C&&"documentMode"in document?document.documentMode:null,fo=C&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),uo=C&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),mo=C&&"InputEvent"in window&&!$e?"getTargetRanges"in new window.InputEvent("input"):!1,tt=C&&/Version\/[\d.].*Safari/.test(navigator.userAgent),et=C&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,go=C&&/Android/.test(navigator.userAgent),po=C&&/Win/.test(navigator.platform),De=C&&/^(?=.*Chrome).*/i.test(navigator.userAgent),nt=C&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!De;import{$getRoot as Xe,$isDecoratorNode as At,$isElementNode as W,$isLineBreakNode as ze,$isTextNode as G}from"lexical";import{$isListItemNode as Be,$isListNode as Rt}from"@lexical/list";import{$isHeadingNode as Pe,$isQuoteNode as ve}from"@lexical/rich-text";import{$isParagraphNode as He,$isTextNode as Ke}from"lexical";var R={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},I={...R,requiresParagraphStart:!0},To={...I,export:$(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},So={...I,export:$(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},wo={...I,export:$(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Co={...I,export:$(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},Ro={...I,export:$(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},Io={...I,export:$(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},Fo={...I,export:We,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},No={...I,export:ot,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},Ao={...I,export:ot,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},yo={...I,export:ot,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},Oo={...I,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},bo={...I,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},ko={...R,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},Mo={...R,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},Lo={...R,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},$o={...R,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},Do={...R,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Bo={...R,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Po={...R,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},vo={...R,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},Ho={...R,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},Ko={...R,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Uo={...R,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},Wo={...R,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function $(r){return(t,e)=>Pe(t)&&t.getTag()==="h"+r?"#".repeat(r)+" "+e(t):null}function ot(r,t){return Rt(r)?It(r,t,0):null}var Ue=4;function It(r,t,e){let n=[],o=r.getChildren(),i=0;for(let s of o)if(Be(s)){if(s.getChildrenSize()===1){let l=s.getFirstChild();if(Rt(l)){n.push(It(l,t,e+1));continue}}let a=" ".repeat(e*Ue),c=r.getListType()==="bullet"?"- ":`${r.getStart()+i}. `;n.push(a+c+t(s)),i++}return n.join(`
2
- `)}function We(r,t){return ve(r)?"> "+t(r):null}function K(r,t){let e={};for(let n of r){let o=t(n);o&&(e[o]?e[o].push(n):e[o]=[n])}return e}function D(r){let t=K(r,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var B=/[!-/:-@[-`{-~\s]/,Ge=/^\s{0,3}$/;function H(r){if(!He(r))return!1;let t=r.getFirstChild();return t==null||r.getChildrenSize()===1&&Ke(t)&&Ge.test(t.getTextContent())}function yt(r,t=!1){let e=D(r),n=[...e.multilineElement,...e.element],o=!t,i=e.textFormat.filter(s=>s.format.length===1);return s=>{let a=[],c=(s||Xe()).getChildren();for(let l=0;l<c.length;l++){let f=c[l],m=Ye(f,n,i,e.textMatch);m!=null&&a.push(o&&l>0&&!H(f)&&!H(c[l-1])?`
2
+ `)}function We(r,t){return ve(r)?"> "+t(r):null}function K(r,t){let e={};for(let n of r){let o=t(n);o&&(e[o]?e[o].push(n):e[o]=[n])}return e}function D(r){let t=K(r,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var B=/[!-/:-@[-`{-~\s]/,Ge=/^\s{0,3}$/;function H(r){if(!He(r))return!1;let t=r.getFirstChild();return t==null||r.getChildrenSize()===1&&Ke(t)&&Ge.test(t.getTextContent())}function yt(r,t=!1){let e=D(r),n=[...e.multilineElement,...e.element],o=!t,i=e.textFormat.filter(s=>s.format.length===1).sort((s,a)=>s.format[0]==="code"&&a.format[0]!=="code"?1:s.format[0]!=="code"&&a.format[0]==="code"?-1:0);return s=>{let a=[],c=(s||Xe()).getChildren();for(let l=0;l<c.length;l++){let f=c[l],m=Ye(f,n,i,e.textMatch);m!=null&&a.push(o&&l>0&&!H(f)&&!H(c[l-1])?`
3
3
  `.concat(m):m)}return a.join(`
4
4
  `)}}function Ye(r,t,e,n){for(let o of t){if(!o.export)continue;let i=o.export(r,s=>X(s,e,n));if(i!=null)return i}return W(r)?X(r,e,n):At(r)?r.getTextContent():null}function X(r,t,e,n,o){let i=[],s=r.getChildren();n||(n=[]),o||(o=[]);t:for(let a of s){for(let c of e){if(!c.export)continue;let l=c.export(a,f=>X(f,t,e,n,[...o,...n]),(f,m)=>Ft(f,m,t,n,o));if(l!=null){i.push(l);continue t}}ze(a)?i.push(`
5
5
  `):G(a)?i.push(Ft(a,a.getTextContent(),t,n,o)):W(a)?i.push(X(a,t,e,n,o)):At(a)&&i.push(a.getTextContent())}return i.join("")}function Ft(r,t,e,n,o){let i=t.trim(),s=i,a="",c="",l="",f=Nt(r,!0),m=Nt(r,!1),g=new Set;for(let p of e){let u=p.format[0],d=p.tag;U(r,u)&&!g.has(u)&&(g.add(u),(!U(f,u)||!n.find(x=>x.tag===d))&&(n.push({format:u,tag:d}),a+=d))}for(let p=0;p<n.length;p++){let u=U(r,n[p].format),d=U(m,n[p].format);if(u&&d)continue;let x=[...n];for(;x.length>p;){let h=x.pop();o&&h&&o.find(T=>T.tag===h.tag)||(h&&typeof h.tag=="string"&&(u?d||(l+=h.tag):c+=h.tag),n.pop())}break}return s=a+s+l,c+t.replace(i,()=>s)}function Nt(r,t){let e=t?r.getPreviousSibling():r.getNextSibling();if(!e){let n=r.getParentOrThrow();n.isInline()&&(e=t?n.getPreviousSibling():n.getNextSibling())}for(;e;){if(W(e)){if(!e.isInline())break;let n=t?e.getLastDescendant():e.getFirstDescendant();if(G(n))return n;e=t?e.getPreviousSibling():e.getNextSibling()}if(G(e))return e;if(!W(e))return null}return null}function U(r,t){return G(r)&&r.hasFormat(t)}import{$isListItemNode as je,$isListNode as Lt}from"@lexical/list";import{$isQuoteNode as qe}from"@lexical/rich-text";import{$findMatchingParent as Ve}from"@lexical/utils";import{$createLineBreakNode as Ze,$createParagraphNode as Je,$createTextNode as tn,$getRoot as en,$getSelection as nn,$isParagraphNode as on}from"lexical";import{$isTextNode as P}from"lexical";function Ot(r,t){let e=r.getTextContent(),n=Qe(e,t);if(!n)return null;let o=n.index||0,i=o+n[0].length,s=t.transformersByTag[n[1]];return{endIndex:i,match:n,startIndex:o,transformer:s}}function Qe(r,t){let e=r.match(t.openTagsRegExp);if(e==null)return null;for(let n of e){let o=n.replace(/^\s/,""),i=t.fullMatchRegExpByTag[o];if(i==null)continue;let s=r.match(i),a=t.transformersByTag[o];if(s!=null&&a!=null){if(a.intraword!==!1)return s;let{index:c=0}=s,l=r[c-1],f=r[c+s[0].length];if((!l||B.test(l))&&(!f||B.test(f)))return s}}return null}function bt(r,t,e,n,o){let i=r.getTextContent(),s,a,c;if(o[0]===i?c=r:t===0?[c,s]=r.splitText(e):[a,c,s]=r.splitText(t,e),c.setTextContent(o[2]),n)for(let l of n.format)c.hasFormat(l)||c.toggleFormat(l);return{nodeAfter:s,nodeBefore:a,transformedNode:c}}function kt(r,t){let e=r,n,o,i,s;for(let a of t){if(!a.replace||!a.importRegExp)continue;let c=e.getTextContent().match(a.importRegExp);if(!c)continue;let l=c.index||0,f=a.getEndIndex?a.getEndIndex(e,c):l+c[0].length;f!==!1&&(n===void 0||o===void 0||l<n&&f>o)&&(n=l,o=f,i=a,s=c)}return n===void 0||o===void 0||i===void 0||s===void 0?null:{endIndex:o,match:s,startIndex:n,transformer:i}}function Mt(r,t,e,n,o){let i,s,a;if(t===0?[a,i]=r.splitText(e):[s,a,i]=r.splitText(t,e),!n.replace)return null;let c=n.replace(a,o);return{nodeAfter:i,nodeBefore:s,transformedNode:c||void 0}}function O(r,t,e){let n=Ot(r,t),o=kt(r,e);if(n&&o&&(n.startIndex<=o.startIndex&&n.endIndex>=o.endIndex?o=null:n=null),n){let i=bt(r,n.startIndex,n.endIndex,n.transformer,n.match);i.nodeAfter&&P(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&O(i.nodeAfter,t,e),i.nodeBefore&&P(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&O(i.nodeBefore,t,e),i.transformedNode&&P(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&O(i.transformedNode,t,e);return}else if(o){let i=Mt(r,o.startIndex,o.endIndex,o.transformer,o.match);if(!i)return;i.nodeAfter&&P(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&O(i.nodeAfter,t,e),i.nodeBefore&&P(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&O(i.nodeBefore,t,e),i.transformedNode&&P(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&O(i.transformedNode,t,e);return}else return}function $t(r,t=!1){let e=D(r),n=an(e.textFormat);return(o,i)=>{let s=o.split(`
@@ -9,4 +9,4 @@ var C=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.crea
9
9
  `)},regExp:Gt,replace:(r,t,e,n)=>{if(n){let i=r.getPreviousSibling();if(Ht(i)){i.splice(i.getChildrenSize(),0,[Cn(),...t]),i.select(0,0),r.remove();return}}let o=_n();o.append(...t),r.replace(o),o.select(0,0)}},Qt={type:"element",dependencies:[ct,at],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:Ut,replace:lt("bullet")},bn={type:"element",dependencies:[ct,at],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:Wt,replace:lt("check")},jt={type:"element",dependencies:[ct,at],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:Kt,replace:lt("number")},qt={type:"text-format",format:["code"],tag:"`"},Vt={type:"text-format",format:["highlight"],tag:"=="},Zt={type:"text-format",format:["bold","italic"],tag:"***"},Jt={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},te={type:"text-format",format:["bold"],tag:"**"},ee={type:"text-format",format:["bold"],intraword:!1,tag:"__"},ne={type:"text-format",format:["strikethrough"],tag:"~~"},oe={type:"text-format",format:["italic"],tag:"*"},re={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function ie(r,t=!1){let e=r.split(`
10
10
  `),n=!1,o=[];for(let i=0;i<e.length;i++){let s=e[i],a=o[o.length-1];if(Fn.test(s)){o.push(s);continue}if(Rn.test(s)||In.test(s)){n=!n,o.push(s);continue}if(n){o.push(s);continue}s===""||a===""||!a||st.test(a)||st.test(s)||Gt.test(s)||Kt.test(s)||Ut.test(s)||Wt.test(s)||Nn.test(s)||An.test(s)||!t?o.push(s):o[o.length-1]=a+s}return o.join(`
11
11
  `)}var kn=[zt,Yt,Qt,jt],Mn=[],Ln=[qt,Zt,Jt,te,ee,Vt,oe,re,ne],$n=[],z=[...kn,...Mn,...Ln,...$n];function Sr(r,t=z,e,n=!1,o=!1){let i=n?r:ie(r,o);return $t(t,n)(i,e)}function wr(r=z,t,e=!1){return yt(r,e)(t)}export{C as a,fo as b,dr as c,z as d,Sr as e,wr as f,Pn as g,j as h,ft as i,no as j,Me as k,oo as l,Ct as m,ao as n};
12
- //# sourceMappingURL=chunk-WCORQHZQ.js.map
12
+ //# sourceMappingURL=chunk-ZD5FCKFR.js.map