@blocknote/core 0.2.2 → 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.
Files changed (89) hide show
  1. package/dist/blocknote.js +1061 -936
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +1 -1
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +22 -29
  7. package/src/BlockNoteExtensions.ts +11 -10
  8. package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +61 -0
  9. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +62 -0
  10. package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +112 -106
  11. package/src/extensions/Blocks/apiTypes.ts +48 -0
  12. package/src/extensions/Blocks/helpers/findBlock.ts +3 -1
  13. package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +1 -1
  14. package/src/extensions/Blocks/index.ts +10 -8
  15. package/src/extensions/Blocks/nodes/Block.module.css +122 -35
  16. package/src/extensions/Blocks/{BlockAttributes.ts → nodes/BlockAttributes.ts} +0 -0
  17. package/src/extensions/Blocks/nodes/{Block.ts → BlockContainer.ts} +113 -119
  18. package/src/extensions/Blocks/nodes/{BlockTypes/HeadingBlock/HeadingContent.ts → BlockContent/HeadingBlockContent/HeadingBlockContent.ts} +16 -24
  19. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +76 -0
  20. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/ListItemKeyboardShortcuts.ts +47 -0
  21. package/src/extensions/Blocks/nodes/{BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.ts → BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts} +10 -14
  22. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +95 -0
  23. package/src/extensions/Blocks/nodes/{BlockTypes/TextBlock/TextContent.ts → BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts} +7 -12
  24. package/src/extensions/Blocks/nodes/BlockGroup.ts +4 -4
  25. package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +9 -1
  26. package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +87 -42
  27. package/src/extensions/{Blocks → DraggableBlocks}/MultipleNodeSelection.ts +0 -0
  28. package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +20 -7
  29. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +51 -12
  30. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.ts +1 -1
  31. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +3 -1
  32. package/src/extensions/Placeholder/PlaceholderExtension.ts +1 -1
  33. package/src/extensions/SlashMenu/SlashMenuExtension.ts +1 -1
  34. package/src/extensions/SlashMenu/SlashMenuItem.ts +3 -28
  35. package/src/extensions/SlashMenu/defaultCommands.tsx +36 -55
  36. package/src/extensions/SlashMenu/index.ts +1 -6
  37. package/src/extensions/TextAlignment/TextAlignmentExtension.ts +75 -0
  38. package/src/extensions/TextColor/TextColorExtension.ts +54 -0
  39. package/src/extensions/TextColor/TextColorMark.ts +62 -0
  40. package/src/extensions/TrailingNode/TrailingNodeExtension.ts +4 -4
  41. package/src/extensions/UniqueID/UniqueID.ts +6 -0
  42. package/src/index.ts +2 -1
  43. package/src/shared/EditorElement.ts +12 -6
  44. package/src/shared/plugins/suggestion/SuggestionItem.ts +0 -9
  45. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +191 -228
  46. package/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts +2 -2
  47. package/types/src/BlockNoteEditor.d.ts +1 -1
  48. package/types/src/BlockNoteExtensions.d.ts +1 -3
  49. package/types/src/api/Document.d.ts +5 -0
  50. package/types/src/extensions/BackgroundColor/BackgroundColorExtension.d.ts +9 -0
  51. package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +9 -0
  52. package/types/src/extensions/Blocks/PreviousBlockTypePlugin.d.ts +3 -2
  53. package/types/src/extensions/Blocks/apiTypes.d.ts +16 -0
  54. package/types/src/extensions/Blocks/helpers/getBlockInfoFromPos.d.ts +1 -1
  55. package/types/src/extensions/Blocks/nodes/BlockAttributes.d.ts +2 -0
  56. package/types/src/extensions/Blocks/nodes/BlockContainer.d.ts +21 -0
  57. package/types/src/extensions/Blocks/nodes/BlockContent/BlockContentTypes.d.ts +4 -0
  58. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +2 -0
  59. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContentTypes.d.ts +4 -0
  60. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +2 -0
  61. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContentTypes.d.ts +2 -0
  62. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +2 -0
  63. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.d.ts +2 -0
  64. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +2 -0
  65. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContentTypes.d.ts +2 -0
  66. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +2 -0
  67. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContentTypes.d.ts +2 -0
  68. package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +9 -5
  69. package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +1 -1
  70. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +6 -11
  71. package/types/src/extensions/DraggableBlocks/MultipleNodeSelection.d.ts +24 -0
  72. package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +18 -8
  73. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +1 -1
  74. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +5 -5
  75. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +2 -2
  76. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +1 -1
  77. package/types/src/extensions/SlashMenu/SlashMenuItem.d.ts +2 -19
  78. package/types/src/extensions/SlashMenu/defaultSlashCommands.d.ts +5 -0
  79. package/types/src/extensions/SlashMenu/index.d.ts +1 -2
  80. package/types/src/extensions/TextAlignment/TextAlignmentExtension.d.ts +9 -0
  81. package/types/src/extensions/TextColor/TextColorExtension.d.ts +9 -0
  82. package/types/src/extensions/TextColor/TextColorMark.d.ts +9 -0
  83. package/types/src/index.d.ts +2 -1
  84. package/types/src/shared/EditorElement.d.ts +6 -2
  85. package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +0 -6
  86. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +11 -25
  87. package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +6 -6
  88. package/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.ts +0 -177
  89. package/src/extensions/Paragraph/FixedParagraph.ts +0 -12
@@ -0,0 +1,21 @@
1
+ import { Node } from "@tiptap/core";
2
+ import { BlockUpdate } from "../apiTypes";
3
+ export interface IBlock {
4
+ HTMLAttributes: Record<string, any>;
5
+ }
6
+ declare module "@tiptap/core" {
7
+ interface Commands<ReturnType> {
8
+ block: {
9
+ BNCreateBlock: (pos: number) => ReturnType;
10
+ BNDeleteBlock: (posInBlock: number) => ReturnType;
11
+ BNMergeBlocks: (posBetweenBlocks: number) => ReturnType;
12
+ BNSplitBlock: (posInBlock: number, keepType: boolean) => ReturnType;
13
+ BNUpdateBlock: (posInBlock: number, blockUpdate: BlockUpdate) => ReturnType;
14
+ BNCreateOrUpdateBlock: (posInBlock: number, blockUpdate: BlockUpdate) => ReturnType;
15
+ };
16
+ }
17
+ }
18
+ /**
19
+ * The main "Block node" documents consist of
20
+ */
21
+ export declare const BlockContainer: Node<IBlock, any>;
@@ -0,0 +1,4 @@
1
+ export declare type Block<Type extends string, Props extends Record<string, string>> = {
2
+ type: Type;
3
+ props: Props;
4
+ };
@@ -0,0 +1,2 @@
1
+ import { Node } from "@tiptap/core";
2
+ export declare const HeadingBlockContent: Node<any, any>;
@@ -0,0 +1,4 @@
1
+ import { Block } from "../BlockContentTypes";
2
+ export declare type HeadingBlock = Block<"heading", {
3
+ level: "1" | "2" | "3";
4
+ }>;
@@ -0,0 +1,2 @@
1
+ import { Node } from "@tiptap/core";
2
+ export declare const BulletListItemBlockContent: Node<any, any>;
@@ -0,0 +1,2 @@
1
+ import { Block } from "../../BlockContentTypes";
2
+ export declare type BulletListItemBlock = Block<"bulletListItem", {}>;
@@ -0,0 +1,2 @@
1
+ import { Editor } from "@tiptap/core";
2
+ export declare const handleEnter: (editor: Editor) => boolean;
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ export declare const NumberedListIndexingPlugin: () => Plugin<any>;
@@ -0,0 +1,2 @@
1
+ import { Node } from "@tiptap/core";
2
+ export declare const NumberedListItemBlockContent: Node<any, any>;
@@ -0,0 +1,2 @@
1
+ import { Block } from "../../BlockContentTypes";
2
+ export declare type NumberedListItemBlock = Block<"numberedListItem", {}>;
@@ -0,0 +1,2 @@
1
+ import { Node } from "@tiptap/core";
2
+ export declare const ParagraphBlockContent: Node<any, any>;
@@ -0,0 +1,2 @@
1
+ import { Block } from "../BlockContentTypes";
2
+ export declare type ParagraphBlock = Block<"paragraph", {}>;
@@ -1,14 +1,18 @@
1
1
  import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
- export declare type BlockSideMenuStaticParams = {
2
+ export type BlockSideMenuStaticParams = {
3
3
  addBlock: () => void;
4
4
  deleteBlock: () => void;
5
5
  blockDragStart: (event: DragEvent) => void;
6
6
  blockDragEnd: () => void;
7
7
  freezeMenu: () => void;
8
8
  unfreezeMenu: () => void;
9
+ setBlockTextColor: (color: string) => void;
10
+ setBlockBackgroundColor: (color: string) => void;
9
11
  };
10
- export declare type BlockSideMenuDynamicParams = {
11
- blockBoundingBox: DOMRect;
12
+ export type BlockSideMenuDynamicParams = {
13
+ blockTextColor: string;
14
+ blockBackgroundColor: string;
15
+ referenceRect: DOMRect;
12
16
  };
13
- export declare type BlockSideMenu = EditorElement<BlockSideMenuDynamicParams>;
14
- export declare type BlockSideMenuFactory = ElementFactory<BlockSideMenuStaticParams, BlockSideMenuDynamicParams>;
17
+ export type BlockSideMenu = EditorElement<BlockSideMenuDynamicParams>;
18
+ export type BlockSideMenuFactory = ElementFactory<BlockSideMenuStaticParams, BlockSideMenuDynamicParams>;
@@ -1,6 +1,6 @@
1
1
  import { Editor, Extension } from "@tiptap/core";
2
2
  import { BlockSideMenuFactory } from "./BlockSideMenuFactoryTypes";
3
- export declare type DraggableBlocksOptions = {
3
+ export type DraggableBlocksOptions = {
4
4
  editor: Editor;
5
5
  blockSideMenuFactory: BlockSideMenuFactory;
6
6
  };
@@ -1,7 +1,7 @@
1
1
  import { Editor } from "@tiptap/core";
2
2
  import { Plugin } from "prosemirror-state";
3
- import { DraggableBlocksOptions } from "./DraggableBlocksExtension";
4
3
  import { BlockSideMenu, BlockSideMenuDynamicParams, BlockSideMenuFactory, BlockSideMenuStaticParams } from "./BlockSideMenuFactoryTypes";
4
+ import { DraggableBlocksOptions } from "./DraggableBlocksExtension";
5
5
  export declare function createRect(rect: DOMRect): {
6
6
  left: number;
7
7
  top: number;
@@ -10,15 +10,7 @@ export declare function createRect(rect: DOMRect): {
10
10
  bottom: number;
11
11
  right: number;
12
12
  };
13
- export declare function absoluteRect(element: HTMLElement): {
14
- left: number;
15
- top: number;
16
- width: number;
17
- height: number;
18
- bottom: number;
19
- right: number;
20
- };
21
- export declare type BlockMenuViewProps = {
13
+ export type BlockMenuViewProps = {
22
14
  editor: Editor;
23
15
  blockMenuFactory: BlockSideMenuFactory;
24
16
  horizontalPosAnchoredAtRoot: boolean;
@@ -26,14 +18,17 @@ export declare type BlockMenuViewProps = {
26
18
  export declare class BlockMenuView {
27
19
  editor: Editor;
28
20
  horizontalPosAnchoredAtRoot: boolean;
21
+ horizontalPosAnchor: number;
29
22
  blockMenu: BlockSideMenu;
30
- hoveredBlock: HTMLElement | undefined;
23
+ hoveredBlockContent: HTMLElement | undefined;
31
24
  menuOpen: boolean;
32
25
  menuFrozen: boolean;
33
26
  constructor({ editor, blockMenuFactory, horizontalPosAnchoredAtRoot, }: BlockMenuViewProps);
34
27
  destroy(): void;
35
28
  addBlock(): void;
36
29
  deleteBlock(): void;
30
+ setBlockBackgroundColor(color: string): void;
31
+ setBlockTextColor(color: string): void;
37
32
  getStaticParams(): BlockSideMenuStaticParams;
38
33
  getDynamicParams(): BlockSideMenuDynamicParams;
39
34
  }
@@ -0,0 +1,24 @@
1
+ import { Selection } from "prosemirror-state";
2
+ import { Node, ResolvedPos, Slice } from "prosemirror-model";
3
+ import { Mappable } from "prosemirror-transform";
4
+ /**
5
+ * This class represents an editor selection which spans multiple nodes/blocks. It's currently only used to allow users
6
+ * to drag multiple blocks at the same time. Expects the selection anchor and head to be between nodes, i.e. just before
7
+ * the first target node and just after the last, and that anchor and head are at the same nesting level.
8
+ *
9
+ * Partially based on ProseMirror's NodeSelection implementation:
10
+ * (https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.ts)
11
+ * MultipleNodeSelection differs from NodeSelection in the following ways:
12
+ * 1. Stores which nodes are included in the selection instead of just a single node.
13
+ * 2. Already expects the selection to start just before the first target node and ends just after the last, while a
14
+ * NodeSelection automatically sets both anchor and head to just before the single target node.
15
+ */
16
+ export declare class MultipleNodeSelection extends Selection {
17
+ nodes: Array<Node>;
18
+ constructor($anchor: ResolvedPos, $head: ResolvedPos);
19
+ static create(doc: Node, from: number, to?: number): MultipleNodeSelection;
20
+ content(): Slice;
21
+ eq(selection: Selection): boolean;
22
+ map(doc: Node, mapping: Mappable): Selection;
23
+ toJSON(): any;
24
+ }
@@ -1,14 +1,19 @@
1
1
  import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
- import { BlockContentType } from "../Blocks/nodes/Block";
3
- export declare type FormattingToolbarStaticParams = {
2
+ import { Block, BlockUpdate } from "../Blocks/apiTypes";
3
+ export type FormattingToolbarStaticParams = {
4
4
  toggleBold: () => void;
5
5
  toggleItalic: () => void;
6
6
  toggleUnderline: () => void;
7
7
  toggleStrike: () => void;
8
8
  setHyperlink: (url: string, text?: string) => void;
9
- setBlockType: (type: BlockContentType) => void;
9
+ setTextColor: (color: string) => void;
10
+ setBackgroundColor: (color: string) => void;
11
+ setTextAlignment: (textAlignment: "left" | "center" | "right" | "justify") => void;
12
+ increaseBlockIndent: () => void;
13
+ decreaseBlockIndent: () => void;
14
+ updateBlock: (blockUpdate: BlockUpdate) => void;
10
15
  };
11
- export declare type FormattingToolbarDynamicParams = {
16
+ export type FormattingToolbarDynamicParams = {
12
17
  boldIsActive: boolean;
13
18
  italicIsActive: boolean;
14
19
  underlineIsActive: boolean;
@@ -16,8 +21,13 @@ export declare type FormattingToolbarDynamicParams = {
16
21
  hyperlinkIsActive: boolean;
17
22
  activeHyperlinkUrl: string;
18
23
  activeHyperlinkText: string;
19
- activeBlockType: Required<BlockContentType>;
20
- selectionBoundingBox: DOMRect;
24
+ textColor: string;
25
+ backgroundColor: string;
26
+ textAlignment: "left" | "center" | "right" | "justify";
27
+ canIncreaseBlockIndent: boolean;
28
+ canDecreaseBlockIndent: boolean;
29
+ block: Block;
30
+ referenceRect: DOMRect;
21
31
  };
22
- export declare type FormattingToolbar = EditorElement<FormattingToolbarDynamicParams>;
23
- export declare type FormattingToolbarFactory = ElementFactory<FormattingToolbarStaticParams, FormattingToolbarDynamicParams>;
32
+ export type FormattingToolbar = EditorElement<FormattingToolbarDynamicParams>;
33
+ export type FormattingToolbarFactory = ElementFactory<FormattingToolbarStaticParams, FormattingToolbarDynamicParams>;
@@ -15,7 +15,7 @@ export interface FormattingToolbarPluginProps {
15
15
  to: number;
16
16
  }) => boolean) | null;
17
17
  }
18
- export declare type FormattingToolbarViewProps = FormattingToolbarPluginProps & {
18
+ export type FormattingToolbarViewProps = FormattingToolbarPluginProps & {
19
19
  view: EditorView;
20
20
  };
21
21
  export declare class FormattingToolbarView {
@@ -1,12 +1,12 @@
1
1
  import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
- export declare type HyperlinkToolbarStaticParams = {
2
+ export type HyperlinkToolbarStaticParams = {
3
3
  editHyperlink: (url: string, text: string) => void;
4
4
  deleteHyperlink: () => void;
5
5
  };
6
- export declare type HyperlinkToolbarDynamicParams = {
6
+ export type HyperlinkToolbarDynamicParams = {
7
7
  url: string;
8
8
  text: string;
9
- boundingBox: DOMRect;
9
+ referenceRect: DOMRect;
10
10
  };
11
- export declare type HyperlinkToolbar = EditorElement<HyperlinkToolbarDynamicParams>;
12
- export declare type HyperlinkToolbarFactory = ElementFactory<HyperlinkToolbarStaticParams, HyperlinkToolbarDynamicParams>;
11
+ export type HyperlinkToolbar = EditorElement<HyperlinkToolbarDynamicParams>;
12
+ export type HyperlinkToolbarFactory = ElementFactory<HyperlinkToolbarStaticParams, HyperlinkToolbarDynamicParams>;
@@ -1,10 +1,10 @@
1
1
  import { Editor } from "@tiptap/core";
2
2
  import { Plugin } from "prosemirror-state";
3
3
  import { HyperlinkToolbarFactory } from "./HyperlinkToolbarFactoryTypes";
4
- export declare type HyperlinkToolbarPluginProps = {
4
+ export type HyperlinkToolbarPluginProps = {
5
5
  hyperlinkToolbarFactory: HyperlinkToolbarFactory;
6
6
  };
7
- export declare type HyperlinkToolbarViewProps = {
7
+ export type HyperlinkToolbarViewProps = {
8
8
  editor: Editor;
9
9
  hyperlinkToolbarFactory: HyperlinkToolbarFactory;
10
10
  };
@@ -2,7 +2,7 @@ import { Extension } from "@tiptap/core";
2
2
  import { PluginKey } from "prosemirror-state";
3
3
  import { SuggestionsMenuFactory } from "../../shared/plugins/suggestion/SuggestionsMenuFactoryTypes";
4
4
  import { SlashMenuItem } from "./SlashMenuItem";
5
- export declare type SlashMenuOptions = {
5
+ export type SlashMenuOptions = {
6
6
  commands: {
7
7
  [key: string]: SlashMenuItem;
8
8
  };
@@ -1,14 +1,5 @@
1
1
  import { Editor, Range } from "@tiptap/core";
2
2
  import { SuggestionItem } from "../../shared/plugins/suggestion/SuggestionItem";
3
- export declare 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 group: SlashMenuGroups;
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, group: SlashMenuGroups, execute: SlashMenuCallback, aliases?: string[], hint?: string | undefined, shortcut?: string | undefined);
19
+ constructor(name: string, execute: (editor: Editor, range: Range) => void, aliases?: string[]);
37
20
  match(query: string): boolean;
38
21
  }
@@ -0,0 +1,5 @@
1
+ import { SlashMenuItem } from "./SlashMenuItem";
2
+ /**
3
+ * An array containing commands for creating all default blocks.
4
+ */
5
+ export declare const defaultSlashCommands: SlashMenuItem[];
@@ -1,5 +1,4 @@
1
1
  import { SlashMenuExtension } from "./SlashMenuExtension";
2
2
  import defaultCommands from "./defaultCommands";
3
- import { SlashMenuGroups, SlashMenuItem } from "./SlashMenuItem";
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>;
@@ -0,0 +1,9 @@
1
+ import { Mark } from "@tiptap/core";
2
+ declare module "@tiptap/core" {
3
+ interface Commands<ReturnType> {
4
+ textColor: {
5
+ setTextColor: (color: string) => ReturnType;
6
+ };
7
+ }
8
+ }
9
+ export declare const TextColorMark: Mark<any, any>;
@@ -1,9 +1,10 @@
1
1
  export * from "./BlockNoteEditor";
2
2
  export * from "./BlockNoteExtensions";
3
- export type { BlockContentType } from "./extensions/Blocks/nodes/Block";
3
+ export type { Block, BlockUpdate } from "./extensions/Blocks/apiTypes";
4
4
  export * from "./extensions/FormattingToolbar/FormattingToolbarFactoryTypes";
5
5
  export * from "./extensions/DraggableBlocks/BlockSideMenuFactoryTypes";
6
6
  export * from "./extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes";
7
7
  export * from "./extensions/SlashMenu/SlashMenuItem";
8
+ export * from "./shared/EditorElement";
8
9
  export type { SuggestionItem } from "./shared/plugins/suggestion/SuggestionItem";
9
10
  export * from "./shared/plugins/suggestion/SuggestionsMenuFactoryTypes";
@@ -1,6 +1,10 @@
1
- export declare type EditorElement<ElementDynamicParams extends Record<string, any>> = {
1
+ export type RequiredStaticParams = Record<string, any>;
2
+ export type RequiredDynamicParams = Record<string, any> & {
3
+ referenceRect: DOMRect;
4
+ };
5
+ export type EditorElement<ElementDynamicParams extends RequiredDynamicParams> = {
2
6
  element: HTMLElement | undefined;
3
7
  render: (params: ElementDynamicParams, isHidden: boolean) => void;
4
8
  hide: () => void;
5
9
  };
6
- export declare type ElementFactory<ElementStaticParams extends Record<string, any>, ElementDynamicParams extends Record<string, any>> = (staticParams: ElementStaticParams) => EditorElement<ElementDynamicParams>;
10
+ export type ElementFactory<ElementStaticParams extends RequiredStaticParams, ElementDynamicParams extends RequiredDynamicParams> = (staticParams: ElementStaticParams) => EditorElement<ElementDynamicParams>;
@@ -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,8 +1,8 @@
1
1
  import { Editor, Range } from "@tiptap/core";
2
- import { Plugin, PluginKey, Selection } from "prosemirror-state";
2
+ import { Plugin, PluginKey } from "prosemirror-state";
3
3
  import { SuggestionsMenuFactory } from "./SuggestionsMenuFactoryTypes";
4
4
  import { SuggestionItem } from "./SuggestionItem";
5
- export declare type SuggestionPluginOptions<T extends SuggestionItem> = {
5
+ export type SuggestionPluginOptions<T extends SuggestionItem> = {
6
6
  /**
7
7
  * The name of the plugin.
8
8
  *
@@ -14,9 +14,9 @@ export declare 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
- char: string;
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.
@@ -39,29 +39,15 @@ export declare type SuggestionPluginOptions<T extends SuggestionItem> = {
39
39
  range: Range;
40
40
  }) => boolean;
41
41
  };
42
- declare type SuggestionPluginState<T extends SuggestionItem> = {
42
+ type SuggestionPluginState<T extends SuggestionItem> = {
43
43
  active: boolean;
44
- range: Range | null;
45
- query: string | null;
46
- notFoundCount: number;
44
+ triggerCharacter: string | undefined;
45
+ queryStartPos: number | undefined;
47
46
  items: T[];
48
- selectedItemIndex: number;
49
- type: string;
50
- decorationId: string | null;
47
+ keyboardHoveredItemIndex: number | undefined;
48
+ notFoundCount: number | undefined;
49
+ decorationId: string | undefined;
51
50
  };
52
- export declare 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, char, suggestionsMenuFactory, onSelectItem: selectItemCallback, items, }: SuggestionPluginOptions<T>): Plugin<SuggestionPluginState<T>>;
64
+ export declare function createSuggestionPlugin<T extends SuggestionItem>({ pluginKey, editor, defaultTriggerCharacter, suggestionsMenuFactory, onSelectItem: selectItemCallback, items, }: SuggestionPluginOptions<T>): Plugin<SuggestionPluginState<T>>;
79
65
  export {};
@@ -1,12 +1,12 @@
1
1
  import { EditorElement, ElementFactory } from "../../EditorElement";
2
2
  import { SuggestionItem } from "./SuggestionItem";
3
- export declare type SuggestionsMenuStaticParams<T extends SuggestionItem> = {
3
+ export type SuggestionsMenuStaticParams<T extends SuggestionItem> = {
4
4
  itemCallback: (item: T) => void;
5
5
  };
6
- export declare type SuggestionsMenuDynamicParams<T extends SuggestionItem> = {
6
+ export type SuggestionsMenuDynamicParams<T extends SuggestionItem> = {
7
7
  items: T[];
8
- selectedItemIndex: number;
9
- queryStartBoundingBox: DOMRect;
8
+ keyboardHoveredItemIndex: number;
9
+ referenceRect: DOMRect;
10
10
  };
11
- export declare type SuggestionsMenu<T extends SuggestionItem> = EditorElement<SuggestionsMenuDynamicParams<T>>;
12
- export declare type SuggestionsMenuFactory<T extends SuggestionItem> = ElementFactory<SuggestionsMenuStaticParams<T>, SuggestionsMenuDynamicParams<T>>;
11
+ export type SuggestionsMenu<T extends SuggestionItem> = EditorElement<SuggestionsMenuDynamicParams<T>>;
12
+ export type SuggestionsMenuFactory<T extends SuggestionItem> = ElementFactory<SuggestionsMenuStaticParams<T>, SuggestionsMenuDynamicParams<T>>;