mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
Only expand/collapse the left pane of the focused window.
This commit is contained in:
parent
3b7285ba5d
commit
a76ca76813
@ -5,10 +5,13 @@ import { t } from "../../services/i18n.js";
|
|||||||
import type { EventData } from "../../components/app_context.js";
|
import type { EventData } from "../../components/app_context.js";
|
||||||
|
|
||||||
export default class LeftPaneToggleWidget extends CommandButtonWidget {
|
export default class LeftPaneToggleWidget extends CommandButtonWidget {
|
||||||
|
private currentLeftPaneVisible: boolean;
|
||||||
|
|
||||||
constructor(isHorizontalLayout: boolean) {
|
constructor(isHorizontalLayout: boolean) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.currentLeftPaneVisible = options.is("leftPaneVisible");
|
||||||
|
|
||||||
this.class(isHorizontalLayout ? "toggle-button" : "launcher-button");
|
this.class(isHorizontalLayout ? "toggle-button" : "launcher-button");
|
||||||
|
|
||||||
this.settings.icon = () => {
|
this.settings.icon = () => {
|
||||||
@ -21,7 +24,7 @@ export default class LeftPaneToggleWidget extends CommandButtonWidget {
|
|||||||
|
|
||||||
this.settings.title = () => (options.is("leftPaneVisible") ? t("left_pane_toggle.hide_panel") : t("left_pane_toggle.show_panel"));
|
this.settings.title = () => (options.is("leftPaneVisible") ? t("left_pane_toggle.hide_panel") : t("left_pane_toggle.show_panel"));
|
||||||
|
|
||||||
this.settings.command = () => (options.is("leftPaneVisible") ? "hideLeftPane" : "showLeftPane");
|
this.settings.command = () => (this.currentLeftPaneVisible ? "hideLeftPane" : "showLeftPane");
|
||||||
|
|
||||||
if (isHorizontalLayout) {
|
if (isHorizontalLayout) {
|
||||||
this.settings.titlePlacement = "bottom";
|
this.settings.titlePlacement = "bottom";
|
||||||
@ -29,13 +32,15 @@ export default class LeftPaneToggleWidget extends CommandButtonWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshIcon() {
|
refreshIcon() {
|
||||||
super.refreshIcon();
|
if (document.hasFocus() || this.currentLeftPaneVisible === true) {
|
||||||
|
super.refreshIcon();
|
||||||
splitService.setupLeftPaneResizer(options.is("leftPaneVisible"));
|
splitService.setupLeftPaneResizer(this.currentLeftPaneVisible);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
||||||
if (loadResults.isOptionReloaded("leftPaneVisible")) {
|
if (loadResults.isOptionReloaded("leftPaneVisible") && document.hasFocus()) {
|
||||||
|
this.currentLeftPaneVisible = options.is("leftPaneVisible");
|
||||||
this.refreshIcon();
|
this.refreshIcon();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ export default class LeftPaneContainer extends FlexContainer<Component> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
||||||
if (loadResults.isOptionReloaded("leftPaneVisible")) {
|
if (loadResults.isOptionReloaded("leftPaneVisible") && document.hasFocus()) {
|
||||||
const visible = this.isEnabled();
|
const visible = this.isEnabled();
|
||||||
this.toggleInt(visible);
|
this.toggleInt(visible);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user