From 6215e1c6ab84ea9680ef2746506e507d355c2bab Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 13 Apr 2023 10:52:40 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/7953 --- app/src/protyle/toolbar/InlineMath.ts | 2 +- app/src/protyle/toolbar/index.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/protyle/toolbar/InlineMath.ts b/app/src/protyle/toolbar/InlineMath.ts index 671014033..80b622489 100644 --- a/app/src/protyle/toolbar/InlineMath.ts +++ b/app/src/protyle/toolbar/InlineMath.ts @@ -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; diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 0dd170343..d97257937 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -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");