@blocknote/core 0.21.0 → 0.22.0

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 (391) hide show
  1. package/dist/blocknote.js +1023 -999
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +7 -7
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/dist/tsconfig.tsbuildinfo +1 -1
  7. package/dist/webpack-stats.json +1 -1
  8. package/package.json +3 -3
  9. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +96 -0
  10. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +96 -0
  11. package/src/api/clipboard/__snapshots__/external/pasteImage.html +111 -0
  12. package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +96 -0
  13. package/src/api/clipboard/__snapshots__/external/pasteTable.html +149 -0
  14. package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +124 -0
  15. package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +1 -0
  16. package/src/api/clipboard/clipboardExternal.test.ts +161 -0
  17. package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +60 -38
  18. package/src/api/clipboard/testUtil.ts +27 -0
  19. package/src/api/clipboard/toClipboard/copyExtension.ts +1 -0
  20. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
  21. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +3 -1
  22. package/src/api/nodeConversions/nodeToBlock.ts +4 -1
  23. package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
  24. package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
  25. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -19
  26. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +3 -15
  27. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
  28. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +25 -5
  29. package/src/editor/Block.css +3 -3
  30. package/src/editor/BlockNoteEditor.test.ts +21 -1
  31. package/src/editor/editor.css +6 -6
  32. package/src/editor/transformPasted.ts +57 -4
  33. package/src/schema/blocks/createSpec.ts +1 -1
  34. package/src/schema/blocks/internal.ts +16 -6
  35. package/src/schema/inlineContent/internal.ts +4 -1
  36. package/src/schema/propTypes.ts +41 -18
  37. package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -0
  38. package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
  39. package/types/src/api/clipboard/testUtil.d.ts +509 -0
  40. package/types/src/api/testUtil/cases/customBlocks.d.ts +8 -0
  41. package/types/src/api/testUtil/cases/customInlineContent.d.ts +8 -0
  42. package/types/src/api/testUtil/cases/customStyles.d.ts +8 -0
  43. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
  44. package/types/src/blocks/defaultBlocks.d.ts +16 -0
  45. package/types/src/editor/transformPasted.d.ts +8 -4
  46. package/types/src/schema/propTypes.d.ts +20 -2
  47. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +0 -30
  48. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +0 -1
  49. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +0 -99
  50. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +0 -1
  51. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +0 -97
  52. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +0 -1
  53. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +0 -88
  54. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +0 -1
  55. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +0 -219
  56. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +0 -1
  57. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +0 -175
  58. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +0 -1
  59. package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +0 -57
  60. package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +0 -1
  61. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +0 -5
  62. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +0 -1
  63. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +0 -31
  64. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +0 -1
  65. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +0 -71
  66. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +0 -1
  67. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +0 -157
  68. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +0 -1
  69. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +0 -27
  70. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +0 -1
  71. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +0 -67
  72. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +0 -1
  73. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +0 -148
  74. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +0 -1
  75. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +0 -252
  76. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +0 -1
  77. package/dist/src/api/blockManipulation/getBlock/getBlock.js +0 -56
  78. package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +0 -1
  79. package/dist/src/api/blockManipulation/insertContentAt.js +0 -64
  80. package/dist/src/api/blockManipulation/insertContentAt.js.map +0 -1
  81. package/dist/src/api/blockManipulation/selections/selection.js +0 -149
  82. package/dist/src/api/blockManipulation/selections/selection.js.map +0 -1
  83. package/dist/src/api/blockManipulation/selections/selection.test.js +0 -39
  84. package/dist/src/api/blockManipulation/selections/selection.test.js.map +0 -1
  85. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +0 -79
  86. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +0 -1
  87. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +0 -33
  88. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +0 -1
  89. package/dist/src/api/blockManipulation/setupTestEnv.js +0 -172
  90. package/dist/src/api/blockManipulation/setupTestEnv.js.map +0 -1
  91. package/dist/src/api/clipboard/clipboard.test.js +0 -249
  92. package/dist/src/api/clipboard/clipboard.test.js.map +0 -1
  93. package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +0 -8
  94. package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +0 -1
  95. package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +0 -38
  96. package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +0 -1
  97. package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +0 -111
  98. package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +0 -1
  99. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +0 -25
  100. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +0 -1
  101. package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +0 -57
  102. package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +0 -1
  103. package/dist/src/api/clipboard/toClipboard/copyExtension.js +0 -134
  104. package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +0 -1
  105. package/dist/src/api/exporters/html/externalHTMLExporter.js +0 -35
  106. package/dist/src/api/exporters/html/externalHTMLExporter.js.map +0 -1
  107. package/dist/src/api/exporters/html/htmlConversion.test.js +0 -72
  108. package/dist/src/api/exporters/html/htmlConversion.test.js.map +0 -1
  109. package/dist/src/api/exporters/html/internalHTMLSerializer.js +0 -21
  110. package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +0 -1
  111. package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +0 -141
  112. package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +0 -1
  113. package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +0 -96
  114. package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +0 -1
  115. package/dist/src/api/exporters/markdown/markdownExporter.js +0 -31
  116. package/dist/src/api/exporters/markdown/markdownExporter.js.map +0 -1
  117. package/dist/src/api/exporters/markdown/markdownExporter.test.js +0 -57
  118. package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +0 -1
  119. package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +0 -33
  120. package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +0 -1
  121. package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +0 -37
  122. package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +0 -1
  123. package/dist/src/api/getBlockInfoFromPos.js +0 -165
  124. package/dist/src/api/getBlockInfoFromPos.js.map +0 -1
  125. package/dist/src/api/nodeConversions/blockToNode.js +0 -197
  126. package/dist/src/api/nodeConversions/blockToNode.js.map +0 -1
  127. package/dist/src/api/nodeConversions/fragmentToBlocks.js +0 -50
  128. package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +0 -1
  129. package/dist/src/api/nodeConversions/nodeConversions.test.js +0 -54
  130. package/dist/src/api/nodeConversions/nodeConversions.test.js.map +0 -1
  131. package/dist/src/api/nodeConversions/nodeToBlock.js +0 -316
  132. package/dist/src/api/nodeConversions/nodeToBlock.js.map +0 -1
  133. package/dist/src/api/nodeUtil.js +0 -28
  134. package/dist/src/api/nodeUtil.js.map +0 -1
  135. package/dist/src/api/parsers/html/parseHTML.js +0 -19
  136. package/dist/src/api/parsers/html/parseHTML.js.map +0 -1
  137. package/dist/src/api/parsers/html/parseHTML.test.js +0 -470
  138. package/dist/src/api/parsers/html/parseHTML.test.js.map +0 -1
  139. package/dist/src/api/parsers/html/util/nestedLists.js +0 -106
  140. package/dist/src/api/parsers/html/util/nestedLists.js.map +0 -1
  141. package/dist/src/api/parsers/html/util/nestedLists.test.js +0 -166
  142. package/dist/src/api/parsers/html/util/nestedLists.test.js.map +0 -1
  143. package/dist/src/api/parsers/markdown/parseMarkdown.js +0 -52
  144. package/dist/src/api/parsers/markdown/parseMarkdown.js.map +0 -1
  145. package/dist/src/api/parsers/markdown/parseMarkdown.test.js +0 -112
  146. package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +0 -1
  147. package/dist/src/api/testUtil/cases/customBlocks.js +0 -313
  148. package/dist/src/api/testUtil/cases/customBlocks.js.map +0 -1
  149. package/dist/src/api/testUtil/cases/customInlineContent.js +0 -91
  150. package/dist/src/api/testUtil/cases/customInlineContent.js.map +0 -1
  151. package/dist/src/api/testUtil/cases/customStyles.js +0 -83
  152. package/dist/src/api/testUtil/cases/customStyles.js.map +0 -1
  153. package/dist/src/api/testUtil/cases/defaultSchema.js +0 -673
  154. package/dist/src/api/testUtil/cases/defaultSchema.js.map +0 -1
  155. package/dist/src/api/testUtil/index.js +0 -2
  156. package/dist/src/api/testUtil/index.js.map +0 -1
  157. package/dist/src/api/testUtil/partialBlockTestUtil.js +0 -114
  158. package/dist/src/api/testUtil/partialBlockTestUtil.js.map +0 -1
  159. package/dist/src/api/testUtil/paste.js +0 -29
  160. package/dist/src/api/testUtil/paste.js.map +0 -1
  161. package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +0 -104
  162. package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
  163. package/dist/src/blocks/AudioBlockContent/parseAudioElement.js +0 -5
  164. package/dist/src/blocks/AudioBlockContent/parseAudioElement.js.map +0 -1
  165. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +0 -281
  166. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +0 -1
  167. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +0 -110
  168. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +0 -1
  169. package/dist/src/blocks/FileBlockContent/FileBlockContent.js +0 -71
  170. package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
  171. package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js +0 -5
  172. package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js.map +0 -1
  173. package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js +0 -10
  174. package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js.map +0 -1
  175. package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js +0 -39
  176. package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js.map +0 -1
  177. package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js +0 -51
  178. package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js.map +0 -1
  179. package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js +0 -17
  180. package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js.map +0 -1
  181. package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js +0 -147
  182. package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js.map +0 -1
  183. package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js +0 -9
  184. package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js.map +0 -1
  185. package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js +0 -11
  186. package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js.map +0 -1
  187. package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +0 -15
  188. package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +0 -1
  189. package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +0 -145
  190. package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +0 -1
  191. package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +0 -114
  192. package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
  193. package/dist/src/blocks/ImageBlockContent/parseImageElement.js +0 -6
  194. package/dist/src/blocks/ImageBlockContent/parseImageElement.js.map +0 -1
  195. package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +0 -113
  196. package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +0 -1
  197. package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +0 -224
  198. package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +0 -1
  199. package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +0 -45
  200. package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +0 -1
  201. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +0 -58
  202. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +0 -1
  203. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +0 -130
  204. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +0 -1
  205. package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +0 -52
  206. package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +0 -1
  207. package/dist/src/blocks/TableBlockContent/TableBlockContent.js +0 -129
  208. package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +0 -1
  209. package/dist/src/blocks/TableBlockContent/TableExtension.js +0 -64
  210. package/dist/src/blocks/TableBlockContent/TableExtension.js.map +0 -1
  211. package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +0 -114
  212. package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
  213. package/dist/src/blocks/VideoBlockContent/parseVideoElement.js +0 -6
  214. package/dist/src/blocks/VideoBlockContent/parseVideoElement.js.map +0 -1
  215. package/dist/src/blocks/defaultBlockHelpers.js +0 -50
  216. package/dist/src/blocks/defaultBlockHelpers.js.map +0 -1
  217. package/dist/src/blocks/defaultBlockTypeGuards.js +0 -40
  218. package/dist/src/blocks/defaultBlockTypeGuards.js.map +0 -1
  219. package/dist/src/blocks/defaultBlocks.js +0 -50
  220. package/dist/src/blocks/defaultBlocks.js.map +0 -1
  221. package/dist/src/blocks/defaultProps.js +0 -19
  222. package/dist/src/blocks/defaultProps.js.map +0 -1
  223. package/dist/src/editor/BlockNoteEditor.js +0 -751
  224. package/dist/src/editor/BlockNoteEditor.js.map +0 -1
  225. package/dist/src/editor/BlockNoteEditor.test.js +0 -65
  226. package/dist/src/editor/BlockNoteEditor.test.js.map +0 -1
  227. package/dist/src/editor/BlockNoteExtensions.js +0 -192
  228. package/dist/src/editor/BlockNoteExtensions.js.map +0 -1
  229. package/dist/src/editor/BlockNoteSchema.js +0 -38
  230. package/dist/src/editor/BlockNoteSchema.js.map +0 -1
  231. package/dist/src/editor/BlockNoteTipTapEditor.js +0 -169
  232. package/dist/src/editor/BlockNoteTipTapEditor.js.map +0 -1
  233. package/dist/src/editor/cursorPositionTypes.js +0 -2
  234. package/dist/src/editor/cursorPositionTypes.js.map +0 -1
  235. package/dist/src/editor/defaultColors.js +0 -77
  236. package/dist/src/editor/defaultColors.js.map +0 -1
  237. package/dist/src/editor/selectionTypes.js +0 -2
  238. package/dist/src/editor/selectionTypes.js.map +0 -1
  239. package/dist/src/editor/transformPasted.js +0 -79
  240. package/dist/src/editor/transformPasted.js.map +0 -1
  241. package/dist/src/exporter/Exporter.js +0 -36
  242. package/dist/src/exporter/Exporter.js.map +0 -1
  243. package/dist/src/exporter/index.js +0 -3
  244. package/dist/src/exporter/index.js.map +0 -1
  245. package/dist/src/exporter/mapping.js +0 -12
  246. package/dist/src/exporter/mapping.js.map +0 -1
  247. package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +0 -30
  248. package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +0 -1
  249. package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +0 -39
  250. package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +0 -1
  251. package/dist/src/extensions/FilePanel/FilePanelPlugin.js +0 -131
  252. package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +0 -1
  253. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +0 -197
  254. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +0 -1
  255. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +0 -341
  256. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +0 -1
  257. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +0 -251
  258. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +0 -1
  259. package/dist/src/extensions/LinkToolbar/protocols.js +0 -14
  260. package/dist/src/extensions/LinkToolbar/protocols.js.map +0 -1
  261. package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +0 -54
  262. package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +0 -1
  263. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +0 -90
  264. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +0 -1
  265. package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +0 -187
  266. package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +0 -1
  267. package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +0 -68
  268. package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +0 -1
  269. package/dist/src/extensions/SideMenu/SideMenuPlugin.js +0 -347
  270. package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
  271. package/dist/src/extensions/SideMenu/dragging.js +0 -135
  272. package/dist/src/extensions/SideMenu/dragging.js.map +0 -1
  273. package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +0 -2
  274. package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +0 -1
  275. package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +0 -2
  276. package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +0 -1
  277. package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +0 -245
  278. package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +0 -1
  279. package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +0 -26
  280. package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +0 -1
  281. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +0 -241
  282. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +0 -1
  283. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +0 -579
  284. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +0 -1
  285. package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +0 -36
  286. package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +0 -1
  287. package/dist/src/extensions/TextColor/TextColorExtension.js +0 -29
  288. package/dist/src/extensions/TextColor/TextColorExtension.js.map +0 -1
  289. package/dist/src/extensions/TextColor/TextColorMark.js +0 -37
  290. package/dist/src/extensions/TextColor/TextColorMark.js.map +0 -1
  291. package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +0 -58
  292. package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +0 -1
  293. package/dist/src/extensions/UniqueID/UniqueID.js +0 -283
  294. package/dist/src/extensions/UniqueID/UniqueID.js.map +0 -1
  295. package/dist/src/extensions/getDraggableBlockFromElement.js +0 -13
  296. package/dist/src/extensions/getDraggableBlockFromElement.js.map +0 -1
  297. package/dist/src/extensions-shared/UiElementPosition.js +0 -2
  298. package/dist/src/extensions-shared/UiElementPosition.js.map +0 -1
  299. package/dist/src/i18n/dictionary.js +0 -4
  300. package/dist/src/i18n/dictionary.js.map +0 -1
  301. package/dist/src/i18n/locales/ar.js +0 -298
  302. package/dist/src/i18n/locales/ar.js.map +0 -1
  303. package/dist/src/i18n/locales/de.js +0 -313
  304. package/dist/src/i18n/locales/de.js.map +0 -1
  305. package/dist/src/i18n/locales/en.js +0 -314
  306. package/dist/src/i18n/locales/en.js.map +0 -1
  307. package/dist/src/i18n/locales/es.js +0 -312
  308. package/dist/src/i18n/locales/es.js.map +0 -1
  309. package/dist/src/i18n/locales/fr.js +0 -313
  310. package/dist/src/i18n/locales/fr.js.map +0 -1
  311. package/dist/src/i18n/locales/hr.js +0 -308
  312. package/dist/src/i18n/locales/hr.js.map +0 -1
  313. package/dist/src/i18n/locales/index.js +0 -16
  314. package/dist/src/i18n/locales/index.js.map +0 -1
  315. package/dist/src/i18n/locales/is.js +0 -305
  316. package/dist/src/i18n/locales/is.js.map +0 -1
  317. package/dist/src/i18n/locales/ja.js +0 -333
  318. package/dist/src/i18n/locales/ja.js.map +0 -1
  319. package/dist/src/i18n/locales/ko.js +0 -326
  320. package/dist/src/i18n/locales/ko.js.map +0 -1
  321. package/dist/src/i18n/locales/nl.js +0 -313
  322. package/dist/src/i18n/locales/nl.js.map +0 -1
  323. package/dist/src/i18n/locales/pl.js +0 -297
  324. package/dist/src/i18n/locales/pl.js.map +0 -1
  325. package/dist/src/i18n/locales/pt.js +0 -305
  326. package/dist/src/i18n/locales/pt.js.map +0 -1
  327. package/dist/src/i18n/locales/ru.js +0 -340
  328. package/dist/src/i18n/locales/ru.js.map +0 -1
  329. package/dist/src/i18n/locales/vi.js +0 -312
  330. package/dist/src/i18n/locales/vi.js.map +0 -1
  331. package/dist/src/i18n/locales/zh.js +0 -346
  332. package/dist/src/i18n/locales/zh.js.map +0 -1
  333. package/dist/src/index.js +0 -63
  334. package/dist/src/index.js.map +0 -1
  335. package/dist/src/pm-nodes/BlockContainer.js +0 -72
  336. package/dist/src/pm-nodes/BlockContainer.js.map +0 -1
  337. package/dist/src/pm-nodes/BlockGroup.js +0 -43
  338. package/dist/src/pm-nodes/BlockGroup.js.map +0 -1
  339. package/dist/src/pm-nodes/Doc.js +0 -7
  340. package/dist/src/pm-nodes/Doc.js.map +0 -1
  341. package/dist/src/pm-nodes/index.js +0 -4
  342. package/dist/src/pm-nodes/index.js.map +0 -1
  343. package/dist/src/schema/blocks/createSpec.js +0 -126
  344. package/dist/src/schema/blocks/createSpec.js.map +0 -1
  345. package/dist/src/schema/blocks/internal.js +0 -147
  346. package/dist/src/schema/blocks/internal.js.map +0 -1
  347. package/dist/src/schema/blocks/types.js +0 -2
  348. package/dist/src/schema/blocks/types.js.map +0 -1
  349. package/dist/src/schema/index.js +0 -11
  350. package/dist/src/schema/index.js.map +0 -1
  351. package/dist/src/schema/inlineContent/createSpec.js +0 -64
  352. package/dist/src/schema/inlineContent/createSpec.js.map +0 -1
  353. package/dist/src/schema/inlineContent/internal.js +0 -52
  354. package/dist/src/schema/inlineContent/internal.js.map +0 -1
  355. package/dist/src/schema/inlineContent/types.js +0 -10
  356. package/dist/src/schema/inlineContent/types.js.map +0 -1
  357. package/dist/src/schema/propTypes.js +0 -2
  358. package/dist/src/schema/propTypes.js.map +0 -1
  359. package/dist/src/schema/styles/createSpec.js +0 -48
  360. package/dist/src/schema/styles/createSpec.js.map +0 -1
  361. package/dist/src/schema/styles/internal.js +0 -53
  362. package/dist/src/schema/styles/internal.js.map +0 -1
  363. package/dist/src/schema/styles/types.js +0 -2
  364. package/dist/src/schema/styles/types.js.map +0 -1
  365. package/dist/src/util/EventEmitter.js +0 -33
  366. package/dist/src/util/EventEmitter.js.map +0 -1
  367. package/dist/src/util/browser.js +0 -17
  368. package/dist/src/util/browser.js.map +0 -1
  369. package/dist/src/util/combineByGroup.js +0 -20
  370. package/dist/src/util/combineByGroup.js.map +0 -1
  371. package/dist/src/util/esmDependencies.js +0 -35
  372. package/dist/src/util/esmDependencies.js.map +0 -1
  373. package/dist/src/util/string.js +0 -14
  374. package/dist/src/util/string.js.map +0 -1
  375. package/dist/src/util/typescript.js +0 -12
  376. package/dist/src/util/typescript.js.map +0 -1
  377. /package/src/api/clipboard/__snapshots__/{childToParent.html → internal/childToParent.html} +0 -0
  378. /package/src/api/clipboard/__snapshots__/{childrenToNextParent.html → internal/childrenToNextParent.html} +0 -0
  379. /package/src/api/clipboard/__snapshots__/{childrenToNextParentsChildren.html → internal/childrenToNextParentsChildren.html} +0 -0
  380. /package/src/api/clipboard/__snapshots__/{image.html → internal/image.html} +0 -0
  381. /package/src/api/clipboard/__snapshots__/{multipleChildren.html → internal/multipleChildren.html} +0 -0
  382. /package/src/api/clipboard/__snapshots__/{multipleStyledText.html → internal/multipleStyledText.html} +0 -0
  383. /package/src/api/clipboard/__snapshots__/{nestedImage.html → internal/nestedImage.html} +0 -0
  384. /package/src/api/clipboard/__snapshots__/{partialChildToParent.html → internal/partialChildToParent.html} +0 -0
  385. /package/src/api/clipboard/__snapshots__/{styledText.html → internal/styledText.html} +0 -0
  386. /package/src/api/clipboard/__snapshots__/{tableAllCells.html → internal/tableAllCells.html} +0 -0
  387. /package/src/api/clipboard/__snapshots__/{tableCell.html → internal/tableCell.html} +0 -0
  388. /package/src/api/clipboard/__snapshots__/{tableCellText.html → internal/tableCellText.html} +0 -0
  389. /package/src/api/clipboard/__snapshots__/{tableRow.html → internal/tableRow.html} +0 -0
  390. /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
  391. /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
@@ -1,134 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import { NodeSelection, Plugin } from "prosemirror-state";
3
- import { CellSelection } from "prosemirror-tables";
4
- import * as pmView from "prosemirror-view";
5
- import { createExternalHTMLExporter } from "../../exporters/html/externalHTMLExporter.js";
6
- import { cleanHTMLToMarkdown } from "../../exporters/markdown/markdownExporter.js";
7
- import { fragmentToBlocks } from "../../nodeConversions/fragmentToBlocks.js";
8
- import { contentNodeToInlineContent, contentNodeToTableContent, } from "../../nodeConversions/nodeToBlock.js";
9
- function fragmentToExternalHTML(view, selectedFragment, editor) {
10
- let isWithinBlockContent = false;
11
- const isWithinTable = view.state.selection instanceof CellSelection;
12
- if (!isWithinTable) {
13
- // Checks whether block ancestry should be included when creating external
14
- // HTML. If the selection is within a block content node, the block ancestry
15
- // is excluded as we only care about the inline content.
16
- const fragmentWithoutParents = view.state.doc.slice(view.state.selection.from, view.state.selection.to, false).content;
17
- const children = [];
18
- for (let i = 0; i < fragmentWithoutParents.childCount; i++) {
19
- children.push(fragmentWithoutParents.child(i));
20
- }
21
- isWithinBlockContent =
22
- children.find((child) => child.type.isInGroup("bnBlock") ||
23
- child.type.name === "blockGroup" ||
24
- child.type.spec.group === "blockContent") === undefined;
25
- if (isWithinBlockContent) {
26
- selectedFragment = fragmentWithoutParents;
27
- }
28
- }
29
- let externalHTML;
30
- const externalHTMLExporter = createExternalHTMLExporter(view.state.schema, editor);
31
- if (isWithinTable) {
32
- if (selectedFragment.firstChild?.type.name === "table") {
33
- // contentNodeToTableContent expects the fragment of the content of a table, not the table node itself
34
- // but cellselection.content() returns the table node itself if all cells and columns are selected
35
- selectedFragment = selectedFragment.firstChild.content;
36
- }
37
- // first convert selection to blocknote-style table content, and then
38
- // pass this to the exporter
39
- const ic = contentNodeToTableContent(selectedFragment, editor.schema.inlineContentSchema, editor.schema.styleSchema);
40
- externalHTML = `<table>${externalHTMLExporter.exportInlineContent(ic, {})}</table>`;
41
- }
42
- else if (isWithinBlockContent) {
43
- // first convert selection to blocknote-style inline content, and then
44
- // pass this to the exporter
45
- const ic = contentNodeToInlineContent(selectedFragment, editor.schema.inlineContentSchema, editor.schema.styleSchema);
46
- externalHTML = externalHTMLExporter.exportInlineContent(ic, {});
47
- }
48
- else {
49
- const blocks = fragmentToBlocks(selectedFragment, editor.schema);
50
- externalHTML = externalHTMLExporter.exportBlocks(blocks, {});
51
- }
52
- return externalHTML;
53
- }
54
- export function selectedFragmentToHTML(view, editor) {
55
- // Checks if a `blockContent` node is being copied and expands
56
- // the selection to the parent `blockContainer` node. This is
57
- // for the use-case in which only a block without content is
58
- // selected, e.g. an image block.
59
- if ("node" in view.state.selection &&
60
- view.state.selection.node.type.spec.group === "blockContent") {
61
- editor.dispatch(editor._tiptapEditor.state.tr.setSelection(new NodeSelection(view.state.doc.resolve(view.state.selection.from - 1))));
62
- }
63
- // Uses default ProseMirror clipboard serialization.
64
- const clipboardHTML = pmView.__serializeForClipboard(view, view.state.selection.content()).dom.innerHTML;
65
- const selectedFragment = view.state.selection.content().content;
66
- const externalHTML = fragmentToExternalHTML(view, selectedFragment, editor);
67
- const markdown = cleanHTMLToMarkdown(externalHTML);
68
- return { clipboardHTML, externalHTML, markdown };
69
- }
70
- const copyToClipboard = (editor, view, event) => {
71
- // Stops the default browser copy behaviour.
72
- event.preventDefault();
73
- event.clipboardData.clearData();
74
- const { clipboardHTML, externalHTML, markdown } = selectedFragmentToHTML(view, editor);
75
- // TODO: Writing to other MIME types not working in Safari for
76
- // some reason.
77
- event.clipboardData.setData("blocknote/html", clipboardHTML);
78
- event.clipboardData.setData("text/html", externalHTML);
79
- event.clipboardData.setData("text/plain", markdown);
80
- };
81
- export const createCopyToClipboardExtension = (editor) => Extension.create({
82
- name: "copyToClipboard",
83
- addProseMirrorPlugins() {
84
- return [
85
- new Plugin({
86
- props: {
87
- handleDOMEvents: {
88
- copy(view, event) {
89
- copyToClipboard(editor, view, event);
90
- // Prevent default PM handler to be called
91
- return true;
92
- },
93
- cut(view, event) {
94
- copyToClipboard(editor, view, event);
95
- if (view.editable) {
96
- view.dispatch(view.state.tr.deleteSelection());
97
- }
98
- // Prevent default PM handler to be called
99
- return true;
100
- },
101
- // This is for the use-case in which only a block without content
102
- // is selected, e.g. an image block, and dragged (not using the
103
- // drag handle).
104
- dragstart(view, event) {
105
- // Checks if a `NodeSelection` is active.
106
- if (!("node" in view.state.selection)) {
107
- return;
108
- }
109
- // Checks if a `blockContent` node is being dragged.
110
- if (view.state.selection.node.type.spec.group !==
111
- "blockContent") {
112
- return;
113
- }
114
- // Expands the selection to the parent `blockContainer` node.
115
- editor.dispatch(editor._tiptapEditor.state.tr.setSelection(new NodeSelection(view.state.doc.resolve(view.state.selection.from - 1))));
116
- // Stops the default browser drag start behaviour.
117
- event.preventDefault();
118
- event.dataTransfer.clearData();
119
- const { clipboardHTML, externalHTML, markdown } = selectedFragmentToHTML(view, editor);
120
- // TODO: Writing to other MIME types not working in Safari for
121
- // some reason.
122
- event.dataTransfer.setData("blocknote/html", clipboardHTML);
123
- event.dataTransfer.setData("text/html", externalHTML);
124
- event.dataTransfer.setData("text/plain", markdown);
125
- // Prevent default PM handler to be called
126
- return true;
127
- },
128
- },
129
- },
130
- }),
131
- ];
132
- },
133
- });
134
- //# sourceMappingURL=copyExtension.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copyExtension.js","sourceRoot":"","sources":["../../../../../src/api/clipboard/toClipboard/copyExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAS3C,O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C;4BAED,6DAA6D;4BAC7D,MAAM,CAAC,QAAQ,CACb,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CACxC,IAAI,aAAa,CACf,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,CACtD,CACF,CACF,CAAC;4BAEF,kDAAkD;4BAClD,KAAK,CAAC,cAAc,EAAE,CAAC;4BACvB,KAAK,CAAC,YAAa,CAAC,SAAS,EAAE,CAAC;4BAEhC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,GAC7C,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;4BAEvC,8DAA8D;4BAC9D,gBAAgB;4BAChB,KAAK,CAAC,YAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;4BAC7D,KAAK,CAAC,YAAa,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;4BACvD,KAAK,CAAC,YAAa,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;4BAEpD,0CAA0C;4BAC1C,OAAO,IAAI,CAAC;wBACd,CAAC;qBACF;iBACF;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -1,35 +0,0 @@
1
- import { DOMSerializer } from "prosemirror-model";
2
- import { serializeBlocksExternalHTML, serializeInlineContentExternalHTML, } from "./util/serializeBlocksExternalHTML.js";
3
- // Used to export BlockNote blocks and ProseMirror nodes to HTML for use outside
4
- // the editor. Blocks are exported using the `toExternalHTML` method in their
5
- // `blockSpec`, or `toInternalHTML` if `toExternalHTML` is not defined.
6
- //
7
- // The HTML created by this serializer is different to what's rendered by the
8
- // editor to the DOM. This also means that data is likely to be lost when
9
- // converting back to original blocks. The differences in the output HTML are:
10
- // 1. It doesn't include the `blockGroup` and `blockContainer` wrappers meaning
11
- // that nesting is not preserved for non-list-item blocks.
12
- // 2. `li` items in the output HTML are wrapped in `ul` or `ol` elements.
13
- // 3. While nesting for list items is preserved, other types of blocks nested
14
- // inside a list are un-nested and a new list is created after them.
15
- // 4. The HTML is wrapped in a single `div` element.
16
- // Needs to be sync because it's used in drag handler event (SideMenuPlugin)
17
- // Ideally, call `await initializeESMDependencies()` before calling this function
18
- export const createExternalHTMLExporter = (schema, editor) => {
19
- const serializer = DOMSerializer.fromSchema(schema);
20
- return {
21
- exportBlocks: (blocks, options) => {
22
- const html = serializeBlocksExternalHTML(editor, blocks, serializer, new Set(["numberedListItem"]), new Set(["bulletListItem", "checkListItem"]), options);
23
- const div = document.createElement("div");
24
- div.append(html);
25
- return div.innerHTML;
26
- },
27
- exportInlineContent: (inlineContent, options) => {
28
- const domFragment = serializeInlineContentExternalHTML(editor, inlineContent, serializer, options);
29
- const parent = document.createElement("div");
30
- parent.append(domFragment.cloneNode(true));
31
- return parent.innerHTML;
32
- },
33
- };
34
- };
35
- //# sourceMappingURL=externalHTMLExporter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"externalHTMLExporter.js","sourceRoot":"","sources":["../../../../../src/api/exporters/html/externalHTMLExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,mBAAmB,CAAC;AAU1D,OAAO,EACL,2BAA2B,EAC3B,kCAAkC,GACnC,MAAM,uCAAuC,CAAC;AAE/C,gFAAgF;AAChF,6EAA6E;AAC7E,uEAAuE;AACvE,EAAE;AACF,6EAA6E;AAC7E,yEAAyE;AACzE,8EAA8E;AAC9E,+EAA+E;AAC/E,0DAA0D;AAC1D,yEAAyE;AACzE,6EAA6E;AAC7E,oEAAoE;AACpE,oDAAoD;AAEpD,4EAA4E;AAC5E,iFAAiF;AACjF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAKxC,MAAc,EACd,MAAsC,EACtC,EAAE;IACF,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAEpD,OAAO;QACL,YAAY,EAAE,CACZ,MAAqC,EACrC,OAAgC,EAChC,EAAE;YACF,MAAM,IAAI,GAAG,2BAA2B,CACtC,MAAM,EACN,MAAM,EACN,UAAU,EACV,IAAI,GAAG,CAAS,CAAC,kBAAkB,CAAC,CAAC,EACrC,IAAI,GAAG,CAAS,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC,EACpD,OAAO,CACR,CAAC;YACF,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC1C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjB,OAAO,GAAG,CAAC,SAAS,CAAC;QACvB,CAAC;QAED,mBAAmB,EAAE,CACnB,aAAoC,EACpC,OAAgC,EAChC,EAAE;YACF,MAAM,WAAW,GAAG,kCAAkC,CACpD,MAAM,EACN,aAAoB,EACpB,UAAU,EACV,OAAO,CACR,CAAC;YAEF,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC7C,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAE3C,OAAO,MAAM,CAAC,SAAS,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,72 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
- import { addIdsToBlocks, partialBlocksToBlocksForTesting, } from "../../../index.js";
3
- import { initializeESMDependencies } from "../../../util/esmDependencies.js";
4
- import { customBlocksTestCases } from "../../testUtil/cases/customBlocks.js";
5
- import { customInlineContentTestCases } from "../../testUtil/cases/customInlineContent.js";
6
- import { customStylesTestCases } from "../../testUtil/cases/customStyles.js";
7
- import { defaultSchemaTestCases } from "../../testUtil/cases/defaultSchema.js";
8
- import { createExternalHTMLExporter } from "./externalHTMLExporter.js";
9
- import { createInternalHTMLSerializer } from "./internalHTMLSerializer.js";
10
- async function convertToHTMLAndCompareSnapshots(editor, blocks, snapshotDirectory, snapshotName) {
11
- addIdsToBlocks(blocks);
12
- const serializer = createInternalHTMLSerializer(editor.pmSchema, editor);
13
- const internalHTML = serializer.serializeBlocks(blocks, {});
14
- const internalHTMLSnapshotPath = "./__snapshots__/" +
15
- snapshotDirectory +
16
- "/" +
17
- snapshotName +
18
- "/internal.html";
19
- expect(internalHTML).toMatchFileSnapshot(internalHTMLSnapshotPath);
20
- // turn the internalHTML back into blocks, and make sure no data was lost
21
- const fullBlocks = partialBlocksToBlocksForTesting(editor.schema, blocks);
22
- const parsed = await editor.tryParseHTMLToBlocks(internalHTML);
23
- expect(parsed).toStrictEqual(fullBlocks);
24
- await initializeESMDependencies();
25
- // Create the "external" HTML, which is a cleaned up HTML representation, but lossy
26
- const exporter = createExternalHTMLExporter(editor.pmSchema, editor);
27
- const externalHTML = exporter.exportBlocks(blocks, {});
28
- const externalHTMLSnapshotPath = "./__snapshots__/" +
29
- snapshotDirectory +
30
- "/" +
31
- snapshotName +
32
- "/external.html";
33
- expect(externalHTML).toMatchFileSnapshot(externalHTMLSnapshotPath);
34
- }
35
- const testCases = [
36
- defaultSchemaTestCases,
37
- customBlocksTestCases,
38
- customStylesTestCases,
39
- customInlineContentTestCases,
40
- ];
41
- describe("Test HTML conversion", () => {
42
- for (const testCase of testCases) {
43
- describe("Case: " + testCase.name, () => {
44
- let editor;
45
- const div = document.createElement("div");
46
- beforeEach(() => {
47
- editor = testCase.createEditor();
48
- // Note that we don't necessarily need to mount a root
49
- // Currently, we do mount to a root so that it reflects the "production" use-case more closely.
50
- // However, it would be nice to increased converage and share the same set of tests for these cases:
51
- // - does render to a root
52
- // - does not render to a root
53
- // - runs in server (jsdom) environment using server-util
54
- editor.mount(div);
55
- });
56
- afterEach(() => {
57
- editor.mount(undefined);
58
- editor._tiptapEditor.destroy();
59
- editor = undefined;
60
- delete window.__TEST_OPTIONS;
61
- });
62
- for (const document of testCase.documents) {
63
- // eslint-disable-next-line no-loop-func
64
- it("Convert " + document.name + " to HTML", async () => {
65
- const nameSplit = document.name.split("/");
66
- await convertToHTMLAndCompareSnapshots(editor, document.blocks, nameSplit[0], nameSplit[1]);
67
- });
68
- }
69
- });
70
- }
71
- });
72
- //# sourceMappingURL=htmlConversion.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"htmlConversion.test.js","sourceRoot":"","sources":["../../../../../src/api/exporters/html/htmlConversion.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAIrE,OAAO,EACL,cAAc,EACd,+BAA+B,GAChC,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAE3E,KAAK,UAAU,gCAAgC,CAK7C,MAAgC,EAChC,MAA+B,EAC/B,iBAAyB,EACzB,YAAoB;IAEpB,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvB,MAAM,UAAU,GAAG,4BAA4B,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzE,MAAM,YAAY,GAAG,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,wBAAwB,GAC5B,kBAAkB;QAClB,iBAAiB;QACjB,GAAG;QACH,YAAY;QACZ,gBAAgB,CAAC;IACnB,MAAM,CAAC,YA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K,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;YAEH,SAAS,CAAC,GAAG,EAAE;gBACb,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBACxB,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;gBAC/B,MAAM,GAAG,SAAgB,CAAC;gBAE1B,OAAQ,MAA4C,CAAC,cAAc,CAAC;YACtE,CAAC,CAAC,CAAC;YAEH,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;gBAC1C,wCAAwC;gBACxC,EAAE,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,GAAG,UAAU,EAAE,KAAK,IAAI,EAAE;oBACrD,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC3C,MAAM,gCAAgC,CACpC,MAAM,EACN,QAAQ,CAAC,MAAM,EACf,SAAS,CAAC,CAAC,CAAC,EACZ,SAAS,CAAC,CAAC,CAAC,CACb,CAAC;gBACJ,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1,21 +0,0 @@
1
- import { DOMSerializer } from "prosemirror-model";
2
- import { serializeBlocksInternalHTML } from "./util/serializeBlocksInternalHTML.js";
3
- // Used to serialize BlockNote blocks and ProseMirror nodes to HTML without
4
- // losing data. Blocks are exported using the `toInternalHTML` method in their
5
- // `blockSpec`.
6
- //
7
- // The HTML created by this serializer is the same as what's rendered by the
8
- // editor to the DOM. This means that it retains the same structure as the
9
- // editor, including the `blockGroup` and `blockContainer` wrappers. This also
10
- // means that it can be converted back to the original blocks without any data
11
- // loss.
12
- export const createInternalHTMLSerializer = (schema, editor) => {
13
- const serializer = DOMSerializer.fromSchema(schema);
14
- return {
15
- serializeBlocks: (blocks, options) => {
16
- return serializeBlocksInternalHTML(editor, blocks, serializer, options)
17
- .outerHTML;
18
- },
19
- };
20
- };
21
- //# sourceMappingURL=internalHTMLSerializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internalHTMLSerializer.js","sourceRoot":"","sources":["../../../../../src/api/exporters/html/internalHTMLSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,mBAAmB,CAAC;AAQ1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,2EAA2E;AAC3E,8EAA8E;AAC9E,eAAe;AACf,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,8EAA8E;AAC9E,8EAA8E;AAC9E,QAAQ;AACR,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAK1C,MAAc,EACd,MAAsC,EACtC,EAAE;IACF,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAEpD,OAAO;QACL,eAAe,EAAE,CACf,MAAqC,EACrC,OAAgC,EAChC,EAAE;YACF,OAAO,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC;iBACpE,SAAS,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,141 +0,0 @@
1
- import { Fragment } from "prosemirror-model";
2
- import { UnreachableCaseError } from "../../../../util/typescript.js";
3
- import { inlineContentToNodes, tableContentToNodes, } from "../../../nodeConversions/blockToNode.js";
4
- function addAttributesAndRemoveClasses(element) {
5
- // Removes all BlockNote specific class names.
6
- const className = [...element.classList].filter((className) => !className.startsWith("bn-")) || [];
7
- if (className.length > 0) {
8
- element.className = className.join(" ");
9
- }
10
- else {
11
- element.removeAttribute("class");
12
- }
13
- }
14
- export function serializeInlineContentExternalHTML(editor, blockContent, serializer, options) {
15
- let nodes;
16
- // TODO: reuse function from nodeconversions?
17
- if (!blockContent) {
18
- throw new Error("blockContent is required");
19
- }
20
- else if (typeof blockContent === "string") {
21
- nodes = inlineContentToNodes([blockContent], editor.pmSchema, editor.schema.styleSchema);
22
- }
23
- else if (Array.isArray(blockContent)) {
24
- nodes = inlineContentToNodes(blockContent, editor.pmSchema, editor.schema.styleSchema);
25
- }
26
- else if (blockContent.type === "tableContent") {
27
- nodes = tableContentToNodes(blockContent, editor.pmSchema, editor.schema.styleSchema);
28
- }
29
- else {
30
- throw new UnreachableCaseError(blockContent.type);
31
- }
32
- // We call the prosemirror serializer here because it handles Marks and Inline Content nodes nicely.
33
- // If we'd want to support custom serialization or externalHTML for Inline Content, we'd have to implement
34
- // a custom serializer here.
35
- const dom = serializer.serializeFragment(Fragment.from(nodes), options);
36
- if (dom.nodeType === 1 /* Node.ELEMENT_NODE */) {
37
- addAttributesAndRemoveClasses(dom);
38
- }
39
- return dom;
40
- }
41
- /**
42
- * TODO: there's still quite some logic that handles getting and filtering properties,
43
- * we should make sure the `toExternalHTML` methods of default blocks actually handle this,
44
- * instead of the serializer.
45
- */
46
- function serializeBlock(fragment, editor, block, serializer, orderedListItemBlockTypes, unorderedListItemBlockTypes, options) {
47
- const doc = options?.document ?? document;
48
- const BC_NODE = editor.pmSchema.nodes["blockContainer"];
49
- let props = block.props;
50
- // set default props in case we were passed a partial block
51
- if (!block.props) {
52
- props = {};
53
- for (const [name, spec] of Object.entries(editor.schema.blockSchema[block.type].propSchema)) {
54
- props[name] = spec.default;
55
- }
56
- }
57
- const bc = BC_NODE.spec?.toDOM?.(BC_NODE.create({
58
- id: block.id,
59
- ...props,
60
- }));
61
- // the container node is just used as a workaround to get some block-level attributes.
62
- // we should change toExternalHTML so that this is not necessary
63
- const attrs = [...bc.dom.attributes];
64
- const ret = editor.blockImplementations[block.type].implementation.toExternalHTML({ ...block, props }, editor);
65
- const elementFragment = doc.createDocumentFragment();
66
- if (ret.dom.classList.contains("bn-block-content")) {
67
- const blockContentDataAttributes = [...attrs, ...ret.dom.attributes].filter((attr) => attr.name.startsWith("data") &&
68
- attr.name !== "data-content-type" &&
69
- attr.name !== "data-file-block" &&
70
- attr.name !== "data-node-view-wrapper" &&
71
- attr.name !== "data-node-type" &&
72
- attr.name !== "data-id" &&
73
- attr.name !== "data-index" &&
74
- attr.name !== "data-editable");
75
- // ret.dom = ret.dom.firstChild! as any;
76
- for (const attr of blockContentDataAttributes) {
77
- ret.dom.firstChild.setAttribute(attr.name, attr.value);
78
- }
79
- addAttributesAndRemoveClasses(ret.dom.firstChild);
80
- elementFragment.append(...ret.dom.childNodes);
81
- }
82
- else {
83
- elementFragment.append(ret.dom);
84
- }
85
- if (ret.contentDOM && block.content) {
86
- const ic = serializeInlineContentExternalHTML(editor, block.content, // TODO
87
- serializer, options);
88
- ret.contentDOM.appendChild(ic);
89
- }
90
- let listType = undefined;
91
- if (orderedListItemBlockTypes.has(block.type)) {
92
- listType = "OL";
93
- }
94
- else if (unorderedListItemBlockTypes.has(block.type)) {
95
- listType = "UL";
96
- }
97
- if (listType) {
98
- if (fragment.lastChild?.nodeName !== listType) {
99
- const list = doc.createElement(listType);
100
- fragment.append(list);
101
- }
102
- const li = doc.createElement("li");
103
- li.append(elementFragment);
104
- fragment.lastChild.appendChild(li);
105
- }
106
- else {
107
- fragment.append(elementFragment);
108
- }
109
- if (block.children && block.children.length > 0) {
110
- const childFragment = doc.createDocumentFragment();
111
- serializeBlocksToFragment(childFragment, editor, block.children, serializer, orderedListItemBlockTypes, unorderedListItemBlockTypes, options);
112
- if (fragment.lastChild?.nodeName === "UL" ||
113
- fragment.lastChild?.nodeName === "OL") {
114
- // add nested lists to the last list item
115
- while (childFragment.firstChild?.nodeName === "UL" ||
116
- childFragment.firstChild?.nodeName === "OL") {
117
- fragment.lastChild.lastChild.appendChild(childFragment.firstChild);
118
- }
119
- }
120
- if (editor.pmSchema.nodes[block.type].isInGroup("blockContent")) {
121
- // default "blockContainer" style blocks are flattened (no "nested block" support) for externalHTML, so append the child fragment to the outer fragment
122
- fragment.append(childFragment);
123
- }
124
- else {
125
- // for columns / column lists, do use nesting
126
- ret.contentDOM?.append(childFragment);
127
- }
128
- }
129
- }
130
- const serializeBlocksToFragment = (fragment, editor, blocks, serializer, orderedListItemBlockTypes, unorderedListItemBlockTypes, options) => {
131
- for (const block of blocks) {
132
- serializeBlock(fragment, editor, block, serializer, orderedListItemBlockTypes, unorderedListItemBlockTypes, options);
133
- }
134
- };
135
- export const serializeBlocksExternalHTML = (editor, blocks, serializer, orderedListItemBlockTypes, unorderedListItemBlockTypes, options) => {
136
- const doc = options?.document ?? document;
137
- const fragment = doc.createDocumentFragment();
138
- serializeBlocksToFragment(fragment, editor, blocks, serializer, orderedListItemBlockTypes, unorderedListItemBlockTypes, options);
139
- return fragment;
140
- };
141
- //# sourceMappingURL=serializeBlocksExternalHTML.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializeBlocksExternalHTML.js","sourceRoot":"","sources":["../../../../../../src/api/exporters/html/util/serializeBlocksExternalHTML.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAS5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,yCAAyC,CAAC;AAEjD,SAAS,6BAA6B,CAAC,OAAoB;IACzD,8CAA8C;IAC9C,MAAM,SAAS,GACb,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAC3B,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAC5C,IAAI,EAAE,CAAC;IAEV,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kCAAkC,CAKhD,MAAkC,EAClC,YAAoD,EACpD,UAAyB,EACzB,O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KAAK,CAAC,IAAW,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;YACvE,uJAAuJ;YACvJ,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,6CAA6C;YAC7C,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,yBAAyB,GAAG,CAKhC,QAA0B,EAC1B,MAAsC,EACtC,MAAqC,EACrC,UAAyB,EACzB,yBAAsC,EACtC,2BAAwC,EACxC,OAAiC,EACjC,EAAE;IACF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,cAAc,CACZ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,UAAU,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,OAAO,CACR,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAKzC,MAAsC,EACtC,MAAqC,EACrC,UAAyB,EACzB,yBAAsC,EACtC,2BAAwC,EACxC,OAAiC,EACjC,EAAE;IACF,MAAM,GAAG,GAAG,OAAO,EAAE,QAAQ,IAAI,QAAQ,CAAC;IAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,sBAAsB,EAAE,CAAC;IAE9C,yBAAyB,CACvB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,UAAU,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,OAAO,CACR,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -1,96 +0,0 @@
1
- import { Fragment } from "prosemirror-model";
2
- import { UnreachableCaseError } from "../../../../util/typescript.js";
3
- import { inlineContentToNodes, tableContentToNodes, } from "../../../nodeConversions/blockToNode.js";
4
- export function serializeInlineContentInternalHTML(editor, blockContent, serializer, options) {
5
- let nodes;
6
- // TODO: reuse function from nodeconversions?
7
- if (!blockContent) {
8
- throw new Error("blockContent is required");
9
- }
10
- else if (typeof blockContent === "string") {
11
- nodes = inlineContentToNodes([blockContent], editor.pmSchema, editor.schema.styleSchema);
12
- }
13
- else if (Array.isArray(blockContent)) {
14
- nodes = inlineContentToNodes(blockContent, editor.pmSchema, editor.schema.styleSchema);
15
- }
16
- else if (blockContent.type === "tableContent") {
17
- nodes = tableContentToNodes(blockContent, editor.pmSchema, editor.schema.styleSchema);
18
- }
19
- else {
20
- throw new UnreachableCaseError(blockContent.type);
21
- }
22
- // We call the prosemirror serializer here because it handles Marks and Inline Content nodes nicely.
23
- // If we'd want to support custom serialization or externalHTML for Inline Content, we'd have to implement
24
- // a custom serializer here.
25
- const dom = serializer.serializeFragment(Fragment.from(nodes), options);
26
- return dom;
27
- }
28
- function serializeBlock(editor, block, serializer, listIndex, options) {
29
- const BC_NODE = editor.pmSchema.nodes["blockContainer"];
30
- let props = block.props;
31
- // set default props in case we were passed a partial block
32
- if (!block.props) {
33
- props = {};
34
- for (const [name, spec] of Object.entries(editor.schema.blockSchema[block.type].propSchema)) {
35
- props[name] = spec.default;
36
- }
37
- }
38
- const impl = editor.blockImplementations[block.type].implementation;
39
- const ret = impl.toInternalHTML({ ...block, props }, editor);
40
- if (block.type === "numberedListItem") {
41
- // This is a workaround to make sure there's a list index set.
42
- // Normally, this is set on the internal prosemirror nodes by the NumberedListIndexingPlugin,
43
- // but:
44
- // - (a) this information is not available on the Blocks passed to the serializer. (we only have access to BlockNote Blocks)
45
- // - (b) the NumberedListIndexingPlugin might not even have run, because we can manually call blocksToFullHTML
46
- // with blocks that are not part of the active document
47
- ret.dom.setAttribute("data-index", listIndex.toString());
48
- }
49
- if (ret.contentDOM && block.content) {
50
- const ic = serializeInlineContentInternalHTML(editor, block.content, // TODO
51
- serializer, options);
52
- ret.contentDOM.appendChild(ic);
53
- }
54
- const pmType = editor.pmSchema.nodes[block.type];
55
- if (pmType.isInGroup("bnBlock")) {
56
- if (block.children && block.children.length > 0) {
57
- const fragment = serializeBlocks(editor, block.children, serializer, options);
58
- ret.contentDOM?.append(fragment);
59
- }
60
- return ret.dom;
61
- }
62
- // wrap the block in a blockContainer
63
- const bc = BC_NODE.spec?.toDOM?.(BC_NODE.create({
64
- id: block.id,
65
- ...props,
66
- }));
67
- bc.contentDOM?.appendChild(ret.dom);
68
- if (block.children && block.children.length > 0) {
69
- bc.contentDOM?.appendChild(serializeBlocksInternalHTML(editor, block.children, serializer, options));
70
- }
71
- return bc.dom;
72
- }
73
- function serializeBlocks(editor, blocks, serializer, options) {
74
- const doc = options?.document ?? document;
75
- const fragment = doc.createDocumentFragment();
76
- let listIndex = 0;
77
- for (const block of blocks) {
78
- if (block.type === "numberedListItem") {
79
- listIndex++;
80
- }
81
- else {
82
- listIndex = 0;
83
- }
84
- const blockDOM = serializeBlock(editor, block, serializer, listIndex, options);
85
- fragment.appendChild(blockDOM);
86
- }
87
- return fragment;
88
- }
89
- export const serializeBlocksInternalHTML = (editor, blocks, serializer, options) => {
90
- const BG_NODE = editor.pmSchema.nodes["blockGroup"];
91
- const bg = BG_NODE.spec.toDOM(BG_NODE.create({}));
92
- const fragment = serializeBlocks(editor, blocks, serializer, options);
93
- bg.contentDOM?.appendChild(fragment);
94
- return bg.dom;
95
- };
96
- //# sourceMappingURL=serializeBlocksInternalHTML.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializeBlocksInternalHTML.js","sourceRoot":"","sources":["../../../../../../src/api/exporters/html/util/serializeBlocksInternalHTML.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAS5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,yCAAyC,CAAC;AAEjD,MAAM,UAAU,kCAAkC,CAKhD,MAAkC,EAClC,YAAoD,EACpD,UAAyB,EACzB,OAAiC;IAEjC,IAAI,KAAU,CAAC;IAEf,6CAA6C;IAC7C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ACR,CAAC;QACF,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAKzC,MAAsC,EACtC,MAAqC,EACrC,UAAyB,EACzB,OAAiC,EACjC,EAAE;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAEpD,MAAM,EAAE,GAAG,OAAO,CAAC,IAAK,CAAC,KAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAGjD,CAAC;IAEF,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAEtE,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAErC,OAAO,EAAE,CAAC,GAAG,CAAC;AAChB,CAAC,CAAC"}
@@ -1,31 +0,0 @@
1
- import { esmDependencies, initializeESMDependencies, } from "../../../util/esmDependencies.js";
2
- import { createExternalHTMLExporter } from "../html/externalHTMLExporter.js";
3
- import { removeUnderlines } from "./removeUnderlinesRehypePlugin.js";
4
- import { addSpacesToCheckboxes } from "./util/addSpacesToCheckboxesRehypePlugin.js";
5
- // Needs to be sync because it's used in drag handler event (SideMenuPlugin)
6
- // Ideally, call `await initializeESMDependencies()` before calling this function
7
- export function cleanHTMLToMarkdown(cleanHTMLString) {
8
- const deps = esmDependencies;
9
- if (!deps) {
10
- throw new Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");
11
- }
12
- const markdownString = deps.unified
13
- .unified()
14
- .use(deps.rehypeParse.default, { fragment: true })
15
- .use(removeUnderlines)
16
- .use(addSpacesToCheckboxes)
17
- .use(deps.rehypeRemark.default)
18
- .use(deps.remarkGfm.default)
19
- .use(deps.remarkStringify.default, {
20
- handlers: { text: (node) => node.value },
21
- })
22
- .processSync(cleanHTMLString);
23
- return markdownString.value;
24
- }
25
- export async function blocksToMarkdown(blocks, schema, editor, options) {
26
- await initializeESMDependencies();
27
- const exporter = createExternalHTMLExporter(schema, editor);
28
- const externalHTML = exporter.exportBlocks(blocks, options);
29
- return cleanHTMLToMarkdown(externalHTML);
30
- }
31
- //# sourceMappingURL=markdownExporter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdownExporter.js","sourceRoot":"","sources":["../../../../../src/api/exporters/markdown/markdownExporter.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,eAAe,EACf,yBAAyB,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,4EAA4E;AAC5E,iFAAiF;AACjF,MAAM,UAAU,mBAAmB,CAAC,eAAuB;IACzD,MAAM,IAAI,GAAG,eAAe,CAAC;IAE7B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO;SAChC,OAAO,EAAE;SACT,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SACjD,GAAG,CAAC,gBAAgB,CAAC;SACrB,GAAG,CAAC,qBAAqB,CAAC;SAC1B,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;SAC9B,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC3B,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE;QACjC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;KACzC,CAAC;SACD,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