Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/13567

Vanessacb0f30c36f98
diff --git a/app/src/boot/globalEvent/command/panel.ts b/app/src/boot/globalEvent/command/panel.ts
index eb22a88613..0ffef3b531 100644
--- a/app/src/boot/globalEvent/command/panel.ts
+++ b/app/src/boot/globalEvent/command/panel.ts
@@ -69,6 +69,14 @@ export const commandPanel = (app: App) => {
html += `<li class="b3-list-item" data-command="${key}">
<span class="b3-list-item__text">${window.siyuan.languages[key]}</span>
<span class="b3-list-item__meta${isMobile() ? " fn__none" : ""}">${updateHotkeyTip(window.siyuan.config.keymap.general[key].custom)}</span>
+</li>`;
+ }
+ });
+ Object.keys(window.siyuan.config.keymap.editor.general).forEach((key) => {
+ if (["switchReadonly", "switchAdjust"].includes(key)) {
+ html += `<li class="b3-list-item" data-command="${key}">
+ <span class="b3-list-item__text">${window.siyuan.languages[key]}</span>
+ <span class="b3-list-item__meta${isMobile() ? " fn__none" : ""}">${updateHotkeyTip(window.siyuan.config.keymap.editor.general[key].custom)}</span>
</li>`;
}
});
diff --git a/app/src/boot/globalEvent/command/protyle.ts b/app/src/boot/globalEvent/command/protyle.ts
index 919e400fd0..08f1adc2b9 100644
--- a/app/src/boot/globalEvent/command/protyle.ts
+++ b/app/src/boot/globalEvent/command/protyle.ts
@@ -5,12 +5,33 @@ import {enterBack, zoomOut} from "../../../menus/protyle";
import {openFileById} from "../../../editor/util";
/// #endif
import {checkFold} from "../../../util/noRelyPCFunction";
+import {updateReadonly} from "../../../protyle/breadcrumb/action";
+import {Constants} from "../../../constants";
+import {fetchPost} from "../../../util/fetch";
export const onlyProtyleCommand = (options: {
command: string,
previousRange: Range,
protyle: IProtyle,
}) => {
+ if (options.command === "switchReadonly") {
+ updateReadonly(options.protyle.breadcrumb.element.parentElement.querySelector('.block__icon[data-type="readonly"]'), options.protyle);
+ return true;
+ }
+ if (options.command === "switchAdjust") {
+ let fullWidth;
+ const adjustWidth = options.protyle.wysiwyg.element.getAttribute(Constants.CUSTOM_SY_FULLWIDTH)
+ if (!adjustWidth) {
+ fullWidth = window.siyuan.config.editor.fullWidth ? "false" : "true";
+ } else {
+ fullWidth = adjustWidth === "true" ? "false" : "true";
+ }
+ fetchPost("/api/attr/setBlockAttrs", {
+ id: options.protyle.block.rootID,
+ attrs: {[Constants.CUSTOM_SY_FULLWIDTH]: fullWidth}
+ });
+ return true;
+ }
const nodeElement = hasClosestBlock(options.previousRange.startContainer);
if (!nodeElement) {
return false;
diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts
index e1769a188b..a5ad57321c 100644
--- a/app/src/boot/globalEvent/keydown.ts
+++ b/app/src/boot/globalEvent/keydown.ts
@@ -73,6 +73,7 @@ import {copyPNGByLink} from "../../menus/util";
import {globalCommand} from "./command/global";
import {duplicateCompletely} from "../../protyle/render/av/action";
import {copyTextByType} from "../../protyle/toolbar/util";
+import {onlyProtyleCommand} from "./command/protyle";
const switchDialogEvent = (app: App, event: MouseEvent) => {
event.preventDefault();
@@ -377,21 +378,19 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
}
if (matchHotKey(window.siyuan.config.keymap.editor.general.switchReadonly.custom, event)) {
event.preventDefault();
- updateReadonly(protyle.breadcrumb.element.parentElement.querySelector('.block__icon[data-type="readonly"]'), protyle);
+ onlyProtyleCommand({
+ protyle,
+ command: "switchReadonly",
+ previousRange: range,
+ });
return true;
}
if (matchHotKey(window.siyuan.config.keymap.editor.general.switchAdjust.custom, event)) {
event.preventDefault();
- let fullWidth;
- const adjustWidth = protyle.wysiwyg.element.getAttribute(Constants.CUSTOM_SY_FULLWIDTH)
- if (!adjustWidth) {
- fullWidth = window.siyuan.config.editor.fullWidth ? "false" : "true";
- } else {
- fullWidth = adjustWidth === "true" ? "false" : "true";
- }
- fetchPost("/api/attr/setBlockAttrs", {
- id: protyle.block.rootID,
- attrs: {[Constants.CUSTOM_SY_FULLWIDTH]: fullWidth}
+ onlyProtyleCommand({
+ protyle,
+ command: "switchAdjust",
+ previousRange: range,
});
return true;
}