@payloadcms/richtext-lexical 3.29.0-internal.e4e913b → 3.30.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use client";import{c as Re,f as I,h as ke,i as we,j as Te,k as ve,l as De}from"./chunk-XO6X2M3F.js";import{a as Se,b as P}from"./chunk-BZZVLW4U.js";import{jsx as O,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as nn,FieldError as rn,FieldLabel as sn,RenderCustomComponent as gt,useEditDepth as ln,useEffectEvent as an,useField as cn}from"@payloadcms/ui";import{mergeFieldStyles as un}from"@payloadcms/ui/shared";import ht,{useCallback as yt,useEffect as xt,useMemo as dn,useState as Et}from"react";import{ErrorBoundary as mn}from"react-error-boundary";import"./bundled.css";import{jsx as _}from"react/jsx-runtime";import{LexicalComposer as en}from"@lexical/react/LexicalComposer.js";import{useEditDepth as tn}from"@payloadcms/ui";import*as mt from"react";import{useMemo as on}from"react";import{c as $o}from"react/compiler-runtime";import{jsx as b,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as Ko}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ho}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as jo}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as zo}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Wo}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Yo,COMMAND_PRIORITY_LOW as ut,FOCUS_COMMAND as Go}from"lexical";import*as q from"react";import{useEffect as Vo,useState as Uo}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var $=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Me(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Me(o.Component,{clientProps:e});import{c as Nt}from"react/compiler-runtime";import{useLexicalComposerContext as Pt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as St}from"@lexical/utils";import{$createNodeSelection as Rt,$getEditor as X,$getNearestNodeFromDOMNode as kt,$getSelection as re,$isDecoratorNode as K,$isElementNode as xe,$isLineBreakNode as wt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as Tt,$isTextNode as vt,$setSelection as Le,CLICK_COMMAND as Dt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as Mt,KEY_ARROW_UP_COMMAND as Bt,KEY_BACKSPACE_COMMAND as Lt,KEY_DELETE_COMMAND as At,SELECTION_CHANGE_COMMAND as It}from"lexical";import{useEffect as _t}from"react";function Ae(){let t=Nt(3),[e]=Pt(),o=zt,r,n;return t[0]!==e?(r=()=>St(e.registerCommand(Dt,jt,W),e.registerCommand(At,o,W),e.registerCommand(Lt,o,W),e.registerCommand(It,Ht,W),e.registerCommand(Bt,$t,W),e.registerCommand(Mt,Ot,W)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),_t(r,n),null}function Ot(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(K(i)){let p=X().getElementByKey(i.getKey());return p&&Z({element:p,node:i}),!0}if(!xe(i))return!0;let l=i.getFirstDescendant()??i;return l&&(ne(l,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Ft),c=n?.getNextSibling();if(!n||c!==Ie(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Ft(t){return Ie(t)!==null}function $t(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(K(i)){let p=X().getElementByKey(i.getKey());return p?(Z({element:p,node:i}),t.preventDefault(),!0):!1}if(!xe(i))return!1;let l=i.getLastDescendant()??i;return l?(ne(l,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Kt),c=n?.getPreviousSibling();if(!n||c!==_e(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Kt(t){return _e(t)!==null}function Ht(){let t=Gt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function jt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Yt(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Le(null):Z(e),!0}function zt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Wt),!0):!1}function Wt(t){t.remove()}function Yt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=kt(e);return K(o)?{element:e,node:o}:void 0}function Gt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return K(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Rt();o.add(e.getKey()),Le(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(K(t)&&!t.isInline())return!0;if(!xe(t)||Tt(t))return!1;let e=t.getFirstChild(),o=e===null||wt(e)||vt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Ie(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function _e(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ee}from"react/jsx-runtime";import{useLexicalComposerContext as Xt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Zt,isHTMLElement as eo}from"lexical";import*as Ke from"react";import{useCallback as to,useEffect as $e,useRef as oo,useState as no}from"react";import{createPortal as ro}from"react-dom";var Y=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:l,left:u,right:p,top:h}=t.getBoundingClientRect(),a=h+window.scrollY,s=l+window.scrollY;if(o<a-c||o>s+c||e<u-n||e>p+n)return-1;(e<u||e>p)&&(i=e<u?e-u:e-p)}return i};import{$getNodeByKey as ae}from"lexical";function G(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(u,p)=>u?parseFloat(window.getComputedStyle(u)[p]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Vt}from"lexical";function H(t){return t.getEditorState().read(()=>Vt().getChildrenKeys())}var Ut=1,qt=-1,Oe=0,B={props:null,result:null};function Jt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function V(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:l},startIndex:u=0,useEdgeAsDefault:p=!1}=t;if(o>0&&B.props&&B.result&&B.props.fuzzy===t.fuzzy&&B.props.horizontalOffset===t.horizontalOffset&&B.props.useEdgeAsDefault===t.useEdgeAsDefault&&Jt(B.props.point,t.point,o))return B.result;let h=e.getBoundingClientRect(),a=H(r),s={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(p){let m=r.getElementByKey(a[0]),y=r.getElementByKey(a[a.length-1]);if(m&&y){let[d,f]=[G(m),G(y)];if(l<d.top?(s.blockElem=m,s.distance=d.top-l,s.blockNode=ae(a[0]),s.foundAtIndex=0):l>f.bottom&&(s.distance=l-f.bottom,s.blockNode=ae(a[a.length-1]),s.blockElem=y,s.foundAtIndex=a.length-1),s?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let g=u,x=Oe;for(;g>=0&&g<a.length;){let m=a[g],y=r.getElementByKey(m);if(y===null)break;let d=new I(i+c,l),f=ve.fromDOMRect(G(y)),{marginBottom:E,marginTop:T}=le(y),R=f.generateNewRect({bottom:f.bottom+E,left:h.left,right:h.right,top:f.top-T}),{distance:S,isOnBottomSide:k,isOnTopSide:C}=R.distanceFromPoint(d);if(S===0){s.blockElem=y,s.blockNode=ae(m),s.foundAtIndex=g,s.distance=S,s.blockNode&&s.blockNode.getType()==="paragraph"&&s.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(s.blockElem=null,s.blockNode=null),s.isFoundNodeEmptyParagraph=!0);break}else n&&S<s.distance&&(s.blockElem=y,s.blockNode=ae(m),s.distance=S,s.foundAtIndex=g);x===Oe&&(C?x=qt:k?x=Ut:x=1/0),g+=x}}),B.props=t,B.result={blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph},{blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var Qt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Fe(t){if(!t||Qt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function ue(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),l=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=n.top+8-l.top;else{let a=Fe(t)?parseInt(c.lineHeight,10):0;u=n.top+(a-i.height)/2-l.top}let h=r;e.style.opacity="1",e.style.transform=`translate(${h}px, ${u}px)`}var io="add-block-menu",de=1/0;function so(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function lo(t,e,o){let r=e.parentElement,{editorConfig:n}=P(),c=n?.admin?.hideGutter?-24:12,i=oo(null),[l,u]=no(null);$e(()=>{function h(a){let s=a.target;if(!eo(s))return;let g=Y(r,a.pageX,a.pageY,s);if(g===-1){u(null);return}if(ce(s,io))return;let x=H(t),{blockElem:m,blockNode:y,foundAtIndex:d}=V({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-g,point:new I(a.x,a.y),returnEmptyParagraphs:!0,startIndex:so(x.length),useEdgeAsDefault:!1});de=d,m&&y&&(l?.node!==y||l?.elem!==m)&&u({elem:m,node:y})}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,l]),$e(()=>{i.current&&l?.node&&ue(l?.elem,i.current,e,c)},[e,l,c]);let p=to(h=>{let a=l;a?.node&&(t.update(()=>{let s=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(s=!1),!s){let g=Zt();a?.node.insertAfter(g),setTimeout(()=>{a={elem:t.getElementByKey(g.getKey()),node:g},u(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(we,{node:a?.node})},2),h.stopPropagation(),h.preventDefault())},[t,l]);return ro(Ee(Ke.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:h=>{p(h)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function He(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=Xt();return lo(r,o,r._editable)}import{jsx as me,jsxs as co}from"react/jsx-runtime";import{useLexicalComposerContext as uo}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as We}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ye,$getNodeByKey as mo,isHTMLElement as be}from"lexical";import*as Je from"react";import{useEffect as Ce,useRef as fe,useState as Ge}from"react";import{createPortal as fo}from"react-dom";var je=0,ao=-24;var j=0;function ze(t,e,o,r,n,c,i,l,u,p=!1){let{height:h,top:a}=r.getBoundingClientRect(),{top:s,width:g}=i.getBoundingClientRect(),{marginBottom:x,marginTop:m}=le(r),y=a,d=c>=a+h/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(d&&n?.elem&&n?.elem===r.nextElementSibling||!d&&n?.elem&&n?.elem===r.previousElementSibling)&&(j++,j<200&&(f=!0));else{j++;let S=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(d===n?.isBelow&&S===k||j<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};p?y+=h/2:d?y+=h+x/2:y-=m/2;let E=0;p||(d?E=-je:E=je);let T=y-s+E,R=ao-e;return o.style.width=`calc(${g}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${R}px, calc(${T}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?d?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),j=0,{isBelow:d,willStayInSamePosition:f}}var po="draggable-block-menu",Ve="application/x-lexical-drag-block",ee=1/0;function Ue(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function go(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function qe(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function ho(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),l=fe(!1),[u,p]=Ge(null),[h,a]=Ge(null),{editorConfig:s}=P(),g=s?.admin?.hideGutter?-44:-8;Ce(()=>{function y(d){let f=d.target;if(!be(f))return;let E=Y(r,d.pageX,d.pageY,f);if(E===-1){p(null);return}if(ce(f,po))return;let T=H(t),{blockElem:R,foundAtIndex:S,isFoundNodeEmptyParagraph:k}=V({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new I(d.x,d.y),startIndex:Ue(T.length),useEdgeAsDefault:!1,verbose:!1});ee=S,!(!R&&!k)&&u!==R&&p(R)}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,u]),Ce(()=>{n.current&&ue(u,n.current,e,g)},[e,u,g]),Ce(()=>{function y(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{pageY:T,target:R}=f;if(!be(R))return!1;let S=Y(r,f.pageX,f.pageY,R,100,50),k=H(t),{blockElem:C,foundAtIndex:z,isFoundNodeEmptyParagraph:v}=V({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-S,point:new I(f.x,f.y),startIndex:Ue(k.length),useEdgeAsDefault:!0,verbose:!0});ee=z;let A=c.current;if(C===null||A===null)return!1;if(u!==C){let{isBelow:w,willStayInSamePosition:J}=ze(s?.admin?.hideGutter?"0px":"3rem",g+(s?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),A,C,h,T,e,f,i,v);f.preventDefault(),J||a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:w})}else h?.elem&&(qe(A,h.elem),a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:!1}));return!0}function d(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{dataTransfer:T,pageY:R,target:S}=f,k=T?.getData(Ve)||"";return t.update(()=>{let C=mo(k);if(!C||!be(S))return!1;let z=Y(r,f.pageX,f.pageY,S,100,50),{blockElem:v,isFoundNodeEmptyParagraph:A}=V({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-z,point:new I(f.x,f.y),useEdgeAsDefault:!0});if(!v)return!1;let w=Ye(v);if(!w)return!1;if(w===C)return!0;let{height:J,top:he}=G(v),oe=R>=he+J/2+window.scrollY;A?(w.insertBefore(C),w.remove()):oe?w.insertAfter(C):w.insertBefore(C),u!==null&&p(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let ye=t.getElementByKey(C.getKey());setTimeout(()=>{let D=ye?.getBoundingClientRect();if(!D)return;let N=document.createElement("div");N.className="lexical-block-highlighter",N.style.backgroundColor="var(--theme-elevation-1000",N.style.transition="opacity 0.5s ease-in-out",N.style.zIndex="1",N.style.pointerEvents="none",N.style.boxSizing="border-box",N.style.borderRadius="4px",N.style.position="absolute",document.body.appendChild(N),N.style.opacity="0.1",N.style.height=`${D.height+8}px`,N.style.width=`${D.width+8}px`,N.style.top=`${D.top+window.scrollY-4}px`,N.style.left=`${D.left-4}px`,setTimeout(()=>{N.style.opacity="0",setTimeout(()=>{N.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",y),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",y),document.removeEventListener("drop",d)}},[r,g,e,t,h,u,s?.admin?.hideGutter]);function x(y){let d=y.dataTransfer;if(!d||!u)return;go(d,u);let f="";t.update(()=>{let E=Ye(u);E&&(f=E.getKey())}),l.current=!0,d.setData(Ve,f)}function m(){l.current=!1,h?.elem&&qe(c.current,h?.elem)}return fo(co(Je.Fragment,{children:[me("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:x,ref:n,children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Qe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=uo();return ho(r,o,r._editable)}import{c as yo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as xo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Eo,$getRoot as bo}from"lexical";import"react";var Xe="insert-paragraph-at-end",Ze=()=>{let t=yo(4),[e]=xo(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(Co)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:Xe,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${Xe}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function Co(){let t=Eo();bo().append(t),t.select()}import{c as No}from"react/compiler-runtime";import{useLexicalComposerContext as Po}from"@lexical/react/LexicalComposerContext";import*as et from"react";var tt=()=>{let t=No(4),{editorConfig:e}=P(),[o]=Po(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>Re(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),et.useEffect(r,n),null};import{jsx as U,jsxs as nt}from"react/jsx-runtime";import{useLexicalComposerContext as Ro}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as rt}from"@payloadcms/ui";import{useCallback as ko,useMemo as wo,useState as To}from"react";import"react";import*as it from"react-dom";import{c as So}from"react/compiler-runtime";import"react";function ot(t,e){let o=So(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,l;return o[0]!==c||o[1]!==i||o[2]!==t?(l=u=>{let{query:p}=u,h="[^"+t+ke+"\\s]",s=new RegExp("(^|\\s|\\()(["+t+"]((?:"+h+"){0,"+c+"}))$").exec(p);if(s!==null){let g=s[1],x=s[3];if(x.length>=i)return{leadOffset:s.index+g.length,matchingString:x,replaceableString:s[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=l):l=o[3],l}var L="slash-menu-popup";function vo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=P(),{i18n:l}=rt(),u=`${L}__item ${L}__item-${e.key}`;t&&(u+=` ${L}__item--selected`);let p=e.key;return e.label&&(p=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:l,schemaPath:i}):e.label),p.length>25&&(p=p.substring(0,25)+"..."),nt("button",{"aria-selected":t,className:u,id:L+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${L}__item-text`,children:p})]},e.key)}function st({anchorElem:t=document.body}){let[e]=Ro(),[o,r]=To(null),{editorConfig:n}=P(),{i18n:c}=rt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=P(),u=ot("/",{minLength:0}),p=ko(()=>{let a=[];for(let s of n.features.slashMenu.dynamicGroups)if(o){let g=s({editor:e,queryString:o});a=a.concat(g)}return a},[e,o,n?.features]),h=wo(()=>{let a=[];for(let s of n?.features.slashMenu.groups??[])a.push(s);if(o){a=a.map(g=>{let x=g.items.filter(m=>{let y=m.key;return m.label&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),new RegExp(o,"gi").exec(y)?!0:m.keywords!=null?m.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...g,items:x}:null}),a=a.filter(g=>g!=null);let s=p();for(let g of s){let x=a.find(m=>m.key===g.key);x?a=a.filter(m=>m.key!==g.key):x={...g,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,p,i,c,l]);return U(Te,{anchorElem:t,groups:h,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:g,setSelectedItemKey:x})=>a.current&&h.length?it.createPortal(U("div",{className:L,children:h.map(m=>{let y=m.key;return m.label&&i&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),nt("div",{className:`${L}__group ${L}__group-${m.key}`,children:[U("div",{className:`${L}__group-title`,children:y}),m.items.map((d,f)=>U(vo,{index:f,isSelected:s===d.key,item:d,onClick:()=>{x(d.key),g(d)},onMouseEnter:()=>{x(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:u})}import{c as Do}from"react/compiler-runtime";import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Bo,TextNode as Lo}from"lexical";import{useEffect as Ao}from"react";function lt(t){let e=Do(6),{features:o}=t,[r]=Mo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=Io(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Lo,l=>{i.forEach(u=>{l.hasFormat(u)&&l.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Ao(n,c),null}function Io(t){let e=Object.keys(Bo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as _o}from"react/compiler-runtime";import{jsx as at}from"react/jsx-runtime";import{ContentEditable as Oo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Fo}from"@payloadcms/ui";import"react";function ct(t){let e=_o(7),{className:o,editorConfig:r}=t,{t:n}=Fo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=at(Oo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:at("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var dt=t=>{let e=$o(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=P(),[l]=Ko(),[u,p]=Uo(null),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=m=>{m!==null&&p(m)},e[0]=h):h=e[0];let a=h,s,g;e[1]!==l||e[2]!==i?(s=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},y=()=>{i.blurEditor(i)},d=l.registerCommand(Go,()=>(m(),!0),ut),f=l.registerCommand(Yo,()=>(y(),!0),ut);return()=>{d(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},g=[l,i],e[1]=l,e[2]=i,e[3]=s,e[4]=g):(s=e[3],g=e[4]),Vo(s,g);let x;if(e[5]!==l||e[6]!==o||e[7]!==r||e[8]!==u||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(d,f,E)=>{(!E.has("focus")||E.size>1)&&c?.(d,f,E)},e[12]=c,e[13]=m):m=e[13];let y;e[14]!==l||e[15]!==o.features.plugins||e[16]!==u||e[17]!==n?(y=u&&te(q.Fragment,{children:[!n&&l.isEditable()&&te(q.Fragment,{children:[b(Qe,{anchorElem:u}),b(He,{anchorElem:u})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&n))return b($,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),l.isEditable()&&b(q.Fragment,{children:b(st,{anchorElem:u})})]}),e[14]=l,e[15]=o.features.plugins,e[16]=u,e[17]=n,e[18]=y):y=e[18],x=te(q.Fragment,{children:[o.features.plugins?.map(qo),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Jo),b(Wo,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ct,{editorConfig:o})})}),ErrorBoundary:Ho}),b(Ze,{}),b(Ae,{}),b(lt,{features:o.features}),b(zo,{ignoreSelectionChange:!0,onChange:m}),y,l.isEditable()&&te(q.Fragment,{children:[b(jo,{}),o?.features?.markdownTransformers?.length>0&&b(tt,{})]}),o.features.plugins?.map(Qo),o.features.plugins?.map(Xo)]}),o.features.plugins?.map(Zo)]}),e[5]=l,e[6]=o,e[7]=r,e[8]=u,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function qo(t){if(t.position==="aboveContainer")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function Jo(t){if(t.position==="top")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function Qo(t){if(t.position==="normal")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function Xo(t){if(t.position==="bottom")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function Zo(t){if(t.position==="belowContainer")return b($,{clientProps:t.clientProps,plugin:t},t.key)}var ft=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?_(o,{children:_(ft,{providers:e.slice(1),children:t})}):_(o,{children:t})},pt=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:l}=t,u=P(),p=tn(),h=mt.useRef(null),a=on(()=>{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:i!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:De({editorConfig:o}),onError:s=>{throw s},theme:o.lexical.theme}},[o]);return a?_(en,{initialConfig:a,children:_(Se,{editorConfig:o,editorContainerRef:h,fieldProps:r,parentContext:u?.editDepth===p?u:void 0,children:_(ft,{providers:o.features.providers,children:_(dt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):_("p",{children:"Loading..."})};var pe="rich-text-lexical",fn=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:c,readOnly:i}={},label:l,localized:u,required:p},path:h,readOnly:a,validate:s}=t,g=a||i,x=h??r,m=ln(),y=yt((M,F)=>typeof s=="function"?s(M,{...F,required:p}):!0,[s,p]),{customComponents:{AfterInput:d,BeforeInput:f,Description:E,Error:T,Label:R}={},disabled:S,initialValue:k,setValue:C,showError:z,value:v}=cn({path:x,validate:y}),A=g||S,[w,J]=Et(!1),[he,Pe]=Et(),oe=ht.useRef(k),Q=ht.useRef(v);xt(()=>{let M=()=>{let F=window.matchMedia("(max-width: 768px)").matches;F!==w&&J(F)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[w]);let ye=[pe,"field-type",n,z&&"error",A&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!w?`${pe}--show-gutter`:null].filter(Boolean).join(" "),D=`${x}.${m}`,N=yt(M=>{let F=M.toJSON();Q.current=F,C(F)},[C]),bt=dn(()=>un(o),[o]),Ct=an(M=>{Q.current!==v&&JSON.stringify(Q.current)!==JSON.stringify(v)&&(oe.current=M,Q.current=v,Pe(new Date))});return xt(()=>{Object.is(k,oe.current)||Ct(k)},[k]),ge("div",{className:ye,style:bt,children:[O(gt,{CustomComponent:T,Fallback:O(rn,{path:x,showError:z})}),R||O(sn,{label:l,localized:u,path:x,required:p}),ge("div",{className:`${pe}__wrap`,children:[ge(mn,{fallbackRender:pn,onReset:()=>{},children:[f,O(pt,{composerKey:D,editorConfig:e,fieldProps:t,isSmallWidthViewport:w,onChange:N,readOnly:A,value:v},JSON.stringify({path:x,rerenderProviderKey:he})),d]}),E,O(gt,{CustomComponent:E,Fallback:O(nn,{description:c,path:x})})]})]},D)};function pn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[O("p",{children:"Something went wrong:"}),O("pre",{style:{color:"red"},children:t.message})]})}var Fi=fn;export{Fi as RichText};
2
- //# sourceMappingURL=Field-5SZDDPZE.js.map
1
+ "use client";import{b as Re,e as I,g as ke,h as we,i as Te,j as ve,k as De}from"./chunk-DOZWITPU.js";import{a as Se,b as P}from"./chunk-BZZVLW4U.js";import{jsx as O,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as nn,FieldError as rn,FieldLabel as sn,RenderCustomComponent as gt,useEditDepth as ln,useEffectEvent as an,useField as cn}from"@payloadcms/ui";import{mergeFieldStyles as un}from"@payloadcms/ui/shared";import ht,{useCallback as yt,useEffect as xt,useMemo as dn,useState as Et}from"react";import{ErrorBoundary as mn}from"react-error-boundary";import"./bundled.css";import{jsx as _}from"react/jsx-runtime";import{LexicalComposer as en}from"@lexical/react/LexicalComposer.js";import{useEditDepth as tn}from"@payloadcms/ui";import*as mt from"react";import{useMemo as on}from"react";import{c as $o}from"react/compiler-runtime";import{jsx as b,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as Ko}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ho}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as jo}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as zo}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Wo}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Yo,COMMAND_PRIORITY_LOW as ut,FOCUS_COMMAND as Go}from"lexical";import*as q from"react";import{useEffect as Vo,useState as Uo}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var $=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Me(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Me(o.Component,{clientProps:e});import{c as Nt}from"react/compiler-runtime";import{useLexicalComposerContext as Pt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as St}from"@lexical/utils";import{$createNodeSelection as Rt,$getEditor as X,$getNearestNodeFromDOMNode as kt,$getSelection as re,$isDecoratorNode as K,$isElementNode as xe,$isLineBreakNode as wt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as Tt,$isTextNode as vt,$setSelection as Le,CLICK_COMMAND as Dt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as Mt,KEY_ARROW_UP_COMMAND as Bt,KEY_BACKSPACE_COMMAND as Lt,KEY_DELETE_COMMAND as At,SELECTION_CHANGE_COMMAND as It}from"lexical";import{useEffect as _t}from"react";function Ae(){let t=Nt(3),[e]=Pt(),o=zt,r,n;return t[0]!==e?(r=()=>St(e.registerCommand(Dt,jt,W),e.registerCommand(At,o,W),e.registerCommand(Lt,o,W),e.registerCommand(It,Ht,W),e.registerCommand(Bt,$t,W),e.registerCommand(Mt,Ot,W)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),_t(r,n),null}function Ot(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(K(i)){let p=X().getElementByKey(i.getKey());return p&&Z({element:p,node:i}),!0}if(!xe(i))return!0;let l=i.getFirstDescendant()??i;return l&&(ne(l,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Ft),c=n?.getNextSibling();if(!n||c!==Ie(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Ft(t){return Ie(t)!==null}function $t(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(K(i)){let p=X().getElementByKey(i.getKey());return p?(Z({element:p,node:i}),t.preventDefault(),!0):!1}if(!xe(i))return!1;let l=i.getLastDescendant()??i;return l?(ne(l,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Kt),c=n?.getPreviousSibling();if(!n||c!==_e(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Kt(t){return _e(t)!==null}function Ht(){let t=Gt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function jt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Yt(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Le(null):Z(e),!0}function zt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Wt),!0):!1}function Wt(t){t.remove()}function Yt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=kt(e);return K(o)?{element:e,node:o}:void 0}function Gt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return K(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Rt();o.add(e.getKey()),Le(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(K(t)&&!t.isInline())return!0;if(!xe(t)||Tt(t))return!1;let e=t.getFirstChild(),o=e===null||wt(e)||vt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Ie(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function _e(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ee}from"react/jsx-runtime";import{useLexicalComposerContext as Xt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Zt,isHTMLElement as eo}from"lexical";import*as Ke from"react";import{useCallback as to,useEffect as $e,useRef as oo,useState as no}from"react";import{createPortal as ro}from"react-dom";var Y=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:l,left:u,right:p,top:h}=t.getBoundingClientRect(),a=h+window.scrollY,s=l+window.scrollY;if(o<a-c||o>s+c||e<u-n||e>p+n)return-1;(e<u||e>p)&&(i=e<u?e-u:e-p)}return i};import{$getNodeByKey as ae}from"lexical";function G(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(u,p)=>u?parseFloat(window.getComputedStyle(u)[p]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Vt}from"lexical";function H(t){return t.getEditorState().read(()=>Vt().getChildrenKeys())}var Ut=1,qt=-1,Oe=0,B={props:null,result:null};function Jt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function V(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:l},startIndex:u=0,useEdgeAsDefault:p=!1}=t;if(o>0&&B.props&&B.result&&B.props.fuzzy===t.fuzzy&&B.props.horizontalOffset===t.horizontalOffset&&B.props.useEdgeAsDefault===t.useEdgeAsDefault&&Jt(B.props.point,t.point,o))return B.result;let h=e.getBoundingClientRect(),a=H(r),s={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(p){let m=r.getElementByKey(a[0]),y=r.getElementByKey(a[a.length-1]);if(m&&y){let[d,f]=[G(m),G(y)];if(l<d.top?(s.blockElem=m,s.distance=d.top-l,s.blockNode=ae(a[0]),s.foundAtIndex=0):l>f.bottom&&(s.distance=l-f.bottom,s.blockNode=ae(a[a.length-1]),s.blockElem=y,s.foundAtIndex=a.length-1),s?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let g=u,x=Oe;for(;g>=0&&g<a.length;){let m=a[g],y=r.getElementByKey(m);if(y===null)break;let d=new I(i+c,l),f=ve.fromDOMRect(G(y)),{marginBottom:E,marginTop:T}=le(y),R=f.generateNewRect({bottom:f.bottom+E,left:h.left,right:h.right,top:f.top-T}),{distance:S,isOnBottomSide:k,isOnTopSide:C}=R.distanceFromPoint(d);if(S===0){s.blockElem=y,s.blockNode=ae(m),s.foundAtIndex=g,s.distance=S,s.blockNode&&s.blockNode.getType()==="paragraph"&&s.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(s.blockElem=null,s.blockNode=null),s.isFoundNodeEmptyParagraph=!0);break}else n&&S<s.distance&&(s.blockElem=y,s.blockNode=ae(m),s.distance=S,s.foundAtIndex=g);x===Oe&&(C?x=qt:k?x=Ut:x=1/0),g+=x}}),B.props=t,B.result={blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph},{blockElem:s.blockElem,blockNode:s.blockNode,foundAtIndex:s.foundAtIndex,isFoundNodeEmptyParagraph:s.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var Qt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Fe(t){if(!t||Qt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function ue(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),l=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=n.top+8-l.top;else{let a=Fe(t)?parseInt(c.lineHeight,10):0;u=n.top+(a-i.height)/2-l.top}let h=r;e.style.opacity="1",e.style.transform=`translate(${h}px, ${u}px)`}var io="add-block-menu",de=1/0;function so(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function lo(t,e,o){let r=e.parentElement,{editorConfig:n}=P(),c=n?.admin?.hideGutter?-24:12,i=oo(null),[l,u]=no(null);$e(()=>{function h(a){let s=a.target;if(!eo(s))return;let g=Y(r,a.pageX,a.pageY,s);if(g===-1){u(null);return}if(ce(s,io))return;let x=H(t),{blockElem:m,blockNode:y,foundAtIndex:d}=V({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-g,point:new I(a.x,a.y),returnEmptyParagraphs:!0,startIndex:so(x.length),useEdgeAsDefault:!1});de=d,m&&y&&(l?.node!==y||l?.elem!==m)&&u({elem:m,node:y})}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,l]),$e(()=>{i.current&&l?.node&&ue(l?.elem,i.current,e,c)},[e,l,c]);let p=to(h=>{let a=l;a?.node&&(t.update(()=>{let s=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(s=!1),!s){let g=Zt();a?.node.insertAfter(g),setTimeout(()=>{a={elem:t.getElementByKey(g.getKey()),node:g},u(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(we,{node:a?.node})},2),h.stopPropagation(),h.preventDefault())},[t,l]);return ro(Ee(Ke.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:h=>{p(h)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function He(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=Xt();return lo(r,o,r._editable)}import{jsx as me,jsxs as co}from"react/jsx-runtime";import{useLexicalComposerContext as uo}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as We}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ye,$getNodeByKey as mo,isHTMLElement as be}from"lexical";import*as Je from"react";import{useEffect as Ce,useRef as fe,useState as Ge}from"react";import{createPortal as fo}from"react-dom";var je=0,ao=-24;var j=0;function ze(t,e,o,r,n,c,i,l,u,p=!1){let{height:h,top:a}=r.getBoundingClientRect(),{top:s,width:g}=i.getBoundingClientRect(),{marginBottom:x,marginTop:m}=le(r),y=a,d=c>=a+h/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(d&&n?.elem&&n?.elem===r.nextElementSibling||!d&&n?.elem&&n?.elem===r.previousElementSibling)&&(j++,j<200&&(f=!0));else{j++;let S=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(d===n?.isBelow&&S===k||j<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};p?y+=h/2:d?y+=h+x/2:y-=m/2;let E=0;p||(d?E=-je:E=je);let T=y-s+E,R=ao-e;return o.style.width=`calc(${g}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${R}px, calc(${T}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?d?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),j=0,{isBelow:d,willStayInSamePosition:f}}var po="draggable-block-menu",Ve="application/x-lexical-drag-block",ee=1/0;function Ue(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function go(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function qe(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function ho(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),l=fe(!1),[u,p]=Ge(null),[h,a]=Ge(null),{editorConfig:s}=P(),g=s?.admin?.hideGutter?-44:-8;Ce(()=>{function y(d){let f=d.target;if(!be(f))return;let E=Y(r,d.pageX,d.pageY,f);if(E===-1){p(null);return}if(ce(f,po))return;let T=H(t),{blockElem:R,foundAtIndex:S,isFoundNodeEmptyParagraph:k}=V({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new I(d.x,d.y),startIndex:Ue(T.length),useEdgeAsDefault:!1,verbose:!1});ee=S,!(!R&&!k)&&u!==R&&p(R)}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,u]),Ce(()=>{n.current&&ue(u,n.current,e,g)},[e,u,g]),Ce(()=>{function y(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{pageY:T,target:R}=f;if(!be(R))return!1;let S=Y(r,f.pageX,f.pageY,R,100,50),k=H(t),{blockElem:C,foundAtIndex:z,isFoundNodeEmptyParagraph:v}=V({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-S,point:new I(f.x,f.y),startIndex:Ue(k.length),useEdgeAsDefault:!0,verbose:!0});ee=z;let A=c.current;if(C===null||A===null)return!1;if(u!==C){let{isBelow:w,willStayInSamePosition:J}=ze(s?.admin?.hideGutter?"0px":"3rem",g+(s?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),A,C,h,T,e,f,i,v);f.preventDefault(),J||a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:w})}else h?.elem&&(qe(A,h.elem),a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:!1}));return!0}function d(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{dataTransfer:T,pageY:R,target:S}=f,k=T?.getData(Ve)||"";return t.update(()=>{let C=mo(k);if(!C||!be(S))return!1;let z=Y(r,f.pageX,f.pageY,S,100,50),{blockElem:v,isFoundNodeEmptyParagraph:A}=V({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-z,point:new I(f.x,f.y),useEdgeAsDefault:!0});if(!v)return!1;let w=Ye(v);if(!w)return!1;if(w===C)return!0;let{height:J,top:he}=G(v),oe=R>=he+J/2+window.scrollY;A?(w.insertBefore(C),w.remove()):oe?w.insertAfter(C):w.insertBefore(C),u!==null&&p(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let ye=t.getElementByKey(C.getKey());setTimeout(()=>{let D=ye?.getBoundingClientRect();if(!D)return;let N=document.createElement("div");N.className="lexical-block-highlighter",N.style.backgroundColor="var(--theme-elevation-1000",N.style.transition="opacity 0.5s ease-in-out",N.style.zIndex="1",N.style.pointerEvents="none",N.style.boxSizing="border-box",N.style.borderRadius="4px",N.style.position="absolute",document.body.appendChild(N),N.style.opacity="0.1",N.style.height=`${D.height+8}px`,N.style.width=`${D.width+8}px`,N.style.top=`${D.top+window.scrollY-4}px`,N.style.left=`${D.left-4}px`,setTimeout(()=>{N.style.opacity="0",setTimeout(()=>{N.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",y),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",y),document.removeEventListener("drop",d)}},[r,g,e,t,h,u,s?.admin?.hideGutter]);function x(y){let d=y.dataTransfer;if(!d||!u)return;go(d,u);let f="";t.update(()=>{let E=Ye(u);E&&(f=E.getKey())}),l.current=!0,d.setData(Ve,f)}function m(){l.current=!1,h?.elem&&qe(c.current,h?.elem)}return fo(co(Je.Fragment,{children:[me("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:x,ref:n,children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Qe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=uo();return ho(r,o,r._editable)}import{c as yo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as xo}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Eo,$getRoot as bo}from"lexical";import"react";var Xe="insert-paragraph-at-end",Ze=()=>{let t=yo(4),[e]=xo(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(Co)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:Xe,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${Xe}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function Co(){let t=Eo();bo().append(t),t.select()}import{c as No}from"react/compiler-runtime";import{useLexicalComposerContext as Po}from"@lexical/react/LexicalComposerContext";import*as et from"react";var tt=()=>{let t=No(4),{editorConfig:e}=P(),[o]=Po(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>Re(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),et.useEffect(r,n),null};import{jsx as U,jsxs as nt}from"react/jsx-runtime";import{useLexicalComposerContext as Ro}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as rt}from"@payloadcms/ui";import{useCallback as ko,useMemo as wo,useState as To}from"react";import"react";import*as it from"react-dom";import{c as So}from"react/compiler-runtime";import"react";function ot(t,e){let o=So(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,l;return o[0]!==c||o[1]!==i||o[2]!==t?(l=u=>{let{query:p}=u,h="[^"+t+ke+"\\s]",s=new RegExp("(^|\\s|\\()(["+t+"]((?:"+h+"){0,"+c+"}))$").exec(p);if(s!==null){let g=s[1],x=s[3];if(x.length>=i)return{leadOffset:s.index+g.length,matchingString:x,replaceableString:s[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=l):l=o[3],l}var L="slash-menu-popup";function vo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=P(),{i18n:l}=rt(),u=`${L}__item ${L}__item-${e.key}`;t&&(u+=` ${L}__item--selected`);let p=e.key;return e.label&&(p=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:l,schemaPath:i}):e.label),p.length>25&&(p=p.substring(0,25)+"..."),nt("button",{"aria-selected":t,className:u,id:L+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${L}__item-text`,children:p})]},e.key)}function st({anchorElem:t=document.body}){let[e]=Ro(),[o,r]=To(null),{editorConfig:n}=P(),{i18n:c}=rt(),{fieldProps:{featureClientSchemaMap:i,schemaPath:l}}=P(),u=ot("/",{minLength:0}),p=ko(()=>{let a=[];for(let s of n.features.slashMenu.dynamicGroups)if(o){let g=s({editor:e,queryString:o});a=a.concat(g)}return a},[e,o,n?.features]),h=wo(()=>{let a=[];for(let s of n?.features.slashMenu.groups??[])a.push(s);if(o){a=a.map(g=>{let x=g.items.filter(m=>{let y=m.key;return m.label&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),new RegExp(o,"gi").exec(y)?!0:m.keywords!=null?m.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...g,items:x}:null}),a=a.filter(g=>g!=null);let s=p();for(let g of s){let x=a.find(m=>m.key===g.key);x?a=a.filter(m=>m.key!==g.key):x={...g,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,p,i,c,l]);return U(Te,{anchorElem:t,groups:h,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:g,setSelectedItemKey:x})=>a.current&&h.length?it.createPortal(U("div",{className:L,children:h.map(m=>{let y=m.key;return m.label&&i&&(y=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:l}):m.label),nt("div",{className:`${L}__group ${L}__group-${m.key}`,children:[U("div",{className:`${L}__group-title`,children:y}),m.items.map((d,f)=>U(vo,{index:f,isSelected:s===d.key,item:d,onClick:()=>{x(d.key),g(d)},onMouseEnter:()=>{x(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:u})}import{c as Do}from"react/compiler-runtime";import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Bo,TextNode as Lo}from"lexical";import{useEffect as Ao}from"react";function lt(t){let e=Do(6),{features:o}=t,[r]=Mo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=Io(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Lo,l=>{i.forEach(u=>{l.hasFormat(u)&&l.toggleFormat(u)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Ao(n,c),null}function Io(t){let e=Object.keys(Bo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as _o}from"react/compiler-runtime";import{jsx as at}from"react/jsx-runtime";import{ContentEditable as Oo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Fo}from"@payloadcms/ui";import"react";function ct(t){let e=_o(7),{className:o,editorConfig:r}=t,{t:n}=Fo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=at(Oo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:at("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var dt=t=>{let e=$o(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=P(),[l]=Ko(),[u,p]=Uo(null),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=m=>{m!==null&&p(m)},e[0]=h):h=e[0];let a=h,s,g;e[1]!==l||e[2]!==i?(s=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},y=()=>{i.blurEditor(i)},d=l.registerCommand(Go,()=>(m(),!0),ut),f=l.registerCommand(Yo,()=>(y(),!0),ut);return()=>{d(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},g=[l,i],e[1]=l,e[2]=i,e[3]=s,e[4]=g):(s=e[3],g=e[4]),Vo(s,g);let x;if(e[5]!==l||e[6]!==o||e[7]!==r||e[8]!==u||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(d,f,E)=>{(!E.has("focus")||E.size>1)&&c?.(d,f,E)},e[12]=c,e[13]=m):m=e[13];let y;e[14]!==l||e[15]!==o.features.plugins||e[16]!==u||e[17]!==n?(y=u&&te(q.Fragment,{children:[!n&&l.isEditable()&&te(q.Fragment,{children:[b(Qe,{anchorElem:u}),b(He,{anchorElem:u})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&n))return b($,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),l.isEditable()&&b(q.Fragment,{children:b(st,{anchorElem:u})})]}),e[14]=l,e[15]=o.features.plugins,e[16]=u,e[17]=n,e[18]=y):y=e[18],x=te(q.Fragment,{children:[o.features.plugins?.map(qo),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(Jo),b(Wo,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ct,{editorConfig:o})})}),ErrorBoundary:Ho}),b(Ze,{}),b(Ae,{}),b(lt,{features:o.features}),b(zo,{ignoreSelectionChange:!0,onChange:m}),y,l.isEditable()&&te(q.Fragment,{children:[b(jo,{}),o?.features?.markdownTransformers?.length>0&&b(tt,{})]}),o.features.plugins?.map(Qo),o.features.plugins?.map(Xo)]}),o.features.plugins?.map(Zo)]}),e[5]=l,e[6]=o,e[7]=r,e[8]=u,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function qo(t){if(t.position==="aboveContainer")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function Jo(t){if(t.position==="top")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function Qo(t){if(t.position==="normal")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function Xo(t){if(t.position==="bottom")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function Zo(t){if(t.position==="belowContainer")return b($,{clientProps:t.clientProps,plugin:t},t.key)}var ft=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?_(o,{children:_(ft,{providers:e.slice(1),children:t})}):_(o,{children:t})},pt=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:l}=t,u=P(),p=tn(),h=mt.useRef(null),a=on(()=>{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:i!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:De({editorConfig:o}),onError:s=>{throw s},theme:o.lexical.theme}},[o]);return a?_(en,{initialConfig:a,children:_(Se,{editorConfig:o,editorContainerRef:h,fieldProps:r,parentContext:u?.editDepth===p?u:void 0,children:_(ft,{providers:o.features.providers,children:_(dt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):_("p",{children:"Loading..."})};var pe="rich-text-lexical",fn=t=>{let{editorConfig:e,field:o,field:{name:r,admin:{className:n,description:c,readOnly:i}={},label:l,localized:u,required:p},path:h,readOnly:a,validate:s}=t,g=a||i,x=h??r,m=ln(),y=yt((M,F)=>typeof s=="function"?s(M,{...F,required:p}):!0,[s,p]),{customComponents:{AfterInput:d,BeforeInput:f,Description:E,Error:T,Label:R}={},disabled:S,initialValue:k,setValue:C,showError:z,value:v}=cn({path:x,validate:y}),A=g||S,[w,J]=Et(!1),[he,Pe]=Et(),oe=ht.useRef(k),Q=ht.useRef(v);xt(()=>{let M=()=>{let F=window.matchMedia("(max-width: 768px)").matches;F!==w&&J(F)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[w]);let ye=[pe,"field-type",n,z&&"error",A&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!w?`${pe}--show-gutter`:null].filter(Boolean).join(" "),D=`${x}.${m}`,N=yt(M=>{let F=M.toJSON();Q.current=F,C(F)},[C]),bt=dn(()=>un(o),[o]),Ct=an(M=>{Q.current!==v&&JSON.stringify(Q.current)!==JSON.stringify(v)&&(oe.current=M,Q.current=v,Pe(new Date))});return xt(()=>{Object.is(k,oe.current)||Ct(k)},[k]),ge("div",{className:ye,style:bt,children:[O(gt,{CustomComponent:T,Fallback:O(rn,{path:x,showError:z})}),R||O(sn,{label:l,localized:u,path:x,required:p}),ge("div",{className:`${pe}__wrap`,children:[ge(mn,{fallbackRender:pn,onReset:()=>{},children:[f,O(pt,{composerKey:D,editorConfig:e,fieldProps:t,isSmallWidthViewport:w,onChange:N,readOnly:A,value:v},JSON.stringify({path:x,rerenderProviderKey:he})),d]}),E,O(gt,{CustomComponent:E,Fallback:O(nn,{description:c,path:x})})]})]},D)};function pn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[O("p",{children:"Something went wrong:"}),O("pre",{style:{color:"red"},children:t.message})]})}var Fi=fn;export{Fi as RichText};
2
+ //# sourceMappingURL=Field-MAUKSOAP.js.map
@@ -0,0 +1,12 @@
1
+ var st=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";var Q=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 ct(r){return r instanceof Q}import{c as Ne}from"react/compiler-runtime";import{jsx as Ie}from"react/jsx-runtime";import{useLexicalComposerContext as ye}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Oe}from"@lexical/utils";import{$getSelection as V,$isRangeSelection as Z,$isTextNode as Ae,COMMAND_PRIORITY_LOW as be,createCommand as ke,getDOMSelection as Me}from"lexical";import{useEffect as xt,useState as Le}from"react";import*as q from"react";import{c as dt}from"react/compiler-runtime";import{useLexicalComposerContext as mt}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as at}from"@lexical/utils";import{$getSelection as gt,$isRangeSelection as ae,$setSelection as le,COMMAND_PRIORITY_LOW as k,createCommand as fe,KEY_ARROW_DOWN_COMMAND as ue,KEY_ARROW_UP_COMMAND as de,KEY_ENTER_COMMAND as me,KEY_ESCAPE_COMMAND as ge,KEY_TAB_COMMAND as pe}from"lexical";import{useCallback as j,useEffect as M,useLayoutEffect as he,useMemo as xe,useRef as Ee,useState as _e}from"react";var Te="slash-menu-popup",lt=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 Se(r,t,e){let o=e;for(let n=o;n<=t.length;n++)r.substring(r.length-n)===t.substring(0,n)&&(o=n);return o}function we(r){let t=gt();if(!ae(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let o=e.getNode();if(!o.isSimpleText())return;let n=e.offset,c=o.getTextContent().slice(0,n),s=r.replaceableString.length,i=Se(c,r.matchingString,s),a=n-i;if(a<0)return;let f;return a===0?[f]=o.splitText(n):[,f]=o.splitText(a,n),f}function Ce(r,t){let e=getComputedStyle(r),o=e.position==="absolute",n=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let c=r;c=c.parentElement;)if(e=getComputedStyle(c),!(o&&e.position==="static")&&n.test(e.overflow+e.overflowY+e.overflowX))return c;return document.body}function ft(r,t){let e=r.getBoundingClientRect(),o=t.getBoundingClientRect();return e.top>o.top&&e.top<o.bottom}function Re(r,t,e,o){let n=dt(12),[c]=mt(),s;n[0]!==c||n[1]!==e||n[2]!==o||n[3]!==r||n[4]!==t.current?(s=()=>{let a=t.current;if(a!=null&&r!=null){let f=c.getRootElement(),l=f!=null?Ce(f,!1):document.body,m;m=!1;let g;g=ft(a,l);let p=function(){m||(window.requestAnimationFrame(function(){e(),m=!1}),m=!0);let u=ft(a,l);u!==g&&(g=u,o?.(u))},d=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",p,{capture:!0,passive:!0}),d.observe(a),()=>{d.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",p,!0)}}},n[0]=c,n[1]=e,n[2]=o,n[3]=r,n[4]=t.current,n[5]=s):s=n[5];let i;n[6]!==c||n[7]!==e||n[8]!==o||n[9]!==r||n[10]!==t?(i=[c,o,e,r,t],n[6]=c,n[7]=e,n[8]=o,n[9]=r,n[10]=t,n[11]=i):i=n[11],M(s,i)}var ut=fe("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function pt({anchorElementRef:r,close:t,editor:e,groups:o,menuRenderFn:n,resolution:c,shouldSplitNodeWithQuery:s=!1}){let[i,a]=_e(null),f=c.match&&c.match.matchingString||"",l=j(d=>{let u=e.getRootElement();u!==null&&(u.setAttribute("aria-activedescendant",`${Te}__item-${d.key}`),a(d.key))},[e]),m=j(()=>{if(o!==null&&f!=null){let d=o.flatMap(u=>u.items);if(d.length){let u=d[0];l(u)}}},[o,l,f]);M(()=>{m()},[f,m]);let g=j(d=>{t(),e.update(()=>{let u=c.match!=null&&s?we(c.match):null;u&&u.remove()}),setTimeout(()=>{let u;e.read(()=>{u=gt()?.clone()}),e.update(()=>{u&&le(u)}),d.onSelect({editor:e,queryString:c.match?c.match.matchingString:""})},0)},[e,s,c.match,t]);M(()=>()=>{let d=e.getRootElement();d!==null&&d.removeAttribute("aria-activedescendant")},[e]),he(()=>{o===null?a(null):i===null&&m()},[o,i,l,m]),M(()=>at(e.registerCommand(ut,({item:d})=>d.ref&&d.ref.current!=null?(lt(d.ref.current),!0):!1,k)),[e,l]),M(()=>at(e.registerCommand(ue,d=>{let u=d;if(o!==null&&o.length&&i!==null){let x=o.flatMap(T=>T.items),h=x.findIndex(T=>T.key===i),E=h!==x.length-1?h+1:0,_=x[E];if(!_)return!1;l(_),_.ref!=null&&_.ref.current&&e.dispatchCommand(ut,{index:E,item:_}),u.preventDefault(),u.stopImmediatePropagation()}return!0},k),e.registerCommand(de,d=>{let u=d;if(o!==null&&o.length&&i!==null){let x=o.flatMap(T=>T.items),h=x.findIndex(T=>T.key===i),E=h!==0?h-1:x.length-1,_=x[E];if(!_)return!1;l(_),_.ref!=null&&_.ref.current&&lt(_.ref.current),u.preventDefault(),u.stopImmediatePropagation()}return!0},k),e.registerCommand(ge,d=>{let u=d;return u.preventDefault(),u.stopImmediatePropagation(),t(),!0},k),e.registerCommand(pe,d=>{let u=d;if(o===null||i===null)return!1;let h=o.flatMap(E=>E.items).find(E=>E.key===i);return h?(u.preventDefault(),u.stopImmediatePropagation(),g(h),!0):!1},k),e.registerCommand(me,d=>{if(o===null||i===null)return!1;let x=o.flatMap(h=>h.items).find(h=>h.key===i);return x?(d!==null&&(d.preventDefault(),d.stopImmediatePropagation()),g(x),!0):!1},k)),[g,t,e,o,i,l]);let p=xe(()=>({groups:o,selectedItemKey:i,selectItemAndCleanUp:g,setSelectedItemKey:a}),[g,i,o]);return n(r,p,c.match?c.match.matchingString:"")}function Fe(r,t){t!=null&&(r.className=t),r.setAttribute("aria-label","Slash menu"),r.setAttribute("role","listbox"),r.style.display="block",r.style.position="absolute"}function ht(r,t,e,o){let n=dt(14),[c]=mt(),s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=st?document.createElement("div"):null,n[0]=s):s=n[0];let i=Ee(s),a;n[1]!==r||n[2]!==o||n[3]!==c||n[4]!==t?(a=()=>{if(i.current===null||parent===void 0)return;let d=c.getRootElement(),u=i.current,x=u.firstChild;if(d!==null&&t!==null){let{height:h,width:E}=t.getRect(),{left:_,top:T}=t.getRect(),N=T;if(T=T-(r.getBoundingClientRect().top+window.scrollY),_=_-(r.getBoundingClientRect().left+window.scrollX),u.style.left=`${_+window.scrollX}px`,u.style.height=`${h}px`,u.style.width=`${E}px`,x!==null){let S=x.getBoundingClientRect(),F=S.height,w=S.width,I=d.getBoundingClientRect();_+w>I.right&&(u.style.left=`${I.right-w+window.scrollX}px`);let y=N+F+32>window.innerHeight,A=N<0;y&&!A?u.style.top=`${T+32-F+window.scrollY-(h+24)}px`:u.style.top=`${T+window.scrollY+32}px`}u.isConnected||(Fe(u,o),r.append(u)),u.setAttribute("id","slash-menu"),i.current=u,d.setAttribute("aria-controls","slash-menu")}},n[1]=r,n[2]=o,n[3]=c,n[4]=t,n[5]=a):a=n[5];let f=a,l,m;n[6]!==c||n[7]!==f||n[8]!==t?(l=()=>{let d=c.getRootElement();if(t!==null)return f(),()=>{d!==null&&d.removeAttribute("aria-controls");let u=i.current;u!==null&&u.isConnected&&(u.remove(),u.removeAttribute("id"))}},m=[c,f,t],n[6]=c,n[7]=f,n[8]=t,n[9]=l,n[10]=m):(l=n[9],m=n[10]),M(l,m);let g;return n[11]!==t||n[12]!==e?(g=d=>{t!==null&&(d||e(null))},n[11]=t,n[12]=e,n[13]=g):g=n[13],Re(t,i,f,g),i}var eo=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function $e(r){let t=r.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let o=t.offset;return e.getTextContent().slice(0,o)}function Et(r,t,e){let o=Me(e);if(o===null||!o.isCollapsed)return!1;let n=o.anchorNode,c=r,s=o.anchorOffset;if(n==null||s==null)return!1;try{t.setStart(n,c),t.setEnd(n,s>1?s:1)}catch{return!1}return!0}function De(r){let t;return r.getEditorState().read(()=>{let e=V();Z(e)&&(t=$e(e))}),t}function _t(r,t){return t!==0?!1:r.getEditorState().read(()=>{let e=V();if(Z(e)){let c=e.anchor.getNode().getPreviousSibling();return Ae(c)&&c.isTextEntity()}return!1})}function Tt(r){q.startTransition?q.startTransition(r):r()}var Be=ke("ENABLE_SLASH_MENU_COMMAND");function no(r){let t=Ne(30),{anchorClassName:e,anchorElem:o,groups:n,menuRenderFn:c,onClose:s,onOpen:i,onQueryChange:a,triggerFn:f}=r,[l]=ye(),[m,g]=Le(null),p=ht(o,m,g,e),d;t[0]!==s||t[1]!==m?(d=()=>{g(null),s!=null&&m!==null&&s()},t[0]=s,t[1]=m,t[2]=d):d=t[2];let u=d,x;t[3]!==i||t[4]!==m?(x=F=>{g(F),i!=null&&m===null&&i(F)},t[3]=i,t[4]=m,t[5]=x):x=t[5];let h=x,E,_;t[6]!==l||t[7]!==h?(E=()=>Oe(l.registerCommand(Be,F=>{let{node:w}=F;return l.getEditorState().read(()=>{let I={leadOffset:0,matchingString:"",replaceableString:""};if(!_t(l,I.leadOffset)&&w!==null){let y=l._window??window,A=y.document.createRange();Et(I.leadOffset,A,y)!==null&&Tt(()=>h({getRect:()=>A.getBoundingClientRect(),match:I}));return}}),!0},be)),_=[l,h],t[6]=l,t[7]=h,t[8]=E,t[9]=_):(E=t[8],_=t[9]),xt(E,_);let T;t[10]!==u||t[11]!==l||t[12]!==a||t[13]!==h||t[14]!==f?(T=()=>{let F=()=>{l.getEditorState().read(()=>{let I=l._window??window,y=I.document.createRange(),A=V(),W=De(l);if(!Z(A)||!A.isCollapsed()||W===void 0||y===null){u();return}let b=f({editor:l,query:W});if(a(b?b.matchingString:null),b!==null&&!_t(l,b.leadOffset)&&Et(b.leadOffset,y,I)!==null){Tt(()=>h({getRect:()=>y.getBoundingClientRect(),match:b}));return}u()})},w=l.registerUpdateListener(F);return()=>{w()}},t[10]=u,t[11]=l,t[12]=a,t[13]=h,t[14]=f,t[15]=T):T=t[15];let N;t[16]!==u||t[17]!==l||t[18]!==a||t[19]!==h||t[20]!==m||t[21]!==f?(N=[l,f,a,m,u,h],t[16]=u,t[17]=l,t[18]=a,t[19]=h,t[20]=m,t[21]=f,t[22]=N):N=t[22],xt(T,N);let S;return t[23]!==p||t[24]!==u||t[25]!==l||t[26]!==n||t[27]!==c||t[28]!==m?(S=p.current===null||m===null||l===null?null:Ie(pt,{anchorElementRef:p,close:u,editor:l,groups:n,menuRenderFn:c,resolution:m,shouldSplitNodeWithQuery:!0}),t[23]=p,t[24]=u,t[25]=l,t[26]=n,t[27]=c,t[28]=m,t[29]=S):S=t[29],S}var St=class r{_bottom;_left;_right;_top;constructor(t,e,o,n){let[c,s]=e<=n?[e,n]:[n,e],[i,a]=t<=o?[t,o]:[o,t];this._top=c,this._right=a,this._left=i,this._bottom=s}static fromDOM(t){let{height:e,left:o,top:n,width:c}=t.getBoundingClientRect();return r.fromLWTH(o,c,n,e)}static fromDOMRect(t){let{height:e,left:o,top:n,width:c}=t;return r.fromLWTH(o,c,n,e)}static fromLTRB(t,e,o,n){return new r(t,e,o,n)}static fromLWTH(t,e,o,n){return new r(t,o,t+e,o+n)}static fromPoints(t,e){let{x:o,y:n}=t,{x:c,y:s}=e;return r.fromLTRB(o,n,c,s)}contains(t){if(ct(t)){let{x:s,y:i}=t,a=i<this._top,f=i>this._bottom,l=s<this._left,m=s>this._right;return{reason:{isOnBottomSide:f,isOnLeftSide:l,isOnRightSide:m,isOnTopSide:a},result:!a&&!f&&!l&&!m}}let{bottom:e,left:o,right:n,top:c}=t;return c>=this._top&&c<=this._bottom&&e>=this._top&&e<=this._bottom&&o>=this._left&&o<=this._right&&n>=this._left&&n<=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 o=0,n=0;return t.x<this._left?o=this._left-t.x:t.x>this._right&&(o=t.x-this._right),t.y<this._top?n=this._top-t.y:t.y>this._bottom&&(n=t.y-this._bottom),{distance:Math.sqrt(o*o+n*n),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:o,top:n}){return n===this._top&&t===this._bottom&&e===this._left&&o===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:o=this.right,top:n=this.top}){return new r(e,n,o,t)}intersectsWith(t){let{height:e,left:o,top:n,width:c}=t,{height:s,left:i,top:a,width:f}=this,l=o+c>=i+f?o+c:i+f,m=n+e>=a+s?n+e:a+s,g=o<=i?o:i,p=n<=a?n:a;return l-g<=c+f&&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 so({editorConfig:r}){return Pe({nodes:r.features.nodes})}function Pe({nodes:r}){return r.map(t=>"node"in t?t.node:t)}import{$getRoot as We,$isDecoratorNode as Nt,$isElementNode as U,$isLineBreakNode as Qe,$isTextNode as G}from"lexical";import{$isListItemNode as ve,$isListNode as wt}from"@lexical/list";import{$isHeadingNode as He,$isQuoteNode as Ke}from"@lexical/rich-text";import{$isParagraphNode as Ue,$isTextNode as Ge}from"lexical";var C={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...C,requiresParagraphStart:!0},uo={...R,export:L(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},mo={...R,export:L(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},go={...R,export:L(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},po={...R,export:L(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},ho={...R,export:L(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},xo={...R,export:L(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},Eo={...R,export:ze,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},_o={...R,export:J,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},To={...R,export:J,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},So={...R,export:J,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},wo={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},Co={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},Ro={...C,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},Fo={...C,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},No={...C,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},Io={...C,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},yo={...C,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Oo={...C,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Ao={...C,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},bo={...C,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},ko={...C,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},Mo={...C,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Lo={...C,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},$o={...C,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function L(r){return(t,e)=>He(t)&&t.getTag()==="h"+r?"#".repeat(r)+" "+e(t):null}function J(r,t){return wt(r)?Ct(r,t,0):null}var Xe=4;function Ct(r,t,e){let o=[],n=r.getChildren(),c=0;for(let s of n)if(ve(s)){if(s.getChildrenSize()===1){let f=s.getFirstChild();if(wt(f)){o.push(Ct(f,t,e+1));continue}}let i=" ".repeat(e*Xe),a=r.getListType()==="bullet"?"- ":`${r.getStart()+c}. `;o.push(i+a+t(s)),c++}return o.join(`
2
+ `)}function ze(r,t){return Ke(r)?"> "+t(r):null}function H(r,t){let e={};for(let o of r){let n=t(o);n&&(e[n]?e[n].push(o):e[n]=[o])}return e}function $(r){let t=H(r,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var D=/[!-/:-@[-`{-~\s]/,Ye=/^\s{0,3}$/;function v(r){if(!Ue(r))return!1;let t=r.getFirstChild();return t==null||r.getChildrenSize()===1&&Ge(t)&&Ye.test(t.getTextContent())}function It(r,t=!1){let e=$(r),o=[...e.multilineElement,...e.element],n=!t,c=e.textFormat.filter(s=>s.format.length===1).sort((s,i)=>s.format.includes("code")&&!i.format.includes("code")?1:!s.format.includes("code")&&i.format.includes("code")?-1:0);return s=>{let i=[],a=(s||We()).getChildren();return a.forEach((f,l)=>{let m=je(f,o,c,e.textMatch);m!=null&&i.push(n&&l>0&&!v(f)&&!v(a[l-1])?`
3
+ `.concat(m):m)}),i.join(`
4
+ `)}}function je(r,t,e,o){for(let n of t){if(!n.export)continue;let c=n.export(r,s=>X(s,e,o));if(c!=null)return c}return U(r)?X(r,e,o):Nt(r)?r.getTextContent():null}function X(r,t,e,o,n){let c=[],s=r.getChildren();o||(o=[]),n||(n=[]);t:for(let i of s){for(let a of e){if(!a.export)continue;let f=a.export(i,l=>X(l,t,e,o,[...n,...o]),(l,m)=>Rt(l,m,t,o,n));if(f!=null){c.push(f);continue t}}Qe(i)?c.push(`
5
+ `):G(i)?c.push(Rt(i,i.getTextContent(),t,o,n)):U(i)?c.push(X(i,t,e,o,n)):Nt(i)&&c.push(i.getTextContent())}return c.join("")}function Rt(r,t,e,o,n){let c=t.trim(),s=c;r.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",a="",f="",l=Ft(r,!0),m=Ft(r,!1),g=new Set;for(let p of e){let d=p.format[0],u=p.tag;K(r,d)&&!g.has(d)&&(g.add(d),(!K(l,d)||!o.find(x=>x.tag===u))&&(o.push({format:d,tag:u}),i+=u))}for(let p=0;p<o.length;p++){let d=o[p],u=K(r,d.format),x=K(m,d.format);if(u&&x)continue;let h=[...o];for(;h.length>p;){let E=h.pop();n&&E&&n.find(_=>_.tag===E.tag)||(E&&typeof E.tag=="string"&&(u?x||(f+=E.tag):a+=E.tag),o.pop())}break}return s=i+s+f,a+t.replace(c,()=>s)}function Ft(r,t){let e=t?r.getPreviousSibling():r.getNextSibling();if(!e){let o=r.getParentOrThrow();o.isInline()&&(e=t?o.getPreviousSibling():o.getNextSibling())}for(;e;){if(U(e)){if(!e.isInline())break;let o=t?e.getLastDescendant():e.getFirstDescendant();if(G(o))return o;e=t?e.getPreviousSibling():e.getNextSibling()}if(G(e))return e;if(!U(e))return null}return null}function K(r,t){return G(r)&&r.hasFormat(t)}import{$isListItemNode as Ve,$isListNode as kt}from"@lexical/list";import{$isQuoteNode as Ze}from"@lexical/rich-text";import{$findMatchingParent as Je}from"@lexical/utils";import{$createLineBreakNode as tn,$createParagraphNode as en,$createTextNode as nn,$getRoot as on,$getSelection as rn,$isParagraphNode as sn}from"lexical";import{$isTextNode as B}from"lexical";function yt(r,t){let e=r.getTextContent(),o=qe(e,t);if(!o)return null;let n=o.index||0,c=n+o[0].length,s=t.transformersByTag[o[1]];return{endIndex:c,match:o,startIndex:n,transformer:s}}function qe(r,t){let e=r.match(t.openTagsRegExp);if(e==null)return null;for(let o of e){let n=o.replace(/^\s/,""),c=t.fullMatchRegExpByTag[n];if(c==null)continue;let s=r.match(c),i=t.transformersByTag[n];if(s!=null&&i!=null){if(i.intraword!==!1)return s;let{index:a=0}=s,f=r[a-1],l=r[a+s[0].length];if((!f||D.test(f))&&(!l||D.test(l)))return s}}return null}function Ot(r,t,e,o,n){let c=r.getTextContent(),s,i,a;if(n[0]===c?a=r:t===0?[a,s]=r.splitText(e):[i,a,s]=r.splitText(t,e),a.setTextContent(n[2]),o)for(let f of o.format)a.hasFormat(f)||a.toggleFormat(f);return{nodeAfter:s,nodeBefore:i,transformedNode:a}}function At(r,t){let e=r,o,n,c,s;for(let i of t){if(!i.replace||!i.importRegExp)continue;let a=e.getTextContent().match(i.importRegExp);if(!a)continue;let f=a.index||0,l=i.getEndIndex?i.getEndIndex(e,a):f+a[0].length;l!==!1&&(o===void 0||n===void 0||f<o&&l>n)&&(o=f,n=l,c=i,s=a)}return o===void 0||n===void 0||c===void 0||s===void 0?null:{endIndex:n,match:s,startIndex:o,transformer:c}}function bt(r,t,e,o,n){let c,s,i;if(t===0?[i,c]=r.splitText(e):[s,i,c]=r.splitText(t,e),!o.replace)return null;let a=i?o.replace(i,n):void 0;return{nodeAfter:c,nodeBefore:s,transformedNode:a||void 0}}function O(r,t,e){let o=yt(r,t),n=At(r,e);if(o&&n&&(o.startIndex<=n.startIndex&&o.endIndex>=n.endIndex?n=null:o=null),o){let i=Ot(r,o.startIndex,o.endIndex,o.transformer,o.match);i.nodeAfter&&B(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&O(i.nodeAfter,t,e),i.nodeBefore&&B(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&O(i.nodeBefore,t,e),i.transformedNode&&B(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&O(i.transformedNode,t,e)}else if(n){let i=bt(r,n.startIndex,n.endIndex,n.transformer,n.match);if(!i)return;i.nodeAfter&&B(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&O(i.nodeAfter,t,e),i.nodeBefore&&B(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&O(i.nodeBefore,t,e),i.transformedNode&&B(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&O(i.transformedNode,t,e)}let s=r.getTextContent().replace(/\\([*_`~])/g,"$1");r.setTextContent(s)}function Mt(r,t=!1){let e=$(r),o=ln(e.textFormat);return(n,c)=>{let s=n.split(`
6
+ `),i=s.length,a=c||on();a.clear();for(let l=0;l<i;l++){let m=s[l],[g,p]=cn(s,l,e.multilineElement,a);if(g){l=p;continue}an(m,a,e.element,o,e.textMatch)}let f=a.getChildren();for(let l of f)!t&&v(l)&&a.getChildrenSize()>1&&l.remove();rn()!==null&&a.selectStart()}}function cn(r,t,e,o){for(let n of e){let{handleImportAfterStartMatch:c,regExpEnd:s,regExpStart:i,replace:a}=n,f=r[t]?.match(i);if(!f)continue;if(c){let d=c({lines:r,rootNode:o,startLineIndex:t,startMatch:f,transformer:n});if(d===null)continue;if(d)return d}let l=typeof s=="object"&&"regExp"in s?s.regExp:s,m=s&&typeof s=="object"&&"optional"in s?s.optional:!s,g=t,p=r.length;for(;g<p;){let d=l?r[g]?.match(l):null;if(!d&&(!m||m&&g<p-1)){g++;continue}if(d&&t===g&&d.index===f.index){g++;continue}let u=[];if(d&&t===g)u.push(r[t].slice(f[0].length,-d[0].length));else for(let x=t;x<=g;x++){let h=r[x];if(x===t){let E=h.slice(f[0].length);u.push(E)}else if(x===g&&d){let E=h.slice(0,-d[0].length);u.push(E)}else u.push(h)}if(a(o,null,f,d,u,!0)!==!1)return[!0,g];break}}return[!1,t]}function an(r,t,e,o,n){let c=nn(r),s=en();s.append(c),t.append(s);for(let{regExp:i,replace:a}of e){let f=r.match(i);if(f&&(c.setTextContent(r.slice(f[0].length)),a(s,[c],f,!0)!==!1))break}if(O(c,o,n),s.isAttached()&&r.length>0){let i=s.getPreviousSibling();if(sn(i)||Ze(i)||kt(i)){let a=i;if(kt(i)){let f=i.getLastDescendant();f==null?a=null:a=Je(f,Ve)}a!=null&&a.getTextContentSize()>0&&(a.splice(a.getChildrenSize(),0,[tn(),...s.getChildren()]),s.remove())}}}function ln(r){let t={},e={},o=[],n="(?<![\\\\])";for(let c of r){let{tag:s}=c;t[s]=c;let i=s.replace(/([*^+])/g,"\\$1");o.push(i),s.length===1?e[s]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):e[s]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp(`${n}(${o.join("|")})`,"g"),transformersByTag:t}}import{$createRangeSelection as fn,$getSelection as tt,$isLineBreakNode as un,$isRangeSelection as et,$isRootOrShadowRoot as $t,$isTextNode as Dt,$setSelection as dn}from"lexical";function mn(r,t,e,o){let n=r.getParent();if(!$t(n)||r.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExp:s,replace:i}of o){let a=c.match(s);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let f=t.getNextSiblings(),[l,m]=t.splitText(e);l?.remove();let g=m?[m,...f]:f;if(i(r,g,a,!1)!==!1)return!0}}return!1}function gn(r,t,e,o){let n=r.getParent();if(!$t(n)||r.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExpEnd:s,regExpStart:i,replace:a}of o){if(s&&!("optional"in s)||s&&"optional"in s&&!s.optional)continue;let f=c.match(i);if(f&&f[0].length===(f[0].endsWith(" ")?e:e-1)){let l=t.getNextSiblings(),[m,g]=t.splitText(e);m?.remove();let p=g?[g,...l]:l;if(a(r,p,f,null,null,!1)!==!1)return!0}}return!1}function pn(r,t,e){let o=r.getTextContent(),n=o[t-1],c=e[n];if(c==null)return!1;t<o.length&&(o=o.slice(0,t));for(let s of c){if(!s.replace||!s.regExp)continue;let i=o.match(s.regExp);if(i===null)continue;let a=i.index||0,f=a+i[0].length,l;return a===0?[l]=r.splitText(f):[,l]=r.splitText(a,f),l&&(l.selectNext(0,0),s.replace(l,i)),!0}return!1}function hn(r,t,e){let o=r.getTextContent(),n=t-1,c=o[n],s=e[c];if(!s)return!1;for(let i of s){let{tag:a}=i,f=a.length,l=n-f+1;if(f>1&&!Bt(o,l,a,0,f)||o[l-1]===" ")continue;let m=o[n+1];if(i.intraword===!1&&m&&!D.test(m))continue;let g=r,p=g,d=Lt(o,l,a),u=p;for(;d<0&&(u=u.getPreviousSibling())&&!un(u);)if(Dt(u)){let w=u.getTextContent();p=u,d=Lt(w,w.length,a)}if(d<0||p===g&&d+f===l)continue;let x=p.getTextContent();if(d>0&&x[d-1]===c)continue;let h=x[d-1];if(i.intraword===!1&&h&&!D.test(h))continue;let E=g.getTextContent(),_=E.slice(0,l)+E.slice(n+1);g.setTextContent(_);let T=p===g?_:x;p.setTextContent(T.slice(0,d)+T.slice(d+f));let N=tt(),S=fn();dn(S);let F=n-f*(p===g?2:1)+1;S.anchor.set(p.__key,d,"text"),S.focus.set(g.__key,F,"text");for(let w of i.format)S.hasFormat(w)||S.formatText(w);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(let w of i.format)S.hasFormat(w)&&S.toggleFormat(w);return et(N)&&(S.format=N.format),!0}return!1}function Lt(r,t,e){let o=e.length;for(let n=t;n>=o;n--){let c=n-o;if(Bt(r,c,e,0,o)&&r[c+o]!==" ")return c}return-1}function Bt(r,t,e,o,n){for(let c=0;c<n;c++)if(r[t+c]!==e[o+c])return!1;return!0}function or(r,t=z){let e=$(t),o=H(e.textFormat,({tag:s})=>s[s.length-1]),n=H(e.textMatch,({trigger:s})=>s);for(let s of t){let i=s.type;if(i==="element"||i==="text-match"||i==="multiline-element"){let a=s.dependencies;for(let f of a)if(!r.hasNode(f))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+f.getType())}}let c=(s,i,a)=>{mn(s,i,a,e.element)||gn(s,i,a,e.multilineElement)||pn(i,a,n)||hn(i,a,o)};return r.registerUpdateListener(({dirtyLeaves:s,editorState:i,prevEditorState:a,tags:f})=>{if(f.has("collaboration")||f.has("historic")||r.isComposing())return;let l=i.read(tt),m=a.read(tt);if(!et(m)||!et(l)||!l.isCollapsed()||l.is(m))return;let g=l.anchor.key,p=l.anchor.offset,d=i._nodeMap.get(g);!Dt(d)||!s.has(g)||p!==1&&p>m.anchor.offset+1||r.update(()=>{if(d.hasFormat("code"))return;let u=d.getParent();u!==null&&c(u,d,l.anchor.offset)})})}import{$createListItemNode as xn,$createListNode as En,$isListItemNode as _n,$isListNode as P,ListItemNode as ot,ListNode as rt}from"@lexical/list";import{$createHeadingNode as Tn,$createQuoteNode as Sn,$isHeadingNode as wn,$isQuoteNode as Pt,HeadingNode as Cn,QuoteNode as Rn}from"@lexical/rich-text";import{$createLineBreakNode as Fn}from"lexical";var vt=/^[\t ]*$/,Gt=/^(\s*)(\d+)\.\s/,Xt=/^(\s*)[-*+]\s/,zt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,nt=/^(#{1,6})\s/,Yt=/^>\s/,Nn=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,Ht=/[ \t]*(\\`\\`\\`|```)$/,In=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,yn=/^\|(.+)\|\s?$/,On=/^(\| ?:?-*:? ?)+\|\s?$/,Kt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,Ut=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,An=r=>(t,e,o)=>{let n=r(o);n.append(...e),t.replace(n),n.select(0,0)},Wt=4;function bn(r){let t=r.match(/\t/g),e=r.match(/ /g),o=0;return t&&(o+=t.length),e&&(o+=Math.floor(e.length/Wt)),o}var it=r=>(t,e,o)=>{let n=t.getPreviousSibling(),c=t.getNextSibling(),s=xn(r==="check"?o[3]==="x":void 0);if(P(c)&&c.getListType()===r){let a=c.getFirstChild();a!==null?a.insertBefore(s):c.append(s),t.remove()}else if(P(n)&&n.getListType()===r)n.append(s),t.remove();else{let a=En(r,r==="number"?Number(o[2]):void 0);a.append(s),t.replace(a)}s.append(...e),s.select(0,0);let i=bn(o[1]);i&&s.setIndent(i)},Y=(r,t,e)=>{let o=[],n=r.getChildren(),c=0;for(let s of n)if(_n(s)){if(s.getChildrenSize()===1){let l=s.getFirstChild();if(P(l)){o.push(Y(l,t,e+1));continue}}let i=" ".repeat(e*Wt),a=r.getListType(),f=a==="number"?`${r.getStart()+c}. `:a==="check"?`- [${s.getChecked()?"x":" "}] `:"- ";o.push(i+f+t(s)),c++}return o.join(`
7
+ `)},Qt={type:"element",dependencies:[Cn],export:(r,t)=>{if(!wn(r))return null;let e=Number(r.getTag().slice(1));return"#".repeat(e)+" "+t(r)},regExp:nt,replace:An(r=>{let t="h"+r[1].length;return Tn(t)})},jt={type:"element",dependencies:[Rn],export:(r,t)=>{if(!Pt(r))return null;let e=t(r).split(`
8
+ `),o=[];for(let n of e)o.push("> "+n);return o.join(`
9
+ `)},regExp:Yt,replace:(r,t,e,o)=>{if(o){let c=r.getPreviousSibling();if(Pt(c)){c.splice(c.getChildrenSize(),0,[Fn(),...t]),c.select(0,0),r.remove();return}}let n=Sn();n.append(...t),r.replace(n),n.select(0,0)}},qt={type:"element",dependencies:[rt,ot],export:(r,t)=>P(r)?Y(r,t,0):null,regExp:Xt,replace:it("bullet")},kn={type:"element",dependencies:[rt,ot],export:(r,t)=>P(r)?Y(r,t,0):null,regExp:zt,replace:it("check")},Vt={type:"element",dependencies:[rt,ot],export:(r,t)=>P(r)?Y(r,t,0):null,regExp:Gt,replace:it("number")},Zt={type:"text-format",format:["code"],tag:"`"},Jt={type:"text-format",format:["highlight"],tag:"=="},te={type:"text-format",format:["bold","italic"],tag:"***"},ee={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},ne={type:"text-format",format:["bold"],tag:"**"},oe={type:"text-format",format:["bold"],intraword:!1,tag:"__"},re={type:"text-format",format:["strikethrough"],tag:"~~"},ie={type:"text-format",format:["italic"],tag:"*"},se={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function ce(r,t){let e=r.split(`
10
+ `),o=!1,n=[],c=0;for(let s=0;s<e.length;s++){let i=e[s],a=n[n.length-1];if(In.test(i)){n.push(i);continue}if(Ht.test(i)){c===0&&(o=!0),c===1&&(o=!1),c>0&&c--,n.push(i);continue}if(Nn.test(i)){o=!0,c++,n.push(i);continue}if(o){n.push(i);continue}vt.test(i)||vt.test(a)||!a||nt.test(a)||nt.test(i)||Yt.test(i)||Gt.test(i)||Xt.test(i)||zt.test(i)||yn.test(i)||On.test(i)||!t||Kt.test(i)||Ut.test(i)||Kt.test(a)||Ut.test(a)||Ht.test(a)?n.push(i):n[n.length-1]=a+" "+i.trim()}return n.join(`
11
+ `)}var Mn=[Qt,jt,qt,Vt],Ln=[],$n=[Zt,te,ee,ne,oe,Jt,ie,se,re],Dn=[],z=[...Mn,...Ln,...$n,...Dn];function dr(r,t=z,e,o=!1,n=!0){let c=o?r:ce(r,n);return Mt(t,o)(c,e)}function mr(r=z,t,e=!1){return It(r,e)(t)}export{st as a,or as b,dr as c,mr as d,Q as e,ct as f,eo as g,Be as h,no as i,St as j,so as k};
12
+ //# sourceMappingURL=chunk-DOZWITPU.js.map