@blocknote/core 0.2.3 → 0.2.4-alpha.7
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 +753 -633
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +1 -1
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +19 -28
- package/src/BlockNoteExtensions.ts +10 -0
- package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +61 -0
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +62 -0
- package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +107 -97
- package/src/extensions/Blocks/nodes/Block.module.css +91 -6
- package/src/extensions/Blocks/nodes/BlockContainer.ts +39 -26
- package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts +4 -4
- package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +8 -0
- package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +80 -35
- package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +16 -0
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +34 -3
- package/src/extensions/Placeholder/PlaceholderExtension.ts +1 -1
- package/src/extensions/SlashMenu/SlashMenuExtension.ts +1 -1
- package/src/extensions/SlashMenu/SlashMenuItem.ts +3 -28
- package/src/extensions/SlashMenu/defaultCommands.tsx +14 -32
- package/src/extensions/SlashMenu/index.ts +1 -6
- package/src/extensions/TextAlignment/TextAlignmentExtension.ts +75 -0
- package/src/extensions/TextColor/TextColorExtension.ts +54 -0
- package/src/extensions/TextColor/TextColorMark.ts +62 -0
- package/src/shared/plugins/suggestion/SuggestionItem.ts +0 -9
- package/src/shared/plugins/suggestion/SuggestionPlugin.ts +191 -228
- package/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts +1 -1
- package/types/src/api/Document.d.ts +5 -0
- package/types/src/extensions/BackgroundColor/BackgroundColorExtension.d.ts +9 -0
- package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +9 -0
- package/types/src/extensions/Blocks/PreviousBlockTypePlugin.d.ts +3 -2
- package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +4 -0
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +4 -9
- package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +10 -0
- package/types/src/extensions/SlashMenu/SlashMenuItem.d.ts +2 -19
- package/types/src/extensions/SlashMenu/defaultSlashCommands.d.ts +5 -0
- package/types/src/extensions/SlashMenu/index.d.ts +1 -2
- package/types/src/extensions/TextAlignment/TextAlignmentExtension.d.ts +9 -0
- package/types/src/extensions/TextColor/TextColorExtension.d.ts +9 -0
- package/types/src/extensions/TextColor/TextColorMark.d.ts +9 -0
- package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +0 -6
- package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +9 -23
- package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +1 -1
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Editor, Range } from "@tiptap/core";
|
|
2
2
|
import { SuggestionItem } from "../../shared/plugins/suggestion/SuggestionItem";
|
|
3
|
-
export type SlashMenuCallback = (editor: Editor, range: Range) => boolean;
|
|
4
|
-
export declare enum SlashMenuGroups {
|
|
5
|
-
HEADINGS = "Headings",
|
|
6
|
-
BASIC_BLOCKS = "Basic Blocks",
|
|
7
|
-
CODE = "Code Blocks",
|
|
8
|
-
INLINE = "Inline",
|
|
9
|
-
EMBED = "Embed",
|
|
10
|
-
PLUGIN = "Plugin"
|
|
11
|
-
}
|
|
12
3
|
/**
|
|
13
4
|
* A class that defines a slash command (/<command>).
|
|
14
5
|
*
|
|
@@ -16,23 +7,15 @@ export declare enum SlashMenuGroups {
|
|
|
16
7
|
*/
|
|
17
8
|
export declare class SlashMenuItem implements SuggestionItem {
|
|
18
9
|
readonly name: string;
|
|
19
|
-
readonly
|
|
20
|
-
readonly execute: SlashMenuCallback;
|
|
10
|
+
readonly execute: (editor: Editor, range: Range) => void;
|
|
21
11
|
readonly aliases: string[];
|
|
22
|
-
readonly hint?: string | undefined;
|
|
23
|
-
readonly shortcut?: string | undefined;
|
|
24
|
-
groupName: string;
|
|
25
12
|
/**
|
|
26
13
|
* Constructs a new slash-command.
|
|
27
14
|
*
|
|
28
15
|
* @param name The name of the command
|
|
29
|
-
* @param group Used to organize the menu
|
|
30
16
|
* @param execute The callback for creating a new node
|
|
31
17
|
* @param aliases Aliases for this command
|
|
32
|
-
* @param icon To be shown next to the name in the menu
|
|
33
|
-
* @param hint Short description of command
|
|
34
|
-
* @param shortcut Info about keyboard shortcut that would activate this command
|
|
35
18
|
*/
|
|
36
|
-
constructor(name: string,
|
|
19
|
+
constructor(name: string, execute: (editor: Editor, range: Range) => void, aliases?: string[]);
|
|
37
20
|
match(query: string): boolean;
|
|
38
21
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SlashMenuExtension } from "./SlashMenuExtension";
|
|
2
2
|
import defaultCommands from "./defaultCommands";
|
|
3
|
-
|
|
4
|
-
export { defaultCommands, SlashMenuItem as SlashCommand, SlashMenuGroups as CommandGroup, };
|
|
3
|
+
export { defaultCommands };
|
|
5
4
|
export default SlashMenuExtension;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
declare module "@tiptap/core" {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
textAlignment: {
|
|
5
|
+
setTextAlignment: (textAlignment: "left" | "center" | "right" | "justify") => ReturnType;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const TextAlignmentExtension: Extension<any, any>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
declare module "@tiptap/core" {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
blockTextColor: {
|
|
5
|
+
setBlockTextColor: (posInBlock: number, color: string) => ReturnType;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const TextColorExtension: Extension<any, any>;
|
|
@@ -6,12 +6,6 @@ export interface SuggestionItem {
|
|
|
6
6
|
* The name of the item
|
|
7
7
|
*/
|
|
8
8
|
name: string;
|
|
9
|
-
/**
|
|
10
|
-
* The name of the group to which this item belongs
|
|
11
|
-
*/
|
|
12
|
-
groupName: string;
|
|
13
|
-
hint?: string;
|
|
14
|
-
shortcut?: string;
|
|
15
9
|
/**
|
|
16
10
|
* This function matches this item against a query string, the function should return **true** if the item
|
|
17
11
|
* matches the query or **false** otherwise.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Editor, Range } from "@tiptap/core";
|
|
2
|
-
import { Plugin, PluginKey
|
|
2
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
3
|
import { SuggestionsMenuFactory } from "./SuggestionsMenuFactoryTypes";
|
|
4
4
|
import { SuggestionItem } from "./SuggestionItem";
|
|
5
5
|
export type SuggestionPluginOptions<T extends SuggestionItem> = {
|
|
@@ -14,9 +14,9 @@ export type SuggestionPluginOptions<T extends SuggestionItem> = {
|
|
|
14
14
|
*/
|
|
15
15
|
editor: Editor;
|
|
16
16
|
/**
|
|
17
|
-
* The character that should trigger the suggestion menu to pop up (e.g. a '/' for commands)
|
|
17
|
+
* The character that should trigger the suggestion menu to pop up (e.g. a '/' for commands), when typed by the user.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
defaultTriggerCharacter: string;
|
|
20
20
|
suggestionsMenuFactory: SuggestionsMenuFactory<T>;
|
|
21
21
|
/**
|
|
22
22
|
* The callback that gets executed when an item is selected by the user.
|
|
@@ -41,27 +41,13 @@ export type SuggestionPluginOptions<T extends SuggestionItem> = {
|
|
|
41
41
|
};
|
|
42
42
|
type SuggestionPluginState<T extends SuggestionItem> = {
|
|
43
43
|
active: boolean;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
notFoundCount: number;
|
|
44
|
+
triggerCharacter: string | undefined;
|
|
45
|
+
queryStartPos: number | undefined;
|
|
47
46
|
items: T[];
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
decorationId: string |
|
|
47
|
+
keyboardHoveredItemIndex: number | undefined;
|
|
48
|
+
notFoundCount: number | undefined;
|
|
49
|
+
decorationId: string | undefined;
|
|
51
50
|
};
|
|
52
|
-
export type MenuType = "slash" | "drag";
|
|
53
|
-
/**
|
|
54
|
-
* Finds a command: a specified character (e.g. '/') followed by a string of characters (all characters except the specified character are allowed).
|
|
55
|
-
* Returns the string following the specified character or undefined if no command was found.
|
|
56
|
-
*
|
|
57
|
-
* @param char the character that indicates the start of a command
|
|
58
|
-
* @param selection the selection (only works if the selection is empty; i.e. is a blinking cursor).
|
|
59
|
-
* @returns an object containing the matching word (excluding the specified character) and the range of the match (including the specified character) or undefined if there is no match.
|
|
60
|
-
*/
|
|
61
|
-
export declare function findCommandBeforeCursor(char: string, selection: Selection): {
|
|
62
|
-
range: Range;
|
|
63
|
-
query: string;
|
|
64
|
-
} | undefined;
|
|
65
51
|
/**
|
|
66
52
|
* A ProseMirror plugin for suggestions, designed to make '/'-commands possible as well as mentions.
|
|
67
53
|
*
|
|
@@ -75,5 +61,5 @@ export declare function findCommandBeforeCursor(char: string, selection: Selecti
|
|
|
75
61
|
* @param options options for configuring the plugin
|
|
76
62
|
* @returns the prosemirror plugin
|
|
77
63
|
*/
|
|
78
|
-
export declare function createSuggestionPlugin<T extends SuggestionItem>({ pluginKey, editor,
|
|
64
|
+
export declare function createSuggestionPlugin<T extends SuggestionItem>({ pluginKey, editor, defaultTriggerCharacter, suggestionsMenuFactory, onSelectItem: selectItemCallback, items, }: SuggestionPluginOptions<T>): Plugin<SuggestionPluginState<T>>;
|
|
79
65
|
export {};
|
|
@@ -5,7 +5,7 @@ export type SuggestionsMenuStaticParams<T extends SuggestionItem> = {
|
|
|
5
5
|
};
|
|
6
6
|
export type SuggestionsMenuDynamicParams<T extends SuggestionItem> = {
|
|
7
7
|
items: T[];
|
|
8
|
-
|
|
8
|
+
keyboardHoveredItemIndex: number;
|
|
9
9
|
referenceRect: DOMRect;
|
|
10
10
|
};
|
|
11
11
|
export type SuggestionsMenu<T extends SuggestionItem> = EditorElement<SuggestionsMenuDynamicParams<T>>;
|