@blocknote/core 0.8.2 → 0.8.4-alpha.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.
- package/README.md +4 -0
- package/dist/blocknote.js +1777 -1849
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +4 -4
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +4 -4
- package/src/BlockNoteEditor.ts +89 -39
- package/src/BlockNoteExtensions.ts +1 -58
- package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +10 -10
- package/src/api/formatConversions/formatConversions.test.ts +587 -605
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +15 -15
- package/src/api/nodeConversions/nodeConversions.test.ts +90 -94
- package/src/extensions/Blocks/api/blockTypes.ts +3 -2
- package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +6 -0
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +101 -114
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +184 -149
- package/src/extensions/Placeholder/PlaceholderExtension.ts +2 -2
- package/src/extensions/{DraggableBlocks/DraggableBlocksPlugin.ts → SideMenu/SideMenuPlugin.ts} +181 -164
- package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +7 -30
- package/src/extensions/SlashMenu/SlashMenuPlugin.ts +51 -0
- package/src/extensions/SlashMenu/defaultSlashMenuItems.ts +109 -0
- package/src/extensions/UniqueID/UniqueID.ts +29 -30
- package/src/index.ts +9 -8
- package/src/shared/BaseUiElementTypes.ts +8 -0
- package/src/shared/EditorElement.ts +0 -16
- package/src/shared/EventEmitter.ts +58 -0
- package/src/shared/plugins/suggestion/SuggestionItem.ts +3 -6
- package/src/shared/plugins/suggestion/SuggestionPlugin.ts +341 -403
- package/types/src/BlockNoteEditor.d.ts +18 -11
- package/types/src/BlockNoteExtensions.d.ts +0 -19
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +3 -2
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +18 -24
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +37 -10
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +79 -0
- package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +5 -18
- package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +13 -0
- package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +1 -69
- package/types/src/index.d.ts +9 -8
- package/types/src/shared/BaseUiElementTypes.d.ts +7 -0
- package/types/src/shared/EditorElement.d.ts +0 -10
- package/types/src/shared/EventEmitter.d.ts +11 -0
- package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +2 -7
- package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +12 -43
- package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +0 -29
- package/src/extensions/DraggableBlocks/DraggableBlocksExtension.ts +0 -37
- package/src/extensions/FormattingToolbar/FormattingToolbarExtension.ts +0 -37
- package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +0 -18
- package/src/extensions/HyperlinkToolbar/HyperlinkMark.ts +0 -28
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.ts +0 -19
- package/src/extensions/SlashMenu/SlashMenuExtension.ts +0 -53
- package/src/extensions/SlashMenu/defaultSlashMenuItems.tsx +0 -195
- package/src/extensions/SlashMenu/index.ts +0 -5
- package/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts +0 -21
- package/types/src/CustomBlock.d.ts +0 -15
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableCol.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableContent.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableRow.d.ts +0 -2
- package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +0 -17
- package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +0 -16
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +0 -49
- package/types/src/extensions/FormattingToolbar/FormattingToolbarExtension.d.ts +0 -11
- package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +0 -10
- package/types/src/extensions/HyperlinkToolbar/HyperlinkMark.d.ts +0 -8
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +0 -12
- package/types/src/extensions/Placeholder/localisation/index.d.ts +0 -2
- package/types/src/extensions/Placeholder/localisation/translation.d.ts +0 -51
- package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +0 -13
- package/types/src/extensions/SlashMenu/index.d.ts +0 -4
- package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +0 -12
- /package/src/extensions/{DraggableBlocks → SideMenu}/MultipleNodeSelection.ts +0 -0
- /package/types/src/extensions/{DraggableBlocks → SideMenu}/MultipleNodeSelection.d.ts +0 -0
|
@@ -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,18 +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
|
-
getReferenceRect: () => DOMRect;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type FormattingToolbarDynamicParams = {};
|
|
12
|
-
|
|
13
|
-
export type FormattingToolbar = EditorElement<FormattingToolbarDynamicParams>;
|
|
14
|
-
export type FormattingToolbarFactory<BSchema extends BlockSchema> =
|
|
15
|
-
ElementFactory<
|
|
16
|
-
FormattingToolbarStaticParams<BSchema>,
|
|
17
|
-
FormattingToolbarDynamicParams
|
|
18
|
-
>;
|
|
@@ -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
|
-
getReferenceRect: () => DOMRect;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type HyperlinkToolbarDynamicParams = {
|
|
11
|
-
url: string;
|
|
12
|
-
text: string;
|
|
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
|
-
getReferenceRect: () => DOMRect;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type SuggestionsMenuDynamicParams<T extends SuggestionItem> = {
|
|
11
|
-
items: T[];
|
|
12
|
-
keyboardHoveredItemIndex: number;
|
|
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,17 +0,0 @@
|
|
|
1
|
-
import { EditorElement, ElementFactory } from "../../shared/EditorElement";
|
|
2
|
-
import { BlockNoteEditor } from "../../BlockNoteEditor";
|
|
3
|
-
import { Block, BlockSchema } from "../Blocks/api/blockTypes";
|
|
4
|
-
export type BlockSideMenuStaticParams<BSchema extends BlockSchema> = {
|
|
5
|
-
editor: BlockNoteEditor<BSchema>;
|
|
6
|
-
addBlock: () => void;
|
|
7
|
-
blockDragStart: (event: DragEvent) => void;
|
|
8
|
-
blockDragEnd: () => void;
|
|
9
|
-
freezeMenu: () => void;
|
|
10
|
-
unfreezeMenu: () => void;
|
|
11
|
-
getReferenceRect: () => DOMRect;
|
|
12
|
-
};
|
|
13
|
-
export type BlockSideMenuDynamicParams<BSchema extends BlockSchema> = {
|
|
14
|
-
block: Block<BSchema>;
|
|
15
|
-
};
|
|
16
|
-
export type BlockSideMenu<BSchema extends BlockSchema> = EditorElement<BlockSideMenuDynamicParams<BSchema>>;
|
|
17
|
-
export type BlockSideMenuFactory<BSchema extends BlockSchema> = ElementFactory<BlockSideMenuStaticParams<BSchema>, BlockSideMenuDynamicParams<BSchema>>;
|
|
@@ -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,49 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
|
-
import { Plugin } from "prosemirror-state";
|
|
3
|
-
import { BlockSideMenu, BlockSideMenuDynamicParams, BlockSideMenuFactory, BlockSideMenuStaticParams } from "./BlockSideMenuFactoryTypes";
|
|
4
|
-
import { DraggableBlocksOptions } from "./DraggableBlocksExtension";
|
|
5
|
-
import { BlockNoteEditor } from "../../BlockNoteEditor";
|
|
6
|
-
import { BlockSchema } from "../Blocks/api/blockTypes";
|
|
7
|
-
export type BlockMenuViewProps<BSchema extends BlockSchema> = {
|
|
8
|
-
tiptapEditor: Editor;
|
|
9
|
-
editor: BlockNoteEditor<BSchema>;
|
|
10
|
-
blockMenuFactory: BlockSideMenuFactory<BSchema>;
|
|
11
|
-
horizontalPosAnchoredAtRoot: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare class BlockMenuView<BSchema extends BlockSchema> {
|
|
14
|
-
editor: BlockNoteEditor<BSchema>;
|
|
15
|
-
private ttEditor;
|
|
16
|
-
horizontalPosAnchoredAtRoot: boolean;
|
|
17
|
-
horizontalPosAnchor: number;
|
|
18
|
-
blockMenu: BlockSideMenu<BSchema>;
|
|
19
|
-
hoveredBlock: HTMLElement | undefined;
|
|
20
|
-
isDragging: boolean;
|
|
21
|
-
menuOpen: boolean;
|
|
22
|
-
menuFrozen: boolean;
|
|
23
|
-
private lastPosition;
|
|
24
|
-
constructor({ tiptapEditor, editor, blockMenuFactory, horizontalPosAnchoredAtRoot, }: BlockMenuViewProps<BSchema>);
|
|
25
|
-
/**
|
|
26
|
-
* Sets isDragging when dragging text.
|
|
27
|
-
*/
|
|
28
|
-
onDragStart: () => void;
|
|
29
|
-
/**
|
|
30
|
-
* If the event is outside the editor contents,
|
|
31
|
-
* we dispatch a fake event, so that we can still drop the content
|
|
32
|
-
* when dragging / dropping to the side of the editor
|
|
33
|
-
*/
|
|
34
|
-
onDrop: (event: DragEvent) => void;
|
|
35
|
-
/**
|
|
36
|
-
* If the event is outside the editor contents,
|
|
37
|
-
* we dispatch a fake event, so that we can still drop the content
|
|
38
|
-
* when dragging / dropping to the side of the editor
|
|
39
|
-
*/
|
|
40
|
-
onDragOver: (event: DragEvent) => void;
|
|
41
|
-
onKeyDown: (_event: KeyboardEvent) => void;
|
|
42
|
-
onMouseDown: (event: MouseEvent) => void;
|
|
43
|
-
onMouseMove: (event: MouseEvent) => void;
|
|
44
|
-
destroy(): void;
|
|
45
|
-
addBlock(): void;
|
|
46
|
-
getStaticParams(): BlockSideMenuStaticParams<BSchema>;
|
|
47
|
-
getDynamicParams(): BlockSideMenuDynamicParams<BSchema>;
|
|
48
|
-
}
|
|
49
|
-
export declare const createDraggableBlocksPlugin: <BSchema extends Record<string, import("../Blocks/api/blockTypes").BlockSpec<string, import("../Blocks/api/blockTypes").PropSchema>>>(options: DraggableBlocksOptions<BSchema>) => Plugin<any>;
|
|
@@ -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,12 +0,0 @@
|
|
|
1
|
-
import { EditorElement, ElementFactory } from "../../shared/EditorElement";
|
|
2
|
-
export type HyperlinkToolbarStaticParams = {
|
|
3
|
-
editHyperlink: (url: string, text: string) => void;
|
|
4
|
-
deleteHyperlink: () => void;
|
|
5
|
-
getReferenceRect: () => DOMRect;
|
|
6
|
-
};
|
|
7
|
-
export type HyperlinkToolbarDynamicParams = {
|
|
8
|
-
url: string;
|
|
9
|
-
text: string;
|
|
10
|
-
};
|
|
11
|
-
export type HyperlinkToolbar = EditorElement<HyperlinkToolbarDynamicParams>;
|
|
12
|
-
export type HyperlinkToolbarFactory = ElementFactory<HyperlinkToolbarStaticParams, HyperlinkToolbarDynamicParams>;
|
|
@@ -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
|
-
};
|
|
@@ -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,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>>;
|
|
File without changes
|
|
File without changes
|