@payloadcms/richtext-lexical 3.68.0-internal-debug.2eb12b9 → 3.68.0-internal-debug.dafc24d

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 (306) hide show
  1. package/dist/cell/rscEntry.js +13 -5
  2. package/dist/cell/rscEntry.js.map +1 -1
  3. package/dist/features/blocks/client/component/BlockContent.js +29 -9
  4. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  5. package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -3
  6. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  7. package/dist/features/blocks/client/component/components/BlockEditButton.js +6 -2
  8. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
  9. package/dist/features/blocks/client/component/components/BlockRemoveButton.js +6 -2
  10. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
  11. package/dist/features/blocks/client/component/index.js +124 -43
  12. package/dist/features/blocks/client/component/index.js.map +1 -1
  13. package/dist/features/blocks/client/component/index.scss +188 -0
  14. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +7 -3
  15. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
  16. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +6 -2
  17. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
  18. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +6 -2
  19. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
  20. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +6 -2
  21. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
  22. package/dist/features/blocks/client/componentInline/index.js +118 -37
  23. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  24. package/dist/features/blocks/client/componentInline/index.scss +90 -0
  25. package/dist/features/blocks/client/getBlockImageComponent.js +7 -3
  26. package/dist/features/blocks/client/getBlockImageComponent.js.map +1 -1
  27. package/dist/features/blocks/client/markdown/markdownTransformer.js +1 -0
  28. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  29. package/dist/features/blocks/client/nodes/BlocksNode.js +7 -3
  30. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  31. package/dist/features/blocks/client/nodes/InlineBlocksNode.js +7 -3
  32. package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
  33. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +88 -27
  34. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  35. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +7 -3
  36. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
  37. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +13 -4
  38. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
  39. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.scss +6 -0
  40. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +19 -6
  41. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
  42. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.scss +29 -0
  43. package/dist/features/blocks/premade/CodeBlock/Component/index.scss +97 -0
  44. package/dist/features/blocks/server/markdown/markdownTransformer.js +1 -0
  45. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  46. package/dist/features/converters/lexicalToJSX/Component/index.js +9 -5
  47. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  48. package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js +7 -3
  49. package/dist/features/converters/lexicalToJSX/converter/converters/blockquote.js.map +1 -1
  50. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +7 -3
  51. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  52. package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js +6 -2
  53. package/dist/features/converters/lexicalToJSX/converter/converters/horizontalRule.js.map +1 -1
  54. package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js +6 -2
  55. package/dist/features/converters/lexicalToJSX/converter/converters/linebreak.js.map +1 -1
  56. package/dist/features/converters/lexicalToJSX/converter/converters/link.js +13 -5
  57. package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
  58. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +38 -14
  59. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  60. package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js +18 -6
  61. package/dist/features/converters/lexicalToJSX/converter/converters/paragraph.js.map +1 -1
  62. package/dist/features/converters/lexicalToJSX/converter/converters/table.js +31 -11
  63. package/dist/features/converters/lexicalToJSX/converter/converters/table.js.map +1 -1
  64. package/dist/features/converters/lexicalToJSX/converter/converters/text.js +43 -15
  65. package/dist/features/converters/lexicalToJSX/converter/converters/text.js.map +1 -1
  66. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js +31 -11
  67. package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
  68. package/dist/features/converters/lexicalToJSX/converter/index.js +8 -4
  69. package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
  70. package/dist/features/debug/jsxConverter/client/plugin/index.js +14 -5
  71. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  72. package/dist/features/debug/jsxConverter/client/plugin/style.scss +12 -0
  73. package/dist/features/debug/testRecorder/client/plugin/index.js +62 -21
  74. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  75. package/dist/features/debug/testRecorder/client/plugin/index.scss +53 -0
  76. package/dist/features/debug/treeView/client/plugin/index.js +8 -3
  77. package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
  78. package/dist/features/debug/treeView/client/plugin/index.scss +80 -0
  79. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +225 -72
  80. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  81. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.scss +87 -0
  82. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +32 -11
  83. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  84. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.scss +11 -0
  85. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +21 -9
  86. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  87. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +26 -9
  88. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
  89. package/dist/features/experimental_table/client/plugins/TablePlugin/index.scss +233 -0
  90. package/dist/features/horizontalRule/client/plugin/index.js +1 -0
  91. package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
  92. package/dist/features/horizontalRule/client/plugin/index.scss +23 -0
  93. package/dist/features/indent/client/IndentPlugin.js +6 -2
  94. package/dist/features/indent/client/IndentPlugin.js.map +1 -1
  95. package/dist/features/link/client/plugins/autoLink/index.js +3 -0
  96. package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
  97. package/dist/features/link/client/plugins/clickableLink/index.js +6 -2
  98. package/dist/features/link/client/plugins/clickableLink/index.js.map +1 -1
  99. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +76 -24
  100. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  101. package/dist/features/link/client/plugins/floatingLinkEditor/index.js +8 -3
  102. package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
  103. package/dist/features/link/client/plugins/floatingLinkEditor/index.scss +92 -0
  104. package/dist/features/link/server/baseFields.js +1 -0
  105. package/dist/features/link/server/baseFields.js.map +1 -1
  106. package/dist/features/lists/checklist/client/plugin/index.js +6 -2
  107. package/dist/features/lists/checklist/client/plugin/index.js.map +1 -1
  108. package/dist/features/lists/plugin/index.js +6 -2
  109. package/dist/features/lists/plugin/index.js.map +1 -1
  110. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +14 -5
  111. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
  112. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +7 -3
  113. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  114. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.scss +16 -0
  115. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +14 -5
  116. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
  117. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +7 -3
  118. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  119. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.scss +16 -0
  120. package/dist/features/relationship/client/components/RelationshipComponent.js +56 -19
  121. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  122. package/dist/features/relationship/client/components/index.scss +95 -0
  123. package/dist/features/relationship/client/drawer/index.js +18 -6
  124. package/dist/features/relationship/client/drawer/index.js.map +1 -1
  125. package/dist/features/relationship/client/nodes/RelationshipNode.js +7 -3
  126. package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
  127. package/dist/features/relationship/client/plugins/index.js +7 -3
  128. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  129. package/dist/features/textState/feature.client.js +18 -6
  130. package/dist/features/textState/feature.client.js.map +1 -1
  131. package/dist/features/toolbars/fixed/client/Toolbar/index.js +72 -23
  132. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  133. package/dist/features/toolbars/fixed/client/Toolbar/index.scss +113 -0
  134. package/dist/features/toolbars/inline/client/Toolbar/index.js +72 -23
  135. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  136. package/dist/features/toolbars/inline/client/Toolbar/index.scss +58 -0
  137. package/dist/features/toolbars/shared/ToolbarButton/index.js +8 -3
  138. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  139. package/dist/features/toolbars/shared/ToolbarButton/index.scss +46 -0
  140. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +60 -20
  141. package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  142. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +37 -12
  143. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  144. package/dist/features/toolbars/shared/ToolbarDropdown/index.scss +129 -0
  145. package/dist/features/upload/client/component/index.js +92 -31
  146. package/dist/features/upload/client/component/index.js.map +1 -1
  147. package/dist/features/upload/client/component/index.scss +191 -0
  148. package/dist/features/upload/client/component/pending/index.js +14 -5
  149. package/dist/features/upload/client/component/pending/index.js.map +1 -1
  150. package/dist/features/upload/client/drawer/index.js +18 -6
  151. package/dist/features/upload/client/drawer/index.js.map +1 -1
  152. package/dist/features/upload/client/nodes/UploadNode.js +12 -4
  153. package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
  154. package/dist/features/upload/client/plugin/index.js +7 -3
  155. package/dist/features/upload/client/plugin/index.js.map +1 -1
  156. package/dist/field/Diff/converters/listitem/index.js +37 -12
  157. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  158. package/dist/field/Diff/converters/listitem/index.scss +47 -0
  159. package/dist/field/Diff/converters/relationship/index.js +37 -12
  160. package/dist/field/Diff/converters/relationship/index.js.map +1 -1
  161. package/dist/field/Diff/converters/relationship/index.scss +73 -0
  162. package/dist/field/Diff/converters/unknown/index.js +31 -10
  163. package/dist/field/Diff/converters/unknown/index.js.map +1 -1
  164. package/dist/field/Diff/converters/unknown/index.scss +40 -0
  165. package/dist/field/Diff/converters/upload/index.js +60 -19
  166. package/dist/field/Diff/converters/upload/index.js.map +1 -1
  167. package/dist/field/Diff/converters/upload/index.scss +115 -0
  168. package/dist/field/Diff/index.js +8 -3
  169. package/dist/field/Diff/index.js.map +1 -1
  170. package/dist/field/Diff/index.scss +102 -0
  171. package/dist/field/Field.js +81 -27
  172. package/dist/field/Field.js.map +1 -1
  173. package/dist/field/RenderLexical/index.js +36 -12
  174. package/dist/field/RenderLexical/index.js.map +1 -1
  175. package/dist/field/index.js +19 -7
  176. package/dist/field/index.js.map +1 -1
  177. package/dist/field/index.scss +41 -0
  178. package/dist/field/rscEntry.js +7 -3
  179. package/dist/field/rscEntry.js.map +1 -1
  180. package/dist/index.js +2 -0
  181. package/dist/index.js.map +1 -1
  182. package/dist/lexical/EditorPlugin.js +13 -5
  183. package/dist/lexical/EditorPlugin.js.map +1 -1
  184. package/dist/lexical/LexicalEditor.js +163 -50
  185. package/dist/lexical/LexicalEditor.js.map +1 -1
  186. package/dist/lexical/LexicalEditor.scss +54 -0
  187. package/dist/lexical/LexicalProvider.js +49 -17
  188. package/dist/lexical/LexicalProvider.js.map +1 -1
  189. package/dist/lexical/config/client/EditorConfigProvider.js +7 -3
  190. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  191. package/dist/lexical/plugins/DecoratorPlugin/index.js +1 -0
  192. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  193. package/dist/lexical/plugins/DecoratorPlugin/index.scss +13 -0
  194. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +20 -7
  195. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  196. package/dist/lexical/plugins/InsertParagraphAtEnd/index.scss +54 -0
  197. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +2 -0
  198. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  199. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +7 -3
  200. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  201. package/dist/lexical/plugins/SlashMenu/index.js +50 -16
  202. package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
  203. package/dist/lexical/plugins/SlashMenu/index.scss +68 -0
  204. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +20 -7
  205. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  206. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.scss +35 -0
  207. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +32 -11
  208. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  209. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.scss +80 -0
  210. package/dist/lexical/theme/EditorTheme.scss +357 -0
  211. package/dist/lexical/ui/ContentEditable.js +14 -5
  212. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  213. package/dist/lexical/ui/ContentEditable.scss +105 -0
  214. package/dist/lexical/ui/icons/AI/index.js +37 -13
  215. package/dist/lexical/ui/icons/AI/index.js.map +1 -1
  216. package/dist/lexical/ui/icons/Add/index.js +19 -7
  217. package/dist/lexical/ui/icons/Add/index.js.map +1 -1
  218. package/dist/lexical/ui/icons/AlignCenter/index.js +25 -9
  219. package/dist/lexical/ui/icons/AlignCenter/index.js.map +1 -1
  220. package/dist/lexical/ui/icons/AlignJustify/index.js +25 -9
  221. package/dist/lexical/ui/icons/AlignJustify/index.js.map +1 -1
  222. package/dist/lexical/ui/icons/AlignLeft/index.js +25 -9
  223. package/dist/lexical/ui/icons/AlignLeft/index.js.map +1 -1
  224. package/dist/lexical/ui/icons/AlignRight/index.js +25 -9
  225. package/dist/lexical/ui/icons/AlignRight/index.js.map +1 -1
  226. package/dist/lexical/ui/icons/Block/index.js +25 -9
  227. package/dist/lexical/ui/icons/Block/index.js.map +1 -1
  228. package/dist/lexical/ui/icons/Blockquote/index.js +13 -5
  229. package/dist/lexical/ui/icons/Blockquote/index.js.map +1 -1
  230. package/dist/lexical/ui/icons/Bold/index.js +13 -5
  231. package/dist/lexical/ui/icons/Bold/index.js.map +1 -1
  232. package/dist/lexical/ui/icons/Checklist/index.js +19 -7
  233. package/dist/lexical/ui/icons/Checklist/index.js.map +1 -1
  234. package/dist/lexical/ui/icons/Code/index.js +19 -7
  235. package/dist/lexical/ui/icons/Code/index.js.map +1 -1
  236. package/dist/lexical/ui/icons/CodeBlock/index.js +13 -5
  237. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  238. package/dist/lexical/ui/icons/Collapse/index.js +13 -5
  239. package/dist/lexical/ui/icons/Collapse/index.js.map +1 -1
  240. package/dist/lexical/ui/icons/H1/index.js +13 -5
  241. package/dist/lexical/ui/icons/H1/index.js.map +1 -1
  242. package/dist/lexical/ui/icons/H2/index.js +13 -5
  243. package/dist/lexical/ui/icons/H2/index.js.map +1 -1
  244. package/dist/lexical/ui/icons/H3/index.js +13 -5
  245. package/dist/lexical/ui/icons/H3/index.js.map +1 -1
  246. package/dist/lexical/ui/icons/H4/index.js +13 -5
  247. package/dist/lexical/ui/icons/H4/index.js.map +1 -1
  248. package/dist/lexical/ui/icons/H5/index.js +13 -5
  249. package/dist/lexical/ui/icons/H5/index.js.map +1 -1
  250. package/dist/lexical/ui/icons/H6/index.js +13 -5
  251. package/dist/lexical/ui/icons/H6/index.js.map +1 -1
  252. package/dist/lexical/ui/icons/HorizontalRule/index.js +13 -5
  253. package/dist/lexical/ui/icons/HorizontalRule/index.js.map +1 -1
  254. package/dist/lexical/ui/icons/IndentDecrease/index.js +31 -11
  255. package/dist/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
  256. package/dist/lexical/ui/icons/IndentIncrease/index.js +31 -11
  257. package/dist/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
  258. package/dist/lexical/ui/icons/InlineBlocks/index.js +13 -5
  259. package/dist/lexical/ui/icons/InlineBlocks/index.js.map +1 -1
  260. package/dist/lexical/ui/icons/Italic/index.js +13 -5
  261. package/dist/lexical/ui/icons/Italic/index.js.map +1 -1
  262. package/dist/lexical/ui/icons/Link/index.js +13 -5
  263. package/dist/lexical/ui/icons/Link/index.js.map +1 -1
  264. package/dist/lexical/ui/icons/Meatballs/index.js +25 -9
  265. package/dist/lexical/ui/icons/Meatballs/index.js.map +1 -1
  266. package/dist/lexical/ui/icons/OrderedList/index.js +37 -13
  267. package/dist/lexical/ui/icons/OrderedList/index.js.map +1 -1
  268. package/dist/lexical/ui/icons/Relationship/index.js +37 -13
  269. package/dist/lexical/ui/icons/Relationship/index.js.map +1 -1
  270. package/dist/lexical/ui/icons/Strikethrough/index.js +19 -7
  271. package/dist/lexical/ui/icons/Strikethrough/index.js.map +1 -1
  272. package/dist/lexical/ui/icons/Subscript/index.js +13 -5
  273. package/dist/lexical/ui/icons/Subscript/index.js.map +1 -1
  274. package/dist/lexical/ui/icons/Superscript/index.js +13 -5
  275. package/dist/lexical/ui/icons/Superscript/index.js.map +1 -1
  276. package/dist/lexical/ui/icons/Table/index.js +13 -5
  277. package/dist/lexical/ui/icons/Table/index.js.map +1 -1
  278. package/dist/lexical/ui/icons/Text/index.js +13 -5
  279. package/dist/lexical/ui/icons/Text/index.js.map +1 -1
  280. package/dist/lexical/ui/icons/TextState/index.js +7 -3
  281. package/dist/lexical/ui/icons/TextState/index.js.map +1 -1
  282. package/dist/lexical/ui/icons/Underline/index.js +19 -7
  283. package/dist/lexical/ui/icons/Underline/index.js.map +1 -1
  284. package/dist/lexical/ui/icons/UnorderedList/index.js +43 -15
  285. package/dist/lexical/ui/icons/UnorderedList/index.js.map +1 -1
  286. package/dist/lexical/ui/icons/Upload/index.js +25 -9
  287. package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
  288. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +2 -0
  289. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -1
  290. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +2 -0
  291. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -1
  292. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +2 -0
  293. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -1
  294. package/dist/utilities/fieldsDrawer/Drawer.js +19 -7
  295. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  296. package/dist/utilities/fieldsDrawer/DrawerContent.js +19 -7
  297. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  298. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js +7 -3
  299. package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
  300. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js +7 -3
  301. package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
  302. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +2 -0
  303. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
  304. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +2 -0
  305. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  306. package/package.json +8 -7
@@ -1,11 +1,12 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
3
3
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
4
  import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
5
5
  import { getTranslation } from '@payloadcms/translations';
6
6
  import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, FormSubmit, RenderFields, ShimmerEffect, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation } from '@payloadcms/ui';
7
7
  import { abortAndIgnore } from '@payloadcms/ui/shared';
8
8
  import { $getNodeByKey } from 'lexical';
9
+ import './index.scss';
9
10
  import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared';
10
11
  import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react';
11
12
  import { v4 as uuid } from 'uuid';
@@ -242,7 +243,7 @@ export const InlineBlockComponent = (props)=>{
242
243
  nodeKey,
243
244
  formData
244
245
  ]);
245
- const RemoveButton = useMemo(()=>()=>/*#__PURE__*/ _jsx(Button, {
246
+ const RemoveButton = useMemo(()=>()=>/*#__PURE__*/ _jsxDEV(Button, {
246
247
  buttonStyle: "icon-label",
247
248
  className: `${baseClass}__removeButton`,
248
249
  disabled: !isEditable,
@@ -256,14 +257,18 @@ export const InlineBlockComponent = (props)=>{
256
257
  tooltip: t('lexical:blocks:inlineBlocks:remove', {
257
258
  label: blockDisplayName
258
259
  })
259
- }), [
260
+ }, void 0, false, {
261
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
262
+ lineNumber: 341,
263
+ columnNumber: 7
264
+ }, this), [
260
265
  baseClass,
261
266
  blockDisplayName,
262
267
  isEditable,
263
268
  removeInlineBlock,
264
269
  t
265
270
  ]);
266
- const EditButton = useMemo(()=>()=>/*#__PURE__*/ _jsx(Button, {
271
+ const EditButton = useMemo(()=>()=>/*#__PURE__*/ _jsxDEV(Button, {
267
272
  buttonStyle: "icon-label",
268
273
  className: `${baseClass}__editButton`,
269
274
  disabled: !isEditable,
@@ -277,14 +282,18 @@ export const InlineBlockComponent = (props)=>{
277
282
  tooltip: t('lexical:blocks:inlineBlocks:edit', {
278
283
  label: blockDisplayName
279
284
  })
280
- }), [
285
+ }, void 0, false, {
286
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
287
+ lineNumber: 360,
288
+ columnNumber: 7
289
+ }, this), [
281
290
  baseClass,
282
291
  blockDisplayName,
283
292
  isEditable,
284
293
  t,
285
294
  toggleDrawer
286
295
  ]);
287
- const InlineBlockContainer = useMemo(()=>({ children, className })=>/*#__PURE__*/ _jsx("div", {
296
+ const InlineBlockContainer = useMemo(()=>({ children, className })=>/*#__PURE__*/ _jsxDEV("div", {
288
297
  className: [
289
298
  `${baseClass}__container`,
290
299
  baseClass + '-' + formData.blockType,
@@ -292,7 +301,11 @@ export const InlineBlockComponent = (props)=>{
292
301
  ].filter(Boolean).join(' '),
293
302
  ref: inlineBlockElemElemRef,
294
303
  children: children
295
- }), [
304
+ }, void 0, false, {
305
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
306
+ lineNumber: 380,
307
+ columnNumber: 9
308
+ }, this), [
296
309
  baseClass,
297
310
  formData.blockType
298
311
  ]);
@@ -300,9 +313,13 @@ export const InlineBlockComponent = (props)=>{
300
313
  if (CustomLabel) {
301
314
  return ()=>CustomLabel;
302
315
  } else {
303
- return ()=>/*#__PURE__*/ _jsx("div", {
316
+ return ()=>/*#__PURE__*/ _jsxDEV("div", {
304
317
  children: clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''
305
- });
318
+ }, void 0, false, {
319
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
320
+ lineNumber: 397,
321
+ columnNumber: 9
322
+ }, this);
306
323
  }
307
324
  }, [
308
325
  CustomLabel,
@@ -310,24 +327,40 @@ export const InlineBlockComponent = (props)=>{
310
327
  i18n
311
328
  ]);
312
329
  if (!clientBlock) {
313
- return /*#__PURE__*/ _jsxs(InlineBlockContainer, {
330
+ return /*#__PURE__*/ _jsxDEV(InlineBlockContainer, {
314
331
  className: `${baseClass}-not-found`,
315
332
  children: [
316
- /*#__PURE__*/ _jsxs("span", {
333
+ /*#__PURE__*/ _jsxDEV("span", {
317
334
  children: [
318
335
  "Error: Block '",
319
336
  formData.blockType,
320
337
  "' not found"
321
338
  ]
322
- }),
323
- isEditable ? /*#__PURE__*/ _jsx("div", {
339
+ }, void 0, true, {
340
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
341
+ lineNumber: 405,
342
+ columnNumber: 9
343
+ }, this),
344
+ isEditable ? /*#__PURE__*/ _jsxDEV("div", {
324
345
  className: `${baseClass}__actions`,
325
- children: /*#__PURE__*/ _jsx(RemoveButton, {})
326
- }) : null
346
+ children: /*#__PURE__*/ _jsxDEV(RemoveButton, {}, void 0, false, {
347
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
348
+ lineNumber: 408,
349
+ columnNumber: 13
350
+ }, this)
351
+ }, void 0, false, {
352
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
353
+ lineNumber: 407,
354
+ columnNumber: 11
355
+ }, this) : null
327
356
  ]
328
- });
357
+ }, void 0, true, {
358
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
359
+ lineNumber: 404,
360
+ columnNumber: 7
361
+ }, this);
329
362
  }
330
- return /*#__PURE__*/ _jsxs(Form, {
363
+ return /*#__PURE__*/ _jsxDEV(Form, {
331
364
  beforeSubmit: [
332
365
  async ({ formState })=>{
333
366
  // This is only called when form is submitted from drawer
@@ -350,16 +383,16 @@ export const InlineBlockComponent = (props)=>{
350
383
  },
351
384
  uuid: uuid(),
352
385
  children: [
353
- /*#__PURE__*/ _jsx(EditDepthProvider, {
354
- children: /*#__PURE__*/ _jsx(Drawer, {
386
+ /*#__PURE__*/ _jsxDEV(EditDepthProvider, {
387
+ children: /*#__PURE__*/ _jsxDEV(Drawer, {
355
388
  className: '',
356
389
  slug: drawerSlug,
357
390
  title: t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {
358
391
  label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label')
359
392
  }),
360
- children: initialState ? /*#__PURE__*/ _jsxs(_Fragment, {
393
+ children: initialState ? /*#__PURE__*/ _jsxDEV(_Fragment, {
361
394
  children: [
362
- /*#__PURE__*/ _jsx(RenderFields, {
395
+ /*#__PURE__*/ _jsxDEV(RenderFields, {
363
396
  fields: clientBlock?.fields,
364
397
  forceRender: true,
365
398
  parentIndexPath: "",
@@ -368,16 +401,32 @@ export const InlineBlockComponent = (props)=>{
368
401
  parentSchemaPath: schemaFieldsPath,
369
402
  permissions: true,
370
403
  readOnly: !isEditable
371
- }),
372
- /*#__PURE__*/ _jsx(FormSubmit, {
404
+ }, void 0, false, {
405
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
406
+ lineNumber: 444,
407
+ columnNumber: 15
408
+ }, this),
409
+ /*#__PURE__*/ _jsxDEV(FormSubmit, {
373
410
  programmaticSubmit: true,
374
411
  children: t('fields:saveChanges')
375
- })
412
+ }, void 0, false, {
413
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
414
+ lineNumber: 453,
415
+ columnNumber: 15
416
+ }, this)
376
417
  ]
377
- }) : null
378
- })
379
- }),
380
- CustomBlock ? /*#__PURE__*/ _jsx(InlineBlockComponentContext, {
418
+ }, void 0, true) : null
419
+ }, void 0, false, {
420
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
421
+ lineNumber: 435,
422
+ columnNumber: 9
423
+ }, this)
424
+ }, void 0, false, {
425
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
426
+ lineNumber: 434,
427
+ columnNumber: 7
428
+ }, this),
429
+ CustomBlock ? /*#__PURE__*/ _jsxDEV(InlineBlockComponentContext, {
381
430
  value: {
382
431
  EditButton,
383
432
  initialState,
@@ -387,23 +436,55 @@ export const InlineBlockComponent = (props)=>{
387
436
  RemoveButton
388
437
  },
389
438
  children: CustomBlock
390
- }) : /*#__PURE__*/ _jsxs(InlineBlockContainer, {
439
+ }, void 0, false, {
440
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
441
+ lineNumber: 459,
442
+ columnNumber: 9
443
+ }, this) : /*#__PURE__*/ _jsxDEV(InlineBlockContainer, {
391
444
  children: [
392
- initialState ? /*#__PURE__*/ _jsx(Label, {}) : /*#__PURE__*/ _jsx(ShimmerEffect, {
445
+ initialState ? /*#__PURE__*/ _jsxDEV(Label, {}, void 0, false, {
446
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
447
+ lineNumber: 473,
448
+ columnNumber: 27
449
+ }, this) : /*#__PURE__*/ _jsxDEV(ShimmerEffect, {
393
450
  height: "15px",
394
451
  width: "40px"
395
- }),
396
- isEditable ? /*#__PURE__*/ _jsxs("div", {
452
+ }, void 0, false, {
453
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
454
+ lineNumber: 473,
455
+ columnNumber: 39
456
+ }, this),
457
+ isEditable ? /*#__PURE__*/ _jsxDEV("div", {
397
458
  className: `${baseClass}__actions`,
398
459
  children: [
399
- /*#__PURE__*/ _jsx(EditButton, {}),
400
- /*#__PURE__*/ _jsx(RemoveButton, {})
460
+ /*#__PURE__*/ _jsxDEV(EditButton, {}, void 0, false, {
461
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
462
+ lineNumber: 476,
463
+ columnNumber: 15
464
+ }, this),
465
+ /*#__PURE__*/ _jsxDEV(RemoveButton, {}, void 0, false, {
466
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
467
+ lineNumber: 477,
468
+ columnNumber: 15
469
+ }, this)
401
470
  ]
402
- }) : null
471
+ }, void 0, true, {
472
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
473
+ lineNumber: 475,
474
+ columnNumber: 13
475
+ }, this) : null
403
476
  ]
404
- })
477
+ }, void 0, true, {
478
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
479
+ lineNumber: 472,
480
+ columnNumber: 9
481
+ }, this)
405
482
  ]
406
- });
483
+ }, void 0, true, {
484
+ fileName: "src/features/blocks/client/componentInline/index.tsx",
485
+ lineNumber: 416,
486
+ columnNumber: 5
487
+ }, this);
407
488
  };
408
489
 
409
490
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly className: string\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, className: baseClass, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n return Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\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 renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n isEditable,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","createContext","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","use","InlineBlockComponent","props","cacheBuster","className","baseClass","formData","nodeKey","editor","isEditable","i18n","t","createdInlineBlock","fieldProps","featureClientSchemaMap","initialLexicalFormState","schemaPath","setCreatedInlineBlock","uuidFromContext","fields","parentDocumentFields","getFormState","editDepth","firstTimeDrawer","setInitialState","useState","cachedFormState","id","formState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","collectionSlug","getDocPreferences","globalSlug","config","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","clientBlockFields","getKey","length","undefined","removeInlineBlock","update","remove","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","initialBlockFormState","operation","readOnly","renderAllFields","signal","newFormStateData","node","newData","setFields","onChange","prevFormState","submit","controller","isStateOutOfSync","keys","some","key","onFormSubmit","RemoveButton","buttonStyle","disabled","icon","onClick","e","preventDefault","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","div","filter","Boolean","join","ref","Label","span","beforeSubmit","disableValidationOnSubmit","onSubmit","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","height","width"],"mappings":"AAAA;;AAIA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AOC,OAAM;;oBAC9D/H,2BACC,MAAC6G;wBAAIlH,WAAW,GAAGC,UAAU,SAAS,CAAC;;0CACrC,KAAC6G;0CACD,KAACX;;yBAED;;;;;AAKd,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly className: string\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, className: baseClass, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n return Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n isEditable,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\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 renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n isEditable,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","createContext","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","use","InlineBlockComponent","props","cacheBuster","className","baseClass","formData","nodeKey","editor","isEditable","i18n","t","createdInlineBlock","fieldProps","featureClientSchemaMap","initialLexicalFormState","schemaPath","setCreatedInlineBlock","uuidFromContext","fields","parentDocumentFields","getFormState","editDepth","firstTimeDrawer","setInitialState","useState","cachedFormState","id","formState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","collectionSlug","getDocPreferences","globalSlug","config","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","clientBlockFields","getKey","length","undefined","removeInlineBlock","update","remove","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","initialBlockFormState","operation","readOnly","renderAllFields","signal","newFormStateData","node","newData","setFields","onChange","prevFormState","submit","controller","isStateOutOfSync","keys","some","key","onFormSubmit","RemoveButton","buttonStyle","disabled","icon","onClick","e","preventDefault","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","div","filter","Boolean","join","ref","Label","span","beforeSubmit","disableValidationOnSubmit","onSubmit","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","height","width"],"mappings":"AAAA;;AAIA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,aAAa,QAAQ,UAAS;AAEvC,OAAO,eAAc;AAErB,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ,iBAAgB;AACjG,OAAOC,SAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AACrF,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAIjC,SAASC,sBAAsB,QAAQ,4DAA2D;AAClG,SAASC,gBAAgB,QAAQ,yDAAwD;AACzF,SAASC,kBAAkB,QAAQ,+BAA8B;AAG/D;;;;GAIC,GAgBH,MAAMC,4CAA8BV,cAA+C;IACjFW,cAAc;AAChB;AAEA,OAAO,MAAMC,iCAAiC,IAAMb,MAAMc,GAAG,CAACH,6BAA4B;AAE1F,OAAO,MAAMI,uBAAwC,CAACC;IACpD,MAAM,EAAEC,W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oB5D,EAAE;oBAC/B;8BAECb,6BACC;;0CACE,QAACxB;gCACC6C,QAAQyC,aAAazC;gCACrB8G,WAAW;gCACXC,iBAAgB;gCAChBC,YAAW;gCAAG,+DAA+D;gCAC7EC,kBAAkBxD;gCAClByD,aAAa;gCACb9C,UAAU,CAAC9E;;;;;;0CAEb,QAACpC;gCAAWiK,oBAAoB;0CAAO3H,EAAE;;;;;;;uCAEzC;;;;;;;;;;;YAGPiC,4BACC,QAAC/C;gBACCuC,OAAO;oBACL8E;oBACApH;oBACAsH;oBACAO;oBACApH;oBACAgG;gBACF;0BAEC3D;;;;;qCAGH,QAACwE;;oBACEtH,6BAAe,QAAC6H;;;;6CAAW,QAACpJ;wBAAcgK,QAAO;wBAAOC,OAAM;;;;;;oBAC9D/H,2BACC,QAAC6G;wBAAIlH,WAAW,GAAGC,UAAU,SAAS,CAAC;;0CACrC,QAAC6G;;;;;0CACD,QAACX;;;;;;;;;;+BAED;;;;;;;;;;;;;AAKd,EAAC"}
@@ -0,0 +1,90 @@
1
+ @import '~@payloadcms/ui/scss';
2
+
3
+ @layer payload-default {
4
+ .LexicalEditorTheme__inlineBlock {
5
+ @extend %body;
6
+ @include shadow-sm;
7
+ display: inline-block;
8
+ margin-right: base(0.2);
9
+ margin-left: base(0.2);
10
+ padding: base(0.1);
11
+ padding-inline-start: base(0.4);
12
+ background: var(--theme-input-bg);
13
+ outline: 1px solid var(--theme-elevation-100);
14
+ border-radius: $style-radius-s;
15
+ max-width: calc(var(--base) * 15);
16
+ font-family: var(--font-body);
17
+
18
+ &__container {
19
+ display: flex;
20
+ align-items: center;
21
+ }
22
+
23
+ &-not-found {
24
+ max-width: calc(var(--base) * 20);
25
+ color: var(--theme-error-500);
26
+ }
27
+
28
+ &::selection {
29
+ background: transparent;
30
+ }
31
+
32
+ &:hover {
33
+ outline: 1px solid var(--theme-elevation-150);
34
+ }
35
+
36
+ &__wrap {
37
+ flex-grow: 1;
38
+ overflow: hidden;
39
+ }
40
+
41
+ &__editButton.btn {
42
+ margin: 0;
43
+ }
44
+
45
+ &__editButton {
46
+ &:disabled {
47
+ color: var(--theme-elevation-300);
48
+ pointer-events: none;
49
+ }
50
+ }
51
+
52
+ &__actions {
53
+ display: flex;
54
+ align-items: center;
55
+ flex-shrink: 0;
56
+ margin-left: base(0.4);
57
+
58
+ & > .btn {
59
+ width: base(1);
60
+ height: base(1);
61
+
62
+ &:not(:disabled):hover {
63
+ background: var(--theme-elevation-100);
64
+ }
65
+
66
+ & > * {
67
+ height: 100%;
68
+ }
69
+ }
70
+
71
+ svg {
72
+ width: 16px;
73
+ height: 16px;
74
+ }
75
+ }
76
+
77
+ &__removeButton.btn {
78
+ margin: 0;
79
+
80
+ line {
81
+ stroke-width: base(0.2);
82
+ }
83
+
84
+ &:disabled {
85
+ color: var(--theme-elevation-300);
86
+ pointer-events: none;
87
+ }
88
+ }
89
+ }
90
+ }
@@ -1,11 +1,11 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
2
2
  import React from 'react';
3
3
  import { BlockIcon } from '../../../lexical/ui/icons/Block/index.js';
4
4
  export function getBlockImageComponent(imageURL, imageAltText) {
5
5
  if (!imageURL) {
6
6
  return BlockIcon;
7
7
  }
8
- return ()=>/*#__PURE__*/ _jsx("img", {
8
+ return ()=>/*#__PURE__*/ _jsxDEV("img", {
9
9
  alt: imageAltText ?? 'Block Image',
10
10
  className: "lexical-block-custom-image",
11
11
  src: imageURL,
@@ -13,7 +13,11 @@ export function getBlockImageComponent(imageURL, imageAltText) {
13
13
  maxHeight: 20,
14
14
  maxWidth: 20
15
15
  }
16
- });
16
+ }, void 0, false, {
17
+ fileName: "src/features/blocks/client/getBlockImageComponent.tsx",
18
+ lineNumber: 11,
19
+ columnNumber: 5
20
+ }, this);
17
21
  }
18
22
 
19
23
  //# sourceMappingURL=getBlockImageComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/blocks/client/getBlockImageComponent.tsx"],"sourcesContent":["import React from 'react'\n\nimport { BlockIcon } from '../../../lexical/ui/icons/Block/index.js'\n\nexport function getBlockImageComponent(imageURL?: string, imageAltText?: string) {\n if (!imageURL) {\n return BlockIcon\n }\n\n return () => (\n <img\n alt={imageAltText ?? 'Block Image'}\n className=\"lexical-block-custom-image\"\n src={imageURL}\n style={{ maxHeight: 20, maxWidth: 20 }}\n />\n )\n}\n"],"names":["React","BlockIcon","getBlockImageComponent","imageURL","imageAltText","img","alt","className","src","style","maxHeight","maxWidth"],"mappings":";AAAA,OAAOA,WAAW,QAAO;AAEzB,SAASC,SAAS,QAAQ,2CAA0C;AAEpE,OAAO,SAASC,uBAAuBC,QAAiB,EAAEC,YAAqB;IAC7E,IAAI,CAACD,UAAU;QACb,OAAOF;IACT;IAEA,OAAO,kBACL,KAACI;YACCC,KAAKF,gBAAgB;YACrBG,WAAU;YACVC,KAAKL;YACLM,OAAO;gBAAEC,WAAW;gBAAIC,UAAU;YAAG;;AAG3C"}
1
+ {"version":3,"sources":["../../../../src/features/blocks/client/getBlockImageComponent.tsx"],"sourcesContent":["import React from 'react'\n\nimport { BlockIcon } from '../../../lexical/ui/icons/Block/index.js'\n\nexport function getBlockImageComponent(imageURL?: string, imageAltText?: string) {\n if (!imageURL) {\n return BlockIcon\n }\n\n return () => (\n <img\n alt={imageAltText ?? 'Block Image'}\n className=\"lexical-block-custom-image\"\n src={imageURL}\n style={{ maxHeight: 20, maxWidth: 20 }}\n />\n )\n}\n"],"names":["React","BlockIcon","getBlockImageComponent","imageURL","imageAltText","img","alt","className","src","style","maxHeight","maxWidth"],"mappings":";AAAA,OAAOA,WAAW,QAAO;AAEzB,SAASC,SAAS,QAAQ,2CAA0C;AAEpE,OAAO,SAASC,uBAAuBC,QAAiB,EAAEC,YAAqB;IAC7E,IAAI,CAACD,UAAU;QACb,OAAOF;IACT;IAEA,OAAO,kBACL,QAACI;YACCC,KAAKF,gBAAgB;YACrBG,WAAU;YACVC,KAAKL;YACLM,OAAO;gBAAEC,WAAW;gBAAIC,UAAU;YAAG;;;;;;AAG3C"}
@@ -276,6 +276,7 @@ function getMarkdownTransformerForBlock(block, isInlineBlock) {
276
276
  const children = $parseSerializedNode(nextNodes[0])?.getChildren();
277
277
  if (children?.length) {
278
278
  for (const child of children){
279
+ ;
279
280
  lastChild.append(child);
280
281
  }
281
282
  }