Vanessa 2024-05-13 17:05:46 +08:00
parent 3212e3511d
commit f15b2f8666
4 changed files with 11 additions and 9 deletions

View file

@ -4,6 +4,7 @@ import {Editor} from "../../../editor";
/// #if MOBILE
import {openDock} from "../../../mobile/dock/util";
import {popMenu} from "../../../mobile/menu";
import {popSearch} from "../../../mobile/menu/search";
/// #else
import {openSearch} from "../../../search/spread";
import {goBack, goForward} from "../../../util/backForward";
@ -14,8 +15,8 @@ import {openSetting} from "../../../config";
import {Tab} from "../../../layout/Tab";
/// #endif
import {App} from "../../../index";
import {editor} from "../../../config/editor";
import {Constants} from "../../../constants";
import {setReadOnly} from "../../../config/util/setReadOnly";
export const globalCommand = (command: string, app: App) => {
/// #if MOBILE
@ -35,6 +36,9 @@ export const globalCommand = (command: string, app: App) => {
case "config":
popMenu();
return true;
case "globalSearch":
popSearch(app);
return true;
}
/// #else
switch (command) {
@ -225,7 +229,7 @@ export const globalCommand = (command: string, app: App) => {
openHistory(app);
return true;
case "editReadonly":
editor.setReadonly(!window.siyuan.config.editor.readOnly);
setReadOnly(!window.siyuan.config.editor.readOnly)
return true;
}

View file

@ -45,7 +45,7 @@ export const commandPanel = (app: App) => {
let keys;
/// #if MOBILE
keys = ["addToDatabase", "fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks", "config",
"dataHistory", "editReadonly", "enter", "enterBack", "globalSearch", "goBack", "goForward"];
"dataHistory", "editReadonly", "enter", "enterBack", "globalSearch"];
/// #else
keys = ["addToDatabase", "fileTree", "outline", "bookmark", "tag", "dailyNote", "inbox", "backlinks",
"graphView", "globalGraph", "closeAll", "closeLeft", "closeOthers", "closeRight", "closeTab",

View file

@ -74,6 +74,7 @@ import {zoomOut} from "../../menus/protyle";
import {getPlainText} from "../../protyle/util/paste";
import {commandPanel, execByCommand} from "./command/panel";
import {filterHotkey} from "./commonHotkey";
import {setReadOnly} from "../../config/util/setReadOnly";
const switchDialogEvent = (app: App, event: MouseEvent) => {
event.preventDefault();
@ -1266,7 +1267,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
}
if (matchHotKey(window.siyuan.config.keymap.general.editReadonly.custom, event)) {
event.preventDefault();
editor.setReadonly(!window.siyuan.config.editor.readOnly);
setReadOnly(!window.siyuan.config.editor.readOnly)
return;
}
if (matchHotKey(window.siyuan.config.keymap.general.lockScreen.custom, event)) {

View file

@ -6,13 +6,10 @@ import {reloadProtyle} from "../protyle/util/reload";
import {updateHotkeyTip} from "../protyle/util/compatibility";
import {Constants} from "../constants";
import {resize} from "../protyle/util/resize";
import {setReadOnly} from "./util/setReadOnly";
export const editor = {
element: undefined as Element,
setReadonly: (readOnly: boolean) => {
window.siyuan.config.editor.readOnly = readOnly;
fetchPost("/api/setting/setEditor", window.siyuan.config.editor);
},
genHTML: () => {
let fontFamilyHTML = "";
fontFamilyHTML = '<select id="fontFamily" class="b3-select fn__flex-center fn__size200"></select>';
@ -401,7 +398,7 @@ export const editor = {
_onSetEditor: (editorData: Config.IEditor) => {
const changeReadonly = editorData.readOnly !== window.siyuan.config.editor.readOnly;
if (changeReadonly) {
editor.setReadonly(editorData.readOnly);
setReadOnly(editorData.readOnly);
}
window.siyuan.config.editor = editorData;
getAllModels().editor.forEach((item) => {