Kaynağa Gözat

:art: fix https://github.com/siyuan-note/siyuan/issues/7047

Vanessa 2 yıl önce
ebeveyn
işleme
8468982005

+ 2 - 0
app/src/config/editor.ts

@@ -6,6 +6,7 @@ import {setPadding} from "../protyle/ui/initUI";
 import {reloadProtyle} from "../protyle/util/reload";
 import {disabledProtyle, enableProtyle} from "../protyle/util/onGet";
 import {updateHotkeyTip} from "../protyle/util/compatibility";
+import {updateTitle} from "../dialog/processSystem";
 
 export const editor = {
     element: undefined as Element,
@@ -22,6 +23,7 @@ export const editor = {
             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");
         }
+        updateTitle(readOnly);
         fetchPost("/api/setting/setEditor", window.siyuan.config.editor, () => {
             const allModels = getAllModels();
             allModels.editor.forEach(editor => {

+ 29 - 1
app/src/dialog/processSystem.ts

@@ -271,7 +271,7 @@ export const bootSync = () => {
     });
 };
 
-export const setTitle = (title: string) => {
+export const setTitle = (title: string, protyle?: IProtyle) => {
     const dragElement = document.getElementById("drag");
     const workspaceName = getWorkspaceName();
     if (title === window.siyuan.languages.siyuanNote) {
@@ -281,12 +281,40 @@ export const setTitle = (title: string) => {
         dragElement.setAttribute("title", versionTitle);
     } else {
         title = title || "Untitled";
+        if (protyle && protyle.disabled) {
+            title = `[${window.siyuan.languages.editReadonly}] ${title}`
+        }
+        if (protyle && protyle.block.showAll) {
+            title = `[${window.siyuan.languages.enter}] ${title}`
+        }
         document.title = `${title} - ${workspaceName}  - ${window.siyuan.languages.siyuanNote} v${Constants.SIYUAN_VERSION}`;
         dragElement.textContent = title;
         dragElement.setAttribute("title", title);
     }
 };
 
+export const updateTitle = (readonly?: boolean, zoomIn?: boolean) => {
+    const title = document.getElementById("drag").textContent;
+    if (typeof readonly === "boolean") {
+        if (readonly) {
+            if (title.indexOf(window.siyuan.languages.editReadonly) === -1) {
+                setTitle(`[${window.siyuan.languages.editReadonly}] ${title}`)
+            }
+        } else {
+            setTitle(title.replace(`[${window.siyuan.languages.editReadonly}] `, ""))
+        }
+    }
+    if (typeof zoomIn === "boolean") {
+        if (zoomIn) {
+            if (title.indexOf(window.siyuan.languages.enter) === -1) {
+                setTitle(`[${window.siyuan.languages.enter}] ${title}`);
+            }
+        } else {
+            setTitle(title.replace(`[${window.siyuan.languages.enter}] `, ""))
+        }
+    }
+}
+
 export const downloadProgress = (data: { id: string, percent: number }) => {
     const bazzarElement = document.getElementById("configBazaarReadme");
     if (!bazzarElement) {

+ 1 - 1
app/src/editor/util.ts

@@ -357,7 +357,7 @@ export const updatePanelByEditor = (protyle?: IProtyle, focus = true, pushBackSt
     const models = getAllModels();
     updateOutline(models, protyle, reload);
     updateBacklinkGraph(models, protyle);
-    setTitle(title);
+    setTitle(title, protyle);
 };
 
 export const isCurrentEditor = (blockId: string) => {

+ 2 - 0
app/src/menus/protyle.ts

@@ -45,6 +45,7 @@ import {exportAsset} from "./util";
 import {removeLink} from "../protyle/toolbar/Link";
 import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey";
 import {getEnableHTML} from "../protyle/wysiwyg/removeEmbed";
+import {updateTitle} from "../dialog/processSystem";
 
 export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
     const nodeElement = hasClosestBlock(element);
@@ -473,6 +474,7 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB
         } else {
             onGet(getResponse, protyle, id === protyle.block.rootID ? [Constants.CB_GET_FOCUS, Constants.CB_GET_HTML, Constants.CB_GET_UNUNDO] : [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS, Constants.CB_GET_UNUNDO, Constants.CB_GET_HTML]);
         }
+        updateTitle(undefined, id !== protyle.block.rootID);
         // https://github.com/siyuan-note/siyuan/issues/4874
         if (focusId) {
             const focusElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${focusId}"]`);

+ 1 - 2
app/src/protyle/header/Title.ts

@@ -282,7 +282,7 @@ export class Title {
                 title: fileName,
             });
             this.setTitle(fileName);
-            setTitle(fileName);
+            setTitle(fileName, protyle);
         }, Constants.TIMEOUT_INPUT);
     }
 
@@ -368,7 +368,6 @@ ${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14))
         if (this.editElement.getAttribute("data-render") === "true" && !refresh) {
             return false;
         }
-        setTitle(response.data.ial.title);
         protyle.background.render(response.data.ial, protyle.block.rootID);
         protyle.wysiwyg.renderCustom(response.data.ial);
         this.editElement.setAttribute("data-render", "true");

+ 2 - 2
app/src/protyle/util/onGet.ts

@@ -1,4 +1,4 @@
-import {lockFile} from "../../dialog/processSystem";
+import {lockFile, setTitle} from "../../dialog/processSystem";
 import {Constants} from "../../constants";
 import {hideElements} from "../ui/hideElements";
 import {genEmptyElement} from "../../block/util";
@@ -121,7 +121,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[]
             unScroll: (scrollObj && scrollObj.focusId) ? true : false,
             isSyncing: data.data.isSyncing,
         }, protyle);
-
+        setTitle(response.data.ial.title, protyle);
         if (scrollObj && protyle.options.mode !== "preview") {
             restoreScroll(protyle, scrollObj);
         }