Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/7721

Vanessaa33d2388fd06
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index bf193b7eb3..ae476da788 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -1295,17 +1295,22 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
if (!nodeElement.classList.contains("code-block") && !event.repeat) {
- const findToolbar = protyle.options.toolbar.find((menuItem: IMenuItem) => {
+ let findToolbar = false;
+ protyle.options.toolbar.find((menuItem: IMenuItem) => {
if (!menuItem.hotkey) {
return false;
}
if (matchHotKey(menuItem.hotkey, event)) {
protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element);
+ if (["block-ref", "text"].includes(menuItem.name) && protyle.toolbar.range.toString() === "") {
+ return true;
+ }
+ findToolbar = true;
if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(menuItem.name)) {
protyle.toolbar.element.querySelector(`[data-type="${menuItem.name}"]`).dispatchEvent(new CustomEvent("click"));
- return true;
+ } else {
+ protyle.toolbar.setInlineMark(protyle, menuItem.name, "range");
}
- protyle.toolbar.setInlineMark(protyle, menuItem.name, "range");
return true;
}
});