@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.
Files changed (26) hide show
  1. package/dist/blocknote.js +958 -940
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +6 -6
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/dist/webpack-stats.json +1 -1
  7. package/package.json +2 -2
  8. package/src/api/getCurrentBlockContentType.ts +14 -0
  9. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +50 -21
  10. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +1 -1
  11. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +18 -5
  12. package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +7 -1
  13. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +18 -5
  14. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +14 -5
  15. package/src/editor/BlockNoteEditor.ts +14 -14
  16. package/src/editor/editor.css +0 -1
  17. package/src/extensions/{ImageToolbar → ImagePanel}/ImageToolbarPlugin.ts +14 -14
  18. package/src/extensions/{HyperlinkToolbar/HyperlinkToolbarPlugin.ts → LinkToolbar/LinkToolbarPlugin.ts} +87 -91
  19. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +1 -1
  20. package/src/index.ts +2 -2
  21. package/types/src/api/getCurrentBlockContentType.d.ts +2 -0
  22. package/types/src/editor/BlockNoteEditor.d.ts +5 -5
  23. package/types/src/extensions/{ImageToolbar → ImagePanel}/ImageToolbarPlugin.d.ts +6 -6
  24. package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +40 -0
  25. package/types/src/index.d.ts +2 -2
  26. 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 HyperlinkToolbarState = UiElementPosition & {
12
- // The hovered hyperlink's URL, and the text it's displayed with in the
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 HyperlinkToolbarView {
19
- public state?: HyperlinkToolbarState;
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
- mouseHoveredHyperlinkMark: Mark | undefined;
27
- mouseHoveredHyperlinkMarkRange: Range | undefined;
26
+ mouseHoveredLinkMark: Mark | undefined;
27
+ mouseHoveredLinkMarkRange: Range | undefined;
28
28
 
29
- keyboardHoveredHyperlinkMark: Mark | undefined;
30
- keyboardHoveredHyperlinkMarkRange: Range | undefined;
29
+ keyboardHoveredLinkMark: Mark | undefined;
30
+ keyboardHoveredLinkMarkRange: Range | undefined;
31
31
 
32
- hyperlinkMark: Mark | undefined;
33
- hyperlinkMarkRange: Range | undefined;
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: HyperlinkToolbarState) => void
38
+ emitUpdate: (state: LinkToolbarState) => void
39
39
  ) {
40
40
  this.emitUpdate = () => {
41
41
  if (!this.state) {
42
- throw new Error("Attempting to update uninitialized hyperlink toolbar");
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 hyperlink mark currently hovered by the mouse cursor.
70
- this.mouseHoveredHyperlinkMark = undefined;
71
- this.mouseHoveredHyperlinkMarkRange = undefined;
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 mouseHoveredHyperlinkMark and
80
- // mouseHoveredHyperlinkMarkRange.
81
- const hoveredHyperlinkElement = event.target;
82
- const posInHoveredHyperlinkMark =
83
- this.pmView.posAtDOM(hoveredHyperlinkElement, 0) + 1;
84
- const resolvedPosInHoveredHyperlinkMark = this.pmView.state.doc.resolve(
85
- posInHoveredHyperlinkMark
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.mouseHoveredHyperlinkMark = mark;
94
- this.mouseHoveredHyperlinkMarkRange =
95
- getMarkRange(
96
- resolvedPosInHoveredHyperlinkMark,
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.hyperlinkMark &&
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.hyperlinkMark !== undefined) {
130
+ if (this.linkMark !== undefined) {
135
131
  if (this.state?.show) {
136
132
  this.state.referencePos = posToDOMRect(
137
133
  this.pmView,
138
- this.hyperlinkMarkRange!.from,
139
- this.hyperlinkMarkRange!.to
134
+ this.linkMarkRange!.from,
135
+ this.linkMarkRange!.to
140
136
  );
141
137
  this.emitUpdate();
142
138
  }
143
139
  }
144
140
  };
145
141
 
146
- editHyperlink(url: string, text: string) {
142
+ editLink(url: string, text: string) {
147
143
  const tr = this.pmView.state.tr.insertText(
148
144
  text,
149
- this.hyperlinkMarkRange!.from,
150
- this.hyperlinkMarkRange!.to
145
+ this.linkMarkRange!.from,
146
+ this.linkMarkRange!.to
151
147
  );
152
148
  tr.addMark(
153
- this.hyperlinkMarkRange!.from,
154
- this.hyperlinkMarkRange!.from + text.length,
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
- deleteHyperlink() {
162
+ deleteLink() {
167
163
  this.pmView.dispatch(
168
164
  this.pmView.state.tr
169
165
  .removeMark(
170
- this.hyperlinkMarkRange!.from,
171
- this.hyperlinkMarkRange!.to,
172
- this.hyperlinkMark!.type
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 hyperlink mark before it's updated.
190
- const prevHyperlinkMark = this.hyperlinkMark;
185
+ // Saves the currently hovered link mark before it's updated.
186
+ const prevLinkMark = this.linkMark;
191
187
 
192
- // Resets the currently hovered hyperlink mark.
193
- this.hyperlinkMark = undefined;
194
- this.hyperlinkMarkRange = undefined;
188
+ // Resets the currently hovered link mark.
189
+ this.linkMark = undefined;
190
+ this.linkMarkRange = undefined;
195
191
 
196
- // Resets the hyperlink mark currently hovered by the keyboard cursor.
197
- this.keyboardHoveredHyperlinkMark = undefined;
198
- this.keyboardHoveredHyperlinkMarkRange = undefined;
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 keyboardHoveredHyperlinkMark and
201
- // keyboardHoveredHyperlinkMarkRange.
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.keyboardHoveredHyperlinkMark = mark;
210
- this.keyboardHoveredHyperlinkMarkRange =
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.mouseHoveredHyperlinkMark) {
223
- this.hyperlinkMark = this.mouseHoveredHyperlinkMark;
224
- this.hyperlinkMarkRange = this.mouseHoveredHyperlinkMarkRange;
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 hyperlink.
228
- if (this.keyboardHoveredHyperlinkMark) {
229
- this.hyperlinkMark = this.keyboardHoveredHyperlinkMark;
230
- this.hyperlinkMarkRange = this.keyboardHoveredHyperlinkMarkRange;
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.hyperlinkMark && this.editor.isEditable) {
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.hyperlinkMarkRange!.from,
239
- this.hyperlinkMarkRange!.to
234
+ this.linkMarkRange!.from,
235
+ this.linkMarkRange!.to
240
236
  ),
241
- url: this.hyperlinkMark!.attrs.href,
237
+ url: this.linkMark!.attrs.href,
242
238
  text: this.pmView.state.doc.textBetween(
243
- this.hyperlinkMarkRange!.from,
244
- this.hyperlinkMarkRange!.to
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
- prevHyperlinkMark &&
256
- (!this.hyperlinkMark || !this.editor.isEditable)
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 hyperlinkToolbarPluginKey = new PluginKey(
273
- "HyperlinkToolbarPlugin"
274
- );
268
+ export const linkToolbarPluginKey = new PluginKey("LinkToolbarPlugin");
275
269
 
276
- export class HyperlinkToolbarProsemirrorPlugin<
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: HyperlinkToolbarView | undefined;
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: hyperlinkToolbarPluginKey,
281
+ key: linkToolbarPluginKey,
288
282
  view: (editorView) => {
289
- this.view = new HyperlinkToolbarView(editor, editorView, (state) => {
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: HyperlinkToolbarState) => void) {
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 hyperlink.
296
+ * Edit the currently hovered link.
303
297
  */
304
- public editHyperlink = (url: string, text: string) => {
305
- this.view!.editHyperlink(url, text);
298
+ public editLink = (url: string, text: string) => {
299
+ this.view!.editLink(url, text);
306
300
  };
307
301
 
308
302
  /**
309
- * Delete the currently hovered hyperlink.
303
+ * Delete the currently hovered link.
310
304
  */
311
- public deleteHyperlink = () => {
312
- this.view!.deleteHyperlink();
305
+ public deleteLink = () => {
306
+ this.view!.deleteLink();
313
307
  };
314
308
 
315
309
  /**
316
- * When hovering on/off hyperlinks using the mouse cursor, the hyperlink
317
- * toolbar will open & close with a delay.
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 cursor enters the hyperlink toolbar.
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 hyperlinks using the mouse cursor, the hyperlink
327
- * toolbar will open & close with a delay.
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 cursor exits the hyperlink toolbar.
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.imageToolbar!.plugin, {
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/HyperlinkToolbar/HyperlinkToolbarPlugin";
15
- export * from "./extensions/ImageToolbar/ImageToolbarPlugin";
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";
@@ -0,0 +1,2 @@
1
+ import { Editor } from "@tiptap/core";
2
+ export declare const getCurrentBlockContentType: (editor: Editor) => string | undefined;
@@ -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 { HyperlinkToolbarProsemirrorPlugin } from "../extensions/HyperlinkToolbar/HyperlinkToolbarPlugin";
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 hyperlinkToolbar: HyperlinkToolbarProsemirrorPlugin<BSchema, ISchema, SSchema>;
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 imageToolbar?: ImageToolbarProsemirrorPlugin<ISchema, SSchema>;
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 ImageToolbarState<I extends InlineContentSchema, S extends StyleSchema> = UiElementPosition & {
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 ImageToolbarView<I extends InlineContentSchema, S extends StyleSchema> {
11
+ export declare class ImagePanelView<I extends InlineContentSchema, S extends StyleSchema> {
12
12
  private readonly pluginKey;
13
13
  private readonly pmView;
14
- state?: ImageToolbarState<I, S>;
14
+ state?: ImagePanelState<I, S>;
15
15
  emitUpdate: () => void;
16
16
  prevWasEditable: boolean | null;
17
- constructor(pluginKey: PluginKey, pmView: EditorView, emitUpdate: (state: ImageToolbarState<I, S>) => void);
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 ImageToolbarProsemirrorPlugin<I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
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: ImageToolbarState<I, S>) => void): () => void;
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
+ }
@@ -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/HyperlinkToolbar/HyperlinkToolbarPlugin";
15
- export * from "./extensions/ImageToolbar/ImageToolbarPlugin";
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
- }