@blocknote/core 0.20.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 (456) hide show
  1. package/dist/blocknote.js +1602 -1569
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +6 -6
  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/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +3 -3
  10. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +1 -3
  11. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +1 -1
  12. package/src/api/blockManipulation/selections/selection.ts +5 -5
  13. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +96 -0
  14. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +96 -0
  15. package/src/api/clipboard/__snapshots__/external/pasteImage.html +111 -0
  16. package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +96 -0
  17. package/src/api/clipboard/__snapshots__/external/pasteTable.html +149 -0
  18. package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +124 -0
  19. package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +1 -0
  20. package/src/api/clipboard/__snapshots__/internal/tableAllCells.html +1 -0
  21. package/src/api/clipboard/__snapshots__/internal/tableCell.html +1 -0
  22. package/src/api/clipboard/__snapshots__/internal/tableRow.html +1 -0
  23. package/src/api/clipboard/clipboardExternal.test.ts +161 -0
  24. package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +66 -40
  25. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
  26. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +7 -14
  27. package/src/api/clipboard/fromClipboard/pasteExtension.ts +6 -6
  28. package/src/api/clipboard/testUtil.ts +27 -0
  29. package/src/api/clipboard/toClipboard/copyExtension.ts +8 -2
  30. package/src/api/exporters/html/__snapshots__/file/basic/internal.html +1 -1
  31. package/src/api/exporters/html/__snapshots__/file/nested/internal.html +1 -1
  32. package/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +1 -1
  33. package/src/api/exporters/html/__snapshots__/file/noName/internal.html +1 -1
  34. package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
  35. package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
  36. package/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +1 -1
  37. package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -1
  38. package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -1
  39. package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
  40. package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
  41. package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
  42. package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
  43. package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
  44. package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +1 -1
  45. package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
  46. package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -1
  47. package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
  48. package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -1
  49. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
  50. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +3 -1
  51. package/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +1 -1
  52. package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +2 -2
  53. package/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +1 -1
  54. package/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +1 -1
  55. package/src/api/nodeConversions/nodeToBlock.ts +4 -1
  56. package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
  57. package/src/api/parsers/markdown/parseMarkdown.test.ts +5 -7
  58. package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
  59. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +13 -14
  60. package/src/blocks/FileBlockContent/FileBlockContent.ts +5 -12
  61. package/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.ts +5 -0
  62. package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +16 -0
  63. package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +63 -0
  64. package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +80 -0
  65. package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +24 -0
  66. package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +204 -0
  67. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +13 -0
  68. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +15 -0
  69. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -19
  70. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +20 -28
  71. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +3 -15
  72. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
  73. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +25 -5
  74. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +20 -27
  75. package/src/editor/Block.css +38 -54
  76. package/src/editor/BlockNoteEditor.test.ts +21 -1
  77. package/src/editor/BlockNoteEditor.ts +14 -7
  78. package/src/editor/BlockNoteExtensions.ts +7 -8
  79. package/src/editor/editor.css +7 -6
  80. package/src/editor/transformPasted.ts +57 -4
  81. package/src/extensions/LinkToolbar/protocols.ts +13 -0
  82. package/src/extensions/Placeholder/PlaceholderPlugin.ts +6 -6
  83. package/src/extensions/SideMenu/SideMenuPlugin.ts +5 -1
  84. package/src/extensions/SideMenu/dragging.ts +3 -0
  85. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +3 -6
  86. package/src/extensions/TableHandles/TableHandlesPlugin.ts +15 -3
  87. package/src/index.ts +9 -2
  88. package/src/schema/blocks/createSpec.ts +1 -1
  89. package/src/schema/blocks/internal.ts +16 -6
  90. package/src/schema/inlineContent/createSpec.ts +2 -2
  91. package/src/schema/inlineContent/internal.ts +4 -1
  92. package/src/schema/propTypes.ts +41 -18
  93. package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -0
  94. package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
  95. package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +2 -3
  96. package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +1 -3
  97. package/types/src/api/clipboard/testUtil.d.ts +509 -0
  98. package/types/src/api/testUtil/cases/customBlocks.d.ts +8 -0
  99. package/types/src/api/testUtil/cases/customInlineContent.d.ts +8 -0
  100. package/types/src/api/testUtil/cases/customStyles.d.ts +8 -0
  101. package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +2 -5
  102. package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +2 -5
  103. package/types/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.d.ts +3 -0
  104. package/types/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.d.ts +4 -0
  105. package/types/src/blocks/FileBlockContent/helpers/render/createAddFileButton.d.ts +6 -0
  106. package/types/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.d.ts +9 -0
  107. package/types/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.d.ts +6 -0
  108. package/types/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.d.ts +9 -0
  109. package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.d.ts +3 -0
  110. package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.d.ts +3 -0
  111. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +2 -5
  112. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
  113. package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +2 -5
  114. package/types/src/blocks/defaultBlocks.d.ts +16 -0
  115. package/types/src/editor/BlockNoteEditor.d.ts +6 -4
  116. package/types/src/editor/transformPasted.d.ts +8 -4
  117. package/types/src/extensions/LinkToolbar/protocols.d.ts +2 -0
  118. package/types/src/index.d.ts +9 -2
  119. package/types/src/schema/propTypes.d.ts +20 -2
  120. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +0 -30
  121. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +0 -1
  122. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +0 -99
  123. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +0 -1
  124. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +0 -97
  125. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +0 -1
  126. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +0 -88
  127. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +0 -1
  128. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +0 -219
  129. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +0 -1
  130. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +0 -175
  131. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +0 -1
  132. package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +0 -57
  133. package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +0 -1
  134. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +0 -5
  135. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +0 -1
  136. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +0 -31
  137. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +0 -1
  138. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +0 -71
  139. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +0 -1
  140. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +0 -157
  141. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +0 -1
  142. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +0 -27
  143. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +0 -1
  144. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +0 -67
  145. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +0 -1
  146. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +0 -148
  147. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +0 -1
  148. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +0 -252
  149. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +0 -1
  150. package/dist/src/api/blockManipulation/getBlock/getBlock.js +0 -56
  151. package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +0 -1
  152. package/dist/src/api/blockManipulation/insertContentAt.js +0 -64
  153. package/dist/src/api/blockManipulation/insertContentAt.js.map +0 -1
  154. package/dist/src/api/blockManipulation/selections/selection.js +0 -149
  155. package/dist/src/api/blockManipulation/selections/selection.js.map +0 -1
  156. package/dist/src/api/blockManipulation/selections/selection.test.js +0 -39
  157. package/dist/src/api/blockManipulation/selections/selection.test.js.map +0 -1
  158. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +0 -79
  159. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +0 -1
  160. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +0 -33
  161. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +0 -1
  162. package/dist/src/api/blockManipulation/setupTestEnv.js +0 -172
  163. package/dist/src/api/blockManipulation/setupTestEnv.js.map +0 -1
  164. package/dist/src/api/clipboard/clipboard.test.js +0 -246
  165. package/dist/src/api/clipboard/clipboard.test.js.map +0 -1
  166. package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +0 -8
  167. package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +0 -1
  168. package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +0 -38
  169. package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +0 -1
  170. package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +0 -111
  171. package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +0 -1
  172. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +0 -26
  173. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +0 -1
  174. package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +0 -57
  175. package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +0 -1
  176. package/dist/src/api/clipboard/toClipboard/copyExtension.js +0 -132
  177. package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +0 -1
  178. package/dist/src/api/exporters/html/externalHTMLExporter.js +0 -35
  179. package/dist/src/api/exporters/html/externalHTMLExporter.js.map +0 -1
  180. package/dist/src/api/exporters/html/htmlConversion.test.js +0 -72
  181. package/dist/src/api/exporters/html/htmlConversion.test.js.map +0 -1
  182. package/dist/src/api/exporters/html/internalHTMLSerializer.js +0 -21
  183. package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +0 -1
  184. package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +0 -141
  185. package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +0 -1
  186. package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +0 -96
  187. package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +0 -1
  188. package/dist/src/api/exporters/markdown/markdownExporter.js +0 -31
  189. package/dist/src/api/exporters/markdown/markdownExporter.js.map +0 -1
  190. package/dist/src/api/exporters/markdown/markdownExporter.test.js +0 -57
  191. package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +0 -1
  192. package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +0 -33
  193. package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +0 -1
  194. package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +0 -37
  195. package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +0 -1
  196. package/dist/src/api/getBlockInfoFromPos.js +0 -165
  197. package/dist/src/api/getBlockInfoFromPos.js.map +0 -1
  198. package/dist/src/api/nodeConversions/blockToNode.js +0 -197
  199. package/dist/src/api/nodeConversions/blockToNode.js.map +0 -1
  200. package/dist/src/api/nodeConversions/fragmentToBlocks.js +0 -50
  201. package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +0 -1
  202. package/dist/src/api/nodeConversions/nodeConversions.test.js +0 -54
  203. package/dist/src/api/nodeConversions/nodeConversions.test.js.map +0 -1
  204. package/dist/src/api/nodeConversions/nodeToBlock.js +0 -316
  205. package/dist/src/api/nodeConversions/nodeToBlock.js.map +0 -1
  206. package/dist/src/api/nodeUtil.js +0 -28
  207. package/dist/src/api/nodeUtil.js.map +0 -1
  208. package/dist/src/api/parsers/html/parseHTML.js +0 -19
  209. package/dist/src/api/parsers/html/parseHTML.js.map +0 -1
  210. package/dist/src/api/parsers/html/parseHTML.test.js +0 -470
  211. package/dist/src/api/parsers/html/parseHTML.test.js.map +0 -1
  212. package/dist/src/api/parsers/html/util/nestedLists.js +0 -106
  213. package/dist/src/api/parsers/html/util/nestedLists.js.map +0 -1
  214. package/dist/src/api/parsers/html/util/nestedLists.test.js +0 -166
  215. package/dist/src/api/parsers/html/util/nestedLists.test.js.map +0 -1
  216. package/dist/src/api/parsers/markdown/parseMarkdown.js +0 -52
  217. package/dist/src/api/parsers/markdown/parseMarkdown.js.map +0 -1
  218. package/dist/src/api/parsers/markdown/parseMarkdown.test.js +0 -109
  219. package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +0 -1
  220. package/dist/src/api/testUtil/cases/customBlocks.js +0 -313
  221. package/dist/src/api/testUtil/cases/customBlocks.js.map +0 -1
  222. package/dist/src/api/testUtil/cases/customInlineContent.js +0 -91
  223. package/dist/src/api/testUtil/cases/customInlineContent.js.map +0 -1
  224. package/dist/src/api/testUtil/cases/customStyles.js +0 -83
  225. package/dist/src/api/testUtil/cases/customStyles.js.map +0 -1
  226. package/dist/src/api/testUtil/cases/defaultSchema.js +0 -673
  227. package/dist/src/api/testUtil/cases/defaultSchema.js.map +0 -1
  228. package/dist/src/api/testUtil/index.js +0 -2
  229. package/dist/src/api/testUtil/index.js.map +0 -1
  230. package/dist/src/api/testUtil/partialBlockTestUtil.js +0 -114
  231. package/dist/src/api/testUtil/partialBlockTestUtil.js.map +0 -1
  232. package/dist/src/api/testUtil/paste.js +0 -29
  233. package/dist/src/api/testUtil/paste.js.map +0 -1
  234. package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +0 -97
  235. package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
  236. package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +0 -5
  237. package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js.map +0 -1
  238. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +0 -281
  239. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +0 -1
  240. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +0 -110
  241. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +0 -1
  242. package/dist/src/blocks/FileBlockContent/FileBlockContent.js +0 -70
  243. package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
  244. package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +0 -317
  245. package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js.map +0 -1
  246. package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +0 -15
  247. package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +0 -1
  248. package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +0 -145
  249. package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +0 -1
  250. package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +0 -106
  251. package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
  252. package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +0 -6
  253. package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js.map +0 -1
  254. package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +0 -113
  255. package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +0 -1
  256. package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +0 -224
  257. package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +0 -1
  258. package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +0 -45
  259. package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +0 -1
  260. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +0 -58
  261. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +0 -1
  262. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +0 -130
  263. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +0 -1
  264. package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +0 -52
  265. package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +0 -1
  266. package/dist/src/blocks/TableBlockContent/TableBlockContent.js +0 -129
  267. package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +0 -1
  268. package/dist/src/blocks/TableBlockContent/TableExtension.js +0 -64
  269. package/dist/src/blocks/TableBlockContent/TableExtension.js.map +0 -1
  270. package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +0 -103
  271. package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
  272. package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +0 -6
  273. package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +0 -1
  274. package/dist/src/blocks/defaultBlockHelpers.js +0 -50
  275. package/dist/src/blocks/defaultBlockHelpers.js.map +0 -1
  276. package/dist/src/blocks/defaultBlockTypeGuards.js +0 -40
  277. package/dist/src/blocks/defaultBlockTypeGuards.js.map +0 -1
  278. package/dist/src/blocks/defaultBlocks.js +0 -50
  279. package/dist/src/blocks/defaultBlocks.js.map +0 -1
  280. package/dist/src/blocks/defaultProps.js +0 -19
  281. package/dist/src/blocks/defaultProps.js.map +0 -1
  282. package/dist/src/editor/BlockNoteEditor.js +0 -748
  283. package/dist/src/editor/BlockNoteEditor.js.map +0 -1
  284. package/dist/src/editor/BlockNoteEditor.test.js +0 -65
  285. package/dist/src/editor/BlockNoteEditor.test.js.map +0 -1
  286. package/dist/src/editor/BlockNoteExtensions.js +0 -196
  287. package/dist/src/editor/BlockNoteExtensions.js.map +0 -1
  288. package/dist/src/editor/BlockNoteSchema.js +0 -38
  289. package/dist/src/editor/BlockNoteSchema.js.map +0 -1
  290. package/dist/src/editor/BlockNoteTipTapEditor.js +0 -169
  291. package/dist/src/editor/BlockNoteTipTapEditor.js.map +0 -1
  292. package/dist/src/editor/cursorPositionTypes.js +0 -2
  293. package/dist/src/editor/cursorPositionTypes.js.map +0 -1
  294. package/dist/src/editor/defaultColors.js +0 -77
  295. package/dist/src/editor/defaultColors.js.map +0 -1
  296. package/dist/src/editor/selectionTypes.js +0 -2
  297. package/dist/src/editor/selectionTypes.js.map +0 -1
  298. package/dist/src/editor/transformPasted.js +0 -79
  299. package/dist/src/editor/transformPasted.js.map +0 -1
  300. package/dist/src/exporter/Exporter.js +0 -36
  301. package/dist/src/exporter/Exporter.js.map +0 -1
  302. package/dist/src/exporter/index.js +0 -3
  303. package/dist/src/exporter/index.js.map +0 -1
  304. package/dist/src/exporter/mapping.js +0 -12
  305. package/dist/src/exporter/mapping.js.map +0 -1
  306. package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +0 -30
  307. package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +0 -1
  308. package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +0 -39
  309. package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +0 -1
  310. package/dist/src/extensions/FilePanel/FilePanelPlugin.js +0 -131
  311. package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +0 -1
  312. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +0 -197
  313. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +0 -1
  314. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +0 -341
  315. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +0 -1
  316. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +0 -251
  317. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +0 -1
  318. package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +0 -54
  319. package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +0 -1
  320. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +0 -90
  321. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +0 -1
  322. package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +0 -187
  323. package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +0 -1
  324. package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +0 -68
  325. package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +0 -1
  326. package/dist/src/extensions/SideMenu/SideMenuPlugin.js +0 -343
  327. package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
  328. package/dist/src/extensions/SideMenu/dragging.js +0 -132
  329. package/dist/src/extensions/SideMenu/dragging.js.map +0 -1
  330. package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +0 -2
  331. package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +0 -1
  332. package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +0 -2
  333. package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +0 -1
  334. package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +0 -245
  335. package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +0 -1
  336. package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +0 -26
  337. package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +0 -1
  338. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +0 -241
  339. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +0 -1
  340. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +0 -570
  341. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +0 -1
  342. package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +0 -36
  343. package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +0 -1
  344. package/dist/src/extensions/TextColor/TextColorExtension.js +0 -29
  345. package/dist/src/extensions/TextColor/TextColorExtension.js.map +0 -1
  346. package/dist/src/extensions/TextColor/TextColorMark.js +0 -37
  347. package/dist/src/extensions/TextColor/TextColorMark.js.map +0 -1
  348. package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +0 -58
  349. package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +0 -1
  350. package/dist/src/extensions/UniqueID/UniqueID.js +0 -283
  351. package/dist/src/extensions/UniqueID/UniqueID.js.map +0 -1
  352. package/dist/src/extensions/getDraggableBlockFromElement.js +0 -13
  353. package/dist/src/extensions/getDraggableBlockFromElement.js.map +0 -1
  354. package/dist/src/extensions-shared/UiElementPosition.js +0 -2
  355. package/dist/src/extensions-shared/UiElementPosition.js.map +0 -1
  356. package/dist/src/i18n/dictionary.js +0 -4
  357. package/dist/src/i18n/dictionary.js.map +0 -1
  358. package/dist/src/i18n/locales/ar.js +0 -298
  359. package/dist/src/i18n/locales/ar.js.map +0 -1
  360. package/dist/src/i18n/locales/de.js +0 -313
  361. package/dist/src/i18n/locales/de.js.map +0 -1
  362. package/dist/src/i18n/locales/en.js +0 -314
  363. package/dist/src/i18n/locales/en.js.map +0 -1
  364. package/dist/src/i18n/locales/es.js +0 -312
  365. package/dist/src/i18n/locales/es.js.map +0 -1
  366. package/dist/src/i18n/locales/fr.js +0 -313
  367. package/dist/src/i18n/locales/fr.js.map +0 -1
  368. package/dist/src/i18n/locales/hr.js +0 -308
  369. package/dist/src/i18n/locales/hr.js.map +0 -1
  370. package/dist/src/i18n/locales/index.js +0 -16
  371. package/dist/src/i18n/locales/index.js.map +0 -1
  372. package/dist/src/i18n/locales/is.js +0 -305
  373. package/dist/src/i18n/locales/is.js.map +0 -1
  374. package/dist/src/i18n/locales/ja.js +0 -333
  375. package/dist/src/i18n/locales/ja.js.map +0 -1
  376. package/dist/src/i18n/locales/ko.js +0 -326
  377. package/dist/src/i18n/locales/ko.js.map +0 -1
  378. package/dist/src/i18n/locales/nl.js +0 -313
  379. package/dist/src/i18n/locales/nl.js.map +0 -1
  380. package/dist/src/i18n/locales/pl.js +0 -297
  381. package/dist/src/i18n/locales/pl.js.map +0 -1
  382. package/dist/src/i18n/locales/pt.js +0 -305
  383. package/dist/src/i18n/locales/pt.js.map +0 -1
  384. package/dist/src/i18n/locales/ru.js +0 -340
  385. package/dist/src/i18n/locales/ru.js.map +0 -1
  386. package/dist/src/i18n/locales/vi.js +0 -312
  387. package/dist/src/i18n/locales/vi.js.map +0 -1
  388. package/dist/src/i18n/locales/zh.js +0 -346
  389. package/dist/src/i18n/locales/zh.js.map +0 -1
  390. package/dist/src/index.js +0 -56
  391. package/dist/src/index.js.map +0 -1
  392. package/dist/src/pm-nodes/BlockContainer.js +0 -72
  393. package/dist/src/pm-nodes/BlockContainer.js.map +0 -1
  394. package/dist/src/pm-nodes/BlockGroup.js +0 -43
  395. package/dist/src/pm-nodes/BlockGroup.js.map +0 -1
  396. package/dist/src/pm-nodes/Doc.js +0 -7
  397. package/dist/src/pm-nodes/Doc.js.map +0 -1
  398. package/dist/src/pm-nodes/index.js +0 -4
  399. package/dist/src/pm-nodes/index.js.map +0 -1
  400. package/dist/src/schema/blocks/createSpec.js +0 -126
  401. package/dist/src/schema/blocks/createSpec.js.map +0 -1
  402. package/dist/src/schema/blocks/internal.js +0 -147
  403. package/dist/src/schema/blocks/internal.js.map +0 -1
  404. package/dist/src/schema/blocks/types.js +0 -2
  405. package/dist/src/schema/blocks/types.js.map +0 -1
  406. package/dist/src/schema/index.js +0 -11
  407. package/dist/src/schema/index.js.map +0 -1
  408. package/dist/src/schema/inlineContent/createSpec.js +0 -64
  409. package/dist/src/schema/inlineContent/createSpec.js.map +0 -1
  410. package/dist/src/schema/inlineContent/internal.js +0 -52
  411. package/dist/src/schema/inlineContent/internal.js.map +0 -1
  412. package/dist/src/schema/inlineContent/types.js +0 -10
  413. package/dist/src/schema/inlineContent/types.js.map +0 -1
  414. package/dist/src/schema/propTypes.js +0 -2
  415. package/dist/src/schema/propTypes.js.map +0 -1
  416. package/dist/src/schema/styles/createSpec.js +0 -48
  417. package/dist/src/schema/styles/createSpec.js.map +0 -1
  418. package/dist/src/schema/styles/internal.js +0 -53
  419. package/dist/src/schema/styles/internal.js.map +0 -1
  420. package/dist/src/schema/styles/types.js +0 -2
  421. package/dist/src/schema/styles/types.js.map +0 -1
  422. package/dist/src/util/EventEmitter.js +0 -33
  423. package/dist/src/util/EventEmitter.js.map +0 -1
  424. package/dist/src/util/browser.js +0 -17
  425. package/dist/src/util/browser.js.map +0 -1
  426. package/dist/src/util/combineByGroup.js +0 -20
  427. package/dist/src/util/combineByGroup.js.map +0 -1
  428. package/dist/src/util/esmDependencies.js +0 -35
  429. package/dist/src/util/esmDependencies.js.map +0 -1
  430. package/dist/src/util/string.js +0 -14
  431. package/dist/src/util/string.js.map +0 -1
  432. package/dist/src/util/typescript.js +0 -12
  433. package/dist/src/util/typescript.js.map +0 -1
  434. package/src/api/clipboard/__snapshots__/tableAllCells.html +0 -1
  435. package/src/api/clipboard/__snapshots__/tableCell.html +0 -1
  436. package/src/api/clipboard/__snapshots__/tableRow.html +0 -1
  437. package/src/blocks/FileBlockContent/fileBlockHelpers.ts +0 -456
  438. package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +0 -41
  439. /package/src/api/clipboard/__snapshots__/{childToParent.html → internal/childToParent.html} +0 -0
  440. /package/src/api/clipboard/__snapshots__/{childrenToNextParent.html → internal/childrenToNextParent.html} +0 -0
  441. /package/src/api/clipboard/__snapshots__/{childrenToNextParentsChildren.html → internal/childrenToNextParentsChildren.html} +0 -0
  442. /package/src/api/clipboard/__snapshots__/{image.html → internal/image.html} +0 -0
  443. /package/src/api/clipboard/__snapshots__/{multipleChildren.html → internal/multipleChildren.html} +0 -0
  444. /package/src/api/clipboard/__snapshots__/{multipleStyledText.html → internal/multipleStyledText.html} +0 -0
  445. /package/src/api/clipboard/__snapshots__/{nestedImage.html → internal/nestedImage.html} +0 -0
  446. /package/src/api/clipboard/__snapshots__/{partialChildToParent.html → internal/partialChildToParent.html} +0 -0
  447. /package/src/api/clipboard/__snapshots__/{styledText.html → internal/styledText.html} +0 -0
  448. /package/src/api/clipboard/__snapshots__/{tableCellText.html → internal/tableCellText.html} +0 -0
  449. /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
  450. /package/src/blocks/AudioBlockContent/{audioBlockHelpers.ts → parseAudioElement.ts} +0 -0
  451. /package/src/blocks/ImageBlockContent/{imageBlockHelpers.ts → parseImageElement.ts} +0 -0
  452. /package/src/blocks/VideoBlockContent/{videoBlockHelpers.ts → parseVideoElement.ts} +0 -0
  453. /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
  454. /package/types/src/blocks/AudioBlockContent/{audioBlockHelpers.d.ts → parseAudioElement.d.ts} +0 -0
  455. /package/types/src/blocks/ImageBlockContent/{imageBlockHelpers.d.ts → parseImageElement.d.ts} +0 -0
  456. /package/types/src/blocks/VideoBlockContent/{videoBlockHelpers.d.ts → parseVideoElement.d.ts} +0 -0
@@ -1,28 +0,0 @@
1
- /**
2
- * Get a TipTap node by id
3
- */
4
- export function getNodeById(id, doc) {
5
- let targetNode = undefined;
6
- let posBeforeNode = undefined;
7
- doc.firstChild.descendants((node, pos) => {
8
- // Skips traversing nodes after node with target ID has been found.
9
- if (targetNode) {
10
- return false;
11
- }
12
- // Keeps traversing nodes if block with target ID has not been found.
13
- if (!node.type.isInGroup("bnBlock") || node.attrs.id !== id) {
14
- return true;
15
- }
16
- targetNode = node;
17
- posBeforeNode = pos + 1;
18
- return false;
19
- });
20
- if (targetNode === undefined || posBeforeNode === undefined) {
21
- return undefined;
22
- }
23
- return {
24
- node: targetNode,
25
- posBeforeNode: posBeforeNode,
26
- };
27
- }
28
- //# sourceMappingURL=nodeUtil.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodeUtil.js","sourceRoot":"","sources":["../../../src/api/nodeUtil.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,EAAU,EACV,GAAS;IAET,IAAI,UAAU,GAAqB,SAAS,CAAC;IAC7C,IAAI,aAAa,GAAuB,SAAS,CAAC;IAElD,GAAG,CAAC,UAAW,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACxC,mEAAmE;QACnE,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;QACf,CAAC;QAED,qEAAqE;QACrE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,UAAU,GAAG,IAAI,CAAC;QAClB,aAAa,GAAG,GAAG,GAAG,CAAC,CAAC;QAExB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,IAAI,UAAU,KAAK,SAAS,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,aAAa,EAAE,aAAa;KAC7B,CAAC;AACJ,CAAC"}
@@ -1,19 +0,0 @@
1
- import { DOMParser } from "prosemirror-model";
2
- import { nodeToBlock } from "../../nodeConversions/nodeToBlock.js";
3
- import { nestedListsToBlockNoteStructure } from "./util/nestedLists.js";
4
- export async function HTMLToBlocks(html, blockSchema, icSchema, styleSchema, pmSchema) {
5
- const htmlNode = nestedListsToBlockNoteStructure(html);
6
- const parser = DOMParser.fromSchema(pmSchema);
7
- // Other approach might be to use
8
- // const doc = pmSchema.nodes["doc"].createAndFill()!;
9
- // and context: doc.resolve(3),
10
- const parentNode = parser.parse(htmlNode, {
11
- topNode: pmSchema.nodes["blockGroup"].create(),
12
- });
13
- const blocks = [];
14
- for (let i = 0; i < parentNode.childCount; i++) {
15
- blocks.push(nodeToBlock(parentNode.child(i), blockSchema, icSchema, styleSchema));
16
- }
17
- return blocks;
18
- }
19
- //# sourceMappingURL=parseHTML.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseHTML.js","sourceRoot":"","sources":["../../../../../src/api/parsers/html/parseHTML.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,mBAAmB,CAAC;AAQtD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACxE,MAAM,CAAC,KAAK,UAAU,YAAY,CAKhC,IAAY,EACZ,WAAoB,EACpB,QAAW,EACX,WAAc,EACd,QAAgB;IAEhB,MAAM,QAAQ,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE9C,iCAAiC;IACjC,sDAAsD;IACtD,+BAA+B;IAE/B,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE;QACxC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;KAC/C,CAAC,CAAC;IAEH,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,CAAC,IAAI,CACT,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,CACrE,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,470 +0,0 @@
1
- import * as pmView from "prosemirror-view";
2
- import { describe, expect, it } from "vitest";
3
- import { BlockNoteEditor } from "../../../index.js";
4
- import { nestedListsToBlockNoteStructure } from "./util/nestedLists.js";
5
- async function parseHTMLAndCompareSnapshots(html, snapshotName) {
6
- const editor = BlockNoteEditor.create();
7
- const div = document.createElement("div");
8
- editor.mount(div);
9
- const blocks = await editor.tryParseHTMLToBlocks(html);
10
- const snapshotPath = "./__snapshots__/" + snapshotName + ".json";
11
- expect(JSON.stringify(blocks, undefined, 2)).toMatchFileSnapshot(snapshotPath);
12
- // Now, we also want to test actually pasting in the editor, and not just calling
13
- // tryParseHTMLToBlocks directly.
14
- // The reason is that the prosemirror logic for pasting can be a bit different, because
15
- // it's related to the context of where the user is pasting exactly (selection)
16
- //
17
- // The internal difference come that in tryParseHTMLToBlocks, we use DOMParser.parse,
18
- // while when pasting, Prosemirror uses DOMParser.parseSlice, and then tries to fit the
19
- // slice in the document. This fitting might change the structure / interpretation of the pasted blocks
20
- // Simulate a paste event (this uses DOMParser.parseSlice internally)
21
- window.__TEST_OPTIONS.mockID = 0; // reset id counter
22
- const htmlNode = nestedListsToBlockNoteStructure(html);
23
- const slice = pmView.__parseFromClipboard(editor.prosemirrorView, "", htmlNode.innerHTML, false, editor._tiptapEditor.state.selection.$from);
24
- editor.dispatch(editor._tiptapEditor.state.tr.replaceSelection(slice));
25
- // alternative paste simulation doesn't work in a non-browser vitest env
26
- // editor._tiptapEditor.view.pasteHTML(html, {
27
- // preventDefault: () => {
28
- // // noop
29
- // },
30
- // clipboardData: {
31
- // types: ["text/html"],
32
- // getData: () => html,
33
- // },
34
- // } as any);
35
- const pastedBlocks = editor.document;
36
- pastedBlocks.pop(); // trailing paragraph
37
- expect(pastedBlocks).toStrictEqual(blocks);
38
- editor.mount(undefined);
39
- }
40
- describe("Parse HTML", () => {
41
- it("Parse basic block types", async () => {
42
- const html = `<h1>Heading 1</h1>
43
- <h2>Heading 2</h2>
44
- <h3>Heading 3</h3>
45
- <p>Paragraph</p>
46
- <figure><img src="exampleURL" /><figcaption>Image Caption</figcaption></figure>
47
- <p>None <strong>Bold </strong><em>Italic </em><u>Underline </u><s>Strikethrough </s><strong><em><s><u>All</u></s></em></strong></p>`;
48
- await parseHTMLAndCompareSnapshots(html, "parse-basic-block-types");
49
- });
50
- it("list test", async () => {
51
- const html = `<ul>
52
- <li>First</li>
53
- <li>Second</li>
54
- <li>Third</li>
55
- <li>
56
- <input type="checkbox">
57
- Fourth
58
- </li>
59
- <li>
60
- <input type="checkbox">
61
- Fifth
62
- </li>
63
- <li>Five Parent
64
- <ul>
65
- <li>Child 1</li>
66
- <li>Child 2</li>
67
- <li>
68
- <input type="checkbox">
69
- Child 3
70
- </li>
71
- <li>
72
- <input type="checkbox">
73
- Child 4
74
- </li>
75
- </ul>
76
- </li>
77
- </ul>`;
78
- await parseHTMLAndCompareSnapshots(html, "list-test");
79
- });
80
- it("Parse nested lists", async () => {
81
- const html = `<ul>
82
- <li>Bullet List Item</li>
83
- <li>Bullet List Item
84
- <ul>
85
- <li>Nested Bullet List Item</li>
86
- <li>Nested Bullet List Item</li>
87
- </ul>
88
- </li>
89
- <li>Bullet List Item</li>
90
- </ul>
91
- <ol>
92
- <li>Numbered List Item</li>
93
- <li>Numbered List Item
94
- <ol>
95
- <li>Nested Numbered List Item</li>
96
- <li>Nested Numbered List Item</li>
97
- </ol>
98
- </li>
99
- <li>Numbered List Item</li>
100
- </ol>
101
- <ul>
102
- <li>
103
- <input type="checkbox">
104
- Check List Item
105
- </li>
106
- <li>
107
- <input type="checkbox">
108
- Check List Item
109
- <ul>
110
- <li>
111
- <input type="checkbox">
112
- Nested Check List Item
113
- </li>
114
- <li>
115
- <input type="checkbox">
116
- Nested Check List Item
117
- </li>
118
- </ul>
119
- </li>
120
- <li>
121
- <input type="checkbox">
122
- Nested Check List Item
123
- </li>
124
- </ul>`;
125
- await parseHTMLAndCompareSnapshots(html, "parse-nested-lists");
126
- });
127
- it("Parse nested lists with paragraphs", async () => {
128
- const html = `<ul>
129
- <li>
130
- <p>Bullet List Item</p>
131
- </li>
132
- <li>
133
- <p>Bullet List Item</p>
134
- <ul>
135
- <li>
136
- <p>Nested Bullet List Item</p>
137
- </li>
138
- <li>
139
- <p>Nested Bullet List Item</p>
140
- </li>
141
- </ul>
142
- </li>
143
- <li>
144
- <p>Bullet List Item</p>
145
- </li>
146
- </ul>
147
- <ol>
148
- <li>
149
- <p>Numbered List Item</p>
150
- </li>
151
- <li>
152
- <p>Numbered List Item</p>
153
- <ol>
154
- <li>
155
- <p>Nested Numbered List Item</p>
156
- </li>
157
- <li>
158
- <p>Nested Numbered List Item</p>
159
- </li>
160
- </ol>
161
- </li>
162
- <li>
163
- <p>Numbered List Item</p>
164
- </li>
165
- </ol>
166
- <ul>
167
- <li>
168
- <input type="checkbox">
169
- <p>Checked List Item</p>
170
- </li>
171
- <li>
172
- <input type="checkbox">
173
- <p>Checked List Item</p>
174
- <ul>
175
- <li>
176
- <input type="checkbox">
177
- <p>Nested Checked List Item</p>
178
- </li>
179
- <li>
180
- <label><input type="checkbox"></label>
181
- <p>Nested Checked List Item</p>
182
- </li>
183
- </ul>
184
- </li>
185
- <li>
186
- <input type="checkbox">
187
- <p>Checked List Item</p>
188
- </li>
189
- </ul>`;
190
- await parseHTMLAndCompareSnapshots(html, "parse-nested-lists-with-paragraphs");
191
- });
192
- it("Parse mixed nested lists", async () => {
193
- const html = `<ul>
194
- <li>Bullet List Item</li>
195
- <li>Bullet List Item
196
- <ol>
197
- <li>Nested Numbered List Item</li>
198
- <li>Nested Numbered List Item</li>
199
- </ol>
200
- </li>
201
- <li>Bullet List Item</li>
202
- </ul>
203
- <ol>
204
- <li>Numbered List Item</li>
205
- <li>Numbered List Item
206
- <ul>
207
- <li>
208
- <input type="checkbox" checked>
209
- Nested Check List Item
210
- </li>
211
- <li>
212
- <input type="checkbox">
213
- Nested Check List Item
214
- </li>
215
- </ul>
216
- </li>
217
- <li>Numbered List Item</li>
218
- </ol>
219
- <ul>
220
- <li>
221
- <input type="checkbox" checked>
222
- Check List Item
223
- </li>
224
- <li>
225
- <input type="checkbox">
226
- Check List Item
227
- <ul>
228
- <li>Nested Bullet List Item</li>
229
- <li>Nested Bullet List Item</li>
230
- </ul>
231
- </li>
232
- <li>
233
- <input type="checkbox" checked>
234
- Nested Check List Item
235
- </li>
236
- </ul>`;
237
- await parseHTMLAndCompareSnapshots(html, "parse-mixed-nested-lists");
238
- });
239
- it("Parse divs", async () => {
240
- const html = `<div>Single Div</div>
241
- <div>
242
- Div
243
- <div>Nested Div</div>
244
- <div>Nested Div</div>
245
- </div>
246
- <div>Single Div 2</div>
247
- <div>
248
- <div>Nested Div</div>
249
- <div>Nested Div</div>
250
- </div>`;
251
- await parseHTMLAndCompareSnapshots(html, "parse-divs");
252
- });
253
- it("Parse two divs", async () => {
254
- const html = `<div>Single Div</div><div>second Div</div>`;
255
- await parseHTMLAndCompareSnapshots(html, "parse-two-divs");
256
- });
257
- it("Parse image in paragraph", async () => {
258
- const html = `<p>
259
- <img src="exampleURL">
260
- </p>`;
261
- await parseHTMLAndCompareSnapshots(html, "parse-image-in-paragraph");
262
- });
263
- it("Parse fake image caption", async () => {
264
- const html = `<div>
265
- <img src="exampleURL">
266
- <p>Image Caption</p>
267
- </div>`;
268
- await parseHTMLAndCompareSnapshots(html, "parse-fake-image-caption");
269
- });
270
- // TODO: this one fails
271
- it.skip("Parse deep nested content", async () => {
272
- const html = `<div>
273
- Outer 1 Div Before
274
- <div>
275
- Outer 2 Div Before
276
- <div>
277
- Outer 3 Div Before
278
- <div>
279
- Outer 4 Div Before
280
- <h1>Heading 1</h1>
281
- <h2>Heading 2</h2>
282
- <h3>Heading 3</h3>
283
- <p>Paragraph</p>
284
- <figure><img src="exampleURL"><figcaption>Image Caption</figcaption></figure>
285
- <p><strong>Bold</strong> <em>Italic</em> <u>Underline</u> <s>Strikethrough</s> <strong><em><s><u>All</u></s></em></strong></p>
286
- Outer 4 Div After
287
- </div>
288
- Outer 3 Div After
289
- </div>
290
- Outer 2 Div After
291
- </div>
292
- Outer 1 Div After
293
- </div>`;
294
- await parseHTMLAndCompareSnapshots(html, "parse-deep-nested-content");
295
- });
296
- it("Parse div with inline content and nested blocks", async () => {
297
- const html = `<div>
298
- None <strong>Bold </strong><em>Italic </em><u>Underline </u><s>Strikethrough </s><strong><em><s><u>All</u></s></em></strong>
299
- <div>Nested Div</div>
300
- <p>Nested Paragraph</p>
301
- </div>`;
302
- await parseHTMLAndCompareSnapshots(html, "parse-div-with-inline-content");
303
- });
304
- it("Parse Notion HTML", async () => {
305
- // A few notes on Notion output HTML:
306
- // - Does not preserve text/background colors
307
- // - Does not preserve non-list-item block nesting
308
- // - Hard breaks are represented using white space, not `<br>` elements
309
- // - Images are converted to links with a "!" at the start
310
- // - Cells in first row of a table are converted to `th` elements, regardless
311
- // of if the row is set as a header row
312
- const html = `<meta charset='utf-8'><h1>Heading 1</h1>
313
- <h2>Heading 2</h2>
314
- <h3>Heading 3</h3>
315
- <p>Paragraph 1</p>
316
- <p>Nested Paragraph 1</p>
317
- <p>Nested Paragraph 2</p>
318
- <p>Paragraph
319
- With Hard Break</p>
320
- <p><strong>Bold</strong> <em>Italic</em> Underline <s>Strikethrough</s> <em><strong><s>All</s></strong></em></p>
321
- <ul>
322
- <li>Bullet List Item 1
323
- <ul>
324
- <li>Nested Bullet List Item 1
325
- <ol>
326
- <li>Nested Numbered List Item 1</li>
327
- <li>Nested Numbered List Item 2</li>
328
- </ol>
329
- </li>
330
- <li>Nested Bullet List Item 2</li>
331
- </ul>
332
- </li>
333
- <li>Bullet List Item 2</li>
334
- </ul>
335
- <ol>
336
- <li>Numbered List Item 1</li>
337
- <li>Numbered List Item 2</li>
338
- </ol>
339
- <p>Background Color Paragraph</p>
340
- <p>!<a href="https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg">https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg</a></p>
341
- <table>
342
- <thead>
343
- <tr>
344
- <th>Cell 1</th>
345
- <th>Cell 2</th>
346
- <th>Cell 3</th>
347
- </tr>
348
- </thead>
349
- <tbody>
350
- <tr>
351
- <td>Cell 4</td>
352
- <td>Cell 5</td>
353
- <td>Cell 6</td>
354
- </tr>
355
- <tr>
356
- <td>Cell 7</td>
357
- <td>Cell 8</td>
358
- <td>Cell 9</td>
359
- </tr>
360
- </tbody>
361
- </table>
362
- <p>Paragraph</p>
363
- <!-- notionvc: 7cb7968f-b969-4795-af7a-d41b5481c675 -->`;
364
- await parseHTMLAndCompareSnapshots(html, "parse-notion-html");
365
- });
366
- // Currently breaking, seems related to parsing `</br>` elements
367
- it.skip("Parse Google Docs HTML", async () => {
368
- // A few notes on Google Docs output HTML:
369
- // - All inline markup is represented as `<span>` elements with inline
370
- // styles (bold, italic, etc.)
371
- // - The nested list structure is not valid, i.e. `<ul/ol>` elements are not
372
- // placed within `<li>` elements
373
- // - Images are wrapped in two spans and a paragraph
374
- // - Everything is nested within a `<b>` element
375
- const html = `<meta charset='utf-8'>
376
- <meta charset="utf-8">
377
- <b style="font-weight:normal;" id="docs-internal-guid-fdf86189-7fff-f50a-2bef-c048469db8a9">
378
- <h1 dir="ltr" style="line-height:1.38;margin-left: 18pt;text-indent: -18pt;margin-top:24pt;margin-bottom:6pt;padding:0pt 0pt 0pt 18pt;"><span style="font-size:23pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Heading 1</span></h1>
379
- <h2 dir="ltr" style="line-height:1.38;margin-left: 18pt;text-indent: -18pt;margin-top:18pt;margin-bottom:4pt;padding:0pt 0pt 0pt 18pt;"><span style="font-size:17pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Heading 2</span></h2>
380
- <h3 dir="ltr" style="line-height:1.38;margin-left: 18pt;text-indent: -18pt;margin-top:14pt;margin-bottom:4pt;padding:0pt 0pt 0pt 18pt;"><span style="font-size:13pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Heading 3</span></h3>
381
- <p dir="ltr" style="line-height:1.38;margin-top:12pt;margin-bottom:12pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Paragraph 1</span></p>
382
- <p dir="ltr" style="line-height:1.38;margin-top:12pt;margin-bottom:12pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Paragraph 2</span></p>
383
- <p dir="ltr" style="line-height:1.38;margin-top:12pt;margin-bottom:12pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Paragraph 3</span></p>
384
- <p dir="ltr" style="line-height:1.38;margin-top:12pt;margin-bottom:12pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Paragraph With </span><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;"><br /></span><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Hard Break</span></p>
385
- <p dir="ltr" style="line-height:1.38;margin-top:12pt;margin-bottom:12pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:700;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Bold</span><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;"> </span><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:italic;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Italic</span><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;"> Underline </span><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:line-through;-webkit-text-decoration-skip:none;text-decoration-skip-ink:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Strikethrough</span><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;"> </span><span style="font-size:11pt;font-family:Arial,sans-serif;color:#ff0000;background-color:transparent;font-weight:700;font-style:italic;font-variant:normal;text-decoration:line-through;-webkit-text-decoration-skip:none;text-decoration-skip-ink:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">All</span></p>
386
- <ul style="margin-top:0;margin-bottom:0;padding-inline-start:48px;">
387
- <li dir="ltr" style="list-style-type:disc;font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;" aria-level="1">
388
- <p dir="ltr" style="line-height:1.38;margin-top:12pt;margin-bottom:0pt;" role="presentation"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Bullet List Item 1</span></p>
389
- </li>
390
- <ul style="margin-top:0;margin-bottom:0;padding-inline-start:48px;">
391
- <li dir="ltr" style="list-style-type:circle;font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;" aria-level="2">
392
- <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;" role="presentation"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Nested Bullet List Item 1</span></p>
393
- </li>
394
- <ol style="margin-top:0;margin-bottom:0;padding-inline-start:48px;">
395
- <li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;" aria-level="3">
396
- <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;" role="presentation"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Nested Numbered List Item 1</span></p>
397
- </li>
398
- <li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;" aria-level="3">
399
- <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;" role="presentation"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Nested Numbered List Item 2</span></p>
400
- </li>
401
- </ol>
402
- <li dir="ltr" style="list-style-type:circle;font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;" aria-level="2">
403
- <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;" role="presentation"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Nested Bullet List Item 2</span></p>
404
- </li>
405
- </ul>
406
- <li dir="ltr" style="list-style-type:disc;font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;" aria-level="1">
407
- <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;" role="presentation"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Bullet List Item 2</span></p>
408
- </li>
409
- </ul>
410
- <ol style="margin-top:0;margin-bottom:0;padding-inline-start:48px;">
411
- <li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;" aria-level="1">
412
- <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;" role="presentation"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Numbered List Item 1</span></p>
413
- </li>
414
- <li dir="ltr" style="list-style-type:decimal;font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;" aria-level="1">
415
- <p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:12pt;" role="presentation"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Numbered List Item 2</span></p>
416
- </li>
417
- </ol>
418
- <p dir="ltr" style="line-height:1.38;margin-top:12pt;margin-bottom:12pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;"><span style="border:none;display:inline-block;overflow:hidden;width:447px;height:301px;"><img src="https://lh7-us.googleusercontent.com/SGyYp6hfLvNkli62NKFJB6NQz-fNa2Sjy8QxfUuqipW--qCCXmCz-dJmeZUGaDXIF9TEZHzbhNJsw4_w-B09eaFOn0oUChKsrSt3cwAIFu6d4SoSjHTR_DRTPr415_P7an7Lue-EwlUcVBk1WCzcoVQ" width="447" height="301" style="margin-left:0px;margin-top:0px;" /></span></span></p>
419
- <br />
420
- <div dir="ltr" style="margin-left:0pt;" align="left">
421
- <table style="border:none;border-collapse:collapse;table-layout:fixed;width:468pt">
422
- <colgroup>
423
- <col />
424
- <col />
425
- <col />
426
- </colgroup>
427
- <tbody>
428
- <tr style="height:0pt">
429
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
430
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 1</span></p>
431
- </td>
432
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
433
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 2</span></p>
434
- </td>
435
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
436
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 3</span></p>
437
- </td>
438
- </tr>
439
- <tr style="height:0pt">
440
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
441
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 4</span></p>
442
- </td>
443
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
444
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 5</span></p>
445
- </td>
446
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
447
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 6</span></p>
448
- </td>
449
- </tr>
450
- <tr style="height:0pt">
451
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
452
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 7</span></p>
453
- </td>
454
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
455
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 8</span></p>
456
- </td>
457
- <td style="border-left:solid #000000 1pt;border-right:solid #000000 1pt;border-bottom:solid #000000 1pt;border-top:solid #000000 1pt;vertical-align:top;padding:5pt 5pt 5pt 5pt;overflow:hidden;overflow-wrap:break-word;">
458
- <p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Cell 9</span></p>
459
- </td>
460
- </tr>
461
- </tbody>
462
- </table>
463
- </div>
464
- <p dir="ltr" style="line-height:1.38;margin-top:12pt;margin-bottom:12pt;"><span style="font-size:11pt;font-family:Arial,sans-serif;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Paragraph</span></p>
465
- </b>
466
- <br class="Apple-interchange-newline">`;
467
- await parseHTMLAndCompareSnapshots(html, "parse-google-docs-html");
468
- });
469
- });
470
- //# sourceMappingURL=parseHTML.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseHTML.test.js","sourceRoot":"","sources":["../../../../../src/api/parsers/html/parseHTML.test.ts"],"names":[],"mappings":"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"}
@@ -1,106 +0,0 @@
1
- function getChildIndex(node) {
2
- return Array.prototype.indexOf.call(node.parentElement.childNodes, node);
3
- }
4
- function isWhitespaceNode(node) {
5
- return node.nodeType === 3 && !/\S/.test(node.nodeValue || "");
6
- }
7
- /**
8
- * Step 1, Turns:
9
- *
10
- * <ul>
11
- * <li>item</li>
12
- * <li>
13
- * <ul>
14
- * <li>...</li>
15
- * <li>...</li>
16
- * </ul>
17
- * </li>
18
- *
19
- * Into:
20
- * <ul>
21
- * <li>item</li>
22
- * <ul>
23
- * <li>...</li>
24
- * <li>...</li>
25
- * </ul>
26
- * </ul>
27
- *
28
- */
29
- function liftNestedListsToParent(element) {
30
- element.querySelectorAll("li > ul, li > ol").forEach((list) => {
31
- const index = getChildIndex(list);
32
- const parentListItem = list.parentElement;
33
- const siblingsAfter = Array.from(parentListItem.childNodes).slice(index + 1);
34
- list.remove();
35
- siblingsAfter.forEach((sibling) => {
36
- sibling.remove();
37
- });
38
- parentListItem.insertAdjacentElement("afterend", list);
39
- siblingsAfter.reverse().forEach((sibling) => {
40
- if (isWhitespaceNode(sibling)) {
41
- return;
42
- }
43
- const siblingContainer = document.createElement("li");
44
- siblingContainer.append(sibling);
45
- list.insertAdjacentElement("afterend", siblingContainer);
46
- });
47
- if (parentListItem.childNodes.length === 0) {
48
- parentListItem.remove();
49
- }
50
- });
51
- }
52
- /**
53
- * Step 2, Turns (output of liftNestedListsToParent):
54
- *
55
- * <li>item</li>
56
- * <ul>
57
- * <li>...</li>
58
- * <li>...</li>
59
- * </ul>
60
- *
61
- * Into:
62
- * <div>
63
- * <li>item</li>
64
- * <div data-node-type="blockGroup">
65
- * <ul>
66
- * <li>...</li>
67
- * <li>...</li>
68
- * </ul>
69
- * </div>
70
- * </div>
71
- *
72
- * This resulting format is parsed
73
- */
74
- function createGroups(element) {
75
- element.querySelectorAll("li + ul, li + ol").forEach((list) => {
76
- const listItem = list.previousElementSibling;
77
- const blockContainer = document.createElement("div");
78
- listItem.insertAdjacentElement("afterend", blockContainer);
79
- blockContainer.append(listItem);
80
- const blockGroup = document.createElement("div");
81
- blockGroup.setAttribute("data-node-type", "blockGroup");
82
- blockContainer.append(blockGroup);
83
- while (blockContainer.nextElementSibling?.nodeName === "UL" ||
84
- blockContainer.nextElementSibling?.nodeName === "OL") {
85
- blockGroup.append(blockContainer.nextElementSibling);
86
- }
87
- });
88
- }
89
- // prevent XSS, similar to https://github.com/ProseMirror/prosemirror-view/blob/1251b2b412656a2a06263e4187574beb43651273/src/clipboard.ts#L204
90
- // https://github.com/TypeCellOS/BlockNote/issues/601
91
- let _detachedDoc = null;
92
- function detachedDoc() {
93
- return (_detachedDoc ||
94
- (_detachedDoc = document.implementation.createHTMLDocument("title")));
95
- }
96
- export function nestedListsToBlockNoteStructure(elementOrHTML) {
97
- if (typeof elementOrHTML === "string") {
98
- const element = detachedDoc().createElement("div");
99
- element.innerHTML = elementOrHTML;
100
- elementOrHTML = element;
101
- }
102
- liftNestedListsToParent(elementOrHTML);
103
- createGroups(elementOrHTML);
104
- return elementOrHTML;
105
- }
106
- //# sourceMappingURL=nestedLists.js.map