@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.
- package/dist/BlockNoteSchema-COA0fsXW.cjs +11 -0
- package/dist/BlockNoteSchema-COA0fsXW.cjs.map +1 -0
- package/dist/{BlockNoteSchema-oR047ACf.js → BlockNoteSchema-CYRHak18.js} +681 -581
- package/dist/BlockNoteSchema-CYRHak18.js.map +1 -0
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +3663 -2817
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +51 -49
- package/dist/en-Cl87Uuyf.cjs +2 -0
- package/dist/en-Cl87Uuyf.cjs.map +1 -0
- package/dist/{en-Bq3Es3Np.js → en-njEqD7AG.js} +9 -3
- package/dist/en-njEqD7AG.js.map +1 -0
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +122 -2
- package/dist/locales.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +4 -3
- package/src/api/exporters/html/externalHTMLExporter.ts +1 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +2 -1
- package/src/api/exporters/markdown/markdownExporter.ts +3 -1
- package/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts +19 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +31 -0
- package/src/blocks/Code/block.ts +14 -14
- package/src/blocks/Divider/block.ts +49 -0
- package/src/blocks/ListItem/BulletListItem/block.ts +9 -1
- package/src/blocks/ListItem/CheckListItem/block.ts +1 -0
- package/src/blocks/ListItem/NumberedListItem/block.ts +9 -1
- package/src/blocks/Table/block.ts +56 -1
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +1 -1
- package/src/blocks/defaultBlocks.ts +16 -14
- package/src/blocks/index.ts +1 -0
- package/src/editor/Block.css +14 -20
- package/src/editor/BlockNoteEditor.test.ts +40 -0
- package/src/editor/BlockNoteEditor.ts +248 -465
- package/src/editor/BlockNoteExtensions.ts +3 -1
- package/src/editor/managers/BlockManager.ts +251 -0
- package/src/editor/managers/CollaborationManager.ts +212 -0
- package/src/editor/managers/EventManager.ts +134 -0
- package/src/editor/managers/ExportManager.ts +137 -0
- package/src/editor/managers/ExtensionManager.ts +130 -0
- package/src/editor/managers/SelectionManager.ts +114 -0
- package/src/editor/managers/StateManager.ts +238 -0
- package/src/editor/managers/StyleManager.ts +182 -0
- package/src/editor/managers/index.ts +11 -0
- package/src/extensions/Comments/CommentsPlugin.ts +7 -4
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +10 -0
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/de.ts +6 -0
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +6 -0
- package/src/i18n/locales/fr.ts +6 -0
- package/src/i18n/locales/he.ts +6 -0
- package/src/i18n/locales/hr.ts +6 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/it.ts +6 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +6 -0
- package/src/i18n/locales/nl.ts +6 -0
- package/src/i18n/locales/no.ts +6 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +6 -0
- package/src/i18n/locales/ru.ts +6 -0
- package/src/i18n/locales/sk.ts +6 -0
- package/src/i18n/locales/uk.ts +6 -0
- package/src/i18n/locales/vi.ts +6 -0
- package/src/i18n/locales/zh-tw.ts +6 -0
- package/src/i18n/locales/zh.ts +6 -0
- package/src/schema/blocks/createSpec.ts +1 -0
- package/src/util/string.ts +21 -0
- package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +2 -0
- package/types/src/blocks/Divider/block.d.ts +3 -0
- package/types/src/blocks/Heading/block.d.ts +3 -3
- package/types/src/blocks/defaultBlocks.d.ts +2 -1
- package/types/src/blocks/index.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +68 -47
- package/types/src/editor/BlockNoteExtensions.d.ts +2 -1
- package/types/src/editor/managers/BlockManager.d.ts +114 -0
- package/types/src/editor/managers/CollaborationManager.d.ts +115 -0
- package/types/src/editor/managers/EventManager.d.ts +58 -0
- package/types/src/editor/managers/ExportManager.d.ts +64 -0
- package/types/src/editor/managers/ExtensionManager.d.ts +68 -0
- package/types/src/editor/managers/SelectionManager.d.ts +54 -0
- package/types/src/editor/managers/StateManager.d.ts +115 -0
- package/types/src/editor/managers/StyleManager.d.ts +48 -0
- package/types/src/editor/managers/index.d.ts +8 -0
- package/types/src/extensions/Comments/CommentsPlugin.d.ts +4 -3
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/sk.d.ts +6 -0
- package/types/src/util/string.d.ts +1 -0
- package/dist/BlockNoteSchema-DmZ6UQfY.cjs +0 -11
- package/dist/BlockNoteSchema-DmZ6UQfY.cjs.map +0 -1
- package/dist/BlockNoteSchema-oR047ACf.js.map +0 -1
- package/dist/en-Bq3Es3Np.js.map +0 -1
- package/dist/en-D3B48eJ7.cjs +0 -2
- package/dist/en-D3B48eJ7.cjs.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/src/api/exporters/markdown/{removeUnderlinesRehypePlugin.ts → util/removeUnderlinesRehypePlugin.ts} +0 -0
- /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(),
|
package/src/blocks/index.ts
CHANGED
package/src/editor/Block.css
CHANGED
|
@@ -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"] >
|
|
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
|
+
});
|