This commit is contained in:
Vanessa 2023-04-13 10:52:40 +08:00
parent 28232dd18c
commit 6215e1c6ab
2 changed files with 6 additions and 5 deletions

View file

@ -28,7 +28,7 @@ export class InlineMath extends ToolbarItem {
let hasMath = false;
// https://github.com/siyuan-note/siyuan/issues/6007
range.cloneContents().childNodes.forEach((item: HTMLElement) => {
if ((item.nodeType !== 3 && item.getAttribute("data-type").indexOf("inline-math") > -1) ||
if ((item.nodeType !== 3 && (item.getAttribute("data-type") || "").indexOf("inline-math") > -1) ||
(item.nodeType == 3 && item.textContent === "")) {
// 是否仅选中数学公式
hasMath = true;

View file

@ -901,14 +901,15 @@ export class Toolbar {
}
return;
}
if (this.subElement.clientHeight <= window.innerHeight - nodeRect.bottom || this.subElement.clientHeight <= nodeRect.top) {
const bottom = nodeRect.bottom === nodeRect.top ? nodeRect.bottom + 26 : nodeRect.bottom;
if (this.subElement.clientHeight <= window.innerHeight - bottom || this.subElement.clientHeight <= nodeRect.top) {
if (types.includes("inline-math") || isInlineMemo) {
setPosition(this.subElement, nodeRect.left, nodeRect.bottom, nodeRect.height);
setPosition(this.subElement, nodeRect.left, bottom, nodeRect.height || 26);
} else {
setPosition(this.subElement, nodeRect.left + (nodeRect.width - this.subElement.clientWidth) / 2, nodeRect.bottom, nodeRect.height);
setPosition(this.subElement, nodeRect.left + (nodeRect.width - this.subElement.clientWidth) / 2, bottom, nodeRect.height || 26);
}
} else {
setPosition(this.subElement, nodeRect.right, nodeRect.bottom);
setPosition(this.subElement, nodeRect.right, bottom);
}
};
const headerElement = this.subElement.querySelector(".block__icons");