mirror of
https://github.com/vicky469/aside.git
synced 2026-07-22 07:01:57 +00:00
fix: clear sidebar context when no active file and adjust toolbar sizing
This commit is contained in:
parent
3281276cc6
commit
df60911c18
8 changed files with 69 additions and 26 deletions
10
docs/releases/2.0.89.md
Normal file
10
docs/releases/2.0.89.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# 2.0.89
|
||||
|
||||
## What's new
|
||||
|
||||
- Keep the sidebar empty when no tab is active so stale notes from previous files are not shown.
|
||||
- Improve index and note toolbar sizing so file-pinned controls and action buttons are more compact.
|
||||
|
||||
## Notes
|
||||
|
||||
- This release only changes sidebar behavior and styling; it does not alter storage formats.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "aside",
|
||||
"name": "Aside",
|
||||
"version": "2.0.88",
|
||||
"version": "2.0.89",
|
||||
"minAppVersion": "1.12.7",
|
||||
"description": "Side comments for humans and agents.",
|
||||
"author": "vicky",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "aside",
|
||||
"version": "2.0.88",
|
||||
"version": "2.0.89",
|
||||
"description": "Side comments for humans and agents.",
|
||||
"private": true,
|
||||
"main": "main.js",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import {
|
|||
resolveWorkspaceFileTargets,
|
||||
resolveWorkspaceLeafTargetInput,
|
||||
shouldHidePublicMarkdownProperties,
|
||||
shouldIgnoreWorkspaceFileOpen,
|
||||
shouldIgnoreWorkspaceLeafChange,
|
||||
type SidebarUnavailableReason,
|
||||
} from "./workspaceContextPlanner";
|
||||
|
|
@ -36,6 +35,7 @@ export class WorkspaceContextController {
|
|||
|
||||
public initializeActiveFiles(activeFile: TFile | null): void {
|
||||
const nextState = resolveWorkspaceFileTargets(
|
||||
activeFile,
|
||||
activeFile,
|
||||
null,
|
||||
null,
|
||||
|
|
@ -47,16 +47,13 @@ export class WorkspaceContextController {
|
|||
|
||||
public handleFileOpen(file: TFile | null): void {
|
||||
const activeFile = this.host.app.workspace.getActiveFile();
|
||||
if (shouldIgnoreWorkspaceFileOpen(file, activeFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
void this.syncIndexNoteLeafMode(this.host.app.workspace.getActiveViewOfType(MarkdownView)?.leaf ?? null);
|
||||
this.syncIndexNoteViewClasses();
|
||||
this.applyWorkspaceFileTargets(resolveWorkspaceTargetInput(
|
||||
file,
|
||||
activeFile,
|
||||
));
|
||||
), activeFile);
|
||||
}
|
||||
|
||||
public handleActiveLeafChange(leaf: WorkspaceLeaf | null): void {
|
||||
|
|
@ -64,10 +61,11 @@ export class WorkspaceContextController {
|
|||
if (shouldIgnoreWorkspaceLeafChange(viewType)) {
|
||||
return;
|
||||
}
|
||||
const workspaceActiveFile = this.host.app.workspace.getActiveFile();
|
||||
|
||||
const file = resolveWorkspaceLeafTargetInput(
|
||||
leaf,
|
||||
this.host.app.workspace.getActiveFile(),
|
||||
workspaceActiveFile,
|
||||
(value): value is TFile => value instanceof TFile,
|
||||
(filePath) => {
|
||||
const file = this.host.app.vault.getAbstractFileByPath(filePath);
|
||||
|
|
@ -76,7 +74,7 @@ export class WorkspaceContextController {
|
|||
);
|
||||
void this.syncIndexNoteLeafMode(leaf);
|
||||
this.syncIndexNoteViewClasses();
|
||||
this.applyWorkspaceFileTargets(file);
|
||||
this.applyWorkspaceFileTargets(file, workspaceActiveFile);
|
||||
}
|
||||
|
||||
public async syncIndexNoteLeafMode(leaf: WorkspaceLeaf | null): Promise<void> {
|
||||
|
|
@ -119,10 +117,14 @@ export class WorkspaceContextController {
|
|||
});
|
||||
}
|
||||
|
||||
private applyWorkspaceFileTargets(file: TFile | null): void {
|
||||
private applyWorkspaceFileTargets(
|
||||
file: TFile | null,
|
||||
workspaceActiveFile: TFile | null,
|
||||
): void {
|
||||
const targetVersion = ++this.workspaceTargetVersion;
|
||||
const nextState = resolveWorkspaceFileTargets(
|
||||
file,
|
||||
workspaceActiveFile,
|
||||
this.host.getActiveMarkdownFile(),
|
||||
this.host.getActiveSidebarFile(),
|
||||
(candidate): candidate is TFile => this.host.isMarkdownCommentableFile(candidate),
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ function isMarkdownWorkspaceLeaf(leaf: unknown): boolean {
|
|||
|
||||
export function resolveWorkspaceFileTargets<T>(
|
||||
file: T | null,
|
||||
workspaceActiveFile: T | null,
|
||||
activeMarkdownFile: T | null,
|
||||
activeSidebarFile: T | null,
|
||||
isMarkdownCommentableFile: (file: T | null) => file is T,
|
||||
|
|
@ -175,19 +176,26 @@ export function resolveWorkspaceFileTargets<T>(
|
|||
): WorkspaceFileTargets<T> {
|
||||
const hasConcreteFile = file !== null;
|
||||
const supportsSidebar = isSidebarSupportedFile(file);
|
||||
const hasWorkspaceActiveFile = workspaceActiveFile !== null;
|
||||
const nextActiveMarkdownFile = isMarkdownCommentableFile(file)
|
||||
? file
|
||||
: activeMarkdownFile;
|
||||
: hasWorkspaceActiveFile
|
||||
? activeMarkdownFile
|
||||
: null;
|
||||
const nextActiveSidebarFile = supportsSidebar
|
||||
? file
|
||||
: hasConcreteFile
|
||||
? null
|
||||
: activeSidebarFile;
|
||||
: hasWorkspaceActiveFile
|
||||
? activeSidebarFile
|
||||
: null;
|
||||
const sidebarFile = supportsSidebar
|
||||
? file
|
||||
: hasConcreteFile
|
||||
? null
|
||||
: activeSidebarFile;
|
||||
: hasWorkspaceActiveFile
|
||||
? activeSidebarFile
|
||||
: null;
|
||||
|
||||
return {
|
||||
activeMarkdownFile: nextActiveMarkdownFile,
|
||||
|
|
|
|||
26
styles.css
26
styles.css
|
|
@ -741,21 +741,21 @@ button.aside-tab-button[aria-disabled="true"] {
|
|||
}
|
||||
|
||||
button.aside-sidebar-file-pin-button {
|
||||
flex: 0 0 26px;
|
||||
width: 26px;
|
||||
min-width: 26px;
|
||||
max-width: 26px;
|
||||
height: 26px;
|
||||
min-height: 26px;
|
||||
max-height: 26px;
|
||||
flex: 0 0 22px;
|
||||
width: 22px;
|
||||
min-width: 22px;
|
||||
max-width: 22px;
|
||||
height: 22px;
|
||||
min-height: 22px;
|
||||
max-height: 22px;
|
||||
margin-left: auto;
|
||||
padding: 0;
|
||||
--icon-size: 13px;
|
||||
--icon-size: 12px;
|
||||
}
|
||||
|
||||
.aside-sidebar-toolbar-row.is-note-primary-row .aside-toolbar-icon-button {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: var(--aside-note-toolbar-radius);
|
||||
margin-bottom: -1px;
|
||||
color: color-mix(in srgb, var(--icon-color, var(--text-faint, var(--text-muted))) 82%, var(--text-muted) 18%);
|
||||
|
|
@ -771,6 +771,8 @@ button.aside-sidebar-file-pin-button {
|
|||
height: 26px;
|
||||
min-height: 26px;
|
||||
max-height: 26px;
|
||||
--aside-toolbar-control-font-size: 11px;
|
||||
--icon-size: 13px;
|
||||
border-radius: var(--aside-note-toolbar-radius);
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
|
|
@ -1253,8 +1255,8 @@ button.aside-filter-chip {
|
|||
}
|
||||
|
||||
.aside-sidebar-toolbar.is-note-toolbar .aside-comment-section-add-button svg {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
}
|
||||
|
||||
.aside-comment-section-add-button:hover,
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class MockPlugin {
|
|||
const nextState = resolveWorkspaceFileTargets(
|
||||
file,
|
||||
this.activeMarkdownFile,
|
||||
this.activeMarkdownFile,
|
||||
this.activeSidebarFile,
|
||||
(candidate): candidate is MockFile => !!candidate && candidate.extension === "md" && candidate.path !== ALL_COMMENTS_NOTE_PATH,
|
||||
(candidate): candidate is MockFile => !!candidate && (candidate.extension === "md" || candidate.extension === "pdf"),
|
||||
|
|
@ -269,6 +270,7 @@ test("workspace file targets preserve the last markdown note while pointing the
|
|||
const target = resolveWorkspaceFileTargets(
|
||||
{ path: ALL_COMMENTS_NOTE_PATH, extension: "md" },
|
||||
{ path: "last-note.md", extension: "md" },
|
||||
{ path: "last-note.md", extension: "md" },
|
||||
null,
|
||||
(file): file is MockFile => !!file && file.extension === "md" && file.path !== ALL_COMMENTS_NOTE_PATH,
|
||||
(file): file is MockFile => !!file && file.extension === "md",
|
||||
|
|
@ -283,6 +285,7 @@ test("workspace file targets preserve the last markdown note while pointing the
|
|||
const target = resolveWorkspaceFileTargets(
|
||||
{ path: "docs/file.pdf", extension: "pdf" },
|
||||
{ path: "last-note.md", extension: "md" },
|
||||
{ path: "last-note.md", extension: "md" },
|
||||
{ path: "docs/note.md", extension: "md" },
|
||||
(file): file is MockFile => !!file && file.extension === "md" && file.path !== ALL_COMMENTS_NOTE_PATH,
|
||||
(file): file is MockFile => !!file && (file.extension === "md" || file.extension === "pdf"),
|
||||
|
|
@ -297,6 +300,7 @@ test("workspace file targets preserve the current sidebar file when leaf changes
|
|||
const target = resolveWorkspaceFileTargets(
|
||||
null,
|
||||
{ path: "last-note.md", extension: "md" },
|
||||
{ path: "last-note.md", extension: "md" },
|
||||
{ path: ALL_COMMENTS_NOTE_PATH, extension: "md" },
|
||||
(file): file is MockFile => !!file && file.extension === "md" && file.path !== ALL_COMMENTS_NOTE_PATH,
|
||||
(file): file is MockFile => !!file && file.extension === "md",
|
||||
|
|
@ -310,6 +314,7 @@ test("workspace file targets preserve the current sidebar file when leaf changes
|
|||
test("workspace file targets clear the sidebar file when the active file is unsupported", () => {
|
||||
const target = resolveWorkspaceFileTargets(
|
||||
{ path: "docs/board.canvas", extension: "canvas" },
|
||||
{ path: "docs/file.pdf", extension: "pdf" },
|
||||
{ path: "last-note.md", extension: "md" },
|
||||
{ path: "docs/note.md", extension: "md" },
|
||||
(file): file is MockFile => !!file && file.extension === "md" && file.path !== ALL_COMMENTS_NOTE_PATH,
|
||||
|
|
@ -321,6 +326,21 @@ test("workspace file targets clear the sidebar file when the active file is unsu
|
|||
assert.equal(target.sidebarFile, null);
|
||||
});
|
||||
|
||||
test("workspace file targets clear when there is no active workspace file", () => {
|
||||
const target = resolveWorkspaceFileTargets(
|
||||
null,
|
||||
null,
|
||||
{ path: "last-note.md", extension: "md" },
|
||||
{ path: ALL_COMMENTS_NOTE_PATH, extension: "md" },
|
||||
(file): file is MockFile => !!file && file.extension === "md" && file.path !== ALL_COMMENTS_NOTE_PATH,
|
||||
(file): file is MockFile => !!file && file.extension === "md",
|
||||
);
|
||||
|
||||
assert.equal(target.activeMarkdownFile, null);
|
||||
assert.equal(target.activeSidebarFile, null);
|
||||
assert.equal(target.sidebarFile, null);
|
||||
});
|
||||
|
||||
test("workspace target input prefers the real active file when the event file is missing", () => {
|
||||
const resolved = resolveWorkspaceTargetInput(
|
||||
null,
|
||||
|
|
|
|||
|
|
@ -123,5 +123,6 @@
|
|||
"2.0.85": "1.12.7",
|
||||
"2.0.86": "1.12.7",
|
||||
"2.0.87": "1.12.7",
|
||||
"2.0.88": "1.12.7"
|
||||
"2.0.88": "1.12.7",
|
||||
"2.0.89": "1.12.7"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue