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