diff --git a/app/appearance/icons/ant/icon.js b/app/appearance/icons/ant/icon.js index c9f828612..49bc4a19f 100644 --- a/app/appearance/icons/ant/icon.js +++ b/app/appearance/icons/ant/icon.js @@ -349,7 +349,10 @@ document.body.insertAdjacentHTML('afterbegin', ` - + + + + diff --git a/app/appearance/icons/ant/icon.json b/app/appearance/icons/ant/icon.json index 88633c17e..a5438987d 100644 --- a/app/appearance/icons/ant/icon.json +++ b/app/appearance/icons/ant/icon.json @@ -2,5 +2,5 @@ "name": "ant", "author": "Vanessa", "url": "https://github.com/Vanessa219", - "version": "1.22.0" + "version": "1.23.0" } diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html index 654c43c82..613c8e301 100644 --- a/app/appearance/icons/index.html +++ b/app/appearance/icons/index.html @@ -640,6 +640,12 @@ iconRefresh +
+ + + + iconUnlock +
diff --git a/app/appearance/icons/material/icon.js b/app/appearance/icons/material/icon.js index ae531762f..8534e7b4c 100644 --- a/app/appearance/icons/material/icon.js +++ b/app/appearance/icons/material/icon.js @@ -341,7 +341,10 @@ document.body.insertAdjacentHTML('afterbegin', ` - + + + + diff --git a/app/appearance/icons/material/icon.json b/app/appearance/icons/material/icon.json index a4db183bd..05206308b 100644 --- a/app/appearance/icons/material/icon.json +++ b/app/appearance/icons/material/icon.json @@ -2,5 +2,5 @@ "name": "material", "author": "Vanessa", "url": "https://github.com/Vanessa219", - "version": "1.22.0" + "version": "1.23.0" } diff --git a/app/src/assets/template/mobile/index.tpl b/app/src/assets/template/mobile/index.tpl index f6ff97d91..fe6269454 100644 --- a/app/src/assets/template/mobile/index.tpl +++ b/app/src/assets/template/mobile/index.tpl @@ -19,9 +19,6 @@ - - - diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts index eba7ed9ee..11f3df002 100644 --- a/app/src/block/Panel.ts +++ b/app/src/block/Panel.ts @@ -175,9 +175,6 @@ export class BlockPanel { }, typewriterMode: false, after: (editor) => { - if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) { - disabledProtyle(editor.protyle); - } editorElement.addEventListener("mouseleave", () => { hideElements(["gutter"], editor.protyle); }); diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts index bf659d2ff..78506d02b 100644 --- a/app/src/boot/globalEvent/keydown.ts +++ b/app/src/boot/globalEvent/keydown.ts @@ -1033,7 +1033,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => { } if (matchHotKey(window.siyuan.config.keymap.general.editMode.custom, event)) { event.preventDefault(); - editor.setReadonly(); + editor.setReadonly(!window.siyuan.config.editor.readOnly); return; } if (matchHotKey(window.siyuan.config.keymap.general.lockScreen.custom, event)) { diff --git a/app/src/card/makeCard.ts b/app/src/card/makeCard.ts index 6d474ddfa..6a90b6fb0 100644 --- a/app/src/card/makeCard.ts +++ b/app/src/card/makeCard.ts @@ -183,7 +183,7 @@ export const quickMakeCard = (protyle: IProtyle, nodeElement: Element[]) => { } item.classList.remove("protyle-wysiwyg--select"); ids.push(item.getAttribute("data-node-id")); - if ((item.getAttribute("custom-riff-decks") || "").indexOf(Constants.QUICK_DECK_ID) === -1) { + if ((item.getAttribute(Constants.CUSTOM_RIFF_DECKS) || "").indexOf(Constants.QUICK_DECK_ID) === -1) { isRemove = false; } }); diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.ts index 14e9b98e0..a387f52f8 100644 --- a/app/src/card/openCard.ts +++ b/app/src/card/openCard.ts @@ -133,9 +133,6 @@ export const bindCardEvent = (options: { if (window.siyuan.mobile) { window.siyuan.mobile.popEditor = editor; } - if (window.siyuan.config.editor.readOnly) { - disabledProtyle(editor.protyle); - } if (options.blocks.length > 0) { fetchPost("/api/filetree/getDoc", { id: options.blocks[index].blockID, diff --git a/app/src/card/viewCards.ts b/app/src/card/viewCards.ts index 63f4aa300..488290850 100644 --- a/app/src/card/viewCards.ts +++ b/app/src/card/viewCards.ts @@ -65,9 +65,6 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr if (window.siyuan.mobile) { window.siyuan.mobile.popEditor = edit; } - if (window.siyuan.config.editor.readOnly) { - disabledProtyle(edit.protyle); - } getArticle(edit, dialog.element.querySelector(".b3-list-item--focus")?.getAttribute("data-id")); } const previousElement = dialog.element.querySelector('[data-type="previous"]'); diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index dfd45a557..e5548f914 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -5,13 +5,11 @@ import {confirmDialog} from "../dialog/confirmDialog"; import {setPadding} from "../protyle/ui/initUI"; import {reloadProtyle} from "../protyle/util/reload"; import {updateHotkeyTip} from "../protyle/util/compatibility"; +import {Constants} from "../constants"; export const editor = { element: undefined as Element, - setReadonly: (readOnly?: boolean) => { - if (typeof readOnly === "undefined") { - readOnly = document.querySelector("#barReadonly").getAttribute("aria-label") === `${window.siyuan.languages.use} ${window.siyuan.languages.editReadonly} ${updateHotkeyTip(window.siyuan.config.keymap.general.editMode.custom)}`; - } + setReadonly: (readOnly: boolean) => { window.siyuan.config.editor.readOnly = readOnly; fetchPost("/api/setting/setEditor", window.siyuan.config.editor); }, @@ -44,7 +42,8 @@ export const editor = {
- ${window.siyuan.languages.editReadonly} + ${window.siyuan.languages.editReadonly} + ${updateHotkeyTip(window.siyuan.config.keymap.general.editMode.custom)}
${window.siyuan.languages.editReadonlyTip}
@@ -345,7 +344,7 @@ export const editor = { getAllModels().editor.forEach((item) => { reloadProtyle(item.editor.protyle, false); setPadding(item.editor.protyle); - let isFullWidth = item.editor.protyle.wysiwyg.element.getAttribute("custom-sy-fullwidth"); + let isFullWidth = item.editor.protyle.wysiwyg.element.getAttribute(Constants.CUSTOM_SY_FULLWIDTH); if (!isFullWidth) { isFullWidth = window.siyuan.config.editor.fullWidth ? "true" : "false"; } diff --git a/app/src/constants.ts b/app/src/constants.ts index ed4485c0d..8afcb2807 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -39,6 +39,12 @@ export abstract class Constants { public static readonly SIYUAN_EXPORT_PREVENT: string = "siyuan-export-prevent"; public static readonly SIYUAN_AUTO_LAUNCH: string = "siyuan-auto-launch"; + // custom + public static readonly CUSTOM_SY_READONLY: string = "custom-sy-readonly"; + public static readonly CUSTOM_SY_FULLWIDTH: string = "custom-sy-fullwidth"; + public static readonly CUSTOM_REMINDER_WECHAT: string = "custom-reminder-wechat"; + public static readonly CUSTOM_RIFF_DECKS: string = "custom-riff-decks"; + // size public static readonly SIZE_LINK_TEXT_MAX: number = 24; public static readonly SIZE_TOOLBAR_HEIGHT: number = isMobile() ? 0 : 32; @@ -99,7 +105,6 @@ export abstract class Constants { en_US: "20210808180117-6v0mkxr", fr_FR: "20210808180117-6v0mkxr", }; - public static readonly QUICK_DECK_ID = "20230218211946-2kw8jgx"; public static readonly KEYCODELIST: { [key: number]: string } = { diff --git a/app/src/editor/index.ts b/app/src/editor/index.ts index e4a62c362..e40a4bcf0 100644 --- a/app/src/editor/index.ts +++ b/app/src/editor/index.ts @@ -53,10 +53,6 @@ export class Editor extends Model { scrollAttr: options.scrollAttr, typewriterMode: true, after: (editor) => { - if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly) { - disabledProtyle(editor.protyle); - } - if (window.siyuan.editorIsFullscreen) { editor.protyle.element.classList.add("fullscreen"); setPadding(editor.protyle); diff --git a/app/src/editor/rename.ts b/app/src/editor/rename.ts index 0072f8e37..c7154fc9e 100644 --- a/app/src/editor/rename.ts +++ b/app/src/editor/rename.ts @@ -44,7 +44,7 @@ export const rename = (options: { type: "notebook" | "file" range?: Range, }) => { - if (window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) { + if (window.siyuan.config.readonly) { return; } const dialog = new Dialog({ diff --git a/app/src/index.ts b/app/src/index.ts index cc190280d..bc75f6c45 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -23,7 +23,6 @@ import { import {initMessage} from "./dialog/message"; import {getAllTabs} from "./layout/getAll"; import {getLocalStorage} from "./protyle/util/compatibility"; -import {updateEditModeElement} from "./layout/topBar"; import {getSearch} from "./util/functions"; import {hideAllElements} from "./protyle/ui/hideElements"; import {loadPlugins} from "./plugin/loader"; @@ -64,7 +63,6 @@ export class App { break; case "readonly": window.siyuan.config.editor.readOnly = data.data; - updateEditModeElement(); hideAllElements(["util"]); break; case "progress": diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index 53fce6d1e..0583a885a 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -409,7 +409,7 @@ export class Wnd { } } - public switchTab(target: HTMLElement, pushBack = false, update = true) { + public switchTab(target: HTMLElement, pushBack = false, update = true, resize = true) { setPanelFocus(this.headersElement.parentElement.parentElement); let currentTab: Tab; this.children.forEach((item) => { @@ -485,7 +485,7 @@ export class Wnd { focus: true, pushBackStack: pushBack, reload: false, - resize: true, + resize, }); } } else { @@ -494,7 +494,7 @@ export class Wnd { focus: false, pushBackStack: false, reload: false, - resize: true, + resize, }); } } @@ -750,7 +750,7 @@ export class Wnd { } }); if (latestHeadElement && !closeAll) { - this.switchTab(latestHeadElement, true); + this.switchTab(latestHeadElement, true, true, false); } } if (animate) { diff --git a/app/src/layout/topBar.ts b/app/src/layout/topBar.ts index a5d6b826c..5d779e455 100644 --- a/app/src/layout/topBar.ts +++ b/app/src/layout/topBar.ts @@ -21,19 +21,6 @@ import {needSubscribe} from "../util/needSubscribe"; import * as dayjs from "dayjs"; import {commandPanel} from "../plugin/commandPanel"; -export const updateEditModeElement = () => { - const target = document.querySelector("#barReadonly"); - if (window.siyuan.config.editor.readOnly) { - target.classList.add("toolbar__item--active"); - target.setAttribute("aria-label", `${window.siyuan.languages.use} ${window.siyuan.languages.editMode} ${updateHotkeyTip(window.siyuan.config.keymap.general.editMode.custom)}`); - target.querySelector("use").setAttribute("xlink:href", "#iconPreview"); - } else { - target.classList.remove("toolbar__item--active"); - target.setAttribute("aria-label", `${window.siyuan.languages.use} ${window.siyuan.languages.editReadonly} ${updateHotkeyTip(window.siyuan.config.keymap.general.editMode.custom)}`); - target.querySelector("use").setAttribute("xlink:href", "#iconEdit"); - } -}; - export const initBar = (app: App) => { const toolbarElement = document.getElementById("toolbar"); toolbarElement.innerHTML = ` @@ -61,9 +48,6 @@ export const initBar = (app: App) => {
-
- -
@@ -128,10 +112,6 @@ export const initBar = (app: App) => { workspaceMenu(app, target.getBoundingClientRect()); event.stopPropagation(); break; - } else if (targetId === "barReadonly") { - editor.setReadonly(); - event.stopPropagation(); - break; } else if (targetId === "barMode") { if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && window.siyuan.menus.menu.element.getAttribute("data-name") === "barmode") { diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts index 896f5375e..4ac4ef761 100644 --- a/app/src/menus/commonMenuItem.ts +++ b/app/src/menus/commonMenuItem.ts @@ -33,7 +33,7 @@ const bindAttrInput = (inputElement: HTMLInputElement, id: string) => { export const openWechatNotify = (nodeElement: Element) => { const id = nodeElement.getAttribute("data-node-id"); const range = getEditorRange(nodeElement); - const reminder = nodeElement.getAttribute("custom-reminder-wechat"); + const reminder = nodeElement.getAttribute(Constants.CUSTOM_REMINDER_WECHAT); let reminderFormat = ""; if (reminder) { reminderFormat = dayjs(reminder).format("YYYY-MM-DDTHH:mm"); @@ -68,7 +68,7 @@ export const openWechatNotify = (nodeElement: Element) => { } btnsElement[1].setAttribute("disabled", "disabled"); fetchPost("/api/block/setBlockReminder", {id, timed: "0"}, () => { - nodeElement.removeAttribute("custom-reminder-wechat"); + nodeElement.removeAttribute(Constants.CUSTOM_REMINDER_WECHAT); dialog.destroy(); }); }); @@ -85,7 +85,7 @@ export const openWechatNotify = (nodeElement: Element) => { btnsElement[2].setAttribute("disabled", "disabled"); const timed = dayjs(date).format("YYYYMMDDHHmmss"); fetchPost("/api/block/setBlockReminder", {id, timed}, () => { - nodeElement.setAttribute("custom-reminder-wechat", timed); + nodeElement.setAttribute(Constants.CUSTOM_REMINDER_WECHAT, timed); dialog.destroy(); }); } else { @@ -98,7 +98,7 @@ export const openFileWechatNotify = (protyle: IProtyle) => { fetchPost("/api/block/getDocInfo", { id: protyle.block.rootID }, (response) => { - const reminder = response.data.ial["custom-reminder-wechat"]; + const reminder = response.data.ial[Constants.CUSTOM_REMINDER_WECHAT]; let reminderFormat = ""; if (reminder) { reminderFormat = dayjs(reminder).format("YYYY-MM-DDTHH:mm"); @@ -155,10 +155,10 @@ export const openFileAttr = (attrs: IObject, focusName = "bookmark") => { let hasAV = false; const range = getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : null; Object.keys(attrs).forEach(item => { - if ("custom-riff-decks" === item || item.startsWith("custom-sy-")) { + if (Constants.CUSTOM_RIFF_DECKS === item || item.startsWith("custom-sy-")) { return; } - if (item === "custom-reminder-wechat") { + if (item === Constants.CUSTOM_REMINDER_WECHAT) { notifyHTML = ` +