@payloadcms/richtext-lexical 4.0.0-internal.934870d → 4.0.0-internal.94ef095

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 (197) hide show
  1. package/dist/exports/client/Field-334JNLRF.js +2 -0
  2. package/dist/exports/client/Field-334JNLRF.js.map +7 -0
  3. package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js → RelationshipComponent-TVK6I4W4.js} +2 -2
  4. package/dist/exports/client/chunk-3V7KW5XF.js +2 -0
  5. package/dist/exports/client/chunk-3V7KW5XF.js.map +7 -0
  6. package/dist/exports/client/chunk-A7DZCL6D.js +2 -0
  7. package/dist/exports/client/chunk-A7DZCL6D.js.map +7 -0
  8. package/dist/exports/client/{chunk-WSAPGI3Z.js → chunk-EA5BHQ2T.js} +1 -1
  9. package/dist/exports/client/{chunk-WSAPGI3Z.js.map → chunk-EA5BHQ2T.js.map} +1 -1
  10. package/dist/exports/client/chunk-FAJJXXCW.js +2 -0
  11. package/dist/exports/client/{chunk-3LRZDIIG.js.map → chunk-FAJJXXCW.js.map} +2 -2
  12. package/dist/exports/client/{chunk-5VIL27GI.js → chunk-IYBYNEKX.js} +1 -1
  13. package/dist/exports/client/{chunk-5VIL27GI.js.map → chunk-IYBYNEKX.js.map} +1 -1
  14. package/dist/exports/client/{component-6DQLENIE.js → component-FCCSBBZG.js} +2 -2
  15. package/dist/exports/client/componentInline-7FQV2X7Z.js +2 -0
  16. package/dist/exports/client/index.js +27 -27
  17. package/dist/exports/client/index.js.map +3 -3
  18. package/dist/features/align/client/index.js.map +1 -1
  19. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  20. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  21. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
  22. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
  23. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  24. package/dist/features/blocks/client/component/index.js +62 -85
  25. package/dist/features/blocks/client/component/index.js.map +1 -1
  26. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
  27. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
  28. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
  29. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
  30. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  31. package/dist/features/blocks/client/componentInline/index.js +22 -69
  32. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  33. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts +0 -1
  34. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.d.ts.map +1 -1
  35. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js +7 -30
  36. package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -1
  37. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  38. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +121 -78
  39. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  40. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +142 -87
  41. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
  42. package/dist/features/converters/lexicalToHtml/async/converters/table.d.ts.map +1 -1
  43. package/dist/features/converters/lexicalToHtml/async/converters/table.js +6 -4
  44. package/dist/features/converters/lexicalToHtml/async/converters/table.js.map +1 -1
  45. package/dist/features/converters/lexicalToHtml/async/converters/upload.d.ts.map +1 -1
  46. package/dist/features/converters/lexicalToHtml/async/converters/upload.js +2 -1
  47. package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
  48. package/dist/features/converters/lexicalToHtml/sync/converters/table.d.ts.map +1 -1
  49. package/dist/features/converters/lexicalToHtml/sync/converters/table.js +6 -4
  50. package/dist/features/converters/lexicalToHtml/sync/converters/table.js.map +1 -1
  51. package/dist/features/converters/lexicalToHtml/sync/converters/upload.d.ts.map +1 -1
  52. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js +2 -1
  53. package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
  54. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  55. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  56. package/dist/features/converters/lexicalToJSX/converter/converters/table.d.ts.map +1 -1
  57. package/dist/features/converters/lexicalToJSX/converter/converters/table.js +3 -2
  58. package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
  59. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  60. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  61. package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
  62. package/dist/features/heading/client/index.js.map +1 -1
  63. package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
  64. package/dist/features/indent/client/index.d.ts.map +1 -1
  65. package/dist/features/indent/client/index.js +0 -2
  66. package/dist/features/indent/client/index.js.map +1 -1
  67. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  68. package/dist/features/indent/server/i18n.js.map +1 -1
  69. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  70. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  71. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +12 -4
  72. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  73. package/dist/features/link/client/plugins/link/index.js.map +1 -1
  74. package/dist/features/link/markdownTransformer.js +2 -2
  75. package/dist/features/link/markdownTransformer.js.map +1 -1
  76. package/dist/features/link/server/baseFields.js.map +1 -1
  77. package/dist/features/lists/shared/schema.d.ts.map +1 -1
  78. package/dist/features/lists/shared/schema.js.map +1 -1
  79. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  80. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  81. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  82. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.css +1 -1
  83. package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  84. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js +7 -7
  85. package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  86. package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  87. package/dist/features/table/client/plugins/TablePlugin/index.js +54 -18
  88. package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -1
  89. package/dist/features/table/client/utils/useDebounce.js.map +1 -1
  90. package/dist/features/table/server/index.d.ts.map +1 -1
  91. package/dist/features/table/server/index.js +3 -1
  92. package/dist/features/table/server/index.js.map +1 -1
  93. package/dist/features/table/server/validate.d.ts +4 -0
  94. package/dist/features/table/server/validate.d.ts.map +1 -0
  95. package/dist/features/table/server/validate.js +15 -0
  96. package/dist/features/table/server/validate.js.map +1 -0
  97. package/dist/features/textState/defaultColors.js +1 -1
  98. package/dist/features/textState/defaultColors.js.map +1 -1
  99. package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -1
  100. package/dist/features/toolbars/fixed/client/Toolbar/index.js +126 -70
  101. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  102. package/dist/features/toolbars/inline/client/Toolbar/index.js +67 -35
  103. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  104. package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  105. package/dist/features/toolbars/shared/ToolbarButton/index.js +26 -2
  106. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  107. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +137 -72
  108. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  109. package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
  110. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +22 -6
  111. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  112. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +100 -70
  113. package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -1
  114. package/dist/features/upload/client/drawer/index.js.map +1 -1
  115. package/dist/features/upload/client/plugin/index.js.map +1 -1
  116. package/dist/field/Diff/converters/upload/index.d.ts.map +1 -1
  117. package/dist/field/Diff/converters/upload/index.js +8 -7
  118. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  119. package/dist/field/Diff/index.d.ts.map +1 -1
  120. package/dist/field/Diff/index.js +1 -0
  121. package/dist/field/Diff/index.js.map +1 -1
  122. package/dist/field/RenderLexical/index.js.map +1 -1
  123. package/dist/field/ViewSelector.js +12 -4
  124. package/dist/field/ViewSelector.js.map +1 -1
  125. package/dist/field/bundled.css +1 -1
  126. package/dist/field/index.js.map +1 -1
  127. package/dist/i18n.d.ts.map +1 -1
  128. package/dist/i18n.js +44 -0
  129. package/dist/i18n.js.map +1 -1
  130. package/dist/index.d.ts +1 -1
  131. package/dist/index.js +1 -1
  132. package/dist/index.js.map +1 -1
  133. package/dist/lexical/LexicalEditor.js.map +1 -1
  134. package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -1
  135. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  136. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  137. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  138. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
  139. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +234 -87
  140. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  141. package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
  142. package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
  143. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  144. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +16 -0
  145. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  146. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +126 -38
  147. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  148. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts +7 -0
  149. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts.map +1 -0
  150. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js +15 -0
  151. package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js.map +1 -0
  152. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -1
  153. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +9 -12
  154. package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -1
  155. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  156. package/dist/lexical/ui/ContentEditable.js +16 -9
  157. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  158. package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
  159. package/dist/lexical/utils/nodeFormat.js +0 -2
  160. package/dist/lexical/utils/nodeFormat.js.map +1 -1
  161. package/dist/lexical/utils/url.d.ts.map +1 -1
  162. package/dist/lexical/utils/url.js +1 -1
  163. package/dist/lexical/utils/url.js.map +1 -1
  164. package/dist/populateGraphQL/populate.d.ts.map +1 -1
  165. package/dist/populateGraphQL/populate.js +4 -1
  166. package/dist/populateGraphQL/populate.js.map +1 -1
  167. package/dist/types/index.d.ts.map +1 -1
  168. package/dist/types/index.js.map +1 -1
  169. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  170. package/dist/utilities/buildEditorState.js.map +1 -1
  171. package/dist/utilities/fieldsDrawer/Drawer.js +36 -36
  172. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  173. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  174. package/dist/utilities/fieldsDrawer/DrawerContent.js +127 -107
  175. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  176. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -1
  177. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
  178. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
  179. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
  180. package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
  181. package/dist/utilities/initLexicalFeatures.js +38 -4
  182. package/dist/utilities/initLexicalFeatures.js.map +1 -1
  183. package/dist/utilities/useLexicalFeature.js +15 -6
  184. package/dist/utilities/useLexicalFeature.js.map +1 -1
  185. package/dist/utilities/useRunDeprioritized.js.map +1 -1
  186. package/package.json +47 -50
  187. package/dist/exports/client/Field-MT4FK3IP.js +0 -2
  188. package/dist/exports/client/Field-MT4FK3IP.js.map +0 -7
  189. package/dist/exports/client/chunk-3LRZDIIG.js +0 -2
  190. package/dist/exports/client/chunk-E6LSRRP2.js +0 -2
  191. package/dist/exports/client/chunk-E6LSRRP2.js.map +0 -7
  192. package/dist/exports/client/chunk-ZQX5HXUL.js +0 -2
  193. package/dist/exports/client/chunk-ZQX5HXUL.js.map +0 -7
  194. package/dist/exports/client/componentInline-HNE5G4TE.js +0 -2
  195. /package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js.map → RelationshipComponent-TVK6I4W4.js.map} +0 -0
  196. /package/dist/exports/client/{component-6DQLENIE.js.map → component-FCCSBBZG.js.map} +0 -0
  197. /package/dist/exports/client/{componentInline-HNE5G4TE.js.map → componentInline-7FQV2X7Z.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ import{a as ae,b as ue,c as me}from"./chunk-IYBYNEKX.js";import{b as ce}from"./chunk-RJ5MAOKZ.js";import{jsx as a,jsxs as _}from"react/jsx-runtime";import{useLexicalComposerContext as qe}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Ge}from"@lexical/react/useLexicalEditable";import{getTranslation as pe}from"@payloadcms/translations";import{Button as he,Drawer as Ue,EditDepthProvider as Qe,Form as Ye,formatDrawerSlug as Ze,RenderFields as et,ShimmerEffect as tt,useConfig as ot,useDocumentForm as nt,useDocumentInfo as rt,useEditDepth as st,useOperation as it,useServerFunctions as lt,useTranslation as ct}from"@payloadcms/ui";import{abortAndIgnore as at}from"@payloadcms/ui/shared";import{$getNodeByKey as j,SKIP_DOM_SELECTION_TAG as be}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as ut,getDataFromFormState as ke}from"payload/shared";import y,{createContext as mt,useCallback as R,useEffect as N,useMemo as k,useRef as I}from"react";import{v4 as dt}from"uuid";import{dequal as ve}from"dequal/lite";import{getDataFromFormState as Ee}from"payload/shared";var fe=({cachedFormState:o,cachedSchemaPath:t,currentSchemaPath:e,formData:n})=>{if(t!==e)return!1;let s=Pe(o),r=D({data:Ee(o,!0),rowFieldPaths:s}),l=D({data:n,rowFieldPaths:s});return ve(de(r),de(l))?o:!1},Pe=o=>new Set(Object.entries(o).filter(([,t])=>Array.isArray(t?.rows)&&t.value!==null&&t.value!==void 0).map(([t])=>t)),D=({data:o,parentPath:t="",rowFieldPaths:e})=>{let n={};for(let[s,r]of Object.entries(o)){let l=t?`${t}.${s}`:s,p=Le({parentPath:l,rowFieldPaths:e,value:r});p!==void 0&&(n[s]=p)}return n},Le=({parentPath:o,rowFieldPaths:t,value:e})=>{if(!(e===void 0||Array.isArray(e)&&e.length===0&&t.has(o)))return Array.isArray(e)?e.map((n,s)=>n&&typeof n=="object"&&!Array.isArray(n)?D({data:n,parentPath:`${o}.${s}`,rowFieldPaths:t}):n):e&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype?D({data:e,parentPath:o,rowFieldPaths:t}):e},de=({blockName:o,blockType:t,...e})=>e;import{jsx as Je}from"react/jsx-runtime";import ze from"bson-objectid";import{$applyNodeReplacement as Ve}from"lexical";import He from"react";import{addClassNamesToElement as je}from"@lexical/utils";import Re from"bson-objectid";import{$applyNodeReplacement as Ae,DecoratorNode as Me}from"lexical";var x=class extends Me{__cacheBuster;__fields;constructor({cacheBuster:t,fields:e,key:n}){super(n),this.__fields=e,this.__cacheBuster=t||0}static clone(t){return new this({cacheBuster:t.__cacheBuster,fields:t.__fields,key:t.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(t){return Ke(t.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(t){let e=document.createElement("span");return je(e,t?.theme?.inlineBlock),e}decorate(t,e){return null}exportDOM(){let t=document.createElement("span");t.classList.add("inline-block-container");let e=document.createTextNode(this.getTextContent());return t.append(e),{element:t}}exportJSON(){return{...super.exportJSON(),type:"inlineBlock",fields:this.getFields()}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(t,e){let n=this.getWritable();n.__fields=t,e||n.__cacheBuster++}updateDOM(){return!1}};function Ke(o){return Ae(new x({fields:{...o,id:o?.id||new Re.default().toHexString()}}))}var We=He.lazy(()=>import("./componentInline-7FQV2X7Z.js").then(o=>({default:o.InlineBlockComponent}))),F=class extends x{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importJSON(t){return Xe(t.fields)}decorate(...[t,e,n,s]){return Je(We,{cacheBuster:this.getCacheBuster(),className:e.theme.inlineBlock??"LexicalEditorTheme__inlineBlock",CustomBlock:n,CustomLabel:s,formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function Xe(o){return Ve(new F({fields:{...o,id:o?.id||new ze.default().toHexString()}}))}function L(o){return o instanceof F}var ge=mt({initialState:!1}),Be=()=>y.use(ge),zt=o=>{let{cacheBuster:t,className:e,CustomBlock:n,CustomLabel:s,formData:r,nodeKey:l}=o,[p]=qe(),u=Ge(),A=it(),{i18n:O,t:b}=ct(),{createdInlineBlock:M,fieldProps:{featureClientSchemaMap:Ce,initialLexicalFormState:xe,schemaPath:K},setCreatedInlineBlock:J,uuid:_e}=ce(),{fields:z}=nt(),{getFormState:V}=lt(),ye=st(),H=I(!1),S=r.blockType,B=`${K}.lexical_internal_feature.blocks.lexical_inline_blocks.${S}.fields`,[f,w]=y.useState(()=>{let i=xe?.[r.id],d=i?.formState;return d?fe({cachedFormState:d,cachedSchemaPath:i.schemaPath,currentSchemaPath:B,formData:r}):!1}),W=I(!1),X=I(t);N(()=>{W.current?(X.current!==t&&w(!1),X.current=t):W.current=!0},[t]);let[Se]=y.useState(()=>dt()),[q,G]=y.useState(()=>{if(!s)return f?._components?.customComponents?.BlockLabel??void 0}),[U,Q]=y.useState(()=>{if(!n)return f?._components?.customComponents?.Block??void 0}),Y=k(()=>n?a(n,{className:e,formData:r,isEditor:!0,isJSXConverter:!1,nodeKey:l,useInlineBlockComponentContext:Be}):U,[n,e,r,l,U]),$=k(()=>s?a(s,{className:e,formData:r,isEditor:!0,isJSXConverter:!1,nodeKey:l,useInlineBlockComponentContext:Be}):q,[s,e,r,l,q]),Z=Ze({slug:`lexical-inlineBlocks-create-${_e}-${r.id}`,depth:ye}),{toggleDrawer:h}=me(Z,!0),De=I(null),{id:ee,collectionSlug:te,getDocPreferences:oe,globalSlug:ne}=rt(),{config:Fe}=ot(),Ne=`${K}.lexical_internal_feature.blocks.lexical_inline_blocks.${S}`,T=Ce.blocks?.[Ne]?.[0]?.blocks?.[0],m=typeof T=="string"?Fe.blocksMap[T]:T,re=m?.fields??[];N(()=>{!H.current&&M?.getKey()===l&&(re.length>2&&h(),J?.(void 0),H.current=!0)},[re.length,M,l,J,h]);let se=R(()=>{p.update(()=>{j(l)?.remove()})},[p,l]),g=m?.labels?.singular?pe(m?.labels.singular,O):m?.slug;N(()=>{let i=new AbortController;return m&&r&&!f&&(async()=>{let{state:c}=await V({id:ee,collectionSlug:te,data:r,docPermissions:{fields:!0},docPreferences:await oe(),documentFormState:z,globalSlug:ne,initialBlockData:r,operation:A,readOnly:!u,renderAllFields:!0,schemaPath:B,signal:i.signal});if(c){let C=ke(ut(c,{excludeFiles:!0}),!0);p.update(()=>{let P=j(l);if(P&&L(P)){let le=C;le.blockType=r.blockType,P.setFields(le,!0)}},{tag:be}),w(c),s||G(c._components?.customComponents?.BlockLabel),n||Q(c._components?.customComponents?.Block)}})(),()=>{at(i)}},[V,p,l,u,s,n,B,ee,r,f,te,ne,oe,A,z,m]);let Ie=R(({formState:i,submitted:d})=>{d&&(s||G(i._components?.customComponents?.BlockLabel),n||Q(i._components?.customComponents?.Block))},[s,n]);N(()=>{let i=(d,c)=>Object.keys(c).some(C=>c[C]&&d[C]!==c[C].value);return()=>{f&&i(r,f)&&w(!1)}},[r,f]);let Oe=R(i=>{let d=ke(i,!0);d.blockType=S,p.update(()=>{let c=j(l);c&&L(c)&&c.setFields(d,!0)},{tag:be})},[S,p,l]),{headerActions:we,submitRef:$e}=ae(),v=k(()=>()=>a(he,{buttonStyle:"ghost",className:`${e}__removeButton`,disabled:!u,icon:"x",onClick:i=>{i.preventDefault(),i.stopPropagation(),se()},round:!0,size:"medium",tooltip:b("lexical:blocks:inlineBlocks:remove",{label:g})}),[e,g,u,se,b]),Te=k(()=>()=>a(he,{buttonStyle:"ghost",className:`${e}__editButton`,disabled:!u,el:"button",icon:"edit",onClick:()=>{h()},round:!0,size:"medium",tooltip:b("lexical:blocks:inlineBlocks:edit",{label:g})}),[e,g,u,b,h]),E=k(()=>({children:i,className:d})=>a("div",{className:[`${e}__container`,e+"-"+r.blockType,d].filter(Boolean).join(" "),...u?{onClick:()=>h(),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),h())},role:"button",tabIndex:0}:{},ref:De,children:i}),[e,r.blockType,u,h]),ie=k(()=>$?()=>$:()=>a("div",{children:m?.labels?pe(m?.labels.singular,O):""}),[$,m?.labels,O]);return m?_(Ye,{disableValidationOnSubmit:!0,el:"div",fields:m?.fields,initialState:f||{},onChange:[Ie],onSubmit:i=>{Oe(i),h()},readOnly:!u,schemaPath:B,uuid:Se,children:[a(Qe,{children:a(Ue,{className:"",headerActions:we,slug:Z,title:b(`lexical:blocks:inlineBlocks:${r?.id?"edit":"create"}`,{label:g??b("lexical:blocks:inlineBlocks:label")}),children:f?_("div",{className:"fields-drawer",children:[a(et,{fields:m?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:B,permissions:!0,readOnly:!u}),a(ue,{submitRef:$e})]}):null})}),Y?a(ge,{value:{EditButton:Te,initialState:f,InlineBlockContainer:E,Label:ie,nodeKey:l,RemoveButton:v},children:Y}):_(E,{children:[f?a(ie,{}):a(tt,{height:"15px",width:"40px"}),u?a("div",{className:`${e}__actions`,children:a(v,{})}):null]})]}):_(E,{className:`${e}-not-found`,children:[_("span",{children:["Error: Block '",r.blockType,"' not found"]}),u?a("div",{className:`${e}__actions`,children:a(v,{})}):null]})};export{fe as a,Be as b,zt as c,F as d,Xe as e,L as f};
2
+ //# sourceMappingURL=chunk-3V7KW5XF.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/getCachedFormStateIfDataMatches.ts", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
4
+ "sourcesContent": ["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\nimport type { BlocksFieldClient, ClientBlock, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useOperation,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey, SKIP_DOM_SELECTION_TAG } from 'lexical'\n\nimport './index.css'\nimport '../../../../utilities/fieldsDrawer/index.css'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, getDataFromFormState } from 'payload/shared'\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'\nimport type { InlineBlockFields } from '../../server/schema.js'\nimport type { BlockComponentProps } from '../component/index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport {\n RegisterFormSubmit,\n useDrawerSubmit,\n} from '../../../../utilities/fieldsDrawer/useDrawerSubmit.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { getCachedFormStateIfDataMatches } from '../getCachedFormStateIfDataMatches.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\nexport type InlineBlockComponentProps<\n TFormData extends Record<string, unknown> = InlineBlockFields,\n> = {\n readonly CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>\n readonly CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>\n} & Pick<BlockComponentProps<TFormData>, 'cacheBuster' | 'className' | 'formData' | 'nodeKey'>\n\nexport type InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<InlineBlockComponentProps<InlineBlockFields>> = (\n props,\n) => {\n const {\n cacheBuster,\n className: baseClass,\n CustomBlock: CustomBlockFromProps,\n CustomLabel: CustomLabelFromProps,\n formData,\n nodeKey,\n } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const operation = useOperation()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n const blockType = formData.blockType\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedState = initialLexicalFormState?.[formData.id]\n const cachedFormState = cachedState?.formState\n if (!cachedFormState) {\n return false\n }\n\n return getCachedFormStateIfDataMatches({\n cachedFormState,\n cachedSchemaPath: cachedState.schemaPath,\n currentSchemaPath: schemaFieldsPath,\n formData,\n })\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [formUuid] = React.useState(() => uuid())\n\n // Server-rendered custom components (from admin.components, NOT viewMap).\n // When viewMap components exist, we render them directly with formData instead.\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomLabelFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.BlockLabel ?? undefined\n })\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(() => {\n if (CustomBlockFromProps) {\n return undefined\n }\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return initialState?.['_components']?.customComponents?.Block ?? undefined\n })\n\n const resolvedCustomBlock = useMemo(() => {\n if (CustomBlockFromProps) {\n return (\n <CustomBlockFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-hooks/hooks -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomBlock\n }, [CustomBlockFromProps, baseClass, formData, nodeKey, CustomBlock])\n\n const resolvedCustomLabel = useMemo(() => {\n if (CustomLabelFromProps) {\n return (\n <CustomLabelFromProps\n className={baseClass}\n formData={formData}\n isEditor={true}\n isJSXConverter={false}\n nodeKey={nodeKey}\n // eslint-disable-next-line react-hooks/hooks -- intentionally passed as a prop for custom block components to call\n useInlineBlockComponentContext={useInlineBlockComponentContext}\n />\n )\n }\n return CustomLabel\n }, [CustomLabelFromProps, baseClass, formData, nodeKey, CustomLabel])\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient | undefined\n\n const blockOrSlug = blocksField?.blocks?.[0]\n const clientBlock: ClientBlock | undefined =\n typeof blockOrSlug === 'string' ? config.blocksMap[blockOrSlug] : blockOrSlug\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: parentDocumentFields,\n globalSlug,\n initialBlockData: formData,\n operation,\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData = getDataFromFormState(\n deepCopyObjectSimpleWithoutReactComponents(state, { excludeFiles: true }),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n\n setInitialState(state)\n if (!CustomLabelFromProps) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n }\n\n if (clientBlock && formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n CustomLabelFromProps,\n CustomBlockFromProps,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n operation,\n parentDocumentFields,\n clientBlock,\n ])\n\n const onChange = useCallback<NonNullable<FormProps['onChange']>[number]>(\n ({ formState, submitted }) => {\n if (submitted) {\n if (!CustomLabelFromProps) {\n setCustomLabel(formState._components?.customComponents?.BlockLabel)\n }\n if (!CustomBlockFromProps) {\n setCustomBlock(formState._components?.customComponents?.Block)\n }\n }\n },\n [CustomLabelFromProps, CustomBlockFromProps],\n )\n\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState) => {\n const newData = getDataFromFormState(formState, true)\n newData.blockType = blockType\n\n editor.update(\n () => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n },\n // Without this, the outer editor's reconciler resets DOM selection\n // back into its own root, kicking focus out of any nested richText.\n { tag: SKIP_DOM_SELECTION_TAG },\n )\n },\n [blockType, editor, nodeKey],\n )\n\n const { headerActions, submitRef } = useDrawerSubmit()\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n removeInlineBlock()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"ghost\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"medium\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n {...(isEditable\n ? {\n onClick: () => toggleDrawer(),\n onKeyDown: (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n toggleDrawer()\n }\n },\n role: 'button',\n tabIndex: 0,\n }\n : {})}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, formData.blockType, isEditable, toggleDrawer],\n )\n\n const Label = useMemo(() => {\n if (resolvedCustomLabel) {\n return () => resolvedCustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [resolvedCustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\n toggleDrawer()\n }}\n readOnly={!isEditable}\n schemaPath={schemaFieldsPath}\n uuid={formUuid}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n headerActions={headerActions}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <div className=\"fields-drawer\">\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <RegisterFormSubmit submitRef={submitRef} />\n </div>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {resolvedCustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {resolvedCustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "import type { Data, FormState } from 'payload'\n\nimport { dequal } from 'dequal/lite'\nimport { getDataFromFormState } from 'payload/shared'\n\nexport const getCachedFormStateIfDataMatches = ({\n cachedFormState,\n cachedSchemaPath,\n currentSchemaPath,\n formData,\n}: {\n cachedFormState: FormState\n cachedSchemaPath?: string\n currentSchemaPath?: string\n formData: Data\n}): false | FormState => {\n if (cachedSchemaPath !== currentSchemaPath) {\n return false\n }\n\n const rowFieldPaths = getRowFieldPaths(cachedFormState)\n const cachedData = normalizeData({\n data: getDataFromFormState(cachedFormState, true),\n rowFieldPaths,\n })\n const currentData = normalizeData({\n data: formData,\n rowFieldPaths,\n })\n\n return dequal(withoutSystemBlockFields(cachedData), withoutSystemBlockFields(currentData))\n ? cachedFormState\n : false\n}\n\nconst getRowFieldPaths = (formState: FormState): Set<string> =>\n new Set(\n Object.entries(formState)\n .filter(\n ([, fieldState]) =>\n Array.isArray(fieldState?.rows) &&\n fieldState.value !== null &&\n fieldState.value !== undefined,\n )\n .map(([path]) => path),\n )\n\nconst normalizeData = ({\n data,\n parentPath = '',\n rowFieldPaths,\n}: {\n data: Data\n parentPath?: string\n rowFieldPaths: Set<string>\n}): Data => {\n const normalizedData: Data = {}\n\n for (const [key, value] of Object.entries(data)) {\n const path = parentPath ? `${parentPath}.${key}` : key\n const normalizedValue = normalizeValue({ parentPath: path, rowFieldPaths, value })\n\n if (normalizedValue !== undefined) {\n normalizedData[key] = normalizedValue\n }\n }\n\n return normalizedData\n}\n\nconst normalizeValue = ({\n parentPath,\n rowFieldPaths,\n value,\n}: {\n parentPath: string\n rowFieldPaths: Set<string>\n value: unknown\n}): unknown => {\n if (\n value === undefined ||\n (Array.isArray(value) && value.length === 0 && rowFieldPaths.has(parentPath))\n ) {\n return undefined\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) =>\n item && typeof item === 'object' && !Array.isArray(item)\n ? normalizeData({\n data: item as Data,\n parentPath: `${parentPath}.${index}`,\n rowFieldPaths,\n })\n : item,\n )\n }\n\n if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) {\n return normalizeData({ data: value, parentPath, rowFieldPaths })\n }\n\n return value\n}\n\nconst withoutSystemBlockFields = ({\n blockName: _blockName,\n blockType: _blockType,\n ...data\n}: Data): Data => data\n", "'use client'\nimport ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'\nimport type { InlineBlockFields, SerializedInlineBlockNode } from '../../server/schema.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type InlineBlockDecorateFunction = (\n editor: LexicalEditor,\n config: EditorConfig,\n CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>,\n CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>,\n) => JSX.Element\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n override decorate(\n ...[_editor, config, CustomBlock, CustomLabel]: Parameters<InlineBlockDecorateFunction>\n ): ReturnType<InlineBlockDecorateFunction> {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\n className={config.theme.inlineBlock ?? 'LexicalEditorTheme__inlineBlock'}\n CustomBlock={CustomBlock}\n CustomLabel={CustomLabel}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return $applyNodeReplacement(\n new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\n\nimport type { InlineBlockFields, SerializedInlineBlockNode } from '../schema.js'\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, config?.theme?.inlineBlock)\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n ...super.exportJSON(),\n type: 'inlineBlock',\n fields: this.getFields(),\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return $applyNodeReplacement(\n new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
5
+ "mappings": "oJAKA,OAASA,6BAAAA,OAAiC,wCAC1C,OAASC,sBAAAA,OAA0B,oCACnC,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,mBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,OAAsB,wBAC/B,OAASC,iBAAAA,EAAeC,0BAAAA,OAA8B,UAEtD,OAAO,8CAAAC,GAAA,wBAAAC,OAAA,iBACP,OAAOC,GAAA,iBAAAC,GAAA,eAAAC,EAAA,aAAAC,EAAA,WAAAC,EAAA,UAAAC,MAAA,QAEP,OAASP,MAAAA,OAAAA,OC5BT,OAASQ,UAAAA,OAAc,cACvB,OAASC,wBAAAA,OAA4B,iBAE9B,IAAMC,GAAkCA,CAAC,CAC9CC,gBAAAA,EACAC,iBAAAA,EACAC,kBAAAA,EACAC,SAAAA,CAAQ,IAMT,CACC,GAAIF,IAAqBC,EACvB,MAAO,GAGT,IAAME,EAAgBC,GAAiBL,CAAA,EACjCM,EAAaC,EAAc,CAC/BC,KAAMV,GAAqBE,EAAiB,EAAA,EAC5CI,cAAAA,CACF,CAAA,EACMK,EAAcF,EAAc,CAChCC,KAAML,EACNC,cAAAA,CACF,CAAA,EAEA,OAAOP,GAAOa,GAAyBJ,CAAA,EAAaI,GAAyBD,CAA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EAAA,mCAAA,CACN4H,CAAAA,WACSlE,EAAsBmE,EAAA,MAAA,CAC/B,UAAA,yBAEC9I,CAAA4H,EAAAmB,GACE,CAAIxI,OAAAqE,GAAU,sBAEXnD,gBAAQmD,GACRoE,WAAW,GACXC,iBAAgB3G,EAChB4G,YAAW,GACXC,SAAAA,CAAAA,IACavB,EAAAwB,GAAA,CACb9D,UAAWvE,QAEOgG,WAEpBa,EAAA/H,GAAA,QAGPqD,WAAAA,GAEGmG,aAAAA,EACE1B,qBAAAA,EACA3H,MAAAA,GACA+H,QAAAA,EACAuB,aAAAA,YAEArC,IACF6B,EAAAf,EAAA,UAEC7E,CAAAA,EAAAA,EAAAA,GAAAA,CAAAA,CAAAA,EAAAA,EAAAA,GAAAA,8BAI0CqG,EAAO3B,EAAA,MAAA,CAAO4B,UAAM,GAAAnJ,CAAA,qBAC9DuH,EACCA,EAAC,CAAA,CAAA,IAAIrH,IAAAA,OAxEX+C,EAAqBsB,EAAqB,CAE1C,UAACA,GAAavE,CAAA,aAChB,SAAA,CACG0H,EAAAA,OAAAA,CAAqBxH,SAAW,CAAA,iBAAGG,EAAqB,UAAA,aAAA,MACtDkH,EAAA,MAAA,WAAK,GAAAvH,CAAA,qBACLuH,EACCA,EAAC,CAAA,CAAA,IAAIrH,IAAAA",
6
+ "names": ["useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "RenderFields", "ShimmerEffect", "useConfig", "useDocumentForm", "useDocumentInfo", "useEditDepth", "useOperation", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "SKIP_DOM_SELECTION_TAG", "deepCopyObjectSimpleWithoutReactComponents", "getDataFromFormState", "React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "dequal", "getDataFromFormState", "getCachedFormStateIfDataMatches", "cachedFormState", "cachedSchemaPath", "currentSchemaPath", "formData", "rowFieldPaths", "getRowFieldPaths", "cachedData", "normalizeData", "data", "currentData", "withoutSystemBlockFields", "formState", "Set", "Object", "entries", "filter", "fieldState", "Array", "isArray", "rows", "value", "undefined", "map", "path", "parentPath", "normalizedData", "key", "normalizedValue", "normalizeValue", "length", "has", "item", "index", "getPrototypeOf", "prototype", "blockName", "_blockName", "blockType", "_blockType", "ObjectID", "$applyNodeReplacement", "React", "addClassNamesToElement", "ObjectID", "$applyNodeReplacement", "DecoratorNode", "ServerInlineBlockNode", "__cacheBuster", "__fields", "constructor", "cacheBuster", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "config", "element", "document", "createElement", "theme", "inlineBlock", "decorate", "editor", "exportDOM", "classList", "add", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "getCacheBuster", "getLatest", "setFields", "preventFormStateUpdate", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "_editor", "config", "CustomBlock", "CustomLabel", "_jsx", "cacheBuster", "getCacheBuster", "className", "theme", "inlineBlock", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "$applyNodeReplacement", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "InlineBlockComponentContext", "createContext", "$isInlineBlockNode", "initialState", "React", "InlineBlockComponent", "props", "cacheBuster", "baseClass", "CustomBlockFromProps", "className", "CustomBlock", "CustomLabel", "formData", "nodeKey", "useLexicalEditable", "operation", "useLexicalComposerContext", "isEditable", "i18n", "t", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "uuidFromContext", "setCreatedInlineBlock", "useEditorConfigContext", "useDocumentForm", "fields", "getFormState", "useServerFunctions", "useRef", "editDepth", "useEditDepth", "firstTimeDrawer", "blockType", "setInitialState", "useState", "cachedFormState", "cachedState", "getCachedFormStateIfDataMatches", "schemaFieldsPath", "cachedSchemaPath", "hasMounted", "prevCacheBuster", "useEffect", "current", "formUuid", "uuid", "setCustomLabel", "CustomLabelFromProps", "customComponents", "BlockLabel", "resolvedCustomBlock", "useMemo", "isEditor", "useInlineBlockComponentContext", "resolvedCustomLabel", "drawerSlug", "depth", "toggleDrawer", "useLexicalDrawer", "id", "collectionSlug", "getDocPreferences", "globalSlug", "config", "useConfig", "clientSchemaMap", "componentMapRenderedBlockPath", "blocksField", "blockOrSlug", "clientBlockFields", "removeInlineBlock", "useCallback", "editor", "length", "$getNodeByKey", "blockDisplayName", "clientBlock", "getTranslation", "abortController", "state", "data", "docPermissions", "parentDocumentFields", "docPreferences", "documentFormState", "initialBlockData", "readOnly", "renderAllFields", "signal", "newFormStateData", "getDataFromFormState", "deepCopyObjectSimpleWithoutReactComponents", "node", "newData", "SKIP_DOM_SELECTION_TAG", "setCustomBlock", "awaitInitialState", "abortAndIgnore", "onChange", "formState", "submitted", "isStateOutOfSync", "formData_0", "initialState_0", "key", "Object", "newData_0", "onFormSubmit", "node_0", "tag", "headerActions", "submitRef", "useDrawerSubmit", "RemoveButton", "buttonStyle", "disabled", "e", "icon", "onClick", "round", "size", "tooltip", "label", "EditButton", "_jsx", "Button", "el", "InlineBlockContainer", "e_0", "onKeyDown", "role", "tabIndex", "children", "ref", "inlineBlockElemElemRef", "disableValidationOnSubmit", "onSubmit", "schemaPath", "EditDepthProvider", "Drawer", "slug", "title", "_jsxs", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "RegisterFormSubmit", "value", "Label", "height", "width"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a as M,b as j}from"./chunk-IYBYNEKX.js";import{b as C}from"./chunk-RJ5MAOKZ.js";import{c as it}from"react/compiler-runtime";import{jsx as T}from"react/jsx-runtime";import{Drawer as st,EditDepthProvider as lt,useModal as ct}from"@payloadcms/ui";import"react";import{c as G}from"react/compiler-runtime";import{jsx as $,jsxs as V}from"react/jsx-runtime";import{useLexicalEditable as q}from"@lexical/react/useLexicalEditable";import{Form as Q,RenderFields as X,useDocumentForm as Y,useDocumentInfo as Z,useEffectEvent as z,useOperation as tt,useServerFunctions as et}from"@payloadcms/ui";import{abortAndIgnore as rt}from"@payloadcms/ui/shared";import{useEffect as at,useState as ot}from"react";import{v4 as nt}from"uuid";var U=r=>{let t=G(30),{data:e,featureKey:a,fieldMapOverride:n,handleDrawerSubmit:m,schemaFieldsPathOverride:D,schemaPath:S,schemaPathSuffix:p,submitRef:f}=r,{id:c,collectionSlug:d,getDocPreferences:i,globalSlug:u}=Z(),{fields:h}=Y(),o=q(),s=tt(),[g,E]=ot(!1),{fieldProps:N}=C(),{featureClientSchemaMap:B}=N,{getFormState:x}=et(),l=D??`${S}.lexical_internal_feature.${a}${p?`.${p}`:""}`,_=n??B[a]?.[l],A;t[0]!==h?(A=()=>h,t[0]=h,t[1]=A):A=t[1];let I=z(A),O;t[2]!==d||t[3]!==e||t[4]!==i||t[5]!==x||t[6]!==I||t[7]!==u||t[8]!==c||t[9]!==o||t[10]!==s||t[11]!==l?(O=()=>{let R=new AbortController;return(async()=>{let{state:F}=await x({id:c,collectionSlug:d,data:e??{},docPermissions:{fields:!0},docPreferences:await i(),documentFormState:I(),globalSlug:u,initialBlockData:e,operation:s,readOnly:!o,renderAllFields:!0,schemaPath:l,signal:R.signal});!R.signal.aborted&&F&&E(F)})(),()=>{rt(R)}},t[2]=d,t[3]=e,t[4]=i,t[5]=x,t[6]=I,t[7]=u,t[8]=c,t[9]=o,t[10]=s,t[11]=l,t[12]=O):O=t[12];let w;if(t[13]!==d||t[14]!==e||t[15]!==i||t[16]!==x||t[17]!==u||t[18]!==c||t[19]!==o||t[20]!==s||t[21]!==l?(w=[l,c,e,x,d,o,u,i,s],t[13]=d,t[14]=e,t[15]=i,t[16]=x,t[17]=u,t[18]=c,t[19]=o,t[20]=s,t[21]=l,t[22]=w):w=t[22],at(O,w),g===!1)return null;let v;return t[23]!==_||t[24]!==m||t[25]!==g||t[26]!==o||t[27]!==l||t[28]!==f?(v=V(Q,{className:"fields-drawer",disableValidationOnSubmit:!0,fields:Array.isArray(_)?_:[],initialState:g,onSubmit:m,readOnly:!o,schemaPath:l,uuid:nt(),children:[$(X,{fields:Array.isArray(_)?_:[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:l,permissions:!0,readOnly:!o}),$(j,{submitRef:f})]}),t[23]=_,t[24]=m,t[25]=g,t[26]=o,t[27]=l,t[28]=f,t[29]=v):v=t[29],v};var Jt=r=>{let t=it(18),{className:e,data:a,drawerSlug:n,drawerTitle:m,featureKey:D,fieldMapOverride:S,handleDrawerSubmit:p,schemaFieldsPathOverride:f,schemaPath:c,schemaPathSuffix:d}=r,{closeModal:i}=ct(),{headerActions:u,submitRef:h}=M(),o;if(t[0]!==e||t[1]!==i||t[2]!==a||t[3]!==n||t[4]!==m||t[5]!==D||t[6]!==S||t[7]!==p||t[8]!==u||t[9]!==f||t[10]!==c||t[11]!==d||t[12]!==h){let s;t[14]!==i||t[15]!==n||t[16]!==p?(s=(g,E)=>{i(n),setTimeout(()=>{p(g,E)},1)},t[14]=i,t[15]=n,t[16]=p,t[17]=s):s=t[17],o=T(lt,{children:T(st,{className:e,headerActions:u,slug:n,title:m??"",children:T(U,{data:a,featureKey:D,fieldMapOverride:S,handleDrawerSubmit:s,schemaFieldsPathOverride:f,schemaPath:c,schemaPathSuffix:d,submitRef:h})})}),t[0]=e,t[1]=i,t[2]=a,t[3]=n,t[4]=m,t[5]=D,t[6]=S,t[7]=p,t[8]=u,t[9]=f,t[10]=c,t[11]=d,t[12]=h,t[13]=o}else o=t[13];return o};import{createCommand as dt}from"lexical";var Wt=dt("INSERT_UPLOAD_WITH_DRAWER_COMMAND");import{jsx as H}from"react/jsx-runtime";import xt from"bson-objectid";import{$applyNodeReplacement as _t}from"lexical";import*as K from"react";import ut from"bson-objectid";function y(r,t){if(r.hasAttribute("data-lexical-pending-upload-form-id")){let a=r.getAttribute("data-lexical-pending-upload-form-id");if(a!=null)return{node:t({data:{pending:{formID:a,src:r.getAttribute("src")||""}}})}}if(r.hasAttribute("data-lexical-upload-relation-to")&&r.hasAttribute("data-lexical-upload-id")){let a=r.getAttribute("data-lexical-upload-id"),n=r.getAttribute("data-lexical-upload-relation-to");if(a!=null&&n!=null)return{node:t({data:{fields:{},relationTo:n,value:a}})}}return{node:t({data:{pending:{formID:new ut.default().toHexString(),src:r.getAttribute("src")||""}}})}}import{DecoratorBlockNode as mt}from"@lexical/react/LexicalDecoratorBlockNode.js";import{addClassNamesToElement as pt}from"@lexical/utils";import ft from"bson-objectid";import{$applyNodeReplacement as ht}from"lexical";var b=class extends mt{__data;constructor({data:t,format:e,key:a}){super(e,a),this.__data=t}static clone(t){return new this({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"upload"}static importDOM(){return{img:t=>({conversion:e=>y(e,k),priority:0})}}static importJSON(t){let e={id:t.id,fields:t.fields,pending:t.pending,relationTo:t.relationTo,value:t.value},a=k({data:e});return a.setFormat(t.format),a}static isInline(){return!1}createDOM(t){let e=document.createElement("div");return pt(e,t?.theme?.upload),e}decorate(){return null}exportDOM(){let t=document.createElement("img"),e=this.__data;return e.pending?(t.setAttribute("data-lexical-pending-upload-form-id",String(e?.pending?.formID)),t.setAttribute("src",e?.pending?.src||"")):(t.setAttribute("data-lexical-upload-id",String(e?.value)),t.setAttribute("data-lexical-upload-relation-to",e?.relationTo)),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload"}}getData(){return this.getLatest().__data}setData(t){let e=this.getWritable();e.__data=t}updateDOM(){return!1}};function k({data:r}){return r?.id||(r.id=new ft.default().toHexString()),ht(new b({data:r}))}import{jsx as J}from"react/jsx-runtime";import{ShimmerEffect as gt}from"@payloadcms/ui";var L=()=>J("div",{className:"lexical-upload",children:J(gt,{height:"95px",width:"203px"})});var Dt=K.lazy(()=>import("./component-FCCSBBZG.js").then(r=>({default:r.UploadComponent}))),P=class extends b{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importDOM(){return{img:t=>({conversion:e=>y(e,W),priority:0})}}static importJSON(t){let e={id:t.id,fields:t.fields,pending:t.pending,relationTo:t.relationTo,value:t.value},a=W({data:e});return a.setFormat(t.format),a}decorate(t,e){return this.__data.pending?H(L,{}):H(Dt,{className:e?.theme?.upload??"LexicalEditorTheme__upload",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function W({data:r}){return r?.id||(r.id=new xt.default().toHexString()),_t(new P({data:r}))}function se(r){return r instanceof P}export{Jt as a,Wt as b,P as c,W as d,se as e};
2
+ //# sourceMappingURL=chunk-A7DZCL6D.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utilities/fieldsDrawer/Drawer.tsx", "../../../src/utilities/fieldsDrawer/DrawerContent.tsx", "../../../src/features/upload/client/drawer/commands.ts", "../../../src/features/upload/client/nodes/UploadNode.tsx", "../../../src/features/upload/server/nodes/conversions.ts", "../../../src/features/upload/server/nodes/UploadNode.tsx", "../../../src/features/upload/client/component/pending/index.tsx"],
4
+ "sourcesContent": ["'use client'\nimport type { ClientField, Data, FormState, JsonObject } from 'payload'\n\nimport { Drawer, EditDepthProvider, useModal } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { DrawerContent } from './DrawerContent.js'\nimport { useDrawerSubmit } from './useDrawerSubmit.js'\n\nexport type FieldsDrawerProps = {\n readonly className?: string\n readonly data?: Data\n readonly drawerSlug: string\n readonly drawerTitle?: string\n readonly featureKey: string\n readonly fieldMapOverride?: ClientField[]\n readonly handleDrawerSubmit: (fields: FormState, data: JsonObject) => void\n readonly schemaFieldsPathOverride?: string\n readonly schemaPath: string\n readonly schemaPathSuffix?: string\n}\n\n/**\n * This FieldsDrawer component can be used to easily create a Drawer that contains a form with fields within your feature.\n * The fields are taken directly from the schema map based on your `featureKey` and `schemaPathSuffix`. Thus, this can only\n * be used if you provide your field schema inside the `generateSchemaMap` prop of your feature.server.ts.\n */\nexport const FieldsDrawer: React.FC<FieldsDrawerProps> = ({\n className,\n data,\n drawerSlug,\n drawerTitle,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { closeModal } = useModal()\n const { headerActions, submitRef } = useDrawerSubmit()\n\n // The Drawer only renders its children (and itself) if it's open. Thus, by extracting the main content\n // to DrawerContent, this should be faster\n return (\n <EditDepthProvider>\n <Drawer\n className={className}\n headerActions={headerActions}\n slug={drawerSlug}\n title={drawerTitle ?? ''}\n >\n <DrawerContent\n data={data}\n featureKey={featureKey}\n fieldMapOverride={fieldMapOverride}\n handleDrawerSubmit={(args, args2) => {\n // Simply close drawer - no need for useLexicalDrawer here as at this point,\n // we don't need to restore the cursor position. This is handled by the useEffect in useLexicalDrawer.\n closeModal(drawerSlug)\n\n // Actual drawer submit logic needs to be triggered after the drawer is closed.\n // That's because the lexical selection / cursor restore logic that is striggerer by\n // `useLexicalDrawer` neeeds to be triggered before any editor.update calls that may happen\n // in the `handleDrawerSubmit` function.\n setTimeout(() => {\n handleDrawerSubmit(args, args2)\n }, 1)\n }}\n schemaFieldsPathOverride={schemaFieldsPathOverride}\n schemaPath={schemaPath}\n schemaPathSuffix={schemaPathSuffix}\n submitRef={submitRef}\n />\n </Drawer>\n </EditDepthProvider>\n )\n}\n", "'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useEffectEvent,\n useOperation,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport React, { useEffect, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\nimport { RegisterFormSubmit } from './useDrawerSubmit.js'\nimport './index.css'\n\nexport const DrawerContent: React.FC<\n {\n submitRef: React.RefObject<(() => void) | null>\n } & Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>\n> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n submitRef,\n}) => {\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n const operation = useOperation()\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n // Parent autosave updates this context without starting a new drawer editing session.\n const getParentDocumentFields = useEffectEvent(() => parentDocumentFields)\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: getParentDocumentFields(),\n globalSlug,\n initialBlockData: data,\n operation,\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!controller.signal.aborted && state) {\n setInitialState(state)\n }\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n operation,\n ])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n className=\"fields-drawer\"\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onSubmit={handleDrawerSubmit}\n readOnly={!isEditable}\n schemaPath={schemaFieldsPath}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <RegisterFormSubmit submitRef={submitRef} />\n </Form>\n )\n}\n", "'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nexport const INSERT_UPLOAD_WITH_DRAWER_COMMAND: LexicalCommand<{\n replace: { nodeKey: string } | false\n}> = createCommand('INSERT_UPLOAD_WITH_DRAWER_COMMAND')\n", "'use client'\nimport type { DOMConversionMap, EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nimport type { Internal_UploadData, SerializedUploadNode, UploadData } from '../../server/schema.js'\n\nimport { $convertUploadElement } from '../../server/nodes/conversions.js'\nimport { UploadServerNode } from '../../server/nodes/UploadNode.js'\nimport { PendingUploadComponent } from '../component/pending/index.js'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../../client/component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport class UploadNode extends UploadServerNode {\n static override clone(node: UploadServerNode): UploadServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadNode {\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n override decorate(editor?: LexicalEditor, config?: EditorConfig): JSX.Element {\n if ((this.__data as Internal_UploadData).pending) {\n return <PendingUploadComponent />\n }\n return (\n <RawUploadComponent\n className={config?.theme?.upload ?? 'LexicalEditorTheme__upload'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedUploadNode {\n return super.exportJSON()\n }\n}\n\nexport function $createUploadNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n\n return $applyNodeReplacement(new UploadNode({ data: data as UploadData }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n", "// This file contains functions used to convert dom elements to upload or pending upload lexical nodes. It requires the actual node\n// creation functions to be passed in to stay compatible with both client and server code.\nimport type { DOMConversionOutput } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\n\nimport type { $createUploadNode } from '../../client/nodes/UploadNode.js'\nimport type { Internal_UploadData } from '../schema.js'\nimport type { $createUploadServerNode } from './UploadNode.js'\n\nexport function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nexport function $convertUploadElement(\n domNode: HTMLImageElement,\n $createNode: typeof $createUploadNode | typeof $createUploadServerNode,\n): DOMConversionOutput | null {\n if (domNode.hasAttribute('data-lexical-pending-upload-form-id')) {\n const formID = domNode.getAttribute('data-lexical-pending-upload-form-id')\n\n if (formID != null) {\n const node = $createNode({\n data: {\n pending: {\n formID,\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n return { node }\n }\n }\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n\n // Create pending UploadNode. Auto-Upload functionality will then be handled by the node transform\n const node = $createNode({\n data: {\n pending: {\n formID: new ObjectID.default().toHexString(),\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n\n return { node }\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\n\nimport type { Internal_UploadData, SerializedUploadNode, UploadData } from '../schema.js'\n\nimport { $convertUploadElement } from './conversions.js'\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('div')\n addClassNamesToElement(element, config?.theme?.upload)\n return element\n }\n\n override decorate(): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n const data = this.__data as Internal_UploadData\n if (data.pending) {\n element.setAttribute('data-lexical-pending-upload-form-id', String(data?.pending?.formID))\n element.setAttribute('src', data?.pending?.src || '')\n } else {\n element.setAttribute('data-lexical-upload-id', String(data?.value))\n element.setAttribute('data-lexical-upload-relation-to', data?.relationTo)\n }\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n", "'use client'\n\nimport { ShimmerEffect } from '@payloadcms/ui'\n\nexport const PendingUploadComponent = (): React.ReactNode => {\n return (\n <div className={'lexical-upload'}>\n <ShimmerEffect height={'95px'} width={'203px'} />\n </div>\n )\n}\n"],
5
+ "mappings": "uFAAA,OAAAA,KAAAC,OAAA,iEAGA,OAASC,UAAAA,GAAQC,qBAAAA,GAAmBC,YAAAA,OAAgB,iBACpD,MAAkB,QCJlB,OAAAC,KAAAC,MAAA,2EAGA,OAASC,sBAAAA,MAA0B,oCACnC,OACEC,QAAAA,EACAC,gBAAAA,EACAC,mBAAAA,EACAC,mBAAAA,EACAC,kBAAAA,EACAC,gBAAAA,GACAC,sBAAAA,OACK,iBACP,OAASC,k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AEO,SAASmB,GAAcpC,EAAoC,CAChE,OAAOA,aAAgBH,CACzB",
6
+ "names": ["c", "_c", "Drawer", "EditDepthProvider", "useModal", "c", "_c", "useLexicalEditable", "Form", "RenderFields", "useDocumentForm", "useDocumentInfo", "useEffectEvent", "useOperation", "useServerFunctions", "abortAndIgnore", "useEffect", "useState", "v4", "uuid", "DrawerContent", "t0", "$", "_c", "data", "featureKey", "fieldMapOverride", "handleDrawerSubmit", "schemaFieldsPathOverride", "schemaPath", "schemaPathSuffix", "submitRef", "id", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "parentDocumentFields", "fields", "useDocumentForm", "useLexicalEditable", "isEditable", "useOperation", "operation", "useState", "t1", "fieldProps", "useEditorConfigContext", "featureClientSchemaMap", "getFormState", "useServerFunctions", "schemaFieldsPath", "t2", "getParentDocumentFields", "useEffectEvent", "t3", "controller", "AbortController", "awaitInitialState", "state", "docPermissions", "docPreferences", "documentFormState", "initialBlockData", "readOnly", "renderAllFields", "setInitialState", "signal", "aborted", "abortAndIgnore", "t4", "useEffect", "initialState", "t5", "_jsxs", "Form", "className", "disableValidationOnSubmit", "onSubmit", "uuid", "_jsx", "RenderFields", "children", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "permissions", "FieldsDrawer", "t0", "$", "_c", "className", "data", "drawerSlug", "drawerTitle", "featureKey", "fieldMapOverride", "handleDrawerSubmit", "schemaFieldsPathOverride", "schemaPath", "schemaPathSuffix", "closeModal", "useModal", "headerActions", "submitRef", "useDrawerSubmit", "t1", "t2", "args", "args2", "setTimeout", "_jsx", "EditDepthProvider", "children", "Drawer", "slug", "title", "DrawerContent", "createCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "ObjectID", "$applyNodeReplacement", "React", "ObjectID", "$convertUploadElement", "domNode", "$createNode", "hasAttribute", "formID", "getAttribute", "node", "data", "pending", "src", "id", "relationTo", "fields", "value", "ObjectID", "default", "toHexString", "DecoratorBlockNode", "addClassNamesToElement", "ObjectID", "$applyNodeReplacement", "UploadServerNode", "DecoratorBlockNode", "__data", "constructor", "data", "format", "key", "clone", "node", "__format", "__key", "getType", "importDOM", "img", "conversion", "domNode", "$convertUploadElement", "$createUploadServerNode", "priority", "importJSON", "serializedNode", "importedData", "id", "fields", "pending", "relationTo", "value", "setFormat", "isInline", "createDOM", "config", "element", "document", "createElement", "addClassNamesToElement", "theme", "upload", "decorate", "exportDOM", "setAttribute", "String", "formID", "src", "exportJSON", "getData", "type", "getLatest", "setData", "writable", "getWritable", "updateDOM", "ObjectID", "default", "toHexString", "$applyNodeReplacement", "ShimmerEffect", "PendingUploadComponent", "_jsx", "className", "height", "width", "RawUploadComponent", "lazy", "then", "module", "default", "UploadComponent", "UploadNode", "UploadServerNode", "clone", "node", "getType", "importDOM", "img", "conversion", "domNode", "$convertUploadElement", "$createUploadNode", "priority", "importJSON", "serializedNode", "importedData", "id", "fields", "pending", "relationTo", "value", "data", "setFormat", "format", "decorate", "editor", "config", "__data", "_jsx", "PendingUploadComponent", "className", "theme", "upload", "__format", "nodeKey", "getKey", "exportJSON", "ObjectID", "toHexString", "$applyNodeReplacement", "$isUploadNode"]
7
+ }
@@ -1,2 +1,2 @@
1
1
  import{c as _}from"react/compiler-runtime";import{jsx as b}from"react/jsx-runtime";import{useLexicalComposerContext as h}from"@lexical/react/LexicalComposerContext";import{useDocumentDrawer as v,useModal as E}from"@payloadcms/ui";import{$getPreviousSelection as P,$getSelection as W,$setSelection as q}from"lexical";import{useEffect as y,useState as O}from"react";var J=j=>{let e=_(25),[o]=h(),[n,L]=O(null),[c,k]=O(!1),[d,g,M]=v(j),{closeDrawer:x,drawerSlug:t,openDrawer:C}=M,{modalState:i}=E(),a;e[0]!==o?(a=()=>{o.read(()=>{let l=W()??P();L(l)}),k(!0)},e[0]=o,e[1]=a):a=e[1];let s=a,u;e[2]!==o||e[3]!==n?(u=()=>{n&&o.update(()=>{q(n.clone())},{discrete:!0,skipTransforms:!0})},e[2]=o,e[3]=n,e[4]=u):u=e[4];let m=u,f;e[5]!==x?(f=()=>{x()},e[5]=x,e[6]=f):f=e[6];let T=f,D,p;e[7]!==t||e[8]!==i||e[9]!==m||e[10]!==c?(D=()=>{if(!c)return;let l=i[t];l&&!l?.isOpen&&(k(!1),setTimeout(()=>{m()},1))},p=[i,t,m,c],e[7]=t,e[8]=i,e[9]=m,e[10]=c,e[11]=D,e[12]=p):(D=e[11],p=e[12]),y(D,p);let S;e[13]!==C||e[14]!==s?(S=()=>{s(),C()},e[13]=C,e[14]=s,e[15]=S):S=e[15];let $=S,r;e[16]!==g||e[17]!==s?(r=l=>b(g,{...l,onClick:s}),e[16]=g,e[17]=s,e[18]=r):r=e[18];let w;return e[19]!==d||e[20]!==T||e[21]!==t||e[22]!==$||e[23]!==r?(w={closeDocumentDrawer:T,DocumentDrawer:d,documentDrawerSlug:t,DocumentDrawerToggler:r,openDocumentDrawer:$},e[19]=d,e[20]=T,e[21]=t,e[22]=$,e[23]=r,e[24]=w):w=e[24],w};export{J as a};
2
- //# sourceMappingURL=chunk-WSAPGI3Z.js.map
2
+ //# sourceMappingURL=chunk-EA5BHQ2T.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utilities/fieldsDrawer/useLexicalDocumentDrawer.tsx"],
4
4
  "sourcesContent": ["'use client'\nimport type { UseDocumentDrawer } from '@payloadcms/ui'\nimport type { BaseSelection } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useDocumentDrawer, useModal } from '@payloadcms/ui'\nimport { $getPreviousSelection, $getSelection, $setSelection } from 'lexical'\nimport { useCallback, useEffect, useState } from 'react'\n\n/**\n *\n * Wrapper around useDocumentDrawer that restores and saves selection state (cursor position) when opening and closing the drawer.\n * By default, the lexical cursor position may be lost when opening a drawer and clicking somewhere on that drawer.\n */\nexport const useLexicalDocumentDrawer = (\n args: Parameters<UseDocumentDrawer>[0],\n): {\n closeDocumentDrawer: () => void\n DocumentDrawer: ReturnType<UseDocumentDrawer>[0]\n documentDrawerSlug: string\n DocumentDrawerToggler: ReturnType<UseDocumentDrawer>[1]\n openDocumentDrawer: () => void\n} => {\n const [editor] = useLexicalComposerContext()\n const [selectionState, setSelectionState] = useState<BaseSelection | null>(null)\n const [wasOpen, setWasOpen] = useState<boolean>(false)\n\n const [\n DocumentDrawer,\n DocumentDrawerToggler,\n { closeDrawer: closeDrawer, drawerSlug: documentDrawerSlug, openDrawer },\n ] = useDocumentDrawer(args)\n const { modalState } = useModal()\n\n const storeSelection = useCallback(() => {\n editor.read(() => {\n const selection = $getSelection() ?? $getPreviousSelection()\n setSelectionState(selection)\n })\n setWasOpen(true)\n }, [editor])\n\n const restoreSelection = useCallback(() => {\n if (selectionState) {\n editor.update(\n () => {\n $setSelection(selectionState.clone())\n },\n { discrete: true, skipTransforms: true },\n )\n }\n }, [editor, selectionState])\n\n const closeDocumentDrawer = () => {\n //restoreSelection() // Should already be stored by the useEffect below\n closeDrawer()\n }\n\n // We need to handle drawer closing via a useEffect, as toggleDrawer / closeDrawer will not be triggered if the drawer\n // is closed by clicking outside of the drawer. This useEffect will handle everything.\n useEffect(() => {\n if (!wasOpen) {\n return\n }\n\n const thisModalState = modalState[documentDrawerSlug]\n // Exists in modalState (thus has opened at least once before) and is closed\n if (thisModalState && !thisModalState?.isOpen) {\n setWasOpen(false)\n setTimeout(() => {\n restoreSelection()\n }, 1)\n }\n }, [modalState, documentDrawerSlug, restoreSelection, wasOpen])\n\n const openDocumentDrawer = useCallback(() => {\n storeSelection()\n openDrawer()\n }, [storeSelection, openDrawer])\n\n return {\n closeDocumentDrawer,\n DocumentDrawer,\n documentDrawerSlug,\n DocumentDrawerToggler: (props) => <DocumentDrawerToggler {...props} onClick={storeSelection} />,\n openDocumentDrawer,\n }\n}\n"],
5
- "mappings": "AAAA,OAAAA,KAAAC,MAAA,iEAIA,OAASC,6BAAAA,MAAiC,wCAC1C,OAASC,qBAAAA,EAAmBC,YAAAA,MAAgB,iBA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5B,EAAA,CAAA,GAA0B2B,EAAKE,QAAWnB,yGAJxEoB,EAAA,CAAAZ,oBAAAA,EAAAnB,eAAAA,EAAAK,mBAAAA,EAAAJ,sBAIkB0B,sBAEzB,EAAAjC,EAAA,EAAA,EAAAM,EAAAN,EAAA,EAAA,EAAAyB,EAAAzB,EAAA,EAAA,EAAAW,EAAAX,EAAA,EAAA,EAAAgC,EAAAhC,EAAA,EAAA,EAAAiC,EAAAjC,EAAA,EAAA,EAAAqC,GAAAA,EAAArC,EAAA,EAAA,EANOqC,CAMP",
6
6
  "names": ["c", "_c", "useLexicalComposerContext", "useDocumentDrawer", "useModal", "$getPreviousSelection", "$getSelection", "$setSelection", "useEffect", "useState", "useLexicalDocumentDrawer", "args", "$", "editor", "selectionState", "setSelectionState", "wasOpen", "setWasOpen", "DocumentDrawer", "DocumentDrawerToggler", "t0", "closeDrawer", "drawerSlug", "documentDrawerSlug", "openDrawer", "modalState", "t1", "read", "selection", "storeSelection", "t2", "update", "clone", "discrete", "skipTransforms", "restoreSelection", "t3", "closeDocumentDrawer", "t4", "t5", "thisModalState", "isOpen", "setTimeout", "t6", "openDocumentDrawer", "t7", "props", "_jsx", "onClick", "t8"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ var z=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";import{c as me}from"react/compiler-runtime";import{useRef as pe}from"react";function ft(i){let e=me(2),n=i===void 0?500:i,o=pe(void 0),t;return e[0]!==n?(t=l=>new Promise(c=>{let s=()=>{l(),c()};"requestIdleCallback"in window?("cancelIdleCallback"in window&&o.current!==void 0&&cancelIdleCallback(o.current),o.current=requestIdleCallback(s,{timeout:n})):ge().then(s)}),e[0]=n,e[1]=t):t=e[1],t}function ge(){return new Promise(i=>{setTimeout(i,100),requestAnimationFrame(()=>{setTimeout(i,0)})})}import{jsx as _e}from"react/jsx-runtime";import{useControllableState as we}from"@payloadcms/ui";import{createContext as ye,use as Oe,useMemo as xe}from"react";var Q=ye({currentView:"default",inheritable:!1,setCurrentView:()=>{}}),_t=i=>{let e=be(),n=i.currentView!==void 0,o=e.inheritable&&(!!e.views||!!e.hasExplicitCurrentView),t=n||e.inheritable&&!!e.hasExplicitCurrentView,{children:r,currentView:l,inheritable:c,views:s}={children:i.children,currentView:o?e.currentView:i.currentView,inheritable:e.inheritable||i.inheritable,views:o&&e.views?e.views:i.views},[u,a]=we(l,"default"),h=s&&u!=="default"&&!s[u]?"default":u,m=xe(()=>{let y=s?s[h]:void 0;return{currentView:h,currentViewMap:y,hasExplicitCurrentView:t,inheritable:c,isControlledByParent:o,setCurrentView:a,views:s}},[h,c,t,o,a,s]);return _e(Q,{value:m,children:r})};function be(){return Oe(Q)}var H=class{_x;_y;constructor(e,n){this._x=e,this._y=n}calcDeltaXTo({x:e}){return this.x-e}calcDeltaYTo({y:e}){return this.y-e}calcDistanceTo(e){return Math.sqrt(Math.pow(this.calcDeltaXTo(e),2)+Math.pow(this.calcDeltaYTo(e),2))}calcHorizontalDistanceTo(e){return Math.abs(this.calcDeltaXTo(e))}calcVerticalDistance(e){return Math.abs(this.calcDeltaYTo(e))}equals({x:e,y:n}){return this.x===e&&this.y===n}get x(){return this._x}get y(){return this._y}};function J(i){return i instanceof H}import{jsx as Fe}from"react/jsx-runtime";import{useLexicalComposerContext as Ke}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ze}from"@lexical/utils";import{$getSelection as U,$isRangeSelection as F,$isTextNode as Qe,COMMAND_PRIORITY_LOW as Je,createCommand as Ge,getDOMSelection as Ze}from"lexical";import{useCallback as se,useEffect as le,useState as et}from"react";import*as q from"react";import{c as X}from"react/compiler-runtime";import{useLexicalComposerContext as te}from"@lexical/react/LexicalComposerContext.js";import{getScrollParent as Ce,mergeRegister as G}from"@lexical/utils";import{$getSelection as ne,$isRangeSelection as Se,$setSelection as Me,COMMAND_PRIORITY_LOW as Re,COMMAND_PRIORITY_NORMAL as $,createCommand as De,KEY_ARROW_DOWN_COMMAND as Te,KEY_ARROW_UP_COMMAND as ve,KEY_ENTER_COMMAND as Ee,KEY_ESCAPE_COMMAND as Ie,KEY_TAB_COMMAND as Ne}from"lexical";import{useEffect as B,useLayoutEffect as ke,useRef as Ae,useState as Le}from"react";var Be="slash-menu-popup",oe=i=>{let e=document.getElementById("slash-menu");if(!e)return;let n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),i.scrollIntoView({block:"nearest"})};function Pe(i,e,n){let o=n;for(let t=o;t<=e.length;t++)i.substring(i.length-t)===e.substring(0,t)&&(o=t);return o}function Ve(i){let e=ne();if(!Se(e)||!e.isCollapsed())return;let n=e.anchor;if(n.type!=="text")return;let o=n.getNode();if(!o.isSimpleText())return;let t=n.offset,r=o.getTextContent().slice(0,t),l=i.replaceableString.length,c=Pe(r,i.matchingString,l),s=t-c;if(s<0)return;let u;return s===0?[u]=o.splitText(t):[,u]=o.splitText(s,t),u}function Z(i,e){let n=i.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>o.top&&n.top<o.bottom}function $e(i,e,n,o){let t=X(7),[r]=te(),l,c;t[0]!==r||t[1]!==n||t[2]!==o||t[3]!==i||t[4]!==e?(l=()=>{let s=e.current;if(s!=null&&i!=null){let u=r.getRootElement(),a=u!=null?Ce(u,!1):document.body,h=!1,m=Z(s,a),y=function(){h||(window.requestAnimationFrame(function(){n(),h=!1}),h=!0);let d=Z(s,a);d!==m&&(m=d,o?.(d))},f=new ResizeObserver(n);return window.addEventListener("resize",n),document.addEventListener("scroll",y,{capture:!0,passive:!0}),f.observe(s),()=>{f.disconnect(),window.removeEventListener("resize",n),document.removeEventListener("scroll",y,!0)}}},c=[r,o,n,i,e],t[0]=r,t[1]=n,t[2]=o,t[3]=i,t[4]=e,t[5]=l,t[6]=c):(l=t[5],c=t[6]),B(l,c)}var ee=De("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function ie(i){let e=X(50),{anchorElementRef:n,close:o,editor:t,groups:r,menuRenderFn:l,resolution:c,shouldSplitNodeWithQuery:s}=i,u=s===void 0?!1:s,[a,h]=Le(null),m=c.match&&c.match.matchingString||"",y;e[0]!==t?(y=g=>{let p=t.getRootElement();p!==null&&(p.setAttribute("aria-activedescendant",`${Be}__item-${g.key}`),h(g.key))},e[0]=t,e[1]=y):y=e[1];let f=y,d;e[2]!==r||e[3]!==m||e[4]!==f?(d=()=>{if(r!==null&&m!=null){let g=r.flatMap(qe);if(g.length){let p=g[0];f(p)}}},e[2]=r,e[3]=m,e[4]=f,e[5]=d):d=e[5];let _=d,O;e[6]!==_?(O=()=>{_()},e[6]=_,e[7]=O):O=e[7];let S;e[8]!==m||e[9]!==_?(S=[m,_],e[8]=m,e[9]=_,e[10]=S):S=e[10],B(O,S);let x;e[11]!==o||e[12]!==t||e[13]!==c.match||e[14]!==u?(x=g=>{o(),t.update(()=>{let p=c.match!=null&&u?Ve(c.match):null;p&&p.remove()}),setTimeout(()=>{let p;t.read(()=>{p=ne()?.clone()}),t.update(()=>{p&&Me(p)}),g.onSelect({editor:t,queryString:c.match?c.match.matchingString:""})},0)},e[11]=o,e[12]=t,e[13]=c.match,e[14]=u,e[15]=x):x=e[15];let w=x,R,D;e[16]!==t?(R=()=>()=>{let g=t.getRootElement();g!==null&&g.removeAttribute("aria-activedescendant")},D=[t],e[16]=t,e[17]=R,e[18]=D):(R=e[17],D=e[18]),B(R,D);let E;e[19]!==r||e[20]!==a||e[21]!==_?(E=()=>{r===null?h(null):a===null&&_()},e[19]=r,e[20]=a,e[21]=_,e[22]=E):E=e[22];let T;e[23]!==r||e[24]!==a||e[25]!==_||e[26]!==f?(T=[r,a,f,_],e[23]=r,e[24]=a,e[25]=_,e[26]=f,e[27]=T):T=e[27],ke(E,T);let v;e[28]!==t?(v=()=>G(t.registerCommand(ee,Xe,Re)),e[28]=t,e[29]=v):v=e[29];let I;e[30]!==t||e[31]!==f?(I=[t,f],e[30]=t,e[31]=f,e[32]=I):I=e[32],B(v,I);let k,N;e[33]!==o||e[34]!==t||e[35]!==r||e[36]!==w||e[37]!==a||e[38]!==f?(k=()=>G(t.registerCommand(Te,g=>{let p=g;if(r!==null&&r.length&&a!==null){let b=r.flatMap(He),M=b.findIndex(j=>j.key===a),L=M!==b.length-1?M+1:0,C=b[L];if(!C)return!1;f(C),C.ref!=null&&C.ref.current&&t.dispatchCommand(ee,{index:L,item:C}),p.preventDefault(),p.stopImmediatePropagation()}return!0},$),t.registerCommand(ve,g=>{let p=g;if(r!==null&&r.length&&a!==null){let b=r.flatMap(je),M=b.findIndex(j=>j.key===a),L=M!==0?M-1:b.length-1,C=b[L];if(!C)return!1;f(C),C.ref!=null&&C.ref.current&&oe(C.ref.current),p.preventDefault(),p.stopImmediatePropagation()}return!0},$),t.registerCommand(Ie,g=>{let p=g;return p.preventDefault(),p.stopImmediatePropagation(),o(),!0},$),t.registerCommand(Ne,g=>{let p=g;if(r===null||a===null)return!1;let M=r.flatMap(Ye).find(L=>L.key===a);return M?(p.preventDefault(),p.stopImmediatePropagation(),w(M),!0):!1},$),t.registerCommand(Ee,g=>{if(r===null||a===null)return!1;let b=r.flatMap(We).find(M=>M.key===a);return b?(g!==null&&(g.preventDefault(),g.stopImmediatePropagation()),w(b),!0):!1},$)),N=[w,o,t,r,a,f],e[33]=o,e[34]=t,e[35]=r,e[36]=w,e[37]=a,e[38]=f,e[39]=k,e[40]=N):(k=e[39],N=e[40]),B(k,N);let A;e[41]!==r||e[42]!==w||e[43]!==a?(A={groups:r,selectedItemKey:a,selectItemAndCleanUp:w,setSelectedItemKey:h},e[41]=r,e[42]=w,e[43]=a,e[44]=A):A=e[44];let P=A,V=c.match?c.match.matchingString:"",Y;return e[45]!==n||e[46]!==P||e[47]!==l||e[48]!==V?(Y=l(n,P,V),e[45]=n,e[46]=P,e[47]=l,e[48]=V,e[49]=Y):Y=e[49],Y}function We(i){return i.items}function Ye(i){return i.items}function je(i){return i.items}function He(i){return i.items}function Xe(i){let{item:e}=i;return e.ref&&e.ref.current!=null?(oe(e.ref.current),!0):!1}function qe(i){return i.items}function Ue(i,e){e!=null&&(i.className=e),i.setAttribute("aria-label","Slash menu"),i.setAttribute("role","listbox"),i.style.display="block",i.style.position="absolute"}function re(i,e,n,o){let t=X(14),[r]=te(),l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=z?document.createElement("div"):null,t[0]=l):l=t[0];let c=Ae(l),s;t[1]!==i||t[2]!==o||t[3]!==r||t[4]!==e?(s=()=>{if(c.current===null||parent===void 0)return;let f=r.getRootElement(),d=c.current,_=d.firstChild;if(f!==null&&e!==null){let{height:O,width:S}=e.getRect(),{left:x,top:w}=e.getRect(),R=w;if(w=w-(i.getBoundingClientRect().top+window.scrollY),x=x-(i.getBoundingClientRect().left+window.scrollX),d.style.left=`${x+window.scrollX}px`,d.style.height=`${O}px`,d.style.width=`${S}px`,_!==null){let D=_.getBoundingClientRect(),E=D.height,T=D.width,v=f.getBoundingClientRect(),I=document.dir==="rtl"||document.documentElement.dir==="rtl",k=i.getBoundingClientRect(),N=Math.max(0,v.left);if(!I&&x+T>v.right)d.style.left=`${v.right-T+window.scrollX}px`;else if(I&&D.left<N){let V=N+T-k.left;d.style.left=`${V+window.scrollX}px`}let A=R+E+32>window.innerHeight,P=R<0;A&&!P?d.style.top=`${w+32-E+window.scrollY-(O+24)}px`:d.style.top=`${w+window.scrollY+32}px`}d.isConnected||(Ue(d,o),i.append(d)),d.setAttribute("id","slash-menu"),c.current=d,f.setAttribute("aria-controls","slash-menu")}},t[1]=i,t[2]=o,t[3]=r,t[4]=e,t[5]=s):s=t[5];let u=s,a,h;t[6]!==r||t[7]!==u||t[8]!==e?(a=()=>{let f=r.getRootElement();if(e!==null)return u(),()=>{f!==null&&f.removeAttribute("aria-controls");let d=c.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},h=[r,u,e],t[6]=r,t[7]=u,t[8]=e,t[9]=a,t[10]=h):(a=t[9],h=t[10]),B(a,h);let m;return t[11]!==e||t[12]!==n?(m=f=>{e!==null&&(f||n(null))},t[11]=e,t[12]=n,t[13]=m):m=t[13],$e(e,c,u,m),c}var Lt=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function tt(i){let e=i.anchor;if(e.type!=="text")return null;let n=e.getNode();if(!n.isSimpleText())return null;let o=e.offset;return n.getTextContent().slice(0,o)}function ce(i,e,n){let o=Ze(n);if(o===null||!o.isCollapsed)return!1;let t=o.anchorNode,r=i,l=o.anchorOffset;if(t==null||l==null)return!1;try{e.setStart(t,r),e.setEnd(t,l>1?l:1)}catch{return!1}return!0}function nt(i){let e;return i.getEditorState().read(()=>{let n=U();F(n)&&(e=tt(n))}),e}function ae(i,e){return e!==0?!1:i.getEditorState().read(()=>{let n=U();if(F(n)){let r=n.anchor.getNode().getPreviousSibling();return Qe(r)&&r.isTextEntity()}return!1})}function ue(i){q.startTransition?q.startTransition(i):i()}var ot=Ge("ENABLE_SLASH_MENU_COMMAND");function Bt({anchorClassName:i,anchorElem:e,groups:n,menuRenderFn:o,onClose:t,onOpen:r,onQueryChange:l,triggerFn:c}){let[s]=Ke(),[u,a]=et(null),h=re(e,u,a,i),m=se(()=>{a(null),t!=null&&u!==null&&t()},[t,u]),y=se(f=>{a(f),r!=null&&u===null&&r(f)},[r,u]);return le(()=>ze(s.registerCommand(ot,({node:f})=>(s.getEditorState().read(()=>{let d={leadOffset:0,matchingString:"",replaceableString:""};if(!ae(s,d.leadOffset)&&f!==null){let _=s._window??window,O=_.document.createRange();ce(d.leadOffset,O,_)!==null&&ue(()=>y({getRect:()=>O.getBoundingClientRect(),match:d}));return}}),!0),Je)),[s,y]),le(()=>{let f=()=>{s.getEditorState().read(()=>{let _=s._window??window,O=_.document.createRange(),S=U(),x=nt(s);if(!F(S)||!S.isCollapsed()||x===void 0||O===null){m();return}let w=c({editor:s,query:x});if(l(w?w.matchingString:null),w!==null&&!ae(s,w.leadOffset)&&ce(w.leadOffset,O,_)!==null){ue(()=>y({getRect:()=>O.getBoundingClientRect(),match:w}));return}m()})},d=s.registerUpdateListener(f);return()=>{d()}},[s,c,l,u,m,y]),h.current===null||u===null||s===null?null:Fe(ie,{anchorElementRef:h,close:m,editor:s,groups:n,menuRenderFn:o,resolution:u,shouldSplitNodeWithQuery:!0})}var fe=class i{_bottom;_left;_right;_top;constructor(e,n,o,t){let[r,l]=n<=t?[n,t]:[t,n],[c,s]=e<=o?[e,o]:[o,e];this._top=r,this._right=s,this._left=c,this._bottom=l}static fromDOM(e){let{height:n,left:o,top:t,width:r}=e.getBoundingClientRect();return i.fromLWTH(o,r,t,n)}static fromDOMRect(e){let{height:n,left:o,top:t,width:r}=e;return i.fromLWTH(o,r,t,n)}static fromLTRB(e,n,o,t){return new i(e,n,o,t)}static fromLWTH(e,n,o,t){return new i(e,o,e+n,o+t)}static fromPoints(e,n){let{x:o,y:t}=e,{x:r,y:l}=n;return i.fromLTRB(o,t,r,l)}contains(e){if(J(e)){let{x:l,y:c}=e,s=c<this._top,u=c>this._bottom,a=l<this._left,h=l>this._right;return{reason:{isOnBottomSide:u,isOnLeftSide:a,isOnRightSide:h,isOnTopSide:s},result:!s&&!u&&!a&&!h}}let{bottom:n,left:o,right:t,top:r}=e;return r>=this._top&&r<=this._bottom&&n>=this._top&&n<=this._bottom&&o>=this._left&&o<=this._right&&t>=this._left&&t<=this._right}distanceFromPoint(e){let n=this.contains(e);if(n.result)return{distance:0,isOnBottomSide:n.reason.isOnBottomSide,isOnLeftSide:n.reason.isOnLeftSide,isOnRightSide:n.reason.isOnRightSide,isOnTopSide:n.reason.isOnTopSide};let o=0,t=0;return e.x<this._left?o=this._left-e.x:e.x>this._right&&(o=e.x-this._right),e.y<this._top?t=this._top-e.y:e.y>this._bottom&&(t=e.y-this._bottom),{distance:Math.sqrt(o*o+t*t),isOnBottomSide:e.y>this._bottom,isOnLeftSide:e.x<this._left,isOnRightSide:e.x>this._right,isOnTopSide:e.y<this._top}}equals({bottom:e,left:n,right:o,top:t}){return t===this._top&&e===this._bottom&&n===this._left&&o===this._right}generateNewRect({bottom:e=this.bottom,left:n=this.left,right:o=this.right,top:t=this.top}){return new i(n,t,o,e)}intersectsWith(e){let{height:n,left:o,top:t,width:r}=e,{height:l,left:c,top:s,width:u}=this,a=o+r>=c+u?o+r:c+u,h=t+n>=s+l?t+n:s+l,m=o<=c?o:c,y=t<=s?t:s;return a-m<=r+u&&h-y<=n+l}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)}};import K from"react";var W=new WeakMap;function Yt(i,e){W.has(i)||W.set(i,new Map);let n=W.get(i);for(let[o,t]of Object.entries(e))if(!(!t||typeof t!="object")){if(o==="blocks"){for(let[r,l]of Object.entries(t))n.set(`block:${r}`,l);continue}if(o==="inlineBlocks"){for(let[r,l]of Object.entries(t))n.set(`inlineBlock:${r}`,l);continue}n.set(o,t)}}function jt(i){W.delete(i)}function de(i,e,n){let o=W.get(i);if(e==="block"&&n?.__fields?.blockType){let t=n.__fields.blockType;return o?.get(`block:${t}`)}if(e==="inlineBlock"&&n?.__fields?.blockType){let t=n.__fields.blockType;return o?.get(`inlineBlock:${t}`)}return o?.get(e)}function it({node:i,nodeType:e}){if(!("getType"in i)||i.getType()!==e)return;let n=i;if(n.prototype._originalDecorate||(n.prototype._originalDecorate=n.prototype.decorate),n.prototype._originalCreateDOM||(n.prototype._originalCreateDOM=n.prototype.createDOM),n.prototype.decorate&&!n.prototype._decorateOverridden){n.prototype._decorateOverridden=!0;let o=!!n.prototype.createDOM;n.prototype.decorate=function(t,r){let l=de(t,e,this);if(l){if(l.Component)return l.Component({config:r,editor:t,isEditor:!0,isJSXConverter:!1,node:this});if(l.createDOM&&l.html){let s=typeof l.html=="function"?l.html({config:r,editor:t,isEditor:!0,isJSXConverter:!1,node:this}):l.html;return K.createElement("span",{dangerouslySetInnerHTML:{__html:s}})}if(l.html&&o&&!l.createDOM)return K.createElement(K.Fragment);if(e==="block"){let s=l;if(s.Block||s.Label)return n.prototype._originalDecorate.call(this,t,r,s.Block,s.Label)}else if(e==="inlineBlock"){let s=l;if(s.Block||s.Label)return n.prototype._originalDecorate.call(this,t,r,s.Block,s.Label)}}return n.prototype._originalDecorate.call(this,t,r)}}n.prototype.createDOM&&!n.prototype._createDOMOverridden&&(n.prototype._createDOMOverridden=!0,n.prototype.createDOM=function(o,t){let r=de(t,e,this);if(r){if(r.createDOM)return r.createDOM({config:o,editor:t,node:this});if(r.html){let l=typeof r.html=="function"?r.html({config:o,editor:t,isEditor:!0,isJSXConverter:!1,node:this}):r.html,c=document.createElement("div");return c.innerHTML=l,c.firstElementChild||c}}return n.prototype._originalCreateDOM.call(this,o,t)})}function Ht({editorConfig:i,nodeViews:e}){let n=rt({nodes:i.features.nodes});if(e){let o=new Set;for(let[t,r]of Object.entries(e))!r||typeof r!="object"||(t==="blocks"&&Object.keys(r).length>0?o.add("block"):t==="inlineBlocks"&&Object.keys(r).length>0?o.add("inlineBlock"):o.add(t));for(let t of n)if("getType"in t){let r=t.getType();o.has(r)&&it({node:t,nodeType:r})}}return n}function rt({nodes:i}){return i.map(e=>"node"in e?e.node:e)}import{jsx as he}from"react/jsx-runtime";import"react";var st={16:"M8.5 3.5a.5.5 0 0 0-1 0v4h-4a.5.5 0 0 0 0 1h4v4a.5.5 0 0 0 1 0v-4h4a.5.5 0 0 0 0-1h-4z",24:"M12 6a.5.5 0 0 1 .5.5v5h5a.5.5 0 0 1 0 1h-5v5a.5.5 0 0 1-1 0v-5h-5a.5.5 0 0 1 0-1h5v-5A.5.5 0 0 1 12 6"},Kt=({className:i,size:e=24})=>he("svg",{className:i,fill:"none",height:e,viewBox:`0 0 ${e} ${e}`,width:e,xmlns:"http://www.w3.org/2000/svg",children:he("path",{clipRule:"evenodd",d:st[e],fill:"currentColor",fillRule:"evenodd"})});export{z as a,Kt as b,ft as c,_t as d,be as e,H as f,J as g,Lt as h,ot as i,Bt as j,fe as k,Yt as l,jt as m,Ht as n};
2
+ //# sourceMappingURL=chunk-FAJJXXCW.js.map