diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts index c49e117a6..b86b376bf 100644 --- a/app/src/boot/globalEvent/keydown.ts +++ b/app/src/boot/globalEvent/keydown.ts @@ -1418,7 +1418,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => { window.siyuan.menus.menu.element.style.zIndex < (window.siyuan.dialogs[0].element.querySelector(".b3-dialog") as HTMLElement).style.zIndex) { // 窗口高于菜单时,先关闭窗口,如 av 修改列 icon 时 } else { - window.siyuan.menus.menu.remove(); + window.siyuan.menus.menu.remove(true); return; } } diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts index 6d4638bab..f5bb571ba 100644 --- a/app/src/menus/Menu.ts +++ b/app/src/menus/Menu.ts @@ -97,7 +97,16 @@ export class Menu { window.removeEventListener(isMobile() ? "touchmove" : this.wheelEvent, this.preventDefault, false); } - public remove() { + public remove(isKeyEvent = false) { + if (isKeyEvent) { + const subElement = window.siyuan.menus.menu.element.querySelector(".b3-menu__item--show"); + if (subElement) { + subElement.classList.remove("b3-menu__item--show"); + subElement.classList.add("b3-menu__item--current"); + subElement.querySelector(".b3-menu__item--current")?.classList.remove("b3-menu__item--current"); + return; + } + } if (window.siyuan.menus.menu.removeCB) { window.siyuan.menus.menu.removeCB(); window.siyuan.menus.menu.removeCB = undefined; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 441a74efa..cfa726a96 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1580,7 +1580,7 @@ export class WYSIWYG { } else if (range.toString() !== "" && startContainer.isSameNode(range.endContainer) && range.startContainer.nodeType === 3 && // 需使用 wholeText https://github.com/siyuan-note/siyuan/issues/14339 - range.endOffset === range.endContainer.wholeText.length && + range.endOffset === (range.endContainer as Text).wholeText.length && range.startOffset === 0 && !["DIV", "TD", "TH", "TR"].includes(range.startContainer.parentElement.tagName)) { // 选中整个内联元素 diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index e08363cd4..5677040aa 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1248,7 +1248,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { protyle.hint.enableExtend = false; } else if (!window.siyuan.menus.menu.element.classList.contains("fn__none")) { // 防止 ESC 时选中当前块 - window.siyuan.menus.menu.remove(); + window.siyuan.menus.menu.remove(true); } else if (nodeElement.classList.contains("protyle-wysiwyg--select")) { hideElements(["select"], protyle); countBlockWord([], protyle.block.rootID);