@blocknote/core 0.12.0 → 0.12.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.
- package/dist/blocknote.js +958 -940
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +2 -2
- package/src/api/getCurrentBlockContentType.ts +14 -0
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +50 -21
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +1 -1
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +18 -5
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +7 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +18 -5
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +14 -5
- package/src/editor/BlockNoteEditor.ts +14 -14
- package/src/editor/editor.css +0 -1
- package/src/extensions/{ImageToolbar → ImagePanel}/ImageToolbarPlugin.ts +14 -14
- package/src/extensions/{HyperlinkToolbar/HyperlinkToolbarPlugin.ts → LinkToolbar/LinkToolbarPlugin.ts} +87 -91
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +1 -1
- package/src/index.ts +2 -2
- package/types/src/api/getCurrentBlockContentType.d.ts +2 -0
- package/types/src/editor/BlockNoteEditor.d.ts +5 -5
- package/types/src/extensions/{ImageToolbar → ImagePanel}/ImageToolbarPlugin.d.ts +6 -6
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +40 -0
- package/types/src/index.d.ts +2 -2
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +0 -38
|
@@ -8,38 +8,38 @@ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
|
8
8
|
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
9
9
|
import { EventEmitter } from "../../util/EventEmitter";
|
|
10
10
|
|
|
11
|
-
export type
|
|
12
|
-
// The hovered
|
|
11
|
+
export type LinkToolbarState = UiElementPosition & {
|
|
12
|
+
// The hovered link's URL, and the text it's displayed with in the
|
|
13
13
|
// editor.
|
|
14
14
|
url: string;
|
|
15
15
|
text: string;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
class
|
|
19
|
-
public state?:
|
|
18
|
+
class LinkToolbarView {
|
|
19
|
+
public state?: LinkToolbarState;
|
|
20
20
|
public emitUpdate: () => void;
|
|
21
21
|
|
|
22
22
|
menuUpdateTimer: ReturnType<typeof setTimeout> | undefined;
|
|
23
23
|
startMenuUpdateTimer: () => void;
|
|
24
24
|
stopMenuUpdateTimer: () => void;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
mouseHoveredLinkMark: Mark | undefined;
|
|
27
|
+
mouseHoveredLinkMarkRange: Range | undefined;
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
keyboardHoveredLinkMark: Mark | undefined;
|
|
30
|
+
keyboardHoveredLinkMarkRange: Range | undefined;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
linkMark: Mark | undefined;
|
|
33
|
+
linkMarkRange: Range | undefined;
|
|
34
34
|
|
|
35
35
|
constructor(
|
|
36
36
|
private readonly editor: BlockNoteEditor<any, any, any>,
|
|
37
37
|
private readonly pmView: EditorView,
|
|
38
|
-
emitUpdate: (state:
|
|
38
|
+
emitUpdate: (state: LinkToolbarState) => void
|
|
39
39
|
) {
|
|
40
40
|
this.emitUpdate = () => {
|
|
41
41
|
if (!this.state) {
|
|
42
|
-
throw new Error("Attempting to update uninitialized
|
|
42
|
+
throw new Error("Attempting to update uninitialized link toolbar");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
emitUpdate(this.state);
|
|
@@ -66,9 +66,9 @@ class HyperlinkToolbarView {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
mouseOverHandler = (event: MouseEvent) => {
|
|
69
|
-
// Resets the
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
69
|
+
// Resets the link mark currently hovered by the mouse cursor.
|
|
70
|
+
this.mouseHoveredLinkMark = undefined;
|
|
71
|
+
this.mouseHoveredLinkMarkRange = undefined;
|
|
72
72
|
|
|
73
73
|
this.stopMenuUpdateTimer();
|
|
74
74
|
|
|
@@ -76,27 +76,23 @@ class HyperlinkToolbarView {
|
|
|
76
76
|
event.target instanceof HTMLAnchorElement &&
|
|
77
77
|
event.target.nodeName === "A"
|
|
78
78
|
) {
|
|
79
|
-
// Finds link mark at the hovered element's position to update
|
|
80
|
-
//
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
this.pmView.posAtDOM(
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
const marksAtPos = resolvedPosInHoveredHyperlinkMark.marks();
|
|
79
|
+
// Finds link mark at the hovered element's position to update mouseHoveredLinkMark and
|
|
80
|
+
// mouseHoveredLinkMarkRange.
|
|
81
|
+
const hoveredLinkElement = event.target;
|
|
82
|
+
const posInHoveredLinkMark =
|
|
83
|
+
this.pmView.posAtDOM(hoveredLinkElement, 0) + 1;
|
|
84
|
+
const resolvedPosInHoveredLinkMark =
|
|
85
|
+
this.pmView.state.doc.resolve(posInHoveredLinkMark);
|
|
86
|
+
const marksAtPos = resolvedPosInHoveredLinkMark.marks();
|
|
88
87
|
|
|
89
88
|
for (const mark of marksAtPos) {
|
|
90
89
|
if (
|
|
91
90
|
mark.type.name === this.pmView.state.schema.mark("link").type.name
|
|
92
91
|
) {
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
getMarkRange(
|
|
96
|
-
|
|
97
|
-
mark.type,
|
|
98
|
-
mark.attrs
|
|
99
|
-
) || undefined;
|
|
92
|
+
this.mouseHoveredLinkMark = mark;
|
|
93
|
+
this.mouseHoveredLinkMarkRange =
|
|
94
|
+
getMarkRange(resolvedPosInHoveredLinkMark, mark.type, mark.attrs) ||
|
|
95
|
+
undefined;
|
|
100
96
|
|
|
101
97
|
break;
|
|
102
98
|
}
|
|
@@ -113,7 +109,7 @@ class HyperlinkToolbarView {
|
|
|
113
109
|
|
|
114
110
|
if (
|
|
115
111
|
// Toolbar is open.
|
|
116
|
-
this.
|
|
112
|
+
this.linkMark &&
|
|
117
113
|
// An element is clicked.
|
|
118
114
|
event &&
|
|
119
115
|
event.target &&
|
|
@@ -131,27 +127,27 @@ class HyperlinkToolbarView {
|
|
|
131
127
|
};
|
|
132
128
|
|
|
133
129
|
scrollHandler = () => {
|
|
134
|
-
if (this.
|
|
130
|
+
if (this.linkMark !== undefined) {
|
|
135
131
|
if (this.state?.show) {
|
|
136
132
|
this.state.referencePos = posToDOMRect(
|
|
137
133
|
this.pmView,
|
|
138
|
-
this.
|
|
139
|
-
this.
|
|
134
|
+
this.linkMarkRange!.from,
|
|
135
|
+
this.linkMarkRange!.to
|
|
140
136
|
);
|
|
141
137
|
this.emitUpdate();
|
|
142
138
|
}
|
|
143
139
|
}
|
|
144
140
|
};
|
|
145
141
|
|
|
146
|
-
|
|
142
|
+
editLink(url: string, text: string) {
|
|
147
143
|
const tr = this.pmView.state.tr.insertText(
|
|
148
144
|
text,
|
|
149
|
-
this.
|
|
150
|
-
this.
|
|
145
|
+
this.linkMarkRange!.from,
|
|
146
|
+
this.linkMarkRange!.to
|
|
151
147
|
);
|
|
152
148
|
tr.addMark(
|
|
153
|
-
this.
|
|
154
|
-
this.
|
|
149
|
+
this.linkMarkRange!.from,
|
|
150
|
+
this.linkMarkRange!.from + text.length,
|
|
155
151
|
this.pmView.state.schema.mark("link", { href: url })
|
|
156
152
|
);
|
|
157
153
|
this.pmView.dispatch(tr);
|
|
@@ -163,13 +159,13 @@ class HyperlinkToolbarView {
|
|
|
163
159
|
}
|
|
164
160
|
}
|
|
165
161
|
|
|
166
|
-
|
|
162
|
+
deleteLink() {
|
|
167
163
|
this.pmView.dispatch(
|
|
168
164
|
this.pmView.state.tr
|
|
169
165
|
.removeMark(
|
|
170
|
-
this.
|
|
171
|
-
this.
|
|
172
|
-
this.
|
|
166
|
+
this.linkMarkRange!.from,
|
|
167
|
+
this.linkMarkRange!.to,
|
|
168
|
+
this.linkMark!.type
|
|
173
169
|
)
|
|
174
170
|
.setMeta("preventAutolink", true)
|
|
175
171
|
);
|
|
@@ -186,19 +182,19 @@ class HyperlinkToolbarView {
|
|
|
186
182
|
return;
|
|
187
183
|
}
|
|
188
184
|
|
|
189
|
-
// Saves the currently hovered
|
|
190
|
-
const
|
|
185
|
+
// Saves the currently hovered link mark before it's updated.
|
|
186
|
+
const prevLinkMark = this.linkMark;
|
|
191
187
|
|
|
192
|
-
// Resets the currently hovered
|
|
193
|
-
this.
|
|
194
|
-
this.
|
|
188
|
+
// Resets the currently hovered link mark.
|
|
189
|
+
this.linkMark = undefined;
|
|
190
|
+
this.linkMarkRange = undefined;
|
|
195
191
|
|
|
196
|
-
// Resets the
|
|
197
|
-
this.
|
|
198
|
-
this.
|
|
192
|
+
// Resets the link mark currently hovered by the keyboard cursor.
|
|
193
|
+
this.keyboardHoveredLinkMark = undefined;
|
|
194
|
+
this.keyboardHoveredLinkMarkRange = undefined;
|
|
199
195
|
|
|
200
|
-
// Finds link mark at the editor selection's position to update
|
|
201
|
-
//
|
|
196
|
+
// Finds link mark at the editor selection's position to update keyboardHoveredLinkMark and
|
|
197
|
+
// keyboardHoveredLinkMarkRange.
|
|
202
198
|
if (this.pmView.state.selection.empty) {
|
|
203
199
|
const marksAtPos = this.pmView.state.selection.$from.marks();
|
|
204
200
|
|
|
@@ -206,8 +202,8 @@ class HyperlinkToolbarView {
|
|
|
206
202
|
if (
|
|
207
203
|
mark.type.name === this.pmView.state.schema.mark("link").type.name
|
|
208
204
|
) {
|
|
209
|
-
this.
|
|
210
|
-
this.
|
|
205
|
+
this.keyboardHoveredLinkMark = mark;
|
|
206
|
+
this.keyboardHoveredLinkMarkRange =
|
|
211
207
|
getMarkRange(
|
|
212
208
|
this.pmView.state.selection.$from,
|
|
213
209
|
mark.type,
|
|
@@ -219,29 +215,29 @@ class HyperlinkToolbarView {
|
|
|
219
215
|
}
|
|
220
216
|
}
|
|
221
217
|
|
|
222
|
-
if (this.
|
|
223
|
-
this.
|
|
224
|
-
this.
|
|
218
|
+
if (this.mouseHoveredLinkMark) {
|
|
219
|
+
this.linkMark = this.mouseHoveredLinkMark;
|
|
220
|
+
this.linkMarkRange = this.mouseHoveredLinkMarkRange;
|
|
225
221
|
}
|
|
226
222
|
|
|
227
|
-
// Keyboard cursor position takes precedence over mouse hovered
|
|
228
|
-
if (this.
|
|
229
|
-
this.
|
|
230
|
-
this.
|
|
223
|
+
// Keyboard cursor position takes precedence over mouse hovered link.
|
|
224
|
+
if (this.keyboardHoveredLinkMark) {
|
|
225
|
+
this.linkMark = this.keyboardHoveredLinkMark;
|
|
226
|
+
this.linkMarkRange = this.keyboardHoveredLinkMarkRange;
|
|
231
227
|
}
|
|
232
228
|
|
|
233
|
-
if (this.
|
|
229
|
+
if (this.linkMark && this.editor.isEditable) {
|
|
234
230
|
this.state = {
|
|
235
231
|
show: true,
|
|
236
232
|
referencePos: posToDOMRect(
|
|
237
233
|
this.pmView,
|
|
238
|
-
this.
|
|
239
|
-
this.
|
|
234
|
+
this.linkMarkRange!.from,
|
|
235
|
+
this.linkMarkRange!.to
|
|
240
236
|
),
|
|
241
|
-
url: this.
|
|
237
|
+
url: this.linkMark!.attrs.href,
|
|
242
238
|
text: this.pmView.state.doc.textBetween(
|
|
243
|
-
this.
|
|
244
|
-
this.
|
|
239
|
+
this.linkMarkRange!.from,
|
|
240
|
+
this.linkMarkRange!.to
|
|
245
241
|
),
|
|
246
242
|
};
|
|
247
243
|
this.emitUpdate();
|
|
@@ -252,8 +248,8 @@ class HyperlinkToolbarView {
|
|
|
252
248
|
// Hides menu.
|
|
253
249
|
if (
|
|
254
250
|
this.state?.show &&
|
|
255
|
-
|
|
256
|
-
(!this.
|
|
251
|
+
prevLinkMark &&
|
|
252
|
+
(!this.linkMark || !this.editor.isEditable)
|
|
257
253
|
) {
|
|
258
254
|
this.state.show = false;
|
|
259
255
|
this.emitUpdate();
|
|
@@ -269,24 +265,22 @@ class HyperlinkToolbarView {
|
|
|
269
265
|
}
|
|
270
266
|
}
|
|
271
267
|
|
|
272
|
-
export const
|
|
273
|
-
"HyperlinkToolbarPlugin"
|
|
274
|
-
);
|
|
268
|
+
export const linkToolbarPluginKey = new PluginKey("LinkToolbarPlugin");
|
|
275
269
|
|
|
276
|
-
export class
|
|
270
|
+
export class LinkToolbarProsemirrorPlugin<
|
|
277
271
|
BSchema extends BlockSchema,
|
|
278
272
|
I extends InlineContentSchema,
|
|
279
273
|
S extends StyleSchema
|
|
280
274
|
> extends EventEmitter<any> {
|
|
281
|
-
private view:
|
|
275
|
+
private view: LinkToolbarView | undefined;
|
|
282
276
|
public readonly plugin: Plugin;
|
|
283
277
|
|
|
284
278
|
constructor(editor: BlockNoteEditor<BSchema, I, S>) {
|
|
285
279
|
super();
|
|
286
280
|
this.plugin = new Plugin({
|
|
287
|
-
key:
|
|
281
|
+
key: linkToolbarPluginKey,
|
|
288
282
|
view: (editorView) => {
|
|
289
|
-
this.view = new
|
|
283
|
+
this.view = new LinkToolbarView(editor, editorView, (state) => {
|
|
290
284
|
this.emit("update", state);
|
|
291
285
|
});
|
|
292
286
|
return this.view;
|
|
@@ -294,39 +288,41 @@ export class HyperlinkToolbarProsemirrorPlugin<
|
|
|
294
288
|
});
|
|
295
289
|
}
|
|
296
290
|
|
|
297
|
-
public onUpdate(callback: (state:
|
|
291
|
+
public onUpdate(callback: (state: LinkToolbarState) => void) {
|
|
298
292
|
return this.on("update", callback);
|
|
299
293
|
}
|
|
300
294
|
|
|
301
295
|
/**
|
|
302
|
-
* Edit the currently hovered
|
|
296
|
+
* Edit the currently hovered link.
|
|
303
297
|
*/
|
|
304
|
-
public
|
|
305
|
-
this.view!.
|
|
298
|
+
public editLink = (url: string, text: string) => {
|
|
299
|
+
this.view!.editLink(url, text);
|
|
306
300
|
};
|
|
307
301
|
|
|
308
302
|
/**
|
|
309
|
-
* Delete the currently hovered
|
|
303
|
+
* Delete the currently hovered link.
|
|
310
304
|
*/
|
|
311
|
-
public
|
|
312
|
-
this.view!.
|
|
305
|
+
public deleteLink = () => {
|
|
306
|
+
this.view!.deleteLink();
|
|
313
307
|
};
|
|
314
308
|
|
|
315
309
|
/**
|
|
316
|
-
* When hovering on/off
|
|
317
|
-
*
|
|
310
|
+
* When hovering on/off links using the mouse cursor, the link toolbar will
|
|
311
|
+
* open & close with a delay.
|
|
318
312
|
*
|
|
319
|
-
* This function starts the delay timer, and should be used for when the mouse
|
|
313
|
+
* This function starts the delay timer, and should be used for when the mouse
|
|
314
|
+
* cursor enters the link toolbar.
|
|
320
315
|
*/
|
|
321
316
|
public startHideTimer = () => {
|
|
322
317
|
this.view!.startMenuUpdateTimer();
|
|
323
318
|
};
|
|
324
319
|
|
|
325
320
|
/**
|
|
326
|
-
* When hovering on/off
|
|
327
|
-
*
|
|
321
|
+
* When hovering on/off links using the mouse cursor, the link toolbar will
|
|
322
|
+
* open & close with a delay.
|
|
328
323
|
*
|
|
329
|
-
* This function stops the delay timer, and should be used for when the mouse
|
|
324
|
+
* This function stops the delay timer, and should be used for when the mouse
|
|
325
|
+
* cursor exits the link toolbar.
|
|
330
326
|
*/
|
|
331
327
|
public stopHideTimer = () => {
|
|
332
328
|
this.view!.stopMenuUpdateTimer();
|
|
@@ -205,7 +205,7 @@ export function getDefaultSlashMenuItems<
|
|
|
205
205
|
|
|
206
206
|
// Immediately open the image toolbar
|
|
207
207
|
editor.prosemirrorView.dispatch(
|
|
208
|
-
editor._tiptapEditor.state.tr.setMeta(editor.
|
|
208
|
+
editor._tiptapEditor.state.tr.setMeta(editor.imagePanel!.plugin, {
|
|
209
209
|
block: insertedBlock,
|
|
210
210
|
})
|
|
211
211
|
);
|
package/src/index.ts
CHANGED
|
@@ -11,8 +11,8 @@ export * from "./editor/BlockNoteSchema";
|
|
|
11
11
|
export * from "./editor/selectionTypes";
|
|
12
12
|
export * from "./extensions-shared/UiElementPosition";
|
|
13
13
|
export * from "./extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
14
|
-
export * from "./extensions/
|
|
15
|
-
export * from "./extensions/
|
|
14
|
+
export * from "./extensions/ImagePanel/ImageToolbarPlugin";
|
|
15
|
+
export * from "./extensions/LinkToolbar/LinkToolbarPlugin";
|
|
16
16
|
export * from "./extensions/SideMenu/SideMenuPlugin";
|
|
17
17
|
export * from "./extensions/SuggestionMenu/DefaultSuggestionItem";
|
|
18
18
|
export * from "./extensions/SuggestionMenu/SuggestionPlugin";
|
|
@@ -3,18 +3,18 @@ import { Node } from "prosemirror-model";
|
|
|
3
3
|
import * as Y from "yjs";
|
|
4
4
|
import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/defaultBlocks";
|
|
5
5
|
import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
6
|
-
import {
|
|
7
|
-
import { ImageToolbarProsemirrorPlugin } from "../extensions/ImageToolbar/ImageToolbarPlugin";
|
|
6
|
+
import { LinkToolbarProsemirrorPlugin } from "../extensions/LinkToolbar/LinkToolbarPlugin";
|
|
8
7
|
import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin";
|
|
9
8
|
import { SuggestionMenuProseMirrorPlugin } from "../extensions/SuggestionMenu/SuggestionPlugin";
|
|
9
|
+
import { ImagePanelProsemirrorPlugin } from "../extensions/ImagePanel/ImageToolbarPlugin";
|
|
10
10
|
import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin";
|
|
11
11
|
import { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, InlineContentSchema, InlineContentSpecs, PartialInlineContent, StyleSchema, StyleSpecs, Styles } from "../schema";
|
|
12
12
|
import { NoInfer } from "../util/typescript";
|
|
13
13
|
import { TextCursorPosition } from "./cursorPositionTypes";
|
|
14
14
|
import { Selection } from "./selectionTypes";
|
|
15
|
-
import "./Block.css";
|
|
16
15
|
import { BlockNoteSchema } from "./BlockNoteSchema";
|
|
17
16
|
import { BlockNoteTipTapEditor } from "./BlockNoteTipTapEditor";
|
|
17
|
+
import "./Block.css";
|
|
18
18
|
import "./editor.css";
|
|
19
19
|
export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> = {
|
|
20
20
|
enableBlockNoteExtensions: boolean;
|
|
@@ -79,10 +79,10 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
79
79
|
readonly inlineContentImplementations: InlineContentSpecs;
|
|
80
80
|
readonly styleImplementations: StyleSpecs;
|
|
81
81
|
readonly formattingToolbar: FormattingToolbarProsemirrorPlugin;
|
|
82
|
-
readonly
|
|
82
|
+
readonly linkToolbar: LinkToolbarProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
83
83
|
readonly sideMenu: SideMenuProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
84
84
|
readonly suggestionMenus: SuggestionMenuProseMirrorPlugin<BSchema, ISchema, SSchema>;
|
|
85
|
-
readonly
|
|
85
|
+
readonly imagePanel?: ImagePanelProsemirrorPlugin<ISchema, SSchema>;
|
|
86
86
|
readonly tableHandles?: TableHandlesProsemirrorPlugin<ISchema, SSchema>;
|
|
87
87
|
readonly uploadFile: ((file: File) => Promise<string>) | undefined;
|
|
88
88
|
static create<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(options?: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>): BlockNoteEditor<BSchema, ISchema, SSchema>;
|
|
@@ -5,16 +5,16 @@ import type { BlockFromConfig, InlineContentSchema, StyleSchema } from "../../sc
|
|
|
5
5
|
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
6
6
|
import { EventEmitter } from "../../util/EventEmitter";
|
|
7
7
|
import { DefaultBlockSchema } from "../../blocks/defaultBlocks";
|
|
8
|
-
export type
|
|
8
|
+
export type ImagePanelState<I extends InlineContentSchema, S extends StyleSchema> = UiElementPosition & {
|
|
9
9
|
block: BlockFromConfig<DefaultBlockSchema["image"], I, S>;
|
|
10
10
|
};
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class ImagePanelView<I extends InlineContentSchema, S extends StyleSchema> {
|
|
12
12
|
private readonly pluginKey;
|
|
13
13
|
private readonly pmView;
|
|
14
|
-
state?:
|
|
14
|
+
state?: ImagePanelState<I, S>;
|
|
15
15
|
emitUpdate: () => void;
|
|
16
16
|
prevWasEditable: boolean | null;
|
|
17
|
-
constructor(pluginKey: PluginKey, pmView: EditorView, emitUpdate: (state:
|
|
17
|
+
constructor(pluginKey: PluginKey, pmView: EditorView, emitUpdate: (state: ImagePanelState<I, S>) => void);
|
|
18
18
|
mouseDownHandler: () => void;
|
|
19
19
|
dragstartHandler: () => void;
|
|
20
20
|
blurHandler: (event: FocusEvent) => void;
|
|
@@ -22,11 +22,11 @@ export declare class ImageToolbarView<I extends InlineContentSchema, S extends S
|
|
|
22
22
|
update(view: EditorView, prevState: EditorState): void;
|
|
23
23
|
destroy(): void;
|
|
24
24
|
}
|
|
25
|
-
export declare class
|
|
25
|
+
export declare class ImagePanelProsemirrorPlugin<I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
|
|
26
26
|
private view;
|
|
27
27
|
readonly plugin: Plugin;
|
|
28
28
|
constructor(_editor: BlockNoteEditor<{
|
|
29
29
|
image: DefaultBlockSchema["image"];
|
|
30
30
|
}, I, S>);
|
|
31
|
-
onUpdate(callback: (state:
|
|
31
|
+
onUpdate(callback: (state: ImagePanelState<I, S>) => void): () => void;
|
|
32
32
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
+
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
5
|
+
import { EventEmitter } from "../../util/EventEmitter";
|
|
6
|
+
export type LinkToolbarState = UiElementPosition & {
|
|
7
|
+
url: string;
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const linkToolbarPluginKey: PluginKey<any>;
|
|
11
|
+
export declare class LinkToolbarProsemirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
|
|
12
|
+
private view;
|
|
13
|
+
readonly plugin: Plugin;
|
|
14
|
+
constructor(editor: BlockNoteEditor<BSchema, I, S>);
|
|
15
|
+
onUpdate(callback: (state: LinkToolbarState) => void): () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Edit the currently hovered link.
|
|
18
|
+
*/
|
|
19
|
+
editLink: (url: string, text: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Delete the currently hovered link.
|
|
22
|
+
*/
|
|
23
|
+
deleteLink: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* When hovering on/off links using the mouse cursor, the link toolbar will
|
|
26
|
+
* open & close with a delay.
|
|
27
|
+
*
|
|
28
|
+
* This function starts the delay timer, and should be used for when the mouse
|
|
29
|
+
* cursor enters the link toolbar.
|
|
30
|
+
*/
|
|
31
|
+
startHideTimer: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* When hovering on/off links using the mouse cursor, the link toolbar will
|
|
34
|
+
* open & close with a delay.
|
|
35
|
+
*
|
|
36
|
+
* This function stops the delay timer, and should be used for when the mouse
|
|
37
|
+
* cursor exits the link toolbar.
|
|
38
|
+
*/
|
|
39
|
+
stopHideTimer: () => void;
|
|
40
|
+
}
|
package/types/src/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export * from "./editor/BlockNoteSchema";
|
|
|
11
11
|
export * from "./editor/selectionTypes";
|
|
12
12
|
export * from "./extensions-shared/UiElementPosition";
|
|
13
13
|
export * from "./extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
14
|
-
export * from "./extensions/
|
|
15
|
-
export * from "./extensions/
|
|
14
|
+
export * from "./extensions/ImagePanel/ImageToolbarPlugin";
|
|
15
|
+
export * from "./extensions/LinkToolbar/LinkToolbarPlugin";
|
|
16
16
|
export * from "./extensions/SideMenu/SideMenuPlugin";
|
|
17
17
|
export * from "./extensions/SuggestionMenu/DefaultSuggestionItem";
|
|
18
18
|
export * from "./extensions/SuggestionMenu/SuggestionPlugin";
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
-
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
-
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
-
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
5
|
-
import { EventEmitter } from "../../util/EventEmitter";
|
|
6
|
-
export type HyperlinkToolbarState = UiElementPosition & {
|
|
7
|
-
url: string;
|
|
8
|
-
text: string;
|
|
9
|
-
};
|
|
10
|
-
export declare const hyperlinkToolbarPluginKey: PluginKey<any>;
|
|
11
|
-
export declare class HyperlinkToolbarProsemirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
|
|
12
|
-
private view;
|
|
13
|
-
readonly plugin: Plugin;
|
|
14
|
-
constructor(editor: BlockNoteEditor<BSchema, I, S>);
|
|
15
|
-
onUpdate(callback: (state: HyperlinkToolbarState) => void): () => void;
|
|
16
|
-
/**
|
|
17
|
-
* Edit the currently hovered hyperlink.
|
|
18
|
-
*/
|
|
19
|
-
editHyperlink: (url: string, text: string) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Delete the currently hovered hyperlink.
|
|
22
|
-
*/
|
|
23
|
-
deleteHyperlink: () => void;
|
|
24
|
-
/**
|
|
25
|
-
* When hovering on/off hyperlinks using the mouse cursor, the hyperlink
|
|
26
|
-
* toolbar will open & close with a delay.
|
|
27
|
-
*
|
|
28
|
-
* This function starts the delay timer, and should be used for when the mouse cursor enters the hyperlink toolbar.
|
|
29
|
-
*/
|
|
30
|
-
startHideTimer: () => void;
|
|
31
|
-
/**
|
|
32
|
-
* When hovering on/off hyperlinks using the mouse cursor, the hyperlink
|
|
33
|
-
* toolbar will open & close with a delay.
|
|
34
|
-
*
|
|
35
|
-
* This function stops the delay timer, and should be used for when the mouse cursor exits the hyperlink toolbar.
|
|
36
|
-
*/
|
|
37
|
-
stopHideTimer: () => void;
|
|
38
|
-
}
|