@blocknote/core 0.11.2 → 0.12.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 (128) hide show
  1. package/README.md +13 -17
  2. package/dist/blocknote.js +1600 -1403
  3. package/dist/blocknote.js.map +1 -1
  4. package/dist/blocknote.umd.cjs +6 -6
  5. package/dist/blocknote.umd.cjs.map +1 -1
  6. package/dist/style.css +1 -1
  7. package/dist/webpack-stats.json +1 -1
  8. package/package.json +7 -3
  9. package/src/api/blockManipulation/blockManipulation.test.ts +19 -15
  10. package/src/api/blockManipulation/blockManipulation.ts +107 -17
  11. package/src/api/exporters/html/externalHTMLExporter.ts +3 -7
  12. package/src/api/exporters/html/htmlConversion.test.ts +6 -3
  13. package/src/api/exporters/html/internalHTMLSerializer.ts +3 -7
  14. package/src/api/exporters/html/util/sharedHTMLConversion.ts +3 -3
  15. package/src/api/exporters/markdown/markdownExporter.test.ts +7 -3
  16. package/src/api/exporters/markdown/markdownExporter.ts +2 -6
  17. package/src/api/nodeConversions/nodeConversions.test.ts +14 -7
  18. package/src/api/nodeConversions/nodeConversions.ts +1 -2
  19. package/src/api/parsers/html/parseHTML.test.ts +5 -1
  20. package/src/api/parsers/html/parseHTML.ts +2 -6
  21. package/src/api/parsers/html/util/nestedLists.ts +11 -1
  22. package/src/api/parsers/markdown/parseMarkdown.test.ts +3 -0
  23. package/src/api/parsers/markdown/parseMarkdown.ts +2 -6
  24. package/src/api/testUtil/cases/customBlocks.ts +18 -16
  25. package/src/api/testUtil/cases/customInlineContent.ts +12 -13
  26. package/src/api/testUtil/cases/customStyles.ts +12 -10
  27. package/src/api/testUtil/index.ts +4 -2
  28. package/src/api/testUtil/partialBlockTestUtil.ts +2 -6
  29. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +1 -2
  30. package/src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +8 -1
  31. package/src/blocks/defaultBlockHelpers.ts +3 -3
  32. package/src/blocks/defaultBlockTypeGuards.ts +84 -0
  33. package/src/blocks/defaultBlocks.ts +29 -3
  34. package/src/editor/Block.css +2 -31
  35. package/src/editor/BlockNoteEditor.ts +218 -262
  36. package/src/editor/BlockNoteExtensions.ts +5 -2
  37. package/src/editor/BlockNoteSchema.ts +98 -0
  38. package/src/editor/BlockNoteTipTapEditor.ts +162 -0
  39. package/src/editor/cursorPositionTypes.ts +2 -6
  40. package/src/editor/editor.css +0 -1
  41. package/src/editor/selectionTypes.ts +2 -6
  42. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +22 -29
  43. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +26 -27
  44. package/src/extensions/ImageToolbar/ImageToolbarPlugin.ts +45 -51
  45. package/src/extensions/Placeholder/PlaceholderExtension.ts +81 -88
  46. package/src/extensions/SideMenu/SideMenuPlugin.ts +55 -56
  47. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +8 -0
  48. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +353 -0
  49. package/src/extensions/{SlashMenu/defaultSlashMenuItems.ts → SuggestionMenu/getDefaultSlashMenuItems.ts} +119 -89
  50. package/src/extensions/TableHandles/TableHandlesPlugin.ts +62 -45
  51. package/src/extensions-shared/UiElementPosition.ts +4 -0
  52. package/src/index.ts +6 -6
  53. package/src/pm-nodes/BlockContainer.ts +5 -5
  54. package/src/schema/blocks/types.ts +15 -15
  55. package/src/schema/inlineContent/createSpec.ts +2 -2
  56. package/src/schema/inlineContent/types.ts +1 -1
  57. package/src/util/browser.ts +6 -4
  58. package/src/util/typescript.ts +7 -4
  59. package/types/src/api/blockManipulation/blockManipulation.d.ts +6 -1
  60. package/types/src/api/exporters/html/externalHTMLExporter.d.ts +2 -1
  61. package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +2 -1
  62. package/types/src/api/exporters/markdown/markdownExporter.d.ts +2 -1
  63. package/types/src/api/nodeConversions/nodeConversions.d.ts +2 -1
  64. package/types/src/api/parsers/html/parseHTML.d.ts +2 -1
  65. package/types/src/api/parsers/markdown/parseMarkdown.d.ts +2 -1
  66. package/types/src/api/testUtil/cases/customBlocks.d.ts +72 -13
  67. package/types/src/api/testUtil/cases/customInlineContent.d.ts +281 -6
  68. package/types/src/api/testUtil/cases/customStyles.d.ts +247 -13
  69. package/types/src/api/testUtil/index.d.ts +4 -2
  70. package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
  71. package/types/src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +6 -1
  72. package/types/src/blocks/defaultBlockHelpers.d.ts +2 -2
  73. package/types/src/blocks/defaultBlockTypeGuards.d.ts +24 -0
  74. package/types/src/blocks/defaultBlocks.d.ts +21 -15
  75. package/types/src/editor/BlockNoteEditor.d.ts +48 -53
  76. package/types/src/editor/BlockNoteExtensions.d.ts +1 -0
  77. package/types/src/editor/BlockNoteSchema.d.ts +34 -0
  78. package/types/src/editor/BlockNoteTipTapEditor.d.ts +28 -0
  79. package/types/src/editor/cursorPositionTypes.d.ts +2 -1
  80. package/types/src/editor/selectionTypes.d.ts +2 -1
  81. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +5 -6
  82. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +2 -2
  83. package/types/src/extensions/ImageToolbar/ImageToolbarPlugin.d.ts +15 -14
  84. package/types/src/extensions/Placeholder/PlaceholderExtension.d.ts +2 -15
  85. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +8 -7
  86. package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +8 -0
  87. package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +31 -0
  88. package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +10 -0
  89. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +7 -7
  90. package/types/src/extensions-shared/UiElementPosition.d.ts +4 -0
  91. package/types/src/index.d.ts +6 -6
  92. package/types/src/pm-nodes/BlockContainer.d.ts +3 -2
  93. package/types/src/pm-nodes/BlockGroup.d.ts +1 -1
  94. package/types/src/schema/blocks/types.d.ts +15 -15
  95. package/types/src/schema/inlineContent/types.d.ts +1 -1
  96. package/types/src/util/browser.d.ts +1 -0
  97. package/types/src/util/typescript.d.ts +1 -0
  98. package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +0 -12
  99. package/src/extensions/SlashMenu/SlashMenuPlugin.ts +0 -53
  100. package/src/extensions-shared/BaseUiElementTypes.ts +0 -8
  101. package/src/extensions-shared/README.md +0 -3
  102. package/src/extensions-shared/suggestion/SuggestionItem.ts +0 -3
  103. package/src/extensions-shared/suggestion/SuggestionPlugin.ts +0 -448
  104. package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +0 -7
  105. package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +0 -13
  106. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +0 -3
  107. package/types/src/extensions-shared/BaseUiElementTypes.d.ts +0 -7
  108. package/types/src/extensions-shared/suggestion/SuggestionItem.d.ts +0 -3
  109. package/types/src/extensions-shared/suggestion/SuggestionPlugin.d.ts +0 -36
  110. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-100.woff +0 -0
  111. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-100.woff2 +0 -0
  112. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-200.woff +0 -0
  113. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-200.woff2 +0 -0
  114. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-300.woff +0 -0
  115. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-300.woff2 +0 -0
  116. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-500.woff +0 -0
  117. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-500.woff2 +0 -0
  118. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-600.woff +0 -0
  119. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-600.woff2 +0 -0
  120. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-700.woff +0 -0
  121. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-700.woff2 +0 -0
  122. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-800.woff +0 -0
  123. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-800.woff2 +0 -0
  124. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-900.woff +0 -0
  125. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-900.woff2 +0 -0
  126. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-regular.woff +0 -0
  127. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-regular.woff2 +0 -0
  128. /package/src/{assets/fonts-inter.css → fonts/inter.css} +0 -0
package/README.md CHANGED
@@ -1,49 +1,45 @@
1
1
  <p align="center">
2
2
  <a href="https://www.blocknotejs.org">
3
- <img alt="TypeCell" src="https://github.com/TypeCellOS/BlockNote/raw/main/packages/website/docs/public/img/logos/banner.svg?raw=true" width="300" />
3
+ <img alt="TypeCell" src="https://github.com/TypeCellOS/BlockNote/raw/main/docs/public/img/logos/banner.svg?raw=true" width="300" />
4
4
  </a>
5
5
  </p>
6
6
 
7
7
  <p align="center">
8
8
  Welcome to BlockNote! The open source Block-Based
9
- rich text editor. Easily add a modern text editing experience to your app.
9
+ React rich text editor. Easily add a modern text editing experience to your app.
10
10
  </p>
11
11
 
12
12
  <p align="center">
13
- <a href="https://discord.gg/Qc2QTTH5dF"><img alt="Discord" src="https://img.shields.io/badge/Chat on discord%20-%237289DA.svg?&style=for-the-badge&logo=discord&logoColor=white"/></a> <a href="https://matrix.to/#/#typecell-space:matrix.org"><img alt="Matrix" src="https://img.shields.io/badge/Chat on matrix%20-%23000.svg?&style=for-the-badge&logo=matrix&logoColor=white"/></a>
13
+ <a href="https://discord.gg/Qc2QTTH5dF"><img alt="Discord" src="https://img.shields.io/badge/Chat on discord%20-%237289DA.svg?&style=for-the-badge&logo=discord&logoColor=white"/></a>
14
14
  </p>
15
15
 
16
16
  <p align="center">
17
17
  <a href="https://www.blocknotejs.org">
18
18
  Homepage
19
19
  </a> - <a href="https://www.blocknotejs.org/docs/introduction">
20
- Introduction
21
- </a> - <a href="https://www.blocknotejs.org/docs/quickstart">
22
20
  Documentation
21
+ </a> - <a href="https://www.blocknotejs.org/docs/quickstart">
22
+ Quickstart
23
+ </a>- <a href="https://www.blocknotejs.org/docs/examples">
24
+ Examples
23
25
  </a>
24
26
  </p>
25
27
 
26
28
  # Live demo
27
29
 
28
- Play with the editor @ [https://blocknote-main.vercel.app/](https://blocknote-main.vercel.app/).
29
-
30
- (Source in [examples/editor](/examples/editor))
30
+ See our homepage @ [https://www.blocknotejs.org](https://www.blocknotejs.org/) or browse the [examples](https://www.blocknotejs.org/examples).
31
31
 
32
32
  # Example code (React)
33
33
 
34
34
  [![npm version](https://badge.fury.io/js/%40blocknote%2Freact.svg)](https://badge.fury.io/js/%40blocknote%2Freact)
35
35
 
36
36
  ```typescript
37
- import { BlockNoteView, useBlockNote } from "@blocknote/react";
37
+ import { BlockNoteView, useCreateBlockNote } from "@blocknote/react";
38
+ import "@blocknote/core/fonts/inter.css";
38
39
  import "@blocknote/react/style.css";
39
40
 
40
41
  function App() {
41
- const editor = useBlockNote({
42
- onEditorContentChange: (editor) => {
43
- // Log the document to console on every update
44
- console.log(editor.getJSON());
45
- },
46
- });
42
+ const editor = useCreateBlockNote();
47
43
 
48
44
  return <BlockNoteView editor={editor} />;
49
45
  }
@@ -99,8 +95,8 @@ Directory structure:
99
95
  blocknote
100
96
  ├── packages/core - The core of the editor
101
97
  ├── packages/react - The main library for use in React apps
102
- ├── examples/editor - Example React app that embeds the editor
103
- ├── examples/vanilla - An advanced example if you don't want to use React or want to build your own UI components
98
+ ├── examples - Example apps
99
+ ├── playground - App to browse the example apps (https://playground.blocknotejs.org)
104
100
  └── tests - Playwright end to end tests
105
101
  ```
106
102