@blocknote/core 0.24.1 → 0.25.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 (149) hide show
  1. package/dist/blocknote.cjs +12 -0
  2. package/dist/blocknote.cjs.map +1 -0
  3. package/dist/blocknote.js +5028 -3444
  4. package/dist/blocknote.js.map +1 -1
  5. package/dist/comments.cjs +2 -0
  6. package/dist/comments.cjs.map +1 -0
  7. package/dist/comments.js +593 -0
  8. package/dist/comments.js.map +1 -0
  9. package/dist/style.css +1 -1
  10. package/dist/tsconfig.tsbuildinfo +1 -1
  11. package/dist/webpack-stats.json +1 -1
  12. package/package.json +39 -26
  13. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +1022 -378
  14. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +730 -270
  15. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +3100 -1260
  16. package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +438 -162
  17. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +1168 -432
  18. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +930 -378
  19. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2485 -1015
  20. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +28 -1
  21. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +1 -1
  22. package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +292 -108
  23. package/src/api/blockManipulation/setupTestEnv.ts +14 -1
  24. package/src/api/blockManipulation/tables/tables.test.ts +1987 -0
  25. package/src/api/blockManipulation/tables/tables.ts +887 -0
  26. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +66 -24
  27. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +66 -24
  28. package/src/api/clipboard/__snapshots__/external/pasteImage.html +66 -24
  29. package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +66 -24
  30. package/src/api/clipboard/__snapshots__/external/pasteTable.html +132 -48
  31. package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +136 -44
  32. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +36 -14
  33. package/src/api/clipboard/toClipboard/copyExtension.ts +2 -3
  34. package/src/api/exporters/html/__snapshots__/table/headerCols/external.html +1 -0
  35. package/src/api/exporters/html/__snapshots__/table/headerCols/internal.html +1 -0
  36. package/src/api/exporters/html/__snapshots__/table/headerRows/external.html +1 -0
  37. package/src/api/exporters/html/__snapshots__/table/headerRows/internal.html +1 -0
  38. package/src/api/exporters/html/__snapshots__/table/headersRows/external.html +1 -0
  39. package/src/api/exporters/html/__snapshots__/table/headersRows/internal.html +1 -0
  40. package/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html +1 -0
  41. package/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html +1 -0
  42. package/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html +1 -0
  43. package/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html +1 -0
  44. package/src/api/exporters/markdown/__snapshots__/table/headerCols/markdown.md +4 -0
  45. package/src/api/exporters/markdown/__snapshots__/table/headerRows/markdown.md +4 -0
  46. package/src/api/exporters/markdown/__snapshots__/table/mixedCellColors/markdown.md +5 -0
  47. package/src/api/exporters/markdown/__snapshots__/table/mixedRowspansAndColspans/markdown.md +5 -0
  48. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +985 -20
  49. package/src/api/nodeConversions/blockToNode.ts +63 -20
  50. package/src/api/nodeConversions/nodeToBlock.ts +75 -13
  51. package/src/api/parsers/html/__snapshots__/parse-notion-html.json +145 -54
  52. package/src/api/testUtil/cases/defaultSchema.ts +782 -9
  53. package/src/api/testUtil/partialBlockTestUtil.ts +39 -4
  54. package/src/blocks/TableBlockContent/TableBlockContent.ts +11 -5
  55. package/src/blocks/defaultBlockTypeGuards.ts +8 -0
  56. package/src/comments/index.ts +9 -0
  57. package/src/comments/models/User.ts +8 -0
  58. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +106 -0
  59. package/src/comments/threadstore/ThreadStore.ts +134 -0
  60. package/src/comments/threadstore/ThreadStoreAuth.ts +13 -0
  61. package/src/comments/threadstore/TipTapThreadStore.ts +292 -0
  62. package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +144 -0
  63. package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +294 -0
  64. package/src/comments/threadstore/yjs/YjsThreadStore.ts +340 -0
  65. package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +48 -0
  66. package/src/comments/threadstore/yjs/yjsHelpers.ts +121 -0
  67. package/src/comments/types.ts +117 -0
  68. package/src/editor/Block.css +16 -8
  69. package/src/editor/BlockNoteEditor.ts +269 -92
  70. package/src/editor/BlockNoteExtensions.ts +24 -1
  71. package/src/editor/BlockNoteTipTapEditor.ts +5 -1
  72. package/src/editor/editor.css +17 -0
  73. package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +1 -1
  74. package/src/extensions/Comments/CommentMark.ts +61 -0
  75. package/src/extensions/Comments/CommentsPlugin.ts +301 -0
  76. package/src/extensions/Comments/userstore/UserStore.ts +72 -0
  77. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +16 -10
  78. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +3 -3
  79. package/src/extensions/ShowSelection/ShowSelectionPlugin.ts +52 -0
  80. package/src/extensions/SideMenu/SideMenuPlugin.ts +22 -9
  81. package/src/extensions/TableHandles/TableHandlesPlugin.ts +409 -57
  82. package/src/extensions/TextAlignment/TextAlignmentExtension.ts +2 -0
  83. package/src/extensions/TextColor/TextColorExtension.ts +1 -1
  84. package/src/extensions/UniqueID/UniqueID.ts +8 -3
  85. package/src/i18n/locales/ar.ts +23 -0
  86. package/src/i18n/locales/de.ts +15 -0
  87. package/src/i18n/locales/en.ts +25 -1
  88. package/src/i18n/locales/es.ts +16 -1
  89. package/src/i18n/locales/fr.ts +23 -0
  90. package/src/i18n/locales/hr.ts +18 -0
  91. package/src/i18n/locales/index.ts +1 -0
  92. package/src/i18n/locales/is.ts +24 -1
  93. package/src/i18n/locales/it.ts +21 -0
  94. package/src/i18n/locales/ja.ts +23 -0
  95. package/src/i18n/locales/ko.ts +23 -0
  96. package/src/i18n/locales/nl.ts +23 -0
  97. package/src/i18n/locales/no.ts +346 -0
  98. package/src/i18n/locales/pl.ts +23 -0
  99. package/src/i18n/locales/pt.ts +23 -0
  100. package/src/i18n/locales/ru.ts +23 -0
  101. package/src/i18n/locales/uk.ts +23 -0
  102. package/src/i18n/locales/vi.ts +23 -0
  103. package/src/i18n/locales/zh.ts +23 -0
  104. package/src/index.ts +6 -4
  105. package/src/schema/blocks/types.ts +32 -2
  106. package/src/util/browser.ts +1 -1
  107. package/src/util/table.ts +107 -0
  108. package/types/src/api/blockManipulation/tables/tables.d.ts +343 -0
  109. package/types/src/api/blockManipulation/tables/tables.test.d.ts +1 -0
  110. package/types/src/api/clipboard/toClipboard/copyExtension.d.ts +1 -1
  111. package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +1 -2
  112. package/types/src/blocks/defaultBlockTypeGuards.d.ts +3 -0
  113. package/types/src/comments/index.d.ts +9 -0
  114. package/types/src/comments/models/User.d.ts +8 -0
  115. package/types/src/comments/threadstore/DefaultThreadStoreAuth.d.ts +47 -0
  116. package/types/src/comments/threadstore/ThreadStore.d.ts +121 -0
  117. package/types/src/comments/threadstore/ThreadStoreAuth.d.ts +12 -0
  118. package/types/src/comments/threadstore/TipTapThreadStore.d.ts +97 -0
  119. package/types/src/comments/threadstore/yjs/RESTYjsThreadStore.d.ts +83 -0
  120. package/types/src/comments/threadstore/yjs/YjsThreadStore.d.ts +79 -0
  121. package/types/src/comments/threadstore/yjs/YjsThreadStore.test.d.ts +1 -0
  122. package/types/src/comments/threadstore/yjs/YjsThreadStoreBase.d.ts +15 -0
  123. package/types/src/comments/threadstore/yjs/yjsHelpers.d.ts +13 -0
  124. package/types/src/comments/types.d.ts +109 -0
  125. package/types/src/editor/BlockNoteEditor.d.ts +146 -66
  126. package/types/src/editor/BlockNoteExtensions.d.ts +4 -0
  127. package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +1 -1
  128. package/types/src/extensions/Comments/CommentMark.d.ts +2 -0
  129. package/types/src/extensions/Comments/CommentsPlugin.d.ts +49 -0
  130. package/types/src/extensions/Comments/userstore/UserStore.d.ts +31 -0
  131. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +1 -1
  132. package/types/src/extensions/ShowSelection/ShowSelectionPlugin.d.ts +15 -0
  133. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +1 -0
  134. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +66 -1
  135. package/types/src/i18n/locales/de.d.ts +15 -0
  136. package/types/src/i18n/locales/en.d.ts +20 -0
  137. package/types/src/i18n/locales/es.d.ts +15 -0
  138. package/types/src/i18n/locales/hr.d.ts +18 -0
  139. package/types/src/i18n/locales/index.d.ts +1 -0
  140. package/types/src/i18n/locales/it.d.ts +21 -0
  141. package/types/src/i18n/locales/no.d.ts +2 -0
  142. package/types/src/index.d.ts +5 -4
  143. package/types/src/pm-nodes/BlockContainer.d.ts +2 -2
  144. package/types/src/pm-nodes/BlockGroup.d.ts +2 -2
  145. package/types/src/schema/blocks/types.d.ts +23 -2
  146. package/types/src/util/browser.d.ts +1 -1
  147. package/types/src/util/table.d.ts +12 -0
  148. package/dist/blocknote.umd.cjs +0 -11
  149. package/dist/blocknote.umd.cjs.map +0 -1
@@ -84,6 +84,9 @@ export declare const hr: {
84
84
  aliases: string[];
85
85
  group: string;
86
86
  };
87
+ comment: {
88
+ tooltip: string;
89
+ };
87
90
  };
88
91
  placeholders: {
89
92
  default: string;
@@ -91,6 +94,9 @@ export declare const hr: {
91
94
  bulletListItem: string;
92
95
  numberedListItem: string;
93
96
  checkListItem: string;
97
+ new_comment: string;
98
+ edit_comment: string;
99
+ comment_reply: string;
94
100
  };
95
101
  file_blocks: {
96
102
  image: {
@@ -242,6 +248,18 @@ export declare const hr: {
242
248
  url_placeholder: string;
243
249
  };
244
250
  };
251
+ comments: {
252
+ actions: {
253
+ add_reaction: string;
254
+ resolve: string;
255
+ edit_comment: string;
256
+ delete_comment: string;
257
+ more_actions: string;
258
+ };
259
+ reactions: {
260
+ reacted_by: string;
261
+ };
262
+ };
245
263
  generic: {
246
264
  ctrl_shortcut: string;
247
265
  };
@@ -9,6 +9,7 @@ export * from "./it.js";
9
9
  export * from "./ja.js";
10
10
  export * from "./ko.js";
11
11
  export * from "./nl.js";
12
+ export * from "./no.js";
12
13
  export * from "./pl.js";
13
14
  export * from "./pt.js";
14
15
  export * from "./ru.js";
@@ -48,6 +48,12 @@ export declare const it: {
48
48
  aliases: string[];
49
49
  group: string;
50
50
  };
51
+ page_break: {
52
+ title: string;
53
+ subtext: string;
54
+ aliases: string[];
55
+ group: string;
56
+ };
51
57
  table: {
52
58
  title: string;
53
59
  subtext: string;
@@ -91,6 +97,9 @@ export declare const it: {
91
97
  bulletListItem: string;
92
98
  numberedListItem: string;
93
99
  checkListItem: string;
100
+ new_comment: string;
101
+ edit_comment: string;
102
+ comment_reply: string;
94
103
  };
95
104
  file_blocks: {
96
105
  image: {
@@ -242,6 +251,18 @@ export declare const it: {
242
251
  url_placeholder: string;
243
252
  };
244
253
  };
254
+ comments: {
255
+ actions: {
256
+ add_reaction: string;
257
+ resolve: string;
258
+ edit_comment: string;
259
+ delete_comment: string;
260
+ more_actions: string;
261
+ };
262
+ reactions: {
263
+ reacted_by: string;
264
+ };
265
+ };
245
266
  generic: {
246
267
  ctrl_shortcut: string;
247
268
  };
@@ -0,0 +1,2 @@
1
+ import { Dictionary } from "../dictionary.js";
2
+ export declare const no: Dictionary;
@@ -1,4 +1,5 @@
1
1
  import * as locales from "./i18n/locales/index.js";
2
+ export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
2
3
  export * from "./api/exporters/html/externalHTMLExporter.js";
3
4
  export * from "./api/exporters/html/internalHTMLSerializer.js";
4
5
  export * from "./api/getBlockInfoFromPos.js";
@@ -6,9 +7,6 @@ export * from "./api/nodeUtil.js";
6
7
  export * from "./api/testUtil/index.js";
7
8
  export * from "./blocks/AudioBlockContent/AudioBlockContent.js";
8
9
  export * from "./blocks/CodeBlockContent/CodeBlockContent.js";
9
- export * from "./blocks/PageBreakBlockContent/PageBreakBlockContent.js";
10
- export * from "./blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.js";
11
- export * from "./blocks/PageBreakBlockContent/schema.js";
12
10
  export * from "./blocks/FileBlockContent/FileBlockContent.js";
13
11
  export * from "./blocks/FileBlockContent/helpers/parse/parseEmbedElement.js";
14
12
  export * from "./blocks/FileBlockContent/helpers/parse/parseFigureElement.js";
@@ -20,6 +18,9 @@ export * from "./blocks/FileBlockContent/helpers/toExternalHTML/createFigureWith
20
18
  export * from "./blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js";
21
19
  export * from "./blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js";
22
20
  export * from "./blocks/ImageBlockContent/ImageBlockContent.js";
21
+ export * from "./blocks/PageBreakBlockContent/PageBreakBlockContent.js";
22
+ export * from "./blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.js";
23
+ export * from "./blocks/PageBreakBlockContent/schema.js";
23
24
  export { EMPTY_CELL_HEIGHT, EMPTY_CELL_WIDTH, } from "./blocks/TableBlockContent/TableExtension.js";
24
25
  export * from "./blocks/VideoBlockContent/VideoBlockContent.js";
25
26
  export * from "./blocks/defaultBlockHelpers.js";
@@ -49,11 +50,11 @@ export * from "./schema/index.js";
49
50
  export * from "./util/browser.js";
50
51
  export * from "./util/combineByGroup.js";
51
52
  export * from "./util/esmDependencies.js";
53
+ export * from "./util/table.js";
52
54
  export * from "./util/string.js";
53
55
  export * from "./util/typescript.js";
54
56
  export { UnreachableCaseError, assertEmpty } from "./util/typescript.js";
55
57
  export { locales };
56
- export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
57
58
  export * from "./api/nodeConversions/blockToNode.js";
58
59
  export * from "./api/nodeConversions/nodeToBlock.js";
59
60
  export * from "./api/testUtil/partialBlockTestUtil.js";
@@ -5,10 +5,10 @@ import type { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
5
5
  */
6
6
  export declare const BlockContainer: Node<{
7
7
  domAttributes?: Partial<{
8
- blockGroup: Record<string, string>;
9
- blockContent: Record<string, string>;
10
8
  editor: Record<string, string>;
11
9
  block: Record<string, string>;
10
+ blockGroup: Record<string, string>;
11
+ blockContent: Record<string, string>;
12
12
  inlineContent: Record<string, string>;
13
13
  }> | undefined;
14
14
  editor: BlockNoteEditor<any, any, any>;
@@ -1,10 +1,10 @@
1
1
  import { Node } from "@tiptap/core";
2
2
  export declare const BlockGroup: Node<{
3
3
  domAttributes?: Partial<{
4
- blockGroup: Record<string, string>;
5
- blockContent: Record<string, string>;
6
4
  editor: Record<string, string>;
7
5
  block: Record<string, string>;
6
+ blockGroup: Record<string, string>;
7
+ blockContent: Record<string, string>;
8
8
  inlineContent: Record<string, string>;
9
9
  }> | undefined;
10
10
  }, any>;
@@ -73,11 +73,25 @@ export type BlockSchemaFromSpecs<T extends BlockSpecs> = {
73
73
  export type BlockSchemaWithBlock<BType extends string, C extends BlockConfig> = {
74
74
  [k in BType]: C;
75
75
  };
76
+ export type TableCellProps = {
77
+ backgroundColor: string;
78
+ textColor: string;
79
+ textAlignment: "left" | "center" | "right" | "justify";
80
+ colspan?: number;
81
+ rowspan?: number;
82
+ };
83
+ export type TableCell<I extends InlineContentSchema, S extends StyleSchema = StyleSchema> = {
84
+ type: "tableCell";
85
+ props: TableCellProps;
86
+ content: InlineContent<I, S>[];
87
+ };
76
88
  export type TableContent<I extends InlineContentSchema, S extends StyleSchema = StyleSchema> = {
77
89
  type: "tableContent";
78
90
  columnWidths: (number | undefined)[];
91
+ headerRows?: number;
92
+ headerCols?: number;
79
93
  rows: {
80
- cells: InlineContent<I, S>[][];
94
+ cells: InlineContent<I, S>[][] | TableCell<I, S>[];
81
95
  }[];
82
96
  };
83
97
  export type BlockFromConfigNoChildren<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = {
@@ -104,11 +118,18 @@ export type SpecificBlock<BSchema extends BlockSchema, BType extends keyof BSche
104
118
  *create/update blocks in the editor.
105
119
  *
106
120
  */
121
+ export type PartialTableCell<I extends InlineContentSchema, S extends StyleSchema = StyleSchema> = {
122
+ type: "tableCell";
123
+ props?: Partial<TableCellProps>;
124
+ content?: PartialInlineContent<I, S>;
125
+ };
107
126
  export type PartialTableContent<I extends InlineContentSchema, S extends StyleSchema = StyleSchema> = {
108
127
  type: "tableContent";
109
128
  columnWidths?: (number | undefined)[];
129
+ headerRows?: number;
130
+ headerCols?: number;
110
131
  rows: {
111
- cells: PartialInlineContent<I, S>[];
132
+ cells: PartialInlineContent<I, S>[] | PartialTableCell<I, S>[];
112
133
  }[];
113
134
  };
114
135
  type PartialBlockFromConfigNoChildren<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = {
@@ -1,4 +1,4 @@
1
1
  export declare const isAppleOS: () => boolean;
2
2
  export declare function formatKeyboardShortcut(shortcut: string, ctrlText?: string): string;
3
- export declare function mergeCSSClasses(...classes: string[]): string;
3
+ export declare function mergeCSSClasses(...classes: (string | false | undefined)[]): string;
4
4
  export declare const isSafari: () => boolean;
@@ -0,0 +1,12 @@
1
+ import type { InlineContentSchema, StyleSchema, PartialInlineContent } from "../schema";
2
+ import { PartialTableCell, TableCell } from "../schema/blocks/types.js";
3
+ /**
4
+ * This will map a table cell to a TableCell object.
5
+ * This is useful for when we want to get the full table cell object from a partial table cell.
6
+ * It is guaranteed to return a new TableCell object.
7
+ */
8
+ export declare function mapTableCell<T extends InlineContentSchema, S extends StyleSchema>(content: PartialInlineContent<T, S> | PartialTableCell<T, S> | TableCell<T, S>): TableCell<T, S>;
9
+ export declare function isPartialTableCell<T extends InlineContentSchema, S extends StyleSchema>(content: TableCell<T, S> | PartialInlineContent<T, S> | PartialTableCell<T, S> | undefined | null): content is PartialTableCell<T, S>;
10
+ export declare function isTableCell<T extends InlineContentSchema, S extends StyleSchema>(content: TableCell<T, S> | PartialInlineContent<T, S> | PartialTableCell<T, S> | undefined | null): content is TableCell<T, S>;
11
+ export declare function getColspan(cell: TableCell<any, any> | PartialTableCell<any, any> | PartialInlineContent<any, any>): number;
12
+ export declare function getRowspan(cell: TableCell<any, any> | PartialTableCell<any, any> | PartialInlineContent<any, any>): number;