@payloadcms/richtext-lexical 3.24.0-canary.1cfcb91 → 3.24.0-canary.48fef90
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-NNWFQETL.js → Field-ZQTPXWY3.js} +2 -2
- package/dist/exports/client/chunk-CIY6PKN6.js +12 -0
- package/dist/exports/client/chunk-CIY6PKN6.js.map +7 -0
- package/dist/exports/client/index.js +2 -2
- package/dist/exports/react/components/RichText/converter/converters/table.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/table.js +7 -10
- package/dist/exports/react/components/RichText/converter/converters/table.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts +3 -3
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/validate.d.ts +0 -5
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js +2 -8
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/experimental_table/server/index.js +1 -1
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/link/server/validate.d.ts.map +1 -1
- package/dist/features/link/server/validate.js +2 -3
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/upload/server/feature.server.d.ts.map +1 -1
- package/dist/features/upload/server/feature.server.js +3 -4
- package/dist/features/upload/server/feature.server.js.map +1 -1
- package/dist/features/upload/server/validate.d.ts.map +1 -1
- package/dist/features/upload/server/validate.js +4 -5
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -11
- package/dist/index.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.js +5 -5
- package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.js +5 -6
- package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +4 -6
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +1 -4
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +1 -2
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +4 -4
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +4 -4
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/dist/validate/hasText.js +1 -1
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +7 -7
- package/dist/exports/client/chunk-OZ6Q4DWN.js +0 -12
- package/dist/exports/client/chunk-OZ6Q4DWN.js.map +0 -7
- /package/dist/exports/client/{Field-NNWFQETL.js.map → Field-ZQTPXWY3.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{c as Re,f as G,g as _,i as ke,j as we,k as Te,l as ve,m as De}from"./chunk-OZ6Q4DWN.js";import{a as Se,b as P}from"./chunk-3LGFOM34.js";import{jsx as F,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 O}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 oe}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 X from"react";import{useEffect as Vo,useState as Uo}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var K=({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 Pt}from"react/compiler-runtime";import{useLexicalComposerContext as St}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Rt}from"@lexical/utils";import{$createNodeSelection as kt,$getEditor as Z,$getNearestNodeFromDOMNode as wt,$getSelection as re,$isDecoratorNode as H,$isElementNode as Ee,$isLineBreakNode as Tt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as vt,$isTextNode as Dt,$setSelection as Le,CLICK_COMMAND as Mt,COMMAND_PRIORITY_LOW as V,KEY_ARROW_DOWN_COMMAND as Bt,KEY_ARROW_UP_COMMAND as Lt,KEY_BACKSPACE_COMMAND as It,KEY_DELETE_COMMAND as At,SELECTION_CHANGE_COMMAND as _t}from"lexical";import{useEffect as Ot}from"react";function Ie(){let t=Pt(3),[e]=St(),o=Wt,r,n;return t[0]!==e?(r=()=>Rt(e.registerCommand(Mt,zt,V),e.registerCommand(At,o,V),e.registerCommand(It,o,V),e.registerCommand(_t,jt,V),e.registerCommand(Lt,Kt,V),e.registerCommand(Bt,Ft,V)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Ot(r,n),null}function Ft(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p&&ee({element:p,node:i}),!0}if(!Ee(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,$t),c=n?.getNextSibling();if(!n||c!==Ae(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function $t(t){return Ae(t)!==null}function Kt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p?(ee({element:p,node:i}),t.preventDefault(),!0):!1}if(!Ee(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,Ht),c=n?.getPreviousSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function Ht(t){return _e(t)!==null}function jt(){let t=Vt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function zt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Gt(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):ee(e),!0}function Wt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Yt),!0):!1}function Yt(t){t.remove()}function Gt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=wt(e);return H(o)?{element:e,node:o}:void 0}function Vt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return H(o)?{decorator:o,element:Z().getElementByKey(o.getKey())}:void 0}function ee({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=kt();o.add(e.getKey()),Le(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(H(t)&&!t.isInline())return!0;if(!Ee(t)||vt(t))return!1;let e=t.getFirstChild(),o=e===null||Tt(e)||Dt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Ae(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 Ce}from"react/jsx-runtime";import{useLexicalComposerContext as Zt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode 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 U=(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 q(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 Ut}from"lexical";function j(t){return t.getEditorState().read(()=>Ut().getChildrenKeys())}var qt=1,Jt=-1,Oe=0,B={props:null,result:null};function Qt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function J(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&&Qt(B.props.point,t.point,o))return B.result;let h=e.getBoundingClientRect(),a=j(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]=[q(m),q(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+c,l),f=ve.fromDOMRect(q(y)),{marginBottom:E,marginTop:k}=le(y),R=f.generateNewRect({bottom:f.bottom+E,left:h.left,right:h.right,top:f.top-k}),{distance:S,isOnBottomSide:w,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=Jt:w?x=qt: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 Xt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Fe(t){if(!t||Xt.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(!G(s))return;let g=U(r,a.pageX,a.pageY,s);if(g===-1){u(null);return}if(ce(s,io))return;let x=j(t),{blockElem:m,blockNode:y,foundAtIndex:d}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-g,point:new _(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=eo();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(Ce(Ke.Fragment,{children:Ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:h=>{p(h)},ref:i,type:"button",children:Ce("div",{className:o?"icon":""})})}),e)}function He(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=Zt();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}from"lexical";import*as Je from"react";import{useEffect as be,useRef as fe,useState as Ge}from"react";import{createPortal as fo}from"react-dom";var je=0,ao=-24;var z=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)&&(z++,z<200&&(f=!0));else{z++;let S=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(d===n?.isBelow&&S===w||z<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 k=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(${k}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="")),z=0,{isBelow:d,willStayInSamePosition:f}}var po="draggable-block-menu",Ve="application/x-lexical-drag-block",te=1/0;function Ue(t){return t===0?1/0:te>=0&&te<t?te: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;be(()=>{function y(d){let f=d.target;if(!G(f))return;let E=U(r,d.pageX,d.pageY,f);if(E===-1){p(null);return}if(ce(f,po))return;let k=j(t),{blockElem:R,foundAtIndex:S,isFoundNodeEmptyParagraph:w}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:Ue(k.length),useEdgeAsDefault:!1,verbose:!1});te=S,!(!R&&!w)&&u!==R&&p(R)}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,u]),be(()=>{n.current&&ue(u,n.current,e,g)},[e,u,g]),be(()=>{function y(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{pageY:k,target:R}=f;if(!G(R))return!1;let S=U(r,f.pageX,f.pageY,R,100,50),w=j(t),{blockElem:C,foundAtIndex:W,isFoundNodeEmptyParagraph:I}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-S,point:new _(f.x,f.y),startIndex:Ue(w.length),useEdgeAsDefault:!0,verbose:!0});te=W;let T=c.current;if(C===null||T===null)return!1;if(u!==C){let{isBelow:v,willStayInSamePosition:A}=ze(s?.admin?.hideGutter?"0px":"3rem",g+(s?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,C,h,k,e,f,i,I);f.preventDefault(),A||a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:v})}else h?.elem&&(qe(T,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:k,pageY:R,target:S}=f,w=k?.getData(Ve)||"";return t.update(()=>{let C=mo(w);if(!C||!G(S))return!1;let W=U(r,f.pageX,f.pageY,S,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-W,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let v=Ye(I);if(!v)return!1;if(v===C)return!0;let{height:A,top:he}=q(I),ye=R>=he+A/2+window.scrollY;T?(v.insertBefore(C),v.remove()):ye?v.insertAfter(C):v.insertBefore(C),u!==null&&p(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let Y=t.getElementByKey(C.getKey());setTimeout(()=>{let D=Y?.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 Co}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(bo)},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 bo(){let t=Eo();Co().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 Q,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&&Q(e.Icon,{}),Q("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 Q(Te,{anchorElem:t,groups:h,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:g,setSelectedItemKey:x})=>a.current&&h.length?it.createPortal(Q("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:[Q("div",{className:`${L}__group-title`,children:y}),m.items.map((d,f)=>Q(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 Io}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=Ao(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],Io(n,c),null}function Ao(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&&oe(X.Fragment,{children:[!n&&l.isEditable()&&oe(X.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(K,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),l.isEditable()&&b(X.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=oe(X.Fragment,{children:[o.features.plugins?.map(qo),oe("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(Ie,{}),b(lt,{features:o.features}),b(zo,{ignoreSelectionChange:!0,onChange:m}),y,l.isEditable()&&oe(X.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(K,{clientProps:t.clientProps,plugin:t},t.key)}function Jo(t){if(t.position==="top")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Qo(t){if(t.position==="normal")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Xo(t){if(t.position==="bottom")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Zo(t){if(t.position==="belowContainer")return b(K,{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(o,{children:O(ft,{providers:e.slice(1),children:t})}):O(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?O(en,{initialConfig:a,children:O(Se,{editorConfig:o,editorContainerRef:h,fieldProps:r,parentContext:u?.editDepth===p?u:void 0,children:O(ft,{providers:o.features.providers,children:O(dt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("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,$)=>typeof s=="function"?s(M,{...$,required:p}):!0,[s,p]),{customComponents:{AfterInput:d,BeforeInput:f,Description:E,Error:k,Label:R}={},formInitializing:S,formProcessing:w,initialValue:C,setValue:W,showError:I,value:T}=cn({path:x,validate:y}),v=g||w||S,[A,he]=Et(!1),[Pe,ye]=Et(),xe=ht.useRef(C),Y=ht.useRef(T);xt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==A&&he($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[A]);let D=[pe,"field-type",n,I&&"error",v&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!A?`${pe}--show-gutter`:null].filter(Boolean).join(" "),N=`${x}.${m}`,Ct=yt(M=>{let $=M.toJSON();Y.current=$,W($)},[W]),bt=dn(()=>un(o),[o]),Nt=an(M=>{Y.current!==T&&JSON.stringify(Y.current)!==JSON.stringify(T)&&(xe.current=M,Y.current=T,ye(new Date))});return xt(()=>{Object.is(C,xe.current)||Nt(C)},[C]),ge("div",{className:D,style:bt,children:[F(gt,{CustomComponent:k,Fallback:F(rn,{path:x,showError:I})}),R||F(sn,{label:l,localized:u,path:x,required:p}),ge("div",{className:`${pe}__wrap`,children:[ge(mn,{fallbackRender:pn,onReset:()=>{},children:[f,F(pt,{composerKey:N,editorConfig:e,fieldProps:t,isSmallWidthViewport:A,onChange:Ct,readOnly:v,value:T},JSON.stringify({path:x,rerenderProviderKey:Pe})),d]}),E,F(gt,{CustomComponent:E,Fallback:F(nn,{description:c,path:x})})]})]},N)};function pn({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 Ki=fn;export{Ki as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-
|
|
1
|
+
"use client";import{c as Re,f as G,g as _,i as ke,j as we,k as Te,l as ve,m as De}from"./chunk-CIY6PKN6.js";import{a as Se,b as P}from"./chunk-3LGFOM34.js";import{jsx as F,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 O}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 oe}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 X from"react";import{useEffect as Vo,useState as Uo}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var K=({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 Pt}from"react/compiler-runtime";import{useLexicalComposerContext as St}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as Rt}from"@lexical/utils";import{$createNodeSelection as kt,$getEditor as Z,$getNearestNodeFromDOMNode as wt,$getSelection as re,$isDecoratorNode as H,$isElementNode as Ee,$isLineBreakNode as Tt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as vt,$isTextNode as Dt,$setSelection as Le,CLICK_COMMAND as Mt,COMMAND_PRIORITY_LOW as V,KEY_ARROW_DOWN_COMMAND as Bt,KEY_ARROW_UP_COMMAND as Lt,KEY_BACKSPACE_COMMAND as It,KEY_DELETE_COMMAND as At,SELECTION_CHANGE_COMMAND as _t}from"lexical";import{useEffect as Ot}from"react";function Ie(){let t=Pt(3),[e]=St(),o=Wt,r,n;return t[0]!==e?(r=()=>Rt(e.registerCommand(Mt,zt,V),e.registerCommand(At,o,V),e.registerCommand(It,o,V),e.registerCommand(_t,jt,V),e.registerCommand(Lt,Kt,V),e.registerCommand(Bt,Ft,V)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Ot(r,n),null}function Ft(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p&&ee({element:p,node:i}),!0}if(!Ee(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,$t),c=n?.getNextSibling();if(!n||c!==Ae(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function $t(t){return Ae(t)!==null}function Kt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let p=Z().getElementByKey(i.getKey());return p?(ee({element:p,node:i}),t.preventDefault(),!0):!1}if(!Ee(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,Ht),c=n?.getPreviousSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=Z().getElementByKey(c.getKey());if(i)return ee({element:i,node:c}),t.preventDefault(),!0}return!1}function Ht(t){return _e(t)!==null}function jt(){let t=Vt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function zt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Gt(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):ee(e),!0}function Wt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Yt),!0):!1}function Yt(t){t.remove()}function Gt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=wt(e);return H(o)?{element:e,node:o}:void 0}function Vt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return H(o)?{decorator:o,element:Z().getElementByKey(o.getKey())}:void 0}function ee({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=kt();o.add(e.getKey()),Le(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(H(t)&&!t.isInline())return!0;if(!Ee(t)||vt(t))return!1;let e=t.getFirstChild(),o=e===null||Tt(e)||Dt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Ae(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 Ce}from"react/jsx-runtime";import{useLexicalComposerContext as Zt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode 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 U=(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 q(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 Ut}from"lexical";function j(t){return t.getEditorState().read(()=>Ut().getChildrenKeys())}var qt=1,Jt=-1,Oe=0,B={props:null,result:null};function Qt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function J(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&&Qt(B.props.point,t.point,o))return B.result;let h=e.getBoundingClientRect(),a=j(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]=[q(m),q(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+c,l),f=ve.fromDOMRect(q(y)),{marginBottom:E,marginTop:k}=le(y),R=f.generateNewRect({bottom:f.bottom+E,left:h.left,right:h.right,top:f.top-k}),{distance:S,isOnBottomSide:w,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=Jt:w?x=qt: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 Xt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Fe(t){if(!t||Xt.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(!G(s))return;let g=U(r,a.pageX,a.pageY,s);if(g===-1){u(null);return}if(ce(s,io))return;let x=j(t),{blockElem:m,blockNode:y,foundAtIndex:d}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-g,point:new _(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=eo();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(Ce(Ke.Fragment,{children:Ce("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:h=>{p(h)},ref:i,type:"button",children:Ce("div",{className:o?"icon":""})})}),e)}function He(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=Zt();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}from"lexical";import*as Je from"react";import{useEffect as be,useRef as fe,useState as Ge}from"react";import{createPortal as fo}from"react-dom";var je=0,ao=-24;var z=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)&&(z++,z<200&&(f=!0));else{z++;let S=n?.boundingBox?.y,w=r.getBoundingClientRect().y;(d===n?.isBelow&&S===w||z<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 k=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(${k}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="")),z=0,{isBelow:d,willStayInSamePosition:f}}var po="draggable-block-menu",Ve="application/x-lexical-drag-block",te=1/0;function Ue(t){return t===0?1/0:te>=0&&te<t?te: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;be(()=>{function y(d){let f=d.target;if(!G(f))return;let E=U(r,d.pageX,d.pageY,f);if(E===-1){p(null);return}if(ce(f,po))return;let k=j(t),{blockElem:R,foundAtIndex:S,isFoundNodeEmptyParagraph:w}=J({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:Ue(k.length),useEdgeAsDefault:!1,verbose:!1});te=S,!(!R&&!w)&&u!==R&&p(R)}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[r,e,t,u]),be(()=>{n.current&&ue(u,n.current,e,g)},[e,u,g]),be(()=>{function y(f){if(!l.current)return!1;let[E]=We(f);if(E)return!1;let{pageY:k,target:R}=f;if(!G(R))return!1;let S=U(r,f.pageX,f.pageY,R,100,50),w=j(t),{blockElem:C,foundAtIndex:W,isFoundNodeEmptyParagraph:I}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-S,point:new _(f.x,f.y),startIndex:Ue(w.length),useEdgeAsDefault:!0,verbose:!0});te=W;let T=c.current;if(C===null||T===null)return!1;if(u!==C){let{isBelow:v,willStayInSamePosition:A}=ze(s?.admin?.hideGutter?"0px":"3rem",g+(s?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),T,C,h,k,e,f,i,I);f.preventDefault(),A||a({boundingBox:C.getBoundingClientRect(),elem:C,isBelow:v})}else h?.elem&&(qe(T,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:k,pageY:R,target:S}=f,w=k?.getData(Ve)||"";return t.update(()=>{let C=mo(w);if(!C||!G(S))return!1;let W=U(r,f.pageX,f.pageY,S,100,50),{blockElem:I,isFoundNodeEmptyParagraph:T}=J({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-W,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let v=Ye(I);if(!v)return!1;if(v===C)return!0;let{height:A,top:he}=q(I),ye=R>=he+A/2+window.scrollY;T?(v.insertBefore(C),v.remove()):ye?v.insertAfter(C):v.insertBefore(C),u!==null&&p(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let Y=t.getElementByKey(C.getKey());setTimeout(()=>{let D=Y?.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 Co}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(bo)},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 bo(){let t=Eo();Co().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 Q,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&&Q(e.Icon,{}),Q("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 Q(Te,{anchorElem:t,groups:h,menuRenderFn:(a,{selectedItemKey:s,selectItemAndCleanUp:g,setSelectedItemKey:x})=>a.current&&h.length?it.createPortal(Q("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:[Q("div",{className:`${L}__group-title`,children:y}),m.items.map((d,f)=>Q(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 Io}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=Ao(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],Io(n,c),null}function Ao(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&&oe(X.Fragment,{children:[!n&&l.isEditable()&&oe(X.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(K,{anchorElem:u,clientProps:d.clientProps,plugin:d},d.key)}),l.isEditable()&&b(X.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=oe(X.Fragment,{children:[o.features.plugins?.map(qo),oe("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(Ie,{}),b(lt,{features:o.features}),b(zo,{ignoreSelectionChange:!0,onChange:m}),y,l.isEditable()&&oe(X.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(K,{clientProps:t.clientProps,plugin:t},t.key)}function Jo(t){if(t.position==="top")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Qo(t){if(t.position==="normal")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Xo(t){if(t.position==="bottom")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function Zo(t){if(t.position==="belowContainer")return b(K,{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(o,{children:O(ft,{providers:e.slice(1),children:t})}):O(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?O(en,{initialConfig:a,children:O(Se,{editorConfig:o,editorContainerRef:h,fieldProps:r,parentContext:u?.editDepth===p?u:void 0,children:O(ft,{providers:o.features.providers,children:O(dt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("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,$)=>typeof s=="function"?s(M,{...$,required:p}):!0,[s,p]),{customComponents:{AfterInput:d,BeforeInput:f,Description:E,Error:k,Label:R}={},formInitializing:S,formProcessing:w,initialValue:C,setValue:W,showError:I,value:T}=cn({path:x,validate:y}),v=g||w||S,[A,he]=Et(!1),[Pe,ye]=Et(),xe=ht.useRef(C),Y=ht.useRef(T);xt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==A&&he($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[A]);let D=[pe,"field-type",n,I&&"error",v&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!A?`${pe}--show-gutter`:null].filter(Boolean).join(" "),N=`${x}.${m}`,Ct=yt(M=>{let $=M.toJSON();Y.current=$,W($)},[W]),bt=dn(()=>un(o),[o]),Nt=an(M=>{Y.current!==T&&JSON.stringify(Y.current)!==JSON.stringify(T)&&(xe.current=M,Y.current=T,ye(new Date))});return xt(()=>{Object.is(C,xe.current)||Nt(C)},[C]),ge("div",{className:D,style:bt,children:[F(gt,{CustomComponent:k,Fallback:F(rn,{path:x,showError:I})}),R||F(sn,{label:l,localized:u,path:x,required:p}),ge("div",{className:`${pe}__wrap`,children:[ge(mn,{fallbackRender:pn,onReset:()=>{},children:[f,F(pt,{composerKey:N,editorConfig:e,fieldProps:t,isSmallWidthViewport:A,onChange:Ct,readOnly:v,value:T},JSON.stringify({path:x,rerenderProviderKey:Pe})),d]}),E,F(gt,{CustomComponent:E,Fallback:F(nn,{description:c,path:x})})]})]},N)};function pn({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 Ki=fn;export{Ki as RichText};
|
|
2
|
+
//# sourceMappingURL=Field-ZQTPXWY3.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var R=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Gn(r){return r instanceof HTMLElement}var j=class{_x;_y;constructor(t,e){this._x=t,this._y=e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}equals({x:t,y:e}){return this.x===t&&this.y===e}get x(){return this._x}get y(){return this._y}};function ft(r){return r instanceof j}import{c as Ae}from"react/compiler-runtime";import{jsx as Oe}from"react/jsx-runtime";import{useLexicalComposerContext as ye}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Me}from"@lexical/utils";import{$getSelection as Z,$isRangeSelection as J,$isTextNode as be,COMMAND_PRIORITY_LOW as ke,createCommand as Le,getDOMSelection as $e}from"lexical";import{useEffect as Tt,useState as De}from"react";import*as V from"react";import{c as pt}from"react/compiler-runtime";import{useLexicalComposerContext as ht}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ut}from"@lexical/utils";import{$getSelection as xt,$isRangeSelection as ue,$setSelection as de,COMMAND_PRIORITY_LOW as k,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 q,useEffect as L,useLayoutEffect as _e,useMemo as Te,useRef as Se,useState as we}from"react";var Re="slash-menu-popup",dt=r=>{let t=document.getElementById("slash-menu");if(!t)return;let e=t.getBoundingClientRect();e.top+e.height>window.innerHeight&&t.scrollIntoView({block:"center"}),e.top<0&&t.scrollIntoView({block:"center"}),r.scrollIntoView({block:"nearest"})};function Ce(r,t,e){let n=e;for(let o=n;o<=t.length;o++)r.substring(r.length-o)===t.substring(0,o)&&(n=o);return n}function Ie(r){let t=xt();if(!ue(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let n=e.getNode();if(!n.isSimpleText())return;let o=e.offset,i=n.getTextContent().slice(0,o),c=r.replaceableString.length,s=Ce(i,r.matchingString,c),a=o-s;if(a<0)return;let l;return a===0?[l]=n.splitText(o):[,l]=n.splitText(a,o),l}function Fe(r,t){let e=getComputedStyle(r),n=e.position==="absolute",o=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let i=r;i=i.parentElement;)if(e=getComputedStyle(i),!(n&&e.position==="static")&&o.test(e.overflow+e.overflowY+e.overflowX))return i;return document.body}function mt(r,t){let e=r.getBoundingClientRect(),n=t.getBoundingClientRect();return e.top>n.top&&e.top<n.bottom}function Ne(r,t,e,n){let o=pt(12),[i]=ht(),c;o[0]!==i||o[1]!==e||o[2]!==n||o[3]!==r||o[4]!==t.current?(c=()=>{let a=t.current;if(a!=null&&r!=null){let l=i.getRootElement(),f=l!=null?Fe(l,!1):document.body,m;m=!1;let g;g=mt(a,f);let p=function(){m||(window.requestAnimationFrame(function(){e(),m=!1}),m=!0);let u=mt(a,f);u!==g&&(g=u,n?.(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)}}},o[0]=i,o[1]=e,o[2]=n,o[3]=r,o[4]=t.current,o[5]=c):c=o[5];let s;o[6]!==i||o[7]!==e||o[8]!==n||o[9]!==r||o[10]!==t?(s=[i,n,e,r,t],o[6]=i,o[7]=e,o[8]=n,o[9]=r,o[10]=t,o[11]=s):s=o[11],L(c,s)}var gt=me("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function Et({anchorElementRef:r,close:t,editor:e,groups:n,menuRenderFn:o,resolution:i,shouldSplitNodeWithQuery:c=!1}){let[s,a]=we(null),l=i.match&&i.match.matchingString||"",f=q(d=>{let u=e.getRootElement();u!==null&&(u.setAttribute("aria-activedescendant",`${Re}__item-${d.key}`),a(d.key))},[e]),m=q(()=>{if(n!==null&&l!=null){let d=n.flatMap(u=>u.items);if(d.length){let u=d[0];f(u)}}},[n,f,l]);L(()=>{m()},[l,m]);let g=q(d=>{t(),e.update(()=>{let u=i.match!=null&&c?Ie(i.match):null;u&&u.remove()}),setTimeout(()=>{let u;e.read(()=>{u=xt()?.clone()}),e.update(()=>{u&&de(u)}),d.onSelect({editor:e,queryString:i.match?i.match.matchingString:""})},0)},[e,c,i.match,t]);L(()=>()=>{let d=e.getRootElement();d!==null&&d.removeAttribute("aria-activedescendant")},[e]),_e(()=>{n===null?a(null):s===null&&m()},[n,s,f,m]),L(()=>ut(e.registerCommand(gt,({item:d})=>d.ref&&d.ref.current!=null?(dt(d.ref.current),!0):!1,k)),[e,f]),L(()=>ut(e.registerCommand(ge,d=>{let u=d;if(n!==null&&n.length&&s!==null){let x=n.flatMap(_=>_.items),h=x.findIndex(_=>_.key===s),T=h!==x.length-1?h+1:0,E=x[T];if(!E)return!1;f(E),E.ref!=null&&E.ref.current&&e.dispatchCommand(gt,{index:T,item:E}),u.preventDefault(),u.stopImmediatePropagation()}return!0},k),e.registerCommand(pe,d=>{let u=d;if(n!==null&&n.length&&s!==null){let x=n.flatMap(_=>_.items),h=x.findIndex(_=>_.key===s),T=h!==0?h-1:x.length-1,E=x[T];if(!E)return!1;f(E),E.ref!=null&&E.ref.current&&dt(E.ref.current),u.preventDefault(),u.stopImmediatePropagation()}return!0},k),e.registerCommand(xe,d=>{let u=d;return u.preventDefault(),u.stopImmediatePropagation(),t(),!0},k),e.registerCommand(Ee,d=>{let u=d;if(n===null||s===null)return!1;let h=n.flatMap(T=>T.items).find(T=>T.key===s);return h?(u.preventDefault(),u.stopImmediatePropagation(),g(h),!0):!1},k),e.registerCommand(he,d=>{if(n===null||s===null)return!1;let x=n.flatMap(h=>h.items).find(h=>h.key===s);return x?(d!==null&&(d.preventDefault(),d.stopImmediatePropagation()),g(x),!0):!1},k)),[g,t,e,n,s,f]);let p=Te(()=>({groups:n,selectedItemKey:s,selectItemAndCleanUp:g,setSelectedItemKey:a}),[g,s,n]);return o(r,p,i.match?i.match.matchingString:"")}function _t(r,t,e,n){let o=pt(14),[i]=ht(),c;o[0]===Symbol.for("react.memo_cache_sentinel")?(c=R?document.createElement("div"):null,o[0]=c):c=o[0];let s=Se(c),a;o[1]!==r||o[2]!==n||o[3]!==i||o[4]!==t?(a=()=>{if(s.current===null||parent===void 0)return;let d=i.getRootElement(),u=s.current,x=u.firstChild;if(d!==null&&t!==null){let{height:h,width:T}=t.getRect(),{left:E,top:_}=t.getRect(),N=_;if(_=_-(r.getBoundingClientRect().top+window.scrollY),E=E-(r.getBoundingClientRect().left+window.scrollX),u.style.left=`${E+window.scrollX}px`,u.style.height=`${h}px`,u.style.width=`${T}px`,x!==null){let S=x.getBoundingClientRect(),F=S.height,w=S.width,A=d.getBoundingClientRect();E+w>A.right&&(u.style.left=`${A.right-w+window.scrollX}px`);let O=N+F+32>window.innerHeight,M=N<0;O&&!M?u.style.top=`${_+32-F+window.scrollY-(h+24)}px`:u.style.top=`${_+window.scrollY+32}px`}u.isConnected||(n!=null&&(u.className=n),u.setAttribute("aria-label","Slash menu"),u.setAttribute("id","slash-menu"),u.setAttribute("role","listbox"),u.style.display="block",u.style.position="absolute",r.append(u)),s.current=u,d.setAttribute("aria-controls","slash-menu")}},o[1]=r,o[2]=n,o[3]=i,o[4]=t,o[5]=a):a=o[5];let l=a,f,m;o[6]!==i||o[7]!==l||o[8]!==t?(f=()=>{let d=i.getRootElement();if(t!==null)return l(),()=>{d!==null&&d.removeAttribute("aria-controls");let u=s.current;u!==null&&u.isConnected&&u.remove()}},m=[i,l,t],o[6]=i,o[7]=l,o[8]=t,o[9]=f,o[10]=m):(f=o[9],m=o[10]),L(f,m);let g;return o[11]!==t||o[12]!==e?(g=d=>{t!==null&&(d||e(null))},o[11]=t,o[12]=e,o[13]=g):g=o[13],Ne(t,s,l,g),s}var co=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Be(r){let t=r.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let n=t.offset;return e.getTextContent().slice(0,n)}function St(r,t,e){let n=$e(e);if(n===null||!n.isCollapsed)return!1;let o=n.anchorNode,i=r,c=n.anchorOffset;if(o==null||c==null)return!1;try{t.setStart(o,i),t.setEnd(o,c>1?c:1)}catch{return!1}return!0}function Pe(r){let t;return r.getEditorState().read(()=>{let e=Z();J(e)&&(t=Be(e))}),t}function wt(r,t){return t!==0?!1:r.getEditorState().read(()=>{let e=Z();if(J(e)){let i=e.anchor.getNode().getPreviousSibling();return be(i)&&i.isTextEntity()}return!1})}function Rt(r){V.startTransition?V.startTransition(r):r()}var ve=Le("ENABLE_SLASH_MENU_COMMAND");function ao(r){let t=Ae(30),{anchorClassName:e,anchorElem:n,groups:o,menuRenderFn:i,onClose:c,onOpen:s,onQueryChange:a,triggerFn:l}=r,[f]=ye(),[m,g]=De(null),p=_t(n,m,g,e),d;t[0]!==c||t[1]!==m?(d=()=>{g(null),c!=null&&m!==null&&c()},t[0]=c,t[1]=m,t[2]=d):d=t[2];let u=d,x;t[3]!==s||t[4]!==m?(x=F=>{g(F),s!=null&&m===null&&s(F)},t[3]=s,t[4]=m,t[5]=x):x=t[5];let h=x,T,E;t[6]!==f||t[7]!==h?(T=()=>Me(f.registerCommand(ve,F=>{let{node:w}=F;return f.getEditorState().read(()=>{let A={leadOffset:0,matchingString:"",replaceableString:""};if(!wt(f,A.leadOffset)&&w!==null){let O=f._window??window,M=O.document.createRange();St(A.leadOffset,M,O)!==null&&Rt(()=>h({getRect:()=>M.getBoundingClientRect(),match:A}));return}}),!0},ke)),E=[f,h],t[6]=f,t[7]=h,t[8]=T,t[9]=E):(T=t[8],E=t[9]),Tt(T,E);let _;t[10]!==u||t[11]!==f||t[12]!==a||t[13]!==h||t[14]!==l?(_=()=>{let F=()=>{f.getEditorState().read(()=>{let A=f._window??window,O=A.document.createRange(),M=Z(),Q=Pe(f);if(!J(M)||!M.isCollapsed()||Q===void 0||O===null){u();return}let b=l({editor:f,query:Q});if(a(b?b.matchingString:null),b!==null&&!wt(f,b.leadOffset)&&St(b.leadOffset,O,A)!==null){Rt(()=>h({getRect:()=>O.getBoundingClientRect(),match:b}));return}u()})},w=f.registerUpdateListener(F);return()=>{w()}},t[10]=u,t[11]=f,t[12]=a,t[13]=h,t[14]=l,t[15]=_):_=t[15];let N;t[16]!==u||t[17]!==f||t[18]!==a||t[19]!==h||t[20]!==m||t[21]!==l?(N=[f,l,a,m,u,h],t[16]=u,t[17]=f,t[18]=a,t[19]=h,t[20]=m,t[21]=l,t[22]=N):N=t[22],Tt(_,N);let S;return t[23]!==p||t[24]!==u||t[25]!==f||t[26]!==o||t[27]!==i||t[28]!==m?(S=p.current===null||m===null||f===null?null:Oe(Et,{anchorElementRef:p,close:u,editor:f,groups:o,menuRenderFn:i,resolution:m,shouldSplitNodeWithQuery:!0}),t[23]=p,t[24]=u,t[25]=f,t[26]=o,t[27]=i,t[28]=m,t[29]=S):S=t[29],S}var Ct=class r{_bottom;_left;_right;_top;constructor(t,e,n,o){let[i,c]=e<=o?[e,o]:[o,e],[s,a]=t<=n?[t,n]:[n,t];this._top=i,this._right=a,this._left=s,this._bottom=c}static fromDOM(t){let{height:e,left:n,top:o,width:i}=t.getBoundingClientRect();return r.fromLWTH(n,i,o,e)}static fromDOMRect(t){let{height:e,left:n,top:o,width:i}=t;return r.fromLWTH(n,i,o,e)}static fromLTRB(t,e,n,o){return new r(t,e,n,o)}static fromLWTH(t,e,n,o){return new r(t,n,t+e,n+o)}static fromPoints(t,e){let{x:n,y:o}=t,{x:i,y:c}=e;return r.fromLTRB(n,o,i,c)}contains(t){if(ft(t)){let{x:c,y:s}=t,a=s<this._top,l=s>this._bottom,f=c<this._left,m=c>this._right;return{reason:{isOnBottomSide:l,isOnLeftSide:f,isOnRightSide:m,isOnTopSide:a},result:!a&&!l&&!f&&!m}}let{bottom:e,left:n,right:o,top:i}=t;return i>=this._top&&i<=this._bottom&&e>=this._top&&e<=this._bottom&&n>=this._left&&n<=this._right&&o>=this._left&&o<=this._right}distanceFromPoint(t){let e=this.contains(t);if(e.result)return{distance:0,isOnBottomSide:e.reason.isOnBottomSide,isOnLeftSide:e.reason.isOnLeftSide,isOnRightSide:e.reason.isOnRightSide,isOnTopSide:e.reason.isOnTopSide};let n=0,o=0;return t.x<this._left?n=this._left-t.x:t.x>this._right&&(n=t.x-this._right),t.y<this._top?o=this._top-t.y:t.y>this._bottom&&(o=t.y-this._bottom),{distance:Math.sqrt(n*n+o*o),isOnBottomSide:t.y>this._bottom,isOnLeftSide:t.x<this._left,isOnRightSide:t.x>this._right,isOnTopSide:t.y<this._top}}equals({bottom:t,left:e,right:n,top:o}){return o===this._top&&t===this._bottom&&e===this._left&&n===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:n=this.right,top:o=this.top}){return new r(e,o,n,t)}intersectsWith(t){let{height:e,left:n,top:o,width:i}=t,{height:c,left:s,top:a,width:l}=this,f=n+i>=s+l?n+i:s+l,m=o+e>=a+c?o+e:a+c,g=n<=s?n:s,p=o<=a?o:a;return f-g<=i+l&&m-p<=e+c}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 mo({editorConfig:r}){return He({nodes:r.features.nodes})}function He({nodes:r}){return r.map(t=>"node"in t?t.node:t)}var Ke=R&&"documentMode"in document?document.documentMode:null,ho=R&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),xo=R&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Eo=R&&"InputEvent"in window&&!Ke?"getTargetRanges"in new window.InputEvent("input"):!1,tt=R&&/Version\/[\d.].*Safari/.test(navigator.userAgent),et=R&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,_o=R&&/Android/.test(navigator.userAgent),To=R&&/Win/.test(navigator.platform),Ue=R&&/^(?=.*Chrome).*/i.test(navigator.userAgent),nt=R&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Ue;import{$getRoot as Ve,$isDecoratorNode as Ot,$isElementNode as G,$isLineBreakNode as Ze,$isTextNode as W}from"lexical";import{$isListItemNode as Ge,$isListNode as It}from"@lexical/list";import{$isHeadingNode as We,$isQuoteNode as Xe}from"@lexical/rich-text";import{$isParagraphNode as ze,$isTextNode as Ye}from"lexical";var C={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},I={...C,requiresParagraphStart:!0},Io={...I,export:$(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},Fo={...I,export:$(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},No={...I,export:$(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Ao={...I,export:$(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},Oo={...I,export:$(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},yo={...I,export:$(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},Mo={...I,export:je,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},bo={...I,export:ot,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},ko={...I,export:ot,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},Lo={...I,export:ot,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},$o={...I,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},Do={...I,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},Bo={...C,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},Po={...C,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},vo={...C,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},Ho={...C,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},Ko={...C,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Uo={...C,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Go={...C,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},Wo={...C,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},Xo={...C,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},zo={...C,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Yo={...C,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},Qo={...C,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function $(r){return(t,e)=>We(t)&&t.getTag()==="h"+r?"#".repeat(r)+" "+e(t):null}function ot(r,t){return It(r)?Ft(r,t,0):null}var Qe=4;function Ft(r,t,e){let n=[],o=r.getChildren(),i=0;for(let c of o)if(Ge(c)){if(c.getChildrenSize()===1){let l=c.getFirstChild();if(It(l)){n.push(Ft(l,t,e+1));continue}}let s=" ".repeat(e*Qe),a=r.getListType()==="bullet"?"- ":`${r.getStart()+i}. `;n.push(s+a+t(c)),i++}return n.join(`
|
|
2
|
+
`)}function je(r,t){return Xe(r)?"> "+t(r):null}function K(r,t){let e={};for(let n of r){let o=t(n);o&&(e[o]?e[o].push(n):e[o]=[n])}return e}function D(r){let t=K(r,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var B=/[!-/:-@[-`{-~\s]/,qe=/^\s{0,3}$/;function H(r){if(!ze(r))return!1;let t=r.getFirstChild();return t==null||r.getChildrenSize()===1&&Ye(t)&&qe.test(t.getTextContent())}function yt(r,t=!1){let e=D(r),n=[...e.multilineElement,...e.element],o=!t,i=e.textFormat.filter(c=>c.format.length===1).sort((c,s)=>c.format.includes("code")&&!s.format.includes("code")?1:!c.format.includes("code")&&s.format.includes("code")?-1:0);return c=>{let s=[],a=(c||Ve()).getChildren();for(let l=0;l<a.length;l++){let f=a[l],m=Je(f,n,i,e.textMatch);m!=null&&s.push(o&&l>0&&!H(f)&&!H(a[l-1])?`
|
|
3
|
+
`.concat(m):m)}return s.join(`
|
|
4
|
+
`)}}function Je(r,t,e,n){for(let o of t){if(!o.export)continue;let i=o.export(r,c=>X(c,e,n));if(i!=null)return i}return G(r)?X(r,e,n):Ot(r)?r.getTextContent():null}function X(r,t,e,n,o){let i=[],c=r.getChildren();n||(n=[]),o||(o=[]);t:for(let s of c){for(let a of e){if(!a.export)continue;let l=a.export(s,f=>X(f,t,e,n,[...o,...n]),(f,m)=>Nt(f,m,t,n,o));if(l!=null){i.push(l);continue t}}Ze(s)?i.push(`
|
|
5
|
+
`):W(s)?i.push(Nt(s,s.getTextContent(),t,n,o)):G(s)?i.push(X(s,t,e,n,o)):Ot(s)&&i.push(s.getTextContent())}return i.join("")}function Nt(r,t,e,n,o){let i=t.trim(),c=i,s="",a="",l="",f=At(r,!0),m=At(r,!1),g=new Set;for(let p of e){let d=p.format[0],u=p.tag;U(r,d)&&!g.has(d)&&(g.add(d),(!U(f,d)||!n.find(x=>x.tag===u))&&(n.push({format:d,tag:u}),s+=u))}for(let p=0;p<n.length;p++){let d=U(r,n[p].format),u=U(m,n[p].format);if(d&&u)continue;let x=[...n];for(;x.length>p;){let h=x.pop();o&&h&&o.find(T=>T.tag===h.tag)||(h&&typeof h.tag=="string"&&(d?u||(l+=h.tag):a+=h.tag),n.pop())}break}return c=s+c+l,a+t.replace(i,()=>c)}function At(r,t){let e=t?r.getPreviousSibling():r.getNextSibling();if(!e){let n=r.getParentOrThrow();n.isInline()&&(e=t?n.getPreviousSibling():n.getNextSibling())}for(;e;){if(G(e)){if(!e.isInline())break;let n=t?e.getLastDescendant():e.getFirstDescendant();if(W(n))return n;e=t?e.getPreviousSibling():e.getNextSibling()}if(W(e))return e;if(!G(e))return null}return null}function U(r,t){return W(r)&&r.hasFormat(t)}import{$isListItemNode as en,$isListNode as $t}from"@lexical/list";import{$isQuoteNode as nn}from"@lexical/rich-text";import{$findMatchingParent as on}from"@lexical/utils";import{$createLineBreakNode as rn,$createParagraphNode as sn,$createTextNode as cn,$getRoot as an,$getSelection as ln,$isParagraphNode as fn}from"lexical";import{$isTextNode as P}from"lexical";function Mt(r,t){let e=r.getTextContent(),n=tn(e,t);if(!n)return null;let o=n.index||0,i=o+n[0].length,c=t.transformersByTag[n[1]];return{endIndex:i,match:n,startIndex:o,transformer:c}}function tn(r,t){let e=r.match(t.openTagsRegExp);if(e==null)return null;for(let n of e){let o=n.replace(/^\s/,""),i=t.fullMatchRegExpByTag[o];if(i==null)continue;let c=r.match(i),s=t.transformersByTag[o];if(c!=null&&s!=null){if(s.intraword!==!1)return c;let{index:a=0}=c,l=r[a-1],f=r[a+c[0].length];if((!l||B.test(l))&&(!f||B.test(f)))return c}}return null}function bt(r,t,e,n,o){let i=r.getTextContent(),c,s,a;if(o[0]===i?a=r:t===0?[a,c]=r.splitText(e):[s,a,c]=r.splitText(t,e),a.setTextContent(o[2]),n)for(let l of n.format)a.hasFormat(l)||a.toggleFormat(l);return{nodeAfter:c,nodeBefore:s,transformedNode:a}}function kt(r,t){let e=r,n,o,i,c;for(let s of t){if(!s.replace||!s.importRegExp)continue;let a=e.getTextContent().match(s.importRegExp);if(!a)continue;let l=a.index||0,f=s.getEndIndex?s.getEndIndex(e,a):l+a[0].length;f!==!1&&(n===void 0||o===void 0||l<n&&f>o)&&(n=l,o=f,i=s,c=a)}return n===void 0||o===void 0||i===void 0||c===void 0?null:{endIndex:o,match:c,startIndex:n,transformer:i}}function Lt(r,t,e,n,o){let i,c,s;if(t===0?[s,i]=r.splitText(e):[c,s,i]=r.splitText(t,e),!n.replace)return null;let a=n.replace(s,o);return{nodeAfter:i,nodeBefore:c,transformedNode:a||void 0}}function y(r,t,e){let n=Mt(r,t),o=kt(r,e);if(n&&o&&(n.startIndex<=o.startIndex&&n.endIndex>=o.endIndex?o=null:n=null),n){let i=bt(r,n.startIndex,n.endIndex,n.transformer,n.match);i.nodeAfter&&P(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&y(i.nodeAfter,t,e),i.nodeBefore&&P(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&y(i.nodeBefore,t,e),i.transformedNode&&P(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&y(i.transformedNode,t,e);return}else if(o){let i=Lt(r,o.startIndex,o.endIndex,o.transformer,o.match);if(!i)return;i.nodeAfter&&P(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&y(i.nodeAfter,t,e),i.nodeBefore&&P(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&y(i.nodeBefore,t,e),i.transformedNode&&P(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&y(i.transformedNode,t,e);return}else return}function Dt(r,t=!1){let e=D(r),n=mn(e.textFormat);return(o,i)=>{let c=o.split(`
|
|
6
|
+
`),s=c.length,a=i||an();a.clear();for(let f=0;f<s;f++){let m=c[f],[g,p]=un(c,f,e.multilineElement,a);if(g){f=p;continue}dn(m,a,e.element,n,e.textMatch)}let l=a.getChildren();for(let f of l)!t&&H(f)&&a.getChildrenSize()>1&&f.remove();ln()!==null&&a.selectStart()}}function un(r,t,e,n){for(let o of e){let{handleImportAfterStartMatch:i,regExpEnd:c,regExpStart:s,replace:a}=o,l=r[t].match(s);if(!l)continue;if(i){let d=i({lines:r,rootNode:n,startLineIndex:t,startMatch:l,transformer:o});if(d===null)continue;if(d)return d}let f=typeof c=="object"&&"regExp"in c?c.regExp:c,m=c&&typeof c=="object"&&"optional"in c?c.optional:!c,g=t,p=r.length;for(;g<p;){let d=f?r[g].match(f):null;if(!d&&(!m||m&&g<p-1)){g++;continue}if(d&&t===g&&d.index===l.index){g++;continue}let u=[];if(d&&t===g)u.push(r[t].slice(l[0].length,-d[0].length));else for(let x=t;x<=g;x++)if(x===t){let h=r[x].slice(l[0].length);u.push(h)}else if(x===g&&d){let h=r[x].slice(0,-d[0].length);u.push(h)}else u.push(r[x]);if(a(n,null,l,d,u,!0)!==!1)return[!0,g];break}}return[!1,t]}function dn(r,t,e,n,o){let i=cn(r),c=sn();c.append(i),t.append(c);for(let{regExp:s,replace:a}of e){let l=r.match(s);if(l&&(i.setTextContent(r.slice(l[0].length)),a(c,[i],l,!0)!==!1))break}if(y(i,n,o),c.isAttached()&&r.length>0){let s=c.getPreviousSibling();if(fn(s)||nn(s)||$t(s)){let a=s;if($t(s)){let l=s.getLastDescendant();l==null?a=null:a=on(l,en)}a!=null&&a.getTextContentSize()>0&&(a.splice(a.getChildrenSize(),0,[rn(),...c.getChildren()]),c.remove())}}}function mn(r){let t={},e={},n=[],o="(?<![\\\\])";for(let i of r){let{tag:c}=i;t[c]=i;let s=c.replace(/([*^+])/g,"\\$1");n.push(s),tt||et||nt?e[c]=new RegExp(`(${s})(?![${s}\\s])(.*?[^${s}\\s])${s}(?!${s})`):e[c]=new RegExp(`(?<![\\\\${s}])(${s})((\\\\${s})?.*?[^${s}\\s](\\\\${s})?)((?<!\\\\)|(?<=\\\\\\\\))(${s})(?![\\\\${s}])`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp((tt||et||nt?"":`${o}`)+"("+n.join("|")+")","g"),transformersByTag:t}}import{$createRangeSelection as gn,$getSelection as rt,$isLineBreakNode as pn,$isRangeSelection as it,$isRootOrShadowRoot as Pt,$isTextNode as vt,$setSelection as hn}from"lexical";function xn(r,t,e,n){let o=r.getParent();if(!Pt(o)||r.getFirstChild()!==t)return!1;let i=t.getTextContent();if(i[e-1]!==" ")return!1;for(let{regExp:c,replace:s}of n){let a=i.match(c);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let l=t.getNextSiblings(),[f,m]=t.splitText(e);f.remove();let g=m?[m,...l]:l;if(s(r,g,a,!1)!==!1)return!0}}return!1}function En(r,t,e,n){let o=r.getParent();if(!Pt(o)||r.getFirstChild()!==t)return!1;let i=t.getTextContent();if(i[e-1]!==" ")return!1;for(let{regExpEnd:c,regExpStart:s,replace:a}of n){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;let l=i.match(s);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let f=t.getNextSiblings(),[m,g]=t.splitText(e);m.remove();let p=g?[g,...f]:f;if(a(r,p,l,null,null,!1)!==!1)return!0}}return!1}function _n(r,t,e){let n=r.getTextContent(),o=n[t-1],i=e[o];if(i==null)return!1;t<n.length&&(n=n.slice(0,t));for(let c of i){if(!c.replace||!c.regExp)continue;let s=n.match(c.regExp);if(s===null)continue;let a=s.index||0,l=a+s[0].length,f;return a===0?[f]=r.splitText(l):[,f]=r.splitText(a,l),f.selectNext(0,0),c.replace(f,s),!0}return!1}function Tn(r,t,e){let n=r.getTextContent(),o=t-1,i=n[o],c=e[i];if(!c)return!1;for(let s of c){let{tag:a}=s,l=a.length,f=o-l+1;if(l>1&&!Ht(n,f,a,0,l)||n[f-1]===" ")continue;let m=n[o+1];if(s.intraword===!1&&m&&!B.test(m))continue;let g=r,p=g,d=Bt(n,f,a),u=p;for(;d<0&&(u=u.getPreviousSibling())&&!pn(u);)if(vt(u)){let w=u.getTextContent();p=u,d=Bt(w,w.length,a)}if(d<0||p===g&&d+l===f)continue;let x=p.getTextContent();if(d>0&&x[d-1]===i)continue;let h=x[d-1];if(s.intraword===!1&&h&&!B.test(h))continue;let T=g.getTextContent(),E=T.slice(0,f)+T.slice(o+1);g.setTextContent(E);let _=p===g?E:x;p.setTextContent(_.slice(0,d)+_.slice(d+l));let N=rt(),S=gn();hn(S);let F=o-l*(p===g?2:1)+1;S.anchor.set(p.__key,d,"text"),S.focus.set(g.__key,F,"text");for(let w of s.format)S.hasFormat(w)||S.formatText(w);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(let w of s.format)S.hasFormat(w)&&S.toggleFormat(w);return it(N)&&(S.format=N.format),!0}return!1}function Bt(r,t,e){let n=e.length;for(let o=t;o>=n;o--){let i=o-n;if(Ht(r,i,e,0,n)&&r[i+n]!==" ")return i}return-1}function Ht(r,t,e,n,o){for(let i=0;i<o;i++)if(r[t+i]!==e[n+i])return!1;return!0}function xr(r,t=z){let e=D(t),n=K(e.textFormat,({tag:c})=>c[c.length-1]),o=K(e.textMatch,({trigger:c})=>c);for(let c of t){let s=c.type;if(s==="element"||s==="text-match"||s==="multiline-element"){let a=c.dependencies;for(let l of a)if(!r.hasNode(l))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+l.getType())}}let i=(c,s,a)=>{xn(c,s,a,e.element)||En(c,s,a,e.multilineElement)||_n(s,a,o)||Tn(s,a,n)};return r.registerUpdateListener(({dirtyLeaves:c,editorState:s,prevEditorState:a,tags:l})=>{if(l.has("collaboration")||l.has("historic")||r.isComposing())return;let f=s.read(rt),m=a.read(rt);if(!it(m)||!it(f)||!f.isCollapsed()||f.is(m))return;let g=f.anchor.key,p=f.anchor.offset,d=s._nodeMap.get(g);!vt(d)||!c.has(g)||p!==1&&p>m.anchor.offset+1||r.update(()=>{if(d.hasFormat("code"))return;let u=d.getParent();u!==null&&i(u,d,f.anchor.offset)})})}import{$createListItemNode as Sn,$createListNode as wn,$isListItemNode as Rn,$isListNode as v,ListItemNode as ct,ListNode as at}from"@lexical/list";import{$createHeadingNode as Cn,$createQuoteNode as In,$isHeadingNode as Fn,$isQuoteNode as Kt,HeadingNode as Nn,QuoteNode as An}from"@lexical/rich-text";import{$createLineBreakNode as On}from"lexical";var Ut=/^[\t ]*$/,zt=/^(\s*)(\d+)\.\s/,Yt=/^(\s*)[-*+]\s/,Qt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,st=/^(#{1,6})\s/,jt=/^>\s/,yn=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,Gt=/[ \t]*(\\`\\`\\`|```)$/,Mn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,bn=/^\|(.+)\|\s?$/,kn=/^(\| ?:?-*:? ?)+\|\s?$/,Wt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,Xt=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,Ln=r=>(t,e,n)=>{let o=r(n);o.append(...e),t.replace(o),o.select(0,0)},qt=4;function $n(r){let t=r.match(/\t/g),e=r.match(/ /g),n=0;return t&&(n+=t.length),e&&(n+=Math.floor(e.length/qt)),n}var lt=r=>(t,e,n)=>{let o=t.getPreviousSibling(),i=t.getNextSibling(),c=Sn(r==="check"?n[3]==="x":void 0);if(v(i)&&i.getListType()===r){let a=i.getFirstChild();a!==null?a.insertBefore(c):i.append(c),t.remove()}else if(v(o)&&o.getListType()===r)o.append(c),t.remove();else{let a=wn(r,r==="number"?Number(n[2]):void 0);a.append(c),t.replace(a)}c.append(...e),c.select(0,0);let s=$n(n[1]);s&&c.setIndent(s)},Y=(r,t,e)=>{let n=[],o=r.getChildren(),i=0;for(let c of o)if(Rn(c)){if(c.getChildrenSize()===1){let f=c.getFirstChild();if(v(f)){n.push(Y(f,t,e+1));continue}}let s=" ".repeat(e*qt),a=r.getListType(),l=a==="number"?`${r.getStart()+i}. `:a==="check"?`- [${c.getChecked()?"x":" "}] `:"- ";n.push(s+l+t(c)),i++}return n.join(`
|
|
7
|
+
`)},Vt={type:"element",dependencies:[Nn],export:(r,t)=>{if(!Fn(r))return null;let e=Number(r.getTag().slice(1));return"#".repeat(e)+" "+t(r)},regExp:st,replace:Ln(r=>{let t="h"+r[1].length;return Cn(t)})},Zt={type:"element",dependencies:[An],export:(r,t)=>{if(!Kt(r))return null;let e=t(r).split(`
|
|
8
|
+
`),n=[];for(let o of e)n.push("> "+o);return n.join(`
|
|
9
|
+
`)},regExp:jt,replace:(r,t,e,n)=>{if(n){let i=r.getPreviousSibling();if(Kt(i)){i.splice(i.getChildrenSize(),0,[On(),...t]),i.select(0,0),r.remove();return}}let o=In();o.append(...t),r.replace(o),o.select(0,0)}},Jt={type:"element",dependencies:[at,ct],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:Yt,replace:lt("bullet")},Dn={type:"element",dependencies:[at,ct],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:Qt,replace:lt("check")},te={type:"element",dependencies:[at,ct],export:(r,t)=>v(r)?Y(r,t,0):null,regExp:zt,replace:lt("number")},ee={type:"text-format",format:["code"],tag:"`"},ne={type:"text-format",format:["highlight"],tag:"=="},oe={type:"text-format",format:["bold","italic"],tag:"***"},re={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},ie={type:"text-format",format:["bold"],tag:"**"},se={type:"text-format",format:["bold"],intraword:!1,tag:"__"},ce={type:"text-format",format:["strikethrough"],tag:"~~"},ae={type:"text-format",format:["italic"],tag:"*"},le={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function fe(r,t){let e=r.split(`
|
|
10
|
+
`),n=!1,o=[],i=0;for(let c=0;c<e.length;c++){let s=e[c],a=o[o.length-1];if(Mn.test(s)){o.push(s);continue}if(Gt.test(s)){i===0&&(n=!0),i===1&&(n=!1),i>0&&i--,o.push(s);continue}if(yn.test(s)){n=!0,i++,o.push(s);continue}if(n){o.push(s);continue}Ut.test(s)||Ut.test(a)||!a||st.test(a)||st.test(s)||jt.test(s)||zt.test(s)||Yt.test(s)||Qt.test(s)||bn.test(s)||kn.test(s)||!t||Wt.test(s)||Xt.test(s)||Wt.test(a)||Xt.test(a)||Gt.test(a)?o.push(s):o[o.length-1]=a+" "+s.trim()}return o.join(`
|
|
11
|
+
`)}var Bn=[Vt,Zt,Jt,te],Pn=[],vn=[ee,oe,re,ie,se,ne,ae,le,ce],Hn=[],z=[...Bn,...Pn,...vn,...Hn];function Fr(r,t=z,e,n=!1,o=!0){let i=n?r:fe(r,o);return Dt(t,n)(i,e)}function Nr(r=z,t,e=!1){return yt(r,e)(t)}export{R as a,ho as b,xr as c,Fr as d,Nr as e,Gn as f,j as g,ft as h,co as i,ve as j,ao as k,Ct as l,mo as m};
|
|
12
|
+
//# sourceMappingURL=chunk-CIY6PKN6.js.map
|