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/5231

Vanessac14fc344c626
diff --git a/app/src/config/keymap.ts b/app/src/config/keymap.ts
index 3e4084787a..d63101c671 100644
--- a/app/src/config/keymap.ts
+++ b/app/src/config/keymap.ts
@@ -264,7 +264,7 @@ export const keymap = {
}
if (["⌘", "⇧", "⌥", "⌃"].includes(keymapStr.substr(keymapStr.length - 1, 1)) ||
- ["⌘S", "⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⌘↑", "⌘↓", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧Enter", "Enter", "PageUp", "PageDown", "⌫", "⌦", "F9"].includes(keymapStr)) {
+ ["⌘S", "⌘A", "⌘X", "⌘C", "⌘V", "⌘/", "⌘↑", "⌘↓", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "F9"].includes(keymapStr)) {
showMessage(tip + "] " + window.siyuan.languages.invalid);
return;
}
diff --git a/app/src/constants.ts b/app/src/constants.ts
index b6d9dfa2ab..c64a295a31 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -177,7 +177,7 @@ export abstract class Constants {
list: {
indent: {default: "⇥", custom: "⇥"},
outdent: {default: "⇧⇥", custom: "⇧⇥"},
- checkToggle: {default: "⌘Enter", custom: "⌘Enter"},
+ checkToggle: {default: "⌘↩", custom: "⌘↩"},
},
table: {
insertRowAbove: {default: "⇧⌘T", custom: "⇧⌘T"},
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts
index d73932dcef..775f7e020b 100644
--- a/app/src/menus/commonMenuItem.ts
+++ b/app/src/menus/commonMenuItem.ts
@@ -29,7 +29,7 @@ const bindAttrInput = (inputElement: HTMLInputElement, confirmElement: Element)
if (event.isComposing) {
return;
}
- if (matchHotKey("⌘Enter", event)) {
+ if (matchHotKey("⌘↩", event)) {
confirmElement.dispatchEvent(new CustomEvent("click"));
event.stopPropagation();
event.preventDefault();
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index b9be6a7ea4..f8fc70f999 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -879,7 +879,7 @@ export class Toolbar {
}
/// #endif
- if (event.key === "Escape" || matchHotKey("⌘Enter", event)) {
+ if (event.key === "Escape" || matchHotKey("⌘↩", event)) {
this.subElement.classList.add("fn__none");
this.subElement.querySelector('[data-type="pin"]').classList.remove("ft__primary");
if (renderElement.tagName === "SPAN") {
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 32d3f06fce..885b3881c4 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -75,7 +75,8 @@ export const updateHotkeyTip = (hotkey: string) => {
}
hotkey = hotkey.replace("⌘", "Ctrl").replace("⇧", "Shift")
.replace("⌥", "Alt").replace("⇥", "Tab")
- .replace("⌫", "Backspace").replace("⌦", "Delete");
+ .replace("⌫", "Backspace").replace("⌦", "Delete")
+ .replace("↩", "Enter");
if (hotkey.indexOf("Shift") > -1) {
hotkey = hotkey.replace(";", ":").replace("=", "+").replace("-", "_").replace(".", ">");
}
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index cb9444f279..b6dfda5f69 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -686,7 +686,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
// 软换行
- if (matchHotKey("⇧Enter", event) && range.toString() === "") {
+ if (matchHotKey("⇧↩", event) && range.toString() === "") {
let startElement = range.startContainer as HTMLElement;
const nextSibling = hasNextSibling(startElement) as Element;
// 图片之前软换行
@@ -1309,9 +1309,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (matchHotKey(window.siyuan.config.keymap.editor.general.vLayout.custom, event)) {
event.preventDefault();
- let selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
- if (selectsElement.length === 0) {
- selectsElement = [nodeElement];
+ const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
+ if (selectsElement.length < 2) {
+ return;
}
turnsIntoTransaction({
protyle, selectsElement,
@@ -1323,9 +1323,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (matchHotKey(window.siyuan.config.keymap.editor.general.hLayout.custom, event)) {
event.preventDefault();
- let selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
- if (selectsElement.length === 0) {
- selectsElement = [nodeElement];
+ const selectsElement: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
+ if (selectsElement.length < 2) {
+ return;
}
turnsIntoTransaction({
protyle, selectsElement,