@payloadcms/richtext-lexical 3.55.0-internal.f8c92b5 → 3.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/exports/client/Field-SOED2PIU.js +2 -0
  2. package/dist/exports/client/{Field-Q3PTZQ75.js.map → Field-SOED2PIU.js.map} +3 -3
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-FSKAVN4P.js +2 -0
  5. package/dist/exports/client/{chunk-CYLMY5ZJ.js.map → chunk-FSKAVN4P.js.map} +2 -2
  6. package/dist/exports/client/chunk-KZKGNMS3.js +12 -0
  7. package/dist/exports/client/{chunk-YCH4JNUH.js.map → chunk-KZKGNMS3.js.map} +2 -2
  8. package/dist/exports/client/{component-3PENNOM3.js → component-M3U253XK.js} +2 -2
  9. package/dist/exports/client/index.d.ts +0 -2
  10. package/dist/exports/client/index.d.ts.map +1 -1
  11. package/dist/exports/client/index.js +10 -10
  12. package/dist/exports/client/index.js.map +4 -4
  13. package/dist/exports/server/rsc.d.ts +0 -1
  14. package/dist/exports/server/rsc.d.ts.map +1 -1
  15. package/dist/exports/server/rsc.js +0 -1
  16. package/dist/exports/server/rsc.js.map +1 -1
  17. package/dist/features/blocks/client/component/BlockContent.js +10 -8
  18. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  19. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +1 -1
  20. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  21. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +1 -1
  22. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  23. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
  24. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +39 -124
  25. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  26. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +8 -6
  27. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  28. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +3 -3
  29. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  30. package/dist/features/relationship/client/plugins/index.js +37 -20
  31. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  32. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +53 -28
  33. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
  34. package/dist/features/textState/feature.client.js +3 -1
  35. package/dist/features/textState/feature.client.js.map +1 -1
  36. package/dist/features/textState/feature.server.d.ts.map +1 -1
  37. package/dist/features/textState/feature.server.js +3 -1
  38. package/dist/features/textState/feature.server.js.map +1 -1
  39. package/dist/features/textState/i18n.d.ts +3 -0
  40. package/dist/features/textState/i18n.d.ts.map +1 -0
  41. package/dist/features/textState/i18n.js +108 -0
  42. package/dist/features/textState/i18n.js.map +1 -0
  43. package/dist/features/toolbars/shared/ToolbarButton/index.js +37 -35
  44. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  45. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +30 -20
  46. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  47. package/dist/field/bundled.css +1 -1
  48. package/dist/index.d.ts +1 -2
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1 -2
  51. package/dist/index.js.map +1 -1
  52. package/dist/lexical/LexicalEditor.js +35 -22
  53. package/dist/lexical/LexicalEditor.js.map +1 -1
  54. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +15 -7
  55. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  56. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +15 -7
  57. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  58. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +141 -75
  59. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  60. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  61. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +3 -1
  62. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  63. package/dist/lexical/ui/ContentEditable.js +11 -2
  64. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  65. package/dist/lexical-proxy/@lexical-react/LexicalNodeContextMenuPlugin.d.ts +2 -0
  66. package/dist/lexical-proxy/@lexical-react/LexicalNodeContextMenuPlugin.d.ts.map +1 -0
  67. package/dist/lexical-proxy/@lexical-react/LexicalNodeContextMenuPlugin.js +2 -0
  68. package/dist/lexical-proxy/@lexical-react/LexicalNodeContextMenuPlugin.js.map +1 -0
  69. package/dist/nodeTypes.d.ts +1 -13
  70. package/dist/nodeTypes.d.ts.map +1 -1
  71. package/dist/nodeTypes.js +1 -4
  72. package/dist/nodeTypes.js.map +1 -1
  73. package/package.json +26 -21
  74. package/dist/exports/client/Field-Q3PTZQ75.js +0 -2
  75. package/dist/exports/client/chunk-CYLMY5ZJ.js +0 -2
  76. package/dist/exports/client/chunk-YCH4JNUH.js +0 -12
  77. package/dist/field/RenderLexical/renderLexical.d.ts +0 -38
  78. package/dist/field/RenderLexical/renderLexical.d.ts.map +0 -1
  79. package/dist/field/RenderLexical/renderLexical.js +0 -96
  80. package/dist/field/RenderLexical/renderLexical.js.map +0 -1
  81. package/dist/field/RenderLexical/useRenderEditor.d.ts +0 -15
  82. package/dist/field/RenderLexical/useRenderEditor.d.ts.map +0 -1
  83. package/dist/field/RenderLexical/useRenderEditor.js +0 -159
  84. package/dist/field/RenderLexical/useRenderEditor.js.map +0 -1
  85. package/dist/utilities/buildEditorState.d.ts +0 -11
  86. package/dist/utilities/buildEditorState.d.ts.map +0 -1
  87. package/dist/utilities/buildEditorState.js +0 -76
  88. package/dist/utilities/buildEditorState.js.map +0 -1
  89. /package/dist/exports/client/{component-3PENNOM3.js.map → component-M3U253XK.js.map} +0 -0
@@ -0,0 +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 Be,l as Le}from"./chunk-KZKGNMS3.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 En,FieldError as xn,FieldLabel as bn,RenderCustomComponent as xt,useEditDepth as Cn,useEffectEvent as Nn,useField as Pn}from"@payloadcms/ui";import{mergeFieldStyles as Sn}from"@payloadcms/ui/shared";import bt,{useCallback as Ct,useEffect as Nt,useMemo as Rn,useState as Pt}from"react";import{ErrorBoundary as kn}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 b,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 Me}from"react/jsx-runtime";import"react";var $=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Me(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Me(o.Component,{clientProps:e});import{c as 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 Ee,$isLineBreakNode as Bt,$isNodeSelection as ie,$isRangeSelection as Ae,$isRootOrShadowRoot as Lt,$isTextNode as Mt,$setSelection as Ie,CLICK_COMMAND as At,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,r,n;return t[0]!==e?(r=()=>vt(e.registerCommand(At,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)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Kt(r,n),null}function Ht(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(K(i)){let y=X().getElementByKey(i.getKey());return y&&Z({element:y,node:i}),!0}if(!Ee(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,jt),c=n?.getNextSibling();if(!n||c!==Oe(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function jt(t){return Oe(t)!==null}function zt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(K(i)){let y=X().getElementByKey(i.getKey());return y?(Z({element:y,node:i}),t.preventDefault(),!0):!1}if(!Ee(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Wt),c=n?.getPreviousSibling();if(!n||c!==Fe(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function 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(!Ee(t)||Lt(t))return!1;let e=t.getFirstChild(),o=e===null||Bt(e)||Mt(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 xe}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,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:d,right:y,top:g}=t.getBoundingClientRect(),a=g+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||e<d-n||e>y+n)return-1;(e<d||e>y)&&(i=e<d?e-d:e-y)}return i};import{$getNodeByKey as ae}from"lexical";function V(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(d,y)=>d?parseFloat(window.getComputedStyle(d)[y]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Qt}from"lexical";function H(t){return t.getEditorState().read(()=>Qt().getChildrenKeys())}var Xt=1,Zt=-1,$e=0,M={props:null,result:null};function eo(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:s},startIndex:d=0,useEdgeAsDefault:y=!1}=t;if(o>0&&M.props&&M.result&&M.props.fuzzy===t.fuzzy&&M.props.horizontalOffset===t.horizontalOffset&&M.props.useEdgeAsDefault===t.useEdgeAsDefault&&eo(M.props.point,t.point,o))return M.result;let g=e.getBoundingClientRect(),a=H(r),l={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(y){let m=r.getElementByKey(a[0]),h=r.getElementByKey(a[a.length-1]);if(m&&h){let[u,f]=[V(m),V(h)];if(s<u.top?(l.blockElem=m,l.distance=u.top-s,l.blockNode=ae(a[0]),l.foundAtIndex=0):s>f.bottom&&(l.distance=s-f.bottom,l.blockNode=ae(a[a.length-1]),l.blockElem=h,l.foundAtIndex=a.length-1),l?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=d,E=$e;for(;p>=0&&p<a.length;){let m=a[p],h=r.getElementByKey(m);if(h===null)break;let u=new _(i+c,s),f=Be.fromDOMRect(V(h)),{marginBottom:x,marginTop:w}=le(h),S=f.generateNewRect({bottom:f.bottom+x,left:g.left,right:g.right,top:f.top-w}),{distance:C,isOnBottomSide:k,isOnTopSide:N}=S.distanceFromPoint(u);if(C===0){l.blockElem=h,l.blockNode=ae(m),l.foundAtIndex=p,l.distance=C,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else n&&C<l.distance&&(l.blockElem=h,l.blockNode=ae(m),l.distance=C,l.foundAtIndex=p);E===$e&&(N?E=Zt:k?E=Xt:E=1/0),p+=E}}),M.props=t,M.result={blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph},{blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var 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 de(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))d=n.top+8-s.top;else{let a=Ke(t)?parseInt(c.lineHeight,10):0;d=n.top+(a-i.height)/2-s.top}let g=r;e.style.opacity="1",e.style.transform=`translate(${g}px, ${d}px)`}var co="add-block-menu",ue=1/0;function uo(t){return t===0?1/0:ue>=0&&ue<t?ue:Math.floor(t/2)}function mo(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),c=n?.admin?.hideGutter?-24:12,i=so(null),[s,d]=lo(null);He(()=>{function g(a){let l=a.target;if(!ro(l))return;let p=Y(r,a.pageX,a.pageY,l);if(p===-1){d(null);return}if(ce(l,co))return;let E=H(t),{blockElem:m,blockNode:h,foundAtIndex:u}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:uo(E.length),useEdgeAsDefault:!1});ue=u,m&&h&&(s?.node!==h||s?.elem!==m)&&d({elem:m,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[r,e,t,s]),He(()=>{i.current&&s?.node&&de(s?.elem,i.current,e,c)},[e,s,c]);let y=io(g=>{let a=s;a?.node&&(t.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let p=no();a?.node.insertAfter(p),setTimeout(()=>{a={elem:t.getElementByKey(p.getKey()),node:p},d(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(Te,{node:a?.node})},2),g.stopPropagation(),g.preventDefault())},[t,s]);return ao(xe(je.Fragment,{children:xe("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:g=>{y(g)},ref:i,type:"button",children:xe("div",{className:o?"icon":""})})}),e)}function ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=oo();return mo(r,o,r._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 be}from"lexical";import*as Xe from"react";import{useEffect as Ce,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,r,n,c,i,s,d,y=!1){let{height:g,top:a}=r.getBoundingClientRect(),{top:l,width:p}=i.getBoundingClientRect(),{marginBottom:E,marginTop:m}=le(r),h=a,u=c>=a+g/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(u&&n?.elem&&n?.elem===r.nextElementSibling||!u&&n?.elem&&n?.elem===r.previousElementSibling)&&(j++,j<200&&(f=!0));else{j++;let C=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(u===n?.isBelow&&C===k||j<200)&&(f=!1)}if(f)return{isBelow:u,willStayInSamePosition:f};y?h+=g/2:u?h+=g+E/2:h-=m/2;let x=0;y||(u?x=-We:x=We);let w=h-l+x,S=fo-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${w}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?u?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),j=0,{isBelow:u,willStayInSamePosition:f}}var Eo="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 xo(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 bo(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),s=fe(!1),[d,y]=Ue(null),[g,a]=Ue(null),{editorConfig:l}=R(),p=l?.admin?.hideGutter?-44:-8;Ce(()=>{function h(u){let f=u.target;if(!be(f))return;let x=Y(r,u.pageX,u.pageY,f);if(x===-1){y(null);return}if(ce(f,Eo))return;let w=H(t),{blockElem:S,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-x,point:new _(u.x,u.y),startIndex:Je(w.length),useEdgeAsDefault:!1,verbose:!1});ee=C,!(!S&&!k)&&d!==S&&y(S)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,d]),Ce(()=>{n.current&&de(d,n.current,e,p)},[e,d,p]),Ce(()=>{function h(f){if(!s.current)return!1;let[x]=Ve(f);if(x)return!1;let{pageY:w,target:S}=f;if(!be(S))return!1;let C=Y(r,f.pageX,f.pageY,S,100,50),k=H(t),{blockElem:N,foundAtIndex:B,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new _(f.x,f.y),startIndex:Je(k.length),useEdgeAsDefault:!0,verbose:!0});ee=B;let v=c.current;if(N===null||v===null)return!1;if(d!==N){let{isBelow:T,willStayInSamePosition:J}=Ye(l?.admin?.hideGutter?"0px":"3rem",p+(l?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),v,N,g,w,e,f,i,I);f.preventDefault(),J||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:T})}else g?.elem&&(Qe(v,g.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function u(f){if(!s.current)return!1;let[x]=Ve(f);if(x)return!1;let{dataTransfer:w,pageY:S,target:C}=f,k=w?.getData(qe)||"";return t.update(()=>{let N=ho(k);if(!N||!be(C))return!1;let B=Y(r,f.pageX,f.pageY,C,100,50),{blockElem:I,isFoundNodeEmptyParagraph:v}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-B,point:new _(f.x,f.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),d!==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",h),document.addEventListener("drop",u),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",u)}},[r,p,e,t,g,d,l?.admin?.hideGutter]);function E(h){let u=h.dataTransfer;if(!u||!d)return;xo(u,d);let f="";t.update(()=>{let x=Ge(d);x&&(f=x.getKey())}),s.current=!0,u.setData(qe,f)}function m(){s.current=!1,g?.elem&&Qe(c.current,g?.elem)}return yo(po(Xe.Fragment,{children:[me("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:E,ref:n,type:"button",children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=go();return bo(r,o,r._editable)}import{c as Co}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=Co(4),[e]=No(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(Ro)},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:et,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${et}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};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(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>we(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]),ot.useEffect(r,n),null};import{useLexicalComposerContext as vo}from"@lexical/react/LexicalComposerContext";import{$getSelection as To,$isRangeSelection as Do,RootNode as Bo}from"lexical";import{useEffect as Lo}from"react";function rt(){let[t]=vo();return Lo(()=>t.registerNodeTransform(Bo,e=>{let o=To();if(Do(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(e.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[t]),null}import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Ao,COMMAND_PRIORITY_LOW as Io,SELECT_ALL_COMMAND as _o}from"lexical";import{useEffect as Oo}from"react";function it(){let[t]=Mo();return Oo(()=>t.registerCommand(_o,()=>{if(Ao())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:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==c||o[1]!==i||o[2]!==t?(s=d=>{let{query:y}=d,g="[^"+t+ve+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+c+"}))$").exec(y);if(l!==null){let p=l[1],E=l[3];if(E.length>=i)return{leadOffset:l.index+p.length,matchingString:E,replaceableString:l[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var A="slash-menu-popup";function zo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=R(),{i18n:s}=at(),d=`${A}__item ${A}__item-${e.key}`;t&&(d+=` ${A}__item--selected`);let y=e.key;return e.label&&(y=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:s,schemaPath:i}):e.label),y.length>25&&(y=y.substring(0,25)+"..."),lt("button",{"aria-selected":t,className:d,id:A+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${A}__item-text`,children:y})]},e.key)}function dt({anchorElem:t=document.body}){let[e]=$o(),[o,r]=jo(null),{editorConfig:n}=R(),{i18n:c}=at(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),d=st("/",{minLength:0}),y=Ko(()=>{let a=[];for(let l of n.features.slashMenu.dynamicGroups)if(o){let p=l({editor:e,queryString:o});a=a.concat(p)}return a},[e,o,n?.features]),g=Ho(()=>{let a=[];for(let l of n?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(p=>{let E=p.items.filter(m=>{let h=m.key;return m.label&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),new RegExp(o,"gi").exec(h)?!0:m.keywords!=null?m.keywords.some(u=>new RegExp(o,"gi").exec(u)):!1});return E.length?{...p,items:E}:null}),a=a.filter(p=>p!=null);let l=y();for(let p of l){let E=a.find(m=>m.key===p.key);E?a=a.filter(m=>m.key!==p.key):E={...p,items:[]},E?.items?.length&&(E.items=E.items.concat(E.items)),a.push(E)}}return a},[o,n?.features.slashMenu.groups,y,i,c,s]);return U(De,{anchorElem:t,groups:g,menuRenderFn:(a,{selectedItemKey:l,selectItemAndCleanUp:p,setSelectedItemKey:E})=>a.current&&g.length?ct.createPortal(U("div",{className:A,children:g.map(m=>{let h=m.key;return m.label&&i&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),lt("div",{className:`${A}__group ${A}__group-${m.key}`,children:[U("div",{className:`${A}__group-title`,children:h}),m.items.map((u,f)=>U(zo,{index:f,isSelected:l===u.key,item:u,onClick:()=>{E(u.key),p(u)},onMouseEnter:()=>{E(u.key)},ref:x=>{u.ref={current:x}}},u.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:d})}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 ut(t){let e=Wo(6),{features:o}=t,[r]=Yo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=qo(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Go,s=>{i.forEach(d=>{s.hasFormat(d)&&s.toggleFormat(d)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Uo(n,c),null}function qo(t){let e=Object.keys(Vo),o=new Set(t);return e.filter(r=>!o.has(r))}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(7),{className:o,editorConfig:r}=t,{t:n}=Xo(),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=mt(Qo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:mt("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 gt=t=>{let e=Zo(21),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=R(),[s]=en(),[d,y]=cn(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&y(m)},e[0]=g):g=e[0];let a=g,l,p;e[1]!==s||e[2]!==i?(l=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},h=()=>{i.blurEditor(i)},u=s.registerCommand(ln,()=>(m(),!0),pt),f=s.registerCommand(sn,()=>(h(),!0),pt);return()=>{u(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},p=[s,i],e[1]=s,e[2]=i,e[3]=l,e[4]=p):(l=e[3],p=e[4]),an(l,p);let E;if(e[5]!==s||e[6]!==o||e[7]!==r||e[8]!==d||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(u,f,x)=>{(!x.has("focus")||x.size>1)&&c?.(u,f,x)},e[12]=c,e[13]=m):m=e[13];let h;e[14]!==s||e[15]!==o.admin?.hideAddBlockButton||e[16]!==o.admin?.hideDraggableBlockElement||e[17]!==o.features.plugins||e[18]!==d||e[19]!==n?(h=d&&te(q.Fragment,{children:[!n&&s.isEditable()&&te(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:b(Ze,{anchorElem:d}),o.admin?.hideAddBlockButton?null:b(ze,{anchorElem:d})]}),o.features.plugins?.map(u=>{if(u.position==="floatingAnchorElem"&&!(u.desktopOnly===!0&&n))return b($,{anchorElem:d,clientProps:u.clientProps,plugin:u},u.key)}),s.isEditable()&&b(q.Fragment,{children:b(dt,{anchorElem:d})})]}),e[14]=s,e[15]=o.admin?.hideAddBlockButton,e[16]=o.admin?.hideDraggableBlockElement,e[17]=o.features.plugins,e[18]=d,e[19]=n,e[20]=h):h=e[20],E=te(q.Fragment,{children:[o.features.plugins?.map(dn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(un),b(rn,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ft,{editorConfig:o})})}),ErrorBoundary:tn}),b(rt,{}),b(tt,{}),b(_e,{}),b(ut,{features:o.features}),b(it,{}),b(nn,{ignoreSelectionChange:!0,onChange:m}),h,s.isEditable()&&te(q.Fragment,{children:[b(on,{}),o?.features?.markdownTransformers?.length>0&&b(nt,{})]}),o.features.plugins?.map(mn),o.features.plugins?.map(fn)]}),o.features.plugins?.map(pn)]}),e[5]=s,e[6]=o,e[7]=r,e[8]=d,e[9]=n,e[10]=c,e[11]=E}else E=e[11];return E};function dn(t){if(t.position==="aboveContainer")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function un(t){if(t.position==="top")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function mn(t){if(t.position==="normal")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function fn(t){if(t.position==="bottom")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function pn(t){if(t.position==="belowContainer")return b($,{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})},Et=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:s}=t,d=R(),y=hn(),g=ht.useRef(null),a=yn(()=>{if(s&&typeof s!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(s));if(s&&Array.isArray(s)&&!("root"in s))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(s&&"jsonContent"in s)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:i!==!0,editorState:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Le({editorConfig:o}),onError:l=>{throw l},theme:o.lexical.theme}},[o]);return a?O(gn,{initialConfig:a,children:O(Re,{editorConfig:o,editorContainerRef:g,fieldProps:r,parentContext:d?.editDepth===y?d:void 0,children:O(yt,{providers:o.features.providers,children:O(gt,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",wn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:s,required:d},path:y,readOnly:g,validate:a}=t,l=g||c,p=Cn(),E=Ct((L,Q)=>typeof a=="function"?a(L,{...Q,required:d}):!0,[a,d]),{customComponents:{AfterInput:m,BeforeInput:h,Description:u,Error:f,Label:x}={},disabled:w,initialValue:S,path:C,setValue:k,showError:N,value:B}=Pn({potentiallyStalePath:y,validate:E}),I=l||w,[v,T]=Pt(!1),[J,he]=Pt(),ye=bt.useRef(S),z=bt.useRef(B);Nt(()=>{let L=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==v&&T(Q)};return L(),window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L)}},[v]);let Pe=[pe,"field-type",r,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${C}.${p}`,D=ke(),P=Ct(L=>{D(()=>{let Se=L.toJSON();z.current=Se,k(Se)})},[k,D]),St=Rn(()=>Sn(o),[o]),Rt=Nn(L=>{z.current!==B&&JSON.stringify(z.current)!==JSON.stringify(B)&&(ye.current=L,z.current=B,he(new Date))});return Nt(()=>{Object.is(S,ye.current)||Rt(S)},[S]),ge("div",{className:Pe,style:St,children:[F(xt,{CustomComponent:f,Fallback:F(xn,{path:C,showError:N})}),x||F(bn,{label:i,localized:s,path:C,required:d}),ge("div",{className:`${pe}__wrap`,children:[ge(kn,{fallbackRender:vn,onReset:()=>{},children:[h,F(Et,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:I,value:B},JSON.stringify({path:C,rerenderProviderKey:J})),m]}),u,F(xt,{CustomComponent:u,Fallback:F(En,{description:n,path:C})})]})]},oe)};function vn({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 cs=wn;export{cs as RichText};
2
+ //# sourceMappingURL=Field-SOED2PIU.js.map