@blocknote/core 0.14.5 → 0.15.2
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 +1311 -1074
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +28 -25
- package/src/api/blockManipulation/blockManipulation.ts +21 -21
- package/src/api/exporters/copyExtension.ts +14 -10
- package/src/api/exporters/html/externalHTMLExporter.ts +26 -8
- package/src/api/exporters/html/htmlConversion.test.ts +27 -25
- package/src/api/exporters/html/internalHTMLSerializer.ts +22 -7
- package/src/api/exporters/html/util/sharedHTMLConversion.ts +3 -2
- package/src/api/exporters/markdown/markdownExporter.ts +5 -4
- package/src/api/nodeConversions/nodeConversions.test.ts +9 -6
- package/src/api/parsers/html/parseHTML.test.ts +3 -4
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +7 -7
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +1 -1
- package/src/blocks/defaultBlockHelpers.ts +3 -6
- package/src/blocks/defaultBlockTypeGuards.ts +26 -1
- package/src/editor/BlockNoteEditor.test.ts +48 -1
- package/src/editor/BlockNoteEditor.ts +153 -36
- package/src/editor/BlockNoteExtensions.ts +0 -1
- package/src/editor/BlockNoteTipTapEditor.ts +14 -5
- package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +10 -4
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +37 -0
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +2 -2
- package/src/extensions/SideMenu/SideMenuPlugin.ts +20 -14
- package/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.ts +4 -0
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +45 -0
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +13 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +5 -5
- package/src/extensions/TextAlignment/TextAlignmentExtension.ts +7 -3
- package/src/extensions/TextColor/TextColorExtension.ts +7 -3
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/en.ts +19 -13
- package/src/i18n/locales/fr.ts +6 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +15 -0
- package/src/i18n/locales/nl.ts +11 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +6 -0
- package/src/i18n/locales/ru.ts +322 -309
- package/src/i18n/locales/vi.ts +13 -0
- package/src/i18n/locales/zh.ts +14 -0
- package/src/index.ts +14 -5
- package/src/style.css +2 -7
- package/types/src/api/blockManipulation/blockManipulation.d.ts +1 -1
- package/types/src/api/exporters/copyExtension.d.ts +2 -2
- package/types/src/api/exporters/html/externalHTMLExporter.d.ts +7 -3
- package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +7 -3
- package/types/src/api/exporters/html/util/sharedHTMLConversion.d.ts +5 -3
- package/types/src/api/exporters/markdown/markdownExporter.d.ts +4 -2
- package/types/src/api/parsers/fileDropExtension.d.ts +2 -2
- package/types/src/api/parsers/pasteExtension.d.ts +2 -2
- package/types/src/blocks/defaultBlockHelpers.d.ts +2 -2
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +4 -1
- package/types/src/editor/BlockNoteEditor.d.ts +71 -11
- package/types/src/editor/BlockNoteExtensions.d.ts +2 -3
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +1 -0
- package/types/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.d.ts +4 -0
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +1 -2
- package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +4 -0
- package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +1 -1
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/index.d.ts +11 -5
- package/types/src/pm-nodes/BlockContainer.d.ts +2 -8
- package/types/src/pm-nodes/BlockGroup.d.ts +2 -7
- package/types/src/schema/inlineContent/internal.d.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -2,13 +2,14 @@ import * as locales from "./i18n/locales";
|
|
|
2
2
|
export * from "./api/exporters/html/externalHTMLExporter";
|
|
3
3
|
export * from "./api/exporters/html/internalHTMLSerializer";
|
|
4
4
|
export * from "./api/testUtil";
|
|
5
|
+
export * from "./blocks/AudioBlockContent/AudioBlockContent";
|
|
5
6
|
export * from "./blocks/FileBlockContent/FileBlockContent";
|
|
6
7
|
export * from "./blocks/ImageBlockContent/ImageBlockContent";
|
|
7
8
|
export * from "./blocks/VideoBlockContent/VideoBlockContent";
|
|
8
|
-
export * from "./blocks/AudioBlockContent/AudioBlockContent";
|
|
9
9
|
|
|
10
10
|
export * from "./blocks/FileBlockContent/fileBlockHelpers";
|
|
11
11
|
export * from "./blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
12
|
+
export { parseImageElement } from "./blocks/ImageBlockContent/imageBlockHelpers";
|
|
12
13
|
export * from "./blocks/defaultBlockTypeGuards";
|
|
13
14
|
export * from "./blocks/defaultBlocks";
|
|
14
15
|
export * from "./blocks/defaultProps";
|
|
@@ -22,17 +23,25 @@ export * from "./extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
|
22
23
|
export * from "./extensions/LinkToolbar/LinkToolbarPlugin";
|
|
23
24
|
export * from "./extensions/SideMenu/SideMenuPlugin";
|
|
24
25
|
export * from "./extensions/SuggestionMenu/DefaultSuggestionItem";
|
|
26
|
+
export * from "./extensions/SuggestionMenu/DefaultGridSuggestionItem";
|
|
25
27
|
export * from "./extensions/SuggestionMenu/SuggestionPlugin";
|
|
26
28
|
export * from "./extensions/SuggestionMenu/getDefaultSlashMenuItems";
|
|
29
|
+
export * from "./extensions/SuggestionMenu/getDefaultEmojiPickerItems";
|
|
27
30
|
export * from "./extensions/TableHandles/TableHandlesPlugin";
|
|
31
|
+
export * from "./i18n/dictionary";
|
|
28
32
|
export * from "./schema";
|
|
29
33
|
export * from "./util/browser";
|
|
30
34
|
export * from "./util/string";
|
|
35
|
+
export * from "./util/typescript";
|
|
36
|
+
export { UnreachableCaseError, assertEmpty } from "./util/typescript";
|
|
37
|
+
export { locales };
|
|
38
|
+
|
|
31
39
|
// for testing from react (TODO: move):
|
|
32
40
|
export * from "./api/nodeConversions/nodeConversions";
|
|
33
41
|
export * from "./api/testUtil/partialBlockTestUtil";
|
|
34
42
|
export * from "./extensions/UniqueID/UniqueID";
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export
|
|
38
|
-
export
|
|
43
|
+
|
|
44
|
+
// for server-util (TODO: maybe move):
|
|
45
|
+
export * from "./api/exporters/markdown/markdownExporter";
|
|
46
|
+
export * from "./api/parsers/html/parseHTML";
|
|
47
|
+
export * from "./api/parsers/markdown/parseMarkdown";
|
package/src/style.css
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
It's here so DEV environment doesn't show a 404
|
|
4
|
-
|
|
5
|
-
- In DEV environment, examples/editor loads this stub file, but actual CSS is loaded from CSS modules directly
|
|
6
|
-
- In PROD environment, the actual dist/style.css file is built from the CSS modules
|
|
7
|
-
*/
|
|
1
|
+
@import url("./editor/Block.css");
|
|
2
|
+
@import url("./editor/editor.css");
|
|
@@ -2,7 +2,7 @@ import { Node } from "prosemirror-model";
|
|
|
2
2
|
import { Block, PartialBlock } from "../../blocks/defaultBlocks";
|
|
3
3
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
4
4
|
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
5
|
-
export declare function insertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToInsert: PartialBlock<BSchema, I, S>[], referenceBlock: BlockIdentifier, placement: "before" | "after" | "nested" | undefined, editor: BlockNoteEditor<BSchema, I, S>): Block<BSchema, I, S>[];
|
|
5
|
+
export declare function insertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToInsert: PartialBlock<BSchema, I, S>[], referenceBlock: BlockIdentifier, placement: ("before" | "after" | "nested") | undefined, editor: BlockNoteEditor<BSchema, I, S>): Block<BSchema, I, S>[];
|
|
6
6
|
export declare function updateBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, I, S>, editor: BlockNoteEditor<BSchema, I, S>): Block<BSchema, I, S>;
|
|
7
7
|
export declare function removeBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToRemove: BlockIdentifier[], editor: BlockNoteEditor<BSchema, I, S>): Block<BSchema, I, S>[];
|
|
8
8
|
export declare function replaceBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[], editor: BlockNoteEditor<BSchema, I, S>): {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
2
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
-
import { InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
-
export declare const createCopyToClipboardExtension: <BSchema extends
|
|
3
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
+
export declare const createCopyToClipboardExtension: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>) => Extension<{
|
|
5
5
|
editor: BlockNoteEditor<BSchema, I, S>;
|
|
6
6
|
}, undefined>;
|
|
@@ -3,7 +3,11 @@ import { PartialBlock } from "../../../blocks/defaultBlocks";
|
|
|
3
3
|
import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
4
4
|
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema";
|
|
5
5
|
export interface ExternalHTMLExporter<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> {
|
|
6
|
-
exportBlocks: (blocks: PartialBlock<BSchema, I, S>[]
|
|
7
|
-
|
|
6
|
+
exportBlocks: (blocks: PartialBlock<BSchema, I, S>[], options: {
|
|
7
|
+
document?: Document;
|
|
8
|
+
}) => string;
|
|
9
|
+
exportProseMirrorFragment: (fragment: Fragment, options: {
|
|
10
|
+
document?: Document;
|
|
11
|
+
}) => string;
|
|
8
12
|
}
|
|
9
|
-
export declare const createExternalHTMLExporter: <BSchema extends
|
|
13
|
+
export declare const createExternalHTMLExporter: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(schema: Schema, editor: BlockNoteEditor<BSchema, I, S>) => ExternalHTMLExporter<BSchema, I, S>;
|
|
@@ -3,7 +3,11 @@ import { PartialBlock } from "../../../blocks/defaultBlocks";
|
|
|
3
3
|
import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
4
4
|
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema";
|
|
5
5
|
export interface InternalHTMLSerializer<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> {
|
|
6
|
-
serializeProseMirrorFragment: (fragment: Fragment
|
|
7
|
-
|
|
6
|
+
serializeProseMirrorFragment: (fragment: Fragment, options: {
|
|
7
|
+
document?: Document;
|
|
8
|
+
}) => string;
|
|
9
|
+
serializeBlocks: (blocks: PartialBlock<BSchema, I, S>[], options: {
|
|
10
|
+
document?: Document;
|
|
11
|
+
}) => string;
|
|
8
12
|
}
|
|
9
|
-
export declare const createInternalHTMLSerializer: <BSchema extends
|
|
13
|
+
export declare const createInternalHTMLSerializer: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(schema: Schema, editor: BlockNoteEditor<BSchema, I, S>) => InternalHTMLSerializer<BSchema, I, S>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DOMSerializer, Fragment, Node } from "prosemirror-model";
|
|
2
2
|
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
|
|
3
|
-
import { InlineContentSchema, StyleSchema } from "../../../../schema";
|
|
4
|
-
export declare const serializeNodeInner: <BSchema extends
|
|
3
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema";
|
|
4
|
+
export declare const serializeNodeInner: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(node: Node, options: {
|
|
5
5
|
document?: Document;
|
|
6
6
|
}, serializer: DOMSerializer, editor: BlockNoteEditor<BSchema, I, S>, toExternalHTML: boolean) => HTMLElement;
|
|
7
|
-
export declare const serializeProseMirrorFragment: (fragment: Fragment, serializer: DOMSerializer
|
|
7
|
+
export declare const serializeProseMirrorFragment: (fragment: Fragment, serializer: DOMSerializer, options?: {
|
|
8
|
+
document?: Document;
|
|
9
|
+
}) => string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Schema } from "prosemirror-model";
|
|
2
|
-
import {
|
|
2
|
+
import { PartialBlock } from "../../../blocks/defaultBlocks";
|
|
3
3
|
import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
4
4
|
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema";
|
|
5
5
|
export declare function cleanHTMLToMarkdown(cleanHTMLString: string): string;
|
|
6
|
-
export declare function blocksToMarkdown<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocks:
|
|
6
|
+
export declare function blocksToMarkdown<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocks: PartialBlock<BSchema, I, S>[], schema: Schema, editor: BlockNoteEditor<BSchema, I, S>, options: {
|
|
7
|
+
document?: Document;
|
|
8
|
+
}): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
2
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
-
import { InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
-
export declare const createDropFileExtension: <BSchema extends
|
|
3
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
+
export declare const createDropFileExtension: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>) => Extension<{
|
|
5
5
|
editor: BlockNoteEditor<BSchema, I, S>;
|
|
6
6
|
}, undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
2
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
-
import { InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
-
export declare const createPasteFromClipboardExtension: <BSchema extends
|
|
3
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
+
export declare const createPasteFromClipboardExtension: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>) => Extension<{
|
|
5
5
|
editor: BlockNoteEditor<BSchema, I, S>;
|
|
6
6
|
}, undefined>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { BlockNoteEditor } from "../editor/BlockNoteEditor";
|
|
2
|
-
import type { BlockNoDefaults, InlineContentSchema, StyleSchema } from "../schema";
|
|
2
|
+
import type { BlockNoDefaults, BlockSchema, InlineContentSchema, StyleSchema } from "../schema";
|
|
3
3
|
export declare function createDefaultBlockDOMOutputSpec(blockName: string, htmlTag: string, blockContentHTMLAttributes: Record<string, string>, inlineContentHTMLAttributes: Record<string, string>): {
|
|
4
4
|
dom: HTMLDivElement;
|
|
5
5
|
contentDOM: HTMLElement;
|
|
6
6
|
};
|
|
7
|
-
export declare const defaultBlockToHTML: <BSchema extends
|
|
7
|
+
export declare const defaultBlockToHTML: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(block: BlockNoDefaults<BSchema, I, S>, editor: BlockNoteEditor<BSchema, I, S>) => {
|
|
8
8
|
dom: HTMLElement;
|
|
9
9
|
contentDOM?: HTMLElement;
|
|
10
10
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { BlockNoteEditor } from "../editor/BlockNoteEditor";
|
|
2
2
|
import { BlockFromConfig, BlockSchema, FileBlockConfig, InlineContentSchema, StyleSchema } from "../schema";
|
|
3
|
-
import { Block, DefaultBlockSchema } from "./defaultBlocks";
|
|
3
|
+
import { Block, DefaultBlockSchema, DefaultInlineContentSchema } 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
|
+
export declare function checkDefaultInlineContentTypeInSchema<InlineContentType extends keyof DefaultInlineContentSchema, B extends BlockSchema, S extends StyleSchema>(inlineContentType: InlineContentType, editor: BlockNoteEditor<B, any, S>): editor is BlockNoteEditor<B, {
|
|
9
|
+
Type: DefaultInlineContentSchema[InlineContentType];
|
|
10
|
+
}, S>;
|
|
8
11
|
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
12
|
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
13
|
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 & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorOptions } from "@tiptap/core";
|
|
2
|
-
import { Node } from "prosemirror-model";
|
|
2
|
+
import { Node, Schema } from "prosemirror-model";
|
|
3
3
|
import * as Y from "yjs";
|
|
4
4
|
import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/defaultBlocks";
|
|
5
5
|
import { FilePanelProsemirrorPlugin } from "../extensions/FilePanel/FilePanelPlugin";
|
|
@@ -15,8 +15,8 @@ import { Selection } from "./selectionTypes";
|
|
|
15
15
|
import { BlockNoteSchema } from "./BlockNoteSchema";
|
|
16
16
|
import { BlockNoteTipTapEditor } from "./BlockNoteTipTapEditor";
|
|
17
17
|
import { Dictionary } from "../i18n/dictionary";
|
|
18
|
-
import "
|
|
19
|
-
import "
|
|
18
|
+
import { Transaction } from "@tiptap/pm/state";
|
|
19
|
+
import "../style.css";
|
|
20
20
|
export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> = {
|
|
21
21
|
disableExtensions: string[];
|
|
22
22
|
/**
|
|
@@ -45,7 +45,11 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
45
45
|
defaultStyles: boolean;
|
|
46
46
|
schema: BlockNoteSchema<BSchema, ISchema, SSchema>;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
|
|
49
|
+
* This method should set when creating the editor as this is application-specific.
|
|
50
|
+
*
|
|
51
|
+
* `undefined` means the application doesn't support file uploads.
|
|
52
|
+
*
|
|
49
53
|
* @param file The file that should be uploaded.
|
|
50
54
|
* @returns The URL of the uploaded file OR an object containing props that should be set on the file block (such as an id)
|
|
51
55
|
*/
|
|
@@ -82,14 +86,47 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
82
86
|
};
|
|
83
87
|
_tiptapOptions: Partial<EditorOptions>;
|
|
84
88
|
trailingBlock?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Boolean indicating whether the editor is in headless mode.
|
|
91
|
+
* Headless mode means we can use features like importing / exporting blocks,
|
|
92
|
+
* but there's no underlying editor (UI) instantiated.
|
|
93
|
+
*
|
|
94
|
+
* You probably don't need to set this manually, but use the `server-util` package instead that uses this option internally
|
|
95
|
+
*/
|
|
96
|
+
_headless: boolean;
|
|
85
97
|
};
|
|
86
98
|
export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
|
|
87
99
|
private readonly options;
|
|
100
|
+
private readonly _pmSchema;
|
|
101
|
+
/**
|
|
102
|
+
* Boolean indicating whether the editor is in headless mode.
|
|
103
|
+
* Headless mode means we can use features like importing / exporting blocks,
|
|
104
|
+
* but there's no underlying editor (UI) instantiated.
|
|
105
|
+
*
|
|
106
|
+
* You probably don't need to set this manually, but use the `server-util` package instead that uses this option internally
|
|
107
|
+
*/
|
|
108
|
+
readonly headless: boolean;
|
|
88
109
|
readonly _tiptapEditor: BlockNoteTipTapEditor & {
|
|
89
110
|
contentComponent: any;
|
|
90
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* Used by React to store a reference to an `ElementRenderer` helper utility to make sure we can render React elements
|
|
114
|
+
* in the correct context (used by `ReactRenderUtil`)
|
|
115
|
+
*/
|
|
116
|
+
elementRenderer: ((node: any, container: HTMLElement) => void) | null;
|
|
117
|
+
/**
|
|
118
|
+
* Cache of all blocks. This makes sure we don't have to "recompute" blocks if underlying Prosemirror Nodes haven't changed.
|
|
119
|
+
* This is especially useful when we want to keep track of the same block across multiple operations,
|
|
120
|
+
* with this cache, blocks stay the same object reference (referential equality with ===).
|
|
121
|
+
*/
|
|
91
122
|
blockCache: WeakMap<Node, Block<any, any, any>>;
|
|
123
|
+
/**
|
|
124
|
+
* The dictionary contains translations for the editor.
|
|
125
|
+
*/
|
|
92
126
|
readonly dictionary: Dictionary;
|
|
127
|
+
/**
|
|
128
|
+
* The schema of the editor. The schema defines which Blocks, InlineContent, and Styles are available in the editor.
|
|
129
|
+
*/
|
|
93
130
|
readonly schema: BlockNoteSchema<BSchema, ISchema, SSchema>;
|
|
94
131
|
readonly blockImplementations: BlockSpecs;
|
|
95
132
|
readonly inlineContentImplementations: InlineContentSpecs;
|
|
@@ -100,16 +137,27 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
100
137
|
readonly suggestionMenus: SuggestionMenuProseMirrorPlugin<BSchema, ISchema, SSchema>;
|
|
101
138
|
readonly filePanel?: FilePanelProsemirrorPlugin<ISchema, SSchema>;
|
|
102
139
|
readonly tableHandles?: TableHandlesProsemirrorPlugin<ISchema, SSchema>;
|
|
140
|
+
/**
|
|
141
|
+
* The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
|
|
142
|
+
* This method should set when creating the editor as this is application-specific.
|
|
143
|
+
*
|
|
144
|
+
* `undefined` means the application doesn't support file uploads.
|
|
145
|
+
*
|
|
146
|
+
* @param file The file that should be uploaded.
|
|
147
|
+
* @returns The URL of the uploaded file OR an object containing props that should be set on the file block (such as an id)
|
|
148
|
+
*/
|
|
103
149
|
readonly uploadFile: ((file: File) => Promise<string | Record<string, any>>) | undefined;
|
|
104
150
|
readonly resolveFileUrl: (url: string) => Promise<string>;
|
|
151
|
+
get pmSchema(): Schema<any, any>;
|
|
105
152
|
static create<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(options?: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>): BlockNoteEditor<BSchema, ISchema, SSchema>;
|
|
106
153
|
private constructor();
|
|
154
|
+
dispatch(tr: Transaction): void;
|
|
107
155
|
/**
|
|
108
156
|
* Mount the editor to a parent DOM element. Call mount(undefined) to clean up
|
|
109
157
|
*
|
|
110
|
-
* @warning Not needed
|
|
158
|
+
* @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
|
|
111
159
|
*/
|
|
112
|
-
mount(parentElement?: HTMLElement | null)
|
|
160
|
+
mount: (parentElement?: HTMLElement | null) => void;
|
|
113
161
|
get prosemirrorView(): import("prosemirror-view").EditorView;
|
|
114
162
|
get domElement(): HTMLDivElement;
|
|
115
163
|
isFocused(): boolean;
|
|
@@ -260,12 +308,23 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
260
308
|
*/
|
|
261
309
|
unnestBlock(): void;
|
|
262
310
|
/**
|
|
263
|
-
*
|
|
311
|
+
* Exports blocks into a simplified HTML string. To better conform to HTML standards, children of blocks which aren't list
|
|
264
312
|
* items are un-nested in the output HTML.
|
|
313
|
+
*
|
|
314
|
+
* @param blocks An array of blocks that should be serialized into HTML.
|
|
315
|
+
* @returns The blocks, serialized as an HTML string.
|
|
316
|
+
*/
|
|
317
|
+
blocksToHTMLLossy(blocks?: PartialBlock<BSchema, ISchema, SSchema>[]): Promise<string>;
|
|
318
|
+
/**
|
|
319
|
+
* Serializes blocks into an HTML string in the format that would normally be rendered by the editor.
|
|
320
|
+
*
|
|
321
|
+
* Use this method if you want to server-side render HTML (for example, a blog post that has been edited in BlockNote)
|
|
322
|
+
* and serve it to users without loading the editor on the client (i.e.: displaying the blog post)
|
|
323
|
+
*
|
|
265
324
|
* @param blocks An array of blocks that should be serialized into HTML.
|
|
266
325
|
* @returns The blocks, serialized as an HTML string.
|
|
267
326
|
*/
|
|
268
|
-
|
|
327
|
+
blocksToFullHTML(blocks: PartialBlock<BSchema, ISchema, SSchema>[]): Promise<string>;
|
|
269
328
|
/**
|
|
270
329
|
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
271
330
|
* `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
|
|
@@ -280,7 +339,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
280
339
|
* @param blocks An array of blocks that should be serialized into Markdown.
|
|
281
340
|
* @returns The blocks, serialized as a Markdown string.
|
|
282
341
|
*/
|
|
283
|
-
blocksToMarkdownLossy(blocks?:
|
|
342
|
+
blocksToMarkdownLossy(blocks?: PartialBlock<BSchema, ISchema, SSchema>[]): Promise<string>;
|
|
284
343
|
/**
|
|
285
344
|
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
286
345
|
* Markdown syntax, though not all symbols are recognized. If BlockNote doesn't recognize a symbol, it will parse it
|
|
@@ -302,12 +361,13 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
302
361
|
* @param callback The callback to execute.
|
|
303
362
|
* @returns A function to remove the callback.
|
|
304
363
|
*/
|
|
305
|
-
onChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void): () => void;
|
|
364
|
+
onChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void): (() => void) | undefined;
|
|
306
365
|
/**
|
|
307
366
|
* A callback function that runs whenever the text cursor position or selection changes.
|
|
308
367
|
*
|
|
309
368
|
* @param callback The callback to execute.
|
|
310
369
|
* @returns A function to remove the callback.
|
|
311
370
|
*/
|
|
312
|
-
onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void): () => void;
|
|
371
|
+
onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void): (() => void) | undefined;
|
|
372
|
+
openSelectionMenu(triggerCharacter: string): void;
|
|
313
373
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { BlockNoteEditor } from "./BlockNoteEditor";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
|
-
import { BlockNoteDOMAttributes, BlockSpecs, InlineContentSchema, InlineContentSpecs, StyleSchema, StyleSpecs } from "../schema";
|
|
3
|
+
import { BlockNoteDOMAttributes, BlockSchema, BlockSpecs, InlineContentSchema, InlineContentSpecs, StyleSchema, StyleSpecs } from "../schema";
|
|
4
4
|
/**
|
|
5
5
|
* Get all the Tiptap extensions BlockNote is configured with by default
|
|
6
6
|
*/
|
|
7
|
-
export declare const getBlockNoteExtensions: <BSchema extends
|
|
7
|
+
export declare const getBlockNoteExtensions: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(opts: {
|
|
8
8
|
editor: BlockNoteEditor<BSchema, I, S>;
|
|
9
9
|
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
10
|
-
blockSchema: BSchema;
|
|
11
10
|
blockSpecs: BlockSpecs;
|
|
12
11
|
inlineContentSpecs: InlineContentSpecs;
|
|
13
12
|
styleSpecs: StyleSpecs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EditorOptions } from "@tiptap/core";
|
|
2
2
|
import { Editor as TiptapEditor } from "@tiptap/core";
|
|
3
|
-
import { EditorState } from "
|
|
3
|
+
import { EditorState, Transaction } from "@tiptap/pm/state";
|
|
4
4
|
import { PartialBlock } from "../blocks/defaultBlocks";
|
|
5
5
|
import { StyleSchema } from "../schema";
|
|
6
6
|
export type BlockNoteTipTapEditorOptions = Partial<Omit<EditorOptions, "content">> & {
|
|
@@ -14,7 +14,7 @@ export declare class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
14
14
|
private _state;
|
|
15
15
|
constructor(options: BlockNoteTipTapEditorOptions, styleSchema: StyleSchema);
|
|
16
16
|
get state(): EditorState;
|
|
17
|
-
|
|
17
|
+
dispatch(tr: Transaction): void;
|
|
18
18
|
/**
|
|
19
19
|
* Replace the default `createView` method with a custom one - which we call on mount
|
|
20
20
|
*/
|
|
@@ -19,6 +19,7 @@ export declare class FormattingToolbarView implements PluginView {
|
|
|
19
19
|
to: number;
|
|
20
20
|
}) => boolean;
|
|
21
21
|
constructor(editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>, pmView: EditorView, emitUpdate: (state: FormattingToolbarState) => void);
|
|
22
|
+
blurHandler: (event: FocusEvent) => void;
|
|
22
23
|
viewMousedownHandler: () => void;
|
|
23
24
|
viewMouseupHandler: () => void;
|
|
24
25
|
dragHandler: () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin
|
|
1
|
+
import { Plugin } from "prosemirror-state";
|
|
2
2
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
3
|
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
4
4
|
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
@@ -6,7 +6,6 @@ import { EventEmitter } from "../../util/EventEmitter";
|
|
|
6
6
|
export type SuggestionMenuState = UiElementPosition & {
|
|
7
7
|
query: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const suggestionMenuPluginKey: PluginKey<any>;
|
|
10
9
|
/**
|
|
11
10
|
* A ProseMirror plugin for suggestions, designed to make '/'-commands possible as well as mentions.
|
|
12
11
|
*
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
2
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
3
|
+
import { DefaultGridSuggestionItem } from "./DefaultGridSuggestionItem";
|
|
4
|
+
export declare function getDefaultEmojiPickerItems<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, query: string): Promise<DefaultGridSuggestionItem[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
2
1
|
import { Block, PartialBlock } from "../../blocks/defaultBlocks";
|
|
2
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
3
|
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
4
|
import { DefaultSuggestionItem } from "./DefaultSuggestionItem";
|
|
5
5
|
export declare function insertOrUpdateBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, block: PartialBlock<BSchema, I, S>): Block<BSchema, I, S>;
|
package/types/src/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import * as locales from "./i18n/locales";
|
|
|
2
2
|
export * from "./api/exporters/html/externalHTMLExporter";
|
|
3
3
|
export * from "./api/exporters/html/internalHTMLSerializer";
|
|
4
4
|
export * from "./api/testUtil";
|
|
5
|
+
export * from "./blocks/AudioBlockContent/AudioBlockContent";
|
|
5
6
|
export * from "./blocks/FileBlockContent/FileBlockContent";
|
|
6
7
|
export * from "./blocks/ImageBlockContent/ImageBlockContent";
|
|
7
8
|
export * from "./blocks/VideoBlockContent/VideoBlockContent";
|
|
8
|
-
export * from "./blocks/AudioBlockContent/AudioBlockContent";
|
|
9
9
|
export * from "./blocks/FileBlockContent/fileBlockHelpers";
|
|
10
10
|
export * from "./blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
11
|
+
export { parseImageElement } from "./blocks/ImageBlockContent/imageBlockHelpers";
|
|
11
12
|
export * from "./blocks/defaultBlockTypeGuards";
|
|
12
13
|
export * from "./blocks/defaultBlocks";
|
|
13
14
|
export * from "./blocks/defaultProps";
|
|
@@ -21,16 +22,21 @@ export * from "./extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
|
21
22
|
export * from "./extensions/LinkToolbar/LinkToolbarPlugin";
|
|
22
23
|
export * from "./extensions/SideMenu/SideMenuPlugin";
|
|
23
24
|
export * from "./extensions/SuggestionMenu/DefaultSuggestionItem";
|
|
25
|
+
export * from "./extensions/SuggestionMenu/DefaultGridSuggestionItem";
|
|
24
26
|
export * from "./extensions/SuggestionMenu/SuggestionPlugin";
|
|
25
27
|
export * from "./extensions/SuggestionMenu/getDefaultSlashMenuItems";
|
|
28
|
+
export * from "./extensions/SuggestionMenu/getDefaultEmojiPickerItems";
|
|
26
29
|
export * from "./extensions/TableHandles/TableHandlesPlugin";
|
|
30
|
+
export * from "./i18n/dictionary";
|
|
27
31
|
export * from "./schema";
|
|
28
32
|
export * from "./util/browser";
|
|
29
33
|
export * from "./util/string";
|
|
34
|
+
export * from "./util/typescript";
|
|
35
|
+
export { UnreachableCaseError, assertEmpty } from "./util/typescript";
|
|
36
|
+
export { locales };
|
|
30
37
|
export * from "./api/nodeConversions/nodeConversions";
|
|
31
38
|
export * from "./api/testUtil/partialBlockTestUtil";
|
|
32
39
|
export * from "./extensions/UniqueID/UniqueID";
|
|
33
|
-
export * from "./
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export { parseImageElement } from "./blocks/ImageBlockContent/imageBlockHelpers";
|
|
40
|
+
export * from "./api/exporters/markdown/markdownExporter";
|
|
41
|
+
export * from "./api/parsers/html/parseHTML";
|
|
42
|
+
export * from "./api/parsers/markdown/parseMarkdown";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
2
|
import { PartialBlock } from "../blocks/defaultBlocks";
|
|
3
3
|
import type { BlockNoteEditor } from "../editor/BlockNoteEditor";
|
|
4
|
-
import { BlockSchema, InlineContentSchema, StyleSchema } from "../schema";
|
|
4
|
+
import { BlockNoteDOMAttributes, BlockSchema, InlineContentSchema, StyleSchema } from "../schema";
|
|
5
5
|
declare module "@tiptap/core" {
|
|
6
6
|
interface Commands<ReturnType> {
|
|
7
7
|
block: {
|
|
@@ -18,12 +18,6 @@ declare module "@tiptap/core" {
|
|
|
18
18
|
* The main "Block node" documents consist of
|
|
19
19
|
*/
|
|
20
20
|
export declare const BlockContainer: Node<{
|
|
21
|
-
domAttributes?:
|
|
22
|
-
blockGroup: Record<string, string>;
|
|
23
|
-
block: Record<string, string>;
|
|
24
|
-
editor: Record<string, string>;
|
|
25
|
-
blockContent: Record<string, string>;
|
|
26
|
-
inlineContent: Record<string, string>;
|
|
27
|
-
}> | undefined;
|
|
21
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
28
22
|
editor: BlockNoteEditor<any, any, any>;
|
|
29
23
|
}, any>;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
|
+
import { BlockNoteDOMAttributes } from "../schema";
|
|
2
3
|
export declare const BlockGroup: Node<{
|
|
3
|
-
domAttributes?:
|
|
4
|
-
blockGroup: Record<string, string>;
|
|
5
|
-
block: Record<string, string>;
|
|
6
|
-
editor: Record<string, string>;
|
|
7
|
-
blockContent: Record<string, string>;
|
|
8
|
-
inlineContent: Record<string, string>;
|
|
9
|
-
}> | undefined;
|
|
4
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
10
5
|
}, any>;
|
|
@@ -22,7 +22,7 @@ export declare function createInlineContentSpecFromTipTapNode<T extends Node, P
|
|
|
22
22
|
content: "styled" | "none";
|
|
23
23
|
};
|
|
24
24
|
implementation: {
|
|
25
|
-
node: Node
|
|
25
|
+
node: Node;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
export declare function getInlineContentSchemaFromSpecs<T extends InlineContentSpecs>(specs: T): InlineContentSchemaFromSpecs<T>;
|