@blocknote/core 0.9.0 → 0.9.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.
Files changed (37) hide show
  1. package/dist/blocknote.js +337 -298
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +5 -4
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/package.json +2 -2
  6. package/src/BlockNoteEditor.ts +2 -2
  7. package/src/BlockNoteExtensions.ts +24 -22
  8. package/src/api/blockManipulation/blockManipulation.test.ts +2 -2
  9. package/src/api/blockManipulation/blockManipulation.ts +1 -1
  10. package/src/api/formatConversions/formatConversions.test.ts +2 -2
  11. package/src/api/formatConversions/formatConversions.ts +47 -3
  12. package/src/api/nodeConversions/nodeConversions.test.ts +6 -6
  13. package/src/api/nodeConversions/nodeConversions.ts +6 -6
  14. package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +2 -2
  15. package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +27 -5
  16. package/src/extensions/Blocks/nodes/BlockContainer.ts +5 -5
  17. package/src/extensions/SideMenu/MultipleNodeSelection.ts +3 -3
  18. package/src/extensions/SideMenu/SideMenuPlugin.ts +9 -9
  19. package/src/extensions/UniqueID/UniqueID.ts +10 -9
  20. package/src/shared/EventEmitter.ts +1 -0
  21. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +6 -2
  22. package/types/src/extensions/Blocks/helpers/getBlockInfoFromPos.d.ts +9 -1
  23. package/types/src/extensions/Blocks/nodes/TableCell.d.ts +5 -0
  24. package/types/src/extensions/Blocks/nodes/TableRow.d.ts +5 -0
  25. package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +1 -1
  26. package/types/src/EventEmitter.d.ts +0 -11
  27. package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +0 -0
  28. package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +0 -16
  29. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +0 -55
  30. package/types/src/extensions/DraggableBlocks/MultipleNodeSelection.d.ts +0 -24
  31. package/types/src/extensions/FormattingToolbar/FormattingToolbarExtension.d.ts +0 -11
  32. package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +0 -10
  33. package/types/src/extensions/HyperlinkToolbar/HyperlinkMark.d.ts +0 -8
  34. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +0 -0
  35. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +0 -13
  36. package/types/src/extensions/SlashMenu/index.d.ts +0 -3
  37. package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +0 -12
@@ -1,16 +0,0 @@
1
- import { Editor, Extension } from "@tiptap/core";
2
- import { BlockSideMenuFactory } from "./BlockSideMenuFactoryTypes";
3
- import { BlockNoteEditor } from "../../BlockNoteEditor";
4
- import { BlockSchema } from "../Blocks/api/blockTypes";
5
- export type DraggableBlocksOptions<BSchema extends BlockSchema> = {
6
- tiptapEditor: Editor;
7
- editor: BlockNoteEditor<BSchema>;
8
- blockSideMenuFactory: BlockSideMenuFactory<BSchema>;
9
- };
10
- /**
11
- * This extension adds a menu to the side of blocks which features various BlockNote functions such as adding and
12
- * removing blocks. More importantly, it adds a drag handle which allows the user to drag and drop blocks.
13
- *
14
- * code based on https://github.com/ueberdosis/tiptap/issues/323#issuecomment-506637799
15
- */
16
- export declare const createDraggableBlocksExtension: <BSchema extends Record<string, import("../Blocks/api/blockTypes").BlockSpec<string, import("../Blocks/api/blockTypes").PropSchema>>>() => Extension<DraggableBlocksOptions<BSchema>, any>;
@@ -1,55 +0,0 @@
1
- import { PluginView } from "@tiptap/pm/state";
2
- import { Plugin, PluginKey } from "prosemirror-state";
3
- import { BlockNoteEditor } from "../../BlockNoteEditor";
4
- import { BaseUiElementCallbacks, BaseUiElementState } from "../../shared/BaseUiElementTypes";
5
- import { Block, BlockSchema } from "../Blocks/api/blockTypes";
6
- import { Editor } from "@tiptap/core";
7
- export type SideMenuCallbacks = BaseUiElementCallbacks & {
8
- addBlock: () => void;
9
- freezeMenu: () => void;
10
- unfreezeMenu: () => void;
11
- blockDragStart: (event: DragEvent) => void;
12
- blockDragEnd: () => void;
13
- };
14
- export type SideMenuState<BSchema extends BlockSchema> = BaseUiElementState & {
15
- block: Block<BSchema>;
16
- };
17
- export declare class SideMenuView<BSchema extends BlockSchema> implements PluginView {
18
- editor: BlockNoteEditor<BSchema>;
19
- ttEditor: Editor;
20
- private sideMenuState?;
21
- updateSideMenu: () => void;
22
- horizontalPosAnchoredAtRoot: boolean;
23
- horizontalPosAnchor: number;
24
- hoveredBlock: HTMLElement | undefined;
25
- isDragging: boolean;
26
- menuFrozen: boolean;
27
- constructor(editor: BlockNoteEditor<BSchema>, tiptapEditor: Editor, updateSideMenu: (sideMenuState: SideMenuState<BSchema>) => void);
28
- /**
29
- * Sets isDragging when dragging text.
30
- */
31
- onDragStart: () => void;
32
- /**
33
- * If the event is outside the editor contents,
34
- * we dispatch a fake event, so that we can still drop the content
35
- * when dragging / dropping to the side of the editor
36
- */
37
- onDrop: (event: DragEvent) => void;
38
- /**
39
- * If the event is outside the editor contents,
40
- * we dispatch a fake event, so that we can still drop the content
41
- * when dragging / dropping to the side of the editor
42
- */
43
- onDragOver: (event: DragEvent) => void;
44
- onKeyDown: (_event: KeyboardEvent) => void;
45
- onMouseDown: (_event: MouseEvent) => void;
46
- onMouseMove: (event: MouseEvent) => void;
47
- onScroll: () => void;
48
- destroy(): void;
49
- addBlock(): void;
50
- }
51
- export declare const sideMenuPluginKey: PluginKey<any>;
52
- export declare function setupSideMenu<BSchema extends BlockSchema>(editor: BlockNoteEditor<BSchema>, tiptapEditor: Editor, updateSideMenu: (sideMenuState: SideMenuState<BSchema>) => void): {
53
- plugin: Plugin;
54
- callbacks: Omit<SideMenuCallbacks, "destroy">;
55
- };
@@ -1,24 +0,0 @@
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,11 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import { BlockNoteEditor, BlockSchema } from "../..";
3
- import { FormattingToolbarFactory } from "./FormattingToolbarFactoryTypes";
4
- export type FormattingToolbarOptions<BSchema extends BlockSchema> = {
5
- formattingToolbarFactory: FormattingToolbarFactory<BSchema>;
6
- editor: BlockNoteEditor<BSchema>;
7
- };
8
- /**
9
- * The menu that is displayed when selecting a piece of text.
10
- */
11
- export declare const createFormattingToolbarExtension: <BSchema extends Record<string, import("../..").BlockSpec<string, import("../..").PropSchema>>>() => Extension<FormattingToolbarOptions<BSchema>, any>;
@@ -1,10 +0,0 @@
1
- import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
- import { BlockNoteEditor } from "../../BlockNoteEditor";
3
- import { BlockSchema } from "../Blocks/api/blockTypes";
4
- export type FormattingToolbarStaticParams<BSchema extends BlockSchema> = {
5
- editor: BlockNoteEditor<BSchema>;
6
- getReferenceRect: () => DOMRect;
7
- };
8
- export type FormattingToolbarDynamicParams = {};
9
- export type FormattingToolbar = EditorElement<FormattingToolbarDynamicParams>;
10
- export type FormattingToolbarFactory<BSchema extends BlockSchema> = ElementFactory<FormattingToolbarStaticParams<BSchema>, FormattingToolbarDynamicParams>;
@@ -1,8 +0,0 @@
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;
@@ -1,13 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import { PluginKey } from "prosemirror-state";
3
- import { SuggestionsMenuFactory } from "../../shared/plugins/suggestion/SuggestionsMenuFactoryTypes";
4
- import { BaseSlashMenuItem } from "./BaseSlashMenuItem";
5
- import { BlockNoteEditor } from "../../BlockNoteEditor";
6
- import { BlockSchema } from "../Blocks/api/blockTypes";
7
- export type SlashMenuOptions<BSchema extends BlockSchema> = {
8
- editor: BlockNoteEditor<BSchema> | undefined;
9
- commands: BaseSlashMenuItem<BSchema>[] | undefined;
10
- slashMenuFactory: SuggestionsMenuFactory<any> | undefined;
11
- };
12
- export declare const SlashMenuPluginKey: PluginKey<any>;
13
- export declare const createSlashMenuExtension: <BSchema extends Record<string, import("../Blocks/api/blockTypes").BlockSpec<string, import("../Blocks/api/blockTypes").PropSchema>>>() => Extension<SlashMenuOptions<BSchema>, any>;
@@ -1,3 +0,0 @@
1
- import { getDefaultSlashMenuItems } from "./defaultSlashMenuItems";
2
- import { BaseSlashMenuItem } from "./BaseSlashMenuItem";
3
- export { getDefaultSlashMenuItems, BaseSlashMenuItem };
@@ -1,12 +0,0 @@
1
- import { EditorElement, ElementFactory } from "../../EditorElement";
2
- import { SuggestionItem } from "./SuggestionItem";
3
- export type SuggestionsMenuStaticParams<T extends SuggestionItem> = {
4
- itemCallback: (item: T) => void;
5
- getReferenceRect: () => DOMRect;
6
- };
7
- export type SuggestionsMenuDynamicParams<T extends SuggestionItem> = {
8
- items: T[];
9
- keyboardHoveredItemIndex: number;
10
- };
11
- export type SuggestionsMenu<T extends SuggestionItem> = EditorElement<SuggestionsMenuDynamicParams<T>>;
12
- export type SuggestionsMenuFactory<T extends SuggestionItem> = ElementFactory<SuggestionsMenuStaticParams<T>, SuggestionsMenuDynamicParams<T>>;