@payloadcms/richtext-lexical 4.0.0-internal.2fddfc0 → 4.0.0-internal.3aa3d85

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 (302) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/exports/client/Field-XH5C4HFU.js +2 -0
  3. package/dist/exports/client/Field-XH5C4HFU.js.map +7 -0
  4. package/dist/exports/client/bundled.css +1 -1
  5. package/dist/exports/client/chunk-X3D4LZS7.js +2 -0
  6. package/dist/exports/client/chunk-X3D4LZS7.js.map +7 -0
  7. package/dist/exports/client/index.d.ts +0 -2
  8. package/dist/exports/client/index.d.ts.map +1 -1
  9. package/dist/exports/client/index.js +24 -25
  10. package/dist/exports/client/index.js.map +4 -4
  11. package/dist/features/blockquote/client/index.js +2 -2
  12. package/dist/features/blockquote/client/index.js.map +1 -1
  13. package/dist/features/blockquote/server/index.js +2 -2
  14. package/dist/features/blockquote/server/index.js.map +1 -1
  15. package/dist/features/blocks/client/component/index.css +2 -2
  16. package/dist/features/blocks/client/componentInline/index.css +8 -8
  17. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
  18. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
  19. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
  20. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
  21. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
  22. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
  23. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +5 -2
  24. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
  25. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +1 -2
  26. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
  27. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
  28. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.css +1 -1
  29. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.css +2 -4
  30. package/dist/features/blocks/premade/CodeBlock/Component/index.css +5 -5
  31. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
  32. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
  33. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
  34. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  35. package/dist/features/blocks/server/schema.js +3 -2
  36. package/dist/features/blocks/server/schema.js.map +1 -1
  37. package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
  38. package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
  39. package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
  40. package/dist/features/converters/markdownToLexical/index.d.ts.map +1 -1
  41. package/dist/features/converters/markdownToLexical/index.js +5 -2
  42. package/dist/features/converters/markdownToLexical/index.js.map +1 -1
  43. package/dist/features/debug/jsxConverter/client/plugin/style.css +2 -2
  44. package/dist/features/experimental_table/client/index.js +2 -2
  45. package/dist/features/experimental_table/client/index.js.map +1 -1
  46. package/dist/features/experimental_table/markdownTransformer.d.ts +2 -2
  47. package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
  48. package/dist/features/experimental_table/markdownTransformer.js +6 -3
  49. package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
  50. package/dist/features/experimental_table/server/index.js +2 -2
  51. package/dist/features/experimental_table/server/index.js.map +1 -1
  52. package/dist/features/format/bold/feature.client.js +1 -1
  53. package/dist/features/format/bold/feature.client.js.map +1 -1
  54. package/dist/features/format/bold/feature.server.d.ts.map +1 -1
  55. package/dist/features/format/bold/feature.server.js +1 -1
  56. package/dist/features/format/bold/feature.server.js.map +1 -1
  57. package/dist/features/format/inlineCode/feature.client.js +1 -1
  58. package/dist/features/format/inlineCode/feature.client.js.map +1 -1
  59. package/dist/features/format/inlineCode/feature.server.d.ts.map +1 -1
  60. package/dist/features/format/inlineCode/feature.server.js +1 -1
  61. package/dist/features/format/inlineCode/feature.server.js.map +1 -1
  62. package/dist/features/format/italic/feature.client.js +1 -1
  63. package/dist/features/format/italic/feature.client.js.map +1 -1
  64. package/dist/features/format/italic/feature.server.d.ts.map +1 -1
  65. package/dist/features/format/italic/feature.server.js +1 -1
  66. package/dist/features/format/italic/feature.server.js.map +1 -1
  67. package/dist/features/format/strikethrough/feature.client.js +1 -1
  68. package/dist/features/format/strikethrough/feature.client.js.map +1 -1
  69. package/dist/features/format/strikethrough/feature.server.d.ts.map +1 -1
  70. package/dist/features/format/strikethrough/feature.server.js +1 -1
  71. package/dist/features/format/strikethrough/feature.server.js.map +1 -1
  72. package/dist/features/heading/client/index.js +2 -2
  73. package/dist/features/heading/client/index.js.map +1 -1
  74. package/dist/features/heading/markdownTransformer.d.ts +2 -2
  75. package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
  76. package/dist/features/heading/markdownTransformer.js +6 -19
  77. package/dist/features/heading/markdownTransformer.js.map +1 -1
  78. package/dist/features/heading/server/index.js +2 -2
  79. package/dist/features/heading/server/index.js.map +1 -1
  80. package/dist/features/horizontalRule/client/index.js +2 -2
  81. package/dist/features/horizontalRule/client/index.js.map +1 -1
  82. package/dist/features/horizontalRule/client/markdownTransformer.d.ts +2 -2
  83. package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
  84. package/dist/features/horizontalRule/client/markdownTransformer.js +1 -1
  85. package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
  86. package/dist/features/horizontalRule/client/plugin/index.css +2 -2
  87. package/dist/features/horizontalRule/server/index.js +2 -2
  88. package/dist/features/horizontalRule/server/index.js.map +1 -1
  89. package/dist/features/horizontalRule/server/markdownTransformer.d.ts +2 -2
  90. package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
  91. package/dist/features/horizontalRule/server/markdownTransformer.js +1 -1
  92. package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
  93. package/dist/features/link/client/index.js +2 -2
  94. package/dist/features/link/client/index.js.map +1 -1
  95. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -3
  96. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  97. package/dist/features/link/client/plugins/floatingLinkEditor/index.css +7 -11
  98. package/dist/features/link/markdownTransformer.d.ts +4 -4
  99. package/dist/features/link/markdownTransformer.d.ts.map +1 -1
  100. package/dist/features/link/markdownTransformer.js +2 -2
  101. package/dist/features/link/markdownTransformer.js.map +1 -1
  102. package/dist/features/link/markdownTransformer.spec.js +10 -10
  103. package/dist/features/link/markdownTransformer.spec.js.map +1 -1
  104. package/dist/features/link/server/baseFields.js.map +1 -1
  105. package/dist/features/link/server/index.js +2 -2
  106. package/dist/features/link/server/index.js.map +1 -1
  107. package/dist/features/link/server/schema.d.ts.map +1 -1
  108. package/dist/features/link/server/schema.js +4 -2
  109. package/dist/features/link/server/schema.js.map +1 -1
  110. package/dist/features/lists/checklist/client/index.js +1 -1
  111. package/dist/features/lists/checklist/client/index.js.map +1 -1
  112. package/dist/features/lists/checklist/server/index.js +1 -1
  113. package/dist/features/lists/checklist/server/index.js.map +1 -1
  114. package/dist/features/lists/orderedList/client/index.js +1 -1
  115. package/dist/features/lists/orderedList/client/index.js.map +1 -1
  116. package/dist/features/lists/orderedList/server/index.js +1 -1
  117. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  118. package/dist/features/lists/unorderedList/client/index.js +1 -1
  119. package/dist/features/lists/unorderedList/client/index.js.map +1 -1
  120. package/dist/features/lists/unorderedList/server/index.js +1 -1
  121. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  122. package/dist/features/relationship/server/schema.d.ts +3 -3
  123. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  124. package/dist/features/relationship/server/schema.js +22 -5
  125. package/dist/features/relationship/server/schema.js.map +1 -1
  126. package/dist/features/textState/feature.client.js +1 -1
  127. package/dist/features/textState/feature.client.js.map +1 -1
  128. package/dist/features/toolbars/fixed/client/Toolbar/index.css +2 -2
  129. package/dist/features/toolbars/inline/client/Toolbar/index.css +2 -13
  130. package/dist/features/toolbars/shared/ToolbarDropdown/index.css +8 -12
  131. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  132. package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
  133. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  134. package/dist/features/typesClient.d.ts +1 -1
  135. package/dist/features/typesClient.d.ts.map +1 -1
  136. package/dist/features/typesClient.js.map +1 -1
  137. package/dist/features/typesServer.d.ts +2 -2
  138. package/dist/features/typesServer.d.ts.map +1 -1
  139. package/dist/features/typesServer.js.map +1 -1
  140. package/dist/features/upload/client/component/index.css +9 -9
  141. package/dist/features/upload/client/plugin/index.js +5 -5
  142. package/dist/features/upload/client/plugin/index.js.map +1 -1
  143. package/dist/features/upload/server/index.js +2 -2
  144. package/dist/features/upload/server/index.js.map +1 -1
  145. package/dist/features/upload/server/markdownTransformer.d.ts +2 -2
  146. package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
  147. package/dist/features/upload/server/markdownTransformer.js +1 -1
  148. package/dist/features/upload/server/markdownTransformer.js.map +1 -1
  149. package/dist/features/upload/server/schema.d.ts +4 -4
  150. package/dist/features/upload/server/schema.d.ts.map +1 -1
  151. package/dist/features/upload/server/schema.js +26 -6
  152. package/dist/features/upload/server/schema.js.map +1 -1
  153. package/dist/field/Diff/converters/unknown/index.css +1 -1
  154. package/dist/field/Field.js +1 -1
  155. package/dist/field/Field.js.map +1 -1
  156. package/dist/field/ViewSelector.css +1 -1
  157. package/dist/field/bundled.css +1 -1
  158. package/dist/field/index.css +11 -11
  159. package/dist/index.d.ts +2 -2
  160. package/dist/index.d.ts.map +1 -1
  161. package/dist/index.js +7 -50
  162. package/dist/index.js.map +1 -1
  163. package/dist/lexical/LexicalEditor.css +2 -2
  164. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  165. package/dist/lexical/LexicalEditor.js +2 -36
  166. package/dist/lexical/LexicalEditor.js.map +1 -1
  167. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  168. package/dist/lexical/LexicalProvider.js +7 -22
  169. package/dist/lexical/LexicalProvider.js.map +1 -1
  170. package/dist/lexical/plugins/DecoratorPlugin/index.css +1 -1
  171. package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
  172. package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
  173. package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
  174. package/dist/lexical/plugins/SlashMenu/index.css +1 -5
  175. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.css +1 -1
  176. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +3 -3
  177. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +1 -1
  178. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  179. package/dist/lexical/theme/EditorTheme.css +18 -19
  180. package/dist/lexical/ui/ContentEditable.css +5 -5
  181. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts +17 -0
  182. package/dist/lexical/utils/markdown/convertFromMarkdownString.d.ts.map +1 -0
  183. package/dist/lexical/utils/markdown/convertFromMarkdownString.js +27 -0
  184. package/dist/lexical/utils/markdown/convertFromMarkdownString.js.map +1 -0
  185. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js +88 -0
  186. package/dist/lexical/utils/markdown/convertFromMarkdownString.spec.js.map +1 -0
  187. package/dist/lexical/utils/markdown/createBlockNode.d.ts +1 -1
  188. package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
  189. package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
  190. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +25 -0
  191. package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +1 -0
  192. package/dist/lexical/utils/markdown/normalizeMarkdown.js +91 -0
  193. package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +1 -0
  194. package/dist/lexical-proxy/@lexical-markdown.d.ts +1 -1
  195. package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
  196. package/dist/lexical-proxy/@lexical-markdown.js +1 -1
  197. package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
  198. package/dist/types/schema.d.ts.map +1 -1
  199. package/dist/types/schema.js +12 -5
  200. package/dist/types/schema.js.map +1 -1
  201. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  202. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  203. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  204. package/dist/utilities/generateImportMap.js +3 -7
  205. package/dist/utilities/generateImportMap.js.map +1 -1
  206. package/package.json +22 -27
  207. package/dist/@types/assets.d.js +0 -2
  208. package/dist/@types/assets.d.js.map +0 -1
  209. package/dist/exports/client/Field-VW7ZGT6K.js +0 -2
  210. package/dist/exports/client/Field-VW7ZGT6K.js.map +0 -7
  211. package/dist/exports/client/chunk-4EIYXZ6H.js +0 -12
  212. package/dist/exports/client/chunk-4EIYXZ6H.js.map +0 -7
  213. package/dist/exports/server/rsc.browser.d.ts +0 -11
  214. package/dist/exports/server/rsc.browser.d.ts.map +0 -1
  215. package/dist/exports/server/rsc.browser.js +0 -10
  216. package/dist/exports/server/rsc.browser.js.map +0 -1
  217. package/dist/features/blockquote/markdownTransformer.d.ts +0 -3
  218. package/dist/features/blockquote/markdownTransformer.d.ts.map +0 -1
  219. package/dist/features/blockquote/markdownTransformer.js +0 -33
  220. package/dist/features/blockquote/markdownTransformer.js.map +0 -1
  221. package/dist/features/format/bold/markdownTransformers.d.ts +0 -6
  222. package/dist/features/format/bold/markdownTransformers.d.ts.map +0 -1
  223. package/dist/features/format/bold/markdownTransformers.js +0 -23
  224. package/dist/features/format/bold/markdownTransformers.js.map +0 -1
  225. package/dist/features/format/inlineCode/markdownTransformers.d.ts +0 -3
  226. package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +0 -1
  227. package/dist/features/format/inlineCode/markdownTransformers.js +0 -6
  228. package/dist/features/format/inlineCode/markdownTransformers.js.map +0 -1
  229. package/dist/features/format/italic/markdownTransformers.d.ts +0 -4
  230. package/dist/features/format/italic/markdownTransformers.d.ts.map +0 -1
  231. package/dist/features/format/italic/markdownTransformers.js +0 -12
  232. package/dist/features/format/italic/markdownTransformers.js.map +0 -1
  233. package/dist/features/format/strikethrough/markdownTransformers.d.ts +0 -3
  234. package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +0 -1
  235. package/dist/features/format/strikethrough/markdownTransformers.js +0 -6
  236. package/dist/features/format/strikethrough/markdownTransformers.js.map +0 -1
  237. package/dist/features/lists/checklist/markdownTransformers.d.ts +0 -3
  238. package/dist/features/lists/checklist/markdownTransformers.d.ts.map +0 -1
  239. package/dist/features/lists/checklist/markdownTransformers.js +0 -12
  240. package/dist/features/lists/checklist/markdownTransformers.js.map +0 -1
  241. package/dist/features/lists/orderedList/markdownTransformer.d.ts +0 -3
  242. package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +0 -1
  243. package/dist/features/lists/orderedList/markdownTransformer.js +0 -12
  244. package/dist/features/lists/orderedList/markdownTransformer.js.map +0 -1
  245. package/dist/features/lists/shared/markdown.d.ts +0 -6
  246. package/dist/features/lists/shared/markdown.d.ts.map +0 -1
  247. package/dist/features/lists/shared/markdown.js +0 -57
  248. package/dist/features/lists/shared/markdown.js.map +0 -1
  249. package/dist/features/lists/unorderedList/markdownTransformer.d.ts +0 -3
  250. package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +0 -1
  251. package/dist/features/lists/unorderedList/markdownTransformer.js +0 -12
  252. package/dist/features/lists/unorderedList/markdownTransformer.js.map +0 -1
  253. package/dist/field/clientEntry.d.ts +0 -29
  254. package/dist/field/clientEntry.d.ts.map +0 -1
  255. package/dist/field/clientEntry.js +0 -86
  256. package/dist/field/clientEntry.js.map +0 -1
  257. package/dist/lexical/utils/guard.d.ts +0 -5
  258. package/dist/lexical/utils/guard.d.ts.map +0 -1
  259. package/dist/lexical/utils/guard.js +0 -9
  260. package/dist/lexical/utils/guard.js.map +0 -1
  261. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
  262. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
  263. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
  264. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
  265. package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js +0 -160
  266. package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js.map +0 -1
  267. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +0 -14
  268. package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +0 -1
  269. package/dist/packages/@lexical/markdown/MarkdownExport.js +0 -220
  270. package/dist/packages/@lexical/markdown/MarkdownExport.js.map +0 -1
  271. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +0 -19
  272. package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +0 -1
  273. package/dist/packages/@lexical/markdown/MarkdownImport.js +0 -199
  274. package/dist/packages/@lexical/markdown/MarkdownImport.js.map +0 -1
  275. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +0 -11
  276. package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +0 -1
  277. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +0 -304
  278. package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +0 -1
  279. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +0 -173
  280. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +0 -1
  281. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +0 -352
  282. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +0 -1
  283. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +0 -22
  284. package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +0 -1
  285. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +0 -91
  286. package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +0 -1
  287. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +0 -21
  288. package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +0 -1
  289. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +0 -54
  290. package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +0 -1
  291. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +0 -18
  292. package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +0 -1
  293. package/dist/packages/@lexical/markdown/importTextTransformers.js +0 -54
  294. package/dist/packages/@lexical/markdown/importTextTransformers.js.map +0 -1
  295. package/dist/packages/@lexical/markdown/index.d.ts +0 -29
  296. package/dist/packages/@lexical/markdown/index.d.ts.map +0 -1
  297. package/dist/packages/@lexical/markdown/index.js +0 -39
  298. package/dist/packages/@lexical/markdown/index.js.map +0 -1
  299. package/dist/packages/@lexical/markdown/utils.d.ts +0 -34
  300. package/dist/packages/@lexical/markdown/utils.d.ts.map +0 -1
  301. package/dist/packages/@lexical/markdown/utils.js +0 -267
  302. package/dist/packages/@lexical/markdown/utils.js.map +0 -1
@@ -1,160 +0,0 @@
1
- import { createHeadlessEditor } from '@lexical/headless';
2
- import { LinkNode } from '@lexical/link';
3
- import { ListItemNode, ListNode } from '@lexical/list';
4
- import { HeadingNode, QuoteNode } from '@lexical/rich-text';
5
- import { $getRoot, $getState, $isElementNode, $isLineBreakNode, $isTextNode } from 'lexical';
6
- import { describe, expect, it } from 'vitest';
7
- import { $convertFromMarkdownString, $convertToMarkdownString } from './index.js';
8
- import { hardLineBreakState, normalizeMarkdown } from './MarkdownTransformers.js';
9
- function createEditor() {
10
- return createHeadlessEditor({
11
- nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode]
12
- });
13
- }
14
- function importMarkdown(markdown) {
15
- const editor = createEditor();
16
- editor.update(() => $convertFromMarkdownString(markdown), {
17
- discrete: true
18
- });
19
- let result = {
20
- hasLineBreak: false,
21
- textContent: ''
22
- };
23
- editor.getEditorState().read(() => {
24
- const firstChild = $getRoot().getFirstChild();
25
- if (!$isElementNode(firstChild)) {
26
- throw new Error('Expected an element block');
27
- }
28
- result = {
29
- hasLineBreak: firstChild.getChildren().some(child => $isLineBreakNode(child)),
30
- textContent: firstChild.getTextContent()
31
- };
32
- });
33
- return result;
34
- }
35
- // Returns the hard line break marker stored on the first LineBreakNode of the
36
- // first block, plus the text content of every text node in that block. Used to
37
- // assert the marker was moved off the text and onto the line break node, even
38
- // when the trailing whitespace was split into its own text node by an inline
39
- // transformer (e.g. after bold or a link).
40
- function getStoredHardLineBreak(markdown) {
41
- const editor = createEditor();
42
- editor.update(() => $convertFromMarkdownString(markdown), {
43
- discrete: true
44
- });
45
- let result = {
46
- marker: '',
47
- textNodeTexts: []
48
- };
49
- editor.getEditorState().read(() => {
50
- const block = $getRoot().getFirstChild();
51
- if (!$isElementNode(block)) {
52
- throw new Error('Expected an element block');
53
- }
54
- const lineBreakNode = block.getChildren().find(child => $isLineBreakNode(child));
55
- if (lineBreakNode === undefined) {
56
- throw new Error('Expected a line break node');
57
- }
58
- result = {
59
- marker: $getState(lineBreakNode, hardLineBreakState),
60
- textNodeTexts: block.getChildren().filter($isTextNode).map(child => child.getTextContent())
61
- };
62
- });
63
- return result;
64
- }
65
- function roundTrip(markdown) {
66
- const editor = createEditor();
67
- editor.update(() => $convertFromMarkdownString(markdown), {
68
- discrete: true
69
- });
70
- let output = '';
71
- editor.getEditorState().read(() => {
72
- output = $convertToMarkdownString();
73
- });
74
- return output;
75
- }
76
- describe('markdown hard line break normalization', () => {
77
- it('should preserve trailing-space hard breaks when merging adjacent lines', () => {
78
- const md = ['foo ', 'bar'].join('\n');
79
- expect(normalizeMarkdown(md, true)).toBe(md);
80
- });
81
- it('should preserve the exact number of trailing spaces', () => {
82
- const md = ['foo ', 'bar'].join('\n');
83
- expect(normalizeMarkdown(md, true)).toBe(md);
84
- });
85
- it('should preserve backslash hard breaks when merging adjacent lines', () => {
86
- const md = 'foo\\\nbar';
87
- expect(normalizeMarkdown(md, true)).toBe(md);
88
- });
89
- it('should still merge a soft break into the previous line', () => {
90
- const md = ['foo', 'bar'].join('\n');
91
- expect(normalizeMarkdown(md, true)).toBe('foo bar');
92
- });
93
- it('should merge a soft break before a hard-breaking line', () => {
94
- const md = ['foo', 'bar ', 'baz'].join('\n');
95
- expect(normalizeMarkdown(md, true)).toBe(['foo bar ', 'baz'].join('\n'));
96
- });
97
- });
98
- describe('markdown hard line break import', () => {
99
- it('should import a trailing-space hard break as a line break node with the marker stripped', () => {
100
- const {
101
- hasLineBreak,
102
- textContent
103
- } = importMarkdown(['foo ', 'bar'].join('\n'));
104
- expect(hasLineBreak).toBe(true);
105
- // The marker is stripped from the text and represented by the line break node.
106
- expect(textContent).toBe('foo\nbar');
107
- });
108
- it('should import a backslash hard break as a line break node with the marker stripped', () => {
109
- const {
110
- hasLineBreak,
111
- textContent
112
- } = importMarkdown('foo\\\nbar');
113
- expect(hasLineBreak).toBe(true);
114
- expect(textContent).toBe('foo\nbar');
115
- });
116
- it('should store the marker on the line break when the hard break follows formatted text', () => {
117
- const {
118
- marker,
119
- textNodeTexts
120
- } = getStoredHardLineBreak('**foo** \nbar');
121
- expect(marker).toBe(' ');
122
- // The trailing-space marker is split into its own text node by the bold
123
- // transformer; it must be moved onto the line break node, not left as text.
124
- expect(textNodeTexts).not.toContain(' ');
125
- });
126
- it('should store the exact number of trailing spaces when the hard break follows formatted text', () => {
127
- const {
128
- marker
129
- } = getStoredHardLineBreak('**foo** \nbar');
130
- expect(marker).toBe(' ');
131
- });
132
- it('should store the marker on the line break when the hard break follows a link', () => {
133
- const {
134
- marker
135
- } = getStoredHardLineBreak('[foo](https://payloadcms.com) \nbar');
136
- expect(marker).toBe(' ');
137
- });
138
- });
139
- describe('markdown hard line break round trip', () => {
140
- it('should round trip a trailing-space hard break', () => {
141
- const md = ['foo ', 'bar'].join('\n');
142
- expect(roundTrip(md)).toBe(md);
143
- });
144
- it('should round trip a backslash hard break', () => {
145
- const md = 'foo\\\nbar';
146
- expect(roundTrip(md)).toBe(md);
147
- });
148
- it('should not introduce a hard break for a soft wrap', () => {
149
- expect(roundTrip(['foo', 'bar'].join('\n'))).toBe('foo bar');
150
- });
151
- it('should round trip a hard break after formatted text', () => {
152
- const md = '**foo** \nbar';
153
- expect(roundTrip(md)).toBe(md);
154
- });
155
- it('should round trip a hard break after a link', () => {
156
- const md = '[foo](https://payloadcms.com) \nbar';
157
- expect(roundTrip(md)).toBe(md);
158
- });
159
- });
160
- //# sourceMappingURL=LexicalMarkdownHardLineBreak.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LexicalMarkdownHardLineBreak.spec.js","names":["createHeadlessEditor","LinkNode","ListItemNode","ListNode","HeadingNode","QuoteNode","$getRoot","$getState","$isElementNode","$isLineBreakNode","$isTextNode","describe","expect","it","$convertFromMarkdownString","$convertToMarkdownString","hardLineBreakState","normalizeMarkdown","createEditor","nodes","importMarkdown","markdown","editor","update","discrete","result","hasLineBreak","textContent","getEditorState","read","firstChild","getFirstChild","Error","getChildren","some","child","getTextContent","getStoredHardLineBreak","marker","textNodeTexts","block","lineBreakNode","find","undefined","filter","map","roundTrip","output","md","join","toBe","not","toContain"],"sources":["../../../../src/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless'\nimport { LinkNode } from '@lexical/link'\nimport { ListItemNode, ListNode } from '@lexical/list'\nimport { HeadingNode, QuoteNode } from '@lexical/rich-text'\nimport { $getRoot, $getState, $isElementNode, $isLineBreakNode, $isTextNode } from 'lexical'\nimport { describe, expect, it } from 'vitest'\n\nimport { $convertFromMarkdownString, $convertToMarkdownString } from './index.js'\nimport { hardLineBreakState, normalizeMarkdown } from './MarkdownTransformers.js'\n\nfunction createEditor() {\n return createHeadlessEditor({\n nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, LinkNode],\n })\n}\n\nfunction importMarkdown(markdown: string): { hasLineBreak: boolean; textContent: string } {\n const editor = createEditor()\n editor.update(() => $convertFromMarkdownString(markdown), { discrete: true })\n let result = { hasLineBreak: false, textContent: '' }\n editor.getEditorState().read(() => {\n const firstChild = $getRoot().getFirstChild()\n if (!$isElementNode(firstChild)) {\n throw new Error('Expected an element block')\n }\n result = {\n hasLineBreak: firstChild.getChildren().some((child) => $isLineBreakNode(child)),\n textContent: firstChild.getTextContent(),\n }\n })\n return result\n}\n\n// Returns the hard line break marker stored on the first LineBreakNode of the\n// first block, plus the text content of every text node in that block. Used to\n// assert the marker was moved off the text and onto the line break node, even\n// when the trailing whitespace was split into its own text node by an inline\n// transformer (e.g. after bold or a link).\nfunction getStoredHardLineBreak(markdown: string): {\n marker: string\n textNodeTexts: string[]\n} {\n const editor = createEditor()\n editor.update(() => $convertFromMarkdownString(markdown), { discrete: true })\n let result = { marker: '', textNodeTexts: [] as string[] }\n editor.getEditorState().read(() => {\n const block = $getRoot().getFirstChild()\n if (!$isElementNode(block)) {\n throw new Error('Expected an element block')\n }\n const lineBreakNode = block.getChildren().find((child) => $isLineBreakNode(child))\n if (lineBreakNode === undefined) {\n throw new Error('Expected a line break node')\n }\n result = {\n marker: $getState(lineBreakNode, hardLineBreakState),\n textNodeTexts: block\n .getChildren()\n .filter($isTextNode)\n .map((child) => child.getTextContent()),\n }\n })\n return result\n}\n\nfunction roundTrip(markdown: string): string {\n const editor = createEditor()\n editor.update(() => $convertFromMarkdownString(markdown), { discrete: true })\n let output = ''\n editor.getEditorState().read(() => {\n output = $convertToMarkdownString()\n })\n return output\n}\n\ndescribe('markdown hard line break normalization', () => {\n it('should preserve trailing-space hard breaks when merging adjacent lines', () => {\n const md = ['foo ', 'bar'].join('\\n')\n expect(normalizeMarkdown(md, true)).toBe(md)\n })\n\n it('should preserve the exact number of trailing spaces', () => {\n const md = ['foo ', 'bar'].join('\\n')\n expect(normalizeMarkdown(md, true)).toBe(md)\n })\n\n it('should preserve backslash hard breaks when merging adjacent lines', () => {\n const md = 'foo\\\\\\nbar'\n expect(normalizeMarkdown(md, true)).toBe(md)\n })\n\n it('should still merge a soft break into the previous line', () => {\n const md = ['foo', 'bar'].join('\\n')\n expect(normalizeMarkdown(md, true)).toBe('foo bar')\n })\n\n it('should merge a soft break before a hard-breaking line', () => {\n const md = ['foo', 'bar ', 'baz'].join('\\n')\n expect(normalizeMarkdown(md, true)).toBe(['foo bar ', 'baz'].join('\\n'))\n })\n})\n\ndescribe('markdown hard line break import', () => {\n it('should import a trailing-space hard break as a line break node with the marker stripped', () => {\n const { hasLineBreak, textContent } = importMarkdown(['foo ', 'bar'].join('\\n'))\n\n expect(hasLineBreak).toBe(true)\n // The marker is stripped from the text and represented by the line break node.\n expect(textContent).toBe('foo\\nbar')\n })\n\n it('should import a backslash hard break as a line break node with the marker stripped', () => {\n const { hasLineBreak, textContent } = importMarkdown('foo\\\\\\nbar')\n\n expect(hasLineBreak).toBe(true)\n expect(textContent).toBe('foo\\nbar')\n })\n\n it('should store the marker on the line break when the hard break follows formatted text', () => {\n const { marker, textNodeTexts } = getStoredHardLineBreak('**foo** \\nbar')\n\n expect(marker).toBe(' ')\n // The trailing-space marker is split into its own text node by the bold\n // transformer; it must be moved onto the line break node, not left as text.\n expect(textNodeTexts).not.toContain(' ')\n })\n\n it('should store the exact number of trailing spaces when the hard break follows formatted text', () => {\n const { marker } = getStoredHardLineBreak('**foo** \\nbar')\n\n expect(marker).toBe(' ')\n })\n\n it('should store the marker on the line break when the hard break follows a link', () => {\n const { marker } = getStoredHardLineBreak('[foo](https://payloadcms.com) \\nbar')\n\n expect(marker).toBe(' ')\n })\n})\n\ndescribe('markdown hard line break round trip', () => {\n it('should round trip a trailing-space hard break', () => {\n const md = ['foo ', 'bar'].join('\\n')\n expect(roundTrip(md)).toBe(md)\n })\n\n it('should round trip a backslash hard break', () => {\n const md = 'foo\\\\\\nbar'\n expect(roundTrip(md)).toBe(md)\n })\n\n it('should not introduce a hard break for a soft wrap', () => {\n expect(roundTrip(['foo', 'bar'].join('\\n'))).toBe('foo bar')\n })\n\n it('should round trip a hard break after formatted text', () => {\n const md = '**foo** \\nbar'\n expect(roundTrip(md)).toBe(md)\n })\n\n it('should round trip a hard break after a link', () => {\n const md = '[foo](https://payloadcms.com) \\nbar'\n expect(roundTrip(md)).toBe(md)\n })\n})\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,QAAQ,QAAQ;AACzB,SAASC,YAAY,EAAEC,QAAQ,QAAQ;AACvC,SAASC,WAAW,EAAEC,SAAS,QAAQ;AACvC,SAASC,QAAQ,EAAEC,SAAS,EAAEC,cAAc,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ;AACnF,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,0BAA0B,EAAEC,wBAAwB,QAAQ;AACrE,SAASC,kBAAkB,EAAEC,iBAAiB,QAAQ;AAEtD,SAASC,aAAA;EACP,OAAOlB,oBAAA,CAAqB;IAC1BmB,KAAA,EAAO,CAACf,WAAA,EAAaC,SAAA,EAAWF,QAAA,EAAUD,YAAA,EAAcD,QAAA;EAC1D;AACF;AAEA,SAASmB,eAAeC,QAAgB;EACtC,MAAMC,MAAA,GAASJ,YAAA;EACfI,MAAA,CAAOC,MAAM,CAAC,MAAMT,0BAAA,CAA2BO,QAAA,GAAW;IAAEG,QAAA,EAAU;EAAK;EAC3E,IAAIC,MAAA,GAAS;IAAEC,YAAA,EAAc;IAAOC,WAAA,EAAa;EAAG;EACpDL,MAAA,CAAOM,cAAc,GAAGC,IAAI,CAAC;IAC3B,MAAMC,UAAA,GAAaxB,QAAA,GAAWyB,aAAa;IAC3C,IAAI,CAACvB,cAAA,CAAesB,UAAA,GAAa;MAC/B,MAAM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AA,GAAK;IACXpC,MAAA,CAAOkC,SAAA,CAAUE,EAAA,GAAKE,IAAI,CAACF,EAAA;EAC7B;EAEAnC,EAAA,CAAG,+CAA+C;IAChD,MAAMmC,EAAA,GAAK;IACXpC,MAAA,CAAOkC,SAAA,CAAUE,EAAA,GAAKE,IAAI,CAACF,EAAA;EAC7B;AACF","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import type { ElementNode } from 'lexical';
9
- import type { Transformer } from './MarkdownTransformers.js';
10
- /**
11
- * Renders string from markdown. The selection is moved to the start after the operation.
12
- */
13
- export declare function createMarkdownExport(transformers: Array<Transformer>, shouldPreserveNewLines?: boolean): (node?: ElementNode) => string;
14
- //# sourceMappingURL=MarkdownExport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownExport.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/MarkdownExport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAwD,MAAM,SAAS,CAAA;AAWhG,OAAO,KAAK,EAKV,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAKlC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,EAChC,sBAAsB,GAAE,OAAe,GACtC,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,MAAM,CAkDhC"}
@@ -1,220 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */import { $getRoot, $getState, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isTextNode } from 'lexical';
8
- import { hardLineBreakState } from './MarkdownTransformers.js';
9
- import { isEmptyParagraph, transformersByType } from './utils.js';
10
- /**
11
- * Renders string from markdown. The selection is moved to the start after the operation.
12
- */
13
- export function createMarkdownExport(transformers, shouldPreserveNewLines = false) {
14
- const byType = transformersByType(transformers);
15
- const elementTransformers = [...byType.multilineElement, ...byType.element];
16
- const isNewlineDelimited = !shouldPreserveNewLines;
17
- // Export only uses text formats that are responsible for single format
18
- // e.g. it will filter out *** (bold, italic) and instead use separate ** and *
19
- const textFormatTransformers = byType.textFormat.filter(transformer => transformer.format.length === 1) // Make sure all text transformers that contain 'code' in their format are at the end of the array. Otherwise, formatted code like
20
- // <strong><code>code</code></strong> will be exported as `**Bold Code**`, as the code format will be applied first, and the bold format
21
- // will be applied second and thus skipped entirely, as the code format will prevent any further formatting.
22
- .sort((a, b) => {
23
- if (a.format.includes('code') && !b.format.includes('code')) {
24
- return 1;
25
- } else if (!a.format.includes('code') && b.format.includes('code')) {
26
- return -1;
27
- } else {
28
- return 0;
29
- }
30
- });
31
- return node => {
32
- const output = [];
33
- const children = (node || $getRoot()).getChildren();
34
- children.forEach((child, i) => {
35
- const result = exportTopLevelElements(child, elementTransformers, textFormatTransformers, byType.textMatch);
36
- if (result != null) {
37
- output.push(
38
- // separate consecutive group of texts with a line break: eg. ["hello", "world"] -> ["hello", "/nworld"]
39
- isNewlineDelimited && i > 0 && !isEmptyParagraph(child) && !isEmptyParagraph(children[i - 1]) ? '\n'.concat(result) : result);
40
- }
41
- });
42
- // Ensure consecutive groups of texts are at least \n\n apart while each empty paragraph render as a newline.
43
- // Eg. ["hello", "", "", "hi", "\nworld"] -> "hello\n\n\nhi\n\nworld"
44
- return output.join('\n');
45
- };
46
- }
47
- function exportTopLevelElements(node, elementTransformers, textTransformersIndex, textMatchTransformers) {
48
- for (const transformer of elementTransformers) {
49
- if (!transformer.export) {
50
- continue;
51
- }
52
- const result = transformer.export(node, _node => exportChildren(_node, textTransformersIndex, textMatchTransformers));
53
- if (result != null) {
54
- return result;
55
- }
56
- }
57
- if ($isElementNode(node)) {
58
- return exportChildren(node, textTransformersIndex, textMatchTransformers);
59
- } else if ($isDecoratorNode(node)) {
60
- return node.getTextContent();
61
- } else {
62
- return null;
63
- }
64
- }
65
- function exportChildren(node, textTransformersIndex, textMatchTransformers, unclosedTags, unclosableTags) {
66
- const output = [];
67
- const children = node.getChildren();
68
- // keep track of unclosed tags from the very beginning
69
- if (!unclosedTags) {
70
- unclosedTags = [];
71
- }
72
- if (!unclosableTags) {
73
- unclosableTags = [];
74
- }
75
- mainLoop: for (const child of children) {
76
- for (const transformer of textMatchTransformers) {
77
- if (!transformer.export) {
78
- continue;
79
- }
80
- const result = transformer.export(child, parentNode => exportChildren(parentNode, textTransformersIndex, textMatchTransformers, unclosedTags,
81
- // Add current unclosed tags to the list of unclosable tags - we don't want nested tags from
82
- // textmatch transformers to close the outer ones, as that may result in invalid markdown.
83
- // E.g. **text [text**](https://lexical.io)
84
- // is invalid markdown, as the closing ** is inside the link.
85
- //
86
- [...unclosableTags, ...unclosedTags]), (textNode, textContent) => exportTextFormat(textNode, textContent, textTransformersIndex, unclosedTags, unclosableTags));
87
- if (result != null) {
88
- output.push(result);
89
- continue mainLoop;
90
- }
91
- }
92
- if ($isLineBreakNode(child)) {
93
- output.push($exportLineBreak(child));
94
- } else if ($isTextNode(child)) {
95
- output.push(exportTextFormat(child, child.getTextContent(), textTransformersIndex, unclosedTags, unclosableTags));
96
- } else if ($isElementNode(child)) {
97
- // empty paragraph returns ""
98
- output.push(exportChildren(child, textTransformersIndex, textMatchTransformers, unclosedTags, unclosableTags));
99
- } else if ($isDecoratorNode(child)) {
100
- output.push(child.getTextContent());
101
- }
102
- }
103
- return output.join('');
104
- }
105
- // Prefixes the newline with the original CommonMark hard line break marker
106
- // (`\` or trailing spaces) when one was preserved on import, otherwise exports a
107
- // plain soft line break.
108
- function $exportLineBreak(node) {
109
- return $getState(node, hardLineBreakState) + '\n';
110
- }
111
- function exportTextFormat(node, textContent, textTransformers,
112
- // unclosed tags include the markdown tags that haven't been closed yet, and their associated formats
113
- unclosedTags, unclosableTags) {
114
- // This function handles the case of a string looking like this: " foo "
115
- // Where it would be invalid markdown to generate: "** foo **"
116
- // We instead want to trim the whitespace out, apply formatting, and then
117
- // bring the whitespace back. So our returned string looks like this: " **foo** "
118
- const frozenString = textContent.trim();
119
- let output = frozenString;
120
- if (!node.hasFormat('code')) {
121
- // Escape any markdown characters in the text content
122
- output = output.replace(/([*_`~\\])/g, '\\$1');
123
- }
124
- // the opening tags to be added to the result
125
- let openingTags = '';
126
- // the closing tags to be added to the result
127
- let closingTagsBefore = '';
128
- let closingTagsAfter = '';
129
- const prevNode = getTextSibling(node, true);
130
- const nextNode = getTextSibling(node, false);
131
- const applied = new Set();
132
- for (const transformer of textTransformers) {
133
- const format = transformer.format[0];
134
- const tag = transformer.tag;
135
- // dedup applied formats
136
- if (hasFormat(node, format) && !applied.has(format)) {
137
- // Multiple tags might be used for the same format (*, _)
138
- applied.add(format);
139
- // append the tag to openningTags, if it's not applied to the previous nodes,
140
- // or the nodes before that (which would result in an unclosed tag)
141
- if (!hasFormat(prevNode, format) || !unclosedTags.find(element => element.tag === tag)) {
142
- unclosedTags.push({
143
- format,
144
- tag
145
- });
146
- openingTags += tag;
147
- }
148
- }
149
- }
150
- // close any tags in the same order they were applied, if necessary
151
- for (let i = 0; i < unclosedTags.length; i++) {
152
- const unclosedTag = unclosedTags[i];
153
- const nodeHasFormat = hasFormat(node, unclosedTag.format);
154
- const nextNodeHasFormat = hasFormat(nextNode, unclosedTag.format);
155
- // prevent adding closing tag if next sibling will do it
156
- if (nodeHasFormat && nextNodeHasFormat) {
157
- continue;
158
- }
159
- const unhandledUnclosedTags = [...unclosedTags] // Shallow copy to avoid modifying the original array
160
- ;
161
- while (unhandledUnclosedTags.length > i) {
162
- const unclosedTag = unhandledUnclosedTags.pop();
163
- // If tag is unclosable, don't close it and leave it in the original array,
164
- // So that it can be closed when it's no longer unclosable
165
- if (unclosableTags && unclosedTag && unclosableTags.find(element => element.tag === unclosedTag.tag)) {
166
- continue;
167
- }
168
- if (unclosedTag && typeof unclosedTag.tag === 'string') {
169
- if (!nodeHasFormat) {
170
- // Handles cases where the tag has not been closed before, e.g. if the previous node
171
- // was a text match transformer that did not account for closing tags of the next node (e.g. a link)
172
- closingTagsBefore += unclosedTag.tag;
173
- } else if (!nextNodeHasFormat) {
174
- closingTagsAfter += unclosedTag.tag;
175
- }
176
- }
177
- // Mutate the original array to remove the closed tag
178
- unclosedTags.pop();
179
- }
180
- break;
181
- }
182
- output = openingTags + output + closingTagsAfter;
183
- // Replace trimmed version of textContent ensuring surrounding whitespace is not modified
184
- return closingTagsBefore + textContent.replace(frozenString, () => output);
185
- }
186
- // Get next or previous text sibling a text node, including cases
187
- // when it's a child of inline element (e.g. link)
188
- function getTextSibling(node, backward) {
189
- let sibling = backward ? node.getPreviousSibling() : node.getNextSibling();
190
- if (!sibling) {
191
- const parent = node.getParentOrThrow();
192
- if (parent.isInline()) {
193
- sibling = backward ? parent.getPreviousSibling() : parent.getNextSibling();
194
- }
195
- }
196
- while (sibling) {
197
- if ($isElementNode(sibling)) {
198
- if (!sibling.isInline()) {
199
- break;
200
- }
201
- const descendant = backward ? sibling.getLastDescendant() : sibling.getFirstDescendant();
202
- if ($isTextNode(descendant)) {
203
- return descendant;
204
- } else {
205
- sibling = backward ? sibling.getPreviousSibling() : sibling.getNextSibling();
206
- }
207
- }
208
- if ($isTextNode(sibling)) {
209
- return sibling;
210
- }
211
- if (!$isElementNode(sibling)) {
212
- return null;
213
- }
214
- }
215
- return null;
216
- }
217
- function hasFormat(node, format) {
218
- return $isTextNode(node) && node.hasFormat(format);
219
- }
220
- //# sourceMappingURL=MarkdownExport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownExport.js","names":["$getRoot","$getState","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isTextNode","hardLineBreakState","isEmptyParagraph","transformersByType","createMarkdownExport","transformers","shouldPreserveNewLines","byType","elementTransformers","multilineElement","element","isNewlineDelimited","textFormatTransformers","textFormat","filter","transformer","format","length","sort","a","b","includes","node","output","children","getChildren","forEach","child","i","result","exportTopLevelElements","textMatch","push","concat","join","textTransformersIndex","textMatchTransformers","export","_node","exportChildren","getTextContent","unclosedTags","unclosableTags","mainLoop","parentNode","textNode","textContent","exportTextFormat","$exportLineBreak","textTransformers","frozenString","trim","hasFormat","replace","openingTags","closingTagsBefore","closingTagsAfter","prevNode","getTextSibling","nextNode","applied","Set","tag","has","add","find","unclosedTag","nodeHasFormat","nextNodeHasFormat","unhandledUnclosedTags","pop","backward","sibling","getPreviousSibling","getNextSibling","parent","getParentOrThrow","isInline","descendant","getLastDescendant","getFirstDescendant"],"sources":["../../../../src/packages/@lexical/markdown/MarkdownExport.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ElementNode, LexicalNode, LineBreakNode, TextFormatType, TextNode } from 'lexical'\n\nimport {\n $getRoot,\n $getState,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isTextNode,\n} from 'lexical'\n\nimport type {\n ElementTransformer,\n MultilineElementTransformer,\n TextFormatTransformer,\n TextMatchTransformer,\n Transformer,\n} from './MarkdownTransformers.js'\n\nimport { hardLineBreakState } from './MarkdownTransformers.js'\nimport { isEmptyParagraph, transformersByType } from './utils.js'\n\n/**\n * Renders string from markdown. The selection is moved to the start after the operation.\n */\nexport function createMarkdownExport(\n transformers: Array<Transformer>,\n shouldPreserveNewLines: boolean = false,\n): (node?: ElementNode) => string {\n const byType = transformersByType(transformers)\n const elementTransformers = [...byType.multilineElement, ...byType.element]\n const isNewlineDelimited = !shouldPreserveNewLines\n\n // Export only uses text formats that are responsible for single format\n // e.g. it will filter out *** (bold, italic) and instead use separate ** and *\n const textFormatTransformers = byType.textFormat\n .filter((transformer) => transformer.format.length === 1)\n // Make sure all text transformers that contain 'code' in their format are at the end of the array. Otherwise, formatted code like\n // <strong><code>code</code></strong> will be exported as `**Bold Code**`, as the code format will be applied first, and the bold format\n // will be applied second and thus skipped entirely, as the code format will prevent any further formatting.\n .sort((a, b) => {\n if (a.format.includes('code') && !b.format.includes('code')) {\n return 1\n } else if (!a.format.includes('code') && b.format.includes('code')) {\n return -1\n } else {\n return 0\n }\n })\n\n return (node) => {\n const output: string[] = []\n const children = (node || $getRoot()).getChildren()\n\n children.forEach((child, i) => {\n const result = exportTopLevelElements(\n child,\n elementTransformers,\n textFormatTransformers,\n byType.textMatch,\n )\n\n if (result != null) {\n output.push(\n // separate consecutive group of texts with a line break: eg. [\"hello\", \"world\"] -> [\"hello\", \"/nworld\"]\n isNewlineDelimited &&\n i > 0 &&\n !isEmptyParagraph(child) &&\n !isEmptyParagraph(children[i - 1]!)\n ? '\\n'.concat(result)\n : result,\n )\n }\n })\n // Ensure consecutive groups of texts are at least \\n\\n apart while each empty paragraph render as a newline.\n // Eg. [\"hello\", \"\", \"\", \"hi\", \"\\nworld\"] -> \"hello\\n\\n\\nhi\\n\\nworld\"\n return output.join('\\n')\n }\n}\n\nfunction exportTopLevelElements(\n node: LexicalNode,\n elementTransformers: Array<ElementTransformer | MultilineElementTransformer>,\n textTransformersIndex: Array<TextFormatTransformer>,\n textMatchTransformers: Array<TextMatchTransformer>,\n): null | string {\n for (const transformer of elementTransformers) {\n if (!transformer.export) {\n continue\n }\n const result = transformer.export(node, (_node) =>\n exportChildren(_node, textTransformersIndex, textMatchTransformers),\n )\n\n if (result != null) {\n return result\n }\n }\n\n if ($isElementNode(node)) {\n return exportChildren(node, textTransformersIndex, textMatchTransformers)\n } else if ($isDecoratorNode(node)) {\n return node.getTextContent()\n } else {\n return null\n }\n}\n\nfunction exportChildren(\n node: ElementNode,\n textTransformersIndex: Array<TextFormatTransformer>,\n textMatchTransformers: Array<TextMatchTransformer>,\n unclosedTags?: Array<{ format: TextFormatType; tag: string }>,\n unclosableTags?: Array<{ format: TextFormatType; tag: string }>,\n): string {\n const output = []\n const children = node.getChildren()\n // keep track of unclosed tags from the very beginning\n if (!unclosedTags) {\n unclosedTags = []\n }\n if (!unclosableTags) {\n unclosableTags = []\n }\n\n mainLoop: for (const child of children) {\n for (const transformer of textMatchTransformers) {\n if (!transformer.export) {\n continue\n }\n\n const result = transformer.export(\n child,\n (parentNode) =>\n exportChildren(\n parentNode,\n textTransformersIndex,\n textMatchTransformers,\n unclosedTags,\n // Add current unclosed tags to the list of unclosable tags - we don't want nested tags from\n // textmatch transformers to close the outer ones, as that may result in invalid markdown.\n // E.g. **text [text**](https://lexical.io)\n // is invalid markdown, as the closing ** is inside the link.\n //\n [...unclosableTags, ...unclosedTags],\n ),\n (textNode, textContent) =>\n exportTextFormat(\n textNode,\n textContent,\n textTransformersIndex,\n unclosedTags,\n unclosableTags,\n ),\n )\n\n if (result != null) {\n output.push(result)\n continue mainLoop\n }\n }\n\n if ($isLineBreakNode(child)) {\n output.push($exportLineBreak(child))\n } else if ($isTextNode(child)) {\n output.push(\n exportTextFormat(\n child,\n child.getTextContent(),\n textTransformersIndex,\n unclosedTags,\n unclosableTags,\n ),\n )\n } else if ($isElementNode(child)) {\n // empty paragraph returns \"\"\n output.push(\n exportChildren(\n child,\n textTransformersIndex,\n textMatchTransformers,\n unclosedTags,\n unclosableTags,\n ),\n )\n } else if ($isDecoratorNode(child)) {\n output.push(child.getTextContent())\n }\n }\n\n return output.join('')\n}\n\n// Prefixes the newline with the original CommonMark hard line break marker\n// (`\\` or trailing spaces) when one was preserved on import, otherwise exports a\n// plain soft line break.\nfunction $exportLineBreak(node: LineBreakNode): string {\n return $getState(node, hardLineBreakState) + '\\n'\n}\n\nfunction exportTextFormat(\n node: TextNode,\n textContent: string,\n textTransformers: Array<TextFormatTransformer>,\n // unclosed tags include the markdown tags that haven't been closed yet, and their associated formats\n unclosedTags: Array<{ format: TextFormatType; tag: string }>,\n unclosableTags?: Array<{ format: TextFormatType; tag: string }>,\n): string {\n // This function handles the case of a string looking like this: \" foo \"\n // Where it would be invalid markdown to generate: \"** foo **\"\n // We instead want to trim the whitespace out, apply formatting, and then\n // bring the whitespace back. So our returned string looks like this: \" **foo** \"\n const frozenString = textContent.trim()\n let output = frozenString\n\n if (!node.hasFormat('code')) {\n // Escape any markdown characters in the text content\n output = output.replace(/([*_`~\\\\])/g, '\\\\$1')\n }\n\n // the opening tags to be added to the result\n let openingTags = ''\n // the closing tags to be added to the result\n let closingTagsBefore = ''\n let closingTagsAfter = ''\n\n const prevNode = getTextSibling(node, true)\n const nextNode = getTextSibling(node, false)\n\n const applied = new Set()\n\n for (const transformer of textTransformers) {\n const format = transformer.format[0]!\n const tag = transformer.tag\n\n // dedup applied formats\n if (hasFormat(node, format) && !applied.has(format)) {\n // Multiple tags might be used for the same format (*, _)\n applied.add(format)\n\n // append the tag to openningTags, if it's not applied to the previous nodes,\n // or the nodes before that (which would result in an unclosed tag)\n if (!hasFormat(prevNode, format) || !unclosedTags.find((element) => element.tag === tag)) {\n unclosedTags.push({ format, tag })\n openingTags += tag\n }\n }\n }\n\n // close any tags in the same order they were applied, if necessary\n for (let i = 0; i < unclosedTags.length; i++) {\n const unclosedTag = unclosedTags[i]!\n const nodeHasFormat = hasFormat(node, unclosedTag.format)\n const nextNodeHasFormat = hasFormat(nextNode, unclosedTag.format)\n\n // prevent adding closing tag if next sibling will do it\n if (nodeHasFormat && nextNodeHasFormat) {\n continue\n }\n\n const unhandledUnclosedTags = [...unclosedTags] // Shallow copy to avoid modifying the original array\n\n while (unhandledUnclosedTags.length > i) {\n const unclosedTag = unhandledUnclosedTags.pop()\n\n // If tag is unclosable, don't close it and leave it in the original array,\n // So that it can be closed when it's no longer unclosable\n if (\n unclosableTags &&\n unclosedTag &&\n unclosableTags.find((element) => element.tag === unclosedTag.tag)\n ) {\n continue\n }\n\n if (unclosedTag && typeof unclosedTag.tag === 'string') {\n if (!nodeHasFormat) {\n // Handles cases where the tag has not been closed before, e.g. if the previous node\n // was a text match transformer that did not account for closing tags of the next node (e.g. a link)\n closingTagsBefore += unclosedTag.tag\n } else if (!nextNodeHasFormat) {\n closingTagsAfter += unclosedTag.tag\n }\n }\n // Mutate the original array to remove the closed tag\n unclosedTags.pop()\n }\n break\n }\n\n output = openingTags + output + closingTagsAfter\n // Replace trimmed version of textContent ensuring surrounding whitespace is not modified\n return closingTagsBefore + textContent.replace(frozenString, () => output)\n}\n\n// Get next or previous text sibling a text node, including cases\n// when it's a child of inline element (e.g. link)\nfunction getTextSibling(node: TextNode, backward: boolean): null | TextNode {\n let sibling = backward ? node.getPreviousSibling() : node.getNextSibling()\n\n if (!sibling) {\n const parent = node.getParentOrThrow()\n\n if (parent.isInline()) {\n sibling = backward ? parent.getPreviousSibling() : parent.getNextSibling()\n }\n }\n\n while (sibling) {\n if ($isElementNode(sibling)) {\n if (!sibling.isInline()) {\n break\n }\n\n const descendant = backward ? sibling.getLastDescendant() : sibling.getFirstDescendant()\n\n if ($isTextNode(descendant)) {\n return descendant\n } else {\n sibling = backward ? sibling.getPreviousSibling() : sibling.getNextSibling()\n }\n }\n\n if ($isTextNode(sibling)) {\n return sibling\n }\n\n if (!$isElementNode(sibling)) {\n return null\n }\n }\n\n return null\n}\n\nfunction hasFormat(node: LexicalNode | null | undefined, format: TextFormatType): boolean {\n return $isTextNode(node) && node.hasFormat(format)\n}\n"],"mappings":"AAAA;;;;;;GAUA,SACEA,QAAQ,EACRC,SAAS,EACTC,gBAAgB,EAChBC,cAAc,EACdC,gBAAgB,EAChBC,WAAW,QACN;AAUP,SAASC,kBAAkB,QAAQ;AACnC,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ;AAErD;;;AAGA,OAAO,SAASC,qBACdC,YAAgC,EAChCC,sBAAA,GAAkC,KAAK;EAEvC,MAAMC,MAAA,GAASJ,kBAAA,CAAmBE,YAAA;EAClC,MAAMG,mBAAA,GAAsB,C,GAAID,MAAA,CAAOE,gBAAgB,E,GAAKF,MAAA,CAAOG,OAAO,CAAC;EAC3E,MAAMC,kBAAA,GAAqB,CAACL,s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GAAWC,OAAA,CAAQC,kBAAkB,KAAKD,OAAA,CAAQE,cAAc;MAC5E;IACF;IAEA,IAAI1E,WAAA,CAAYwE,OAAA,GAAU;MACxB,OAAOA,OAAA;IACT;IAEA,IAAI,CAAC1E,cAAA,CAAe0E,OAAA,GAAU;MAC5B,OAAO;IACT;EACF;EAEA,OAAO;AACT;AAEA,SAASpB,UAAU9B,IAAoC,EAAEN,MAAsB;EAC7E,OAAOhB,WAAA,CAAYsB,IAAA,KAASA,IAAA,CAAK8B,SAAS,CAACpC,MAAA;AAC7C","ignoreList":[]}
@@ -1,19 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import type { ElementNode } from 'lexical';
9
- import type { TextFormatTransformer, Transformer } from './MarkdownTransformers.js';
10
- export type TextFormatTransformersIndex = Readonly<{
11
- fullMatchRegExpByTag: Readonly<Record<string, RegExp>>;
12
- openTagsRegExp: RegExp;
13
- transformersByTag: Readonly<Record<string, TextFormatTransformer>>;
14
- }>;
15
- /**
16
- * Renders markdown from a string. The selection is moved to the start after the operation.
17
- */
18
- export declare function createMarkdownImport(transformers: Array<Transformer>, shouldPreserveNewLines?: boolean): (markdownString: string, node?: ElementNode) => void;
19
- //# sourceMappingURL=MarkdownImport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownImport.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/MarkdownImport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAa1C,OAAO,KAAK,EAGV,qBAAqB,EAErB,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAMlC,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;IACjD,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACtD,cAAc,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAA;CACnE,CAAC,CAAA;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,EAChC,sBAAsB,UAAQ,GAC7B,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,IAAI,CAyCtD"}