@blocknote/core 0.15.9 → 0.15.10
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/blocknote.js +402 -394
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +5 -5
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +2 -2
- package/src/schema/blocks/createSpec.ts +31 -2
- package/src/schema/blocks/types.ts +2 -0
- package/src/schema/inlineContent/createSpec.ts +7 -4
- package/types/src/schema/blocks/createSpec.d.ts +3 -0
- package/types/src/schema/blocks/types.d.ts +2 -0
- package/types/src/schema/inlineContent/createSpec.d.ts +3 -2
package/dist/webpack-stats.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"builtAt":
|
|
1
|
+
{"builtAt":1726846121918,"assets":[{"name":"blocknote.umd.cjs","size":199731},{"name":"blocknote.umd.cjs.map","size":723863}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote.umd.cjs"],"names":["index"]}],"modules":[{"name":"./src/i18n/locales/ar.ts","size":6582,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/de.ts","size":7183,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/en.ts","size":6664,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/es.ts","size":6796,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/fr.ts","size":7294,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/is.ts","size":6876,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ja.ts","size":6323,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ko.ts","size":6146,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/nl.ts","size":7079,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pl.ts","size":6768,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pt.ts","size":6965,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ru.ts","size":7638,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/vi.ts","size":6927,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/zh.ts","size":6093,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/util/esmDependencies.ts","size":820,"chunks":["a1ee98a"]},{"name":"./src/extensions/UniqueID/UniqueID.ts","size":8887,"chunks":["a1ee98a"]},{"name":"./src/api/getBlockInfoFromPos.ts","size":1691,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/types.ts","size":302,"chunks":["a1ee98a"]},{"name":"./src/util/typescript.ts","size":331,"chunks":["a1ee98a"]},{"name":"./src/api/nodeConversions/nodeConversions.ts","size":11998,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/sharedHTMLConversion.ts","size":2311,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts","size":4488,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/externalHTMLExporter.ts","size":1320,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/internalHTMLSerializer.ts","size":758,"chunks":["a1ee98a"]},{"name":"./src/api/getCurrentBlockContentType.ts","size":192,"chunks":["a1ee98a"]},{"name":"./src/util/browser.ts","size":536,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockHelpers.ts","size":1691,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultProps.ts","size":269,"chunks":["a1ee98a"]},{"name":"./src/util/string.ts","size":299,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/internal.ts","size":3877,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/createSpec.ts","size":3331,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/internal.ts","size":1357,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/createSpec.ts","size":2761,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/internal.ts","size":1162,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/createSpec.ts","size":1263,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/fileBlockHelpers.ts","size":10029,"chunks":["a1ee98a"]},{"name":"./src/blocks/AudioBlockContent/audioBlockHelpers.ts","size":108,"chunks":["a1ee98a"]},{"name":"./src/blocks/AudioBlockContent/AudioBlockContent.ts","size":3075,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/FileBlockContent.ts","size":1581,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts","size":316,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/imageBlockHelpers.ts","size":175,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/ImageBlockContent.ts","size":3242,"chunks":["a1ee98a"]},{"name":"./src/blocks/VideoBlockContent/videoBlockHelpers.ts","size":175,"chunks":["a1ee98a"]},{"name":"./src/blocks/VideoBlockContent/VideoBlockContent.ts","size":3050,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorMark.ts","size":946,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorMark.ts","size":866,"chunks":["a1ee98a"]},{"name":"./src/blocks/HeadingBlockContent/HeadingBlockContent.ts","size":3439,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts","size":1201,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts","size":3122,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts","size":1862,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts","size":3437,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts","size":6423,"chunks":["a1ee98a"]},{"name":"./src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts","size":1307,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableExtension.ts","size":1462,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableBlockContent.ts","size":1624,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlocks.ts","size":1123,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockTypeGuards.ts","size":1580,"chunks":["a1ee98a"]},{"name":"./src/api/nodeUtil.ts","size":548,"chunks":["a1ee98a"]},{"name":"./src/api/blockManipulation/blockManipulation.ts","size":5664,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/removeUnderlinesRehypePlugin.ts","size":752,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts","size":962,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/markdownExporter.ts","size":837,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/util/nestedLists.ts","size":2174,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/parseHTML.ts","size":503,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/markdown/parseMarkdown.ts","size":1104,"chunks":["a1ee98a"]},{"name":"./src/util/EventEmitter.ts","size":744,"chunks":["a1ee98a"]},{"name":"./src/extensions/FilePanel/FilePanelPlugin.ts","size":3584,"chunks":["a1ee98a"]},{"name":"./src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts","size":5062,"chunks":["a1ee98a"]},{"name":"./src/extensions/LinkToolbar/LinkToolbarPlugin.ts","size":7365,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/MultipleNodeSelection.ts","size":1616,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/SideMenuPlugin.ts","size":17383,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/SuggestionPlugin.ts","size":7996,"chunks":["a1ee98a"]},{"name":"./src/extensions/TableHandles/TableHandlesPlugin.ts","size":15279,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/copyExtension.ts","size":3195,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/acceptedMIMETypes.ts","size":91,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/handleFileInsertion.ts","size":3396,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/fileDropExtension.ts","size":884,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/pasteExtension.ts","size":1244,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorExtension.ts","size":791,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextAlignment/TextAlignmentExtension.ts","size":928,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorExtension.ts","size":725,"chunks":["a1ee98a"]},{"name":"./src/extensions/TrailingNode/TrailingNodeExtension.ts","size":1594,"chunks":["a1ee98a"]},{"name":"./src/extensions/NonEditableBlocks/NonEditableBlockPlugin.ts","size":1086,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockContainer.ts","size":18085,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockGroup.ts","size":1097,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/Doc.ts","size":90,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteExtensions.ts","size":4286,"chunks":["a1ee98a"]},{"name":"./src/editor/transformPasted.ts","size":1062,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteSchema.ts","size":1044,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteTipTapEditor.ts","size":2883,"chunks":["a1ee98a"]},{"name":"./src/extensions/Placeholder/PlaceholderPlugin.ts","size":2762,"chunks":["a1ee98a"]},{"name":"./src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts","size":4572,"chunks":["a1ee98a"]},{"name":"./src/style.css","size":0,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteEditor.ts","size":27988,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts","size":700,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts","size":6416,"chunks":["a1ee98a"]},{"name":"./src/api/testUtil/partialBlockTestUtil.ts","size":2166,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]}]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://github.com/TypeCellOS/BlockNote",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"version": "0.15.
|
|
6
|
+
"version": "0.15.10",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
9
|
"types",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"access": "public",
|
|
120
120
|
"registry": "https://registry.npmjs.org/"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "9354902c7b8774fa8f4ca1921104fb99fdc28e03"
|
|
123
123
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/core";
|
|
1
2
|
import { TagParseRule } from "@tiptap/pm/model";
|
|
3
|
+
import { NodeView } from "@tiptap/pm/view";
|
|
2
4
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
5
|
import { InlineContentSchema } from "../inlineContent/types";
|
|
4
6
|
import { StyleSchema } from "../styles/types";
|
|
@@ -61,6 +63,27 @@ export type CustomBlockImplementation<
|
|
|
61
63
|
) => PartialBlockFromConfig<T, I, S>["props"] | undefined;
|
|
62
64
|
};
|
|
63
65
|
|
|
66
|
+
// Function that enables copying of selected content within non-selectable
|
|
67
|
+
// blocks.
|
|
68
|
+
export function applyNonSelectableBlockFix(nodeView: NodeView, editor: Editor) {
|
|
69
|
+
nodeView.stopEvent = (event) => {
|
|
70
|
+
// Ensures copy events are handled by the browser and not by ProseMirror.
|
|
71
|
+
if (event.type === "copy" || event.type === "cut") {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
// Blurs the editor on mouse down as the block is non-selectable. This is
|
|
75
|
+
// mainly done to prevent UI elements like the formatting toolbar from being
|
|
76
|
+
// visible while content within a non-selectable block is selected.
|
|
77
|
+
if (event.type === "mousedown") {
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
editor.view.dom.blur();
|
|
80
|
+
}, 10);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
64
87
|
// Function that uses the 'parse' function of a blockConfig to create a
|
|
65
88
|
// TipTap node's `parseHTML` property. This is only used for parsing content
|
|
66
89
|
// from the clipboard.
|
|
@@ -125,7 +148,7 @@ export function createBlockSpec<
|
|
|
125
148
|
? "inline*"
|
|
126
149
|
: "") as T["content"] extends "inline" ? "inline*" : "",
|
|
127
150
|
group: "blockContent",
|
|
128
|
-
selectable: true,
|
|
151
|
+
selectable: blockConfig.isSelectable ?? true,
|
|
129
152
|
|
|
130
153
|
addAttributes() {
|
|
131
154
|
return propsToAttributes(blockConfig.propSchema);
|
|
@@ -163,13 +186,19 @@ export function createBlockSpec<
|
|
|
163
186
|
|
|
164
187
|
const output = blockImplementation.render(block as any, editor);
|
|
165
188
|
|
|
166
|
-
|
|
189
|
+
const nodeView: NodeView = wrapInBlockStructure(
|
|
167
190
|
output,
|
|
168
191
|
block.type,
|
|
169
192
|
block.props,
|
|
170
193
|
blockConfig.propSchema,
|
|
171
194
|
blockContentDOMAttributes
|
|
172
195
|
);
|
|
196
|
+
|
|
197
|
+
if (blockConfig.isSelectable === false) {
|
|
198
|
+
applyNonSelectableBlockFix(nodeView, this.editor);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return nodeView;
|
|
173
202
|
};
|
|
174
203
|
},
|
|
175
204
|
});
|
|
@@ -49,6 +49,7 @@ export type FileBlockConfig = {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
content: "none";
|
|
52
|
+
isSelectable?: boolean;
|
|
52
53
|
isFileBlock: true;
|
|
53
54
|
fileBlockAccept?: string[];
|
|
54
55
|
};
|
|
@@ -60,6 +61,7 @@ export type BlockConfig =
|
|
|
60
61
|
type: string;
|
|
61
62
|
readonly propSchema: PropSchema;
|
|
62
63
|
content: "inline" | "none" | "table";
|
|
64
|
+
isSelectable?: boolean;
|
|
63
65
|
isFileBlock?: false;
|
|
64
66
|
}
|
|
65
67
|
| FileBlockConfig;
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
inlineContentToNodes,
|
|
5
5
|
nodeToCustomInlineContent,
|
|
6
6
|
} from "../../api/nodeConversions/nodeConversions";
|
|
7
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
7
8
|
import { propsToAttributes } from "../blocks/internal";
|
|
8
9
|
import { Props } from "../propTypes";
|
|
9
10
|
import { StyleSchema } from "../styles/types";
|
|
@@ -34,13 +35,13 @@ export type CustomInlineContentImplementation<
|
|
|
34
35
|
inlineContent: InlineContentFromConfig<T, S>,
|
|
35
36
|
updateInlineContent: (
|
|
36
37
|
update: PartialCustomInlineContentFromConfig<T, S>
|
|
37
|
-
) => void
|
|
38
|
+
) => void,
|
|
38
39
|
/**
|
|
39
40
|
* The BlockNote editor instance
|
|
40
41
|
* This is typed generically. If you want an editor with your custom schema, you need to
|
|
41
42
|
* cast it manually, e.g.: `const e = editor as BlockNoteEditor<typeof mySchema>;`
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
editor: BlockNoteEditor<any, any, S>
|
|
44
45
|
// (note) if we want to fix the manual cast, we need to prevent circular references and separate block definition and render implementations
|
|
45
46
|
// or allow manually passing <BSchema>, but that's not possible without passing the other generics because Typescript doesn't support partial inferred generics
|
|
46
47
|
) => {
|
|
@@ -109,7 +110,8 @@ export function createInlineContentSpec<
|
|
|
109
110
|
) as any as InlineContentFromConfig<T, S>, // TODO: fix cast
|
|
110
111
|
() => {
|
|
111
112
|
// No-op
|
|
112
|
-
}
|
|
113
|
+
},
|
|
114
|
+
editor
|
|
113
115
|
);
|
|
114
116
|
|
|
115
117
|
return addInlineContentAttributes(
|
|
@@ -148,7 +150,8 @@ export function createInlineContentSpec<
|
|
|
148
150
|
content
|
|
149
151
|
)
|
|
150
152
|
);
|
|
151
|
-
}
|
|
153
|
+
},
|
|
154
|
+
editor
|
|
152
155
|
);
|
|
153
156
|
|
|
154
157
|
return addInlineContentAttributes(
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/core";
|
|
1
2
|
import { TagParseRule } from "@tiptap/pm/model";
|
|
3
|
+
import { NodeView } from "@tiptap/pm/view";
|
|
2
4
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
5
|
import { InlineContentSchema } from "../inlineContent/types";
|
|
4
6
|
import { StyleSchema } from "../styles/types";
|
|
@@ -28,6 +30,7 @@ export type CustomBlockImplementation<T extends CustomBlockConfig, I extends Inl
|
|
|
28
30
|
};
|
|
29
31
|
parse?: (el: HTMLElement) => PartialBlockFromConfig<T, I, S>["props"] | undefined;
|
|
30
32
|
};
|
|
33
|
+
export declare function applyNonSelectableBlockFix(nodeView: NodeView, editor: Editor): void;
|
|
31
34
|
export declare function getParseRules(config: BlockConfig, customParseFunction: CustomBlockImplementation<any, any, any>["parse"]): TagParseRule[];
|
|
32
35
|
export declare function createBlockSpec<T extends CustomBlockConfig, I extends InlineContentSchema, S extends StyleSchema>(blockConfig: T, blockImplementation: CustomBlockImplementation<T, I, S>): {
|
|
33
36
|
config: T;
|
|
@@ -28,6 +28,7 @@ export type FileBlockConfig = {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
content: "none";
|
|
31
|
+
isSelectable?: boolean;
|
|
31
32
|
isFileBlock: true;
|
|
32
33
|
fileBlockAccept?: string[];
|
|
33
34
|
};
|
|
@@ -35,6 +36,7 @@ export type BlockConfig = {
|
|
|
35
36
|
type: string;
|
|
36
37
|
readonly propSchema: PropSchema;
|
|
37
38
|
content: "inline" | "none" | "table";
|
|
39
|
+
isSelectable?: boolean;
|
|
38
40
|
isFileBlock?: false;
|
|
39
41
|
} | FileBlockConfig;
|
|
40
42
|
export type TiptapBlockImplementation<T extends BlockConfig, B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TagParseRule } from "@tiptap/pm/model";
|
|
2
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
2
3
|
import { StyleSchema } from "../styles/types";
|
|
3
4
|
import { CustomInlineContentConfig, InlineContentFromConfig, InlineContentSpec, PartialCustomInlineContentFromConfig } from "./types";
|
|
4
5
|
export type CustomInlineContentImplementation<T extends CustomInlineContentConfig, S extends StyleSchema> = {
|
|
@@ -6,13 +7,13 @@ export type CustomInlineContentImplementation<T extends CustomInlineContentConfi
|
|
|
6
7
|
/**
|
|
7
8
|
* The custom inline content to render
|
|
8
9
|
*/
|
|
9
|
-
inlineContent: InlineContentFromConfig<T, S>, updateInlineContent: (update: PartialCustomInlineContentFromConfig<T, S>) => void
|
|
10
|
+
inlineContent: InlineContentFromConfig<T, S>, updateInlineContent: (update: PartialCustomInlineContentFromConfig<T, S>) => void,
|
|
10
11
|
/**
|
|
11
12
|
* The BlockNote editor instance
|
|
12
13
|
* This is typed generically. If you want an editor with your custom schema, you need to
|
|
13
14
|
* cast it manually, e.g.: `const e = editor as BlockNoteEditor<typeof mySchema>;`
|
|
14
15
|
*/
|
|
15
|
-
) => {
|
|
16
|
+
editor: BlockNoteEditor<any, any, S>) => {
|
|
16
17
|
dom: HTMLElement;
|
|
17
18
|
contentDOM?: HTMLElement;
|
|
18
19
|
};
|