@blocknote/core 0.13.2 → 0.13.3

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 (137) hide show
  1. package/dist/blocknote.js +5282 -2785
  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/webpack-stats.json +1 -1
  7. package/package.json +2 -2
  8. package/src/api/exporters/html/__snapshots__/file/basic/external.html +1 -0
  9. package/src/api/exporters/html/__snapshots__/file/basic/internal.html +1 -0
  10. package/src/api/exporters/html/__snapshots__/file/button/external.html +1 -0
  11. package/src/api/exporters/html/__snapshots__/file/button/internal.html +1 -0
  12. package/src/api/exporters/html/__snapshots__/file/nested/external.html +1 -0
  13. package/src/api/exporters/html/__snapshots__/file/nested/internal.html +1 -0
  14. package/src/api/exporters/html/__snapshots__/file/noCaption/external.html +1 -0
  15. package/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +1 -0
  16. package/src/api/exporters/html/__snapshots__/file/noName/external.html +1 -0
  17. package/src/api/exporters/html/__snapshots__/file/noName/internal.html +1 -0
  18. package/src/api/exporters/html/__snapshots__/image/basic/external.html +1 -1
  19. package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
  20. package/src/api/exporters/html/__snapshots__/image/button/external.html +1 -1
  21. package/src/api/exporters/html/__snapshots__/image/button/internal.html +1 -1
  22. package/src/api/exporters/html/__snapshots__/image/nested/external.html +1 -1
  23. package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
  24. package/src/api/exporters/html/__snapshots__/image/noCaption/external.html +1 -0
  25. package/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +1 -0
  26. package/src/api/exporters/html/__snapshots__/image/noName/external.html +1 -0
  27. package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -0
  28. package/src/api/exporters/html/__snapshots__/image/noPreview/external.html +1 -0
  29. package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -0
  30. package/src/api/exporters/html/__snapshots__/simpleFile/basic/external.html +1 -0
  31. package/src/api/exporters/html/__snapshots__/simpleFile/basic/internal.html +1 -0
  32. package/src/api/exporters/html/__snapshots__/simpleFile/button/external.html +1 -0
  33. package/src/api/exporters/html/__snapshots__/simpleFile/button/internal.html +1 -0
  34. package/src/api/exporters/html/__snapshots__/simpleFile/nested/external.html +1 -0
  35. package/src/api/exporters/html/__snapshots__/simpleFile/nested/internal.html +1 -0
  36. package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
  37. package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
  38. package/src/api/exporters/html/__snapshots__/simpleImage/button/external.html +1 -1
  39. package/src/api/exporters/html/__snapshots__/simpleImage/button/internal.html +1 -1
  40. package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
  41. package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
  42. package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -0
  43. package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +1 -0
  44. package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -0
  45. package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -0
  46. package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -0
  47. package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -0
  48. package/src/api/exporters/markdown/__snapshots__/file/basic/markdown.md +3 -0
  49. package/src/api/exporters/markdown/__snapshots__/file/button/markdown.md +1 -0
  50. package/src/api/exporters/markdown/__snapshots__/file/nested/markdown.md +7 -0
  51. package/src/api/exporters/markdown/__snapshots__/file/noCaption/markdown.md +1 -0
  52. package/src/api/exporters/markdown/__snapshots__/file/noName/markdown.md +3 -0
  53. package/src/api/exporters/markdown/__snapshots__/image/basic/markdown.md +1 -1
  54. package/src/api/exporters/markdown/__snapshots__/image/button/markdown.md +1 -1
  55. package/src/api/exporters/markdown/__snapshots__/image/nested/markdown.md +2 -2
  56. package/src/api/exporters/markdown/__snapshots__/image/noCaption/markdown.md +1 -0
  57. package/src/api/exporters/markdown/__snapshots__/image/noName/markdown.md +3 -0
  58. package/src/api/exporters/markdown/__snapshots__/image/noPreview/markdown.md +3 -0
  59. package/src/api/exporters/markdown/__snapshots__/simpleFile/basic/markdown.md +3 -0
  60. package/src/api/exporters/markdown/__snapshots__/simpleFile/button/markdown.md +1 -0
  61. package/src/api/exporters/markdown/__snapshots__/simpleFile/nested/markdown.md +7 -0
  62. package/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +3 -1
  63. package/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md +1 -0
  64. package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +6 -2
  65. package/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +1 -0
  66. package/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +3 -0
  67. package/src/api/exporters/markdown/__snapshots__/simpleImage/noPreview/markdown.md +3 -0
  68. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +212 -4
  69. package/src/api/parsers/html/__snapshots__/paste/parse-basic-block-types.json +3 -1
  70. package/src/api/parsers/html/__snapshots__/paste/parse-fake-image-caption.json +3 -1
  71. package/src/api/testUtil/cases/customBlocks.ts +79 -33
  72. package/src/api/testUtil/cases/customInlineContent.ts +1 -1
  73. package/src/api/testUtil/cases/customStyles.ts +1 -1
  74. package/src/api/testUtil/cases/defaultSchema.ts +114 -4
  75. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +162 -0
  76. package/src/blocks/AudioBlockContent/audioBlockHelpers.ts +5 -0
  77. package/src/blocks/FileBlockContent/FileBlockContent.ts +121 -0
  78. package/src/blocks/FileBlockContent/fileBlockHelpers.ts +377 -0
  79. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +135 -356
  80. package/src/blocks/ImageBlockContent/imageBlockHelpers.ts +6 -0
  81. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +182 -0
  82. package/src/blocks/VideoBlockContent/videoBlockHelpers.ts +6 -0
  83. package/src/blocks/defaultBlockTypeGuards.ts +53 -1
  84. package/src/blocks/defaultBlocks.ts +8 -2
  85. package/src/editor/Block.css +67 -27
  86. package/src/editor/BlockNoteEditor.ts +14 -10
  87. package/src/editor/BlockNoteSchema.ts +12 -3
  88. package/src/extensions/{ImagePanel/ImageToolbarPlugin.ts → FilePanel/FilePanelPlugin.ts} +22 -25
  89. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +14 -2
  90. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +59 -2
  91. package/src/i18n/locales/en.ts +102 -11
  92. package/src/i18n/locales/fr.ts +104 -11
  93. package/src/i18n/locales/index.ts +8 -2
  94. package/src/i18n/locales/is.ts +288 -0
  95. package/src/i18n/locales/ja.ts +300 -0
  96. package/src/i18n/locales/ko.ts +292 -0
  97. package/src/i18n/locales/nl.ts +101 -8
  98. package/src/i18n/locales/pl.ts +280 -0
  99. package/src/i18n/locales/pt.ts +281 -0
  100. package/src/i18n/locales/vi.ts +281 -0
  101. package/src/i18n/locales/zh.ts +107 -8
  102. package/src/index.ts +9 -2
  103. package/src/pm-nodes/BlockContainer.ts +2 -2
  104. package/src/schema/blocks/createSpec.ts +1 -0
  105. package/src/schema/blocks/internal.ts +10 -0
  106. package/src/schema/blocks/types.ts +41 -5
  107. package/src/util/string.ts +12 -0
  108. package/types/src/api/testUtil/cases/customBlocks.d.ts +228 -42
  109. package/types/src/api/testUtil/cases/customInlineContent.d.ts +178 -4
  110. package/types/src/api/testUtil/cases/customStyles.d.ts +178 -4
  111. package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +104 -0
  112. package/types/src/blocks/AudioBlockContent/audioBlockHelpers.d.ts +3 -0
  113. package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +96 -0
  114. package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +30 -0
  115. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +53 -14
  116. package/types/src/blocks/ImageBlockContent/imageBlockHelpers.d.ts +4 -0
  117. package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +132 -0
  118. package/types/src/blocks/VideoBlockContent/videoBlockHelpers.d.ts +4 -0
  119. package/types/src/blocks/defaultBlockTypeGuards.d.ts +6 -1
  120. package/types/src/blocks/defaultBlocks.d.ts +356 -8
  121. package/types/src/editor/BlockNoteEditor.d.ts +5 -5
  122. package/types/src/extensions/{ImagePanel/ImageToolbarPlugin.d.ts → FilePanel/FilePanelPlugin.d.ts} +9 -12
  123. package/types/src/i18n/locales/en.d.ts +49 -7
  124. package/types/src/i18n/locales/fr.d.ts +2 -184
  125. package/types/src/i18n/locales/index.d.ts +7 -1
  126. package/types/src/i18n/locales/is.d.ts +2 -0
  127. package/types/src/i18n/locales/ja.d.ts +2 -0
  128. package/types/src/i18n/locales/ko.d.ts +2 -0
  129. package/types/src/i18n/locales/pl.d.ts +2 -0
  130. package/types/src/i18n/locales/pt.d.ts +2 -0
  131. package/types/src/i18n/locales/vi.d.ts +2 -0
  132. package/types/src/index.d.ts +8 -2
  133. package/types/src/schema/blocks/internal.d.ts +1 -1
  134. package/types/src/schema/blocks/types.d.ts +26 -1
  135. package/types/src/util/string.d.ts +1 -0
  136. /package/src/blocks/{ImageBlockContent → FileBlockContent}/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -0
  137. /package/types/src/blocks/{ImageBlockContent → FileBlockContent}/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
2
- import { BlockFromConfig, BlockSchemaWithBlock, InlineContentSchema, StyleSchema } from "../../schema";
2
+ import { BlockFromConfig, Props } from "../../schema";
3
3
  export declare const imagePropSchema: {
4
4
  textAlignment: {
5
5
  default: "left";
@@ -8,17 +8,23 @@ export declare const imagePropSchema: {
8
8
  backgroundColor: {
9
9
  default: "default";
10
10
  };
11
+ name: {
12
+ default: "";
13
+ };
11
14
  url: {
12
15
  default: "";
13
16
  };
14
17
  caption: {
15
18
  default: "";
16
19
  };
17
- width: {
18
- default: 512;
20
+ showPreview: {
21
+ default: true;
22
+ };
23
+ previewWidth: {
24
+ default: number;
19
25
  };
20
26
  };
21
- declare const blockConfig: {
27
+ export declare const imageBlockConfig: {
22
28
  type: "image";
23
29
  propSchema: {
24
30
  textAlignment: {
@@ -28,23 +34,39 @@ declare const blockConfig: {
28
34
  backgroundColor: {
29
35
  default: "default";
30
36
  };
37
+ name: {
38
+ default: "";
39
+ };
31
40
  url: {
32
41
  default: "";
33
42
  };
34
43
  caption: {
35
44
  default: "";
36
45
  };
37
- width: {
38
- default: 512;
46
+ showPreview: {
47
+ default: true;
48
+ };
49
+ previewWidth: {
50
+ default: number;
39
51
  };
40
52
  };
41
53
  content: "none";
54
+ isFileBlock: true;
55
+ isFileBlockPlaceholder: (block: any) => boolean;
56
+ fileBlockAcceptMimeTypes: string[];
42
57
  };
43
- export declare const renderImage: (block: BlockFromConfig<typeof blockConfig, InlineContentSchema, StyleSchema>, editor: BlockNoteEditor<BlockSchemaWithBlock<"image", typeof blockConfig>>) => {
58
+ export declare const imageRender: (block: BlockFromConfig<typeof imageBlockConfig, any, any>, editor: BlockNoteEditor<any, any, any>) => {
44
59
  dom: HTMLDivElement;
45
60
  destroy: () => void;
61
+ } | {
62
+ dom: HTMLDivElement;
63
+ destroy?: undefined;
46
64
  };
47
- export declare const Image: {
65
+ export declare const imageParse: (element: HTMLElement) => Partial<Props<typeof imageBlockConfig.propSchema>> | undefined;
66
+ export declare const imageToExternalHTML: (block: BlockFromConfig<typeof imageBlockConfig, any, any>) => {
67
+ dom: HTMLElement;
68
+ };
69
+ export declare const ImageBlock: {
48
70
  config: {
49
71
  type: "image";
50
72
  propSchema: {
@@ -55,17 +77,26 @@ export declare const Image: {
55
77
  backgroundColor: {
56
78
  default: "default";
57
79
  };
80
+ name: {
81
+ default: "";
82
+ };
58
83
  url: {
59
84
  default: "";
60
85
  };
61
86
  caption: {
62
87
  default: "";
63
88
  };
64
- width: {
65
- default: 512;
89
+ showPreview: {
90
+ default: true;
91
+ };
92
+ previewWidth: {
93
+ default: number;
66
94
  };
67
95
  };
68
96
  content: "none";
97
+ isFileBlock: true;
98
+ isFileBlockPlaceholder: (block: any) => boolean;
99
+ fileBlockAcceptMimeTypes: string[];
69
100
  };
70
101
  implementation: import("../../schema").TiptapBlockImplementation<{
71
102
  type: "image";
@@ -77,17 +108,25 @@ export declare const Image: {
77
108
  backgroundColor: {
78
109
  default: "default";
79
110
  };
111
+ name: {
112
+ default: "";
113
+ };
80
114
  url: {
81
115
  default: "";
82
116
  };
83
117
  caption: {
84
118
  default: "";
85
119
  };
86
- width: {
87
- default: 512;
120
+ showPreview: {
121
+ default: true;
122
+ };
123
+ previewWidth: {
124
+ default: number;
88
125
  };
89
126
  };
90
127
  content: "none";
91
- }, any, InlineContentSchema, StyleSchema>;
128
+ isFileBlock: true;
129
+ isFileBlockPlaceholder: (block: any) => boolean;
130
+ fileBlockAcceptMimeTypes: string[];
131
+ }, any, import("../../schema").InlineContentSchema, import("../../schema").StyleSchema>;
92
132
  };
93
- export {};
@@ -0,0 +1,4 @@
1
+ export declare const parseImageElement: (imageElement: HTMLImageElement) => {
2
+ url: string | undefined;
3
+ previewWidth: number | undefined;
4
+ };
@@ -0,0 +1,132 @@
1
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
2
+ import { BlockFromConfig, Props } from "../../schema";
3
+ export declare const videoPropSchema: {
4
+ textAlignment: {
5
+ default: "left";
6
+ values: readonly ["left", "center", "right", "justify"];
7
+ };
8
+ backgroundColor: {
9
+ default: "default";
10
+ };
11
+ name: {
12
+ default: "";
13
+ };
14
+ url: {
15
+ default: "";
16
+ };
17
+ caption: {
18
+ default: "";
19
+ };
20
+ showPreview: {
21
+ default: true;
22
+ };
23
+ previewWidth: {
24
+ default: number;
25
+ };
26
+ };
27
+ export declare const videoBlockConfig: {
28
+ type: "video";
29
+ propSchema: {
30
+ textAlignment: {
31
+ default: "left";
32
+ values: readonly ["left", "center", "right", "justify"];
33
+ };
34
+ backgroundColor: {
35
+ default: "default";
36
+ };
37
+ name: {
38
+ default: "";
39
+ };
40
+ url: {
41
+ default: "";
42
+ };
43
+ caption: {
44
+ default: "";
45
+ };
46
+ showPreview: {
47
+ default: true;
48
+ };
49
+ previewWidth: {
50
+ default: number;
51
+ };
52
+ };
53
+ content: "none";
54
+ isFileBlock: true;
55
+ isFileBlockPlaceholder: (block: any) => boolean;
56
+ fileBlockAcceptMimeTypes: string[];
57
+ };
58
+ export declare const videoRender: (block: BlockFromConfig<typeof videoBlockConfig, any, any>, editor: BlockNoteEditor<any, any, any>) => {
59
+ dom: HTMLDivElement;
60
+ destroy: () => void;
61
+ } | {
62
+ dom: HTMLDivElement;
63
+ destroy?: undefined;
64
+ };
65
+ export declare const videoParse: (element: HTMLElement) => Partial<Props<typeof videoBlockConfig.propSchema>> | undefined;
66
+ export declare const videoToExternalHTML: (block: BlockFromConfig<typeof videoBlockConfig, any, any>) => {
67
+ dom: HTMLElement;
68
+ };
69
+ export declare const VideoBlock: {
70
+ config: {
71
+ type: "video";
72
+ propSchema: {
73
+ textAlignment: {
74
+ default: "left";
75
+ values: readonly ["left", "center", "right", "justify"];
76
+ };
77
+ backgroundColor: {
78
+ default: "default";
79
+ };
80
+ name: {
81
+ default: "";
82
+ };
83
+ url: {
84
+ default: "";
85
+ };
86
+ caption: {
87
+ default: "";
88
+ };
89
+ showPreview: {
90
+ default: true;
91
+ };
92
+ previewWidth: {
93
+ default: number;
94
+ };
95
+ };
96
+ content: "none";
97
+ isFileBlock: true;
98
+ isFileBlockPlaceholder: (block: any) => boolean;
99
+ fileBlockAcceptMimeTypes: string[];
100
+ };
101
+ implementation: import("../../schema").TiptapBlockImplementation<{
102
+ type: "video";
103
+ propSchema: {
104
+ textAlignment: {
105
+ default: "left";
106
+ values: readonly ["left", "center", "right", "justify"];
107
+ };
108
+ backgroundColor: {
109
+ default: "default";
110
+ };
111
+ name: {
112
+ default: "";
113
+ };
114
+ url: {
115
+ default: "";
116
+ };
117
+ caption: {
118
+ default: "";
119
+ };
120
+ showPreview: {
121
+ default: true;
122
+ };
123
+ previewWidth: {
124
+ default: number;
125
+ };
126
+ };
127
+ content: "none";
128
+ isFileBlock: true;
129
+ isFileBlockPlaceholder: (block: any) => boolean;
130
+ fileBlockAcceptMimeTypes: string[];
131
+ }, any, import("../../schema").InlineContentSchema, import("../../schema").StyleSchema>;
132
+ };
@@ -0,0 +1,4 @@
1
+ export declare const parseVideoElement: (videoElement: HTMLVideoElement) => {
2
+ url: string | undefined;
3
+ previewWidth: number | undefined;
4
+ };
@@ -1,11 +1,16 @@
1
1
  import type { BlockNoteEditor } from "../editor/BlockNoteEditor";
2
- import { BlockFromConfig, InlineContentSchema, StyleSchema } from "../schema";
2
+ import { BlockFromConfig, BlockSchema, FileBlockConfig, InlineContentSchema, StyleSchema } from "../schema";
3
3
  import { Block, DefaultBlockSchema } from "./defaultBlocks";
4
4
  import { defaultProps } from "./defaultProps";
5
5
  export declare function checkDefaultBlockTypeInSchema<BlockType extends keyof DefaultBlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blockType: BlockType, editor: BlockNoteEditor<any, I, S>): editor is BlockNoteEditor<{
6
6
  Type: DefaultBlockSchema[BlockType];
7
7
  }, I, S>;
8
8
  export declare function checkBlockIsDefaultType<BlockType extends keyof DefaultBlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blockType: BlockType, block: Block<any, I, S>, editor: BlockNoteEditor<any, I, S>): block is BlockFromConfig<DefaultBlockSchema[BlockType], I, S>;
9
+ export declare function checkBlockIsFileBlock<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(block: Block<any, I, S>, editor: BlockNoteEditor<B, I, S>): block is BlockFromConfig<FileBlockConfig, I, S>;
10
+ export declare function checkBlockIsFileBlockWithPreview<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(block: Block<any, I, S>, editor: BlockNoteEditor<B, I, S>): block is BlockFromConfig<FileBlockConfig & {
11
+ propSchema: Required<FileBlockConfig["propSchema"]>;
12
+ }, I, S>;
13
+ export declare function checkBlockIsFileBlockWithPlaceholder<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(block: Block<B, I, S>, editor: BlockNoteEditor<B, I, S>): boolean | undefined;
9
14
  export declare function checkBlockTypeHasDefaultProp<Prop extends keyof typeof defaultProps, I extends InlineContentSchema, S extends StyleSchema>(prop: Prop, blockType: string, editor: BlockNoteEditor<any, I, S>): editor is BlockNoteEditor<{
10
15
  [BT in string]: {
11
16
  type: BT;