Vanessa 2024-02-19 17:12:59 +08:00
parent bffd71dd67
commit c9b2db8818
3 changed files with 9 additions and 3 deletions

View File

@ -105,6 +105,7 @@ export abstract class Constants {
public static readonly LOCAL_FILEPOSITION = "local-fileposition"; public static readonly LOCAL_FILEPOSITION = "local-fileposition";
public static readonly LOCAL_DIALOGPOSITION = "local-dialogposition"; public static readonly LOCAL_DIALOGPOSITION = "local-dialogposition";
public static readonly LOCAL_SESSION_FIRSTLOAD = "local-session-firstload"; public static readonly LOCAL_SESSION_FIRSTLOAD = "local-session-firstload";
public static readonly LOCAL_OUTLINE = "local-outline";
// dialog // dialog
public static readonly DIALOG_OPENCARD = "dialog-opencard"; public static readonly DIALOG_OPENCARD = "dialog-opencard";

View File

@ -6,7 +6,7 @@ import {getDockByType} from "../tabUtil";
import {fetchPost} from "../../util/fetch"; import {fetchPost} from "../../util/fetch";
import {getAllModels} from "../getAll"; import {getAllModels} from "../getAll";
import {hasClosestBlock, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest"; import {hasClosestBlock, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest";
import {updateHotkeyTip} from "../../protyle/util/compatibility"; import {setStorageVal, updateHotkeyTip} from "../../protyle/util/compatibility";
import {openFileById} from "../../editor/util"; import {openFileById} from "../../editor/util";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {escapeHtml} from "../../util/escape"; import {escapeHtml} from "../../util/escape";
@ -87,7 +87,7 @@ export class Outline extends Model {
<svg class="block__logoicon"><use xlink:href="#iconAlignCenter"></use></svg>${window.siyuan.languages.outline} <svg class="block__logoicon"><use xlink:href="#iconAlignCenter"></use></svg>${window.siyuan.languages.outline}
</div> </div>
<span class="fn__flex-1 fn__space"></span> <span class="fn__flex-1 fn__space"></span>
<span data-type="expand" class="block__icon b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.stickOpen} ${updateHotkeyTip(window.siyuan.config.keymap.editor.general.expand.custom)}"> <span data-type="expand" class="block__icon b3-tooltips b3-tooltips__sw${window.siyuan.storage[Constants.LOCAL_OUTLINE].keepExpand ? " block__icon--active" : ""}" aria-label="${window.siyuan.languages.stickOpen} ${updateHotkeyTip(window.siyuan.config.keymap.editor.general.expand.custom)}">
<svg><use xlink:href="#iconExpand"></use></svg> <svg><use xlink:href="#iconExpand"></use></svg>
</span> </span>
<span class="fn__space"></span> <span class="fn__space"></span>
@ -155,9 +155,13 @@ export class Outline extends Model {
} }
if (iconElement.classList.contains("block__icon--active")) { if (iconElement.classList.contains("block__icon--active")) {
iconElement.classList.remove("block__icon--active"); iconElement.classList.remove("block__icon--active");
window.siyuan.storage[Constants.LOCAL_OUTLINE].keepExpand = false;
} else { } else {
iconElement.classList.add("block__icon--active"); iconElement.classList.add("block__icon--active");
window.siyuan.storage[Constants.LOCAL_OUTLINE].keepExpand = true;
} }
setStorageVal(Constants.LOCAL_OUTLINE, window.siyuan.storage[Constants.LOCAL_OUTLINE]);
this.tree.expandAll(); this.tree.expandAll();
}); });
options.tab.panelElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => { options.tab.panelElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {

View File

@ -187,6 +187,7 @@ export const getLocalStorage = (cb: () => void) => {
defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}} defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}}
defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""} defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = []; defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true};
defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr} defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr}
defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition} defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition}
defaultStorage[Constants.LOCAL_FLASHCARD] = { defaultStorage[Constants.LOCAL_FLASHCARD] = {
@ -250,7 +251,7 @@ export const getLocalStorage = (cb: () => void) => {
Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES,
Constants.LOCAL_SEARCHDATA, Constants.LOCAL_ZOOM, Constants.LOCAL_LAYOUTS, Constants.LOCAL_AI, Constants.LOCAL_SEARCHDATA, Constants.LOCAL_ZOOM, Constants.LOCAL_LAYOUTS, Constants.LOCAL_AI,
Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD, Constants.LOCAL_DIALOGPOSITION, Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD, Constants.LOCAL_DIALOGPOSITION,
Constants.LOCAL_FILEPOSITION].forEach((key) => { Constants.LOCAL_OUTLINE, Constants.LOCAL_FILEPOSITION].forEach((key) => {
if (typeof response.data[key] === "string") { if (typeof response.data[key] === "string") {
try { try {
const parseData = JSON.parse(response.data[key]); const parseData = JSON.parse(response.data[key]);