This commit is contained in:
parent
43d0bb1bfe
commit
932e45e612
9 changed files with 35 additions and 19 deletions
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"switchReadonly": "Switch read-only mode",
|
||||
"original": "Original",
|
||||
"selectRelation": "Please select the related column first",
|
||||
"backRelation": "Bidirectional",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"switchReadonly": "Cambiar modo de sólo lectura",
|
||||
"original": "Original",
|
||||
"selectRelation": "Seleccione primero la columna relacionada",
|
||||
"backRelation": "Bidireccional",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"switchReadonly": "Changer de mode lecture seule",
|
||||
"original": "Originale",
|
||||
"selectRelation": "Veuillez d'abord sélectionner la colonne associée",
|
||||
"backRelation": "Bidirectionnel",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"switchReadonly": "唯讀模式切換",
|
||||
"original": "原值",
|
||||
"selectRelation": "請先選擇關聯列",
|
||||
"backRelation": "雙向關聯",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"switchReadonly": "只读模式切换",
|
||||
"original": "原值",
|
||||
"selectRelation": "请先选择关联列",
|
||||
"backRelation": "双向关联",
|
||||
|
|
|
@ -57,7 +57,7 @@ import {openCard, openCardByData} from "../../card/openCard";
|
|||
import {lockScreen} from "../../dialog/processSystem";
|
||||
import {isWindow} from "../../util/functions";
|
||||
import {reloadProtyle} from "../../protyle/util/reload";
|
||||
import {fullscreen} from "../../protyle/breadcrumb/action";
|
||||
import {fullscreen, updateReadonly} from "../../protyle/breadcrumb/action";
|
||||
import {openRecentDocs} from "../../business/openRecentDocs";
|
||||
import {App} from "../../index";
|
||||
import {commandPanel} from "../../plugin/commandPanel";
|
||||
|
@ -333,6 +333,11 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||
zoomOut({protyle, id: protyle.block.rootID, focusId: protyle.block.id});
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
|
||||
event.preventDefault();
|
||||
if (range) {
|
||||
|
|
|
@ -359,6 +359,7 @@ export abstract class Constants {
|
|||
refPopover: {default: "", custom: ""},
|
||||
copyText: {default: "", custom: ""},
|
||||
exitFocus: {default: "", custom: ""},
|
||||
switchReadonly: {default: "", custom: ""},
|
||||
expand: {default: "⌘↓", custom: "⌘↓"},
|
||||
collapse: {default: "⌘↑", custom: "⌘↑"},
|
||||
insertBottom: {default: "⌥⌘.", custom: "⌥⌘."},
|
||||
|
|
|
@ -8,6 +8,7 @@ import {hideAllElements, hideElements} from "../ui/hideElements";
|
|||
import {hasClosestByClassName} from "../util/hasClosest";
|
||||
import {reloadProtyle} from "../util/reload";
|
||||
import {resize} from "../util/resize";
|
||||
import {disabledProtyle, enableProtyle} from "../util/onGet";
|
||||
|
||||
export const net2LocalAssets = (protyle: IProtyle, type: "Assets" | "Img") => {
|
||||
if (protyle.element.querySelector(".wysiwygLoading")) {
|
||||
|
@ -81,3 +82,23 @@ export const fullscreen = (element: Element, btnElement?: Element) => {
|
|||
});
|
||||
/// #endif
|
||||
};
|
||||
|
||||
export const updateReadonly = (target: Element, protyle: IProtyle) => {
|
||||
if (!window.siyuan.config.readonly) {
|
||||
const isReadonly = target.querySelector("use").getAttribute("xlink:href") !== "#iconUnlock";
|
||||
if (window.siyuan.config.editor.readOnly) {
|
||||
if (isReadonly) {
|
||||
enableProtyle(protyle);
|
||||
} else {
|
||||
disabledProtyle(protyle);
|
||||
}
|
||||
} else {
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
id: protyle.block.rootID,
|
||||
attrs: {
|
||||
[Constants.CUSTOM_SY_READONLY]: isReadonly ? "false" : "true"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import {getIconByType} from "../../editor/getIcon";
|
|||
import {fetchPost} from "../../util/fetch";
|
||||
import {Constants} from "../../constants";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {fullscreen, net2LocalAssets} from "./action";
|
||||
import {fullscreen, net2LocalAssets, updateReadonly} from "./action";
|
||||
import {openFileAttr} from "../../menus/commonMenuItem";
|
||||
import {setEditMode} from "../util/setEditMode";
|
||||
import {RecordMedia} from "../util/RecordMedia";
|
||||
|
@ -107,23 +107,7 @@ export class Breadcrumb {
|
|||
event.preventDefault();
|
||||
break;
|
||||
} else if (type === "readonly") {
|
||||
if (!window.siyuan.config.readonly) {
|
||||
const isReadonly = target.querySelector("use").getAttribute("xlink:href") !== "#iconUnlock";
|
||||
if (window.siyuan.config.editor.readOnly) {
|
||||
if (isReadonly) {
|
||||
enableProtyle(protyle);
|
||||
} else {
|
||||
disabledProtyle(protyle);
|
||||
}
|
||||
} else {
|
||||
fetchPost("/api/attr/setBlockAttrs", {
|
||||
id: protyle.block.rootID,
|
||||
attrs: {
|
||||
[Constants.CUSTOM_SY_READONLY]: isReadonly ? "false" : "true"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
updateReadonly(target, protyle);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue