@payloadcms/richtext-lexical 3.59.0-internal.929dda3 → 3.59.0-internal.b804ca6

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 (205) hide show
  1. package/dist/exports/client/Field-CJFETHA3.js +2 -0
  2. package/dist/exports/client/Field-CJFETHA3.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-TSIENULZ.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/chunk-BQCXN3B4.js +2 -0
  7. package/dist/exports/client/chunk-BQCXN3B4.js.map +7 -0
  8. package/dist/exports/client/{chunk-2Y72RT72.js → chunk-TLQLXR6Q.js} +2 -2
  9. package/dist/exports/client/chunk-XNERFY6G.js +2 -0
  10. package/dist/exports/client/chunk-XNERFY6G.js.map +7 -0
  11. package/dist/exports/client/component-CYFKY3IL.js +2 -0
  12. package/dist/exports/client/component-CYFKY3IL.js.map +7 -0
  13. package/dist/exports/client/componentInline-NGTRUSGB.js +2 -0
  14. package/dist/exports/client/index.d.ts +3 -0
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +35 -10
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/align/server/i18n.d.ts.map +1 -1
  19. package/dist/features/align/server/i18n.js +6 -0
  20. package/dist/features/align/server/i18n.js.map +1 -1
  21. package/dist/features/blockquote/server/i18n.d.ts.map +1 -1
  22. package/dist/features/blockquote/server/i18n.js +3 -0
  23. package/dist/features/blockquote/server/i18n.js.map +1 -1
  24. package/dist/features/blocks/client/component/BlockContent.d.ts +52 -27
  25. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  26. package/dist/features/blocks/client/component/BlockContent.js +48 -51
  27. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  28. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +2 -9
  29. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
  30. package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -25
  31. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  32. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  33. package/dist/features/blocks/client/component/index.js +71 -56
  34. package/dist/features/blocks/client/component/index.js.map +1 -1
  35. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  36. package/dist/features/blocks/client/componentInline/index.js +13 -11
  37. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  38. package/dist/features/blocks/client/index.d.ts.map +1 -1
  39. package/dist/features/blocks/client/index.js +5 -0
  40. package/dist/features/blocks/client/index.js.map +1 -1
  41. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +6 -0
  42. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -0
  43. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +24 -0
  44. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -0
  45. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +6 -0
  46. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -0
  47. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +20 -0
  48. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -0
  49. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +12 -0
  50. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -0
  51. package/dist/features/blocks/client/markdown/markdownTransformer.js +348 -0
  52. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -0
  53. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +5 -0
  54. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -0
  55. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +156 -0
  56. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -0
  57. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +61 -0
  58. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +1 -0
  59. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +99 -0
  60. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -0
  61. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +4 -0
  62. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +1 -0
  63. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +17 -0
  64. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -0
  65. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +4 -0
  66. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +1 -0
  67. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +26 -0
  68. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -0
  69. package/dist/features/blocks/premade/CodeBlock/converter.d.ts +7 -0
  70. package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +1 -0
  71. package/dist/features/blocks/premade/CodeBlock/converter.js +46 -0
  72. package/dist/features/blocks/premade/CodeBlock/converter.js.map +1 -0
  73. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +2 -0
  74. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +1 -0
  75. package/dist/features/blocks/premade/CodeBlock/converterClient.js +4 -0
  76. package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +1 -0
  77. package/dist/features/blocks/premade/CodeBlock/index.d.ts +7 -0
  78. package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -0
  79. package/dist/features/blocks/premade/CodeBlock/index.js +52 -0
  80. package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -0
  81. package/dist/features/blocks/server/i18n.d.ts.map +1 -1
  82. package/dist/features/blocks/server/i18n.js +9 -0
  83. package/dist/features/blocks/server/i18n.js.map +1 -1
  84. package/dist/features/blocks/server/index.js +1 -1
  85. package/dist/features/blocks/server/index.js.map +1 -1
  86. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +6 -0
  87. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +1 -0
  88. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +27 -0
  89. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +1 -0
  90. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +7 -0
  91. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +1 -0
  92. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +22 -0
  93. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +1 -0
  94. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
  95. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +1 -0
  96. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +15 -0
  97. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -0
  98. package/dist/features/blocks/server/{markdownTransformer.js → markdown/markdownTransformer.js} +6 -48
  99. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -0
  100. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  101. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +5 -3
  102. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  103. package/dist/features/heading/server/i18n.d.ts.map +1 -1
  104. package/dist/features/heading/server/i18n.js +3 -0
  105. package/dist/features/heading/server/i18n.js.map +1 -1
  106. package/dist/features/horizontalRule/server/i18n.d.ts.map +1 -1
  107. package/dist/features/horizontalRule/server/i18n.js +3 -0
  108. package/dist/features/horizontalRule/server/i18n.js.map +1 -1
  109. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  110. package/dist/features/indent/server/i18n.js +4 -0
  111. package/dist/features/indent/server/i18n.js.map +1 -1
  112. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  113. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -1
  114. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  115. package/dist/features/link/server/i18n.d.ts.map +1 -1
  116. package/dist/features/link/server/i18n.js +4 -0
  117. package/dist/features/link/server/i18n.js.map +1 -1
  118. package/dist/features/lists/checklist/server/i18n.d.ts.map +1 -1
  119. package/dist/features/lists/checklist/server/i18n.js +3 -0
  120. package/dist/features/lists/checklist/server/i18n.js.map +1 -1
  121. package/dist/features/lists/orderedList/server/i18n.d.ts.map +1 -1
  122. package/dist/features/lists/orderedList/server/i18n.js +3 -0
  123. package/dist/features/lists/orderedList/server/i18n.js.map +1 -1
  124. package/dist/features/lists/unorderedList/server/i18n.d.ts.map +1 -1
  125. package/dist/features/lists/unorderedList/server/i18n.js +3 -0
  126. package/dist/features/lists/unorderedList/server/i18n.js.map +1 -1
  127. package/dist/features/paragraph/server/i18n.d.ts.map +1 -1
  128. package/dist/features/paragraph/server/i18n.js +4 -0
  129. package/dist/features/paragraph/server/i18n.js.map +1 -1
  130. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  131. package/dist/features/relationship/client/components/RelationshipComponent.js +5 -9
  132. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  133. package/dist/features/relationship/server/i18n.d.ts.map +1 -1
  134. package/dist/features/relationship/server/i18n.js +3 -0
  135. package/dist/features/relationship/server/i18n.js.map +1 -1
  136. package/dist/features/textState/i18n.d.ts.map +1 -1
  137. package/dist/features/textState/i18n.js +3 -0
  138. package/dist/features/textState/i18n.js.map +1 -1
  139. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  140. package/dist/features/toolbars/fixed/client/Toolbar/index.js +7 -1
  141. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  142. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  143. package/dist/features/toolbars/inline/client/Toolbar/index.js +3 -1
  144. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  145. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  146. package/dist/features/upload/client/component/index.js +6 -5
  147. package/dist/features/upload/client/component/index.js.map +1 -1
  148. package/dist/features/upload/server/i18n.d.ts.map +1 -1
  149. package/dist/features/upload/server/i18n.js +3 -0
  150. package/dist/features/upload/server/i18n.js.map +1 -1
  151. package/dist/field/bundled.css +1 -1
  152. package/dist/field/rscEntry.d.ts.map +1 -1
  153. package/dist/field/rscEntry.js +2 -0
  154. package/dist/field/rscEntry.js.map +1 -1
  155. package/dist/i18n.d.ts.map +1 -1
  156. package/dist/i18n.js +6 -0
  157. package/dist/i18n.js.map +1 -1
  158. package/dist/index.d.ts +1 -0
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +1 -0
  161. package/dist/index.js.map +1 -1
  162. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  163. package/dist/lexical/LexicalEditor.js +20 -26
  164. package/dist/lexical/LexicalEditor.js.map +1 -1
  165. package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
  166. package/dist/lexical/ui/icons/CodeBlock/index.js +10 -15
  167. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  168. package/dist/lexical/ui/icons/Collapse/index.d.ts +3 -0
  169. package/dist/lexical/ui/icons/Collapse/index.d.ts.map +1 -0
  170. package/dist/lexical/ui/icons/Collapse/index.js +18 -0
  171. package/dist/lexical/ui/icons/Collapse/index.js.map +1 -0
  172. package/dist/utilities/buildInitialState.d.ts +1 -0
  173. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  174. package/dist/utilities/buildInitialState.js +1 -0
  175. package/dist/utilities/buildInitialState.js.map +1 -1
  176. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  177. package/dist/utilities/fieldsDrawer/DrawerContent.js +7 -3
  178. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  179. package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
  180. package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
  181. package/package.json +6 -6
  182. package/dist/exports/client/Field-EHRBYNHO.js +0 -2
  183. package/dist/exports/client/Field-EHRBYNHO.js.map +0 -7
  184. package/dist/exports/client/RelationshipComponent-APF3CN47.js +0 -2
  185. package/dist/exports/client/RelationshipComponent-APF3CN47.js.map +0 -7
  186. package/dist/exports/client/chunk-3BY5IZJD.js +0 -2
  187. package/dist/exports/client/chunk-3BY5IZJD.js.map +0 -7
  188. package/dist/exports/client/chunk-CYLMY5ZJ.js +0 -2
  189. package/dist/exports/client/chunk-CYLMY5ZJ.js.map +0 -7
  190. package/dist/exports/client/component-VDJI45F2.js +0 -2
  191. package/dist/exports/client/component-VDJI45F2.js.map +0 -7
  192. package/dist/exports/client/componentInline-7TPI7ZBC.js +0 -2
  193. package/dist/features/blocks/client/markdownTransformer.d.ts +0 -17
  194. package/dist/features/blocks/client/markdownTransformer.d.ts.map +0 -1
  195. package/dist/features/blocks/client/markdownTransformer.js +0 -144
  196. package/dist/features/blocks/client/markdownTransformer.js.map +0 -1
  197. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
  198. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +0 -1
  199. package/dist/features/blocks/server/markdownTransformer.d.ts +0 -22
  200. package/dist/features/blocks/server/markdownTransformer.d.ts.map +0 -1
  201. package/dist/features/blocks/server/markdownTransformer.js.map +0 -1
  202. /package/dist/exports/client/{chunk-2Y72RT72.js.map → chunk-TLQLXR6Q.js.map} +0 -0
  203. /package/dist/exports/client/{componentInline-7TPI7ZBC.js.map → componentInline-NGTRUSGB.js.map} +0 -0
  204. /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.d.ts → markdown/linesFromMatchToContentAndPropsString.d.ts} +0 -0
  205. /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.js → markdown/linesFromMatchToContentAndPropsString.js} +0 -0
@@ -7,6 +7,7 @@ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js';
7
7
  import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js';
8
8
  import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js';
9
9
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js';
10
+ import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
10
11
  import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical';
11
12
  import * as React from 'react';
12
13
  import { useEffect, useState } from 'react';
@@ -23,7 +24,7 @@ import { SlashMenuPlugin } from './plugins/SlashMenu/index.js';
23
24
  import { TextPlugin } from './plugins/TextPlugin/index.js';
24
25
  import { LexicalContentEditable } from './ui/ContentEditable.js';
25
26
  export const LexicalEditor = props => {
26
- const $ = _c(14);
27
+ const $ = _c(12);
27
28
  const {
28
29
  editorConfig,
29
30
  editorContainerRef,
@@ -32,6 +33,7 @@ export const LexicalEditor = props => {
32
33
  } = props;
33
34
  const editorConfigContext = useEditorConfigContext();
34
35
  const [editor] = useLexicalComposerContext();
36
+ const isEditable = useLexicalEditable();
35
37
  const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
36
38
  let t0;
37
39
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -87,21 +89,7 @@ export const LexicalEditor = props => {
87
89
  }
88
90
  useEffect(t1, t2);
89
91
  let t3;
90
- if ($[5] !== editor || $[6] !== editorConfig || $[7] !== editorContainerRef || $[8] !== floatingAnchorElem || $[9] !== isSmallWidthViewport || $[10] !== onChange) {
91
- let t4;
92
- if ($[12] !== onChange) {
93
- t4 = (editorState, editor_0, tags) => {
94
- if (!tags.has("focus") || tags.size > 1) {
95
- if (onChange != null) {
96
- onChange(editorState, editor_0, tags);
97
- }
98
- }
99
- };
100
- $[12] = onChange;
101
- $[13] = t4;
102
- } else {
103
- t4 = $[13];
104
- }
92
+ if ($[5] !== editorConfig || $[6] !== editorContainerRef || $[7] !== floatingAnchorElem || $[8] !== isEditable || $[9] !== isSmallWidthViewport || $[10] !== onChange) {
105
93
  t3 = _jsxs(React.Fragment, {
106
94
  children: [editorConfig.features.plugins?.map(_temp), _jsxs("div", {
107
95
  className: "editor-container",
@@ -118,13 +106,19 @@ export const LexicalEditor = props => {
118
106
  })
119
107
  }),
120
108
  ErrorBoundary: LexicalErrorBoundary
121
- }), _jsx(NormalizeSelectionPlugin, {}), _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(TextPlugin, {
109
+ }), _jsx(NormalizeSelectionPlugin, {}), isEditable && _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(TextPlugin, {
122
110
  features: editorConfig.features
123
- }), _jsx(SelectAllPlugin, {}), _jsx(OnChangePlugin, {
111
+ }), _jsx(SelectAllPlugin, {}), isEditable && _jsx(OnChangePlugin, {
124
112
  ignoreSelectionChange: true,
125
- onChange: t4
113
+ onChange: (editorState, editor_0, tags) => {
114
+ if (!tags.has("focus") || tags.size > 1) {
115
+ if (onChange != null) {
116
+ onChange(editorState, editor_0, tags);
117
+ }
118
+ }
119
+ }
126
120
  }), floatingAnchorElem && _jsxs(React.Fragment, {
127
- children: [!isSmallWidthViewport && editor.isEditable() && _jsxs(React.Fragment, {
121
+ children: [!isSmallWidthViewport && isEditable && _jsxs(React.Fragment, {
128
122
  children: [editorConfig.admin?.hideDraggableBlockElement ? null : _jsx(DraggableBlockPlugin, {
129
123
  anchorElem: floatingAnchorElem
130
124
  }), editorConfig.admin?.hideAddBlockButton ? null : _jsx(AddBlockHandlePlugin, {
@@ -138,20 +132,20 @@ export const LexicalEditor = props => {
138
132
  plugin: plugin_1
139
133
  }, plugin_1.key);
140
134
  }
141
- }), editor.isEditable() && _jsx(React.Fragment, {
135
+ }), isEditable && _jsx(React.Fragment, {
142
136
  children: _jsx(SlashMenuPlugin, {
143
137
  anchorElem: floatingAnchorElem
144
138
  })
145
139
  })]
146
- }), editor.isEditable() && _jsxs(React.Fragment, {
140
+ }), isEditable && _jsxs(React.Fragment, {
147
141
  children: [_jsx(HistoryPlugin, {}), editorConfig?.features?.markdownTransformers?.length > 0 && _jsx(MarkdownShortcutPlugin, {})]
148
142
  }), editorConfig.features.plugins?.map(_temp3), editorConfig.features.plugins?.map(_temp4)]
149
143
  }), editorConfig.features.plugins?.map(_temp5)]
150
144
  });
151
- $[5] = editor;
152
- $[6] = editorConfig;
153
- $[7] = editorContainerRef;
154
- $[8] = floatingAnchorElem;
145
+ $[5] = editorConfig;
146
+ $[6] = editorContainerRef;
147
+ $[7] = floatingAnchorElem;
148
+ $[8] = isEditable;
155
149
  $[9] = isSmallWidthViewport;
156
150
  $[10] = onChange;
157
151
  $[11] = t3;
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","t4","editorState","editor_0","tags","has","size","_jsxs","Fragment","children","features","plugins","map","_temp","className","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","isEditable","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n <InsertParagraphAtEndPlugin />\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'below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
+ {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","isEditable","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","_jsxs","Fragment","children","features","plugins","map","_temp","className","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport './LexicalEditor.scss'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n {isEditable && (\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,sBAAsB,QAAQ;AAEvC,SAASC,YAAY,QAAQ;AAC7B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAC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OAEpBd,IAAA,CAAAtD,YAAA;MAAAsE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAhJxE,SAAAI,OAAAI,QAAA;EAAA,IAqJUZ,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAAtD,YAAA;MAAAsE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAvJxE,SAAAK,OAAAI,QAAA;EAAA,IA6JQb,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfd,IAAA,CAAAtD,YAAA;MAAAsE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAcjC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAQjC,CAAA"}
@@ -1,22 +1,17 @@
1
1
  'use client';
2
2
 
3
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import React from 'react';
5
- export const CodeBlockIcon = () => /*#__PURE__*/_jsxs("svg", {
6
- "aria-hidden": "true",
7
- className: "icon",
5
+ export const CodeBlockIcon = () => /*#__PURE__*/_jsx("svg", {
8
6
  fill: "none",
9
- focusable: "false",
10
- height: "20",
11
- viewBox: "0 0 20 20",
12
- width: "20",
7
+ height: "12",
8
+ viewBox: "0 0 15 12",
9
+ width: "15",
13
10
  xmlns: "http://www.w3.org/2000/svg",
14
- children: [/*#__PURE__*/_jsx("path", {
15
- d: "M7.76465 6L3.76465 10L7.76465 14",
16
- stroke: "currentColor"
17
- }), /*#__PURE__*/_jsx("path", {
18
- d: "M12.2354 6L16.2354 10L12.2354 14",
19
- stroke: "currentColor"
20
- })]
11
+ children: /*#__PURE__*/_jsx("path", {
12
+ d: "M11.3738 8.62598L14.0404 5.95931L11.3738 3.29264M3.37376 3.29264L0.707092 5.95931L3.37376 8.62598M9.04043 0.625977L5.70709 11.2926",
13
+ stroke: "currentColor",
14
+ strokeLinecap: "square"
15
+ })
21
16
  });
22
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","CodeBlockIcon","_jsxs","className","fill","focusable","height","viewBox","width","xmlns","_jsx","d","stroke"],"sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nexport const CodeBlockIcon: React.FC = () => (\n <svg\n aria-hidden=\"true\"\n className=\"icon\"\n fill=\"none\"\n focusable=\"false\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n width=\"20\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M7.76465 6L3.76465 10L7.76465 14\" stroke=\"currentColor\" />\n <path d=\"M12.2354 6L16.2354 10L12.2354 14\" stroke=\"currentColor\" />\n </svg>\n)\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,OAAO,MAAMC,aAAA,GAA0BA,CAAA,kBACrCC,KAAA,CAAC;EACC,eAAY;EACZC,SAAA,EAAU;EACVC,IAAA,EAAK;EACLC,SAAA,EAAU;EACVC,MAAA,EAAO;EACPC,OAAA,EAAQ;EACRC,KAAA,EAAM;EACNC,KAAA,EAAM;0BAENC,IAAA,CAAC;IAAKC,CAAA,EAAE;IAAmCC,MAAA,EAAO;mBAClDF,IAAA,CAAC;IAAKC,CAAA,EAAE;IAAmCC,MAAA,EAAO","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","CodeBlockIcon","_jsx","fill","height","viewBox","width","xmlns","d","stroke","strokeLinecap"],"sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nexport const CodeBlockIcon: React.FC = () => (\n <svg fill=\"none\" height=\"12\" viewBox=\"0 0 15 12\" width=\"15\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M11.3738 8.62598L14.0404 5.95931L11.3738 3.29264M3.37376 3.29264L0.707092 5.95931L3.37376 8.62598M9.04043 0.625977L5.70709 11.2926\"\n stroke=\"currentColor\"\n strokeLinecap=\"square\"\n />\n </svg>\n)\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,OAAO,MAAMC,aAAA,GAA0BA,CAAA,kBACrCC,IAAA,CAAC;EAAIC,IAAA,EAAK;EAAOC,MAAA,EAAO;EAAKC,OAAA,EAAQ;EAAYC,KAAA,EAAM;EAAKC,KAAA,EAAM;YAChE,aAAAL,IAAA,CAAC;IACCM,CAAA,EAAE;IACFC,MAAA,EAAO;IACPC,aAAA,EAAc","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const CollapseIcon: React.FC;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/ui/icons/Collapse/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAShC,CAAA"}
@@ -0,0 +1,18 @@
1
+ 'use client';
2
+
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import React from 'react';
5
+ export const CollapseIcon = () => /*#__PURE__*/_jsx("svg", {
6
+ fill: "none",
7
+ height: "15",
8
+ viewBox: "0 0 15 15",
9
+ width: "15",
10
+ xmlns: "http://www.w3.org/2000/svg",
11
+ children: /*#__PURE__*/_jsx("path", {
12
+ d: "M7.16667 13.8333V9.83333M7.16667 9.83333L9.16667 11.8333M7.16667 9.83333L5.16667 11.8333M7.16667 4.5V0.5M7.16667 4.5L9.16667 2.5M7.16667 4.5L5.16667 2.5M1.83333 7.16667H0.5M5.83333 7.16667H4.5M9.83333 7.16667H8.5M13.8333 7.16667H12.5",
13
+ stroke: "currentColor",
14
+ strokeLinecap: "round",
15
+ strokeLinejoin: "round"
16
+ })
17
+ });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["React","CollapseIcon","_jsx","fill","height","viewBox","width","xmlns","d","stroke","strokeLinecap","strokeLinejoin"],"sources":["../../../../../src/lexical/ui/icons/Collapse/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nexport const CollapseIcon: React.FC = () => (\n <svg fill=\"none\" height=\"15\" viewBox=\"0 0 15 15\" width=\"15\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M7.16667 13.8333V9.83333M7.16667 9.83333L9.16667 11.8333M7.16667 9.83333L5.16667 11.8333M7.16667 4.5V0.5M7.16667 4.5L9.16667 2.5M7.16667 4.5L5.16667 2.5M1.83333 7.16667H0.5M5.83333 7.16667H4.5M9.83333 7.16667H8.5M13.8333 7.16667H12.5\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n)\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,OAAO,MAAMC,YAAA,GAAyBA,CAAA,kBACpCC,IAAA,CAAC;EAAIC,IAAA,EAAK;EAAOC,MAAA,EAAO;EAAKC,OAAA,EAAQ;EAAYC,KAAA,EAAM;EAAKC,KAAA,EAAM;YAChE,aAAAL,IAAA,CAAC;IACCM,CAAA,EAAE;IACFC,MAAA,EAAO;IACPC,aAAA,EAAc;IACdC,cAAA,EAAe","ignoreList":[]}
@@ -10,6 +10,7 @@ type Props = {
10
10
  context: {
11
11
  clientFieldSchemaMap: ClientFieldSchemaMap;
12
12
  collectionSlug: string;
13
+ disabled?: boolean;
13
14
  documentData?: any;
14
15
  field: RichTextField;
15
16
  fieldSchemaMap: FieldSchemaMap;
@@ -1 +1 @@
1
- {"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,YAAY,CAAC,EAAE,GAAG,CAAA;QAClB,KAAK,EAAE,aAAa,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB,sBAAsB,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,SAAS,CAAA;QACpB,WAAW,CAAC,EAAE,yBAAyB,CAAA;QACvC,WAAW,EAAE,mBAAmB,CAAA;QAChC,aAAa,EAAE,GAAG,CAAA;QAClB,GAAG,EAAE,cAAc,CAAA;KACpB,CAAA;IACD,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,YAAY,EAAE,oBAAoB,EAClC,QAAQ,GACT,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA2D1C"}
1
+ {"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,YAAY,CAAC,EAAE,GAAG,CAAA;QAClB,KAAK,EAAE,aAAa,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB,sBAAsB,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,SAAS,CAAA;QACpB,WAAW,CAAC,EAAE,yBAAyB,CAAA;QACvC,WAAW,EAAE,mBAAmB,CAAA;QAChC,aAAa,EAAE,GAAG,CAAA;QAClB,GAAG,EAAE,cAAc,CAAA;KACpB,CAAA;IACD,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,YAAY,EAAE,oBAAoB,EAClC,QAAQ,GACT,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA4D1C"}
@@ -33,6 +33,7 @@ export async function buildInitialState({
33
33
  operation: context.operation,
34
34
  permissions: true,
35
35
  preferences: context.preferences,
36
+ readOnly: context.disabled,
36
37
  renderAllFields: true,
37
38
  renderFieldFn: context.renderFieldFn,
38
39
  req: context.req,
@@ -1 +1 @@
1
- {"version":3,"file":"buildInitialState.js","names":["fieldSchemasToFormState","buildInitialState","context","initialState","initialStateFromArgs","nodeData","node","children","type","blockNode","id","fields","schemaFieldsPath","lexicalFieldSchemaPath","blockType","formStateResult","clientFieldSchemaMap","collectionSlug","data","documentData","fieldSchemaMap","get","initialBlockData","operation","permissions","preferences","renderAllFields","renderFieldFn","req","schemaPath","formState","currentFieldPreferences","field","name","collapsedArray","collapsed","Array","isArray","includes"],"sources":["../../src/utilities/buildInitialState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type {\n ClientFieldSchemaMap,\n DocumentPreferences,\n FieldSchemaMap,\n FormState,\n Operation,\n PayloadRequest,\n RichTextField,\n SanitizedFieldPermissions,\n} from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { SerializedBlockNode } from '../nodeTypes.js'\n\nexport type InitialLexicalFormState = {\n [nodeID: string]: {\n [key: string]: any\n formState?: FormState\n }\n}\n\ntype Props = {\n context: {\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n documentData?: any\n field: RichTextField\n fieldSchemaMap: FieldSchemaMap\n id?: number | string\n lexicalFieldSchemaPath: string\n operation: Operation\n permissions?: SanitizedFieldPermissions\n preferences: DocumentPreferences\n renderFieldFn: any\n req: PayloadRequest\n }\n initialState?: InitialLexicalFormState\n nodeData: SerializedLexicalNode[]\n}\n\nexport async function buildInitialState({\n context,\n initialState: initialStateFromArgs,\n nodeData,\n}: Props): Promise<InitialLexicalFormState> {\n let initialState: InitialLexicalFormState = initialStateFromArgs ?? {}\n for (const node of nodeData) {\n if ('children' in node) {\n initialState = await buildInitialState({\n context,\n initialState,\n nodeData: node.children as SerializedLexicalNode[],\n })\n }\n\n if (node.type === 'block' || node.type === 'inlineBlock') {\n const blockNode = node as SerializedBlockNode\n const id = blockNode?.fields?.id\n if (!id) {\n continue\n }\n\n const schemaFieldsPath =\n node.type === 'block'\n ? `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockNode.fields.blockType}.fields`\n : `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockNode.fields.blockType}.fields`\n\n // Build form state for the block\n\n const formStateResult = await fieldSchemasToFormState({\n id: context.id,\n clientFieldSchemaMap: context.clientFieldSchemaMap,\n collectionSlug: context.collectionSlug,\n data: blockNode.fields,\n documentData: context.documentData,\n fields: (context.fieldSchemaMap.get(schemaFieldsPath) as any)?.fields,\n fieldSchemaMap: context.fieldSchemaMap,\n initialBlockData: blockNode.fields,\n operation: context.operation as any, // TODO: Type\n permissions: true,\n preferences: context.preferences,\n renderAllFields: true, // If this function runs, the parent lexical field is being re-rendered => thus we can assume all its sub-fields need to be re-rendered\n renderFieldFn: context.renderFieldFn,\n req: context.req,\n schemaPath: schemaFieldsPath,\n })\n\n if (!initialState[id]) {\n initialState[id] = {}\n }\n\n initialState[id].formState = formStateResult\n\n if (node.type === 'block') {\n const currentFieldPreferences = context.preferences?.fields?.[context.field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n if (Array.isArray(collapsedArray) && collapsedArray.includes(id)) {\n initialState[id].collapsed = true\n }\n }\n }\n }\n return initialState\n}\n"],"mappings":"AAYA,SAASA,uBAAuB,QAAQ;AA8BxC,OAAO,eAAeC,kBAAkB;EACtCC,OAAO;EACPC,YAAA,EAAcC,oBAAoB;EAClCC;AAAQ,CACF;EACN,IAAIF,YAAA,GAAwCC,oBAAA,IAA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B,OAAA,CAAQ0B,GAAG;QAChBC,UAAA,EAAYjB;MACd;MAEA,IAAI,CAACT,YAAY,CAACO,EAAA,CAAG,EAAE;QACrBP,YAAY,CAACO,EAAA,CAAG,GAAG,CAAC;MACtB;MAEAP,YAAY,CAACO,EAAA,CAAG,CAACoB,SAAS,GAAGf,eAAA;MAE7B,IAAIT,IAAA,CAAKE,IAAI,KAAK,SAAS;QACzB,MAAMuB,uBAAA,GAA0B7B,OAAA,CAAQuB,WAAW,EAAEd,MAAA,GAAST,OAAA,CAAQ8B,KAAK,CAACC,IAAI,CAAC;QACjF,MAAMC,cAAA,GAAiBH,uBAAA,EAAyBI,SAAA;QAChD,IAAIC,KAAA,CAAMC,OAAO,CAACH,cAAA,KAAmBA,cAAA,CAAeI,QAAQ,CAAC5B,EAAA,GAAK;UAChEP,YAAY,CAACO,EAAA,CAAG,CAACyB,SAAS,GAAG;QAC/B;MACF;IACF;EACF;EACA,OAAOhC,YAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"buildInitialState.js","names":["fieldSchemasToFormState","buildInitialState","context","initialState","initialStateFromArgs","nodeData","node","children","type","blockNode","id","fields","schemaFieldsPath","lexicalFieldSchemaPath","blockType","formStateResult","clientFieldSchemaMap","collectionSlug","data","documentData","fieldSchemaMap","get","initialBlockData","operation","permissions","preferences","readOnly","disabled","renderAllFields","renderFieldFn","req","schemaPath","formState","currentFieldPreferences","field","name","collapsedArray","collapsed","Array","isArray","includes"],"sources":["../../src/utilities/buildInitialState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type {\n ClientFieldSchemaMap,\n DocumentPreferences,\n FieldSchemaMap,\n FormState,\n Operation,\n PayloadRequest,\n RichTextField,\n SanitizedFieldPermissions,\n} from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { SerializedBlockNode } from '../nodeTypes.js'\n\nexport type InitialLexicalFormState = {\n [nodeID: string]: {\n [key: string]: any\n formState?: FormState\n }\n}\n\ntype Props = {\n context: {\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n disabled?: boolean\n documentData?: any\n field: RichTextField\n fieldSchemaMap: FieldSchemaMap\n id?: number | string\n lexicalFieldSchemaPath: string\n operation: Operation\n permissions?: SanitizedFieldPermissions\n preferences: DocumentPreferences\n renderFieldFn: any\n req: PayloadRequest\n }\n initialState?: InitialLexicalFormState\n nodeData: SerializedLexicalNode[]\n}\n\nexport async function buildInitialState({\n context,\n initialState: initialStateFromArgs,\n nodeData,\n}: Props): Promise<InitialLexicalFormState> {\n let initialState: InitialLexicalFormState = initialStateFromArgs ?? {}\n for (const node of nodeData) {\n if ('children' in node) {\n initialState = await buildInitialState({\n context,\n initialState,\n nodeData: node.children as SerializedLexicalNode[],\n })\n }\n\n if (node.type === 'block' || node.type === 'inlineBlock') {\n const blockNode = node as SerializedBlockNode\n const id = blockNode?.fields?.id\n if (!id) {\n continue\n }\n\n const schemaFieldsPath =\n node.type === 'block'\n ? `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockNode.fields.blockType}.fields`\n : `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockNode.fields.blockType}.fields`\n\n // Build form state for the block\n\n const formStateResult = await fieldSchemasToFormState({\n id: context.id,\n clientFieldSchemaMap: context.clientFieldSchemaMap,\n collectionSlug: context.collectionSlug,\n data: blockNode.fields,\n documentData: context.documentData,\n fields: (context.fieldSchemaMap.get(schemaFieldsPath) as any)?.fields,\n fieldSchemaMap: context.fieldSchemaMap,\n initialBlockData: blockNode.fields,\n operation: context.operation as any, // TODO: Type\n permissions: true,\n preferences: context.preferences,\n readOnly: context.disabled,\n renderAllFields: true, // If this function runs, the parent lexical field is being re-rendered => thus we can assume all its sub-fields need to be re-rendered\n renderFieldFn: context.renderFieldFn,\n req: context.req,\n schemaPath: schemaFieldsPath,\n })\n\n if (!initialState[id]) {\n initialState[id] = {}\n }\n\n initialState[id].formState = formStateResult\n\n if (node.type === 'block') {\n const currentFieldPreferences = context.preferences?.fields?.[context.field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n if (Array.isArray(collapsedArray) && collapsedArray.includes(id)) {\n initialState[id].collapsed = true\n }\n }\n }\n }\n return initialState\n}\n"],"mappings":"AAYA,SAASA,uBAAuB,QAAQ;AA+BxC,OAAO,eAAeC,kBAAkB;EACtCC,OAAO;EACPC,YAAA,EAAcC,oBAAoB;EAClCC;AAAQ,CACF;EACN,IAAIF,YAAA,GAAwCC,oBAAA,IAAwB,CAAC;EACrE,KAAK,MAAME,IAAA,IAAQD,QAAA,EAAU;IAC3B,IAAI,cAAcC,IAAA,EAAM;MACtBH,YAAA,GAAe,MAAMF,iBAAA,CAAkB;QACrCC,OAAA;QACAC,YAAA;QACAE,QAAA,EAAUC,IAAA,CAAKC;MACjB;IACF;IAEA,IAAID,IAAA,CAAKE,IAAI,KAAK,WAAWF,IAAA,CAAKE,IAAI,KAAK,eAAe;MACxD,MAAMC,SAAA,GAAYH,IAAA;MAClB,MAAMI,EAAA,GAAKD,SAAA,EAAWE,MAAA,EAAQD,EAAA;MAC9B,IAAI,CAACA,EAAA,EAAI;QACP;MACF;MAEA,MAAME,gBAAA,GACJN,IAAA,CAAKE,IAAI,KAAK,UACV,GAAGN,OAAA,CAAQW,sBAAsB,mDAAmDJ,SAAA,CAAUE,MAAM,CAACG,SAAS,SAAS,GACvH,GAAGZ,OAAA,CAAQW,sBAAsB,0DAA0DJ,SAAA,CAAUE,MAAM,CAACG,SAAS,SAAS;MAEpI;MAEA,MAAMC,eAAA,GAAkB,MAAMf,uBAAA,CAAwB;QACpDU,EAAA,EAAIR,OAAA,CAAQQ,EAAE;QACdM,oBAAA,EAAsBd,OAAA,CAAQc,oBAAoB;QAClDC,cAAA,EAAgBf,OAAA,CAAQe,cAAc;QACtCC,IAAA,EAAMT,SAAA,CAAUE,MAAM;QACtBQ,YAAA,EAAcjB,OAAA,CAAQiB,YAAY;QAClCR,MAAA,EAAST,OAAA,CAAQkB,cAAc,CAACC,GAAG,CAACT,gBAAA,GAA2BD,MAAA;QAC/DS,cAAA,EAAgBlB,OAAA,CAAQkB,cAAc;QACtCE,gBAAA,EAAkBb,SAAA,CAAUE,MAAM;QAClCY,SAAA,EAAWrB,OAAA,CAAQqB,SAAS;QAC5BC,WAAA,EAAa;QACbC,WAAA,EAAavB,OAAA,CAAQuB,WAAW;QAChCC,QAAA,EAAUxB,OAAA,CAAQyB,QAAQ;QAC1BC,eAAA,EAAiB;QACjBC,aAAA,EAAe3B,OAAA,CAAQ2B,aAAa;QACpCC,GAAA,EAAK5B,OAAA,CAAQ4B,GAAG;QAChBC,UAAA,EAAYnB;MACd;MAEA,IAAI,CAACT,YAAY,CAACO,EAAA,CAAG,EAAE;QACrBP,YAAY,CAACO,EAAA,CAAG,GAAG,CAAC;MACtB;MAEAP,YAAY,CAACO,EAAA,CAAG,CAACsB,SAAS,GAAGjB,eAAA;MAE7B,IAAIT,IAAA,CAAKE,IAAI,KAAK,SAAS;QACzB,MAAMyB,uBAAA,GAA0B/B,OAAA,CAAQuB,WAAW,EAAEd,MAAA,GAAST,OAAA,CAAQgC,KAAK,CAACC,IAAI,CAAC;QACjF,MAAMC,cAAA,GAAiBH,uBAAA,EAAyBI,SAAA;QAChD,IAAIC,KAAA,CAAMC,OAAO,CAACH,cAAA,KAAmBA,cAAA,CAAeI,QAAQ,CAAC9B,EAAA,GAAK;UAChEP,YAAY,CAACO,EAAA,CAAG,CAAC2B,SAAS,GAAG;QAC/B;MACF;IACF;EACF;EACA,OAAOlC,YAAA;AACT","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAGvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAIpD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,aAAa,CAAC,CA8IzF,CAAA"}
1
+ {"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAGvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAIpD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,aAAa,CAAC,CAmJzF,CAAA"}
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
4
5
  import { Form, FormSubmit, RenderFields, useDocumentForm, useDocumentInfo, useServerFunctions, useTranslation } from '@payloadcms/ui';
5
6
  import { abortAndIgnore } from '@payloadcms/ui/shared';
6
7
  import { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared';
@@ -28,6 +29,7 @@ export const DrawerContent = ({
28
29
  const {
29
30
  fields: parentDocumentFields
30
31
  } = useDocumentForm();
32
+ const isEditable = useLexicalEditable();
31
33
  const onChangeAbortControllerRef = useRef(new AbortController());
32
34
  const [initialState, setInitialState] = useState(false);
33
35
  const {
@@ -58,6 +60,7 @@ export const DrawerContent = ({
58
60
  globalSlug,
59
61
  initialBlockData: data,
60
62
  operation: 'update',
63
+ readOnly: !isEditable,
61
64
  renderAllFields: true,
62
65
  schemaPath: schemaFieldsPath,
63
66
  signal: controller.signal
@@ -68,7 +71,7 @@ export const DrawerContent = ({
68
71
  return () => {
69
72
  abortAndIgnore(controller);
70
73
  };
71
- }, [schemaFieldsPath, id, data, getFormState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
74
+ }, [schemaFieldsPath, id, data, getFormState, collectionSlug, isEditable, globalSlug, getDocPreferences, parentDocumentFields]);
72
75
  const onChange = useCallback(async ({
73
76
  formState: prevFormState
74
77
  }) => {
@@ -89,6 +92,7 @@ export const DrawerContent = ({
89
92
  globalSlug,
90
93
  initialBlockFormState: prevFormState,
91
94
  operation: 'update',
95
+ readOnly: !isEditable,
92
96
  schemaPath: schemaFieldsPath,
93
97
  signal: controller_0.signal
94
98
  });
@@ -96,7 +100,7 @@ export const DrawerContent = ({
96
100
  return prevFormState;
97
101
  }
98
102
  return state_0;
99
- }, [getFormState, id, collectionSlug, getDocPreferences, parentDocumentFields, globalSlug, schemaFieldsPath]);
103
+ }, [getFormState, id, isEditable, collectionSlug, getDocPreferences, parentDocumentFields, globalSlug, schemaFieldsPath]);
100
104
  // cleanup effect
101
105
  useEffect(() => {
102
106
  return () => {
@@ -123,7 +127,7 @@ export const DrawerContent = ({
123
127
 
124
128
  parentSchemaPath: schemaFieldsPath,
125
129
  permissions: true,
126
- readOnly: false
130
+ readOnly: !isEditable
127
131
  }), /*#__PURE__*/_jsx(FormSubmit, {
128
132
  children: t('fields:saveChanges')
129
133
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerContent.js","names":["Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","_jsxs","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","_jsx","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","readOnly"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, 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'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\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 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: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\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={false}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SACEA,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;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,EACAF,UAAA,EACAU,gBAAA,CACD;EAGH;EACA5B,SAAA,CAAU;IACR,OAAO;MACLJ,cAAA,CAAeyB,0BAAA,CAA2BqB,OAAO;IACnD;EACF,GAAG,EAAE;EAEL,IAAInB,YAAA,KAAiB,OAAO;IAC1B,OAAO;EACT;EAEA,oBACEqB,KAAA,CAACvD,IAAA;IACCwD,YAAA,EAAc,CAACN,QAAA,CAAS;IACxBO,yBAAyB;IACzB3B,MAAA,EAAQ4B,KAAA,CAAMC,OAAO,CAAC7B,MAAA,IAAUA,MAAA,GAAS,EAAE;IAC3CI,YAAA,EAAcA,YAAA;IACdgB,QAAA,EAAU,CAACA,QAAA,CAAS;IACpBU,QAAA,EAAUvC,kBAAA;IACVN,IAAA,EAAMA,IAAA;4BAEN8C,IAAA,CAAC3D,YAAA;MACC4B,MAAA,EAAQ4B,KAAA,CAAMC,OAAO,CAAC7B,MAAA,IAAUA,MAAA,GAAS,EAAE;MAC3CgC,WAAW;MACXC,eAAA,EAAgB;MAChBC,UAAA,EAAW,GAAG;MAAA;;MACdC,gBAAA,EAAkB1B,gBAAA;MAClB2B,WAAA,EAAa;MACbC,QAAA,EAAU;qBAEZN,IAAA,CAAC5D,UAAA;gBAAYwB,CAAA,CAAE;;;AAGrB","ignoreList":[]}
1
+ {"version":3,"file":"DrawerContent.js","names":["useLexicalEditable","Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","isEditable","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","_jsxs","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","_jsx","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, 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'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\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 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: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\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 parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\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={!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BAAA;MAC9DsB,SAAA,EAAWC,aAAA;MACXzB,UAAA;MACA2B,qBAAA,EAAuBF,aAAA;MACvBN,SAAA,EAAW;MACXC,QAAA,EAAU,CAACjB,UAAA;MACXT,UAAA,EAAYiB,gBAAA;MACZW,MAAA,EAAQV,YAAA,CAAWU;IACrB;IAEA,IAAI,CAACR,OAAA,EAAO;MACV,OAAOW,aAAA;IACT;IAEA,OAAOX,OAAA;EACT,GACA,CACEJ,YAAA,EACAb,EAAA,EACAM,UAAA,EACAL,cAAA,EACAC,iBAAA,EACAG,oBAAA,EACAF,UAAA,EACAW,gBAAA,CACD;EAGH;EACA7B,SAAA,CAAU;IACR,OAAO;MACLJ,cAAA,CAAe0B,0BAAA,CAA2BsB,OAAO;IACnD;EACF,GAAG,EAAE;EAEL,IAAIpB,YAAA,KAAiB,OAAO;IAC1B,OAAO;EACT;EAEA,oBACEsB,KAAA,CAACzD,IAAA;IACC0D,YAAA,EAAc,CAACN,QAAA,CAAS;IACxBO,yBAAyB;IACzB7B,MAAA,EAAQ8B,KAAA,CAAMC,OAAO,CAAC/B,MAAA,IAAUA,MAAA,GAAS,EAAE;IAC3CK,YAAA,EAAcA,YAAA;IACdiB,QAAA,EAAU,CAACA,QAAA,CAAS;IACpBU,QAAA,EAAUzC,kBAAA;IACVN,IAAA,EAAMA,IAAA;4BAENgD,IAAA,CAAC7D,YAAA;MACC4B,MAAA,EAAQ8B,KAAA,CAAMC,OAAO,CAAC/B,MAAA,IAAUA,MAAA,GAAS,EAAE;MAC3CkC,WAAW;MACXC,eAAA,EAAgB;MAChBC,UAAA,EAAW,GAAG;MAAA;;MACdC,gBAAA,EAAkB3B,gBAAA;MAClB4B,WAAA,EAAa;MACbnB,QAAA,EAAU,CAACjB;qBAEb+B,IAAA,CAAC9D,UAAA;gBAAYwB,CAAA,CAAE;;;AAGrB","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/linesFromMatchToContentAndPropsString.js';
2
- import { createTagRegexes } from '../../features/blocks/server/markdownTransformer.js';
1
+ import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js';
2
+ import { createTagRegexes } from '../../features/blocks/server/markdown/markdownTransformer.js';
3
3
  /**
4
4
  * Helpful utility for parsing out all matching top-level JSX tags in a given string.
5
5
  * This will collect them in a list, that contains the content of the JSX tag and the props string.
@@ -1 +1 @@
1
- {"version":3,"file":"collectTopLevelJSXInLines.js","names":["linesFromStartToContentAndPropsString","createTagRegexes","collectTopLevelJSXInLines","lines","jsxToMatch","finds","regex","linesLength","length","i","line","startMatch","match","regExpStart","content","endLineIndex","propsString","isEndOptional","regexpEndRegex","regExpEnd","startLineIndex","push"],"sources":["../../../src/utilities/jsx/collectTopLevelJSXInLines.ts"],"sourcesContent":["import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/linesFromMatchToContentAndPropsString.js'\nimport { createTagRegexes } from '../../features/blocks/server/markdownTransformer.js'\n\n/**\n * Helpful utility for parsing out all matching top-level JSX tags in a given string.\n * This will collect them in a list, that contains the content of the JSX tag and the props string.\n *\n * While this is not used within payload, this can be used for certain payload blocks that need to\n * be serializable and deserializable to and from JSX.\n *\n * @example:\n *\n * Say you have Steps block that contains a steps array. Its JSX representation may look like this:\n *\n * <Steps>\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n * </Steps>\n *\n * In this case, the Steps block would have the following content as its children string:\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n *\n * It could then use this function to collect all the top-level JSX tags (= the steps):\n *\n * collectTopLevelJSXInLines(children.split('\\n'), 'Step')\n *\n * This will return:\n *\n * [\n * {\n * content: '<h1>Step 1</h1>',\n * propsString: 'title=\"Step1\"',\n * },\n * {\n * content: '<h1>Step 2</h1>',\n * propsString: 'title=\"Step2\"',\n * },\n * ]\n *\n * You can then map this data to construct the data for this blocks array field.\n */\nexport function collectTopLevelJSXInLines(\n lines: Array<string>,\n jsxToMatch: string,\n): {\n content: string\n propsString: string\n}[] {\n const finds: {\n content: string\n propsString: string\n }[] = []\n const regex = createTagRegexes(jsxToMatch)\n\n const linesLength = lines.length\n\n for (let i = 0; i < linesLength; i++) {\n const line = lines[i]!\n const startMatch = line.match(regex.regExpStart)\n if (!startMatch) {\n continue // Try next transformer\n }\n\n const { content, endLineIndex, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines,\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: i,\n startMatch,\n })\n\n finds.push({\n content,\n propsString,\n })\n\n i = endLineIndex\n continue\n }\n\n return finds\n}\n"],"mappings":"AAAA,SAASA,qCAAqC,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,OAAO,SAASC,0BACdC,KAAoB,EACpBC,UAAkB;EAKlB,MAAMC,KAAA,GAGA,EAAE;EACR,MAAMC,KAAA,GAAQL,gBAAA,CAAiBG,UAAA;EAE/B,MAAMG,WAAA,GAAcJ,KAAA,CAAMK,MAAM;EAEhC,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIF,WAAA,EAAaE,CAAA,IAAK;IACpC,MAAMC,IAAA,GAAOP,KAAK,CAACM,CAAA,CAAE;IACrB,MAAME,UAAA,GAAaD,IAAA,CAAKE,KAAK,CAACN,KAAA,CAAMO,WAAW;IAC/C,IAAI,CAACF,UAAA,EAAY;MACf,UAAS;IACX;IAEA,MAAM;MAAEG,OAAO;MAAEC,YAAY;MAAEC;IAAW,CAAE,GAAGhB,qCAAA,CAAsC;MACnFiB,aAAA,EAAe;MACfd,KAAA;MACAe,cAAA,EAAgBZ,KAAA,CAAMa,SAAS;MAC/BC,cAAA,EAAgBX,CAAA;MAChBE;IACF;IAEAN,KAAA,CAAMgB,IAAI,CAAC;MACTP,OAAA;MACAE;IACF;IAEAP,CAAA,GAAIM,YAAA;IACJ;EACF;EAEA,OAAOV,KAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"collectTopLevelJSXInLines.js","names":["linesFromStartToContentAndPropsString","createTagRegexes","collectTopLevelJSXInLines","lines","jsxToMatch","finds","regex","linesLength","length","i","line","startMatch","match","regExpStart","content","endLineIndex","propsString","isEndOptional","regexpEndRegex","regExpEnd","startLineIndex","push"],"sources":["../../../src/utilities/jsx/collectTopLevelJSXInLines.ts"],"sourcesContent":["import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js'\nimport { createTagRegexes } from '../../features/blocks/server/markdown/markdownTransformer.js'\n\n/**\n * Helpful utility for parsing out all matching top-level JSX tags in a given string.\n * This will collect them in a list, that contains the content of the JSX tag and the props string.\n *\n * While this is not used within payload, this can be used for certain payload blocks that need to\n * be serializable and deserializable to and from JSX.\n *\n * @example:\n *\n * Say you have Steps block that contains a steps array. Its JSX representation may look like this:\n *\n * <Steps>\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n * </Steps>\n *\n * In this case, the Steps block would have the following content as its children string:\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n *\n * It could then use this function to collect all the top-level JSX tags (= the steps):\n *\n * collectTopLevelJSXInLines(children.split('\\n'), 'Step')\n *\n * This will return:\n *\n * [\n * {\n * content: '<h1>Step 1</h1>',\n * propsString: 'title=\"Step1\"',\n * },\n * {\n * content: '<h1>Step 2</h1>',\n * propsString: 'title=\"Step2\"',\n * },\n * ]\n *\n * You can then map this data to construct the data for this blocks array field.\n */\nexport function collectTopLevelJSXInLines(\n lines: Array<string>,\n jsxToMatch: string,\n): {\n content: string\n propsString: string\n}[] {\n const finds: {\n content: string\n propsString: string\n }[] = []\n const regex = createTagRegexes(jsxToMatch)\n\n const linesLength = lines.length\n\n for (let i = 0; i < linesLength; i++) {\n const line = lines[i]!\n const startMatch = line.match(regex.regExpStart)\n if (!startMatch) {\n continue // Try next transformer\n }\n\n const { content, endLineIndex, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines,\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: i,\n startMatch,\n })\n\n finds.push({\n content,\n propsString,\n })\n\n i = endLineIndex\n continue\n }\n\n return finds\n}\n"],"mappings":"AAAA,SAASA,qCAAqC,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,OAAO,SAASC,0BACdC,KAAoB,EACpBC,UAAkB;EAKlB,MAAMC,KAAA,GAGA,EAAE;EACR,MAAMC,KAAA,GAAQL,gBAAA,CAAiBG,UAAA;EAE/B,MAAMG,WAAA,GAAcJ,KAAA,CAAMK,MAAM;EAEhC,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIF,WAAA,EAAaE,CAAA,IAAK;IACpC,MAAMC,IAAA,GAAOP,KAAK,CAACM,CAAA,CAAE;IACrB,MAAME,UAAA,GAAaD,IAAA,CAAKE,KAAK,CAACN,KAAA,CAAMO,WAAW;IAC/C,IAAI,CAACF,UAAA,EAAY;MACf,UAAS;IACX;IAEA,MAAM;MAAEG,OAAO;MAAEC,YAAY;MAAEC;IAAW,CAAE,GAAGhB,qCAAA,CAAsC;MACnFiB,aAAA,EAAe;MACfd,KAAA;MACAe,cAAA,EAAgBZ,KAAA,CAAMa,SAAS;MAC/BC,cAAA,EAAgBX,CAAA;MAChBE;IACF;IAEAN,KAAA,CAAMgB,IAAI,CAAC;MACTP,OAAA;MACAE;IACF;IAEAP,CAAA,GAAIM,YAAA;IACJ;EACF;EAEA,OAAOV,KAAA;AACT","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.59.0-internal.929dda3",
3
+ "version": "3.59.0-internal.b804ca6",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -373,8 +373,8 @@
373
373
  "react-error-boundary": "4.1.2",
374
374
  "ts-essentials": "10.0.3",
375
375
  "uuid": "10.0.0",
376
- "@payloadcms/ui": "3.59.0-internal.929dda3",
377
- "@payloadcms/translations": "3.59.0-internal.929dda3"
376
+ "@payloadcms/translations": "3.59.0-internal.b804ca6",
377
+ "@payloadcms/ui": "3.59.0-internal.b804ca6"
378
378
  },
379
379
  "devDependencies": {
380
380
  "@babel/cli": "7.27.2",
@@ -394,15 +394,15 @@
394
394
  "esbuild-sass-plugin": "3.3.1",
395
395
  "swc-plugin-transform-remove-imports": "4.0.4",
396
396
  "@payloadcms/eslint-config": "3.28.0",
397
- "payload": "3.59.0-internal.929dda3"
397
+ "payload": "3.59.0-internal.b804ca6"
398
398
  },
399
399
  "peerDependencies": {
400
400
  "@faceless-ui/modal": "3.0.0",
401
401
  "@faceless-ui/scroll-info": "2.0.0",
402
402
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
403
403
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
404
- "payload": "3.59.0-internal.929dda3",
405
- "@payloadcms/next": "3.59.0-internal.929dda3"
404
+ "@payloadcms/next": "3.59.0-internal.b804ca6",
405
+ "payload": "3.59.0-internal.b804ca6"
406
406
  },
407
407
  "engines": {
408
408
  "node": "^18.20.2 || >=20.9.0"
@@ -1,2 +0,0 @@
1
- "use client";import{b as ke,c as we,f as _,h as ve,i as Te,j as De,k as Le,l as Me}from"./chunk-2Y72RT72.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as xn,FieldError as En,FieldLabel as Cn,RenderCustomComponent as Et,useEditDepth as bn,useEffectEvent as Nn,useField as Pn}from"@payloadcms/ui";import{mergeFieldStyles as Sn}from"@payloadcms/ui/shared";import{dequal as Rn}from"dequal/lite";import Ct,{useCallback as bt,useEffect as Nt,useMemo as kn,useState as Pt}from"react";import{ErrorBoundary as wn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as gn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as hn}from"@payloadcms/ui";import*as ht from"react";import{useMemo as yn}from"react";import{c as Zo}from"react/compiler-runtime";import{jsx as E,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as tn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as on}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as nn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as rn}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as sn,COMMAND_PRIORITY_LOW as pt,FOCUS_COMMAND as ln}from"lexical";import*as q from"react";import{useEffect as an,useState as cn}from"react";import{jsx as Ae}from"react/jsx-runtime";import"react";var $=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ae(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ae(o.Component,{clientProps:e});import{c as kt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as vt}from"@lexical/utils";import{$createNodeSelection as Tt,$getEditor as X,$getNearestNodeFromDOMNode as Dt,$getSelection as re,$isDecoratorNode as K,$isElementNode as xe,$isLineBreakNode as Lt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as Mt,$isTextNode as At,$setSelection as Ie,CLICK_COMMAND as Bt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as It,KEY_ARROW_UP_COMMAND as _t,KEY_BACKSPACE_COMMAND as Ot,KEY_DELETE_COMMAND as Ft,SELECTION_CHANGE_COMMAND as $t}from"lexical";import{useEffect as Kt}from"react";function _e(){let t=kt(3),[e]=wt(),o=Gt,n,r;return t[0]!==e?(n=()=>vt(e.registerCommand(Bt,Vt,W),e.registerCommand(Ft,o,W),e.registerCommand(Ot,o,W),e.registerCommand($t,Yt,W),e.registerCommand(_t,zt,W),e.registerCommand(It,Ht,W)),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),Kt(n,r),null}function Ht(t){let e=re();if(ie(e)){t.preventDefault();let s=e.getNodes()[0]?.getNextSibling();if(K(s)){let y=X().getElementByKey(s.getKey());return y&&Z({element:y,node:s}),!0}if(!xe(s))return!0;let l=s.getFirstDescendant()??s;return l&&(ne(l,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let n=(e.isBackward()?e.anchor:e.focus).getNode(),r=ne(n,jt),c=r?.getNextSibling();if(!r||c!==Oe(r))return!1;if(K(c)){let s=X().getElementByKey(c.getKey());if(s)return Z({element:s,node:c}),t.preventDefault(),!0}return!1}function jt(t){return Oe(t)!==null}function zt(t){let e=re();if(ie(e)){let s=e.getNodes()[0]?.getPreviousSibling();if(K(s)){let y=X().getElementByKey(s.getKey());return y?(Z({element:y,node:s}),t.preventDefault(),!0):!1}if(!xe(s))return!1;let l=s.getLastDescendant()??s;return l?(ne(l,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let n=(e.isBackward()?e.anchor:e.focus).getNode(),r=ne(n,Wt),c=r?.getPreviousSibling();if(!r||c!==Fe(r))return!1;if(K(c)){let s=X().getElementByKey(c.getKey());if(s)return Z({element:s,node:c}),t.preventDefault(),!0}return!1}function Wt(t){return Fe(t)!==null}function Yt(){let t=Jt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function Vt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=qt(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Ie(null):Z(e),!0}function Gt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Ut),!0):!1}function Ut(t){t.remove()}function qt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=Dt(e);return K(o)?{element:e,node:o}:void 0}function Jt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return K(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Tt();o.add(e.getKey()),Ie(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(K(t)&&!t.isInline())return!0;if(!xe(t)||Mt(t))return!1;let e=t.getFirstChild(),o=e===null||Lt(e)||At(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Oe(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function Fe(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ee}from"react/jsx-runtime";import{useLexicalComposerContext as oo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as no,isHTMLElement as ro}from"lexical";import*as je from"react";import{useCallback as io,useEffect as He,useRef as so,useState as lo}from"react";import{createPortal as ao}from"react-dom";var Y=(t,e,o,n,r=50,c=25)=>{let s=0;if(t&&!t.contains(n)){let{bottom:l,left:u,right:y,top:h}=t.getBoundingClientRect(),a=h+window.scrollY,i=l+window.scrollY;if(o<a-c||o>i+c||e<u-r||e>y+r)return-1;(e<u||e>y)&&(s=e<u?e-u:e-y)}return s};import{$getNodeByKey as ae}from"lexical";function V(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let n=o.split(",").pop();return e.y=e.y-Number(n?.replace(")","")),e}function le(t){let e=(u,y)=>u?parseFloat(window.getComputedStyle(u)[y]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),s=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),c),marginTop:s}}import{$getRoot as Qt}from"lexical";function H(t){return t.getEditorState().read(()=>Qt().getChildrenKeys())}var Xt=1,Zt=-1,$e=0,A={props:null,result:null};function eo(t,e,o=20){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:c=0,point:{x:s,y:l},startIndex:u=0,useEdgeAsDefault:y=!1}=t;if(o>0&&A.props&&A.result&&A.props.fuzzy===t.fuzzy&&A.props.horizontalOffset===t.horizontalOffset&&A.props.useEdgeAsDefault===t.useEdgeAsDefault&&eo(A.props.point,t.point,o))return A.result;let h=e.getBoundingClientRect(),a=H(n),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(y){let d=n.getElementByKey(a[0]),f=n.getElementByKey(a[a.length-1]);if(d&&f){let[p,m]=[V(d),V(f)];if(l<p.top?(i.blockElem=d,i.distance=p.top-l,i.blockNode=ae(a[0]),i.foundAtIndex=0):l>m.bottom&&(i.distance=l-m.bottom,i.blockNode=ae(a[a.length-1]),i.blockElem=f,i.foundAtIndex=a.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let g=u,x=$e;for(;g>=0&&g<a.length;){let d=a[g],f=n.getElementByKey(d);if(f===null)break;let p=new _(s+c,l),m=Le.fromDOMRect(V(f)),{marginBottom:C,marginTop:w}=le(f),S=m.generateNewRect({bottom:m.bottom+C,left:h.left,right:h.right,top:m.top-w}),{distance:b,isOnBottomSide:k,isOnTopSide:N}=S.distanceFromPoint(p);if(b===0){i.blockElem=f,i.blockNode=ae(d),i.foundAtIndex=g,i.distance=b,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else r&&b<i.distance&&(i.blockElem=f,i.blockNode=ae(d),i.distance=b,i.foundAtIndex=g);x===$e&&(N?x=Zt:k?x=Xt:x=1/0),g+=x}}),A.props=t,A.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var to=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ke(t){if(!t||to.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function ue(t,e,o,n=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),c=window.getComputedStyle(t),s=e.getBoundingClientRect(),l=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))u=r.top+8-l.top;else{let a=Ke(t)?parseInt(c.lineHeight,10):0;u=r.top+(a-s.height)/2-l.top}let h=n;e.style.opacity="1",e.style.transform=`translate(${h}px, ${u}px)`}var co="add-block-menu",de=1/0;function uo(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function mo(t,e,o){let n=e.parentElement,{editorConfig:r}=R(),c=r?.admin?.hideGutter?-24:12,s=so(null),[l,u]=lo(null);He(()=>{function h(a){let i=a.target;if(!ro(i))return;let g=Y(n,a.pageX,a.pageY,i);if(g===-1){u(null);return}if(ce(i,co))return;let x=H(t),{blockElem:d,blockNode:f,foundAtIndex:p}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-g,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:uo(x.length),useEdgeAsDefault:!1});de=p,d&&f&&(l?.node!==f||l?.elem!==d)&&u({elem:d,node:f})}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[n,e,t,l]),He(()=>{s.current&&l?.node&&ue(l?.elem,s.current,e,c)},[e,l,c]);let y=io(h=>{let a=l;a?.node&&(t.update(()=>{let i=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(i=!1),!i){let g=no();a?.node.insertAfter(g),setTimeout(()=>{a={elem:t.getElementByKey(g.getKey()),node:g},u(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(Te,{node:a?.node})},2),h.stopPropagation(),h.preventDefault())},[t,l]);return ao(Ee(je.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:h=>{y(h)},ref:s,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=oo();return mo(n,o,n._editable)}import{jsx as me,jsxs as po}from"react/jsx-runtime";import{useLexicalComposerContext as go}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ve}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ge,$getNodeByKey as ho,isHTMLElement as Ce}from"lexical";import*as Xe from"react";import{useEffect as be,useRef as fe,useState as Ue}from"react";import{createPortal as yo}from"react-dom";var We=0,fo=-24;var j=0;function Ye(t,e,o,n,r,c,s,l,u,y=!1){let{height:h,top:a}=n.getBoundingClientRect(),{top:i,width:g}=s.getBoundingClientRect(),{marginBottom:x,marginTop:d}=le(n),f=a,p=c>=a+h/2+window.scrollY,m=!1;if(r?.elem)if(n!==r?.elem)(p&&r?.elem&&r?.elem===n.nextElementSibling||!p&&r?.elem&&r?.elem===n.previousElementSibling)&&(j++,j<200&&(m=!0));else{j++;let b=r?.boundingBox?.y,k=n.getBoundingClientRect().y;(p===r?.isBelow&&b===k||j<200)&&(m=!1)}if(m)return{isBelow:p,willStayInSamePosition:m};y?f+=h/2:p?f+=h+x/2:f-=d/2;let C=0;y||(p?C=-We:C=We);let w=f-i+C,S=fo-e;return o.style.width=`calc(${g}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${w}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?p?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),j=0,{isBelow:p,willStayInSamePosition:m}}var xo="draggable-block-menu",qe="application/x-lexical-drag-block",ee=1/0;function Je(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function Eo(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Qe(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Co(t,e,o){let n=e.parentElement,r=fe(null),c=fe(null),s=fe(null),l=fe(!1),[u,y]=Ue(null),[h,a]=Ue(null),{editorConfig:i}=R(),g=i?.admin?.hideGutter?-44:-8;be(()=>{function f(p){let m=p.target;if(!Ce(m))return;let C=Y(n,p.pageX,p.pageY,m);if(C===-1){y(null);return}if(ce(m,xo))return;let w=H(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-C,point:new _(p.x,p.y),startIndex:Je(w.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!k)&&u!==S&&y(S)}return document?.addEventListener("mousemove",f),()=>{document?.removeEventListener("mousemove",f)}},[n,e,t,u]),be(()=>{r.current&&ue(u,r.current,e,g)},[e,u,g]),be(()=>{function f(m){if(!l.current)return!1;let[C]=Ve(m);if(C)return!1;let{pageY:w,target:S}=m;if(!Ce(S))return!1;let b=Y(n,m.pageX,m.pageY,S,100,50),k=H(t),{blockElem:N,foundAtIndex:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new _(m.x,m.y),startIndex:Je(k.length),useEdgeAsDefault:!0,verbose:!0});ee=L;let v=c.current;if(N===null||v===null)return!1;if(u!==N){let{isBelow:T,willStayInSamePosition:J}=Ye(i?.admin?.hideGutter?"0px":"3rem",g+(i?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),v,N,h,w,e,m,s,I);m.preventDefault(),J||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:T})}else h?.elem&&(Qe(v,h.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function p(m){if(!l.current)return!1;let[C]=Ve(m);if(C)return!1;let{dataTransfer:w,pageY:S,target:b}=m,k=w?.getData(qe)||"";return t.update(()=>{let N=ho(k);if(!N||!Ce(b))return!1;let L=Y(n,m.pageX,m.pageY,b,100,50),{blockElem:I,isFoundNodeEmptyParagraph:v}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-L,point:new _(m.x,m.y),useEdgeAsDefault:!0});if(!I)return!1;let T=Ge(I);if(!T)return!1;if(T===N)return!0;let{height:J,top:he}=V(I),z=S>=he+J/2+window.scrollY;v?(T.insertBefore(N),T.remove()):z?T.insertAfter(N):T.insertBefore(N),u!==null&&y(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let D=oe?.getBoundingClientRect();if(!D)return;let P=document.createElement("div");P.className="lexical-block-highlighter",P.style.backgroundColor="var(--theme-elevation-1000",P.style.transition="opacity 0.5s ease-in-out",P.style.zIndex="1",P.style.pointerEvents="none",P.style.boxSizing="border-box",P.style.borderRadius="4px",P.style.position="absolute",document.body.appendChild(P),P.style.opacity="0.1",P.style.height=`${D.height+8}px`,P.style.width=`${D.width+8}px`,P.style.top=`${D.top+window.scrollY-4}px`,P.style.left=`${D.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",f),document.addEventListener("drop",p),()=>{document.removeEventListener("dragover",f),document.removeEventListener("drop",p)}},[n,g,e,t,h,u,i?.admin?.hideGutter]);function x(f){let p=f.dataTransfer;if(!p||!u)return;Eo(p,u);let m="";t.update(()=>{let C=Ge(u);C&&(m=C.getKey())}),l.current=!0,p.setData(qe,m)}function d(){l.current=!1,h?.elem&&Qe(c.current,h?.elem)}return yo(po(Xe.Fragment,{children:[me("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:d,onDragStart:x,ref:r,type:"button",children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:s})]}),e)}function Ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=go();return Co(n,o,n._editable)}import{c as bo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as No}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Po,$getRoot as So}from"lexical";import"react";var et="insert-paragraph-at-end",tt=()=>{let t=bo(2),[e]=No(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let n;return t[0]!==e?(n=Ne("div",{"aria-label":"Insert Paragraph",className:et,onClick:()=>{e.update(Ro)},role:"button",tabIndex:0,children:Ne("div",{className:`${et}-inside`,children:Ne("span",{children:"+"})})}),t[0]=e,t[1]=n):n=t[1],n};function Ro(){let t=Po();So().append(t),t.select()}import{c as ko}from"react/compiler-runtime";import{useLexicalComposerContext as wo}from"@lexical/react/LexicalComposerContext";import*as ot from"react";var nt=()=>{let t=ko(4),{editorConfig:e}=R(),[o]=wo(),n,r;return t[0]!==o||t[1]!==e.features.markdownTransformers?(n=()=>we(o,e.features.markdownTransformers??[]),r=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=n,t[3]=r):(n=t[2],r=t[3]),ot.useEffect(n,r),null};import{useLexicalComposerContext as vo}from"@lexical/react/LexicalComposerContext";import{$getSelection as To,$isRangeSelection as Do,RootNode as Lo}from"lexical";import{useEffect as Mo}from"react";function rt(){let[t]=vo();return Mo(()=>t.registerNodeTransform(Lo,e=>{let o=To();if(Do(o)){let n=o.anchor.getNode(),r=o.focus.getNode();(!n.isAttached()||!r.isAttached())&&(e.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[t]),null}import{useLexicalComposerContext as Ao}from"@lexical/react/LexicalComposerContext";import{$getSelection as Bo,COMMAND_PRIORITY_LOW as Io,SELECT_ALL_COMMAND as _o}from"lexical";import{useEffect as Oo}from"react";function it(){let[t]=Ao();return Oo(()=>t.registerCommand(_o,()=>{if(Bo())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Io),[t]),null}import{jsx as U,jsxs as lt}from"react/jsx-runtime";import{useLexicalComposerContext as $o}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as at}from"@payloadcms/ui";import{useCallback as Ko,useMemo as Ho,useState as jo}from"react";import"react";import*as ct from"react-dom";import{c as Fo}from"react/compiler-runtime";import"react";function st(t,e){let o=Fo(4),{maxLength:n,minLength:r}=e,c=n===void 0?75:n,s=r===void 0?1:r,l;return o[0]!==c||o[1]!==s||o[2]!==t?(l=u=>{let{query:y}=u,h="[^"+t+ve+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+h+"){0,"+c+"}))$").exec(y);if(i!==null){let g=i[1],x=i[3];if(x.length>=s)return{leadOffset:i.index+g.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=c,o[1]=s,o[2]=t,o[3]=l):l=o[3],l}var B="slash-menu-popup";function zo({isSelected:t,item:e,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:s}}=R(),{i18n:l}=at(),u=`${B}__item ${B}__item-${e.key}`;t&&(u+=` ${B}__item--selected`);let y=e.key;return e.label&&(y=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:l,schemaPath:s}):e.label),y.length>25&&(y=y.substring(0,25)+"..."),lt("button",{"aria-selected":t,className:u,id:B+"__item-"+e.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${B}__item-text`,children:y})]},e.key)}function ut({anchorElem:t=document.body}){let[e]=$o(),[o,n]=jo(null),{editorConfig:r}=R(),{i18n:c}=at(),{fieldProps:{featureClientSchemaMap:s,schemaPath:l}}=R(),u=st("/",{minLength:0}),y=Ko(()=>{let a=[];for(let i of r.features.slashMenu.dynamicGroups)if(o){let g=i({editor:e,queryString:o});a=a.concat(g)}return a},[e,o,r?.features]),h=Ho(()=>{let a=[];for(let i of r?.features.slashMenu.groups??[])a.push(i);if(o){a=a.map(g=>{let x=g.items.filter(d=>{let f=d.key;return d.label&&(f=typeof d.label=="function"?d.label({featureClientSchemaMap:s,i18n:c,schemaPath:l}):d.label),new RegExp(o,"gi").exec(f)?!0:d.keywords!=null?d.keywords.some(p=>new RegExp(o,"gi").exec(p)):!1});return x.length?{...g,items:x}:null}),a=a.filter(g=>g!=null);let i=y();for(let g of i){let x=a.find(d=>d.key===g.key);x?a=a.filter(d=>d.key!==g.key):x={...g,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,r?.features.slashMenu.groups,y,s,c,l]);return U(De,{anchorElem:t,groups:h,menuRenderFn:(a,{selectedItemKey:i,selectItemAndCleanUp:g,setSelectedItemKey:x})=>a.current&&h.length?ct.createPortal(U("div",{className:B,children:h.map(d=>{let f=d.key;return d.label&&s&&(f=typeof d.label=="function"?d.label({featureClientSchemaMap:s,i18n:c,schemaPath:l}):d.label),lt("div",{className:`${B}__group ${B}__group-${d.key}`,children:[U("div",{className:`${B}__group-title`,children:f}),d.items.map((p,m)=>U(zo,{index:m,isSelected:i===p.key,item:p,onClick:()=>{x(p.key),g(p)},onMouseEnter:()=>{x(p.key)},ref:C=>{p.ref={current:C}}},p.key))]},d.key)})}),a.current):null,onQueryChange:n,triggerFn:u})}import{c as Wo}from"react/compiler-runtime";import{useLexicalComposerContext as Yo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Vo,TextNode as Go}from"lexical";import{useEffect as Uo}from"react";function dt(t){let e=Wo(6),{features:o}=t,[n]=Yo(),r;e[0]!==n||e[1]!==o.enabledFormats?(r=()=>{let s=qo(o.enabledFormats);if(s.length!==0)return n.registerNodeTransform(Go,l=>{s.forEach(u=>{l.hasFormat(u)&&l.toggleFormat(u)})})},e[0]=n,e[1]=o.enabledFormats,e[2]=r):r=e[2];let c;return e[3]!==n||e[4]!==o?(c=[n,o],e[3]=n,e[4]=o,e[5]=c):c=e[5],Uo(r,c),null}function qo(t){let e=Object.keys(Vo),o=new Set(t);return e.filter(n=>!o.has(n))}import{c as Jo}from"react/compiler-runtime";import{jsx as mt}from"react/jsx-runtime";import{ContentEditable as Qo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Xo}from"@payloadcms/ui";import"react";function ft(t){let e=Jo(4),{className:o,editorConfig:n}=t,{t:r}=Xo(),c;return e[0]!==o||e[1]!==n?.admin?.placeholder||e[2]!==r?(c=mt(Qo,{"aria-placeholder":r("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:mt("p",{className:"editor-placeholder",children:n?.admin?.placeholder??r("lexical:general:placeholder")})}),e[0]=o,e[1]=n?.admin?.placeholder,e[2]=r,e[3]=c):c=e[3],c}var gt=t=>{let e=Zo(14),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:c}=t,s=R(),[l]=en(),[u,y]=cn(null),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=d=>{d!==null&&y(d)},e[0]=h):h=e[0];let a=h,i,g;e[1]!==l||e[2]!==s?(i=()=>{if(!s?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}s?.parentEditor?.uuid&&s.parentEditor?.registerChild(s.uuid,s);let d=()=>{s.focusEditor(s)},f=()=>{s.blurEditor(s)},p=l.registerCommand(ln,()=>(d(),!0),pt),m=l.registerCommand(sn,()=>(f(),!0),pt);return()=>{p(),m(),s.parentEditor?.unregisterChild?.(s.uuid)}},g=[l,s],e[1]=l,e[2]=s,e[3]=i,e[4]=g):(i=e[3],g=e[4]),an(i,g);let x;if(e[5]!==l||e[6]!==o||e[7]!==n||e[8]!==u||e[9]!==r||e[10]!==c){let d;e[12]!==c?(d=(f,p,m)=>{(!m.has("focus")||m.size>1)&&c?.(f,p,m)},e[12]=c,e[13]=d):d=e[13],x=te(q.Fragment,{children:[o.features.plugins?.map(un),te("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(dn),E(rn,{contentEditable:E("div",{className:"editor-scroller",children:E("div",{className:"editor",ref:a,children:E(ft,{editorConfig:o})})}),ErrorBoundary:tn}),E(rt,{}),E(tt,{}),E(_e,{}),E(dt,{features:o.features}),E(it,{}),E(nn,{ignoreSelectionChange:!0,onChange:d}),u&&te(q.Fragment,{children:[!r&&l.isEditable()&&te(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:E(Ze,{anchorElem:u}),o.admin?.hideAddBlockButton?null:E(ze,{anchorElem:u})]}),o.features.plugins?.map(f=>{if(f.position==="floatingAnchorElem"&&!(f.desktopOnly===!0&&r))return E($,{anchorElem:u,clientProps:f.clientProps,plugin:f},f.key)}),l.isEditable()&&E(q.Fragment,{children:E(ut,{anchorElem:u})})]}),l.isEditable()&&te(q.Fragment,{children:[E(on,{}),o?.features?.markdownTransformers?.length>0&&E(nt,{})]}),o.features.plugins?.map(mn),o.features.plugins?.map(fn)]}),o.features.plugins?.map(pn)]}),e[5]=l,e[6]=o,e[7]=n,e[8]=u,e[9]=r,e[10]=c,e[11]=x}else x=e[11];return x};function un(t){if(t.position==="aboveContainer")return E($,{clientProps:t.clientProps,plugin:t},t.key)}function dn(t){if(t.position==="top")return E($,{clientProps:t.clientProps,plugin:t},t.key)}function mn(t){if(t.position==="normal")return E($,{clientProps:t.clientProps,plugin:t},t.key)}function fn(t){if(t.position==="bottom")return E($,{clientProps:t.clientProps,plugin:t},t.key)}function pn(t){if(t.position==="belowContainer")return E($,{clientProps:t.clientProps,plugin:t},t.key)}var yt=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(yt,{providers:e.slice(1),children:t})}):O(o,{children:t})},xt=t=>{let{composerKey:e,editorConfig:o,fieldProps:n,isSmallWidthViewport:r,onChange:c,readOnly:s,value:l}=t,u=R(),y=hn(),h=ht.useRef(null),a=yn(()=>{if(l&&typeof l!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(l));if(l&&Array.isArray(l)&&!("root"in l))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:s!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:Me({editorConfig:o}),onError:i=>{throw i},theme:o.lexical.theme}},[o]);return a?O(gn,{initialConfig:a,children:O(Re,{editorConfig:o,editorContainerRef:h,fieldProps:n,parentContext:u?.editDepth===y?u:void 0,children:O(yt,{providers:o.features.providers,children:O(gt,{editorConfig:o,editorContainerRef:h,isSmallWidthViewport:r,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",vn=t=>{let{editorConfig:e,field:o,field:{admin:{className:n,description:r,readOnly:c}={},label:s,localized:l,required:u},path:y,readOnly:h,validate:a}=t,i=h||c,g=bn(),x=bt((M,Q)=>typeof a=="function"?a(M,{...Q,required:u}):!0,[a,u]),{customComponents:{AfterInput:d,BeforeInput:f,Description:p,Error:m,Label:C}={},disabled:w,initialValue:S,path:b,setValue:k,showError:N,value:L}=Pn({potentiallyStalePath:y,validate:x}),I=i||w,[v,T]=Pt(!1),[J,he]=Pt(),ye=Ct.useRef(S),z=Ct.useRef(L);Nt(()=>{let M=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==v&&T(Q)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[v]);let Pe=[pe,"field-type",n,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${g}`,D=ke(),P=bt(M=>{D(()=>{let Se=M.toJSON();z.current=Se,k(Se)})},[k,D]),St=kn(()=>Sn(o),[o]),Rt=Nn(M=>{z.current!==L&&!Rn(JSON.parse(JSON.stringify(z.current)),L)&&(ye.current=M,z.current=L,he(new Date))});return Nt(()=>{Object.is(S,ye.current)||Rt(S)},[S]),ge("div",{className:Pe,style:St,children:[F(Et,{CustomComponent:m,Fallback:F(En,{path:b,showError:N})}),C||F(Cn,{label:s,localized:l,path:b,required:u}),ge("div",{className:`${pe}__wrap`,children:[ge(wn,{fallbackRender:Tn,onReset:()=>{},children:[f,F(xt,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:I,value:L},JSON.stringify({path:b,rerenderProviderKey:J})),d]}),F(Et,{CustomComponent:p,Fallback:F(xn,{description:r,path:b})})]})]},oe)};function Tn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var ds=vn;export{ds as RichText};
2
- //# sourceMappingURL=Field-EHRBYNHO.js.map