mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-11 14:41:51 +08:00
This commit is contained in:
parent
135c80fcb2
commit
cb0f30c36f
@ -69,6 +69,14 @@ export const commandPanel = (app: App) => {
|
|||||||
html += `<li class="b3-list-item" data-command="${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__text">${window.siyuan.languages[key]}</span>
|
||||||
<span class="b3-list-item__meta${isMobile() ? " fn__none" : ""}">${updateHotkeyTip(window.siyuan.config.keymap.general[key].custom)}</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>`;
|
</li>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,12 +5,33 @@ import {enterBack, zoomOut} from "../../../menus/protyle";
|
|||||||
import {openFileById} from "../../../editor/util";
|
import {openFileById} from "../../../editor/util";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {checkFold} from "../../../util/noRelyPCFunction";
|
import {checkFold} from "../../../util/noRelyPCFunction";
|
||||||
|
import {updateReadonly} from "../../../protyle/breadcrumb/action";
|
||||||
|
import {Constants} from "../../../constants";
|
||||||
|
import {fetchPost} from "../../../util/fetch";
|
||||||
|
|
||||||
export const onlyProtyleCommand = (options: {
|
export const onlyProtyleCommand = (options: {
|
||||||
command: string,
|
command: string,
|
||||||
previousRange: Range,
|
previousRange: Range,
|
||||||
protyle: IProtyle,
|
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);
|
const nodeElement = hasClosestBlock(options.previousRange.startContainer);
|
||||||
if (!nodeElement) {
|
if (!nodeElement) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -73,6 +73,7 @@ import {copyPNGByLink} from "../../menus/util";
|
|||||||
import {globalCommand} from "./command/global";
|
import {globalCommand} from "./command/global";
|
||||||
import {duplicateCompletely} from "../../protyle/render/av/action";
|
import {duplicateCompletely} from "../../protyle/render/av/action";
|
||||||
import {copyTextByType} from "../../protyle/toolbar/util";
|
import {copyTextByType} from "../../protyle/toolbar/util";
|
||||||
|
import {onlyProtyleCommand} from "./command/protyle";
|
||||||
|
|
||||||
const switchDialogEvent = (app: App, event: MouseEvent) => {
|
const switchDialogEvent = (app: App, event: MouseEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -377,21 +378,19 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||||||
}
|
}
|
||||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.switchReadonly.custom, event)) {
|
if (matchHotKey(window.siyuan.config.keymap.editor.general.switchReadonly.custom, event)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
updateReadonly(protyle.breadcrumb.element.parentElement.querySelector('.block__icon[data-type="readonly"]'), protyle);
|
onlyProtyleCommand({
|
||||||
|
protyle,
|
||||||
|
command: "switchReadonly",
|
||||||
|
previousRange: range,
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.switchAdjust.custom, event)) {
|
if (matchHotKey(window.siyuan.config.keymap.editor.general.switchAdjust.custom, event)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let fullWidth;
|
onlyProtyleCommand({
|
||||||
const adjustWidth = protyle.wysiwyg.element.getAttribute(Constants.CUSTOM_SY_FULLWIDTH)
|
protyle,
|
||||||
if (!adjustWidth) {
|
command: "switchAdjust",
|
||||||
fullWidth = window.siyuan.config.editor.fullWidth ? "false" : "true";
|
previousRange: range,
|
||||||
} else {
|
|
||||||
fullWidth = adjustWidth === "true" ? "false" : "true";
|
|
||||||
}
|
|
||||||
fetchPost("/api/attr/setBlockAttrs", {
|
|
||||||
id: protyle.block.rootID,
|
|
||||||
attrs: {[Constants.CUSTOM_SY_FULLWIDTH]: fullWidth}
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user