mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-09 21:23:02 +08:00
This commit is contained in:
parent
1c90c34091
commit
8468982005
@ -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 => {
|
||||
|
@ -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) {
|
||||
|
@ -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) => {
|
||||
|
@ -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}"]`);
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user