Skip to content

Commit 12f1f41

Browse files
committed
Fixed mount adding editor as child instead of replacing element
1 parent b5b8cd7 commit 12f1f41

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,12 +1061,13 @@ export class BlockNoteEditor<
10611061
return extension;
10621062
}
10631063
/**
1064-
* Mount the editor to a parent DOM element.
1064+
* Mount the editor to a DOM element.
10651065
*
10661066
* @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
10671067
*/
1068-
public mount = (parentElement: HTMLElement) => {
1069-
this._tiptapEditor.mount(parentElement);
1068+
public mount = (element: HTMLElement) => {
1069+
// TODO: Fix typing for this in a TipTap PR
1070+
this._tiptapEditor.mount({ mount: element } as any);
10701071
};
10711072

10721073
/**

packages/core/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class FormattingToolbarView implements PluginView {
9999
return;
100100
}
101101

102-
const editorWrapper = this.pmView.dom.parentElement!.parentElement!;
102+
const editorWrapper = this.pmView.dom.parentElement!;
103103

104104
// Checks if the focus is moving to an element outside the editor. If it is,
105105
// the toolbar is hidden.
@@ -127,7 +127,7 @@ export class FormattingToolbarView implements PluginView {
127127
if (!element) {
128128
return false;
129129
}
130-
const editorWrapper = this.pmView.dom.parentElement!.parentElement!;
130+
const editorWrapper = this.pmView.dom.parentElement!;
131131
if (!editorWrapper) {
132132
return false;
133133
}

packages/core/src/extensions/LinkToolbar/LinkToolbarPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class LinkToolbarView implements PluginView {
119119
};
120120

121121
clickHandler = (event: MouseEvent) => {
122-
const editorWrapper = this.pmView.dom.parentElement!.parentElement!;
122+
const editorWrapper = this.pmView.dom.parentElement!;
123123

124124
if (
125125
// Toolbar is open.

packages/core/src/extensions/SideMenu/SideMenuPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ export class SideMenuView<
571571
this.mousePos.y < editorOuterBoundingBox.bottom;
572572

573573
// TODO: remove parentElement, but then we need to remove padding from boundingbox or find a different solution
574-
const editorWrapper = this.pmView.dom!.parentElement!.parentElement!;
574+
const editorWrapper = this.pmView.dom!.parentElement!;
575575

576576
// Doesn't update if the mouse hovers an element that's over the editor but
577577
// isn't a part of it or the side menu.

0 commit comments

Comments
 (0)