@blocknote/core 0.4.0 → 0.4.3

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 (87) hide show
  1. package/dist/blocknote.js +12371 -12268
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +20 -20
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +2 -2
  7. package/src/BlockNoteEditor.ts +237 -14
  8. package/src/BlockNoteExtensions.ts +19 -15
  9. package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +616 -0
  10. package/src/api/blockManipulation/blockManipulation.test.ts +172 -0
  11. package/src/api/blockManipulation/blockManipulation.ts +25 -14
  12. package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +346 -0
  13. package/src/api/formatConversions/formatConversions.test.ts +766 -0
  14. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +268 -0
  15. package/src/api/nodeConversions/nodeConversions.test.ts +244 -0
  16. package/src/api/nodeConversions/nodeConversions.ts +167 -58
  17. package/src/api/nodeConversions/testUtil.ts +61 -0
  18. package/src/api/util/nodeUtil.ts +38 -0
  19. package/src/editor.module.css +1 -0
  20. package/src/extensions/Blocks/api/blockTypes.ts +14 -9
  21. package/src/extensions/Blocks/api/cursorPositionTypes.ts +2 -0
  22. package/src/extensions/Blocks/api/inlineContentTypes.ts +27 -36
  23. package/src/extensions/Blocks/nodes/Block.module.css +39 -36
  24. package/src/extensions/Blocks/nodes/BlockContainer.ts +15 -14
  25. package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +149 -87
  26. package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +31 -0
  27. package/src/extensions/SlashMenu/SlashMenuExtension.ts +10 -7
  28. package/src/extensions/SlashMenu/{defaultSlashCommands.tsx → defaultSlashMenuItems.tsx} +59 -106
  29. package/src/extensions/SlashMenu/index.ts +3 -7
  30. package/src/index.ts +2 -3
  31. package/src/shared/plugins/suggestion/SuggestionItem.ts +2 -13
  32. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +31 -18
  33. package/src/shared/utils.ts +6 -0
  34. package/types/src/BlockNoteEditor.d.ts +82 -8
  35. package/types/src/BlockNoteExtensions.d.ts +5 -4
  36. package/types/src/api/Editor.d.ts +26 -6
  37. package/types/src/api/blockManipulation/blockManipulation.d.ts +5 -5
  38. package/types/src/api/blockManipulation/blockManipulation.test.d.ts +1 -0
  39. package/types/src/api/formatConversions/formatConversions.test.d.ts +1 -0
  40. package/types/src/api/nodeConversions/nodeConversions.d.ts +11 -4
  41. package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
  42. package/types/src/api/nodeConversions/testUtil.d.ts +2 -0
  43. package/types/src/api/util/nodeUtil.d.ts +8 -0
  44. package/types/src/extensions/Blocks/api/blockTypes.d.ts +10 -9
  45. package/types/src/extensions/Blocks/api/cursorPositionTypes.d.ts +2 -0
  46. package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +25 -19
  47. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +15 -0
  48. package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +20 -0
  49. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +4 -2
  50. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +5 -0
  51. package/types/src/extensions/SlashMenu/index.d.ts +3 -3
  52. package/types/src/index.d.ts +2 -3
  53. package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +3 -11
  54. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +4 -4
  55. package/types/src/shared/utils.d.ts +3 -0
  56. package/src/api/Editor.ts +0 -142
  57. package/src/extensions/SlashMenu/SlashMenuItem.ts +0 -34
  58. package/types/src/EditorElement.d.ts +0 -7
  59. package/types/src/api/Document.d.ts +0 -5
  60. package/types/src/api/removeUnderlinesRehypePlugin.d.ts +0 -6
  61. package/types/src/api/simplifyBlocksRehypePlugin.d.ts +0 -16
  62. package/types/src/extensions/Blocks/BlockAttributes.d.ts +0 -2
  63. package/types/src/extensions/Blocks/MultipleNodeSelection.d.ts +0 -24
  64. package/types/src/extensions/Blocks/api/apiTypes.d.ts +0 -18
  65. package/types/src/extensions/Blocks/api/styleTypes.d.ts +0 -22
  66. package/types/src/extensions/Blocks/apiTypes.d.ts +0 -16
  67. package/types/src/extensions/Blocks/nodes/Block.d.ts +0 -24
  68. package/types/src/extensions/Blocks/nodes/BlockContent/BlockContentTypes.d.ts +0 -4
  69. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContentTypes.d.ts +0 -4
  70. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContentTypes.d.ts +0 -2
  71. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContentTypes.d.ts +0 -2
  72. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContentTypes.d.ts +0 -2
  73. package/types/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.d.ts +0 -8
  74. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.d.ts +0 -8
  75. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.d.ts +0 -2
  76. package/types/src/extensions/Blocks/nodes/BlockTypes/TextBlock/TextContent.d.ts +0 -6
  77. package/types/src/extensions/BubbleMenu/BubbleMenuExtension.d.ts +0 -8
  78. package/types/src/extensions/BubbleMenu/BubbleMenuFactoryTypes.d.ts +0 -27
  79. package/types/src/extensions/BubbleMenu/BubbleMenuPlugin.d.ts +0 -44
  80. package/types/src/extensions/DraggableBlocks/BlockMenuFactoryTypes.d.ts +0 -12
  81. package/types/src/extensions/DraggableBlocks/DragMenuFactoryTypes.d.ts +0 -18
  82. package/types/src/extensions/Hyperlinks/HyperlinkMark.d.ts +0 -8
  83. package/types/src/extensions/Hyperlinks/HyperlinkMenuFactoryTypes.d.ts +0 -11
  84. package/types/src/extensions/Hyperlinks/HyperlinkMenuPlugin.d.ts +0 -11
  85. package/types/src/extensions/Paragraph/FixedParagraph.d.ts +0 -1
  86. package/types/src/extensions/SlashMenu/defaultCommands.d.ts +0 -8
  87. package/types/src/utils.d.ts +0 -2
package/src/api/Editor.ts DELETED
@@ -1,142 +0,0 @@
1
- import { Editor as TiptapEditor } from "@tiptap/core";
2
- import { Node } from "prosemirror-model";
3
- import { getBlockInfoFromPos } from "../extensions/Blocks/helpers/getBlockInfoFromPos";
4
- import { Block, PartialBlock } from "../extensions/Blocks/api/blockTypes";
5
- import { TextCursorPosition } from "../extensions/Blocks/api/cursorPositionTypes";
6
- import { nodeToBlock } from "./nodeConversions/nodeConversions";
7
- import {
8
- insertBlocks,
9
- removeBlocks,
10
- replaceBlocks,
11
- updateBlock,
12
- } from "./blockManipulation/blockManipulation";
13
- import {
14
- blocksToHTML,
15
- blocksToMarkdown,
16
- HTMLToBlocks,
17
- markdownToBlocks,
18
- } from "./formatConversions/formatConversions";
19
-
20
- export class Editor {
21
- constructor(
22
- private tiptapEditor: TiptapEditor,
23
- private blockCache = new WeakMap<Node, Block>()
24
- ) {}
25
-
26
- /**
27
- * Gets a list of all top-level blocks that are in the editor.
28
- */
29
- public get allBlocks(): Block[] {
30
- const blocks: Block[] = [];
31
-
32
- this.tiptapEditor.state.doc.firstChild!.descendants((node) => {
33
- blocks.push(nodeToBlock(node, this.blockCache));
34
-
35
- return false;
36
- });
37
-
38
- return blocks;
39
- }
40
-
41
- /**
42
- * Gets information regarding the position of the text cursor in the editor.
43
- */
44
- public get textCursorPosition(): TextCursorPosition {
45
- const { node } = getBlockInfoFromPos(
46
- this.tiptapEditor.state.doc,
47
- this.tiptapEditor.state.selection.from
48
- )!;
49
-
50
- return { block: nodeToBlock(node, this.blockCache) };
51
- }
52
-
53
- /**
54
- * Inserts multiple blocks before, after, or nested inside an existing block in the editor.
55
- * @param blocksToInsert An array of blocks to insert.
56
- * @param blockToInsertAt An existing block, marking where the new blocks should be inserted at.
57
- * @param placement Determines whether the blocks should be inserted just before, just after, or nested inside the
58
- * existing block.
59
- */
60
- public insertBlocks(
61
- blocksToInsert: PartialBlock[],
62
- blockToInsertAt: Block,
63
- placement: "before" | "after" | "nested" = "before"
64
- ): void {
65
- insertBlocks(blocksToInsert, blockToInsertAt, placement, this.tiptapEditor);
66
- }
67
-
68
- /**
69
- * Updates a block in the editor to the given specification.
70
- * @param blockToUpdate The block that should be updated.
71
- * @param updatedBlock The specification that the block should be updated to.
72
- */
73
- public updateBlock(blockToUpdate: Block, updatedBlock: PartialBlock) {
74
- updateBlock(blockToUpdate, updatedBlock, this.tiptapEditor);
75
- }
76
-
77
- /**
78
- * Removes multiple blocks from the editor. Throws an error if any of the blocks could not be found.
79
- * @param blocksToRemove An array of blocks that should be removed.
80
- */
81
- public removeBlocks(blocksToRemove: Block[]) {
82
- removeBlocks(blocksToRemove, this.tiptapEditor);
83
- }
84
-
85
- /**
86
- * Replaces multiple blocks in the editor with several other blocks. If the provided blocks to remove are not adjacent
87
- * to each other, the new blocks are inserted at the position of the first block in the array. Throws an error if any
88
- * of the blocks could not be found.
89
- * @param blocksToRemove An array of blocks that should be replaced.
90
- * @param blocksToInsert An array of blocks to replace the old ones with.
91
- */
92
- public replaceBlocks(
93
- blocksToRemove: Block[],
94
- blocksToInsert: PartialBlock[]
95
- ) {
96
- replaceBlocks(blocksToRemove, blocksToInsert, this.tiptapEditor);
97
- }
98
-
99
- /**
100
- * Executes a callback function whenever the editor's content changes.
101
- * @param callback The callback function to execute.
102
- */
103
- public onContentChange(callback: () => void) {
104
- this.tiptapEditor.on("update", callback);
105
- }
106
-
107
- /**
108
- * Serializes a list of blocks into an HTML string. The output is not the same as what's rendered by the editor, and
109
- * is simplified in order to better conform to HTML standards. Block structuring elements are removed, children of
110
- * blocks which aren't list items are lifted out of them, and list items blocks are wrapped in `ul`/`ol` tags.
111
- * @param blocks The list of blocks to serialize into HTML.
112
- */
113
- public async blocksToHTML(blocks: Block[]): Promise<string> {
114
- return blocksToHTML(blocks, this.tiptapEditor.schema);
115
- }
116
-
117
- /**
118
- * Creates a list of blocks from an HTML string.
119
- * @param htmlString The HTML string to create a list of blocks from.
120
- */
121
- public async HTMLToBlocks(htmlString: string): Promise<Block[]> {
122
- return HTMLToBlocks(htmlString, this.tiptapEditor.schema);
123
- }
124
-
125
- /**
126
- * Serializes a list of blocks into a Markdown string. The output is simplified as Markdown does not support all
127
- * features of BlockNote. Block structuring elements are removed, children of blocks which aren't list items are
128
- * lifted out of them, and certain styles are removed.
129
- * @param blocks The list of blocks to serialize into Markdown.
130
- */
131
- public async blocksToMarkdown(blocks: Block[]): Promise<string> {
132
- return blocksToMarkdown(blocks, this.tiptapEditor.schema);
133
- }
134
-
135
- /**
136
- * Creates a list of blocks from a Markdown string.
137
- * @param markdownString The Markdown string to create a list of blocks from.
138
- */
139
- public async markdownToBlocks(markdownString: string): Promise<Block[]> {
140
- return markdownToBlocks(markdownString, this.tiptapEditor.schema);
141
- }
142
- }
@@ -1,34 +0,0 @@
1
- import { Editor, Range } from "@tiptap/core";
2
- import { SuggestionItem } from "../../shared/plugins/suggestion/SuggestionItem";
3
-
4
- /**
5
- * A class that defines a slash command (/<command>).
6
- *
7
- * Not to be confused with ProseMirror commands nor TipTap commands.
8
- */
9
- export class SlashMenuItem implements SuggestionItem {
10
- /**
11
- * Constructs a new slash-command.
12
- *
13
- * @param name The name of the command
14
- * @param execute The callback for creating a new node
15
- * @param aliases Aliases for this command
16
- */
17
- constructor(
18
- public readonly name: string,
19
- public readonly execute: (editor: Editor, range: Range) => void,
20
- public readonly aliases: string[] = [],
21
- public readonly group: string,
22
- public readonly hint?: string,
23
- public readonly shortcut?: string
24
- ) {}
25
-
26
- match(query: string): boolean {
27
- return (
28
- this.name.toLowerCase().startsWith(query.toLowerCase()) ||
29
- this.aliases.filter((alias) =>
30
- alias.toLowerCase().startsWith(query.toLowerCase())
31
- ).length !== 0
32
- );
33
- }
34
- }
@@ -1,7 +0,0 @@
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>;
@@ -1,5 +0,0 @@
1
- import { Node } from "prosemirror-model";
2
- import { EditorState } from "prosemirror-state";
3
- import { Block, Document } from "../extensions/Blocks/apiTypes";
4
- export declare function BlockFromPMNode(node: Node): Block;
5
- export declare function DocumentFromPMState(_state: EditorState): Document;
@@ -1,6 +0,0 @@
1
- import { Parent as HASTParent } from "hast";
2
- /**
3
- * Rehype plugin which removes <u> tags. Used to remove underlines before converting HTML to markdown, as Markdown
4
- * doesn't support underlines.
5
- */
6
- export declare function removeUnderlines(): (tree: HASTParent) => void;
@@ -1,16 +0,0 @@
1
- import { Parent as HASTParent } from "hast";
2
- type SimplifyBlocksOptions = {
3
- orderedListItemBlockTypes: Set<string>;
4
- unorderedListItemBlockTypes: Set<string>;
5
- };
6
- /**
7
- * Rehype plugin which converts the HTML output string rendered by BlockNote into a simplified structure which better
8
- * follows HTML standards. It does several things:
9
- * - Removes all block related div elements, leaving only the actual content inside the block.
10
- * - Lifts nested blocks to a higher level for all block types that don't represent list items.
11
- * - Wraps blocks which represent list items in corresponding ul/ol HTML elements and restructures them to comply
12
- * with HTML list structure.
13
- * @param options Options for specifying which block types represent ordered and unordered list items.
14
- */
15
- export declare function simplifyBlocks(options: SimplifyBlocksOptions): (tree: HASTParent) => void;
16
- export {};
@@ -1,2 +0,0 @@
1
- declare const BlockAttributes: Record<string, string>;
2
- export default BlockAttributes;
@@ -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,18 +0,0 @@
1
- export type BlockSpec<Type extends string, Props extends Record<string, string>> = {
2
- id: string;
3
- children: Block[];
4
- type: Type;
5
- props: Props;
6
- };
7
- export type BlockSpecUpdate<Spec> = Spec extends BlockSpec<infer Type, infer Props> ? {
8
- type: Type;
9
- props?: Partial<Props>;
10
- } : never;
11
- export type NumberedListItemBlock = BlockSpec<"numberedListItem", {}>;
12
- export type BulletListItemBlock = BlockSpec<"bulletListItem", {}>;
13
- export type HeadingBlock = BlockSpec<"heading", {
14
- level: "1" | "2" | "3";
15
- }>;
16
- export type ParagraphBlock = BlockSpec<"paragraph", {}>;
17
- export type Block = ParagraphBlock | HeadingBlock | BulletListItemBlock | NumberedListItemBlock;
18
- export type BlockUpdate = BlockSpecUpdate<Block>;
@@ -1,22 +0,0 @@
1
- export type StyleTemplate<Type extends string, Props extends Record<string, string>> = {
2
- type: Type;
3
- props: Props;
4
- };
5
- export type Bold = StyleTemplate<"bold", {}>;
6
- export type Italic = StyleTemplate<"italic", {}>;
7
- export type Underline = StyleTemplate<"underline", {}>;
8
- export type Strikethrough = StyleTemplate<"strike", {}>;
9
- export type TextColor = StyleTemplate<"textColor", {
10
- color: string;
11
- }>;
12
- export type BackgroundColor = StyleTemplate<"backgroundColor", {
13
- color: string;
14
- }>;
15
- export type Link = StyleTemplate<"link", {
16
- href: string;
17
- }>;
18
- export type Style = Bold | Italic | Underline | Strikethrough | TextColor | BackgroundColor | Link;
19
- export type StyledText = {
20
- text: string;
21
- styles: Style[];
22
- };
@@ -1,16 +0,0 @@
1
- export type BlockSpec<Type extends string, Props extends Record<string, string>> = {
2
- type: Type;
3
- props: Props;
4
- };
5
- export type BlockSpecUpdate<Spec> = Spec extends BlockSpec<infer Type, infer Props> ? {
6
- type: Type;
7
- props?: Partial<Props>;
8
- } : never;
9
- export type NumberedListItemBlock = BlockSpec<"numberedListItem", {}>;
10
- export type BulletListItemBlock = BlockSpec<"bulletListItem", {}>;
11
- export type HeadingBlock = BlockSpec<"heading", {
12
- level: "1" | "2" | "3";
13
- }>;
14
- export type ParagraphBlock = BlockSpec<"paragraph", {}>;
15
- export type Block = ParagraphBlock | HeadingBlock | BulletListItemBlock | NumberedListItemBlock;
16
- export type BlockUpdate = BlockSpecUpdate<Block>;
@@ -1,24 +0,0 @@
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";
5
- export interface IBlock {
6
- HTMLAttributes: Record<string, any>;
7
- }
8
- export declare type BlockContentType = TextContentType | HeadingContentType | ListItemContentType;
9
- declare module "@tiptap/core" {
10
- interface Commands<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;
18
- };
19
- }
20
- }
21
- /**
22
- * The main "Block node" documents consist of
23
- */
24
- export declare const Block: Node<IBlock, any>;
@@ -1,4 +0,0 @@
1
- export declare type Block<Type extends string, Props extends Record<string, string>> = {
2
- type: Type;
3
- props: Props;
4
- };
@@ -1,4 +0,0 @@
1
- import { Block } from "../BlockContentTypes";
2
- export declare type HeadingBlock = Block<"heading", {
3
- level: "1" | "2" | "3";
4
- }>;
@@ -1,2 +0,0 @@
1
- import { Block } from "../../BlockContentTypes";
2
- export declare type BulletListItemBlock = Block<"bulletListItem", {}>;
@@ -1,2 +0,0 @@
1
- import { Block } from "../../BlockContentTypes";
2
- export declare type NumberedListItemBlock = Block<"numberedListItem", {}>;
@@ -1,2 +0,0 @@
1
- import { Block } from "../BlockContentTypes";
2
- export declare type ParagraphBlock = Block<"paragraph", {}>;
@@ -1,8 +0,0 @@
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>;
@@ -1,8 +0,0 @@
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>;
@@ -1,2 +0,0 @@
1
- import { Plugin } from "prosemirror-state";
2
- export declare const OrderedListItemIndexPlugin: () => Plugin<any>;
@@ -1,6 +0,0 @@
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,8 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import { BubbleMenuFactory } from "./BubbleMenuFactoryTypes";
3
- /**
4
- * The menu that is displayed when selecting a piece of text.
5
- */
6
- export declare const BubbleMenuExtension: Extension<{
7
- bubbleMenuFactory: BubbleMenuFactory;
8
- }, any>;
@@ -1,27 +0,0 @@
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,44 +0,0 @@
1
- import { Editor } from "@tiptap/core";
2
- import { EditorState, Plugin, PluginKey } from "prosemirror-state";
3
- import { EditorView } from "prosemirror-view";
4
- import { BubbleMenu, BubbleMenuFactory, BubbleMenuParams } from "./BubbleMenuFactoryTypes";
5
- export interface BubbleMenuPluginProps {
6
- pluginKey: PluginKey;
7
- editor: Editor;
8
- bubbleMenuFactory: BubbleMenuFactory;
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 BubbleMenuViewProps = BubbleMenuPluginProps & {
19
- view: EditorView;
20
- };
21
- export declare class BubbleMenuView {
22
- editor: Editor;
23
- view: EditorView;
24
- bubbleMenuParams: BubbleMenuParams;
25
- bubbleMenu: BubbleMenu;
26
- preventHide: boolean;
27
- preventShow: boolean;
28
- menuIsOpen: boolean;
29
- shouldShow: Exclude<BubbleMenuPluginProps["shouldShow"], null>;
30
- constructor({ editor, bubbleMenuFactory, view, shouldShow, }: BubbleMenuViewProps);
31
- viewMousedownHandler: () => void;
32
- viewMouseupHandler: () => void;
33
- dragstartHandler: () => void;
34
- focusHandler: () => void;
35
- blurHandler: ({ event }: {
36
- event: FocusEvent;
37
- }) => void;
38
- update(view: EditorView, oldState?: EditorState): void;
39
- destroy(): void;
40
- getSelectionBoundingBox(): DOMRect;
41
- initBubbleMenuParams(): BubbleMenuParams;
42
- updateBubbleMenuParams(): void;
43
- }
44
- export declare const createBubbleMenuPlugin: (options: BubbleMenuPluginProps) => Plugin<any>;
@@ -1,12 +0,0 @@
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>;
@@ -1,18 +0,0 @@
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,8 +0,0 @@
1
- import { HyperlinkMenuPluginProps } from "./HyperlinkMenuPlugin";
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<HyperlinkMenuPluginProps, any>;
8
- export default Hyperlink;
@@ -1,11 +0,0 @@
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,11 +0,0 @@
1
- import { Editor } from "@tiptap/core";
2
- import { Plugin } from "prosemirror-state";
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 +0,0 @@
1
- export declare const FixedParagraph: import("@tiptap/core").Node<import("@tiptap/extension-paragraph").ParagraphOptions, any>;
@@ -1,8 +0,0 @@
1
- import { SlashMenuItem } from "./SlashMenuItem";
2
- /**
3
- * An array containing commands for creating all default blocks.
4
- */
5
- declare const defaultCommands: {
6
- [key: string]: SlashMenuItem;
7
- };
8
- export default defaultCommands;
@@ -1,2 +0,0 @@
1
- export const isAppleOS: () => boolean;
2
- export function formatKeyboardShortcut(shortcut: string): string;