-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to pin tabs to they are always first in the toolbar (#47)
* Add ability to pin tabs to they are always first in the toolbar * Reorder tabs when pinning
- Loading branch information
1 parent
3fe3413
commit 72a2635
Showing
11 changed files
with
241 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/marqus-desktop/src/main/schemas/appState/2_addViewState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/marqus-desktop/src/main/schemas/appState/3_addIsPinned.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { z } from "zod"; | ||
import { ModelViewState, Section } from "../../../shared/ui/app"; | ||
import { DATE_OR_STRING_SCHEMA, PX_REGEX } from "../../../shared/domain"; | ||
import { NoteSort } from "../../../shared/domain/note"; | ||
import { AppStateV2 } from "./2_addViewState"; | ||
|
||
export interface AppStateV3 { | ||
version: number; | ||
sidebar: Sidebar; | ||
editor: Editor; | ||
focused: Section[]; | ||
} | ||
|
||
interface Sidebar { | ||
searchString?: string; | ||
hidden?: boolean; | ||
width: string; | ||
scroll: number; | ||
selected?: string[]; | ||
expanded?: string[]; | ||
sort: NoteSort; | ||
} | ||
|
||
interface Editor { | ||
isEditing: boolean; | ||
scroll: number; | ||
tabs: EditorTab[]; | ||
tabsScroll: number; | ||
activeTabNoteId?: string; | ||
} | ||
|
||
interface EditorTab { | ||
noteId: string; | ||
noteContent?: string; | ||
lastActive?: Date | string; | ||
viewState?: ModelViewState["viewState"]; | ||
isPinned?: boolean; | ||
} | ||
|
||
export const appStateV3 = z.preprocess( | ||
obj => { | ||
const state = obj as AppStateV2 | AppStateV3; | ||
if (state.version === 2) { | ||
state.version = 3; | ||
} | ||
|
||
return state; | ||
}, | ||
z.object({ | ||
version: z.literal(3), | ||
sidebar: z.object({ | ||
width: z.string().regex(PX_REGEX), | ||
scroll: z.number(), | ||
hidden: z.boolean().optional(), | ||
selected: z.array(z.string()).optional(), | ||
expanded: z.array(z.string()).optional(), | ||
sort: z.nativeEnum(NoteSort), | ||
searchString: z.string().optional(), | ||
}), | ||
editor: z.object({ | ||
isEditing: z.boolean(), | ||
scroll: z.number(), | ||
tabs: z.array( | ||
z.object({ | ||
noteId: z.string(), | ||
// Intentionally omitted noteContent | ||
lastActive: DATE_OR_STRING_SCHEMA.optional(), | ||
viewState: z.any().optional(), | ||
isPinned: z.boolean().optional(), | ||
}), | ||
), | ||
tabsScroll: z.number(), | ||
activeTabNoteId: z.string().optional(), | ||
}), | ||
focused: z.array(z.nativeEnum(Section)), | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { appStateV1 } from "./1_initialDefinition"; | ||
import { appStateV2 } from "./2_addViewState"; | ||
import { appStateV3 } from "./3_addIsPinned"; | ||
|
||
export const APP_STATE_SCHEMAS = { | ||
1: appStateV1, | ||
2: appStateV2, | ||
3: appStateV3, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.