@blocknote/core 0.8.1 → 0.8.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 (71) hide show
  1. package/README.md +4 -0
  2. package/dist/blocknote.js +1787 -1834
  3. package/dist/blocknote.js.map +1 -1
  4. package/dist/blocknote.umd.cjs +4 -4
  5. package/dist/blocknote.umd.cjs.map +1 -1
  6. package/dist/style.css +1 -1
  7. package/package.json +3 -3
  8. package/src/BlockNoteEditor.ts +102 -38
  9. package/src/BlockNoteExtensions.ts +1 -58
  10. package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +10 -10
  11. package/src/api/formatConversions/formatConversions.test.ts +587 -605
  12. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +15 -15
  13. package/src/api/nodeConversions/nodeConversions.test.ts +90 -94
  14. package/src/extensions/Blocks/api/blockTypes.ts +3 -2
  15. package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +6 -0
  16. package/src/extensions/Blocks/nodes/BlockContainer.ts +12 -3
  17. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +92 -104
  18. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +178 -134
  19. package/src/extensions/Placeholder/PlaceholderExtension.ts +2 -2
  20. package/src/extensions/{DraggableBlocks/DraggableBlocksPlugin.ts → SideMenu/SideMenuPlugin.ts} +173 -163
  21. package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +7 -30
  22. package/src/extensions/SlashMenu/SlashMenuPlugin.ts +51 -0
  23. package/src/extensions/SlashMenu/defaultSlashMenuItems.ts +109 -0
  24. package/src/extensions/UniqueID/UniqueID.ts +29 -30
  25. package/src/index.ts +9 -8
  26. package/src/node_modules/.vitest/results.json +1 -0
  27. package/src/shared/BaseUiElementTypes.ts +8 -0
  28. package/src/shared/EditorElement.ts +0 -16
  29. package/src/shared/EventEmitter.ts +58 -0
  30. package/src/shared/plugins/suggestion/SuggestionItem.ts +3 -6
  31. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +333 -389
  32. package/types/src/BlockNoteEditor.d.ts +18 -10
  33. package/types/src/BlockNoteExtensions.d.ts +0 -19
  34. package/types/src/EventEmitter.d.ts +11 -0
  35. package/types/src/extensions/Blocks/api/blockTypes.d.ts +3 -2
  36. package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +0 -17
  37. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +25 -19
  38. package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +2 -3
  39. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +17 -24
  40. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +0 -12
  41. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +37 -10
  42. package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +24 -0
  43. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +79 -0
  44. package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +5 -18
  45. package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +13 -0
  46. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +1 -69
  47. package/types/src/extensions/SlashMenu/index.d.ts +2 -3
  48. package/types/src/index.d.ts +9 -8
  49. package/types/src/shared/BaseUiElementTypes.d.ts +7 -0
  50. package/types/src/shared/EditorElement.d.ts +0 -10
  51. package/types/src/shared/EventEmitter.d.ts +11 -0
  52. package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +2 -7
  53. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +12 -43
  54. package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +1 -1
  55. package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +0 -29
  56. package/src/extensions/DraggableBlocks/DraggableBlocksExtension.ts +0 -37
  57. package/src/extensions/FormattingToolbar/FormattingToolbarExtension.ts +0 -37
  58. package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +0 -20
  59. package/src/extensions/HyperlinkToolbar/HyperlinkMark.ts +0 -28
  60. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.ts +0 -19
  61. package/src/extensions/SlashMenu/SlashMenuExtension.ts +0 -53
  62. package/src/extensions/SlashMenu/defaultSlashMenuItems.tsx +0 -195
  63. package/src/extensions/SlashMenu/index.ts +0 -5
  64. package/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts +0 -21
  65. package/types/src/CustomBlock.d.ts +0 -15
  66. package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableCol.d.ts +0 -2
  67. package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableContent.d.ts +0 -2
  68. package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableRow.d.ts +0 -2
  69. package/types/src/extensions/Placeholder/localisation/index.d.ts +0 -2
  70. package/types/src/extensions/Placeholder/localisation/translation.d.ts +0 -51
  71. /package/src/extensions/{DraggableBlocks → SideMenu}/MultipleNodeSelection.ts +0 -0
@@ -0,0 +1,11 @@
1
+ type StringKeyOf<T> = Extract<keyof T, string>;
2
+ type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
3
+ type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
4
+ export declare class EventEmitter<T extends Record<string, any>> {
5
+ private callbacks;
6
+ on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): () => void;
7
+ protected emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): void;
8
+ off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): void;
9
+ protected removeAllListeners(): void;
10
+ }
11
+ export {};
@@ -1,8 +1,3 @@
1
- /**
2
- * A generic interface used in all suggestion menus (slash menu, mentions, etc)
3
- */
4
- export declare class SuggestionItem {
1
+ export type SuggestionItem = {
5
2
  name: string;
6
- match: (query: string) => boolean;
7
- constructor(name: string, match: (query: string) => boolean);
8
- }
3
+ };
@@ -1,44 +1,10 @@
1
- import { Editor, Range } from "@tiptap/core";
2
1
  import { Plugin, PluginKey } from "prosemirror-state";
3
- import { SuggestionsMenuFactory } from "./SuggestionsMenuFactoryTypes";
4
- import { SuggestionItem } from "./SuggestionItem";
5
2
  import { BlockNoteEditor } from "../../../BlockNoteEditor";
6
- import { BlockSchema } from "../../../extensions/Blocks/api/blockTypes";
7
- export type SuggestionPluginOptions<T extends SuggestionItem, BSchema extends BlockSchema> = {
8
- /**
9
- * The name of the plugin.
10
- *
11
- * Used for ensuring that the plugin key is unique when more than one instance of the SuggestionPlugin is used.
12
- */
13
- pluginKey: PluginKey;
14
- /**
15
- * The BlockNote editor.
16
- */
17
- editor: BlockNoteEditor<BSchema>;
18
- /**
19
- * The character that should trigger the suggestion menu to pop up (e.g. a '/' for commands), when typed by the user.
20
- */
21
- defaultTriggerCharacter: string;
22
- suggestionsMenuFactory: SuggestionsMenuFactory<T>;
23
- /**
24
- * The callback that gets executed when an item is selected by the user.
25
- *
26
- * **NOTE:** The command text is not removed automatically from the editor by this plugin,
27
- * this should be done manually. The `editor` and `range` properties passed
28
- * to the callback function might come in handy when doing this.
29
- */
30
- onSelectItem?: (props: {
31
- item: T;
32
- editor: BlockNoteEditor<BSchema>;
33
- }) => void;
34
- /**
35
- * A function that should supply the plugin with items to suggest, based on a certain query string.
36
- */
37
- items?: (query: string) => T[];
38
- allow?: (props: {
39
- editor: Editor;
40
- range: Range;
41
- }) => boolean;
3
+ import { BaseUiElementState } from "../../BaseUiElementTypes";
4
+ import { SuggestionItem } from "./SuggestionItem";
5
+ export type SuggestionsMenuState<T extends SuggestionItem> = BaseUiElementState & {
6
+ filteredItems: T[];
7
+ keyboardHoveredItemIndex: number;
42
8
  };
43
9
  type SuggestionPluginState<T extends SuggestionItem> = {
44
10
  active: boolean;
@@ -58,9 +24,12 @@ type SuggestionPluginState<T extends SuggestionItem> = {
58
24
  * - This version supports generic items instead of only strings (to allow for more advanced filtering for example)
59
25
  * - This version hides some unnecessary complexity from the user of the plugin.
60
26
  * - This version handles key events differently
61
- *
62
- * @param options options for configuring the plugin
63
- * @returns the prosemirror plugin
64
27
  */
65
- export declare function createSuggestionPlugin<T extends SuggestionItem, BSchema extends BlockSchema>({ pluginKey, editor, defaultTriggerCharacter, suggestionsMenuFactory, onSelectItem: selectItemCallback, items, }: SuggestionPluginOptions<T, BSchema>): Plugin<SuggestionPluginState<T>>;
28
+ export declare const setupSuggestionsMenu: <T extends SuggestionItem, BSchema extends Record<string, import("../../../extensions/Blocks/api/blockTypes").BlockSpec<string, import("../../../extensions/Blocks/api/blockTypes").PropSchema>>>(editor: BlockNoteEditor<BSchema>, updateSuggestionsMenu: (suggestionsMenuState: SuggestionsMenuState<T>) => void, pluginKey: PluginKey, defaultTriggerCharacter: string, items?: (query: string) => T[], onSelectItem?: (props: {
29
+ item: T;
30
+ editor: BlockNoteEditor<BSchema>;
31
+ }) => void) => {
32
+ plugin: Plugin<SuggestionPluginState<T>>;
33
+ itemCallback: (item: T) => void;
34
+ };
66
35
  export {};
@@ -2,11 +2,11 @@ import { EditorElement, ElementFactory } from "../../EditorElement";
2
2
  import { SuggestionItem } from "./SuggestionItem";
3
3
  export type SuggestionsMenuStaticParams<T extends SuggestionItem> = {
4
4
  itemCallback: (item: T) => void;
5
+ getReferenceRect: () => DOMRect;
5
6
  };
6
7
  export type SuggestionsMenuDynamicParams<T extends SuggestionItem> = {
7
8
  items: T[];
8
9
  keyboardHoveredItemIndex: number;
9
- referenceRect: DOMRect;
10
10
  };
11
11
  export type SuggestionsMenu<T extends SuggestionItem> = EditorElement<SuggestionsMenuDynamicParams<T>>;
12
12
  export type SuggestionsMenuFactory<T extends SuggestionItem> = ElementFactory<SuggestionsMenuStaticParams<T>, SuggestionsMenuDynamicParams<T>>;
@@ -1,29 +0,0 @@
1
- import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
- import { BlockNoteEditor } from "../../BlockNoteEditor";
3
- import { Block, BlockSchema } from "../Blocks/api/blockTypes";
4
-
5
- export type BlockSideMenuStaticParams<BSchema extends BlockSchema> = {
6
- editor: BlockNoteEditor<BSchema>;
7
-
8
- addBlock: () => void;
9
-
10
- blockDragStart: (event: DragEvent) => void;
11
- blockDragEnd: () => void;
12
-
13
- freezeMenu: () => void;
14
- unfreezeMenu: () => void;
15
- };
16
-
17
- export type BlockSideMenuDynamicParams<BSchema extends BlockSchema> = {
18
- block: Block<BSchema>;
19
-
20
- referenceRect: DOMRect;
21
- };
22
-
23
- export type BlockSideMenu<BSchema extends BlockSchema> = EditorElement<
24
- BlockSideMenuDynamicParams<BSchema>
25
- >;
26
- export type BlockSideMenuFactory<BSchema extends BlockSchema> = ElementFactory<
27
- BlockSideMenuStaticParams<BSchema>,
28
- BlockSideMenuDynamicParams<BSchema>
29
- >;
@@ -1,37 +0,0 @@
1
- import { Editor, Extension } from "@tiptap/core";
2
- import { BlockSideMenuFactory } from "./BlockSideMenuFactoryTypes";
3
- import { createDraggableBlocksPlugin } from "./DraggableBlocksPlugin";
4
- import { BlockNoteEditor } from "../../BlockNoteEditor";
5
- import { BlockSchema } from "../Blocks/api/blockTypes";
6
-
7
- export type DraggableBlocksOptions<BSchema extends BlockSchema> = {
8
- tiptapEditor: Editor;
9
- editor: BlockNoteEditor<BSchema>;
10
- blockSideMenuFactory: BlockSideMenuFactory<BSchema>;
11
- };
12
-
13
- /**
14
- * This extension adds a menu to the side of blocks which features various BlockNote functions such as adding and
15
- * removing blocks. More importantly, it adds a drag handle which allows the user to drag and drop blocks.
16
- *
17
- * code based on https://github.com/ueberdosis/tiptap/issues/323#issuecomment-506637799
18
- */
19
- export const createDraggableBlocksExtension = <BSchema extends BlockSchema>() =>
20
- Extension.create<DraggableBlocksOptions<BSchema>>({
21
- name: "DraggableBlocksExtension",
22
- priority: 1000, // Need to be high, in order to hide menu when typing slash
23
- addProseMirrorPlugins() {
24
- if (!this.options.blockSideMenuFactory) {
25
- throw new Error(
26
- "UI Element factory not defined for DraggableBlocksExtension"
27
- );
28
- }
29
- return [
30
- createDraggableBlocksPlugin({
31
- tiptapEditor: this.editor,
32
- editor: this.options.editor,
33
- blockSideMenuFactory: this.options.blockSideMenuFactory,
34
- }),
35
- ];
36
- },
37
- });
@@ -1,37 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import { PluginKey } from "prosemirror-state";
3
- import { BlockNoteEditor, BlockSchema } from "../..";
4
- import { FormattingToolbarFactory } from "./FormattingToolbarFactoryTypes";
5
- import { createFormattingToolbarPlugin } from "./FormattingToolbarPlugin";
6
-
7
- export type FormattingToolbarOptions<BSchema extends BlockSchema> = {
8
- formattingToolbarFactory: FormattingToolbarFactory<BSchema>;
9
- editor: BlockNoteEditor<BSchema>;
10
- };
11
-
12
- /**
13
- * The menu that is displayed when selecting a piece of text.
14
- */
15
- export const createFormattingToolbarExtension = <
16
- BSchema extends BlockSchema
17
- >() =>
18
- Extension.create<FormattingToolbarOptions<BSchema>>({
19
- name: "FormattingToolbarExtension",
20
-
21
- addProseMirrorPlugins() {
22
- if (!this.options.formattingToolbarFactory || !this.options.editor) {
23
- throw new Error(
24
- "required args not defined for FormattingToolbarExtension"
25
- );
26
- }
27
-
28
- return [
29
- createFormattingToolbarPlugin({
30
- tiptapEditor: this.editor,
31
- editor: this.options.editor,
32
- formattingToolbarFactory: this.options.formattingToolbarFactory,
33
- pluginKey: new PluginKey("FormattingToolbarPlugin"),
34
- }),
35
- ];
36
- },
37
- });
@@ -1,20 +0,0 @@
1
- import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
- import { BlockNoteEditor } from "../../BlockNoteEditor";
3
- import { BlockSchema } from "../Blocks/api/blockTypes";
4
-
5
- export type FormattingToolbarStaticParams<BSchema extends BlockSchema> = {
6
- editor: BlockNoteEditor<BSchema>;
7
- };
8
-
9
- export type FormattingToolbarDynamicParams = {
10
- referenceRect: DOMRect;
11
- };
12
-
13
- export type FormattingToolbar = EditorElement<
14
- FormattingToolbarDynamicParams
15
- >;
16
- export type FormattingToolbarFactory<BSchema extends BlockSchema> =
17
- ElementFactory<
18
- FormattingToolbarStaticParams<BSchema>,
19
- FormattingToolbarDynamicParams
20
- >;
@@ -1,28 +0,0 @@
1
- import { Link } from "@tiptap/extension-link";
2
- import {
3
- createHyperlinkToolbarPlugin,
4
- HyperlinkToolbarPluginProps,
5
- } from "./HyperlinkToolbarPlugin";
6
-
7
- /**
8
- * This custom link includes a special menu for editing/deleting/opening the link.
9
- * The menu will be triggered by hovering over the link with the mouse,
10
- * or by moving the cursor inside the link text
11
- */
12
- const Hyperlink = Link.extend<HyperlinkToolbarPluginProps>({
13
- priority: 500,
14
- addProseMirrorPlugins() {
15
- if (!this.options.hyperlinkToolbarFactory) {
16
- throw new Error("UI Element factory not defined for HyperlinkMark");
17
- }
18
-
19
- return [
20
- ...(this.parent?.() || []),
21
- createHyperlinkToolbarPlugin(this.editor, {
22
- hyperlinkToolbarFactory: this.options.hyperlinkToolbarFactory,
23
- }),
24
- ];
25
- },
26
- });
27
-
28
- export default Hyperlink;
@@ -1,19 +0,0 @@
1
- import { EditorElement, ElementFactory } from "../../shared/EditorElement";
2
-
3
- export type HyperlinkToolbarStaticParams = {
4
- editHyperlink: (url: string, text: string) => void;
5
- deleteHyperlink: () => void;
6
- };
7
-
8
- export type HyperlinkToolbarDynamicParams = {
9
- url: string;
10
- text: string;
11
-
12
- referenceRect: DOMRect;
13
- };
14
-
15
- export type HyperlinkToolbar = EditorElement<HyperlinkToolbarDynamicParams>;
16
- export type HyperlinkToolbarFactory = ElementFactory<
17
- HyperlinkToolbarStaticParams,
18
- HyperlinkToolbarDynamicParams
19
- >;
@@ -1,53 +0,0 @@
1
- import { Extension } from "@tiptap/core";
2
- import { PluginKey } from "prosemirror-state";
3
- import { createSuggestionPlugin } from "../../shared/plugins/suggestion/SuggestionPlugin";
4
- import { SuggestionsMenuFactory } from "../../shared/plugins/suggestion/SuggestionsMenuFactoryTypes";
5
- import { BaseSlashMenuItem } from "./BaseSlashMenuItem";
6
- import { BlockNoteEditor } from "../../BlockNoteEditor";
7
- import { BlockSchema } from "../Blocks/api/blockTypes";
8
-
9
- export type SlashMenuOptions<BSchema extends BlockSchema> = {
10
- editor: BlockNoteEditor<BSchema> | undefined;
11
- commands: BaseSlashMenuItem<BSchema>[] | undefined;
12
- slashMenuFactory: SuggestionsMenuFactory<any> | undefined;
13
- };
14
-
15
- export const SlashMenuPluginKey = new PluginKey("suggestions-slash-commands");
16
-
17
- export const createSlashMenuExtension = <BSchema extends BlockSchema>() =>
18
- Extension.create<SlashMenuOptions<BSchema>>({
19
- name: "slash-command",
20
-
21
- addOptions() {
22
- return {
23
- editor: undefined,
24
- commands: undefined,
25
- slashMenuFactory: undefined,
26
- };
27
- },
28
-
29
- addProseMirrorPlugins() {
30
- if (!this.options.slashMenuFactory || !this.options.commands) {
31
- throw new Error("required args not defined for SlashMenuExtension");
32
- }
33
-
34
- const commands = this.options.commands;
35
-
36
- return [
37
- createSuggestionPlugin<BaseSlashMenuItem<BSchema>, BSchema>({
38
- pluginKey: SlashMenuPluginKey,
39
- editor: this.options.editor!,
40
- defaultTriggerCharacter: "/",
41
- suggestionsMenuFactory: this.options.slashMenuFactory!,
42
- items: (query) => {
43
- return commands.filter((cmd: BaseSlashMenuItem<BSchema>) =>
44
- cmd.match(query)
45
- );
46
- },
47
- onSelectItem: ({ item, editor }) => {
48
- item.execute(editor);
49
- },
50
- }),
51
- ];
52
- },
53
- });
@@ -1,195 +0,0 @@
1
- import { BlockNoteEditor } from "../../BlockNoteEditor";
2
- import { PartialBlock } from "../Blocks/api/blockTypes";
3
- import { DefaultBlockSchema } from "../Blocks/api/defaultBlocks";
4
- import { BaseSlashMenuItem } from "./BaseSlashMenuItem";
5
-
6
- function insertOrUpdateBlock<BSchema extends DefaultBlockSchema>(
7
- editor: BlockNoteEditor<BSchema>,
8
- block: PartialBlock<BSchema>
9
- ) {
10
- const currentBlock = editor.getTextCursorPosition().block;
11
-
12
- if (
13
- (currentBlock.content.length === 1 &&
14
- currentBlock.content[0].type === "text" &&
15
- currentBlock.content[0].text === "/") ||
16
- currentBlock.content.length === 0
17
- ) {
18
- editor.updateBlock(currentBlock, block);
19
- } else {
20
- editor.insertBlocks([block], currentBlock, "after");
21
- editor.setTextCursorPosition(editor.getTextCursorPosition().nextBlock!);
22
- }
23
- }
24
-
25
- /**
26
- * An array containing commands for creating all default blocks.
27
- */
28
- export const defaultSlashMenuItems = [
29
- // Command for creating a level 1 heading
30
- new BaseSlashMenuItem<DefaultBlockSchema>(
31
- "Heading",
32
- (editor) =>
33
- insertOrUpdateBlock(editor, {
34
- type: "heading",
35
- props: { level: "1" },
36
- }),
37
- ["h", "heading1", "h1"]
38
- ),
39
-
40
- // Command for creating a level 2 heading
41
- new BaseSlashMenuItem<DefaultBlockSchema>(
42
- "Heading 2",
43
- (editor) =>
44
- insertOrUpdateBlock(editor, {
45
- type: "heading",
46
- props: { level: "2" },
47
- }),
48
- ["h2", "heading2", "subheading"]
49
- ),
50
-
51
- // Command for creating a level 3 heading
52
- new BaseSlashMenuItem<DefaultBlockSchema>(
53
- "Heading 3",
54
- (editor) =>
55
- insertOrUpdateBlock(editor, {
56
- type: "heading",
57
- props: { level: "3" },
58
- }),
59
- ["h3", "heading3", "subheading"]
60
- ),
61
-
62
- // Command for creating an ordered list
63
- new BaseSlashMenuItem<DefaultBlockSchema>(
64
- "Numbered List",
65
- (editor) =>
66
- insertOrUpdateBlock(editor, {
67
- type: "numberedListItem",
68
- }),
69
- ["li", "list", "numberedlist", "numbered list"]
70
- ),
71
-
72
- // Command for creating a bullet list
73
- new BaseSlashMenuItem<DefaultBlockSchema>(
74
- "Bullet List",
75
- (editor) =>
76
- insertOrUpdateBlock(editor, {
77
- type: "bulletListItem",
78
- }),
79
- ["ul", "list", "bulletlist", "bullet list"]
80
- ),
81
-
82
- // Command for creating a paragraph (pretty useless)
83
- new BaseSlashMenuItem<DefaultBlockSchema>(
84
- "Paragraph",
85
- (editor) =>
86
- insertOrUpdateBlock(editor, {
87
- type: "paragraph",
88
- }),
89
- ["p"]
90
- ),
91
-
92
- // replaceRangeWithNode(editor, range, node);
93
-
94
- // return true;
95
- // },
96
- // ["ol", "orderedlist"],
97
- // OrderedListIcon,
98
- // "Used to display an ordered (enumerated) list item"
99
- // ),
100
-
101
- // Command for creating a blockquote
102
- // blockquote: new SlashCommand(
103
- // "Block Quote",
104
- // CommandGroup.BASIC_BLOCKS,
105
- // (editor, range) => {
106
- // const paragraph = editor.schema.node("paragraph");
107
- // const node = editor.schema.node(
108
- // "blockquote",
109
- // { "block-id": uniqueId.generate() },
110
- // paragraph
111
- // );
112
-
113
- // replaceRangeWithNode(editor, range, node);
114
-
115
- // return true;
116
- // },
117
- // ["quote", "blockquote"],
118
- // QuoteIcon,
119
- // "Used to make a quote stand out",
120
- // "Ctrl+Shift+B"
121
- // ),
122
-
123
- // Command for creating a horizontal rule
124
- // horizontalRule: new SlashCommand(
125
- // "Horizontal Rule",
126
- // CommandGroup.BASIC_BLOCKS,
127
- // (editor, range) => {
128
- // const node = editor.schema.node("horizontalRule", {
129
- // "block-id": uniqueId.generate(),
130
- // });
131
-
132
- // // insert horizontal rule, create a new block after the horizontal rule if applicable
133
- // // and put the cursor in the block after the horizontal rule.
134
- // editor
135
- // .chain()
136
- // .focus()
137
- // .replaceRangeAndUpdateSelection(range, node)
138
- // .command(({ tr, dispatch }) => {
139
- // if (dispatch) {
140
- // // the node immediately after the cursor
141
- // const nodeAfter = tr.selection.$to.nodeAfter;
142
-
143
- // // the position of the cursor
144
- // const cursorPos = tr.selection.$to.pos;
145
-
146
- // // check if there is no node after the cursor (end of document)
147
- // if (!nodeAfter) {
148
- // // create a new block of the default type (probably paragraph) after the cursor
149
- // const { parent } = tr.selection.$to;
150
- // const node = parent.type.contentMatch.defaultType?.create();
151
-
152
- // if (node) {
153
- // tr.insert(cursorPos, node);
154
- // }
155
- // }
156
-
157
- // // try to put the cursor at the start of the node directly after the inserted horizontal rule
158
- // tr.doc.nodesBetween(cursorPos, cursorPos + 1, (node, pos) => {
159
- // if (node.type.name !== "horizontalRule") {
160
- // tr.setSelection(TextSelection.create(tr.doc, pos));
161
- // }
162
- // });
163
- // }
164
-
165
- // return true;
166
- // })
167
- // .scrollIntoView()
168
- // .run();
169
- // return true;
170
- // },
171
- // ["hr", "horizontalrule"],
172
- // SeparatorIcon,
173
- // "Used to separate sections with a horizontal line"
174
- // ),
175
-
176
- // Command for creating a table
177
- // table: new SlashCommand(
178
- // "Table",
179
- // CommandGroup.BASIC_BLOCKS,
180
- // (editor, range) => {
181
- // editor.chain().focus().deleteRange(range).run();
182
- // // TODO: add blockid, pending https://github.com/ueberdosis/tiptap/pull/1469
183
- // editor
184
- // .chain()
185
- // .focus()
186
- // .insertTable({ rows: 1, cols: 2, withHeaderRow: false })
187
- // .scrollIntoView()
188
- // .run();
189
- // return true;
190
- // },
191
- // ["table", "database"],
192
- // TableIcon,
193
- // "Used to create a simple table"
194
- // ),
195
- ];
@@ -1,5 +0,0 @@
1
- import { defaultSlashMenuItems } from "./defaultSlashMenuItems";
2
- import { createSlashMenuExtension } from "./SlashMenuExtension";
3
- import { BaseSlashMenuItem } from "./BaseSlashMenuItem";
4
-
5
- export { defaultSlashMenuItems, BaseSlashMenuItem, createSlashMenuExtension };
@@ -1,21 +0,0 @@
1
- import { EditorElement, ElementFactory } from "../../EditorElement";
2
- import { SuggestionItem } from "./SuggestionItem";
3
-
4
- export type SuggestionsMenuStaticParams<T extends SuggestionItem> = {
5
- itemCallback: (item: T) => void;
6
- };
7
-
8
- export type SuggestionsMenuDynamicParams<T extends SuggestionItem> = {
9
- items: T[];
10
- keyboardHoveredItemIndex: number;
11
-
12
- referenceRect: DOMRect;
13
- };
14
-
15
- export type SuggestionsMenu<T extends SuggestionItem> = EditorElement<
16
- SuggestionsMenuDynamicParams<T>
17
- >;
18
- export type SuggestionsMenuFactory<T extends SuggestionItem> = ElementFactory<
19
- SuggestionsMenuStaticParams<T>,
20
- SuggestionsMenuDynamicParams<T>
21
- >;
@@ -1,15 +0,0 @@
1
- import { Node } from "@tiptap/core";
2
- import { NodeViewRendererProps } from "@tiptap/core";
3
- export type CustomBlock = {
4
- name: string;
5
- priority?: number;
6
- atom?: boolean;
7
- selectable?: boolean;
8
- className?: string;
9
- props?: Record<string, string>;
10
- element: (props: NodeViewRendererProps) => {
11
- element: HTMLElement;
12
- editable?: HTMLElement;
13
- };
14
- };
15
- export declare function createCustomBlock(customBlock: CustomBlock): Node<CustomBlock, any>;
@@ -1,2 +0,0 @@
1
- import { Node } from "@tiptap/core";
2
- export declare const TableCol: Node<any, any>;
@@ -1,2 +0,0 @@
1
- import { Node } from "@tiptap/core";
2
- export declare const TableContent: Node<any, any>;
@@ -1,2 +0,0 @@
1
- import { Node } from "@tiptap/core";
2
- export declare const TableRow: Node<any, any>;
@@ -1,2 +0,0 @@
1
- import i18next from "i18next";
2
- export default i18next;
@@ -1,51 +0,0 @@
1
- export declare const translation: {
2
- en: {
3
- translation: {
4
- placeholder: string;
5
- heading: string;
6
- list: string;
7
- };
8
- };
9
- de: {
10
- translation: {
11
- placeholder: string;
12
- heading: string;
13
- list: string;
14
- };
15
- };
16
- it: {
17
- translation: {
18
- placeholder: string;
19
- heading: string;
20
- list: string;
21
- };
22
- };
23
- es: {
24
- translation: {
25
- placeholder: string;
26
- heading: string;
27
- list: string;
28
- };
29
- };
30
- fr: {
31
- translation: {
32
- placeholder: string;
33
- heading: string;
34
- list: string;
35
- };
36
- };
37
- fi: {
38
- translation: {
39
- placeholder: string;
40
- heading: string;
41
- list: string;
42
- };
43
- };
44
- sv: {
45
- translation: {
46
- placeholder: string;
47
- heading: string;
48
- list: string;
49
- };
50
- };
51
- };