@blocknote/core 0.21.0 → 0.23.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 (444) hide show
  1. package/dist/blocknote.js +2320 -1692
  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/basicBlocks.html +1 -0
  16. package/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html +1 -0
  17. package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +1 -0
  18. package/src/api/clipboard/clipboardExternal.test.ts +161 -0
  19. package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +186 -38
  20. package/src/api/clipboard/testUtil.ts +27 -0
  21. package/src/api/clipboard/toClipboard/copyExtension.ts +1 -0
  22. package/src/api/exporters/html/__snapshots__/pageBreak/basic/external.html +1 -0
  23. package/src/api/exporters/html/__snapshots__/pageBreak/basic/internal.html +1 -0
  24. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
  25. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +3 -1
  26. package/src/api/exporters/markdown/__snapshots__/pageBreak/basic/markdown.md +0 -0
  27. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +16 -0
  28. package/src/api/nodeConversions/nodeToBlock.ts +4 -1
  29. package/src/api/parsers/html/__snapshots__/parse-codeblocks.json +62 -0
  30. package/src/api/parsers/html/parseHTML.test.ts +9 -0
  31. package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
  32. package/src/api/testUtil/cases/defaultSchema.ts +15 -1
  33. package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
  34. package/src/blocks/CodeBlockContent/CodeBlockContent.ts +32 -11
  35. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -28
  36. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +1 -1
  37. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +4 -16
  38. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
  39. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +26 -6
  40. package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +49 -0
  41. package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +45 -0
  42. package/src/blocks/PageBreakBlockContent/schema.ts +40 -0
  43. package/src/editor/Block.css +18 -4
  44. package/src/editor/BlockNoteEditor.test.ts +21 -1
  45. package/src/editor/BlockNoteEditor.ts +17 -0
  46. package/src/editor/BlockNoteExtensions.ts +111 -16
  47. package/src/editor/editor.css +28 -13
  48. package/src/editor/transformPasted.ts +57 -4
  49. package/src/extensions/SideMenu/SideMenuPlugin.ts +115 -23
  50. package/src/extensions/SideMenu/dragging.ts +0 -1
  51. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +1 -1
  52. package/src/i18n/locales/ar.ts +6 -0
  53. package/src/i18n/locales/de.ts +6 -0
  54. package/src/i18n/locales/en.ts +6 -0
  55. package/src/i18n/locales/es.ts +6 -0
  56. package/src/i18n/locales/fr.ts +47 -17
  57. package/src/i18n/locales/hr.ts +72 -54
  58. package/src/i18n/locales/index.ts +1 -0
  59. package/src/i18n/locales/is.ts +6 -0
  60. package/src/i18n/locales/it.ts +315 -0
  61. package/src/i18n/locales/ja.ts +6 -0
  62. package/src/i18n/locales/ko.ts +6 -0
  63. package/src/i18n/locales/nl.ts +6 -0
  64. package/src/i18n/locales/pl.ts +6 -0
  65. package/src/i18n/locales/pt.ts +6 -0
  66. package/src/i18n/locales/ru.ts +6 -0
  67. package/src/i18n/locales/vi.ts +6 -0
  68. package/src/i18n/locales/zh.ts +6 -0
  69. package/src/index.ts +3 -0
  70. package/src/schema/blocks/createSpec.ts +1 -1
  71. package/src/schema/blocks/internal.ts +16 -6
  72. package/src/schema/inlineContent/internal.ts +4 -1
  73. package/src/schema/propTypes.ts +41 -18
  74. package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -0
  75. package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
  76. package/types/src/api/clipboard/testUtil.d.ts +509 -0
  77. package/types/src/api/testUtil/cases/customBlocks.d.ts +8 -0
  78. package/types/src/api/testUtil/cases/customInlineContent.d.ts +8 -0
  79. package/types/src/api/testUtil/cases/customStyles.d.ts +8 -0
  80. package/types/src/api/testUtil/cases/defaultSchema.d.ts +2 -1
  81. package/types/src/blocks/CodeBlockContent/CodeBlockContent.d.ts +2 -0
  82. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
  83. package/types/src/blocks/PageBreakBlockContent/PageBreakBlockContent.d.ts +31 -0
  84. package/types/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.d.ts +8 -0
  85. package/types/src/blocks/PageBreakBlockContent/schema.d.ts +86 -0
  86. package/types/src/blocks/defaultBlocks.d.ts +16 -0
  87. package/types/src/editor/BlockNoteEditor.d.ts +15 -0
  88. package/types/src/editor/BlockNoteExtensions.d.ts +2 -0
  89. package/types/src/editor/transformPasted.d.ts +8 -4
  90. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +25 -5
  91. package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +1 -1
  92. package/types/src/i18n/locales/de.d.ts +6 -0
  93. package/types/src/i18n/locales/en.d.ts +6 -0
  94. package/types/src/i18n/locales/es.d.ts +6 -0
  95. package/types/src/i18n/locales/hr.d.ts +6 -0
  96. package/types/src/i18n/locales/index.d.ts +1 -0
  97. package/types/src/i18n/locales/it.d.ts +245 -0
  98. package/types/src/index.d.ts +3 -0
  99. package/types/src/schema/propTypes.d.ts +20 -2
  100. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +0 -30
  101. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +0 -1
  102. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +0 -99
  103. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +0 -1
  104. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +0 -97
  105. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +0 -1
  106. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +0 -88
  107. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +0 -1
  108. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +0 -219
  109. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +0 -1
  110. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +0 -175
  111. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +0 -1
  112. package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +0 -57
  113. package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +0 -1
  114. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +0 -5
  115. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +0 -1
  116. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +0 -31
  117. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +0 -1
  118. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +0 -71
  119. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +0 -1
  120. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +0 -157
  121. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +0 -1
  122. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +0 -27
  123. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +0 -1
  124. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +0 -67
  125. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +0 -1
  126. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +0 -148
  127. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +0 -1
  128. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +0 -252
  129. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +0 -1
  130. package/dist/src/api/blockManipulation/getBlock/getBlock.js +0 -56
  131. package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +0 -1
  132. package/dist/src/api/blockManipulation/insertContentAt.js +0 -64
  133. package/dist/src/api/blockManipulation/insertContentAt.js.map +0 -1
  134. package/dist/src/api/blockManipulation/selections/selection.js +0 -149
  135. package/dist/src/api/blockManipulation/selections/selection.js.map +0 -1
  136. package/dist/src/api/blockManipulation/selections/selection.test.js +0 -39
  137. package/dist/src/api/blockManipulation/selections/selection.test.js.map +0 -1
  138. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +0 -79
  139. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +0 -1
  140. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +0 -33
  141. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +0 -1
  142. package/dist/src/api/blockManipulation/setupTestEnv.js +0 -172
  143. package/dist/src/api/blockManipulation/setupTestEnv.js.map +0 -1
  144. package/dist/src/api/clipboard/clipboard.test.js +0 -249
  145. package/dist/src/api/clipboard/clipboard.test.js.map +0 -1
  146. package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +0 -8
  147. package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +0 -1
  148. package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +0 -38
  149. package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +0 -1
  150. package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +0 -111
  151. package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +0 -1
  152. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +0 -25
  153. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +0 -1
  154. package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +0 -57
  155. package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +0 -1
  156. package/dist/src/api/clipboard/toClipboard/copyExtension.js +0 -134
  157. package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +0 -1
  158. package/dist/src/api/exporters/html/externalHTMLExporter.js +0 -35
  159. package/dist/src/api/exporters/html/externalHTMLExporter.js.map +0 -1
  160. package/dist/src/api/exporters/html/htmlConversion.test.js +0 -72
  161. package/dist/src/api/exporters/html/htmlConversion.test.js.map +0 -1
  162. package/dist/src/api/exporters/html/internalHTMLSerializer.js +0 -21
  163. package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +0 -1
  164. package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +0 -141
  165. package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +0 -1
  166. package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +0 -96
  167. package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +0 -1
  168. package/dist/src/api/exporters/markdown/markdownExporter.js +0 -31
  169. package/dist/src/api/exporters/markdown/markdownExporter.js.map +0 -1
  170. package/dist/src/api/exporters/markdown/markdownExporter.test.js +0 -57
  171. package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +0 -1
  172. package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +0 -33
  173. package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +0 -1
  174. package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +0 -37
  175. package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +0 -1
  176. package/dist/src/api/getBlockInfoFromPos.js +0 -165
  177. package/dist/src/api/getBlockInfoFromPos.js.map +0 -1
  178. package/dist/src/api/nodeConversions/blockToNode.js +0 -197
  179. package/dist/src/api/nodeConversions/blockToNode.js.map +0 -1
  180. package/dist/src/api/nodeConversions/fragmentToBlocks.js +0 -50
  181. package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +0 -1
  182. package/dist/src/api/nodeConversions/nodeConversions.test.js +0 -54
  183. package/dist/src/api/nodeConversions/nodeConversions.test.js.map +0 -1
  184. package/dist/src/api/nodeConversions/nodeToBlock.js +0 -316
  185. package/dist/src/api/nodeConversions/nodeToBlock.js.map +0 -1
  186. package/dist/src/api/nodeUtil.js +0 -28
  187. package/dist/src/api/nodeUtil.js.map +0 -1
  188. package/dist/src/api/parsers/html/parseHTML.js +0 -19
  189. package/dist/src/api/parsers/html/parseHTML.js.map +0 -1
  190. package/dist/src/api/parsers/html/parseHTML.test.js +0 -470
  191. package/dist/src/api/parsers/html/parseHTML.test.js.map +0 -1
  192. package/dist/src/api/parsers/html/util/nestedLists.js +0 -106
  193. package/dist/src/api/parsers/html/util/nestedLists.js.map +0 -1
  194. package/dist/src/api/parsers/html/util/nestedLists.test.js +0 -166
  195. package/dist/src/api/parsers/html/util/nestedLists.test.js.map +0 -1
  196. package/dist/src/api/parsers/markdown/parseMarkdown.js +0 -52
  197. package/dist/src/api/parsers/markdown/parseMarkdown.js.map +0 -1
  198. package/dist/src/api/parsers/markdown/parseMarkdown.test.js +0 -112
  199. package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +0 -1
  200. package/dist/src/api/testUtil/cases/customBlocks.js +0 -313
  201. package/dist/src/api/testUtil/cases/customBlocks.js.map +0 -1
  202. package/dist/src/api/testUtil/cases/customInlineContent.js +0 -91
  203. package/dist/src/api/testUtil/cases/customInlineContent.js.map +0 -1
  204. package/dist/src/api/testUtil/cases/customStyles.js +0 -83
  205. package/dist/src/api/testUtil/cases/customStyles.js.map +0 -1
  206. package/dist/src/api/testUtil/cases/defaultSchema.js +0 -673
  207. package/dist/src/api/testUtil/cases/defaultSchema.js.map +0 -1
  208. package/dist/src/api/testUtil/index.js +0 -2
  209. package/dist/src/api/testUtil/index.js.map +0 -1
  210. package/dist/src/api/testUtil/partialBlockTestUtil.js +0 -114
  211. package/dist/src/api/testUtil/partialBlockTestUtil.js.map +0 -1
  212. package/dist/src/api/testUtil/paste.js +0 -29
  213. package/dist/src/api/testUtil/paste.js.map +0 -1
  214. package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +0 -104
  215. package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
  216. package/dist/src/blocks/AudioBlockContent/parseAudioElement.js +0 -5
  217. package/dist/src/blocks/AudioBlockContent/parseAudioElement.js.map +0 -1
  218. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +0 -281
  219. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +0 -1
  220. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +0 -110
  221. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +0 -1
  222. package/dist/src/blocks/FileBlockContent/FileBlockContent.js +0 -71
  223. package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
  224. package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js +0 -5
  225. package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js.map +0 -1
  226. package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js +0 -10
  227. package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js.map +0 -1
  228. package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js +0 -39
  229. package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js.map +0 -1
  230. package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js +0 -51
  231. package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js.map +0 -1
  232. package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js +0 -17
  233. package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js.map +0 -1
  234. package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js +0 -147
  235. package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js.map +0 -1
  236. package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js +0 -9
  237. package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js.map +0 -1
  238. package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js +0 -11
  239. package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js.map +0 -1
  240. package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +0 -15
  241. package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +0 -1
  242. package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +0 -145
  243. package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +0 -1
  244. package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +0 -114
  245. package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
  246. package/dist/src/blocks/ImageBlockContent/parseImageElement.js +0 -6
  247. package/dist/src/blocks/ImageBlockContent/parseImageElement.js.map +0 -1
  248. package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +0 -113
  249. package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +0 -1
  250. package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +0 -224
  251. package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +0 -1
  252. package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +0 -45
  253. package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +0 -1
  254. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +0 -58
  255. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +0 -1
  256. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +0 -130
  257. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +0 -1
  258. package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +0 -52
  259. package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +0 -1
  260. package/dist/src/blocks/TableBlockContent/TableBlockContent.js +0 -129
  261. package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +0 -1
  262. package/dist/src/blocks/TableBlockContent/TableExtension.js +0 -64
  263. package/dist/src/blocks/TableBlockContent/TableExtension.js.map +0 -1
  264. package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +0 -114
  265. package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
  266. package/dist/src/blocks/VideoBlockContent/parseVideoElement.js +0 -6
  267. package/dist/src/blocks/VideoBlockContent/parseVideoElement.js.map +0 -1
  268. package/dist/src/blocks/defaultBlockHelpers.js +0 -50
  269. package/dist/src/blocks/defaultBlockHelpers.js.map +0 -1
  270. package/dist/src/blocks/defaultBlockTypeGuards.js +0 -40
  271. package/dist/src/blocks/defaultBlockTypeGuards.js.map +0 -1
  272. package/dist/src/blocks/defaultBlocks.js +0 -50
  273. package/dist/src/blocks/defaultBlocks.js.map +0 -1
  274. package/dist/src/blocks/defaultProps.js +0 -19
  275. package/dist/src/blocks/defaultProps.js.map +0 -1
  276. package/dist/src/editor/BlockNoteEditor.js +0 -751
  277. package/dist/src/editor/BlockNoteEditor.js.map +0 -1
  278. package/dist/src/editor/BlockNoteEditor.test.js +0 -65
  279. package/dist/src/editor/BlockNoteEditor.test.js.map +0 -1
  280. package/dist/src/editor/BlockNoteExtensions.js +0 -192
  281. package/dist/src/editor/BlockNoteExtensions.js.map +0 -1
  282. package/dist/src/editor/BlockNoteSchema.js +0 -38
  283. package/dist/src/editor/BlockNoteSchema.js.map +0 -1
  284. package/dist/src/editor/BlockNoteTipTapEditor.js +0 -169
  285. package/dist/src/editor/BlockNoteTipTapEditor.js.map +0 -1
  286. package/dist/src/editor/cursorPositionTypes.js +0 -2
  287. package/dist/src/editor/cursorPositionTypes.js.map +0 -1
  288. package/dist/src/editor/defaultColors.js +0 -77
  289. package/dist/src/editor/defaultColors.js.map +0 -1
  290. package/dist/src/editor/selectionTypes.js +0 -2
  291. package/dist/src/editor/selectionTypes.js.map +0 -1
  292. package/dist/src/editor/transformPasted.js +0 -79
  293. package/dist/src/editor/transformPasted.js.map +0 -1
  294. package/dist/src/exporter/Exporter.js +0 -36
  295. package/dist/src/exporter/Exporter.js.map +0 -1
  296. package/dist/src/exporter/index.js +0 -3
  297. package/dist/src/exporter/index.js.map +0 -1
  298. package/dist/src/exporter/mapping.js +0 -12
  299. package/dist/src/exporter/mapping.js.map +0 -1
  300. package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +0 -30
  301. package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +0 -1
  302. package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +0 -39
  303. package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +0 -1
  304. package/dist/src/extensions/FilePanel/FilePanelPlugin.js +0 -131
  305. package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +0 -1
  306. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +0 -197
  307. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +0 -1
  308. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +0 -341
  309. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +0 -1
  310. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +0 -251
  311. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +0 -1
  312. package/dist/src/extensions/LinkToolbar/protocols.js +0 -14
  313. package/dist/src/extensions/LinkToolbar/protocols.js.map +0 -1
  314. package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +0 -54
  315. package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +0 -1
  316. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +0 -90
  317. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +0 -1
  318. package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +0 -187
  319. package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +0 -1
  320. package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +0 -68
  321. package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +0 -1
  322. package/dist/src/extensions/SideMenu/SideMenuPlugin.js +0 -347
  323. package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
  324. package/dist/src/extensions/SideMenu/dragging.js +0 -135
  325. package/dist/src/extensions/SideMenu/dragging.js.map +0 -1
  326. package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +0 -2
  327. package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +0 -1
  328. package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +0 -2
  329. package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +0 -1
  330. package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +0 -245
  331. package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +0 -1
  332. package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +0 -26
  333. package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +0 -1
  334. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +0 -241
  335. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +0 -1
  336. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +0 -579
  337. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +0 -1
  338. package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +0 -36
  339. package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +0 -1
  340. package/dist/src/extensions/TextColor/TextColorExtension.js +0 -29
  341. package/dist/src/extensions/TextColor/TextColorExtension.js.map +0 -1
  342. package/dist/src/extensions/TextColor/TextColorMark.js +0 -37
  343. package/dist/src/extensions/TextColor/TextColorMark.js.map +0 -1
  344. package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +0 -58
  345. package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +0 -1
  346. package/dist/src/extensions/UniqueID/UniqueID.js +0 -283
  347. package/dist/src/extensions/UniqueID/UniqueID.js.map +0 -1
  348. package/dist/src/extensions/getDraggableBlockFromElement.js +0 -13
  349. package/dist/src/extensions/getDraggableBlockFromElement.js.map +0 -1
  350. package/dist/src/extensions-shared/UiElementPosition.js +0 -2
  351. package/dist/src/extensions-shared/UiElementPosition.js.map +0 -1
  352. package/dist/src/i18n/dictionary.js +0 -4
  353. package/dist/src/i18n/dictionary.js.map +0 -1
  354. package/dist/src/i18n/locales/ar.js +0 -298
  355. package/dist/src/i18n/locales/ar.js.map +0 -1
  356. package/dist/src/i18n/locales/de.js +0 -313
  357. package/dist/src/i18n/locales/de.js.map +0 -1
  358. package/dist/src/i18n/locales/en.js +0 -314
  359. package/dist/src/i18n/locales/en.js.map +0 -1
  360. package/dist/src/i18n/locales/es.js +0 -312
  361. package/dist/src/i18n/locales/es.js.map +0 -1
  362. package/dist/src/i18n/locales/fr.js +0 -313
  363. package/dist/src/i18n/locales/fr.js.map +0 -1
  364. package/dist/src/i18n/locales/hr.js +0 -308
  365. package/dist/src/i18n/locales/hr.js.map +0 -1
  366. package/dist/src/i18n/locales/index.js +0 -16
  367. package/dist/src/i18n/locales/index.js.map +0 -1
  368. package/dist/src/i18n/locales/is.js +0 -305
  369. package/dist/src/i18n/locales/is.js.map +0 -1
  370. package/dist/src/i18n/locales/ja.js +0 -333
  371. package/dist/src/i18n/locales/ja.js.map +0 -1
  372. package/dist/src/i18n/locales/ko.js +0 -326
  373. package/dist/src/i18n/locales/ko.js.map +0 -1
  374. package/dist/src/i18n/locales/nl.js +0 -313
  375. package/dist/src/i18n/locales/nl.js.map +0 -1
  376. package/dist/src/i18n/locales/pl.js +0 -297
  377. package/dist/src/i18n/locales/pl.js.map +0 -1
  378. package/dist/src/i18n/locales/pt.js +0 -305
  379. package/dist/src/i18n/locales/pt.js.map +0 -1
  380. package/dist/src/i18n/locales/ru.js +0 -340
  381. package/dist/src/i18n/locales/ru.js.map +0 -1
  382. package/dist/src/i18n/locales/vi.js +0 -312
  383. package/dist/src/i18n/locales/vi.js.map +0 -1
  384. package/dist/src/i18n/locales/zh.js +0 -346
  385. package/dist/src/i18n/locales/zh.js.map +0 -1
  386. package/dist/src/index.js +0 -63
  387. package/dist/src/index.js.map +0 -1
  388. package/dist/src/pm-nodes/BlockContainer.js +0 -72
  389. package/dist/src/pm-nodes/BlockContainer.js.map +0 -1
  390. package/dist/src/pm-nodes/BlockGroup.js +0 -43
  391. package/dist/src/pm-nodes/BlockGroup.js.map +0 -1
  392. package/dist/src/pm-nodes/Doc.js +0 -7
  393. package/dist/src/pm-nodes/Doc.js.map +0 -1
  394. package/dist/src/pm-nodes/index.js +0 -4
  395. package/dist/src/pm-nodes/index.js.map +0 -1
  396. package/dist/src/schema/blocks/createSpec.js +0 -126
  397. package/dist/src/schema/blocks/createSpec.js.map +0 -1
  398. package/dist/src/schema/blocks/internal.js +0 -147
  399. package/dist/src/schema/blocks/internal.js.map +0 -1
  400. package/dist/src/schema/blocks/types.js +0 -2
  401. package/dist/src/schema/blocks/types.js.map +0 -1
  402. package/dist/src/schema/index.js +0 -11
  403. package/dist/src/schema/index.js.map +0 -1
  404. package/dist/src/schema/inlineContent/createSpec.js +0 -64
  405. package/dist/src/schema/inlineContent/createSpec.js.map +0 -1
  406. package/dist/src/schema/inlineContent/internal.js +0 -52
  407. package/dist/src/schema/inlineContent/internal.js.map +0 -1
  408. package/dist/src/schema/inlineContent/types.js +0 -10
  409. package/dist/src/schema/inlineContent/types.js.map +0 -1
  410. package/dist/src/schema/propTypes.js +0 -2
  411. package/dist/src/schema/propTypes.js.map +0 -1
  412. package/dist/src/schema/styles/createSpec.js +0 -48
  413. package/dist/src/schema/styles/createSpec.js.map +0 -1
  414. package/dist/src/schema/styles/internal.js +0 -53
  415. package/dist/src/schema/styles/internal.js.map +0 -1
  416. package/dist/src/schema/styles/types.js +0 -2
  417. package/dist/src/schema/styles/types.js.map +0 -1
  418. package/dist/src/util/EventEmitter.js +0 -33
  419. package/dist/src/util/EventEmitter.js.map +0 -1
  420. package/dist/src/util/browser.js +0 -17
  421. package/dist/src/util/browser.js.map +0 -1
  422. package/dist/src/util/combineByGroup.js +0 -20
  423. package/dist/src/util/combineByGroup.js.map +0 -1
  424. package/dist/src/util/esmDependencies.js +0 -35
  425. package/dist/src/util/esmDependencies.js.map +0 -1
  426. package/dist/src/util/string.js +0 -14
  427. package/dist/src/util/string.js.map +0 -1
  428. package/dist/src/util/typescript.js +0 -12
  429. package/dist/src/util/typescript.js.map +0 -1
  430. /package/src/api/clipboard/__snapshots__/{childToParent.html → internal/childToParent.html} +0 -0
  431. /package/src/api/clipboard/__snapshots__/{childrenToNextParent.html → internal/childrenToNextParent.html} +0 -0
  432. /package/src/api/clipboard/__snapshots__/{childrenToNextParentsChildren.html → internal/childrenToNextParentsChildren.html} +0 -0
  433. /package/src/api/clipboard/__snapshots__/{image.html → internal/image.html} +0 -0
  434. /package/src/api/clipboard/__snapshots__/{multipleChildren.html → internal/multipleChildren.html} +0 -0
  435. /package/src/api/clipboard/__snapshots__/{multipleStyledText.html → internal/multipleStyledText.html} +0 -0
  436. /package/src/api/clipboard/__snapshots__/{nestedImage.html → internal/nestedImage.html} +0 -0
  437. /package/src/api/clipboard/__snapshots__/{partialChildToParent.html → internal/partialChildToParent.html} +0 -0
  438. /package/src/api/clipboard/__snapshots__/{styledText.html → internal/styledText.html} +0 -0
  439. /package/src/api/clipboard/__snapshots__/{tableAllCells.html → internal/tableAllCells.html} +0 -0
  440. /package/src/api/clipboard/__snapshots__/{tableCell.html → internal/tableCell.html} +0 -0
  441. /package/src/api/clipboard/__snapshots__/{tableCellText.html → internal/tableCellText.html} +0 -0
  442. /package/src/api/clipboard/__snapshots__/{tableRow.html → internal/tableRow.html} +0 -0
  443. /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
  444. /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
@@ -1,79 +0,0 @@
1
- import { UnreachableCaseError } from "../../../../util/typescript.js";
2
- import { getBlockInfo, getBlockInfoFromSelection, } from "../../../getBlockInfoFromPos.js";
3
- import { nodeToBlock } from "../../../nodeConversions/nodeToBlock.js";
4
- import { getNodeById } from "../../../nodeUtil.js";
5
- export function getTextCursorPosition(editor) {
6
- const { bnBlock } = getBlockInfoFromSelection(editor._tiptapEditor.state);
7
- const resolvedPos = editor._tiptapEditor.state.doc.resolve(bnBlock.beforePos);
8
- // Gets previous blockContainer node at the same nesting level, if the current node isn't the first child.
9
- const prevNode = resolvedPos.nodeBefore;
10
- // Gets next blockContainer node at the same nesting level, if the current node isn't the last child.
11
- const nextNode = editor._tiptapEditor.state.doc.resolve(bnBlock.afterPos).nodeAfter;
12
- // Gets parent blockContainer node, if the current node is nested.
13
- let parentNode = undefined;
14
- if (resolvedPos.depth > 1) {
15
- // for nodes nested in bnBlocks
16
- parentNode = resolvedPos.node();
17
- if (!parentNode.type.isInGroup("bnBlock")) {
18
- // for blockGroups, we need to go one level up
19
- parentNode = resolvedPos.node(resolvedPos.depth - 1);
20
- }
21
- }
22
- return {
23
- block: nodeToBlock(bnBlock.node, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache),
24
- prevBlock: prevNode === null
25
- ? undefined
26
- : nodeToBlock(prevNode, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache),
27
- nextBlock: nextNode === null
28
- ? undefined
29
- : nodeToBlock(nextNode, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache),
30
- parentBlock: parentNode === undefined
31
- ? undefined
32
- : nodeToBlock(parentNode, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache),
33
- };
34
- }
35
- export function setTextCursorPosition(editor, targetBlock, placement = "start") {
36
- const id = typeof targetBlock === "string" ? targetBlock : targetBlock.id;
37
- const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
38
- if (!posInfo) {
39
- throw new Error(`Block with ID ${id} not found`);
40
- }
41
- const info = getBlockInfo(posInfo);
42
- const contentType = editor.schema.blockSchema[info.blockNoteType].content;
43
- if (info.isBlockContainer) {
44
- const blockContent = info.blockContent;
45
- if (contentType === "none") {
46
- editor._tiptapEditor.commands.setNodeSelection(blockContent.beforePos);
47
- return;
48
- }
49
- if (contentType === "inline") {
50
- if (placement === "start") {
51
- editor._tiptapEditor.commands.setTextSelection(blockContent.beforePos + 1);
52
- }
53
- else {
54
- editor._tiptapEditor.commands.setTextSelection(blockContent.afterPos - 1);
55
- }
56
- }
57
- else if (contentType === "table") {
58
- if (placement === "start") {
59
- // Need to offset the position as we have to get through the `tableRow`
60
- // and `tableCell` nodes to get to the `tableParagraph` node we want to
61
- // set the selection in.
62
- editor._tiptapEditor.commands.setTextSelection(blockContent.beforePos + 4);
63
- }
64
- else {
65
- editor._tiptapEditor.commands.setTextSelection(blockContent.afterPos - 4);
66
- }
67
- }
68
- else {
69
- throw new UnreachableCaseError(contentType);
70
- }
71
- }
72
- else {
73
- const child = placement === "start"
74
- ? info.childContainer.node.firstChild
75
- : info.childContainer.node.lastChild;
76
- setTextCursorPosition(editor, child.attrs.id, placement);
77
- }
78
- }
79
- //# sourceMappingURL=textCursorPosition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"textCursorPosition.js","sourceRoot":"","sources":["../../../../../../src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,YAAY,EACZ,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,UAAU,qBAAqB,CAInC,MAAsC;IACtC,MAAM,EAAE,OAAO,EAAE,GAAG,yBAAyB,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAE1E,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9E,0GAA0G;IAC1G,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC;IAExC,qGAAqG;IACrG,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,KAA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AQ,GAAG,CAAC,CAC1B,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,IAAI,WAAW,KAAK,OAAO,EAAE,CAAC;YACnC,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;gBAC1B,uEAAuE;gBACvE,uEAAuE;gBACvE,wBAAwB;gBACxB,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAC5C,YAAY,CAAC,SAAS,GAAG,CAAC,CAC3B,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAC5C,YAAY,CAAC,QAAQ,GAAG,CAAC,CAC1B,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GACT,SAAS,KAAK,OAAO;YACnB,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAW;YACtC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAU,CAAC;QAE1C,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
@@ -1,33 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { setupTestEnv } from "../../setupTestEnv.js";
3
- import { getTextCursorPosition, setTextCursorPosition, } from "./textCursorPosition.js";
4
- const getEditor = setupTestEnv();
5
- describe("Test getTextCursorPosition & setTextCursorPosition", () => {
6
- it("Basic", () => {
7
- setTextCursorPosition(getEditor(), "paragraph-1");
8
- expect(getTextCursorPosition(getEditor())).toMatchSnapshot();
9
- });
10
- it("First block", () => {
11
- setTextCursorPosition(getEditor(), "paragraph-0");
12
- expect(getTextCursorPosition(getEditor())).toMatchSnapshot();
13
- });
14
- it("Last block", () => {
15
- setTextCursorPosition(getEditor(), "trailing-paragraph");
16
- expect(getTextCursorPosition(getEditor())).toMatchSnapshot();
17
- });
18
- it("Nested block", () => {
19
- setTextCursorPosition(getEditor(), "nested-paragraph-0");
20
- expect(getTextCursorPosition(getEditor())).toMatchSnapshot();
21
- });
22
- it("Set to start", () => {
23
- setTextCursorPosition(getEditor(), "paragraph-1", "start");
24
- expect(getEditor()._tiptapEditor.state.selection.$from.parentOffset === 0).toBeTruthy();
25
- });
26
- it("Set to end", () => {
27
- setTextCursorPosition(getEditor(), "paragraph-1", "end");
28
- expect(getEditor()._tiptapEditor.state.selection.$from.parentOffset ===
29
- getEditor()._tiptapEditor.state.selection.$from.node().firstChild
30
- .nodeSize).toBeTruthy();
31
- });
32
- });
33
- //# sourceMappingURL=textCursorPosition.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"textCursorPosition.test.js","sourceRoot":"","sources":["../../../../../../src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;AAEjC,QAAQ,CAAC,oDAAoD,EAAE,GAAG,EAAE;IAClE,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACf,qBAAqB,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC;QAElD,MAAM,CAAC,qBAAqB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;QACrB,qBAAqB,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC;QAElD,MAAM,CAAC,qBAAqB,CAAC,SAAS,EAAE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.js";
3
- export function setupTestEnv() {
4
- let editor;
5
- const div = document.createElement("div");
6
- beforeAll(() => {
7
- editor = BlockNoteEditor.create();
8
- editor.mount(div);
9
- });
10
- afterAll(() => {
11
- editor.mount(undefined);
12
- editor._tiptapEditor.destroy();
13
- editor = undefined;
14
- });
15
- beforeEach(() => {
16
- editor.replaceBlocks(editor.document, testDocument);
17
- });
18
- return () => editor;
19
- }
20
- const testDocument = [
21
- {
22
- id: "paragraph-0",
23
- type: "paragraph",
24
- content: "Paragraph 0",
25
- },
26
- {
27
- id: "paragraph-1",
28
- type: "paragraph",
29
- content: "Paragraph 1",
30
- },
31
- {
32
- id: "paragraph-with-children",
33
- type: "paragraph",
34
- content: "Paragraph with children",
35
- children: [
36
- {
37
- id: "nested-paragraph-0",
38
- type: "paragraph",
39
- content: "Nested Paragraph 0",
40
- children: [
41
- {
42
- id: "double-nested-paragraph-0",
43
- type: "paragraph",
44
- content: "Double Nested Paragraph 0",
45
- },
46
- ],
47
- },
48
- ],
49
- },
50
- {
51
- id: "paragraph-2",
52
- type: "paragraph",
53
- content: "Paragraph 2",
54
- },
55
- {
56
- id: "paragraph-with-props",
57
- type: "paragraph",
58
- props: {
59
- textAlignment: "center",
60
- textColor: "red",
61
- },
62
- content: "Paragraph with props",
63
- },
64
- {
65
- id: "paragraph-3",
66
- type: "paragraph",
67
- content: "Paragraph 3",
68
- },
69
- {
70
- id: "paragraph-with-styled-content",
71
- type: "paragraph",
72
- content: [
73
- { type: "text", text: "Paragraph", styles: { bold: true } },
74
- { type: "text", text: " with styled ", styles: {} },
75
- { type: "text", text: "content", styles: { italic: true } },
76
- ],
77
- },
78
- {
79
- id: "paragraph-4",
80
- type: "paragraph",
81
- content: "Paragraph 4",
82
- },
83
- {
84
- id: "heading-0",
85
- type: "heading",
86
- content: "Heading 1",
87
- },
88
- {
89
- id: "paragraph-5",
90
- type: "paragraph",
91
- content: "Paragraph 5",
92
- },
93
- {
94
- id: "image-0",
95
- type: "image",
96
- props: {
97
- url: "https://via.placeholder.com/150",
98
- },
99
- },
100
- {
101
- id: "paragraph-6",
102
- type: "paragraph",
103
- content: "Paragraph 6",
104
- },
105
- {
106
- id: "table-0",
107
- type: "table",
108
- content: {
109
- type: "tableContent",
110
- rows: [
111
- {
112
- cells: ["Cell 1", "Cell 2", "Cell 3"],
113
- },
114
- {
115
- cells: ["Cell 4", "Cell 5", "Cell 6"],
116
- },
117
- {
118
- cells: ["Cell 7", "Cell 8", "Cell 9"],
119
- },
120
- ],
121
- },
122
- },
123
- {
124
- id: "paragraph-7",
125
- type: "paragraph",
126
- content: "Paragraph 7",
127
- },
128
- {
129
- id: "empty-paragraph",
130
- type: "paragraph",
131
- content: "",
132
- },
133
- {
134
- id: "paragraph-8",
135
- type: "paragraph",
136
- content: "Paragraph 8",
137
- },
138
- {
139
- id: "heading-with-everything",
140
- type: "heading",
141
- props: {
142
- backgroundColor: "red",
143
- level: 2,
144
- textAlignment: "center",
145
- textColor: "red",
146
- },
147
- content: [
148
- { type: "text", text: "Heading", styles: { bold: true } },
149
- { type: "text", text: " with styled ", styles: {} },
150
- { type: "text", text: "content", styles: { italic: true } },
151
- ],
152
- children: [
153
- {
154
- id: "nested-paragraph-1",
155
- type: "paragraph",
156
- content: "Nested Paragraph 1",
157
- children: [
158
- {
159
- id: "double-nested-paragraph-1",
160
- type: "paragraph",
161
- content: "Double Nested Paragraph 1",
162
- },
163
- ],
164
- },
165
- ],
166
- },
167
- {
168
- id: "trailing-paragraph",
169
- type: "paragraph",
170
- },
171
- ];
172
- //# sourceMappingURL=setupTestEnv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setupTestEnv.js","sourceRoot":"","sources":["../../../../src/api/blockManipulation/setupTestEnv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,UAAU,YAAY;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eSelection, TextSelection } from "prosemirror-state";
2
- import { CellSelection } from "prosemirror-tables";
3
- import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
4
- import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
5
- import { initializeESMDependencies } from "../../util/esmDependencies.js";
6
- import { doPaste } from "../testUtil/paste.js";
7
- import { selectedFragmentToHTML } from "./toClipboard/copyExtension.js";
8
- // These tests are meant to test the copying of user selections in the editor.
9
- // The test cases used for the other HTML conversion tests are not suitable here
10
- // as they are represented in the BlockNote API, whereas here we want to test
11
- // ProseMirror/TipTap selections directly.
12
- describe("Test ProseMirror selection clipboard HTML", () => {
13
- const initialContent = [
14
- {
15
- type: "heading",
16
- props: {
17
- level: 2,
18
- textColor: "red",
19
- },
20
- content: "Heading 1",
21
- children: [
22
- {
23
- type: "paragraph",
24
- content: "Nested Paragraph 1",
25
- },
26
- {
27
- type: "paragraph",
28
- content: "Nested Paragraph 2",
29
- },
30
- {
31
- type: "paragraph",
32
- content: "Nested Paragraph 3",
33
- },
34
- ],
35
- },
36
- {
37
- type: "heading",
38
- props: {
39
- level: 2,
40
- textColor: "red",
41
- },
42
- content: "Heading 2",
43
- children: [
44
- {
45
- type: "paragraph",
46
- content: "Nested Paragraph 1",
47
- },
48
- {
49
- type: "paragraph",
50
- content: "Nested Paragraph 2",
51
- },
52
- {
53
- type: "paragraph",
54
- content: "Nested Paragraph 3",
55
- },
56
- ],
57
- },
58
- {
59
- type: "heading",
60
- props: {
61
- level: 2,
62
- textColor: "red",
63
- },
64
- content: [
65
- {
66
- type: "text",
67
- text: "Bold",
68
- styles: {
69
- bold: true,
70
- },
71
- },
72
- {
73
- type: "text",
74
- text: "Italic",
75
- styles: {
76
- italic: true,
77
- },
78
- },
79
- {
80
- type: "text",
81
- text: "Regular",
82
- styles: {},
83
- },
84
- ],
85
- children: [
86
- {
87
- type: "image",
88
- props: {
89
- url: "https://ralfvanveen.com/wp-content/uploads/2021/06/Placeholder-_-Glossary.svg",
90
- },
91
- children: [
92
- {
93
- type: "paragraph",
94
- content: "Nested Paragraph",
95
- },
96
- ],
97
- },
98
- ],
99
- },
100
- {
101
- type: "table",
102
- content: {
103
- type: "tableContent",
104
- rows: [
105
- {
106
- cells: ["Table Cell", "Table Cell"],
107
- },
108
- {
109
- cells: ["Table Cell", "Table Cell"],
110
- },
111
- ],
112
- },
113
- // Not needed as selections starting in table cells will get snapped to
114
- // the table boundaries.
115
- // children: [
116
- // {
117
- // type: "table",
118
- // content: {
119
- // type: "tableContent",
120
- // rows: [
121
- // {
122
- // cells: ["Table Cell", "Table Cell"],
123
- // },
124
- // {
125
- // cells: ["Table Cell", "Table Cell"],
126
- // },
127
- // ],
128
- // },
129
- // },
130
- // ],
131
- },
132
- ];
133
- let editor;
134
- const div = document.createElement("div");
135
- beforeEach(() => {
136
- editor.replaceBlocks(editor.document, initialContent);
137
- });
138
- beforeAll(async () => {
139
- window.__TEST_OPTIONS = window.__TEST_OPTIONS || {};
140
- editor = BlockNoteEditor.create();
141
- editor.mount(div);
142
- await initializeESMDependencies();
143
- });
144
- afterAll(() => {
145
- editor.mount(undefined);
146
- editor._tiptapEditor.destroy();
147
- editor = undefined;
148
- delete window.__TEST_OPTIONS;
149
- });
150
- // Sets the editor selection to the given start and end positions, then
151
- // exports the selected content to HTML and compares it to a snapshot.
152
- async function testSelection(testCase) {
153
- if (!editor.prosemirrorView) {
154
- throw new Error("Editor view not initialized.");
155
- }
156
- editor.dispatch(editor._tiptapEditor.state.tr.setSelection(testCase.createSelection(editor.prosemirrorView.state.doc)));
157
- const { clipboardHTML, externalHTML } = selectedFragmentToHTML(editor.prosemirrorView, editor);
158
- expect(externalHTML).toMatchFileSnapshot(`./__snapshots__/${testCase.testName}.html`);
159
- const originalDocument = editor.document;
160
- doPaste(editor.prosemirrorView, "text", clipboardHTML, false, new ClipboardEvent("paste"));
161
- const newDocument = editor.document;
162
- expect(newDocument).toStrictEqual(originalDocument);
163
- }
164
- const testCases = [
165
- // TODO: Consider adding test cases for nested blocks & double nested blocks.
166
- // Selection spans all of first heading's children.
167
- {
168
- testName: "multipleChildren",
169
- createSelection: (doc) => TextSelection.create(doc, 16, 78),
170
- },
171
- // Selection spans from start of first heading to end of its first child.
172
- {
173
- testName: "childToParent",
174
- createSelection: (doc) => TextSelection.create(doc, 3, 34),
175
- },
176
- // Selection spans from middle of first heading to the middle of its first
177
- // child.
178
- {
179
- testName: "partialChildToParent",
180
- createSelection: (doc) => TextSelection.create(doc, 6, 23),
181
- },
182
- // Selection spans from start of first heading's first child to end of
183
- // second heading's content (does not include second heading's children).
184
- {
185
- testName: "childrenToNextParent",
186
- createSelection: (doc) => TextSelection.create(doc, 16, 93),
187
- },
188
- // Selection spans from start of first heading's first child to end of
189
- // second heading's last child.
190
- {
191
- testName: "childrenToNextParentsChildren",
192
- createSelection: (doc) => TextSelection.create(doc, 16, 159),
193
- },
194
- // Selection spans "Regular" text inside third heading.
195
- {
196
- testName: "unstyledText",
197
- createSelection: (doc) => TextSelection.create(doc, 175, 182),
198
- },
199
- // Selection spans "Italic" text inside third heading.
200
- {
201
- testName: "styledText",
202
- createSelection: (doc) => TextSelection.create(doc, 169, 175),
203
- },
204
- // Selection spans third heading's content (does not include third heading's
205
- // children).
206
- {
207
- testName: "multipleStyledText",
208
- createSelection: (doc) => TextSelection.create(doc, 165, 182),
209
- },
210
- // Selection spans the image block content.
211
- {
212
- testName: "image",
213
- createSelection: (doc) => NodeSelection.create(doc, 185),
214
- },
215
- // Selection spans from start of third heading to end of it's last
216
- // descendant.
217
- {
218
- testName: "nestedImage",
219
- createSelection: (doc) => TextSelection.create(doc, 165, 205),
220
- },
221
- // Selection spans text in first cell of the table.
222
- {
223
- testName: "tableCellText",
224
- createSelection: (doc) => TextSelection.create(doc, 216, 226),
225
- },
226
- // Selection spans first cell of the table.
227
- // TODO: External HTML is wrapped in unnecessary `tr` element.
228
- {
229
- testName: "tableCell",
230
- createSelection: (doc) => CellSelection.create(doc, 214),
231
- },
232
- // Selection spans first row of the table.
233
- {
234
- testName: "tableRow",
235
- createSelection: (doc) => CellSelection.create(doc, 214, 228),
236
- },
237
- // Selection spans all cells of the table.
238
- {
239
- testName: "tableAllCells",
240
- createSelection: (doc) => CellSelection.create(doc, 214, 258),
241
- },
242
- ];
243
- for (const testCase of testCases) {
244
- it(`${testCase.testName}`, async () => {
245
- await testSelection(testCase);
246
- });
247
- }
248
- });
249
- //# sourceMappingURL=clipboard.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clipboard.test.js","sourceRoot":"","sources":["../../../../src/api/clipboard/clipboard.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAa,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAOxE,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,0CAA0C;AAC1C,QAAQ,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACzD,MAAM,cAAc,GAAmB;QACrC;YACE,IAAI,EAAE,SAAS;YACf,KAAK,EAAE;gBACL,KAAK,EAAE,CAAC;gBACR,SAAS,EAAE,KAAK;aACjB;YACD,OAAO,EAAE,WAAW;YACpB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,oBAAoB;iBAC9B;gBACD;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,oBAAoB;iBAC9B;gBACD;oB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C9D;QACD,2CAA2C;QAC3C,8DAA8D;QAC9D;YACE,QAAQ,EAAE,WAAW;YACrB,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;SACzD;QACD,0CAA0C;QAC1C;YACE,QAAQ,EAAE,UAAU;YACpB,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;SAC9D;QACD,0CAA0C;QAC1C;YACE,QAAQ,EAAE,eAAe;YACzB,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;SAC9D;KACF,CAAC;IAEF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,EAAE,CAAC,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,IAAI,EAAE;YACpC,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- export const acceptedMIMETypes = [
2
- "vscode-editor-data",
3
- "blocknote/html",
4
- "text/html",
5
- "text/plain",
6
- "Files",
7
- ];
8
- //# sourceMappingURL=acceptedMIMETypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acceptedMIMETypes.js","sourceRoot":"","sources":["../../../../../src/api/clipboard/fromClipboard/acceptedMIMETypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,oBAAoB;IACpB,gBAAgB;IAChB,WAAW;IACX,YAAY;IACZ,OAAO;CACC,CAAC"}
@@ -1,38 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import { Plugin } from "prosemirror-state";
3
- import { acceptedMIMETypes } from "./acceptedMIMETypes.js";
4
- import { handleFileInsertion } from "./handleFileInsertion.js";
5
- export const createDropFileExtension = (editor) => Extension.create({
6
- name: "dropFile",
7
- addProseMirrorPlugins() {
8
- return [
9
- new Plugin({
10
- props: {
11
- handleDOMEvents: {
12
- drop(_view, event) {
13
- if (!editor.isEditable) {
14
- return;
15
- }
16
- let format = null;
17
- for (const mimeType of acceptedMIMETypes) {
18
- if (event.dataTransfer.types.includes(mimeType)) {
19
- format = mimeType;
20
- break;
21
- }
22
- }
23
- if (format === null) {
24
- return true;
25
- }
26
- if (format === "Files") {
27
- handleFileInsertion(event, editor);
28
- return true;
29
- }
30
- return false;
31
- },
32
- },
33
- },
34
- }),
35
- ];
36
- },
37
- });
38
- //# sourceMappingURL=fileDropExtension.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileDropExtension.js","sourceRoot":"","sources":["../../../../../src/api/clipboard/fromClipboard/fileDropExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAQ3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAKrC,MAAsC,EACtC,EAAE,CACF,SAAS,CAAC,MAAM,CAAwD;IACtE,IAAI,EAAE,UAAU;IAChB,qBAAqB;QACnB,OAAO;YACL,IAAI,MAAM,CAAC;gBACT,KAAK,EAAE;oBACL,eAAe,EAAE;wBACf,IAAI,CAAC,KAAK,EAAE,KAAK;4BACf,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;gCACvB,OAAO;4BACT,CAAC;4BAED,IAAI,MAAM,GAA8C,IAAI,CAAC;4BAC7D,KAAK,MAAM,QAAQ,IAAI,iBAAiB,EAAE,CAAC;gCACzC,IAAI,KAAK,CAAC,YAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;oCACjD,MAAM,GAAG,QAAQ,CAAC;oCAClB,MAAM;gCACR,CAAC;4BACH,CAAC;4BACD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gCACpB,OAAO,IAAI,CAAC;4BACd,CAAC;4BAED,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;gCACvB,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gCACnC,OAAO,IAAI,CAAC;4BACd,CAAC;4BAED,OAAO,KAAK,CAAC;wBACf,CAAC;qBACF;iBACF;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}