@blocknote/core 0.40.0 → 0.41.1

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 (102) hide show
  1. package/dist/BlockNoteSchema-COA0fsXW.cjs +11 -0
  2. package/dist/BlockNoteSchema-COA0fsXW.cjs.map +1 -0
  3. package/dist/{BlockNoteSchema-oR047ACf.js → BlockNoteSchema-CYRHak18.js} +681 -581
  4. package/dist/BlockNoteSchema-CYRHak18.js.map +1 -0
  5. package/dist/blocknote.cjs +4 -4
  6. package/dist/blocknote.cjs.map +1 -1
  7. package/dist/blocknote.js +3663 -2817
  8. package/dist/blocknote.js.map +1 -1
  9. package/dist/blocks.cjs +1 -1
  10. package/dist/blocks.js +51 -49
  11. package/dist/en-Cl87Uuyf.cjs +2 -0
  12. package/dist/en-Cl87Uuyf.cjs.map +1 -0
  13. package/dist/{en-Bq3Es3Np.js → en-njEqD7AG.js} +9 -3
  14. package/dist/en-njEqD7AG.js.map +1 -0
  15. package/dist/locales.cjs +1 -1
  16. package/dist/locales.cjs.map +1 -1
  17. package/dist/locales.js +122 -2
  18. package/dist/locales.js.map +1 -1
  19. package/dist/style.css +1 -1
  20. package/dist/webpack-stats.json +1 -1
  21. package/package.json +4 -3
  22. package/src/api/exporters/html/externalHTMLExporter.ts +1 -1
  23. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +2 -1
  24. package/src/api/exporters/markdown/markdownExporter.ts +3 -1
  25. package/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts +19 -0
  26. package/src/api/parsers/markdown/parseMarkdown.ts +31 -0
  27. package/src/blocks/Code/block.ts +14 -14
  28. package/src/blocks/Divider/block.ts +49 -0
  29. package/src/blocks/ListItem/BulletListItem/block.ts +9 -1
  30. package/src/blocks/ListItem/CheckListItem/block.ts +1 -0
  31. package/src/blocks/ListItem/NumberedListItem/block.ts +9 -1
  32. package/src/blocks/Table/block.ts +56 -1
  33. package/src/blocks/ToggleWrapper/createToggleWrapper.ts +1 -1
  34. package/src/blocks/defaultBlocks.ts +16 -14
  35. package/src/blocks/index.ts +1 -0
  36. package/src/editor/Block.css +14 -20
  37. package/src/editor/BlockNoteEditor.test.ts +40 -0
  38. package/src/editor/BlockNoteEditor.ts +248 -465
  39. package/src/editor/BlockNoteExtensions.ts +3 -1
  40. package/src/editor/managers/BlockManager.ts +251 -0
  41. package/src/editor/managers/CollaborationManager.ts +212 -0
  42. package/src/editor/managers/EventManager.ts +134 -0
  43. package/src/editor/managers/ExportManager.ts +137 -0
  44. package/src/editor/managers/ExtensionManager.ts +130 -0
  45. package/src/editor/managers/SelectionManager.ts +114 -0
  46. package/src/editor/managers/StateManager.ts +238 -0
  47. package/src/editor/managers/StyleManager.ts +182 -0
  48. package/src/editor/managers/index.ts +11 -0
  49. package/src/extensions/Comments/CommentsPlugin.ts +7 -4
  50. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +10 -0
  51. package/src/i18n/locales/ar.ts +6 -0
  52. package/src/i18n/locales/de.ts +6 -0
  53. package/src/i18n/locales/en.ts +6 -0
  54. package/src/i18n/locales/es.ts +6 -0
  55. package/src/i18n/locales/fr.ts +6 -0
  56. package/src/i18n/locales/he.ts +6 -0
  57. package/src/i18n/locales/hr.ts +6 -0
  58. package/src/i18n/locales/is.ts +6 -0
  59. package/src/i18n/locales/it.ts +6 -0
  60. package/src/i18n/locales/ja.ts +6 -0
  61. package/src/i18n/locales/ko.ts +6 -0
  62. package/src/i18n/locales/nl.ts +6 -0
  63. package/src/i18n/locales/no.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/sk.ts +6 -0
  68. package/src/i18n/locales/uk.ts +6 -0
  69. package/src/i18n/locales/vi.ts +6 -0
  70. package/src/i18n/locales/zh-tw.ts +6 -0
  71. package/src/i18n/locales/zh.ts +6 -0
  72. package/src/schema/blocks/createSpec.ts +1 -0
  73. package/src/util/string.ts +21 -0
  74. package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +2 -0
  75. package/types/src/blocks/Divider/block.d.ts +3 -0
  76. package/types/src/blocks/Heading/block.d.ts +3 -3
  77. package/types/src/blocks/defaultBlocks.d.ts +2 -1
  78. package/types/src/blocks/index.d.ts +1 -0
  79. package/types/src/editor/BlockNoteEditor.d.ts +68 -47
  80. package/types/src/editor/BlockNoteExtensions.d.ts +2 -1
  81. package/types/src/editor/managers/BlockManager.d.ts +114 -0
  82. package/types/src/editor/managers/CollaborationManager.d.ts +115 -0
  83. package/types/src/editor/managers/EventManager.d.ts +58 -0
  84. package/types/src/editor/managers/ExportManager.d.ts +64 -0
  85. package/types/src/editor/managers/ExtensionManager.d.ts +68 -0
  86. package/types/src/editor/managers/SelectionManager.d.ts +54 -0
  87. package/types/src/editor/managers/StateManager.d.ts +115 -0
  88. package/types/src/editor/managers/StyleManager.d.ts +48 -0
  89. package/types/src/editor/managers/index.d.ts +8 -0
  90. package/types/src/extensions/Comments/CommentsPlugin.d.ts +4 -3
  91. package/types/src/i18n/locales/en.d.ts +6 -0
  92. package/types/src/i18n/locales/sk.d.ts +6 -0
  93. package/types/src/util/string.d.ts +1 -0
  94. package/dist/BlockNoteSchema-DmZ6UQfY.cjs +0 -11
  95. package/dist/BlockNoteSchema-DmZ6UQfY.cjs.map +0 -1
  96. package/dist/BlockNoteSchema-oR047ACf.js.map +0 -1
  97. package/dist/en-Bq3Es3Np.js.map +0 -1
  98. package/dist/en-D3B48eJ7.cjs +0 -2
  99. package/dist/en-D3B48eJ7.cjs.map +0 -1
  100. package/dist/tsconfig.tsbuildinfo +0 -1
  101. /package/src/api/exporters/markdown/{removeUnderlinesRehypePlugin.ts → util/removeUnderlinesRehypePlugin.ts} +0 -0
  102. /package/types/src/api/exporters/markdown/{removeUnderlinesRehypePlugin.d.ts → util/removeUnderlinesRehypePlugin.d.ts} +0 -0
@@ -3,11 +3,26 @@ import Code from "@tiptap/extension-code";
3
3
  import Italic from "@tiptap/extension-italic";
4
4
  import Strike from "@tiptap/extension-strike";
5
5
  import Underline from "@tiptap/extension-underline";
6
+ import { COLORS_DEFAULT } from "../editor/defaultColors.js";
7
+ import {
8
+ BlockNoDefaults,
9
+ BlockSchema,
10
+ InlineContentSchema,
11
+ InlineContentSpecs,
12
+ PartialBlockNoDefaults,
13
+ StyleSchema,
14
+ StyleSpecs,
15
+ createStyleSpec,
16
+ createStyleSpecFromTipTapMark,
17
+ getInlineContentSchemaFromSpecs,
18
+ getStyleSchemaFromSpecs,
19
+ } from "../schema/index.js";
6
20
  import {
7
21
  createAudioBlockSpec,
8
22
  createBulletListItemBlockSpec,
9
23
  createCheckListItemBlockSpec,
10
24
  createCodeBlockSpec,
25
+ createDividerBlockSpec,
11
26
  createFileBlockSpec,
12
27
  createHeadingBlockSpec,
13
28
  createImageBlockSpec,
@@ -18,27 +33,14 @@ import {
18
33
  createVideoBlockSpec,
19
34
  defaultProps,
20
35
  } from "./index.js";
21
- import {
22
- BlockNoDefaults,
23
- BlockSchema,
24
- InlineContentSchema,
25
- InlineContentSpecs,
26
- PartialBlockNoDefaults,
27
- StyleSchema,
28
- StyleSpecs,
29
- createStyleSpec,
30
- createStyleSpecFromTipTapMark,
31
- getInlineContentSchemaFromSpecs,
32
- getStyleSchemaFromSpecs,
33
- } from "../schema/index.js";
34
36
  import { createTableBlockSpec } from "./Table/block.js";
35
- import { COLORS_DEFAULT } from "../editor/defaultColors.js";
36
37
 
37
38
  export const defaultBlockSpecs = {
38
39
  audio: createAudioBlockSpec(),
39
40
  bulletListItem: createBulletListItemBlockSpec(),
40
41
  checkListItem: createCheckListItemBlockSpec(),
41
42
  codeBlock: createCodeBlockSpec(),
43
+ divider: createDividerBlockSpec(),
42
44
  file: createFileBlockSpec(),
43
45
  heading: createHeadingBlockSpec(),
44
46
  image: createImageBlockSpec(),
@@ -1,6 +1,7 @@
1
1
  export * from "./Audio/block.js";
2
2
  export * from "./Audio/parseAudioElement.js";
3
3
  export * from "./Code/block.js";
4
+ export * from "./Divider/block.js";
4
5
  export * from "./File/block.js";
5
6
  export * from "./Heading/block.js";
6
7
  export * from "./Image/block.js";
@@ -184,6 +184,14 @@ NESTED BLOCKS
184
184
  padding-left: 1em;
185
185
  }
186
186
 
187
+ /* DIVIDERS */
188
+ [data-content-type="divider"] hr {
189
+ border: none;
190
+ border-top: 1px solid rgb(125, 121, 122);
191
+ margin: 0.5em 0;
192
+ flex: 1;
193
+ }
194
+
187
195
  /* LISTS */
188
196
 
189
197
  .bn-block-content::before {
@@ -232,21 +240,13 @@ NESTED BLOCKS
232
240
  }
233
241
 
234
242
  /* Checked */
235
- .bn-block-content[data-content-type="checkListItem"] > div {
236
- display: flex;
237
- width: 100%;
238
- }
239
-
240
- .bn-block-content[data-content-type="checkListItem"] > div > div {
241
- display: flex;
242
- justify-content: center;
243
- min-width: 24px;
244
- padding-right: 4px;
245
- }
246
-
247
- .bn-block-content[data-content-type="checkListItem"] > div > div > input {
248
- margin: 0;
243
+ .bn-block-content[data-content-type="checkListItem"] > input {
249
244
  cursor: pointer;
245
+ height: 24px;
246
+ margin-left: 4px;
247
+ margin-right: 8px;
248
+ margin-top: 0;
249
+ width: 12px;
250
250
  }
251
251
 
252
252
  .bn-block-content[data-content-type="checkListItem"][data-checked="true"]
@@ -263,12 +263,6 @@ NESTED BLOCKS
263
263
  }
264
264
 
265
265
  /* Toggle */
266
- .bn-block-content:has(.bn-toggle-wrapper) > div {
267
- display: flex;
268
- flex-direction: column;
269
- gap: 4px;
270
- }
271
-
272
266
  .bn-block:has(
273
267
  > .bn-block-content > div > .bn-toggle-wrapper[data-show-children="false"]
274
268
  )
@@ -4,6 +4,7 @@ import {
4
4
  getNearestBlockPos,
5
5
  } from "../api/getBlockInfoFromPos.js";
6
6
  import { BlockNoteEditor } from "./BlockNoteEditor.js";
7
+ import { BlockNoteExtension } from "./BlockNoteExtension.js";
7
8
 
8
9
  /**
9
10
  * @vitest-environment jsdom
@@ -102,3 +103,42 @@ it("block prop types", () => {
102
103
  expect(level).toBe(1);
103
104
  }
104
105
  });
106
+
107
+ it("onMount and onUnmount", () => {
108
+ const editor = BlockNoteEditor.create();
109
+ let mounted = false;
110
+ let unmounted = false;
111
+ editor.onMount(() => {
112
+ mounted = true;
113
+ });
114
+ editor.onUnmount(() => {
115
+ unmounted = true;
116
+ });
117
+ editor.mount(document.createElement("div"));
118
+ expect(mounted).toBe(true);
119
+ expect(unmounted).toBe(false);
120
+ editor.unmount();
121
+ expect(mounted).toBe(true);
122
+ expect(unmounted).toBe(true);
123
+ });
124
+
125
+ it("onCreate event", () => {
126
+ let created = false;
127
+ BlockNoteEditor.create({
128
+ extensions: [
129
+ (e) =>
130
+ new (class extends BlockNoteExtension {
131
+ public static key() {
132
+ return "test";
133
+ }
134
+ constructor(editor: BlockNoteEditor) {
135
+ super(editor);
136
+ editor.onCreate(() => {
137
+ created = true;
138
+ });
139
+ }
140
+ })(e),
141
+ ],
142
+ });
143
+ expect(created).toBe(true);
144
+ });