@blocknote/core 0.1.1 → 0.2.0

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 (171) hide show
  1. package/README.md +12 -6
  2. package/dist/blocknote.js +1425 -5114
  3. package/dist/blocknote.js.map +1 -1
  4. package/dist/blocknote.umd.cjs +1 -53
  5. package/dist/blocknote.umd.cjs.map +1 -1
  6. package/dist/style.css +1 -1
  7. package/package.json +3 -16
  8. package/src/BlockNoteEditor.ts +54 -0
  9. package/src/BlockNoteExtensions.ts +52 -7
  10. package/src/assets/fonts-inter.css +92 -0
  11. package/src/editor.module.css +37 -0
  12. package/src/extensions/Blocks/BlockAttributes.ts +1 -3
  13. package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +71 -18
  14. package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +66 -0
  15. package/src/extensions/Blocks/index.ts +7 -3
  16. package/src/extensions/Blocks/nodes/Block.module.css +116 -74
  17. package/src/extensions/Blocks/nodes/Block.ts +415 -292
  18. package/src/extensions/Blocks/nodes/BlockGroup.ts +6 -6
  19. package/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.ts +84 -0
  20. package/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.ts +177 -0
  21. package/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.ts +77 -0
  22. package/src/extensions/Blocks/nodes/BlockTypes/TextBlock/TextContent.ts +34 -0
  23. package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +20 -0
  24. package/src/extensions/DraggableBlocks/DraggableBlocksExtension.ts +27 -9
  25. package/src/extensions/DraggableBlocks/{DraggableBlocksPlugin.tsx → DraggableBlocksPlugin.ts} +227 -147
  26. package/src/extensions/FormattingToolbar/FormattingToolbarExtension.ts +29 -0
  27. package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +35 -0
  28. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +308 -0
  29. package/src/extensions/HyperlinkToolbar/HyperlinkMark.ts +28 -0
  30. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.ts +19 -0
  31. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +251 -0
  32. package/src/extensions/Placeholder/PlaceholderExtension.ts +2 -2
  33. package/src/extensions/SlashMenu/SlashMenuExtension.ts +9 -1
  34. package/src/extensions/SlashMenu/SlashMenuItem.ts +1 -3
  35. package/src/extensions/SlashMenu/defaultCommands.tsx +33 -22
  36. package/src/extensions/TrailingNode/TrailingNodeExtension.ts +4 -4
  37. package/src/extensions/UniqueID/UniqueID.ts +14 -12
  38. package/src/index.ts +8 -4
  39. package/src/shared/EditorElement.ts +10 -0
  40. package/src/shared/plugins/suggestion/SuggestionItem.ts +1 -8
  41. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +222 -101
  42. package/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts +21 -0
  43. package/src/{utils.ts → shared/utils.ts} +0 -0
  44. package/types/src/BlockNoteEditor.d.ts +13 -0
  45. package/types/src/BlockNoteExtensions.d.ts +12 -1
  46. package/types/src/EditorElement.d.ts +7 -0
  47. package/types/src/extensions/Blocks/PreviousBlockTypePlugin.d.ts +1 -1
  48. package/types/src/extensions/Blocks/helpers/getBlockInfoFromPos.d.ts +19 -0
  49. package/types/src/extensions/Blocks/nodes/Block.d.ts +11 -19
  50. package/types/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.d.ts +8 -0
  51. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.d.ts +8 -0
  52. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.d.ts +2 -0
  53. package/types/src/extensions/Blocks/nodes/BlockTypes/TextBlock/TextContent.d.ts +6 -0
  54. package/types/src/extensions/BubbleMenu/BubbleMenuExtension.d.ts +4 -1
  55. package/types/src/extensions/BubbleMenu/BubbleMenuFactoryTypes.d.ts +27 -0
  56. package/types/src/extensions/BubbleMenu/BubbleMenuPlugin.d.ts +10 -12
  57. package/types/src/extensions/DraggableBlocks/BlockMenuFactoryTypes.d.ts +12 -0
  58. package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +14 -0
  59. package/types/src/extensions/DraggableBlocks/DragMenuFactoryTypes.d.ts +18 -0
  60. package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +9 -3
  61. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +23 -1
  62. package/types/src/extensions/FormattingToolbar/FormattingToolbarExtension.d.ts +8 -0
  63. package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +23 -0
  64. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +43 -0
  65. package/types/src/extensions/HyperlinkToolbar/HyperlinkMark.d.ts +8 -0
  66. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +12 -0
  67. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +11 -0
  68. package/types/src/extensions/Hyperlinks/HyperlinkMark.d.ts +2 -1
  69. package/types/src/extensions/Hyperlinks/HyperlinkMenuFactoryTypes.d.ts +11 -0
  70. package/types/src/extensions/Hyperlinks/HyperlinkMenuPlugin.d.ts +10 -1
  71. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +3 -1
  72. package/types/src/extensions/SlashMenu/SlashMenuItem.d.ts +2 -4
  73. package/types/src/index.d.ts +8 -3
  74. package/types/src/shared/EditorElement.d.ts +6 -0
  75. package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +1 -6
  76. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +15 -10
  77. package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +12 -0
  78. package/types/src/shared/utils.d.ts +2 -0
  79. package/types/src/utils.d.ts +2 -2
  80. package/src/BlockNoteTheme.ts +0 -150
  81. package/src/EditorContent.tsx +0 -2
  82. package/src/extensions/Blocks/OrderedListPlugin.ts +0 -46
  83. package/src/extensions/Blocks/commands/joinBackward.ts +0 -274
  84. package/src/extensions/Blocks/helpers/setBlockHeading.ts +0 -30
  85. package/src/extensions/Blocks/nodes/Content.ts +0 -63
  86. package/src/extensions/Blocks/rule.ts +0 -48
  87. package/src/extensions/BubbleMenu/BubbleMenuExtension.tsx +0 -36
  88. package/src/extensions/BubbleMenu/BubbleMenuPlugin.ts +0 -245
  89. package/src/extensions/BubbleMenu/component/BubbleMenu.tsx +0 -240
  90. package/src/extensions/BubbleMenu/component/LinkToolbarButton.tsx +0 -67
  91. package/src/extensions/DraggableBlocks/components/DragHandle.tsx +0 -102
  92. package/src/extensions/DraggableBlocks/components/DragHandleMenu.tsx +0 -19
  93. package/src/extensions/Hyperlinks/HyperlinkMark.tsx +0 -16
  94. package/src/extensions/Hyperlinks/HyperlinkMenuPlugin.tsx +0 -165
  95. package/src/extensions/Hyperlinks/menus/EditHyperlinkMenu.tsx +0 -44
  96. package/src/extensions/Hyperlinks/menus/EditHyperlinkMenuItem.tsx +0 -34
  97. package/src/extensions/Hyperlinks/menus/EditHyperlinkMenuItemIcon.tsx +0 -31
  98. package/src/extensions/Hyperlinks/menus/EditHyperlinkMenuItemInput.tsx +0 -40
  99. package/src/extensions/Hyperlinks/menus/HoverHyperlinkMenu.tsx +0 -37
  100. package/src/extensions/Hyperlinks/menus/HyperlinkMenu.tsx +0 -63
  101. package/src/fonts-inter.css +0 -94
  102. package/src/globals.css +0 -28
  103. package/src/root.module.css +0 -19
  104. package/src/shared/components/toolbar/Toolbar.tsx +0 -10
  105. package/src/shared/components/toolbar/ToolbarButton.tsx +0 -57
  106. package/src/shared/components/toolbar/ToolbarDropdown.tsx +0 -35
  107. package/src/shared/components/toolbar/ToolbarDropdownItem.tsx +0 -35
  108. package/src/shared/components/toolbar/ToolbarDropdownTarget.tsx +0 -31
  109. package/src/shared/components/tooltip/TooltipContent.module.css +0 -15
  110. package/src/shared/components/tooltip/TooltipContent.tsx +0 -23
  111. package/src/shared/hooks/useEditorForceUpdate.tsx +0 -30
  112. package/src/shared/plugins/suggestion/SuggestionListReactRenderer.tsx +0 -236
  113. package/src/shared/plugins/suggestion/components/SuggestionGroup.tsx +0 -47
  114. package/src/shared/plugins/suggestion/components/SuggestionGroupItem.tsx +0 -82
  115. package/src/shared/plugins/suggestion/components/SuggestionList.tsx +0 -92
  116. package/src/useEditor.ts +0 -51
  117. package/types/src/BlockNoteTheme.d.ts +0 -2
  118. package/types/src/EditorContent.d.ts +0 -1
  119. package/types/src/commands/indentation.d.ts +0 -2
  120. package/types/src/extensions/Blocks/OrderedListPlugin.d.ts +0 -2
  121. package/types/src/extensions/Blocks/commands/joinBackward.d.ts +0 -14
  122. package/types/src/extensions/Blocks/helpers/setBlockHeading.d.ts +0 -5
  123. package/types/src/extensions/Blocks/nodes/Content.d.ts +0 -5
  124. package/types/src/extensions/Blocks/rule.d.ts +0 -16
  125. package/types/src/extensions/BubbleMenu/component/BubbleMenu.d.ts +0 -5
  126. package/types/src/extensions/BubbleMenu/component/DropdownBlockItem.d.ts +0 -10
  127. package/types/src/extensions/BubbleMenu/component/LinkToolbarButton.d.ts +0 -11
  128. package/types/src/extensions/DraggableBlocks/components/DragHandle.d.ts +0 -12
  129. package/types/src/extensions/DraggableBlocks/components/DragHandleMenu.d.ts +0 -6
  130. package/types/src/extensions/Hyperlinks/menus/EditHyperlinkMenu.d.ts +0 -11
  131. package/types/src/extensions/Hyperlinks/menus/EditHyperlinkMenuItem.d.ts +0 -13
  132. package/types/src/extensions/Hyperlinks/menus/EditHyperlinkMenuItemIcon.d.ts +0 -8
  133. package/types/src/extensions/Hyperlinks/menus/EditHyperlinkMenuItemInput.d.ts +0 -9
  134. package/types/src/extensions/Hyperlinks/menus/HoverHyperlinkMenu.d.ts +0 -12
  135. package/types/src/extensions/Hyperlinks/menus/HyperlinkBasicMenu.d.ts +0 -12
  136. package/types/src/extensions/Hyperlinks/menus/HyperlinkEditMenu.d.ts +0 -10
  137. package/types/src/extensions/Hyperlinks/menus/HyperlinkMenu.d.ts +0 -21
  138. package/types/src/extensions/Hyperlinks/menus/atlaskit/PanelTextInput.d.ts +0 -39
  139. package/types/src/extensions/Hyperlinks/menus/atlaskit/PanelTextInputStyles.d.ts +0 -1
  140. package/types/src/extensions/Hyperlinks/menus/atlaskit/ToolbarComponent.d.ts +0 -11
  141. package/types/src/extensions/Hyperlinks/menus/helpers/PanelTextInput.d.ts +0 -39
  142. package/types/src/extensions/Hyperlinks/menus/helpers/PanelTextInputStyles.d.ts +0 -3
  143. package/types/src/extensions/Hyperlinks/menus/helpers/ToolbarComponent.d.ts +0 -13
  144. package/types/src/extensions/helpers/formatKeyboardShortcut.d.ts +0 -1
  145. package/types/src/lib/atlaskit/browser.d.ts +0 -12
  146. package/types/src/nodes/ChildgroupNode.d.ts +0 -28
  147. package/types/src/nodes/patchNodes.d.ts +0 -1
  148. package/types/src/plugins/TreeViewPlugin/index.d.ts +0 -2
  149. package/types/src/plugins/animation.d.ts +0 -2
  150. package/types/src/react/BlockNoteComposer.d.ts +0 -17
  151. package/types/src/react/BlockNotePlugin.d.ts +0 -1
  152. package/types/src/react/index.d.ts +0 -3
  153. package/types/src/react/useBlockNoteSetup.d.ts +0 -2
  154. package/types/src/registerBlockNote.d.ts +0 -2
  155. package/types/src/shared/components/toolbar/SimpleToolbarButton.d.ts +0 -15
  156. package/types/src/shared/components/toolbar/SimpleToolbarDropdown.d.ts +0 -11
  157. package/types/src/shared/components/toolbar/SimpleToolbarDropdownItem.d.ts +0 -11
  158. package/types/src/shared/components/toolbar/Toolbar.d.ts +0 -4
  159. package/types/src/shared/components/toolbar/ToolbarButton.d.ts +0 -15
  160. package/types/src/shared/components/toolbar/ToolbarDropdown.d.ts +0 -17
  161. package/types/src/shared/components/toolbar/ToolbarDropdownItem.d.ts +0 -11
  162. package/types/src/shared/components/toolbar/ToolbarDropdownTarget.d.ts +0 -8
  163. package/types/src/shared/components/toolbar/ToolbarSeparator.d.ts +0 -2
  164. package/types/src/shared/components/tooltip/TooltipContent.d.ts +0 -15
  165. package/types/src/shared/hooks/useEditorForceUpdate.d.ts +0 -2
  166. package/types/src/shared/plugins/suggestion/SuggestionListReactRenderer.d.ts +0 -71
  167. package/types/src/shared/plugins/suggestion/components/SuggestionGroup.d.ts +0 -23
  168. package/types/src/shared/plugins/suggestion/components/SuggestionGroupItem.d.ts +0 -9
  169. package/types/src/shared/plugins/suggestion/components/SuggestionList.d.ts +0 -11
  170. package/types/src/themes/BlockNoteEditorTheme.d.ts +0 -11
  171. package/types/src/useEditor.d.ts +0 -11
@@ -0,0 +1,13 @@
1
+ import { Editor, EditorOptions } from "@tiptap/core";
2
+ import { UiFactories } from "./BlockNoteExtensions";
3
+ export declare type BlockNoteEditorOptions = EditorOptions & {
4
+ enableBlockNoteExtensions: boolean;
5
+ disableHistoryExtension: boolean;
6
+ uiFactories: UiFactories;
7
+ };
8
+ export declare class BlockNoteEditor {
9
+ readonly tiptapEditor: Editor & {
10
+ contentComponent: any;
11
+ };
12
+ constructor(options?: Partial<BlockNoteEditorOptions>);
13
+ }
@@ -1,7 +1,18 @@
1
1
  import { Extensions } from "@tiptap/core";
2
2
  import { Node } from "@tiptap/core";
3
+ import { FormattingToolbarFactory } from "./extensions/FormattingToolbar/FormattingToolbarFactoryTypes";
4
+ import { HyperlinkToolbarFactory } from "./extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes";
5
+ import { SuggestionsMenuFactory } from "./shared/plugins/suggestion/SuggestionsMenuFactoryTypes";
6
+ import { BlockSideMenuFactory } from "./extensions/DraggableBlocks/BlockSideMenuFactoryTypes";
7
+ import { SlashMenuItem } from "./extensions/SlashMenu/SlashMenuItem";
3
8
  export declare const Document: Node<any, any>;
9
+ export declare type UiFactories = Partial<{
10
+ formattingToolbarFactory: FormattingToolbarFactory;
11
+ hyperlinkToolbarFactory: HyperlinkToolbarFactory;
12
+ slashMenuFactory: SuggestionsMenuFactory<SlashMenuItem>;
13
+ blockSideMenuFactory: BlockSideMenuFactory;
14
+ }>;
4
15
  /**
5
16
  * Get all the Tiptap extensions BlockNote is configured with by default
6
17
  */
7
- export declare const getBlockNoteExtensions: () => Extensions;
18
+ export declare const getBlockNoteExtensions: (uiFactories: UiFactories) => Extensions;
@@ -0,0 +1,7 @@
1
+ export declare type EditorElement<ElementParams extends Record<string, any>> = {
2
+ element: HTMLElement | undefined;
3
+ show: (params: ElementParams) => void;
4
+ hide: () => void;
5
+ update: (params: ElementParams) => void;
6
+ };
7
+ export declare type ElementFactory<ElementParams extends Record<string, any>> = (params: ElementParams) => EditorElement<ElementParams>;
@@ -2,7 +2,7 @@ import { Plugin } from "prosemirror-state";
2
2
  /**
3
3
  * This plugin tracks transformation of Block node attributes, so we can support CSS transitions.
4
4
  *
5
- * Problem it solves: Prosemirror recreates the DOM when transactions happen. So when a transaction changes an Node attribute,
5
+ * Problem it solves: ProseMirror recreates the DOM when transactions happen. So when a transaction changes a Node attribute,
6
6
  * it results in a completely new DOM element. This means CSS transitions don't work.
7
7
  *
8
8
  * Solution: When attributes change on a node, this plugin sets a data-* attribute with the "previous" value. This way we can still use CSS transitions. (See block.module.css)
@@ -0,0 +1,19 @@
1
+ import { Node, NodeType } from "prosemirror-model";
2
+ export declare type BlockInfo = {
3
+ id: string;
4
+ node: Node;
5
+ contentNode: Node;
6
+ contentType: NodeType;
7
+ numChildBlocks: number;
8
+ startPos: number;
9
+ endPos: number;
10
+ depth: number;
11
+ };
12
+ /**
13
+ * Retrieves information regarding the most nested block node in a ProseMirror doc, that a given position lies in.
14
+ * @param doc The ProseMirror doc.
15
+ * @param posInBlock A position somewhere within a block node.
16
+ * @returns A BlockInfo object for the block the given position is in, or undefined if the position is not in a block
17
+ * for the given doc.
18
+ */
19
+ export declare function getBlockInfoFromPos(doc: Node, posInBlock: number): BlockInfo | undefined;
@@ -1,28 +1,20 @@
1
1
  import { Node } from "@tiptap/core";
2
+ import { TextContentType } from "./BlockTypes/TextBlock/TextContent";
3
+ import { HeadingContentType } from "./BlockTypes/HeadingBlock/HeadingContent";
4
+ import { ListItemContentType } from "./BlockTypes/ListItemBlock/ListItemContent";
2
5
  export interface IBlock {
3
6
  HTMLAttributes: Record<string, any>;
4
7
  }
5
- export declare type Level = "1" | "2" | "3";
6
- export declare type ListType = "li" | "oli";
8
+ export declare type BlockContentType = TextContentType | HeadingContentType | ListItemContentType;
7
9
  declare module "@tiptap/core" {
8
10
  interface Commands<ReturnType> {
9
- blockHeading: {
10
- /**
11
- * Set a heading node
12
- */
13
- setBlockHeading: (attributes: {
14
- level: Level;
15
- }) => ReturnType;
16
- /**
17
- * Unset a heading node
18
- */
19
- unsetBlockHeading: () => ReturnType;
20
- unsetList: () => ReturnType;
21
- addNewBlockAsSibling: (attributes?: {
22
- headingType?: Level;
23
- listType?: ListType;
24
- }) => ReturnType;
25
- setBlockList: (type: ListType) => ReturnType;
11
+ block: {
12
+ BNCreateBlock: (pos: number) => ReturnType;
13
+ BNDeleteBlock: (posInBlock: number) => ReturnType;
14
+ BNMergeBlocks: (posBetweenBlocks: number) => ReturnType;
15
+ BNSplitBlock: (posInBlock: number, keepType: boolean) => ReturnType;
16
+ BNSetContentType: (posInBlock: number, type: BlockContentType) => ReturnType;
17
+ BNCreateBlockOrSetContentType: (posInBlock: number, type: BlockContentType) => ReturnType;
26
18
  };
27
19
  }
28
20
  }
@@ -0,0 +1,8 @@
1
+ import { Node } from "@tiptap/core";
2
+ export declare type HeadingContentType = {
3
+ name: "headingContent";
4
+ attrs?: {
5
+ headingLevel: string;
6
+ };
7
+ };
8
+ export declare const HeadingContent: Node<any, any>;
@@ -0,0 +1,8 @@
1
+ import { Node } from "@tiptap/core";
2
+ export declare type ListItemContentType = {
3
+ name: "listItemContent";
4
+ attrs?: {
5
+ listItemType: string;
6
+ };
7
+ };
8
+ export declare const ListItemContent: Node<any, any>;
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ export declare const OrderedListItemIndexPlugin: () => Plugin<any>;
@@ -0,0 +1,6 @@
1
+ import { Node } from "@tiptap/core";
2
+ export declare type TextContentType = {
3
+ name: "textContent";
4
+ attrs?: {};
5
+ };
6
+ export declare const TextContent: Node<any, any>;
@@ -1,5 +1,8 @@
1
1
  import { Extension } from "@tiptap/core";
2
+ import { BubbleMenuFactory } from "./BubbleMenuFactoryTypes";
2
3
  /**
3
4
  * The menu that is displayed when selecting a piece of text.
4
5
  */
5
- export declare const BubbleMenuExtension: Extension<{}, any>;
6
+ export declare const BubbleMenuExtension: Extension<{
7
+ bubbleMenuFactory: BubbleMenuFactory;
8
+ }, any>;
@@ -0,0 +1,27 @@
1
+ import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
+ export declare type BubbleMenuParams = {
3
+ boldIsActive: boolean;
4
+ toggleBold: () => void;
5
+ italicIsActive: boolean;
6
+ toggleItalic: () => void;
7
+ underlineIsActive: boolean;
8
+ toggleUnderline: () => void;
9
+ strikeIsActive: boolean;
10
+ toggleStrike: () => void;
11
+ hyperlinkIsActive: boolean;
12
+ activeHyperlinkUrl: string;
13
+ activeHyperlinkText: string;
14
+ setHyperlink: (url: string, text?: string) => void;
15
+ paragraphIsActive: boolean;
16
+ setParagraph: () => void;
17
+ headingIsActive: boolean;
18
+ activeHeadingLevel: string;
19
+ setHeading: (level: string) => void;
20
+ setListItem: (type: string) => void;
21
+ listItemIsActive: boolean;
22
+ activeListItemType: string;
23
+ selectionBoundingBox: DOMRect;
24
+ editorElement: Element;
25
+ };
26
+ export declare type BubbleMenu = EditorElement<BubbleMenuParams>;
27
+ export declare type BubbleMenuFactory = ElementFactory<BubbleMenuParams>;
@@ -1,12 +1,11 @@
1
1
  import { Editor } from "@tiptap/core";
2
2
  import { EditorState, Plugin, PluginKey } from "prosemirror-state";
3
3
  import { EditorView } from "prosemirror-view";
4
- import { Instance, Props } from "tippy.js";
4
+ import { BubbleMenu, BubbleMenuFactory, BubbleMenuParams } from "./BubbleMenuFactoryTypes";
5
5
  export interface BubbleMenuPluginProps {
6
- pluginKey: PluginKey | string;
6
+ pluginKey: PluginKey;
7
7
  editor: Editor;
8
- element: HTMLElement;
9
- tippyOptions?: Partial<Props>;
8
+ bubbleMenuFactory: BubbleMenuFactory;
10
9
  shouldShow?: ((props: {
11
10
  editor: Editor;
12
11
  view: EditorView;
@@ -21,15 +20,14 @@ export declare type BubbleMenuViewProps = BubbleMenuPluginProps & {
21
20
  };
22
21
  export declare class BubbleMenuView {
23
22
  editor: Editor;
24
- element: HTMLElement;
25
23
  view: EditorView;
24
+ bubbleMenuParams: BubbleMenuParams;
25
+ bubbleMenu: BubbleMenu;
26
26
  preventHide: boolean;
27
27
  preventShow: boolean;
28
- tippy: Instance | undefined;
29
- tippyOptions?: Partial<Props>;
28
+ menuIsOpen: boolean;
30
29
  shouldShow: Exclude<BubbleMenuPluginProps["shouldShow"], null>;
31
- constructor({ editor, element, view, tippyOptions, shouldShow, }: BubbleMenuViewProps);
32
- mousedownHandler: () => void;
30
+ constructor({ editor, bubbleMenuFactory, view, shouldShow, }: BubbleMenuViewProps);
33
31
  viewMousedownHandler: () => void;
34
32
  viewMouseupHandler: () => void;
35
33
  dragstartHandler: () => void;
@@ -37,10 +35,10 @@ export declare class BubbleMenuView {
37
35
  blurHandler: ({ event }: {
38
36
  event: FocusEvent;
39
37
  }) => void;
40
- createTooltip(): void;
41
38
  update(view: EditorView, oldState?: EditorState): void;
42
- show(): void;
43
- hide(): void;
44
39
  destroy(): void;
40
+ getSelectionBoundingBox(): DOMRect;
41
+ initBubbleMenuParams(): BubbleMenuParams;
42
+ updateBubbleMenuParams(): void;
45
43
  }
46
44
  export declare const createBubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any>;
@@ -0,0 +1,12 @@
1
+ import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
+ export declare type BlockMenuParams = {
3
+ addBlock: () => void;
4
+ deleteBlock: () => void;
5
+ blockDragStart: (event: DragEvent) => void;
6
+ blockDragEnd: () => void;
7
+ freezeMenu: () => void;
8
+ unfreezeMenu: () => void;
9
+ blockBoundingBox: DOMRect;
10
+ };
11
+ export declare type BlockMenu = EditorElement<BlockMenuParams>;
12
+ export declare type BlockMenuFactory = ElementFactory<BlockMenuParams>;
@@ -0,0 +1,14 @@
1
+ import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
+ export declare type BlockSideMenuStaticParams = {
3
+ addBlock: () => void;
4
+ deleteBlock: () => void;
5
+ blockDragStart: (event: DragEvent) => void;
6
+ blockDragEnd: () => void;
7
+ freezeMenu: () => void;
8
+ unfreezeMenu: () => void;
9
+ };
10
+ export declare type BlockSideMenuDynamicParams = {
11
+ blockBoundingBox: DOMRect;
12
+ };
13
+ export declare type BlockSideMenu = EditorElement<BlockSideMenuDynamicParams>;
14
+ export declare type BlockSideMenuFactory = ElementFactory<BlockSideMenuStaticParams, BlockSideMenuDynamicParams>;
@@ -0,0 +1,18 @@
1
+ import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
+ export declare type AddBlockButtonParams = {
3
+ addBlock: () => void;
4
+ blockBoundingBox: DOMRect;
5
+ };
6
+ export declare type AddBlockButton = EditorElement<AddBlockButtonParams>;
7
+ export declare type AddBlockButtonFactory = ElementFactory<AddBlockButtonParams>;
8
+ export declare type DragHandleParams = {
9
+ blockBoundingBox: DOMRect;
10
+ };
11
+ export declare type DragHandle = EditorElement<DragHandleParams>;
12
+ export declare type DragHandleFactory = ElementFactory<DragHandleParams>;
13
+ export declare type DragHandleMenuParams = {
14
+ deleteBlock: () => void;
15
+ dragHandleBoundingBox: DOMRect;
16
+ };
17
+ export declare type DragHandleMenu = EditorElement<DragHandleMenuParams>;
18
+ export declare type DragHandleMenuFactory = ElementFactory<DragHandleMenuParams>;
@@ -1,7 +1,13 @@
1
- import { Extension } from "@tiptap/core";
1
+ import { Editor, Extension } from "@tiptap/core";
2
+ import { BlockSideMenuFactory } from "./BlockSideMenuFactoryTypes";
3
+ export declare type DraggableBlocksOptions = {
4
+ editor: Editor;
5
+ blockSideMenuFactory: BlockSideMenuFactory;
6
+ };
2
7
  /**
3
- * This extension adds a drag handle in front of all nodes with a "data-id" attribute
8
+ * This extension adds a menu to the side of blocks which features various BlockNote functions such as adding and
9
+ * removing blocks. More importantly, it adds a drag handle which allows the user to drag and drop blocks.
4
10
  *
5
11
  * code based on https://github.com/ueberdosis/tiptap/issues/323#issuecomment-506637799
6
12
  */
7
- export declare const DraggableBlocksExtension: Extension<{}, any>;
13
+ export declare const DraggableBlocksExtension: Extension<DraggableBlocksOptions, any>;
@@ -1,4 +1,7 @@
1
+ import { Editor } from "@tiptap/core";
1
2
  import { Plugin } from "prosemirror-state";
3
+ import { DraggableBlocksOptions } from "./DraggableBlocksExtension";
4
+ import { BlockSideMenu, BlockSideMenuDynamicParams, BlockSideMenuFactory, BlockSideMenuStaticParams } from "./BlockSideMenuFactoryTypes";
2
5
  export declare function createRect(rect: DOMRect): {
3
6
  left: number;
4
7
  top: number;
@@ -15,4 +18,23 @@ export declare function absoluteRect(element: HTMLElement): {
15
18
  bottom: number;
16
19
  right: number;
17
20
  };
18
- export declare const createDraggableBlocksPlugin: () => Plugin<any>;
21
+ export declare type BlockMenuViewProps = {
22
+ editor: Editor;
23
+ blockMenuFactory: BlockSideMenuFactory;
24
+ horizontalPosAnchoredAtRoot: boolean;
25
+ };
26
+ export declare class BlockMenuView {
27
+ editor: Editor;
28
+ horizontalPosAnchoredAtRoot: boolean;
29
+ blockMenu: BlockSideMenu;
30
+ hoveredBlock: HTMLElement | undefined;
31
+ menuOpen: boolean;
32
+ menuFrozen: boolean;
33
+ constructor({ editor, blockMenuFactory, horizontalPosAnchoredAtRoot, }: BlockMenuViewProps);
34
+ destroy(): void;
35
+ addBlock(): void;
36
+ deleteBlock(): void;
37
+ getStaticParams(): BlockSideMenuStaticParams;
38
+ getDynamicParams(): BlockSideMenuDynamicParams;
39
+ }
40
+ export declare const createDraggableBlocksPlugin: (options: DraggableBlocksOptions) => Plugin<any>;
@@ -0,0 +1,8 @@
1
+ import { Extension } from "@tiptap/core";
2
+ import { FormattingToolbarFactory } from "./FormattingToolbarFactoryTypes";
3
+ /**
4
+ * The menu that is displayed when selecting a piece of text.
5
+ */
6
+ export declare const FormattingToolbarExtension: Extension<{
7
+ formattingToolbarFactory: FormattingToolbarFactory;
8
+ }, any>;
@@ -0,0 +1,23 @@
1
+ import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
+ import { BlockContentType } from "../Blocks/nodes/Block";
3
+ export declare type FormattingToolbarStaticParams = {
4
+ toggleBold: () => void;
5
+ toggleItalic: () => void;
6
+ toggleUnderline: () => void;
7
+ toggleStrike: () => void;
8
+ setHyperlink: (url: string, text?: string) => void;
9
+ setBlockType: (type: BlockContentType) => void;
10
+ };
11
+ export declare type FormattingToolbarDynamicParams = {
12
+ boldIsActive: boolean;
13
+ italicIsActive: boolean;
14
+ underlineIsActive: boolean;
15
+ strikeIsActive: boolean;
16
+ hyperlinkIsActive: boolean;
17
+ activeHyperlinkUrl: string;
18
+ activeHyperlinkText: string;
19
+ activeBlockType: Required<BlockContentType>;
20
+ selectionBoundingBox: DOMRect;
21
+ };
22
+ export declare type FormattingToolbar = EditorElement<FormattingToolbarDynamicParams>;
23
+ export declare type FormattingToolbarFactory = ElementFactory<FormattingToolbarStaticParams, FormattingToolbarDynamicParams>;
@@ -0,0 +1,43 @@
1
+ import { Editor } from "@tiptap/core";
2
+ import { EditorState, Plugin, PluginKey } from "prosemirror-state";
3
+ import { EditorView } from "prosemirror-view";
4
+ import { FormattingToolbar, FormattingToolbarDynamicParams, FormattingToolbarFactory, FormattingToolbarStaticParams } from "./FormattingToolbarFactoryTypes";
5
+ export interface FormattingToolbarPluginProps {
6
+ pluginKey: PluginKey;
7
+ editor: Editor;
8
+ formattingToolbarFactory: FormattingToolbarFactory;
9
+ shouldShow?: ((props: {
10
+ editor: Editor;
11
+ view: EditorView;
12
+ state: EditorState;
13
+ oldState?: EditorState;
14
+ from: number;
15
+ to: number;
16
+ }) => boolean) | null;
17
+ }
18
+ export declare type FormattingToolbarViewProps = FormattingToolbarPluginProps & {
19
+ view: EditorView;
20
+ };
21
+ export declare class FormattingToolbarView {
22
+ editor: Editor;
23
+ view: EditorView;
24
+ formattingToolbar: FormattingToolbar;
25
+ preventHide: boolean;
26
+ preventShow: boolean;
27
+ toolbarIsOpen: boolean;
28
+ shouldShow: Exclude<FormattingToolbarPluginProps["shouldShow"], null>;
29
+ constructor({ editor, formattingToolbarFactory, view, shouldShow, }: FormattingToolbarViewProps);
30
+ viewMousedownHandler: () => void;
31
+ viewMouseupHandler: () => void;
32
+ dragstartHandler: () => void;
33
+ focusHandler: () => void;
34
+ blurHandler: ({ event }: {
35
+ event: FocusEvent;
36
+ }) => void;
37
+ update(view: EditorView, oldState?: EditorState): void;
38
+ destroy(): void;
39
+ getSelectionBoundingBox(): DOMRect;
40
+ getStaticParams(): FormattingToolbarStaticParams;
41
+ getDynamicParams(): FormattingToolbarDynamicParams;
42
+ }
43
+ export declare const createFormattingToolbarPlugin: (options: FormattingToolbarPluginProps) => Plugin<any>;
@@ -0,0 +1,8 @@
1
+ import { HyperlinkToolbarPluginProps } from "./HyperlinkToolbarPlugin";
2
+ /**
3
+ * This custom link includes a special menu for editing/deleting/opening the link.
4
+ * The menu will be triggered by hovering over the link with the mouse,
5
+ * or by moving the cursor inside the link text
6
+ */
7
+ declare const Hyperlink: import("@tiptap/core").Mark<HyperlinkToolbarPluginProps, any>;
8
+ export default Hyperlink;
@@ -0,0 +1,12 @@
1
+ import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
+ export declare type HyperlinkToolbarStaticParams = {
3
+ editHyperlink: (url: string, text: string) => void;
4
+ deleteHyperlink: () => void;
5
+ };
6
+ export declare type HyperlinkToolbarDynamicParams = {
7
+ url: string;
8
+ text: string;
9
+ boundingBox: DOMRect;
10
+ };
11
+ export declare type HyperlinkToolbar = EditorElement<HyperlinkToolbarDynamicParams>;
12
+ export declare type HyperlinkToolbarFactory = ElementFactory<HyperlinkToolbarStaticParams, HyperlinkToolbarDynamicParams>;
@@ -0,0 +1,11 @@
1
+ import { Editor } from "@tiptap/core";
2
+ import { Plugin } from "prosemirror-state";
3
+ import { HyperlinkToolbarFactory } from "./HyperlinkToolbarFactoryTypes";
4
+ export declare type HyperlinkToolbarPluginProps = {
5
+ hyperlinkToolbarFactory: HyperlinkToolbarFactory;
6
+ };
7
+ export declare type HyperlinkToolbarViewProps = {
8
+ editor: Editor;
9
+ hyperlinkToolbarFactory: HyperlinkToolbarFactory;
10
+ };
11
+ export declare const createHyperlinkToolbarPlugin: (editor: Editor, options: HyperlinkToolbarPluginProps) => Plugin<any>;
@@ -1,7 +1,8 @@
1
+ import { HyperlinkMenuPluginProps } from "./HyperlinkMenuPlugin";
1
2
  /**
2
3
  * This custom link includes a special menu for editing/deleting/opening the link.
3
4
  * The menu will be triggered by hovering over the link with the mouse,
4
5
  * or by moving the cursor inside the link text
5
6
  */
6
- declare const Hyperlink: import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any>;
7
+ declare const Hyperlink: import("@tiptap/core").Mark<HyperlinkMenuPluginProps, any>;
7
8
  export default Hyperlink;
@@ -0,0 +1,11 @@
1
+ import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
+ export declare type HyperlinkMenuParams = {
3
+ url: string;
4
+ text: string;
5
+ editHyperlink: (url: string, text: string) => void;
6
+ deleteHyperlink: () => void;
7
+ boundingBox: DOMRect;
8
+ editorElement: Element;
9
+ };
10
+ export declare type HyperlinkMenu = EditorElement<HyperlinkMenuParams>;
11
+ export declare type HyperlinkMenuFactory = ElementFactory<HyperlinkMenuParams>;
@@ -1,2 +1,11 @@
1
+ import { Editor } from "@tiptap/core";
1
2
  import { Plugin } from "prosemirror-state";
2
- export declare const createHyperlinkMenuPlugin: () => Plugin<any>;
3
+ import { HyperlinkMenuFactory } from "./HyperlinkMenuFactoryTypes";
4
+ export declare type HyperlinkMenuPluginProps = {
5
+ hyperlinkMenuFactory: HyperlinkMenuFactory;
6
+ };
7
+ export declare type HyperlinkMenuViewProps = {
8
+ editor: Editor;
9
+ hyperlinkMenuFactory: HyperlinkMenuFactory;
10
+ };
11
+ export declare const createHyperlinkMenuPlugin: (editor: Editor, options: HyperlinkMenuPluginProps) => Plugin<any>;
@@ -1,10 +1,12 @@
1
1
  import { Extension } from "@tiptap/core";
2
- import { SlashMenuItem } from "./SlashMenuItem";
3
2
  import { PluginKey } from "prosemirror-state";
3
+ import { SuggestionsMenuFactory } from "../../shared/plugins/suggestion/SuggestionsMenuFactoryTypes";
4
+ import { SlashMenuItem } from "./SlashMenuItem";
4
5
  export declare type SlashMenuOptions = {
5
6
  commands: {
6
7
  [key: string]: SlashMenuItem;
7
8
  };
9
+ slashMenuFactory: SuggestionsMenuFactory<any> | undefined;
8
10
  };
9
11
  export declare const SlashMenuPluginKey: PluginKey<any>;
10
12
  export declare const SlashMenuExtension: Extension<SlashMenuOptions, any>;
@@ -1,6 +1,5 @@
1
1
  import { Editor, Range } from "@tiptap/core";
2
- import SuggestionItem from "../../shared/plugins/suggestion/SuggestionItem";
3
- import { IconType } from "react-icons";
2
+ import { SuggestionItem } from "../../shared/plugins/suggestion/SuggestionItem";
4
3
  export declare type SlashMenuCallback = (editor: Editor, range: Range) => boolean;
5
4
  export declare enum SlashMenuGroups {
6
5
  HEADINGS = "Headings",
@@ -20,7 +19,6 @@ export declare class SlashMenuItem implements SuggestionItem {
20
19
  readonly group: SlashMenuGroups;
21
20
  readonly execute: SlashMenuCallback;
22
21
  readonly aliases: string[];
23
- readonly icon?: IconType | undefined;
24
22
  readonly hint?: string | undefined;
25
23
  readonly shortcut?: string | undefined;
26
24
  groupName: string;
@@ -35,6 +33,6 @@ export declare class SlashMenuItem implements SuggestionItem {
35
33
  * @param hint Short description of command
36
34
  * @param shortcut Info about keyboard shortcut that would activate this command
37
35
  */
38
- constructor(name: string, group: SlashMenuGroups, execute: SlashMenuCallback, aliases?: string[], icon?: IconType | undefined, hint?: string | undefined, shortcut?: string | undefined);
36
+ constructor(name: string, group: SlashMenuGroups, execute: SlashMenuCallback, aliases?: string[], hint?: string | undefined, shortcut?: string | undefined);
39
37
  match(query: string): boolean;
40
38
  }
@@ -1,4 +1,9 @@
1
- import "./globals.css";
1
+ export * from "./BlockNoteEditor";
2
2
  export * from "./BlockNoteExtensions";
3
- export * from "./EditorContent";
4
- export * from "./useEditor";
3
+ export type { BlockContentType } from "./extensions/Blocks/nodes/Block";
4
+ export * from "./extensions/FormattingToolbar/FormattingToolbarFactoryTypes";
5
+ export * from "./extensions/DraggableBlocks/BlockSideMenuFactoryTypes";
6
+ export * from "./extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes";
7
+ export * from "./extensions/SlashMenu/SlashMenuItem";
8
+ export type { SuggestionItem } from "./shared/plugins/suggestion/SuggestionItem";
9
+ export * from "./shared/plugins/suggestion/SuggestionsMenuFactoryTypes";
@@ -0,0 +1,6 @@
1
+ export declare type EditorElement<ElementDynamicParams extends Record<string, any>> = {
2
+ element: HTMLElement | undefined;
3
+ render: (params: ElementDynamicParams, isHidden: boolean) => void;
4
+ hide: () => void;
5
+ };
6
+ export declare type ElementFactory<ElementStaticParams extends Record<string, any>, ElementDynamicParams extends Record<string, any>> = (staticParams: ElementStaticParams) => EditorElement<ElementDynamicParams>;
@@ -1,8 +1,7 @@
1
- import { IconType } from "react-icons";
2
1
  /**
3
2
  * A generic interface used in all suggestion menus (slash menu, mentions, etc)
4
3
  */
5
- export default interface SuggestionItem {
4
+ export interface SuggestionItem {
6
5
  /**
7
6
  * The name of the item
8
7
  */
@@ -11,10 +10,6 @@ export default interface SuggestionItem {
11
10
  * The name of the group to which this item belongs
12
11
  */
13
12
  groupName: string;
14
- /**
15
- * The react icon
16
- */
17
- icon?: IconType;
18
13
  hint?: string;
19
14
  shortcut?: string;
20
15
  /**
@@ -1,6 +1,7 @@
1
1
  import { Editor, Range } from "@tiptap/core";
2
2
  import { Plugin, PluginKey, Selection } from "prosemirror-state";
3
- import SuggestionItem from "./SuggestionItem";
3
+ import { SuggestionsMenuFactory } from "./SuggestionsMenuFactoryTypes";
4
+ import { SuggestionItem } from "./SuggestionItem";
4
5
  export declare type SuggestionPluginOptions<T extends SuggestionItem> = {
5
6
  /**
6
7
  * The name of the plugin.
@@ -16,6 +17,7 @@ export declare type SuggestionPluginOptions<T extends SuggestionItem> = {
16
17
  * The character that should trigger the suggestion menu to pop up (e.g. a '/' for commands)
17
18
  */
18
19
  char: string;
20
+ suggestionsMenuFactory: SuggestionsMenuFactory<T>;
19
21
  /**
20
22
  * The callback that gets executed when an item is selected by the user.
21
23
  *
@@ -37,6 +39,16 @@ export declare type SuggestionPluginOptions<T extends SuggestionItem> = {
37
39
  range: Range;
38
40
  }) => boolean;
39
41
  };
42
+ declare type SuggestionPluginState<T extends SuggestionItem> = {
43
+ active: boolean;
44
+ range: Range | null;
45
+ query: string | null;
46
+ notFoundCount: number;
47
+ items: T[];
48
+ selectedItemIndex: number;
49
+ type: string;
50
+ decorationId: string | null;
51
+ };
40
52
  export declare type MenuType = "slash" | "drag";
41
53
  /**
42
54
  * Finds a command: a specified character (e.g. '/') followed by a string of characters (all characters except the specified character are allowed).
@@ -63,12 +75,5 @@ export declare function findCommandBeforeCursor(char: string, selection: Selecti
63
75
  * @param options options for configuring the plugin
64
76
  * @returns the prosemirror plugin
65
77
  */
66
- export declare function createSuggestionPlugin<T extends SuggestionItem>({ pluginKey, editor, char, onSelectItem: selectItemCallback, items, }: SuggestionPluginOptions<T>): Plugin<{
67
- active: boolean;
68
- range: any;
69
- query: string | null;
70
- notFoundCount: number;
71
- items: T[];
72
- type: string;
73
- decorationId: string | null;
74
- }>;
78
+ export declare function createSuggestionPlugin<T extends SuggestionItem>({ pluginKey, editor, char, suggestionsMenuFactory, onSelectItem: selectItemCallback, items, }: SuggestionPluginOptions<T>): Plugin<SuggestionPluginState<T>>;
79
+ export {};
@@ -0,0 +1,12 @@
1
+ import { EditorElement, ElementFactory } from "../../EditorElement";
2
+ import { SuggestionItem } from "./SuggestionItem";
3
+ export declare type SuggestionsMenuStaticParams<T extends SuggestionItem> = {
4
+ itemCallback: (item: T) => void;
5
+ };
6
+ export declare type SuggestionsMenuDynamicParams<T extends SuggestionItem> = {
7
+ items: T[];
8
+ selectedItemIndex: number;
9
+ queryStartBoundingBox: DOMRect;
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>>;
@@ -0,0 +1,2 @@
1
+ export declare const isAppleOS: () => boolean;
2
+ export declare function formatKeyboardShortcut(shortcut: string): string;