@payloadcms/richtext-lexical 3.68.0-internal-debug.e9b66ee → 3.68.0-internal-debug.654e4ad

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 (313) hide show
  1. package/dist/cell/rscEntry.js +21 -2
  2. package/dist/cell/rscEntry.js.map +1 -1
  3. package/dist/exports/client/index.d.ts +1 -0
  4. package/dist/exports/client/index.d.ts.map +1 -1
  5. package/dist/exports/client/index.js +1 -0
  6. package/dist/exports/client/index.js.map +1 -1
  7. package/dist/exports/client/internal-client.d.ts +3 -0
  8. package/dist/exports/client/internal-client.d.ts.map +1 -0
  9. package/dist/exports/client/internal-client.js +4 -0
  10. package/dist/exports/client/internal-client.js.map +1 -0
  11. package/dist/exports/react/index.d.ts +1 -1
  12. package/dist/exports/react/index.d.ts.map +1 -1
  13. package/dist/exports/react/index.js.map +1 -1
  14. package/dist/features/blocks/client/component/BlockContent.js +48 -13
  15. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  16. package/dist/features/blocks/client/component/components/BlockCollapsible.js +10 -1
  17. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  18. package/dist/features/blocks/client/component/components/BlockEditButton.js +7 -1
  19. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
  20. package/dist/features/blocks/client/component/components/BlockRemoveButton.js +7 -1
  21. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
  22. package/dist/features/blocks/client/component/index.js +247 -81
  23. package/dist/features/blocks/client/component/index.js.map +1 -1
  24. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +9 -1
  25. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
  26. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +7 -1
  27. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
  28. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +7 -1
  29. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
  30. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +7 -1
  31. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
  32. package/dist/features/blocks/client/componentInline/index.js +217 -68
  33. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  34. package/dist/features/blocks/client/getBlockImageComponent.js +15 -4
  35. package/dist/features/blocks/client/getBlockImageComponent.js.map +1 -1
  36. package/dist/features/blocks/client/nodes/BlocksNode.js +12 -1
  37. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  38. package/dist/features/blocks/client/nodes/InlineBlocksNode.js +12 -2
  39. package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
  40. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +127 -26
  41. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  42. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +65 -49
  43. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
  44. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +16 -3
  45. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
  46. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +25 -4
  47. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
  48. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -14
  49. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  50. package/dist/features/converters/lexicalToJSX/Component/index.js +16 -10
  51. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  52. package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js +8 -1
  53. package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js.map +1 -1
  54. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +8 -1
  55. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  56. package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js +6 -1
  57. package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js.map +1 -1
  58. package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js +6 -1
  59. package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js.map +1 -1
  60. package/dist/features/converters/lexicalToJSX/converter/converters/link.js +19 -10
  61. package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
  62. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +63 -16
  63. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  64. package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js +19 -4
  65. package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js.map +1 -1
  66. package/dist/features/converters/lexicalToJSX/converter/converters/table.js +45 -12
  67. package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
  68. package/dist/features/converters/lexicalToJSX/converter/converters/text.js +57 -11
  69. package/dist/features/converters/lexicalToJSX/converter/converters/text.js.map +1 -1
  70. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +46 -7
  71. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  72. package/dist/features/converters/lexicalToJSX/converter/index.d.ts +16 -1
  73. package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
  74. package/dist/features/converters/lexicalToJSX/converter/index.js +98 -9
  75. package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
  76. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
  77. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  78. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  79. package/dist/features/debug/jsxConverter/client/plugin/index.js +17 -4
  80. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  81. package/dist/features/debug/testRecorder/client/plugin/index.js +113 -38
  82. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  83. package/dist/features/debug/treeView/client/plugin/index.js +15 -1
  84. package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
  85. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +357 -79
  86. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  87. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +41 -7
  88. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  89. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +39 -9
  90. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  91. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +59 -28
  92. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
  93. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +1 -0
  94. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  95. package/dist/features/indent/client/IndentPlugin.js +6 -1
  96. package/dist/features/indent/client/IndentPlugin.js.map +1 -1
  97. package/dist/features/link/client/plugins/clickableLink/index.js +7 -1
  98. package/dist/features/link/client/plugins/clickableLink/index.js.map +1 -1
  99. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +151 -59
  100. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  101. package/dist/features/link/client/plugins/floatingLinkEditor/index.js +9 -1
  102. package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
  103. package/dist/features/lists/checklist/client/plugin/index.js +7 -1
  104. package/dist/features/lists/checklist/client/plugin/index.js.map +1 -1
  105. package/dist/features/lists/plugin/index.js +7 -1
  106. package/dist/features/lists/plugin/index.js.map +1 -1
  107. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +18 -3
  108. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
  109. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +9 -2
  110. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  111. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +18 -3
  112. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
  113. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +9 -2
  114. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  115. package/dist/features/relationship/client/components/RelationshipComponent.js +100 -31
  116. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  117. package/dist/features/relationship/client/drawer/index.js +21 -4
  118. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  119. package/dist/features/relationship/client/nodes/RelationshipNode.js +12 -2
  120. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  121. package/dist/features/relationship/client/plugins/index.js +8 -1
  122. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  123. package/dist/features/textState/feature.client.js +22 -5
  124. package/dist/features/textState/feature.client.js.map +1 -1
  125. package/dist/features/toolbars/fixed/client/Toolbar/index.js +123 -27
  126. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  127. package/dist/features/toolbars/inline/client/Toolbar/index.js +111 -18
  128. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  129. package/dist/features/toolbars/shared/ToolbarButton/index.js +14 -4
  130. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  131. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +135 -56
  132. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  133. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +70 -16
  134. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  135. package/dist/features/upload/client/component/index.js +167 -43
  136. package/dist/features/upload/client/component/index.js.map +1 -1
  137. package/dist/features/upload/client/component/pending/index.js +16 -3
  138. package/dist/features/upload/client/component/pending/index.js.map +1 -1
  139. package/dist/features/upload/client/drawer/index.js +21 -4
  140. package/dist/features/upload/client/drawer/index.js.map +1 -1
  141. package/dist/features/upload/client/nodes/UploadNode.js +17 -3
  142. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  143. package/dist/features/upload/client/plugin/index.js +9 -2
  144. package/dist/features/upload/client/plugin/index.js.map +1 -1
  145. package/dist/field/Diff/converters/listitem/index.js +54 -11
  146. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  147. package/dist/field/Diff/converters/relationship/index.js +60 -18
  148. package/dist/field/Diff/converters/relationship/index.js.map +1 -1
  149. package/dist/field/Diff/converters/unknown/index.js +42 -7
  150. package/dist/field/Diff/converters/unknown/index.js.map +1 -1
  151. package/dist/field/Diff/converters/upload/index.js +91 -21
  152. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  153. package/dist/field/Diff/index.js +17 -4
  154. package/dist/field/Diff/index.js.map +1 -1
  155. package/dist/field/Field.d.ts.map +1 -1
  156. package/dist/field/Field.js +141 -26
  157. package/dist/field/Field.js.map +1 -1
  158. package/dist/field/RenderLexical/index.js +47 -15
  159. package/dist/field/RenderLexical/index.js.map +1 -1
  160. package/dist/field/RichTextViewProvider.d.ts +83 -0
  161. package/dist/field/RichTextViewProvider.d.ts.map +1 -0
  162. package/dist/field/RichTextViewProvider.js +102 -0
  163. package/dist/field/RichTextViewProvider.js.map +1 -0
  164. package/dist/field/ViewSelector.d.ts +4 -0
  165. package/dist/field/ViewSelector.d.ts.map +1 -0
  166. package/dist/field/ViewSelector.js +90 -0
  167. package/dist/field/ViewSelector.js.map +1 -0
  168. package/dist/field/ViewSelector.scss +34 -0
  169. package/dist/field/index.d.ts +1 -0
  170. package/dist/field/index.d.ts.map +1 -1
  171. package/dist/field/index.js +56 -12
  172. package/dist/field/index.js.map +1 -1
  173. package/dist/field/index.scss +12 -0
  174. package/dist/field/rscEntry.d.ts +1 -1
  175. package/dist/field/rscEntry.d.ts.map +1 -1
  176. package/dist/field/rscEntry.js +21 -1
  177. package/dist/field/rscEntry.js.map +1 -1
  178. package/dist/index.d.ts +1 -1
  179. package/dist/index.d.ts.map +1 -1
  180. package/dist/index.js +3 -1
  181. package/dist/index.js.map +1 -1
  182. package/dist/lexical/EditorPlugin.js +17 -2
  183. package/dist/lexical/EditorPlugin.js.map +1 -1
  184. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  185. package/dist/lexical/LexicalEditor.js +238 -69
  186. package/dist/lexical/LexicalEditor.js.map +1 -1
  187. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  188. package/dist/lexical/LexicalProvider.js +74 -15
  189. package/dist/lexical/LexicalProvider.js.map +1 -1
  190. package/dist/lexical/config/client/EditorConfigProvider.js +11 -2
  191. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  192. package/dist/lexical/config/client/sanitize.d.ts +1 -1
  193. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  194. package/dist/lexical/config/client/sanitize.js +3 -2
  195. package/dist/lexical/config/client/sanitize.js.map +1 -1
  196. package/dist/lexical/config/types.d.ts +4 -0
  197. package/dist/lexical/config/types.d.ts.map +1 -1
  198. package/dist/lexical/config/types.js +3 -1
  199. package/dist/lexical/config/types.js.map +1 -1
  200. package/dist/lexical/nodes/index.d.ts +12 -2
  201. package/dist/lexical/nodes/index.d.ts.map +1 -1
  202. package/dist/lexical/nodes/index.js +187 -2
  203. package/dist/lexical/nodes/index.js.map +1 -1
  204. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +28 -5
  205. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  206. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
  207. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
  208. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +31 -0
  209. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
  210. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +14 -1
  211. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  212. package/dist/lexical/plugins/SlashMenu/index.js +98 -31
  213. package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
  214. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +27 -7
  215. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  216. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +45 -7
  217. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  218. package/dist/lexical/ui/ContentEditable.js +18 -3
  219. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  220. package/dist/lexical/ui/icons/AI/index.js +58 -10
  221. package/dist/lexical/ui/icons/AI/index.js.map +1 -1
  222. package/dist/lexical/ui/icons/Add/index.js +31 -4
  223. package/dist/lexical/ui/icons/Add/index.js.map +1 -1
  224. package/dist/lexical/ui/icons/AlignCenter/index.js +45 -5
  225. package/dist/lexical/ui/icons/AlignCenter/index.js.map +1 -1
  226. package/dist/lexical/ui/icons/AlignJustify/index.js +45 -5
  227. package/dist/lexical/ui/icons/AlignJustify/index.js.map +1 -1
  228. package/dist/lexical/ui/icons/AlignLeft/index.js +45 -5
  229. package/dist/lexical/ui/icons/AlignLeft/index.js.map +1 -1
  230. package/dist/lexical/ui/icons/AlignRight/index.js +45 -5
  231. package/dist/lexical/ui/icons/AlignRight/index.js.map +1 -1
  232. package/dist/lexical/ui/icons/Block/index.js +54 -5
  233. package/dist/lexical/ui/icons/Block/index.js.map +1 -1
  234. package/dist/lexical/ui/icons/Blockquote/index.js +24 -3
  235. package/dist/lexical/ui/icons/Blockquote/index.js.map +1 -1
  236. package/dist/lexical/ui/icons/Bold/index.js +24 -3
  237. package/dist/lexical/ui/icons/Bold/index.js.map +1 -1
  238. package/dist/lexical/ui/icons/Checklist/index.js +39 -4
  239. package/dist/lexical/ui/icons/Checklist/index.js.map +1 -1
  240. package/dist/lexical/ui/icons/Code/index.js +34 -4
  241. package/dist/lexical/ui/icons/Code/index.js.map +1 -1
  242. package/dist/lexical/ui/icons/CodeBlock/index.js +22 -3
  243. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  244. package/dist/lexical/ui/icons/Collapse/index.js +23 -3
  245. package/dist/lexical/ui/icons/Collapse/index.js.map +1 -1
  246. package/dist/lexical/ui/icons/H1/index.js +24 -3
  247. package/dist/lexical/ui/icons/H1/index.js.map +1 -1
  248. package/dist/lexical/ui/icons/H2/index.js +24 -3
  249. package/dist/lexical/ui/icons/H2/index.js.map +1 -1
  250. package/dist/lexical/ui/icons/H3/index.js +24 -3
  251. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  252. package/dist/lexical/ui/icons/H4/index.js +24 -3
  253. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  254. package/dist/lexical/ui/icons/H5/index.js +24 -3
  255. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  256. package/dist/lexical/ui/icons/H6/index.js +24 -3
  257. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  258. package/dist/lexical/ui/icons/HorizontalRule/index.js +27 -3
  259. package/dist/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
  260. package/dist/lexical/ui/icons/IndentDecrease/index.js +53 -6
  261. package/dist/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
  262. package/dist/lexical/ui/icons/IndentIncrease/index.js +53 -6
  263. package/dist/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
  264. package/dist/lexical/ui/icons/InlineBlocks/index.js +26 -3
  265. package/dist/lexical/ui/icons/InlineBlocks/index.js.map +1 -1
  266. package/dist/lexical/ui/icons/Italic/index.js +24 -3
  267. package/dist/lexical/ui/icons/Italic/index.js.map +1 -1
  268. package/dist/lexical/ui/icons/Link/index.js +25 -3
  269. package/dist/lexical/ui/icons/Link/index.js.map +1 -1
  270. package/dist/lexical/ui/icons/Meatballs/index.js +39 -5
  271. package/dist/lexical/ui/icons/Meatballs/index.js.map +1 -1
  272. package/dist/lexical/ui/icons/OrderedList/index.js +61 -7
  273. package/dist/lexical/ui/icons/OrderedList/index.js.map +1 -1
  274. package/dist/lexical/ui/icons/Relationship/index.js +58 -10
  275. package/dist/lexical/ui/icons/Relationship/index.js.map +1 -1
  276. package/dist/lexical/ui/icons/Strikethrough/index.js +34 -4
  277. package/dist/lexical/ui/icons/Strikethrough/index.js.map +1 -1
  278. package/dist/lexical/ui/icons/Subscript/index.js +24 -3
  279. package/dist/lexical/ui/icons/Subscript/index.js.map +1 -1
  280. package/dist/lexical/ui/icons/Superscript/index.js +24 -3
  281. package/dist/lexical/ui/icons/Superscript/index.js.map +1 -1
  282. package/dist/lexical/ui/icons/Table/index.js +24 -3
  283. package/dist/lexical/ui/icons/Table/index.js.map +1 -1
  284. package/dist/lexical/ui/icons/Text/index.js +24 -3
  285. package/dist/lexical/ui/icons/Text/index.js.map +1 -1
  286. package/dist/lexical/ui/icons/TextState/index.js +18 -12
  287. package/dist/lexical/ui/icons/TextState/index.js.map +1 -1
  288. package/dist/lexical/ui/icons/Underline/index.js +34 -4
  289. package/dist/lexical/ui/icons/Underline/index.js.map +1 -1
  290. package/dist/lexical/ui/icons/UnorderedList/index.js +81 -8
  291. package/dist/lexical/ui/icons/UnorderedList/index.js.map +1 -1
  292. package/dist/lexical/ui/icons/Upload/index.js +48 -5
  293. package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
  294. package/dist/types.d.ts +152 -2
  295. package/dist/types.d.ts.map +1 -1
  296. package/dist/types.js +55 -0
  297. package/dist/types.js.map +1 -1
  298. package/dist/utilities/fieldsDrawer/Drawer.js +41 -16
  299. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  300. package/dist/utilities/fieldsDrawer/DrawerContent.js +42 -10
  301. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  302. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js +9 -1
  303. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
  304. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js +11 -3
  305. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
  306. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  307. package/dist/utilities/generateImportMap.js +1 -0
  308. package/dist/utilities/generateImportMap.js.map +1 -1
  309. package/dist/validate/hasText.d.ts +6 -1
  310. package/dist/validate/hasText.d.ts.map +1 -1
  311. package/dist/validate/hasText.js +10 -4
  312. package/dist/validate/hasText.js.map +1 -1
  313. package/package.json +12 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/field/RenderLexical/index.tsx"],"sourcesContent":["'use client'\nimport type { RichTextField } from 'payload'\n\nimport {\n FieldContext,\n FieldPathContext,\n type FieldType,\n type RenderFieldServerFnArgs,\n ServerFunctionsContext,\n type ServerFunctionsContextType,\n ShimmerEffect,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useRef } from 'react'\n\nimport type { DefaultTypedEditorState } from '../../nodeTypes.js'\nimport type { LexicalRichTextField } from '../../types.js'\n\n/**\n * Utility to render a lexical editor on the client.\n *\n * @experimental - may break in minor releases\n * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx\n */\nexport const RenderLexical: React.FC<\n /**\n * If value or setValue, or both, is provided, this component will manage its own value.\n * If neither is passed, it will rely on the parent form to manage the value.\n */\n {\n /**\n * Override the loading state while the field component is being fetched and rendered.\n */\n Loading?: React.ReactElement\n\n setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue']\n value?: FieldType<DefaultTypedEditorState | undefined>['value']\n } & RenderFieldServerFnArgs<LexicalRichTextField>\n> = (args) => {\n const { field, initialValue, Loading, path, schemaPath, setValue, value } = args\n const [Component, setComponent] = React.useState<null | React.ReactNode>(null)\n const serverFunctionContext = useServerFunctions()\n const { _internal_renderField } = serverFunctionContext\n\n const [entityType, entitySlug] = schemaPath.split('.', 2)\n\n const fieldPath = path ?? (field && 'name' in field ? field?.name : '') ?? ''\n\n const renderLexical = useCallback(() => {\n async function render() {\n const { Field } = await _internal_renderField({\n field: {\n ...((field as RichTextField) || {}),\n type: 'richText',\n admin: {\n ...((field as RichTextField)?.admin || {}),\n // When using \"fake\" anchor fields, hidden is often set to true. We need to override that here to ensure the field is rendered.\n hidden: false,\n },\n },\n initialValue: initialValue ?? undefined,\n path,\n schemaPath,\n })\n\n setComponent(Field)\n }\n void render()\n }, [_internal_renderField, schemaPath, path, field, initialValue])\n\n const mounted = useRef(false)\n\n useEffect(() => {\n if (mounted.current) {\n return\n }\n mounted.current = true\n void renderLexical()\n }, [renderLexical])\n\n if (!Component) {\n return typeof Loading !== 'undefined' ? Loading : <ShimmerEffect />\n }\n\n /**\n * By default, the lexical will make form state requests (e.g. to get drawer fields), passing in the arguments\n * of the current field. However, we need to override those arguments to get it to make requests based on the\n * *target* field. The server only knows the schema map of the target field.\n */\n const adjustedServerFunctionContext: ServerFunctionsContextType = {\n ...serverFunctionContext,\n getFormState: async (getFormStateArgs) => {\n return serverFunctionContext.getFormState({\n ...getFormStateArgs,\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n })\n },\n }\n\n if (typeof value === 'undefined' && !setValue) {\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n {Component}\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n }\n\n const fieldValue: FieldType<DefaultTypedEditorState | undefined> = {\n disabled: false,\n formInitializing: false,\n formProcessing: false,\n formSubmitted: false,\n initialValue: value,\n path: fieldPath,\n setValue: setValue ?? (() => undefined),\n showError: false,\n value,\n }\n\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n <FieldContext value={fieldValue}>{Component}</FieldContext>\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n}\n"],"names":["FieldContext","FieldPathContext","ServerFunctionsContext","ShimmerEffect","useServerFunctions","React","useCallback","useEffect","useRef","RenderLexical","args","field","initialValue","Loading","path","schemaPath","setValue","value","Component","setComponent","useState","serverFunctionContext","_internal_renderField","entityType","entitySlug","split","fieldPath","name","renderLexical","render","Field","type","admin","hidden","undefined","mounted","current","adjustedServerFunctionContext","getFormState","getFormStateArgs","collectionSlug","globalSlug","key","fieldValue","disabled","formInitializing","formProcessing","formSubmitted","showError"],"mappings":"AAAA;AAGA,SACEA,YAAY,EACZC,gBAAgB,EAGhBC,sBAAsB,EAEtBC,aAAa,EACbC,kBAAkB,QACb,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,QAAO;AAK7D;;;;;CAKC,GACD,OAAO,MAAMC,gBACX;;;GAGC,GAEC;;KAEC,GAMD,CAACC;IACH,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAEC,OAAO,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGP;IAC5E,MAAM,CAACQ,WAAWC,aAAa,GAAGd,MAAMe,QAAQ,CAAyB;IACzE,MAAMC,wBAAwBjB;IAC9B,MAAM,EAAEkB,qBAAqB,EAAE,GAAGD;IAElC,MAAM,CAACE,YAAYC,WAAW,GAAGT,WAAWU,KAAK,CAAC,KAAK;IAEvD,MAAMC,YAAYZ,QAASH,CAAAA,SAAS,UAAUA,QAAQA,OAAOgB,OAAO,EAAC,KAAM;IAE3E,MAAMC,gBAAgBtB,YAAY;QAChC,eAAeuB;YACb,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMR,sBAAsB;gBAC5CX,OAAO;oBACL,GAAI,AAACA,SAA2B,CAAC,CAAC;oBAClCoB,MAAM;oBACNC,OAAO;wBACL,GAAI,AAACrB,OA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AiB;IACrB,EAAEC;AAEN,EAAC"}
1
+ {"version":3,"sources":["../../../src/field/RenderLexical/index.tsx"],"sourcesContent":["'use client'\nimport type { RichTextField } from 'payload'\n\nimport {\n FieldContext,\n FieldPathContext,\n type FieldType,\n type RenderFieldServerFnArgs,\n ServerFunctionsContext,\n type ServerFunctionsContextType,\n ShimmerEffect,\n useServerFunctions,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useRef } from 'react'\n\nimport type { DefaultTypedEditorState } from '../../nodeTypes.js'\nimport type { LexicalRichTextField } from '../../types.js'\n\n/**\n * Utility to render a lexical editor on the client.\n *\n * @experimental - may break in minor releases\n * @todo - replace this with a general utility that works for all fields. Maybe merge with packages/ui/src/forms/RenderFields/RenderField.tsx\n */\nexport const RenderLexical: React.FC<\n /**\n * If value or setValue, or both, is provided, this component will manage its own value.\n * If neither is passed, it will rely on the parent form to manage the value.\n */\n {\n /**\n * Override the loading state while the field component is being fetched and rendered.\n */\n Loading?: React.ReactElement\n\n setValue?: FieldType<DefaultTypedEditorState | undefined>['setValue']\n value?: FieldType<DefaultTypedEditorState | undefined>['value']\n } & RenderFieldServerFnArgs<LexicalRichTextField>\n> = (args) => {\n const { field, initialValue, Loading, path, schemaPath, setValue, value } = args\n const [Component, setComponent] = React.useState<null | React.ReactNode>(null)\n const serverFunctionContext = useServerFunctions()\n const { _internal_renderField } = serverFunctionContext\n\n const [entityType, entitySlug] = schemaPath.split('.', 2)\n\n const fieldPath = path ?? (field && 'name' in field ? field?.name : '') ?? ''\n\n const renderLexical = useCallback(() => {\n async function render() {\n const { Field } = await _internal_renderField({\n field: {\n ...((field as RichTextField) || {}),\n type: 'richText',\n admin: {\n ...((field as RichTextField)?.admin || {}),\n // When using \"fake\" anchor fields, hidden is often set to true. We need to override that here to ensure the field is rendered.\n hidden: false,\n },\n },\n initialValue: initialValue ?? undefined,\n path,\n schemaPath,\n })\n\n setComponent(Field)\n }\n void render()\n }, [_internal_renderField, schemaPath, path, field, initialValue])\n\n const mounted = useRef(false)\n\n useEffect(() => {\n if (mounted.current) {\n return\n }\n mounted.current = true\n void renderLexical()\n }, [renderLexical])\n\n if (!Component) {\n return typeof Loading !== 'undefined' ? Loading : <ShimmerEffect />\n }\n\n /**\n * By default, the lexical will make form state requests (e.g. to get drawer fields), passing in the arguments\n * of the current field. However, we need to override those arguments to get it to make requests based on the\n * *target* field. The server only knows the schema map of the target field.\n */\n const adjustedServerFunctionContext: ServerFunctionsContextType = {\n ...serverFunctionContext,\n getFormState: async (getFormStateArgs) => {\n return serverFunctionContext.getFormState({\n ...getFormStateArgs,\n collectionSlug: entityType === 'collection' ? entitySlug : undefined,\n globalSlug: entityType === 'global' ? entitySlug : undefined,\n })\n },\n }\n\n if (typeof value === 'undefined' && !setValue) {\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n {Component}\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n }\n\n const fieldValue: FieldType<DefaultTypedEditorState | undefined> = {\n disabled: false,\n formInitializing: false,\n formProcessing: false,\n formSubmitted: false,\n initialValue: value,\n path: fieldPath,\n setValue: setValue ?? (() => undefined),\n showError: false,\n value,\n }\n\n return (\n <ServerFunctionsContext value={{ ...adjustedServerFunctionContext }}>\n <FieldPathContext key={fieldPath} value={fieldPath}>\n <FieldContext value={fieldValue}>{Component}</FieldContext>\n </FieldPathContext>\n </ServerFunctionsContext>\n )\n}\n"],"names":["FieldContext","FieldPathContext","ServerFunctionsContext","ShimmerEffect","useServerFunctions","React","useCallback","useEffect","useRef","RenderLexical","args","field","initialValue","Loading","path","schemaPath","setValue","value","Component","setComponent","useState","serverFunctionContext","_internal_renderField","entityType","entitySlug","split","fieldPath","name","renderLexical","render","Field","type","admin","hidden","undefined","mounted","current","adjustedServerFunctionContext","getFormState","getFormStateArgs","collectionSlug","globalSlug","fieldValue","disabled","formInitializing","formProcessing","formSubmitted","showError"],"mappings":"AAAA;;AAGA,SACEA,Y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V;;;;;IACrD;IAEA;;;;GAIC,GACD,MAAMkC,gCAA4D;QAChE,GAAGhB,qBAAqB;QACxBiB,cAAc,OAAOC;YACnB,OAAOlB,sBAAsBiB,YAAY,CAAC;gBACxC,GAAGC,gBAAgB;gBACnBC,gBAAgBjB,eAAe,eAAeC,aAAaU;gBAC3DO,YAAYlB,eAAe,WAAWC,aAAaU;YACrD;QACF;IACF;IAEA,IAAI,OAAOjB,UAAU,eAAe,CAACD,UAAU;QAC7C,qBACE,QAACd;YAAuBe,OAAO;gBAAE,GAAGoB,6BAA6B;YAAC;sBAChE,cAAA,QAACpC;gBAAiCgB,OAAOS;0BACtCR;eADoBQ;;;;;;;;;;IAK7B;IAEA,MAAMgB,aAA6D;QACjEC,UAAU;QACVC,kBAAkB;QAClBC,gBAAgB;QAChBC,eAAe;QACflC,cAAcK;QACdH,MAAMY;QACNV,UAAUA,YAAa,CAAA,IAAMkB,SAAQ;QACrCa,WAAW;QACX9B;IACF;IAEA,qBACE,QAACf;QAAuBe,OAAO;YAAE,GAAGoB,6BAA6B;QAAC;kBAChE,cAAA,QAACpC;YAAiCgB,OAAOS;sBACvC,cAAA,QAAC1B;gBAAaiB,OAAOyB;0BAAaxB;;;;;;WADbQ;;;;;;;;;;AAK7B,EAAC"}
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import type { LexicalEditorNodeMap, LexicalEditorViewMap } from '../types.js';
3
+ /**
4
+ * Context type for rich text view management.
5
+ */
6
+ type RichTextViewContextType = {
7
+ /**
8
+ * The name of the currently active view (e.g., 'default', 'frontend', 'debug')
9
+ */
10
+ currentView: string;
11
+ /**
12
+ * The node map for the currently active view, containing rendering overrides for each node type.
13
+ * This is the resolved view from the views map based on currentView.
14
+ */
15
+ currentViewMap?: LexicalEditorNodeMap;
16
+ /**
17
+ * If true, the current view will be inherited by nested richtext editors.
18
+ */
19
+ inheritable?: boolean;
20
+ /**
21
+ * Function to change the current view.
22
+ */
23
+ setCurrentView: (view: string) => void;
24
+ /**
25
+ * The complete map of all available views for this field.
26
+ */
27
+ views?: LexicalEditorViewMap;
28
+ };
29
+ /**
30
+ * Provider component for rich text view context.
31
+ *
32
+ * This provider manages the current view state internally and makes it accessible to child components
33
+ * via the useRichTextView hook. It automatically resolves the current view's node map
34
+ * based on the active view name.
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * <RichTextViewProvider
39
+ * currentView="frontend"
40
+ * views={myViews}
41
+ * >
42
+ * <MyEditor />
43
+ * </RichTextViewProvider>
44
+ * ```
45
+ */
46
+ export declare const RichTextViewProvider: React.FC<{
47
+ children: React.ReactNode;
48
+ currentView?: string;
49
+ inheritable?: boolean;
50
+ views?: LexicalEditorViewMap;
51
+ }>;
52
+ /**
53
+ * Hook to access the current rich text view context.
54
+ *
55
+ * Use this hook to access the currently active view and its node map,
56
+ * or to programmatically switch between views.
57
+ *
58
+ * @returns An object containing:
59
+ * - `currentView`: The name of the active view
60
+ * - `currentViewMap`: The node overrides for the current view
61
+ * - `setCurrentView`: Function to change views
62
+ * - `views`: All available views
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * function MyComponent() {
67
+ * const { currentView, currentViewMap, setCurrentView } = useRichTextView()
68
+ *
69
+ * return (
70
+ * <div>
71
+ * <p>Current view: {currentView}</p>
72
+ * {currentViewMap?.heading && <p>Heading overrides are active</p>}
73
+ * <button onClick={() => setCurrentView('frontend')}>
74
+ * Switch to frontend view
75
+ * </button>
76
+ * </div>
77
+ * )
78
+ * }
79
+ * ```
80
+ */
81
+ export declare function useRichTextView(): RichTextViewContextType;
82
+ export {};
83
+ //# sourceMappingURL=RichTextViewProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextViewProvider.d.ts","sourceRoot":"","sources":["../../src/field/RichTextViewProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAE7E;;GAEG;AACH,KAAK,uBAAuB,GAAG;IAC7B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B,CAAA;AAQD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B,CA6BA,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,IAAI,uBAAuB,CAEzD"}
@@ -0,0 +1,102 @@
1
+ 'use client';
2
+ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
3
+ import { useControllableState } from '@payloadcms/ui';
4
+ import React, { createContext, use, useMemo } from 'react';
5
+ /**
6
+ * Context type for rich text view management.
7
+ */ /**
8
+ * The name of the currently active view (e.g., 'default', 'frontend', 'debug')
9
+ */ /**
10
+ * The node map for the currently active view, containing rendering overrides for each node type.
11
+ * This is the resolved view from the views map based on currentView.
12
+ */ /**
13
+ * If true, the current view will be inherited by nested richtext editors.
14
+ */ /**
15
+ * Function to change the current view.
16
+ */ /**
17
+ * The complete map of all available views for this field.
18
+ */ const RichTextViewContext = /*#__PURE__*/ createContext({
19
+ currentView: 'default',
20
+ inheritable: false,
21
+ setCurrentView: ()=>{}
22
+ });
23
+ /**
24
+ * Provider component for rich text view context.
25
+ *
26
+ * This provider manages the current view state internally and makes it accessible to child components
27
+ * via the useRichTextView hook. It automatically resolves the current view's node map
28
+ * based on the active view name.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * <RichTextViewProvider
33
+ * currentView="frontend"
34
+ * views={myViews}
35
+ * >
36
+ * <MyEditor />
37
+ * </RichTextViewProvider>
38
+ * ```
39
+ */ export const RichTextViewProvider = (args)=>{
40
+ const parentContext = useRichTextView();
41
+ const { children, currentView: currentViewFromProps, inheritable, views } = parentContext.inheritable ? {
42
+ ...parentContext,
43
+ ...args
44
+ } : args;
45
+ const [currentView, setCurrentView] = useControllableState(currentViewFromProps, 'default');
46
+ const value = useMemo(()=>{
47
+ const currentViewMap = views ? views[currentView] || views.default : undefined;
48
+ return {
49
+ currentView,
50
+ currentViewMap,
51
+ inheritable,
52
+ setCurrentView,
53
+ views
54
+ };
55
+ }, [
56
+ currentView,
57
+ inheritable,
58
+ setCurrentView,
59
+ views
60
+ ]);
61
+ return /*#__PURE__*/ _jsxDEV(RichTextViewContext, {
62
+ value: value,
63
+ children: children
64
+ }, void 0, false, {
65
+ fileName: "src/field/RichTextViewProvider.tsx",
66
+ lineNumber: 90,
67
+ columnNumber: 10
68
+ }, this);
69
+ };
70
+ /**
71
+ * Hook to access the current rich text view context.
72
+ *
73
+ * Use this hook to access the currently active view and its node map,
74
+ * or to programmatically switch between views.
75
+ *
76
+ * @returns An object containing:
77
+ * - `currentView`: The name of the active view
78
+ * - `currentViewMap`: The node overrides for the current view
79
+ * - `setCurrentView`: Function to change views
80
+ * - `views`: All available views
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * function MyComponent() {
85
+ * const { currentView, currentViewMap, setCurrentView } = useRichTextView()
86
+ *
87
+ * return (
88
+ * <div>
89
+ * <p>Current view: {currentView}</p>
90
+ * {currentViewMap?.heading && <p>Heading overrides are active</p>}
91
+ * <button onClick={() => setCurrentView('frontend')}>
92
+ * Switch to frontend view
93
+ * </button>
94
+ * </div>
95
+ * )
96
+ * }
97
+ * ```
98
+ */ export function useRichTextView() {
99
+ return use(RichTextViewContext);
100
+ }
101
+
102
+ //# sourceMappingURL=RichTextViewProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/field/RichTextViewProvider.tsx"],"sourcesContent":["'use client'\nimport { useControllableState } from '@payloadcms/ui'\nimport React, { createContext, use, useMemo } from 'react'\n\nimport type { LexicalEditorNodeMap, LexicalEditorViewMap } from '../types.js'\n\n/**\n * Context type for rich text view management.\n */\ntype RichTextViewContextType = {\n /**\n * The name of the currently active view (e.g., 'default', 'frontend', 'debug')\n */\n currentView: string\n /**\n * The node map for the currently active view, containing rendering overrides for each node type.\n * This is the resolved view from the views map based on currentView.\n */\n currentViewMap?: LexicalEditorNodeMap\n /**\n * If true, the current view will be inherited by nested richtext editors.\n */\n inheritable?: boolean\n /**\n * Function to change the current view.\n */\n setCurrentView: (view: string) => void\n /**\n * The complete map of all available views for this field.\n */\n views?: LexicalEditorViewMap\n}\n\nconst RichTextViewContext = createContext<RichTextViewContextType>({\n currentView: 'default',\n inheritable: false,\n setCurrentView: () => {},\n})\n\n/**\n * Provider component for rich text view context.\n *\n * This provider manages the current view state internally and makes it accessible to child components\n * via the useRichTextView hook. It automatically resolves the current view's node map\n * based on the active view name.\n *\n * @example\n * ```tsx\n * <RichTextViewProvider\n * currentView=\"frontend\"\n * views={myViews}\n * >\n * <MyEditor />\n * </RichTextViewProvider>\n * ```\n */\nexport const RichTextViewProvider: React.FC<{\n children: React.ReactNode\n currentView?: string\n inheritable?: boolean\n views?: LexicalEditorViewMap\n}> = (args) => {\n const parentContext = useRichTextView()\n\n const {\n children,\n currentView: currentViewFromProps,\n inheritable,\n views,\n } = parentContext.inheritable\n ? {\n ...parentContext,\n ...args,\n }\n : args\n\n const [currentView, setCurrentView] = useControllableState(currentViewFromProps, 'default')\n\n const value = useMemo(() => {\n const currentViewMap = views ? views[currentView] || views.default : undefined\n return {\n currentView,\n currentViewMap,\n inheritable,\n setCurrentView,\n views,\n }\n }, [currentView, inheritable, setCurrentView, views])\n\n return <RichTextViewContext value={value}>{children}</RichTextViewContext>\n}\n\n/**\n * Hook to access the current rich text view context.\n *\n * Use this hook to access the currently active view and its node map,\n * or to programmatically switch between views.\n *\n * @returns An object containing:\n * - `currentView`: The name of the active view\n * - `currentViewMap`: The node overrides for the current view\n * - `setCurrentView`: Function to change views\n * - `views`: All available views\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { currentView, currentViewMap, setCurrentView } = useRichTextView()\n *\n * return (\n * <div>\n * <p>Current view: {currentView}</p>\n * {currentViewMap?.heading && <p>Heading overrides are active</p>}\n * <button onClick={() => setCurrentView('frontend')}>\n * Switch to frontend view\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRichTextView(): RichTextViewContextType {\n return use(RichTextViewContext)\n}\n"],"names":["useControllableState","React","createContext","use","useMemo","RichTextViewContext","currentView","inheritable","setCurrentView","RichTextViewProvider","args","parentContext","useRichTextView","children","currentViewFromProps","views","value","currentViewMap","default","undefined"],"mappings":"AAAA;;AACA,SAASA,oBAAoB,QAAQ,iBAAgB;AACrD,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,OAAO,QAAQ,QAAO;AAI1D;;CAEC,GAEC;;GAEC,GAED;;;GAGC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAIH,MAAMC,oCAAsBH,cAAuC;IACjEI,aAAa;IACbC,aAAa;IACbC,gBAAgB,KAAO;AACzB;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,uBAKR,CAACC;IACJ,MAAMC,gBAAgBC;IAEtB,MAAM,EACJC,QAAQ,EACRP,aAAaQ,oBAAoB,EACjCP,WAAW,EACXQ,KAAK,EACN,GAAGJ,cAAcJ,WAAW,GACzB;QACE,GAAGI,aAAa;QAChB,GAAGD,IAAI;IACT,IACAA;IAEJ,MAAM,CAACJ,aAAaE,eAAe,GAAGR,qBAAqBc,sBAAsB;IAEjF,MAAME,QAAQZ,QAAQ;QACpB,MAAMa,iBAAiBF,QAAQA,KAAK,CAACT,YAAY,IAAIS,MAAMG,OAAO,GAAGC;QACrE,OAAO;YACLb;YACAW;YACAV;YACAC;YACAO;QACF;IACF,GAAG;QAACT;QAAaC;QAAaC;QAAgBO;KAAM;IAEpD,qBAAO,QAACV;QAAoBW,OAAOA;kBAAQH;;;;;;AAC7C,EAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GACD,OAAO,SAASD;IACd,OAAOT,IAAIE;AACb"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import './ViewSelector.scss';
3
+ export declare function ViewSelector(): null | React.ReactElement;
4
+ //# sourceMappingURL=ViewSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewSelector.d.ts","sourceRoot":"","sources":["../../src/field/ViewSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,qBAAqB,CAAA;AAE5B,wBAAgB,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,YAAY,CAyDxD"}
@@ -0,0 +1,90 @@
1
+ 'use client';
2
+ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
3
+ import { ChevronIcon, Popup, PopupList } from '@payloadcms/ui';
4
+ import React from 'react';
5
+ import { useRichTextView } from './RichTextViewProvider.js';
6
+ import './ViewSelector.scss';
7
+ export function ViewSelector() {
8
+ const { currentView, setCurrentView, views } = useRichTextView();
9
+ // Don't show if no views or only default exists
10
+ if (!views || Object.keys(views).length === 0) {
11
+ return null;
12
+ }
13
+ const viewKeys = Object.keys(views);
14
+ const hasNonDefaultViews = viewKeys.some((key)=>key !== 'default');
15
+ // If only 'default' exists, no need to show selector
16
+ if (!hasNonDefaultViews) {
17
+ return null;
18
+ }
19
+ // Build list of available views
20
+ const allViews = [
21
+ 'default',
22
+ ...viewKeys.filter((key)=>key !== 'default')
23
+ ];
24
+ const currentViewLabel = currentView.charAt(0).toUpperCase() + currentView.slice(1);
25
+ return /*#__PURE__*/ _jsxDEV("div", {
26
+ className: "lexical-view-selector",
27
+ children: /*#__PURE__*/ _jsxDEV(Popup, {
28
+ button: /*#__PURE__*/ _jsxDEV("button", {
29
+ className: "lexical-view-selector__button",
30
+ type: "button",
31
+ children: [
32
+ /*#__PURE__*/ _jsxDEV("span", {
33
+ className: "lexical-view-selector__label",
34
+ children: currentViewLabel
35
+ }, void 0, false, {
36
+ fileName: "src/field/ViewSelector.tsx",
37
+ lineNumber: 34,
38
+ columnNumber: 13
39
+ }, void 0),
40
+ /*#__PURE__*/ _jsxDEV(ChevronIcon, {
41
+ className: "lexical-view-selector__icon"
42
+ }, void 0, false, {
43
+ fileName: "src/field/ViewSelector.tsx",
44
+ lineNumber: 35,
45
+ columnNumber: 13
46
+ }, void 0)
47
+ ]
48
+ }, void 0, true, {
49
+ fileName: "src/field/ViewSelector.tsx",
50
+ lineNumber: 33,
51
+ columnNumber: 11
52
+ }, void 0),
53
+ buttonType: "custom",
54
+ horizontalAlign: "left",
55
+ render: ({ close })=>/*#__PURE__*/ _jsxDEV(PopupList.ButtonGroup, {
56
+ children: allViews.map((viewName)=>{
57
+ const viewLabel = viewName.charAt(0).toUpperCase() + viewName.slice(1);
58
+ return /*#__PURE__*/ _jsxDEV(PopupList.Button, {
59
+ active: viewName === currentView,
60
+ disabled: viewName === currentView,
61
+ onClick: ()=>{
62
+ setCurrentView?.(viewName);
63
+ close();
64
+ },
65
+ children: viewLabel
66
+ }, viewName, false, {
67
+ fileName: "src/field/ViewSelector.tsx",
68
+ lineNumber: 46,
69
+ columnNumber: 17
70
+ }, void 0);
71
+ })
72
+ }, void 0, false, {
73
+ fileName: "src/field/ViewSelector.tsx",
74
+ lineNumber: 41,
75
+ columnNumber: 11
76
+ }, void 0),
77
+ size: "large"
78
+ }, void 0, false, {
79
+ fileName: "src/field/ViewSelector.tsx",
80
+ lineNumber: 31,
81
+ columnNumber: 7
82
+ }, this)
83
+ }, void 0, false, {
84
+ fileName: "src/field/ViewSelector.tsx",
85
+ lineNumber: 30,
86
+ columnNumber: 5
87
+ }, this);
88
+ }
89
+
90
+ //# sourceMappingURL=ViewSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/field/ViewSelector.tsx"],"sourcesContent":["'use client'\nimport { ChevronIcon, Popup, PopupList } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { useRichTextView } from './RichTextViewProvider.js'\nimport './ViewSelector.scss'\n\nexport function ViewSelector(): null | React.ReactElement {\n const { currentView, setCurrentView, views } = useRichTextView()\n\n // Don't show if no views or only default exists\n if (!views || Object.keys(views).length === 0) {\n return null\n }\n\n const viewKeys = Object.keys(views)\n const hasNonDefaultViews = viewKeys.some((key) => key !== 'default')\n\n // If only 'default' exists, no need to show selector\n if (!hasNonDefaultViews) {\n return null\n }\n\n // Build list of available views\n const allViews = ['default', ...viewKeys.filter((key) => key !== 'default')]\n\n const currentViewLabel = currentView.charAt(0).toUpperCase() + currentView.slice(1)\n\n return (\n <div className=\"lexical-view-selector\">\n <Popup\n button={\n <button className=\"lexical-view-selector__button\" type=\"button\">\n <span className=\"lexical-view-selector__label\">{currentViewLabel}</span>\n <ChevronIcon className=\"lexical-view-selector__icon\" />\n </button>\n }\n buttonType=\"custom\"\n horizontalAlign=\"left\"\n render={({ close }) => (\n <PopupList.ButtonGroup>\n {allViews.map((viewName) => {\n const viewLabel = viewName.charAt(0).toUpperCase() + viewName.slice(1)\n\n return (\n <PopupList.Button\n active={viewName === currentView}\n disabled={viewName === currentView}\n key={viewName}\n onClick={() => {\n setCurrentView?.(viewName)\n close()\n }}\n >\n {viewLabel}\n </PopupList.Button>\n )\n })}\n </PopupList.ButtonGroup>\n )}\n size=\"large\"\n />\n </div>\n )\n}\n"],"names":["ChevronIcon","Popup","PopupList","React","useRichTextView","ViewSelector","currentView","setCurrentView","views","Object","keys","length","viewKeys","hasNonDefaultViews","some","key","allViews","filter","currentViewLabel","charAt","toUpperCase","slice","div","className","button","type","span","buttonType","horizontalAlign","render","close","ButtonGro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iB0B;gCACjBH;4BACF;sCAECI;2BANID;;;;;oBASX;;;;;;YAGJM,MAAK;;;;;;;;;;;AAIb"}
@@ -0,0 +1,34 @@
1
+ @import '~@payloadcms/ui/scss';
2
+
3
+ .lexical-view-selector {
4
+ display: inline-flex;
5
+ margin-left: var(--spacing-xs);
6
+ vertical-align: middle;
7
+
8
+ &__button {
9
+ all: unset;
10
+ display: inline-flex;
11
+ align-items: center;
12
+ gap: 4px;
13
+ padding: 2px 6px;
14
+ background: transparent;
15
+ border-radius: var(--border-radius-s);
16
+ cursor: pointer;
17
+ color: var(--theme-elevation-600);
18
+ box-sizing: border-box;
19
+
20
+ &:hover {
21
+ background: var(--theme-elevation-100);
22
+ color: var(--theme-elevation-800);
23
+ }
24
+ }
25
+
26
+ &__label {
27
+ line-height: 1;
28
+ white-space: nowrap;
29
+ }
30
+
31
+ &__icon {
32
+ flex-shrink: 0;
33
+ }
34
+ }
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
2
  import type { LexicalRichTextFieldProps } from '../types.js';
3
3
  export declare const RichTextField: React.FC<LexicalRichTextFieldProps>;
4
+ export declare const RichTextFieldImpl: React.FC<LexicalRichTextFieldProps>;
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/field/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA8C,MAAM,OAAO,CAAA;AAIlE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAU5D,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAiE7D,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/field/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA8C,MAAM,OAAO,CAAA;AAIlE,OAAO,KAAK,EAAgC,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAW1F,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAM7D,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAgFjE,CAAA"}
@@ -1,18 +1,40 @@
1
1
  'use client';
2
+ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
3
+ import { createElement as _createElement } from "react";
2
4
  import { ShimmerEffect, useConfig } from '@payloadcms/ui';
3
- import { lazy, Suspense, useEffect, useState } from 'react';
5
+ import React, { lazy, Suspense, useEffect, useState } from 'react';
4
6
  import { defaultEditorLexicalConfig } from '../lexical/config/client/default.js';
5
7
  import { loadClientFeatures } from '../lexical/config/client/loader.js';
6
8
  import { sanitizeClientEditorConfig } from '../lexical/config/client/sanitize.js';
7
- const RichTextEditor = lazy(()=>import('./Field.js').then((module)=>({
9
+ import { RichTextViewProvider, useRichTextView } from './RichTextViewProvider.js';
10
+ const RichTextEditor = /*#__PURE__*/ lazy(()=>import('./Field.js').then((module)=>({
8
11
  default: module.RichText
9
12
  })));
10
13
  export const RichTextField = (props)=>{
11
- const { admin = {}, clientFeatures, featureClientImportMap = {}, featureClientSchemaMap, field, lexicalEditorConfig = defaultEditorLexicalConfig, schemaPath } = props;
14
+ return /*#__PURE__*/ _jsxDEV(RichTextViewProvider, {
15
+ views: props.views,
16
+ children: /*#__PURE__*/ _jsxDEV(RichTextFieldImpl, {
17
+ ...props
18
+ }, void 0, false, {
19
+ fileName: "src/field/index.tsx",
20
+ lineNumber: 25,
21
+ columnNumber: 7
22
+ }, this)
23
+ }, void 0, false, {
24
+ fileName: "src/field/index.tsx",
25
+ lineNumber: 24,
26
+ columnNumber: 5
27
+ }, this);
28
+ };
29
+ export const RichTextFieldImpl = (props)=>{
30
+ const { admin: _admin = {}, clientFeatures, featureClientImportMap = {}, featureClientSchemaMap, field, lexicalEditorConfig: _lexicalEditorConfig = defaultEditorLexicalConfig, schemaPath, views } = props;
31
+ const { currentView } = useRichTextView();
32
+ const currentViewAdminConfig = views?.[currentView]?.admin ?? _admin;
33
+ const currentViewLexicalEditorConfig = views?.[currentView]?.lexical ?? _lexicalEditorConfig;
12
34
  const { config } = useConfig();
13
35
  const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] = useState(null);
14
36
  useEffect(()=>{
15
- if (finalSanitizedEditorConfig) {
37
+ if (finalSanitizedEditorConfig && finalSanitizedEditorConfig.view === currentView) {
16
38
  return;
17
39
  }
18
40
  const featureProvidersLocal = [];
@@ -31,25 +53,47 @@ export const RichTextField = (props)=>{
31
53
  schemaPath: schemaPath ?? field.name,
32
54
  unSanitizedEditorConfig: {
33
55
  features: featureProvidersLocal,
34
- lexical: lexicalEditorConfig
56
+ lexical: currentViewLexicalEditorConfig
35
57
  }
36
58
  });
37
- setFinalSanitizedEditorConfig(sanitizeClientEditorConfig(resolvedClientFeatures, lexicalEditorConfig, admin));
59
+ setFinalSanitizedEditorConfig(sanitizeClientEditorConfig(resolvedClientFeatures, currentViewLexicalEditorConfig, currentViewAdminConfig, currentView));
38
60
  }, [
39
- admin,
61
+ currentViewAdminConfig,
40
62
  clientFeatures,
41
63
  config,
42
64
  featureClientImportMap,
43
65
  featureClientSchemaMap,
44
66
  field,
45
67
  finalSanitizedEditorConfig,
46
- lexicalEditorConfig,
47
- schemaPath
68
+ currentViewLexicalEditorConfig,
69
+ schemaPath,
70
+ currentView
48
71
  ]);
49
72
  // TODO: Optimize this and use useMemo for this in the future. This might break sub-richtext-blocks from the blocks feature. Need to investigate
50
- return <Suspense fallback={<ShimmerEffect height="35vh"/>}>
51
- {finalSanitizedEditorConfig && <RichTextEditor {...props} editorConfig={finalSanitizedEditorConfig}/>}
52
- </Suspense>;
73
+ return /*#__PURE__*/ _jsxDEV(Suspense, {
74
+ fallback: /*#__PURE__*/ _jsxDEV(ShimmerEffect, {
75
+ height: "35vh"
76
+ }, void 0, false, {
77
+ fileName: "src/field/index.tsx",
78
+ lineNumber: 100,
79
+ columnNumber: 25
80
+ }, void 0),
81
+ children: finalSanitizedEditorConfig && /*#__PURE__*/ _createElement(RichTextEditor, {
82
+ ...props,
83
+ editorConfig: finalSanitizedEditorConfig,
84
+ key: finalSanitizedEditorConfig.view,
85
+ __source: {
86
+ fileName: "src/field/index.tsx",
87
+ lineNumber: 102,
88
+ columnNumber: 9
89
+ },
90
+ __self: this
91
+ })
92
+ }, void 0, false, {
93
+ fileName: "src/field/index.tsx",
94
+ lineNumber: 100,
95
+ columnNumber: 5
96
+ }, this);
53
97
  };
54
98
 
55
99
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\n\nimport type { RichTextFieldClient } from 'payload'\n\nimport { ShimmerEffect, useConfig } from '@payloadcms/ui'\nimport React, { lazy, Suspense, useEffect, useState } from 'react'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { defaultEditorLexicalConfig } from '../lexical/config/client/default.js'\nimport { loadClientFeatures } from '../lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from '../lexical/config/client/sanitize.js'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<LexicalRichTextFieldProps> = (props) => {\n const {\n admin = {},\n clientFeatures,\n featureClientImportMap = {},\n featureClientSchemaMap,\n field,\n lexicalEditorConfig = defaultEditorLexicalConfig,\n schemaPath,\n } = props\n\n const { config } = useConfig()\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<null | SanitizedClientEditorConfig>(null)\n\n useEffect(() => {\n if (finalSanitizedEditorConfig) {\n return\n }\n\n const featureProvidersLocal: FeatureProviderClient<any, any>[] = []\n for (const clientFeature of Object.values(clientFeatures)) {\n if (!clientFeature.clientFeatureProvider) {\n continue\n }\n featureProvidersLocal.push(\n clientFeature.clientFeatureProvider(clientFeature.clientFeatureProps),\n ) // Execute the clientFeatureProvider function here, as the server cannot execute functions imported from use client files\n }\n\n const resolvedClientFeatures = loadClientFeatures({\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field: field as RichTextFieldClient,\n schemaPath: schemaPath ?? field.name,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: lexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(resolvedClientFeatures, lexicalEditorConfig, admin),\n )\n }, [\n admin,\n clientFeatures,\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field,\n finalSanitizedEditorConfig,\n lexicalEditorConfig,\n schemaPath,\n ]) // TODO: Optimize this and use useMemo for this in the future. This might break sub-richtext-blocks from the blocks feature. Need to investigate\n\n return (\n <Suspense fallback={<ShimmerEffect height=\"35vh\" />}>\n {finalSanitizedEditorConfig && (\n <RichTextEditor {...props} editorConfig={finalSanitizedEditorConfig} />\n )}\n </Suspense>\n )\n}\n"],"names":["ShimmerEffect","useConfig","lazy","Suspense","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextEditor","then","module","default","RichText","RichTextField","props","admin","clientFeatures","featureClientImportMap","featureClientSchemaMap","field","lexicalEditorConfig","schemaPath","config","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","featureProvidersLocal","clientFeature","Object","values","clientFeatureProvider","push","clientFeatureProps","resolvedClientFeatures","name","unSanitizedEditorConfig","features","lexical","fallback","height","editorConfig"],"mappings":"AAAA;AAIA,SAASA,aAAa,EAAEC,SAAS,QAAQ,iBAAgB;AACzD,SAAgBC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAMlE,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,0BAA0B,QAAQ,uCAAsC;AAEjF,MAAMC,iBAAiBP,KAAK,IAC1B,MAAM,CAAC,cAAcQ,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,SAASD,OAAOE,QAAQ;QAAC,CAAA;AAGpE,OAAO,MAAMC,gBAAqD,CAACC;IACjE,MAAM,EACJC,QAAQ,CAAC,CAAC,EACVC,cAAc,EACdC,yBAAyB,CAAC,CAAC,EAC3BC,sBAAsB,EACtBC,KAAK,EACLC,sBAAsBf,0BAA0B,EAChDgB,UAAU,EACX,GAAGP;IAEJ,MAAM,EAAEQ,MAAM,EAAE,GAAGtB;IAEnB,MAAM,CAACuB,4BAA4BC,8BAA8B,GAC/DpB,SAA6C;IAE/CD,UAAU;QACR,IAAIoB,4BAA4B;YAC9B;QACF;QAEA,MAAME,wBAA2D,EAAE;QACnE,KAAK,MAAMC,iBAAiBC,OAAOC,MAAM,CAACZ,gBAAiB;YACzD,IAAI,CAACU,cAAcG,qBAAqB,EAAE;gBACxC;YACF;YACAJ,sBAAsBK,IAAI,CACxBJ,cAAcG,qBAAqB,CAACH,cAAcK,kBAAkB;QAExE;QADI,yHAAyH;QAG7H,MAAMC,yBAAyB1B,mBAAmB;YAChDgB;YACAL;YACAC;YACAC,OAAOA;YACPE,YAAYA,cAAcF,MAAMc,IAAI;YACpCC,yBAAyB;gBACvBC,UAAUV;gBACVW,SAAShB;YACX;QACF;QAEAI,8BACEjB,2BAA2ByB,wBAAwBZ,qBAAqBL;IAE5E,GAAG;QACDA;QACAC;QACAM;QACAL;QACAC;QACAC;QACAI;QACAH;QACAC;KACD;IAAE,gJAAgJ;IAEnJ,QACGnB,SAASmC,WAAWtC,cAAcuC,OAAO,UAAW;MACnD,CAACf,+BACEf,gBAAgB,GAAGM,KAAK,EAAEyB,cAAchB,8BACzC;IACJ,EAAErB;AAEN,EAAC"}
1
+ {"version":3,"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\nimport type { RichTextFieldClient } from 'payload'\n\nimport { ShimmerEffect, useConfig } from '@payloadcms/ui'\nimport React, { lazy, Suspense, useEffect, useState } from 'react'\n\nimport type { FeatureProviderClient } from '../features/typesClient.js'\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalFieldAdminClientProps, LexicalRichTextFieldProps } from '../types.js'\n\nimport { defaultEditorLexicalConfig } from '../lexical/config/client/default.js'\nimport { loadClientFeatures } from '../lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from '../lexical/config/client/sanitize.js'\nimport { RichTextViewProvider, useRichTextView } from './RichTextViewProvider.js'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<LexicalRichTextFieldProps> = (props) => {\n return (\n <RichTextViewProvider views={props.views}>\n <RichTextFieldImpl {...props} />\n </RichTextViewProvider>\n )\n}\n\nexport const RichTextFieldImpl: React.FC<LexicalRichTextFieldProps> = (props) => {\n const {\n admin: _admin = {},\n clientFeatures,\n featureClientImportMap = {},\n featureClientSchemaMap,\n field,\n lexicalEditorConfig: _lexicalEditorConfig = defaultEditorLexicalConfig,\n schemaPath,\n views,\n } = props\n const { currentView } = useRichTextView()\n const currentViewAdminConfig: LexicalFieldAdminClientProps = views?.[currentView]?.admin ?? _admin\n const currentViewLexicalEditorConfig: LexicalEditorConfig =\n views?.[currentView]?.lexical ?? _lexicalEditorConfig\n\n const { config } = useConfig()\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<null | SanitizedClientEditorConfig>(null)\n\n useEffect(() => {\n if (finalSanitizedEditorConfig && finalSanitizedEditorConfig.view === currentView) {\n return\n }\n\n const featureProvidersLocal: FeatureProviderClient<any, any>[] = []\n for (const clientFeature of Object.values(clientFeatures)) {\n if (!clientFeature.clientFeatureProvider) {\n continue\n }\n featureProvidersLocal.push(\n clientFeature.clientFeatureProvider(clientFeature.clientFeatureProps),\n ) // Execute the clientFeatureProvider function here, as the server cannot execute functions imported from use client files\n }\n\n const resolvedClientFeatures = loadClientFeatures({\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field: field as RichTextFieldClient,\n schemaPath: schemaPath ?? field.name,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: currentViewLexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(\n resolvedClientFeatures,\n currentViewLexicalEditorConfig,\n currentViewAdminConfig,\n currentView,\n ),\n )\n }, [\n currentViewAdminConfig,\n clientFeatures,\n config,\n featureClientImportMap,\n featureClientSchemaMap,\n field,\n finalSanitizedEditorConfig,\n currentViewLexicalEditorConfig,\n schemaPath,\n currentView,\n ]) // TODO: Optimize this and use useMemo for this in the future. This might break sub-richtext-blocks from the blocks feature. Need to investigate\n\n return (\n <Suspense fallback={<ShimmerEffect height=\"35vh\" />}>\n {finalSanitizedEditorConfig && (\n <RichTextEditor\n {...props}\n editorConfig={finalSanitizedEditorConfig}\n key={finalSanitizedEditorConfig.view}\n />\n )}\n </Suspense>\n )\n}\n"],"names":["ShimmerEffect","useConfig","React","lazy","Suspense","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextViewProvider","useRichTextView","RichTextEditor","then","module","default","RichText","RichTextField","props","views","RichTextFieldImpl","admin","_admin","clientFeatures","featureClientImportMap","featureClientSchemaMap","field","lexicalEditorConfig","_lexicalEditorConfig","schemaPath","currentView","currentViewAdminConfig","currentViewLexicalEditorConfig","lexical","config","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","view","featureProvidersLocal","clientFeature","Object","values","clientFeatureProvider","push","clientFeatureProps","resolvedClientFeatures","name","unSanitizedEditorConfig","features","fallback","height","editorConfig","key"],"mappings":"AAAA;;;AAKA,SAASA,aAAa,EAAEC,SAAS,QAAQ,iBAAgB;AACzD,OAAOC,SAASC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAMlE,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,kBAAkB,QAAQ,qCA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;YACpCC,yBAAyB;gBACvBC,UAAUV;gBACVL,SAASD;YACX;QACF;QAEAI,8BACE3B,2BACEoC,wBACAb,gCACAD,wBACAD;IAGN,GAAG;QACDC;QACAR;QACAW;QACAV;QACAC;QACAC;QACAS;QACAH;QACAH;QACAC;KACD;IAAE,gJAAgJ;IAEnJ,qBACE,QAAC1B;QAAS6C,wBAAU,QAACjD;YAAckD,QAAO;;;;;;kBACvCf,4CACC,eAACvB;YACE,GAAGM,KAAK;YACTiC,cAAchB;YACdiB,KAAKjB,2BAA2BE,IAAI;;;;;;;;;;;;;AAK9C,EAAC"}
@@ -15,6 +15,18 @@
15
15
  }
16
16
  }
17
17
 
18
+ &__label-row {
19
+ display: flex;
20
+ align-items: center;
21
+ margin-bottom: calc(var(--base) / 4);
22
+ gap: calc(var(--base) / 3);
23
+
24
+ label.field-label:not(.unstyled) {
25
+ margin-right: unset;
26
+ padding-bottom: unset;
27
+ }
28
+ }
29
+
18
30
  &__wrap {
19
31
  width: 100%;
20
32
  position: relative;
@@ -4,5 +4,5 @@ import type { SanitizedServerEditorConfig } from '../lexical/config/types.js';
4
4
  import type { LexicalEditorProps } from '../types.js';
5
5
  export declare const RscEntryLexicalField: React.FC<{
6
6
  sanitizedEditorConfig: SanitizedServerEditorConfig;
7
- } & ClientComponentProps & Pick<FieldPaths, 'path'> & Pick<LexicalEditorProps, 'admin'> & ServerComponentProps>;
7
+ } & ClientComponentProps & Pick<FieldPaths, 'path'> & Pick<LexicalEditorProps, 'admin' | 'views'> & ServerComponentProps>;
8
8
  //# sourceMappingURL=rscEntry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/field/rscEntry.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EAGV,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,aAAa,CAAA;AAOpB,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC;IACE,qBAAqB,EAAE,2BAA2B,CAAA;CACnD,GAAG,oBAAoB,GACtB,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GACxB,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,GACjC,oBAAoB,CA6FvB,CAAA"}
1
+ {"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/field/rscEntry.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EAGV,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EACV,kBAAkB,EAInB,MAAM,aAAa,CAAA;AAOpB,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC;IACE,qBAAqB,EAAE,2BAA2B,CAAA;CACnD,GAAG,oBAAoB,GACtB,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GACxB,IAAI,CAAC,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAC,GAC3C,oBAAoB,CAyGvB,CAAA"}
@@ -1,5 +1,8 @@
1
+ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
1
2
  import { getTranslation } from '@payloadcms/translations';
2
3
  import { renderField } from '@payloadcms/ui/forms/renderField';
4
+ import { getFromImportMap } from 'payload/shared';
5
+ import React from 'react';
3
6
  // eslint-disable-next-line payload/no-imports-from-exports-dir
4
7
  import { RichTextField } from '../exports/client/index.js';
5
8
  import { buildInitialState } from '../utilities/buildInitialState.js';
@@ -74,6 +77,17 @@ export const RscEntryLexicalField = async (args)=>{
74
77
  renderedBlocks: args.renderedBlocks,
75
78
  schemaPath
76
79
  };
80
+ if (args?.views) {
81
+ const viewMap = getFromImportMap({
82
+ importMap: args.payload.importMap,
83
+ PayloadComponent: args.views,
84
+ schemaPath: 'lexical-viewMap',
85
+ silent: true
86
+ });
87
+ if (viewMap) {
88
+ props.views = viewMap;
89
+ }
90
+ }
77
91
  if (Object.keys(admin).length) {
78
92
  props.admin = admin;
79
93
  }
@@ -85,7 +99,13 @@ export const RscEntryLexicalField = async (args)=>{
85
99
  delete props[key];
86
100
  }
87
101
  }
88
- return <RichTextField {...props}/>;
102
+ return /*#__PURE__*/ _jsxDEV(RichTextField, {
103
+ ...props
104
+ }, void 0, false, {
105
+ fileName: "src/field/rscEntry.tsx",
106
+ lineNumber: 138,
107
+ columnNumber: 10
108
+ }, this);
89
109
  };
90
110
 
91
111
  //# sourceMappingURL=rscEntry.js.map