@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,173 +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, Klass, LexicalNode, LineBreakNode, TextFormatType, TextNode } from 'lexical';
9
- export type Transformer = ElementTransformer | MultilineElementTransformer | TextFormatTransformer | TextMatchTransformer;
10
- export type ElementTransformer = {
11
- dependencies: Array<Klass<LexicalNode>>;
12
- /**
13
- * `export` is called when the `$convertToMarkdownString` is called to convert the editor state into markdown.
14
- *
15
- * @return return null to cancel the export, even though the regex matched. Lexical will then search for the next transformer.
16
- */
17
- export: (node: LexicalNode, traverseChildren: (node: ElementNode) => string) => null | string;
18
- regExp: RegExp;
19
- /**
20
- * `replace` is called when markdown is imported or typed in the editor
21
- *
22
- * @return return false to cancel the transform, even though the regex matched. Lexical will then search for the next transformer.
23
- */
24
- replace: (parentNode: ElementNode, children: Array<LexicalNode>, match: Array<string>,
25
- /**
26
- * Whether the match is from an import operation (e.g. through `$convertFromMarkdownString`) or not (e.g. through typing in the editor).
27
- */
28
- isImport: boolean) => boolean | void;
29
- type: 'element';
30
- };
31
- export type MultilineElementTransformer = {
32
- dependencies: Array<Klass<LexicalNode>>;
33
- /**
34
- * `export` is called when the `$convertToMarkdownString` is called to convert the editor state into markdown.
35
- *
36
- * @return return null to cancel the export, even though the regex matched. Lexical will then search for the next transformer.
37
- */
38
- export?: (node: LexicalNode, traverseChildren: (node: ElementNode) => string) => null | string;
39
- /**
40
- * Use this function to manually handle the import process, once the `regExpStart` has matched successfully.
41
- * Without providing this function, the default behavior is to match until `regExpEnd` is found, or until the end of the document if `regExpEnd.optional` is true.
42
- *
43
- * @returns a tuple or null. The first element of the returned tuple is a boolean indicating if a multiline element was imported. The second element is the index of the last line that was processed. If null is returned, the next multilineElementTransformer will be tried. If undefined is returned, the default behavior will be used.
44
- */
45
- handleImportAfterStartMatch?: (args: {
46
- lines: Array<string>;
47
- rootNode: ElementNode;
48
- startLineIndex: number;
49
- startMatch: RegExpMatchArray;
50
- transformer: MultilineElementTransformer;
51
- }) => [boolean, number] | null | undefined;
52
- /**
53
- * This regex determines when to stop matching. Anything in between regExpStart and regExpEnd will be matched
54
- */
55
- regExpEnd?: {
56
- /**
57
- * Whether the end match is optional. If true, the end match is not required to match for the transformer to be triggered.
58
- * The entire text from regexpStart to the end of the document will then be matched.
59
- */
60
- optional?: true;
61
- regExp: RegExp;
62
- } | RegExp;
63
- /**
64
- * This regex determines when to start matching
65
- */
66
- regExpStart: RegExp;
67
- /**
68
- * `replace` is called only when markdown is imported in the editor, not when it's typed
69
- *
70
- * @return return false to cancel the transform, even though the regex matched. Lexical will then search for the next transformer.
71
- */
72
- replace: (rootNode: ElementNode,
73
- /**
74
- * During markdown shortcut transforms, children nodes may be provided to the transformer. If this is the case, no `linesInBetween` will be provided and
75
- * the children nodes should be used instead of the `linesInBetween` to create the new node.
76
- */
77
- children: Array<LexicalNode> | null, startMatch: Array<string>, endMatch: Array<string> | null,
78
- /**
79
- * linesInBetween includes the text between the start & end matches, split up by lines, not including the matches themselves.
80
- * This is null when the transformer is triggered through markdown shortcuts (by typing in the editor)
81
- */
82
- linesInBetween: Array<string> | null,
83
- /**
84
- * Whether the match is from an import operation (e.g. through `$convertFromMarkdownString`) or not (e.g. through typing in the editor).
85
- */
86
- isImport: boolean) => boolean | void;
87
- type: 'multiline-element';
88
- };
89
- export type TextFormatTransformer = Readonly<{
90
- format: ReadonlyArray<TextFormatType>;
91
- intraword?: boolean;
92
- tag: string;
93
- type: 'text-format';
94
- }>;
95
- export type TextMatchTransformer = Readonly<{
96
- dependencies: Array<Klass<LexicalNode>>;
97
- /**
98
- * Determines how a node should be exported to markdown
99
- */
100
- export?: (node: LexicalNode, exportChildren: (node: ElementNode) => string, exportFormat: (node: TextNode, textContent: string) => string) => null | string;
101
- /**
102
- * For import operations, this function can be used to determine the end index of the match, after `importRegExp` has matched.
103
- * Without this function, the end index will be determined by the length of the match from `importRegExp`. Manually determining the end index can be useful if
104
- * the match from `importRegExp` is not the entire text content of the node. That way, `importRegExp` can be used to match only the start of the node, and `getEndIndex`
105
- * can be used to match the end of the node.
106
- *
107
- * @returns The end index of the match, or false if the match was unsuccessful and a different transformer should be tried.
108
- */
109
- getEndIndex?: (node: TextNode, match: RegExpMatchArray) => false | number;
110
- /**
111
- * This regex determines what text is matched during markdown imports
112
- */
113
- importRegExp?: RegExp;
114
- /**
115
- * This regex determines what text is matched for markdown shortcuts while typing in the editor
116
- */
117
- regExp: RegExp;
118
- /**
119
- * Determines how the matched markdown text should be transformed into a node during the markdown import process
120
- *
121
- * @returns nothing, or a TextNode that may be a child of the new node that is created.
122
- * If a TextNode is returned, text format matching will be applied to it (e.g. bold, italic, etc.)
123
- */
124
- replace?: (node: TextNode, match: RegExpMatchArray) => TextNode | void;
125
- /**
126
- * Single character that allows the transformer to trigger when typed in the editor. This does not affect markdown imports outside of the markdown shortcut plugin.
127
- * If the trigger is matched, the `regExp` will be used to match the text in the second step.
128
- */
129
- trigger?: string;
130
- type: 'text-match';
131
- }>;
132
- /**
133
- * A CommonMark hard line break marker: either a single backslash (`\`) or two or
134
- * more trailing spaces, both placed at the end of a line before the newline.
135
- * See https://spec.commonmark.org/0.31.2/#hard-line-breaks
136
- */
137
- export type MarkdownHardLineBreak = string;
138
- /**
139
- * Stores the original hard line break marker on a `LineBreakNode` so it can be
140
- * preserved across a markdown import/export round trip instead of being
141
- * collapsed into a soft line break.
142
- *
143
- * Note: unlike upstream Lexical (which sets `resetOnCopyNode: true`), that option
144
- * does not exist in the `lexical` version pinned here (0.41.0), so it is omitted.
145
- */
146
- export declare const hardLineBreakState: import("lexical").StateConfig<"mdHardLineBreak", string>;
147
- /**
148
- * Detects a CommonMark hard line break marker at the end of a raw line.
149
- *
150
- * @returns a tuple of `[textWithoutMarker, marker]` when a marker is found, otherwise null.
151
- */
152
- export declare function parseMarkdownHardLineBreak(line: string): [string, MarkdownHardLineBreak] | null;
153
- /**
154
- * Creates a `LineBreakNode` for a markdown line join, preserving any CommonMark
155
- * hard line break marker found at the end of `previousNode` via node state.
156
- */
157
- export declare function $createMarkdownLineBreakNode(previousNode: ElementNode): LineBreakNode;
158
- export declare const HEADING: ElementTransformer;
159
- export declare const QUOTE: ElementTransformer;
160
- export declare const UNORDERED_LIST: ElementTransformer;
161
- export declare const CHECK_LIST: ElementTransformer;
162
- export declare const ORDERED_LIST: ElementTransformer;
163
- export declare const INLINE_CODE: TextFormatTransformer;
164
- export declare const HIGHLIGHT: TextFormatTransformer;
165
- export declare const BOLD_ITALIC_STAR: TextFormatTransformer;
166
- export declare const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer;
167
- export declare const BOLD_STAR: TextFormatTransformer;
168
- export declare const BOLD_UNDERSCORE: TextFormatTransformer;
169
- export declare const STRIKETHROUGH: TextFormatTransformer;
170
- export declare const ITALIC_STAR: TextFormatTransformer;
171
- export declare const ITALIC_UNDERSCORE: TextFormatTransformer;
172
- export declare function normalizeMarkdown(input: string, shouldMergeAdjacentLines: boolean): string;
173
- //# sourceMappingURL=MarkdownTransformers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/MarkdownTransformers.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,KAAK,EACL,WAAW,EACX,aAAa,EACb,cAAc,EACd,QAAQ,EACT,MAAM,SAAS,CAAA;AA0BhB,MAAM,MAAM,WAAW,GACnB,kBAAkB,GAClB,2BAA2B,GAC3B,qBAAqB,GACrB,oBAAoB,CAAA;AAExB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;IACvC;;;;OAIG;IACH,MAAM,EAAE,CACN,IAAI,EAAE,WAAW,EAEjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,KAC5C,IAAI,GAAG,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,OAAO,EAAE,CACP,UAAU,EAAE,WAAW,EACvB,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,EAC5B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,OAAO,KACd,OAAO,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,YAAY,EAAE,KA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,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,kBAQ5B,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,kBAQxB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,kBAQ1B,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,qBAIzB,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,qBAIvB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,qBAI9B,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,qBAKpC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,qBAIvB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,qBAK7B,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,qBAI3B,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,qBAIzB,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,qBAK/B,CAAA;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,wBAAwB,EAAE,OAAO,GAAG,MAAM,CAgF1F"}
@@ -1,352 +0,0 @@
1
- /* eslint-disable regexp/no-unused-capturing-group */ /**
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 { $createListItemNode, $createListNode, $isListItemNode, $isListNode, ListItemNode, ListNode } from '@lexical/list';
8
- import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, HeadingNode, QuoteNode } from '@lexical/rich-text';
9
- import { $createLineBreakNode, $isLineBreakNode, $isTextNode, $setState, createState } from 'lexical';
10
- const EMPTY_OR_WHITESPACE_ONLY = /^[\t ]*$/;
11
- const ORDERED_LIST_REGEX = /^(\s*)(\d+)\.\s/;
12
- const UNORDERED_LIST_REGEX = /^(\s*)[-*+]\s/;
13
- const CHECK_LIST_REGEX = /^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i;
14
- const HEADING_REGEX = /^(#{1,6})\s/;
15
- const QUOTE_REGEX = /^>\s/;
16
- const CODE_START_REGEX = /^[ \t]*(\\`\\`\\`|```)(\w+)?/;
17
- const CODE_END_REGEX = /[ \t]*(\\`\\`\\`|```)$/;
18
- const CODE_SINGLE_LINE_REGEX = /^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/;
19
- const TABLE_ROW_REG_EXP = /^\|(.+)\|\s?$/;
20
- const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
21
- const TAG_START_REGEX = /^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i;
22
- const TAG_END_REGEX = /^[ \t]*<\/[a-z_][\w-]*\s*>/i;
23
- /**
24
- * Stores the original hard line break marker on a `LineBreakNode` so it can be
25
- * preserved across a markdown import/export round trip instead of being
26
- * collapsed into a soft line break.
27
- *
28
- * Note: unlike upstream Lexical (which sets `resetOnCopyNode: true`), that option
29
- * does not exist in the `lexical` version pinned here (0.41.0), so it is omitted.
30
- */
31
- export const hardLineBreakState = createState('mdHardLineBreak', {
32
- parse: val => {
33
- if (typeof val === 'string' && /^(\\| {2,})$/.test(val)) {
34
- return val;
35
- }
36
- return '';
37
- }
38
- });
39
- /**
40
- * Detects a CommonMark hard line break marker at the end of a raw line.
41
- *
42
- * @returns a tuple of `[textWithoutMarker, marker]` when a marker is found, otherwise null.
43
- */
44
- export function parseMarkdownHardLineBreak(line) {
45
- if (line.endsWith('\\')) {
46
- return [line.slice(0, -1), '\\'];
47
- }
48
- const spaces = line.match(/^(.*?\S)( {2,})$/);
49
- return spaces ? [spaces[1], spaces[2]] : null;
50
- }
51
- function hasNonWhitespaceContentOnLine(children, endIndex) {
52
- for (let i = endIndex - 1; i >= 0; i--) {
53
- if ($isLineBreakNode(children[i])) {
54
- return false;
55
- }
56
- if (/\S/.test(children[i].getTextContent())) {
57
- return true;
58
- }
59
- }
60
- return false;
61
- }
62
- /**
63
- * Removes a trailing hard line break marker from the last text node of `previousNode`
64
- * (if present) and returns the marker, so it can be carried onto a `LineBreakNode`.
65
- */
66
- function $extractMarkdownHardLineBreakMarker(previousNode) {
67
- const children = previousNode.getChildren();
68
- const lastChildIndex = children.length - 1;
69
- const lastChild = children[lastChildIndex];
70
- if (!$isTextNode(lastChild)) {
71
- return null;
72
- }
73
- const lastText = lastChild.getTextContent();
74
- const hardLineBreak = parseMarkdownHardLineBreak(lastText);
75
- if (hardLineBreak !== null) {
76
- const [text, marker] = hardLineBreak;
77
- lastChild.setTextContent(text);
78
- return marker;
79
- }
80
- // Trailing whitespace may have been split into its own text node by inline
81
- // transformers (e.g. after formatted or linked content). Only treat it as a
82
- // hard break when there is preceding non-whitespace content on the same line.
83
- if (/^ {2,}$/.test(lastText) && hasNonWhitespaceContentOnLine(children, lastChildIndex)) {
84
- lastChild.setTextContent('');
85
- return lastText;
86
- }
87
- return null;
88
- }
89
- /**
90
- * Creates a `LineBreakNode` for a markdown line join, preserving any CommonMark
91
- * hard line break marker found at the end of `previousNode` via node state.
92
- */
93
- export function $createMarkdownLineBreakNode(previousNode) {
94
- const lineBreakNode = $createLineBreakNode();
95
- const hardLineBreak = $extractMarkdownHardLineBreakMarker(previousNode);
96
- if (hardLineBreak !== null) {
97
- $setState(lineBreakNode, hardLineBreakState, hardLineBreak);
98
- }
99
- return lineBreakNode;
100
- }
101
- const createBlockNode = createNode => {
102
- return (parentNode, children, match) => {
103
- const node = createNode(match);
104
- node.append(...children);
105
- parentNode.replace(node);
106
- node.select(0, 0);
107
- };
108
- };
109
- // Amount of spaces that define indentation level
110
- // TODO: should be an option
111
- const LIST_INDENT_SIZE = 4;
112
- function getIndent(whitespaces) {
113
- const tabs = whitespaces.match(/\t/g);
114
- const spaces = whitespaces.match(/ /g);
115
- let indent = 0;
116
- if (tabs) {
117
- indent += tabs.length;
118
- }
119
- if (spaces) {
120
- indent += Math.floor(spaces.length / LIST_INDENT_SIZE);
121
- }
122
- return indent;
123
- }
124
- const listReplace = listType => {
125
- return (parentNode, children, match) => {
126
- const previousNode = parentNode.getPreviousSibling();
127
- const nextNode = parentNode.getNextSibling();
128
- const listItem = $createListItemNode(listType === 'check' ? match[3] === 'x' : undefined);
129
- if ($isListNode(nextNode) && nextNode.getListType() === listType) {
130
- const firstChild = nextNode.getFirstChild();
131
- if (firstChild !== null) {
132
- firstChild.insertBefore(listItem);
133
- } else {
134
- // should never happen, but let's handle gracefully, just in case.
135
- nextNode.append(listItem);
136
- }
137
- parentNode.remove();
138
- } else if ($isListNode(previousNode) && previousNode.getListType() === listType) {
139
- previousNode.append(listItem);
140
- parentNode.remove();
141
- } else {
142
- const list = $createListNode(listType, listType === 'number' ? Number(match[2]) : undefined);
143
- list.append(listItem);
144
- parentNode.replace(list);
145
- }
146
- listItem.append(...children);
147
- listItem.select(0, 0);
148
- const indent = getIndent(match[1]);
149
- if (indent) {
150
- listItem.setIndent(indent);
151
- }
152
- };
153
- };
154
- const listExport = (listNode, exportChildren, depth) => {
155
- const output = [];
156
- const children = listNode.getChildren();
157
- let index = 0;
158
- for (const listItemNode of children) {
159
- if ($isListItemNode(listItemNode)) {
160
- if (listItemNode.getChildrenSize() === 1) {
161
- const firstChild = listItemNode.getFirstChild();
162
- if ($isListNode(firstChild)) {
163
- output.push(listExport(firstChild, exportChildren, depth + 1));
164
- continue;
165
- }
166
- }
167
- const indent = ' '.repeat(depth * LIST_INDENT_SIZE);
168
- const listType = listNode.getListType();
169
- const prefix = listType === 'number' ? `${listNode.getStart() + index}. ` : listType === 'check' ? `- [${listItemNode.getChecked() ? 'x' : ' '}] ` : '- ';
170
- output.push(indent + prefix + exportChildren(listItemNode));
171
- index++;
172
- }
173
- }
174
- return output.join('\n');
175
- };
176
- export const HEADING = {
177
- type: 'element',
178
- dependencies: [HeadingNode],
179
- export: (node, exportChildren) => {
180
- if (!$isHeadingNode(node)) {
181
- return null;
182
- }
183
- const level = Number(node.getTag().slice(1));
184
- return '#'.repeat(level) + ' ' + exportChildren(node);
185
- },
186
- regExp: HEADING_REGEX,
187
- replace: createBlockNode(match => {
188
- const tag = 'h' + match[1].length;
189
- return $createHeadingNode(tag);
190
- })
191
- };
192
- export const QUOTE = {
193
- type: 'element',
194
- dependencies: [QuoteNode],
195
- export: (node, exportChildren) => {
196
- if (!$isQuoteNode(node)) {
197
- return null;
198
- }
199
- const lines = exportChildren(node).split('\n');
200
- const output = [];
201
- for (const line of lines) {
202
- output.push('> ' + line);
203
- }
204
- return output.join('\n');
205
- },
206
- regExp: QUOTE_REGEX,
207
- replace: (parentNode, children, _match, isImport) => {
208
- if (isImport) {
209
- const previousNode = parentNode.getPreviousSibling();
210
- if ($isQuoteNode(previousNode)) {
211
- previousNode.splice(previousNode.getChildrenSize(), 0, [$createMarkdownLineBreakNode(previousNode), ...children]);
212
- previousNode.select(0, 0);
213
- parentNode.remove();
214
- return;
215
- }
216
- }
217
- const node = $createQuoteNode();
218
- node.append(...children);
219
- parentNode.replace(node);
220
- node.select(0, 0);
221
- }
222
- };
223
- export const UNORDERED_LIST = {
224
- type: 'element',
225
- dependencies: [ListNode, ListItemNode],
226
- export: (node, exportChildren) => {
227
- return $isListNode(node) ? listExport(node, exportChildren, 0) : null;
228
- },
229
- regExp: UNORDERED_LIST_REGEX,
230
- replace: listReplace('bullet')
231
- };
232
- export const CHECK_LIST = {
233
- type: 'element',
234
- dependencies: [ListNode, ListItemNode],
235
- export: (node, exportChildren) => {
236
- return $isListNode(node) ? listExport(node, exportChildren, 0) : null;
237
- },
238
- regExp: CHECK_LIST_REGEX,
239
- replace: listReplace('check')
240
- };
241
- export const ORDERED_LIST = {
242
- type: 'element',
243
- dependencies: [ListNode, ListItemNode],
244
- export: (node, exportChildren) => {
245
- return $isListNode(node) ? listExport(node, exportChildren, 0) : null;
246
- },
247
- regExp: ORDERED_LIST_REGEX,
248
- replace: listReplace('number')
249
- };
250
- export const INLINE_CODE = {
251
- type: 'text-format',
252
- format: ['code'],
253
- tag: '`'
254
- };
255
- export const HIGHLIGHT = {
256
- type: 'text-format',
257
- format: ['highlight'],
258
- tag: '=='
259
- };
260
- export const BOLD_ITALIC_STAR = {
261
- type: 'text-format',
262
- format: ['bold', 'italic'],
263
- tag: '***'
264
- };
265
- export const BOLD_ITALIC_UNDERSCORE = {
266
- type: 'text-format',
267
- format: ['bold', 'italic'],
268
- intraword: false,
269
- tag: '___'
270
- };
271
- export const BOLD_STAR = {
272
- type: 'text-format',
273
- format: ['bold'],
274
- tag: '**'
275
- };
276
- export const BOLD_UNDERSCORE = {
277
- type: 'text-format',
278
- format: ['bold'],
279
- intraword: false,
280
- tag: '__'
281
- };
282
- export const STRIKETHROUGH = {
283
- type: 'text-format',
284
- format: ['strikethrough'],
285
- tag: '~~'
286
- };
287
- export const ITALIC_STAR = {
288
- type: 'text-format',
289
- format: ['italic'],
290
- tag: '*'
291
- };
292
- export const ITALIC_UNDERSCORE = {
293
- type: 'text-format',
294
- format: ['italic'],
295
- intraword: false,
296
- tag: '_'
297
- };
298
- export function normalizeMarkdown(input, shouldMergeAdjacentLines) {
299
- const lines = input.split('\n');
300
- let inCodeBlock = false;
301
- const sanitizedLines = [];
302
- let nestedDeepCodeBlock = 0;
303
- for (let i = 0; i < lines.length; i++) {
304
- const line = lines[i];
305
- const lastLine = sanitizedLines[sanitizedLines.length - 1];
306
- // A hard line break marker on the current line only matters if another line follows it.
307
- const hardLineBreak = i < lines.length - 1 ? parseMarkdownHardLineBreak(line) : null;
308
- const lastLineHasHardLineBreak = lastLine !== undefined && parseMarkdownHardLineBreak(lastLine) !== null;
309
- // Code blocks of ```single line``` don't toggle the inCodeBlock flag
310
- if (CODE_SINGLE_LINE_REGEX.test(line)) {
311
- sanitizedLines.push(line);
312
- continue;
313
- }
314
- if (CODE_END_REGEX.test(line)) {
315
- if (nestedDeepCodeBlock === 0) {
316
- inCodeBlock = true;
317
- }
318
- if (nestedDeepCodeBlock === 1) {
319
- inCodeBlock = false;
320
- }
321
- if (nestedDeepCodeBlock > 0) {
322
- nestedDeepCodeBlock--;
323
- }
324
- sanitizedLines.push(line);
325
- continue;
326
- }
327
- // Toggle inCodeBlock state when encountering start or end of a code block
328
- if (CODE_START_REGEX.test(line)) {
329
- inCodeBlock = true;
330
- nestedDeepCodeBlock++;
331
- sanitizedLines.push(line);
332
- continue;
333
- }
334
- // If we are inside a code block, keep the line unchanged
335
- if (inCodeBlock) {
336
- sanitizedLines.push(line);
337
- continue;
338
- }
339
- // In markdown the concept of "empty paragraphs" does not exist.
340
- // Blocks must be separated by an empty line. Non-empty adjacent lines must be merged.
341
- if (EMPTY_OR_WHITESPACE_ONLY.test(line) || EMPTY_OR_WHITESPACE_ONLY.test(lastLine) || !lastLine || HEADING_REGEX.test(lastLine) || HEADING_REGEX.test(line) || QUOTE_REGEX.test(line) || ORDERED_LIST_REGEX.test(line) || UNORDERED_LIST_REGEX.test(line) || CHECK_LIST_REGEX.test(line) || TABLE_ROW_REG_EXP.test(line) || TABLE_ROW_DIVIDER_REG_EXP.test(line) ||
342
- // Don't merge the next line into a line that ends with a hard line break marker.
343
- lastLineHasHardLineBreak || !shouldMergeAdjacentLines || TAG_START_REGEX.test(line) || TAG_END_REGEX.test(line) || TAG_START_REGEX.test(lastLine) || TAG_END_REGEX.test(lastLine) || CODE_END_REGEX.test(lastLine)) {
344
- sanitizedLines.push(line);
345
- } else {
346
- // Preserve a trailing hard line break marker on the merged line so it survives import.
347
- sanitizedLines[sanitizedLines.length - 1] = lastLine + ' ' + (hardLineBreak === null ? line.trim() : line.trimStart());
348
- }
349
- }
350
- return sanitizedLines.join('\n');
351
- }
352
- //# sourceMappingURL=MarkdownTransformers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownTransformers.js","names":["$createListItemNode","$createListNode","$isListItemNode","$isListNode","ListItemNode","ListNode","$createHeadingNode","$createQuoteNode","$isHeadingNode","$isQuoteNode","HeadingNode","QuoteNode","$createLineBreakNode","$isLineBreakNode","$isTextNode","$setState","createState","EMPTY_OR_WHITESPACE_ONLY","ORDERED_LIST_REGEX","UNORDERED_LIST_REGEX","CHECK_LIST_REGEX","HEADING_REGEX","QUOTE_REGEX","CODE_START_REGEX","CODE_END_REGEX","CODE_SINGLE_LINE_REGEX","TABLE_ROW_REG_EXP","TABLE_ROW_DIVIDER_REG_EXP","TAG_START_REGEX","TAG_END_REGEX","hardLineBreakState","parse","val","test","parseMarkdownHardLineBreak","line","endsWith","slice","spaces","match","hasNonWhitespaceContentOnLine","children","endIndex","i","getTextContent","$extractMarkdownHardLineBreakMarker","previousNode","getChildren","lastChildIndex","length","lastChild","lastText","hardLineBreak","text","marker","setTextContent","$createMarkdownLineBreakNode","lineBreakNode","createBlockNode","createNode","parentNode","node","append","replace","select","LIST_INDENT_SIZE","getIndent","whitespaces","tabs","indent","Math","floor","listReplace","listType","getPreviousSibling","nextNode","getNextSibling","listItem","undefined","getListType","firstChild","getFirstChild","insertBefore","remove","list","Number","setIndent","listExport","listNode","exportChildren","depth","output","index","listItemNode","getChildrenSize","push","repeat","prefix","getStart","getChecked","join","HEADING","type","dependencies","export","level","getTag","regExp","tag","QUOTE","lines","split","_match","isImport","splice","UNORDERED_LIST","CHECK_LIST","ORDERED_LIST","INLINE_CODE","format","HIGHLIGHT","BOLD_ITALIC_STAR","BOLD_ITALIC_UNDERSCORE","intraword","BOLD_STAR","BOLD_UNDERSCORE","STRIKETHROUGH","ITALIC_STAR","ITALIC_UNDERSCORE","normalizeMarkdown","input","shouldMergeAdjacentLines","inCodeBlock","sanitizedLines","nestedDeepCodeBlock","lastLine","lastLineHasHardLineBreak","trim","trimStart"],"sources":["../../../../src/packages/@lexical/markdown/MarkdownTransformers.ts"],"sourcesContent":["/* eslint-disable regexp/no-unused-capturing-group */\n/**\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 { ListType } from '@lexical/list'\nimport type { HeadingTagType } from '@lexical/rich-text'\nimport type {\n ElementNode,\n Klass,\n LexicalNode,\n LineBreakNode,\n TextFormatType,\n TextNode,\n} from 'lexical'\n\nimport {\n $createListItemNode,\n $createListNode,\n $isListItemNode,\n $isListNode,\n ListItemNode,\n ListNode,\n} from '@lexical/list'\nimport {\n $createHeadingNode,\n $createQuoteNode,\n $isHeadingNode,\n $isQuoteNode,\n HeadingNode,\n QuoteNode,\n} from '@lexical/rich-text'\nimport {\n $createLineBreakNode,\n $isLineBreakNode,\n $isTextNode,\n $setState,\n createState,\n} from 'lexical'\n\nexport type Transformer =\n | ElementTransformer\n | MultilineElementTransformer\n | TextFormatTransformer\n | TextMatchTransformer\n\nexport type ElementTransformer = {\n dependencies: Array<Klass<LexicalNode>>\n /**\n * `export` is called when the `$convertToMarkdownString` is called to convert the editor state into markdown.\n *\n * @return return null to cancel the export, even though the regex matched. Lexical will then search for the next transformer.\n */\n export: (\n node: LexicalNode,\n\n traverseChildren: (node: ElementNode) => string,\n ) => null | string\n regExp: RegExp\n /**\n * `replace` is called when markdown is imported or typed in the editor\n *\n * @return return false to cancel the transform, even though the regex matched. Lexical will then search for the next transformer.\n */\n replace: (\n parentNode: ElementNode,\n children: Array<LexicalNode>,\n match: Array<string>,\n /**\n * Whether the match is from an import operation (e.g. through `$convertFromMarkdownString`) or not (e.g. through typing in the editor).\n */\n isImport: boolean,\n ) => boolean | void\n type: 'element'\n}\n\nexport type MultilineElementTransformer = {\n dependencies: Array<Klass<LexicalNode>>\n /**\n * `export` is called when the `$convertToMarkdownString` is called to convert the editor state into markdown.\n *\n * @return return null to cancel the export, even though the regex matched. Lexical will then search for the next transformer.\n */\n export?: (\n node: LexicalNode,\n\n traverseChildren: (node: ElementNode) => string,\n ) => null | string\n /**\n * Use this function to manually handle the import process, once the `regExpStart` has matched successfully.\n * Without providing this function, the default behavior is to match until `regExpEnd` is found, or until the end of the document if `regExpEnd.optional` is true.\n *\n * @returns a tuple or null. The first element of the returned tuple is a boolean indicating if a multiline element was imported. The second element is the index of the last line that was processed. If null is returned, the next multilineElementTransformer will be tried. If undefined is returned, the default behavior will be used.\n */\n handleImportAfterStartMatch?: (args: {\n lines: Array<string>\n rootNode: ElementNode\n startLineIndex: number\n startMatch: RegExpMatchArray\n transformer: MultilineElementTransformer\n }) => [boolean, number] | null | undefined\n /**\n * This regex determines when to stop matching. Anything in between regExpStart and regExpEnd will be matched\n */\n regExpEnd?:\n | {\n /**\n * Whether the end match is optional. If true, the end match is not required to match for the transformer to be triggered.\n * The entire text from regexpStart to the end of the document will then be matched.\n */\n optional?: true\n regExp: RegExp\n }\n | RegExp\n /**\n * This regex determines when to start matching\n */\n regExpStart: RegExp\n /**\n * `replace` is called only when markdown is imported in the editor, not when it's typed\n *\n * @return return false to cancel the transform, even though the regex matched. Lexical will then search for the next transformer.\n */\n replace: (\n rootNode: ElementNode,\n /**\n * During markdown shortcut transforms, children nodes may be provided to the transformer. If this is the case, no `linesInBetween` will be provided and\n * the children nodes should be used instead of the `linesInBetween` to create the new node.\n */\n children: Array<LexicalNode> | null,\n startMatch: Array<string>,\n endMatch: Array<string> | null,\n /**\n * linesInBetween includes the text between the start & end matches, split up by lines, not including the matches themselves.\n * This is null when the transformer is triggered through markdown shortcuts (by typing in the editor)\n */\n linesInBetween: Array<string> | null,\n /**\n * Whether the match is from an import operation (e.g. through `$convertFromMarkdownString`) or not (e.g. through typing in the editor).\n */\n isImport: boolean,\n ) => boolean | void\n type: 'multiline-element'\n}\n\nexport type TextFormatTransformer = Readonly<{\n format: ReadonlyArray<TextFormatType>\n intraword?: boolean\n tag: string\n type: 'text-format'\n}>\n\nexport type TextMatchTransformer = Readonly<{\n dependencies: Array<Klass<LexicalNode>>\n /**\n * Determines how a node should be exported to markdown\n */\n export?: (\n node: LexicalNode,\n\n exportChildren: (node: ElementNode) => string,\n\n exportFormat: (node: TextNode, textContent: string) => string,\n ) => null | string\n /**\n * For import operations, this function can be used to determine the end index of the match, after `importRegExp` has matched.\n * Without this function, the end index will be determined by the length of the match from `importRegExp`. Manually determining the end index can be useful if\n * the match from `importRegExp` is not the entire text content of the node. That way, `importRegExp` can be used to match only the start of the node, and `getEndIndex`\n * can be used to match the end of the node.\n *\n * @returns The end index of the match, or false if the match was unsuccessful and a different transformer should be tried.\n */\n getEndIndex?: (node: TextNode, match: RegExpMatchArray) => false | number\n /**\n * This regex determines what text is matched during markdown imports\n */\n importRegExp?: RegExp\n /**\n * This regex determines what text is matched for markdown shortcuts while typing in the editor\n */\n regExp: RegExp\n /**\n * Determines how the matched markdown text should be transformed into a node during the markdown import process\n *\n * @returns nothing, or a TextNode that may be a child of the new node that is created.\n * If a TextNode is returned, text format matching will be applied to it (e.g. bold, italic, etc.)\n */\n replace?: (node: TextNode, match: RegExpMatchArray) => TextNode | void\n /**\n * Single character that allows the transformer to trigger when typed in the editor. This does not affect markdown imports outside of the markdown shortcut plugin.\n * If the trigger is matched, the `regExp` will be used to match the text in the second step.\n */\n trigger?: string\n type: 'text-match'\n}>\n\nconst EMPTY_OR_WHITESPACE_ONLY = /^[\\t ]*$/\nconst ORDERED_LIST_REGEX = /^(\\s*)(\\d+)\\.\\s/\nconst UNORDERED_LIST_REGEX = /^(\\s*)[-*+]\\s/\nconst CHECK_LIST_REGEX = /^(\\s*)(?:-\\s)?\\s?(\\[(\\s|x)?\\])\\s/i\nconst HEADING_REGEX = /^(#{1,6})\\s/\nconst QUOTE_REGEX = /^>\\s/\nconst CODE_START_REGEX = /^[ \\t]*(\\\\`\\\\`\\\\`|```)(\\w+)?/\nconst CODE_END_REGEX = /[ \\t]*(\\\\`\\\\`\\\\`|```)$/\nconst CODE_SINGLE_LINE_REGEX = /^[ \\t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/\nconst TABLE_ROW_REG_EXP = /^\\|(.+)\\|\\s?$/\nconst TABLE_ROW_DIVIDER_REG_EXP = /^(\\| ?:?-*:? ?)+\\|\\s?$/\nconst TAG_START_REGEX = /^[ \\t]*<[a-z_][\\w-]*(?:\\s[^<>]*)?\\/?>/i\nconst TAG_END_REGEX = /^[ \\t]*<\\/[a-z_][\\w-]*\\s*>/i\n\n/**\n * A CommonMark hard line break marker: either a single backslash (`\\`) or two or\n * more trailing spaces, both placed at the end of a line before the newline.\n * See https://spec.commonmark.org/0.31.2/#hard-line-breaks\n */\nexport type MarkdownHardLineBreak = string\n\n/**\n * Stores the original hard line break marker on a `LineBreakNode` so it can be\n * preserved across a markdown import/export round trip instead of being\n * collapsed into a soft line break.\n *\n * Note: unlike upstream Lexical (which sets `resetOnCopyNode: true`), that option\n * does not exist in the `lexical` version pinned here (0.41.0), so it is omitted.\n */\nexport const hardLineBreakState = createState('mdHardLineBreak', {\n parse: (val): MarkdownHardLineBreak => {\n if (typeof val === 'string' && /^(\\\\| {2,})$/.test(val)) {\n return val\n }\n return ''\n },\n})\n\n/**\n * Detects a CommonMark hard line break marker at the end of a raw line.\n *\n * @returns a tuple of `[textWithoutMarker, marker]` when a marker is found, otherwise null.\n */\nexport function parseMarkdownHardLineBreak(line: string): [string, MarkdownHardLineBreak] | null {\n if (line.endsWith('\\\\')) {\n return [line.slice(0, -1), '\\\\']\n }\n\n const spaces = line.match(/^(.*?\\S)( {2,})$/)\n return spaces ? [spaces[1]!, spaces[2]!] : null\n}\n\nfunction hasNonWhitespaceContentOnLine(children: Array<LexicalNode>, endIndex: number): boolean {\n for (let i = endIndex - 1; i >= 0; i--) {\n if ($isLineBreakNode(children[i])) {\n return false\n }\n if (/\\S/.test(children[i]!.getTextContent())) {\n return true\n }\n }\n return false\n}\n\n/**\n * Removes a trailing hard line break marker from the last text node of `previousNode`\n * (if present) and returns the marker, so it can be carried onto a `LineBreakNode`.\n */\nfunction $extractMarkdownHardLineBreakMarker(\n previousNode: ElementNode,\n): MarkdownHardLineBreak | null {\n const children = previousNode.getChildren()\n const lastChildIndex = children.length - 1\n const lastChild = children[lastChildIndex]\n\n if (!$isTextNode(lastChild)) {\n return null\n }\n\n const lastText = lastChild.getTextContent()\n const hardLineBreak = parseMarkdownHardLineBreak(lastText)\n\n if (hardLineBreak !== null) {\n const [text, marker] = hardLineBreak\n lastChild.setTextContent(text)\n return marker\n }\n\n // Trailing whitespace may have been split into its own text node by inline\n // transformers (e.g. after formatted or linked content). Only treat it as a\n // hard break when there is preceding non-whitespace content on the same line.\n if (/^ {2,}$/.test(lastText) && hasNonWhitespaceContentOnLine(children, lastChildIndex)) {\n lastChild.setTextContent('')\n return lastText\n }\n\n return null\n}\n\n/**\n * Creates a `LineBreakNode` for a markdown line join, preserving any CommonMark\n * hard line break marker found at the end of `previousNode` via node state.\n */\nexport function $createMarkdownLineBreakNode(previousNode: ElementNode): LineBreakNode {\n const lineBreakNode = $createLineBreakNode()\n const hardLineBreak = $extractMarkdownHardLineBreakMarker(previousNode)\n\n if (hardLineBreak !== null) {\n $setState(lineBreakNode, hardLineBreakState, hardLineBreak)\n }\n\n return lineBreakNode\n}\n\nconst createBlockNode = (\n createNode: (match: Array<string>) => ElementNode,\n): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const node = createNode(match)\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n }\n}\n\n// Amount of spaces that define indentation level\n// TODO: should be an option\nconst LIST_INDENT_SIZE = 4\n\nfunction getIndent(whitespaces: string): number {\n const tabs = whitespaces.match(/\\t/g)\n const spaces = whitespaces.match(/ /g)\n\n let indent = 0\n\n if (tabs) {\n indent += tabs.length\n }\n\n if (spaces) {\n indent += Math.floor(spaces.length / LIST_INDENT_SIZE)\n }\n\n return indent\n}\n\nconst listReplace = (listType: ListType): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const previousNode = parentNode.getPreviousSibling()\n const nextNode = parentNode.getNextSibling()\n const listItem = $createListItemNode(listType === 'check' ? match[3] === 'x' : undefined)\n if ($isListNode(nextNode) && nextNode.getListType() === listType) {\n const firstChild = nextNode.getFirstChild()\n if (firstChild !== null) {\n firstChild.insertBefore(listItem)\n } else {\n // should never happen, but let's handle gracefully, just in case.\n nextNode.append(listItem)\n }\n parentNode.remove()\n } else if ($isListNode(previousNode) && previousNode.getListType() === listType) {\n previousNode.append(listItem)\n parentNode.remove()\n } else {\n const list = $createListNode(listType, listType === 'number' ? Number(match[2]) : undefined)\n list.append(listItem)\n parentNode.replace(list)\n }\n listItem.append(...children)\n listItem.select(0, 0)\n const indent = getIndent(match[1]!)\n if (indent) {\n listItem.setIndent(indent)\n }\n }\n}\n\nconst listExport = (\n listNode: ListNode,\n exportChildren: (node: ElementNode) => string,\n depth: number,\n): string => {\n const output: string[] = []\n const children = listNode.getChildren()\n let index = 0\n for (const listItemNode of children) {\n if ($isListItemNode(listItemNode)) {\n if (listItemNode.getChildrenSize() === 1) {\n const firstChild = listItemNode.getFirstChild()\n if ($isListNode(firstChild)) {\n output.push(listExport(firstChild, exportChildren, depth + 1))\n continue\n }\n }\n const indent = ' '.repeat(depth * LIST_INDENT_SIZE)\n const listType = listNode.getListType()\n const prefix =\n listType === 'number'\n ? `${listNode.getStart() + index}. `\n : listType === 'check'\n ? `- [${listItemNode.getChecked() ? 'x' : ' '}] `\n : '- '\n output.push(indent + prefix + exportChildren(listItemNode))\n index++\n }\n }\n\n return output.join('\\n')\n}\n\nexport const HEADING: ElementTransformer = {\n type: 'element',\n dependencies: [HeadingNode],\n export: (node, exportChildren) => {\n if (!$isHeadingNode(node)) {\n return null\n }\n const level = Number(node.getTag().slice(1))\n return '#'.repeat(level) + ' ' + exportChildren(node)\n },\n regExp: HEADING_REGEX,\n replace: createBlockNode((match) => {\n const tag = ('h' + match[1]!.length) as HeadingTagType\n return $createHeadingNode(tag)\n }),\n}\n\nexport const QUOTE: ElementTransformer = {\n type: 'element',\n dependencies: [QuoteNode],\n export: (node, exportChildren) => {\n if (!$isQuoteNode(node)) {\n return null\n }\n\n const lines = exportChildren(node).split('\\n')\n const output: string[] = []\n for (const line of lines) {\n output.push('> ' + line)\n }\n return output.join('\\n')\n },\n regExp: QUOTE_REGEX,\n replace: (parentNode, children, _match, isImport) => {\n if (isImport) {\n const previousNode = parentNode.getPreviousSibling()\n if ($isQuoteNode(previousNode)) {\n previousNode.splice(previousNode.getChildrenSize(), 0, [\n $createMarkdownLineBreakNode(previousNode),\n ...children,\n ])\n previousNode.select(0, 0)\n parentNode.remove()\n return\n }\n }\n\n const node = $createQuoteNode()\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n },\n}\n\nexport const UNORDERED_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: UNORDERED_LIST_REGEX,\n replace: listReplace('bullet'),\n}\n\nexport const CHECK_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: CHECK_LIST_REGEX,\n replace: listReplace('check'),\n}\n\nexport const ORDERED_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: ORDERED_LIST_REGEX,\n replace: listReplace('number'),\n}\n\nexport const INLINE_CODE: TextFormatTransformer = {\n type: 'text-format',\n format: ['code'],\n tag: '`',\n}\n\nexport const HIGHLIGHT: TextFormatTransformer = {\n type: 'text-format',\n format: ['highlight'],\n tag: '==',\n}\n\nexport const BOLD_ITALIC_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold', 'italic'],\n tag: '***',\n}\n\nexport const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold', 'italic'],\n intraword: false,\n tag: '___',\n}\n\nexport const BOLD_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold'],\n tag: '**',\n}\n\nexport const BOLD_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold'],\n intraword: false,\n tag: '__',\n}\n\nexport const STRIKETHROUGH: TextFormatTransformer = {\n type: 'text-format',\n format: ['strikethrough'],\n tag: '~~',\n}\n\nexport const ITALIC_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['italic'],\n tag: '*',\n}\n\nexport const ITALIC_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['italic'],\n intraword: false,\n tag: '_',\n}\n\nexport function normalizeMarkdown(input: string, shouldMergeAdjacentLines: boolean): string {\n const lines = input.split('\\n')\n let inCodeBlock = false\n const sanitizedLines: string[] = []\n let nestedDeepCodeBlock = 0\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n const lastLine = sanitizedLines[sanitizedLines.length - 1]\n // A hard line break marker on the current line only matters if another line follows it.\n const hardLineBreak = i < lines.length - 1 ? parseMarkdownHardLineBreak(line) : null\n const lastLineHasHardLineBreak =\n lastLine !== undefined && parseMarkdownHardLineBreak(lastLine) !== null\n\n // Code blocks of ```single line``` don't toggle the inCodeBlock flag\n if (CODE_SINGLE_LINE_REGEX.test(line)) {\n sanitizedLines.push(line)\n continue\n }\n\n if (CODE_END_REGEX.test(line)) {\n if (nestedDeepCodeBlock === 0) {\n inCodeBlock = true\n }\n if (nestedDeepCodeBlock === 1) {\n inCodeBlock = false\n }\n if (nestedDeepCodeBlock > 0) {\n nestedDeepCodeBlock--\n }\n sanitizedLines.push(line)\n continue\n }\n\n // Toggle inCodeBlock state when encountering start or end of a code block\n if (CODE_START_REGEX.test(line)) {\n inCodeBlock = true\n nestedDeepCodeBlock++\n sanitizedLines.push(line)\n continue\n }\n\n // If we are inside a code block, keep the line unchanged\n if (inCodeBlock) {\n sanitizedLines.push(line)\n continue\n }\n\n // In markdown the concept of \"empty paragraphs\" does not exist.\n // Blocks must be separated by an empty line. Non-empty adjacent lines must be merged.\n if (\n EMPTY_OR_WHITESPACE_ONLY.test(line) ||\n EMPTY_OR_WHITESPACE_ONLY.test(lastLine!) ||\n !lastLine ||\n HEADING_REGEX.test(lastLine) ||\n HEADING_REGEX.test(line) ||\n QUOTE_REGEX.test(line) ||\n ORDERED_LIST_REGEX.test(line) ||\n UNORDERED_LIST_REGEX.test(line) ||\n CHECK_LIST_REGEX.test(line) ||\n TABLE_ROW_REG_EXP.test(line) ||\n TABLE_ROW_DIVIDER_REG_EXP.test(line) ||\n // Don't merge the next line into a line that ends with a hard line break marker.\n lastLineHasHardLineBreak ||\n !shouldMergeAdjacentLines ||\n TAG_START_REGEX.test(line) ||\n TAG_END_REGEX.test(line) ||\n TAG_START_REGEX.test(lastLine) ||\n TAG_END_REGEX.test(lastLine) ||\n CODE_END_REGEX.test(lastLine)\n ) {\n sanitizedLines.push(line)\n } else {\n // Preserve a trailing hard line break marker on the merged line so it survives import.\n sanitizedLines[sanitizedLines.length - 1] =\n lastLine + ' ' + (hardLineBreak === null ? line.trim() : line.trimStart())\n }\n }\n\n return sanitizedLines.join('\\n')\n}\n"],"mappings":"AAAA,sDACA;;;;;;wDAmBA,SACEA,mBAAmB,EACnBC,eAAe,EACfC,eAAe,EACfC,WAAW,EACXC,YAAY,EACZC,QAAQ,QACH;AACP,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,WAAW,EACXC,SAAS,QACJ;AACP,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,WAAW,EACXC,SAAS,EACTC,WAAW,QACN;AA8JP,MAAMC,wBAAA,GAA2B;AACjC,MAAMC,kBAAA,GAAqB;AAC3B,MAAMC,oBAAA,GAAuB;AAC7B,MAAMC,gBAAA,GAAmB;AACzB,MAAMC,aAAA,GAAgB;AACtB,MAAMC,WAAA,GAAc;AACpB,MAAMC,gBAAA,GAAmB;AACzB,MAAMC,cAAA,GAAiB;AACvB,MAAMC,sBAAA,GAAyB;AAC/B,MAAMC,iBAAA,GAAoB;AAC1B,MAAMC,yBAAA,GAA4B;AAClC,MAAMC,eAAA,GAAkB;AACxB,MAAMC,aAAA,GAAgB;AAStB;;;;;;;;AAQA,OAAO,MAAMC,kBAAA,GAAqBd,WAAA,CAAY,mBAAmB;EAC/De,KAAA,EAAQC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AAA,CAAgBK,IAAI,CAACsG,QAAA,KACrB1G,aAAA,CAAcI,IAAI,CAACsG,QAAA,KACnB/G,cAAA,CAAeS,IAAI,CAACsG,QAAA,GACpB;MACAF,cAAA,CAAetC,IAAI,CAAC5D,IAAA;IACtB,OAAO;MACL;MACAkG,cAAc,CAACA,cAAA,CAAepF,MAAM,GAAG,EAAE,GACvCsF,QAAA,GAAW,OAAOnF,aAAA,KAAkB,OAAOjB,IAAA,CAAKsG,IAAI,KAAKtG,IAAA,CAAKuG,SAAS,EAAC;IAC5E;EACF;EAEA,OAAOL,cAAA,CAAejC,IAAI,CAAC;AAC7B","ignoreList":[]}
@@ -1,22 +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 { TextNode } from 'lexical';
9
- import type { TextFormatTransformersIndex } from './MarkdownImport.js';
10
- import type { TextFormatTransformer } from './MarkdownTransformers.js';
11
- export declare function findOutermostTextFormatTransformer(textNode: TextNode, textFormatTransformersIndex: TextFormatTransformersIndex): {
12
- endIndex: number;
13
- match: RegExpMatchArray;
14
- startIndex: number;
15
- transformer: TextFormatTransformer;
16
- } | null;
17
- export declare function importTextFormatTransformer(textNode: TextNode, startIndex: number, endIndex: number, transformer: TextFormatTransformer, match: RegExpMatchArray): {
18
- nodeAfter: TextNode | undefined;
19
- nodeBefore: TextNode | undefined;
20
- transformedNode: TextNode;
21
- };
22
- //# sourceMappingURL=importTextFormatTransformer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importTextFormatTransformer.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/importTextFormatTransformer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAItE,wBAAgB,kCAAkC,CAChD,QAAQ,EAAE,QAAQ,EAClB,2BAA2B,EAAE,2BAA2B,GACvD;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,gBAAgB,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,qBAAqB,CAAA;CACnC,GAAG,IAAI,CAoBP;AA+CD,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,qBAAqB,EAClC,KAAK,EAAE,gBAAgB,GACtB;IACD,SAAS,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC/B,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAA;IAChC,eAAe,EAAE,QAAQ,CAAA;CAC1B,CA0CA"}