mirror of https://github.com/fantasticit/think.git
tiptap: fix get bubble menu container
This commit is contained in:
parent
276175cb88
commit
8e10998859
|
@ -158,7 +158,9 @@ export class BubbleMenuView {
|
||||||
const { ranges } = selection;
|
const { ranges } = selection;
|
||||||
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
||||||
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
||||||
const node = view.domAtPos(from).node as HTMLElement;
|
const domAtPos = view.domAtPos(from).node as HTMLElement;
|
||||||
|
const nodeDOM = view.nodeDOM(from) as HTMLElement;
|
||||||
|
const node = nodeDOM || domAtPos;
|
||||||
|
|
||||||
const shouldShow =
|
const shouldShow =
|
||||||
this.editor.isEditable &&
|
this.editor.isEditable &&
|
||||||
|
@ -179,15 +181,15 @@ export class BubbleMenuView {
|
||||||
|
|
||||||
this.tippy?.setProps({
|
this.tippy?.setProps({
|
||||||
getReferenceClientRect: () => {
|
getReferenceClientRect: () => {
|
||||||
let toMountNode;
|
let toMountNode = null;
|
||||||
|
|
||||||
if (isNodeSelection(state.selection)) {
|
if (isNodeSelection(state.selection)) {
|
||||||
if (this.getRenderContainer) {
|
if (this.getRenderContainer && node) {
|
||||||
toMountNode = this.getRenderContainer(node);
|
toMountNode = this.getRenderContainer(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getRenderContainer) {
|
if (this.getRenderContainer && node) {
|
||||||
toMountNode = this.getRenderContainer(node);
|
toMountNode = this.getRenderContainer(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +197,10 @@ export class BubbleMenuView {
|
||||||
return toMountNode.getBoundingClientRect();
|
return toMountNode.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node && node.getBoundingClientRect) {
|
||||||
|
return node.getBoundingClientRect();
|
||||||
|
}
|
||||||
|
|
||||||
return posToDOMRect(view, from, to);
|
return posToDOMRect(view, from, to);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue