chore(client/ts): port desktop_layout

This commit is contained in:
Elian Doran 2025-03-21 18:14:37 +02:00
parent 8e3a75ad57
commit c2a7b92660
No known key found for this signature in database
5 changed files with 16 additions and 7 deletions

View File

@ -404,7 +404,7 @@ type FilterByValueType<T, ValueType> = { [K in keyof T]: T[K] extends ValueType
*/ */
export type FilteredCommandNames<T extends CommandData> = keyof Pick<CommandMappings, FilterByValueType<CommandMappings, T>>; export type FilteredCommandNames<T extends CommandData> = keyof Pick<CommandMappings, FilterByValueType<CommandMappings, T>>;
class AppContext extends Component { export class AppContext extends Component {
isMainWindow: boolean; isMainWindow: boolean;
components: Component[]; components: Component[];
beforeUnloadListeners: WeakRef<BeforeUploadListener>[]; beforeUnloadListeners: WeakRef<BeforeUploadListener>[];

View File

@ -88,13 +88,18 @@ import utils from "../services/utils.js";
import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js"; import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";
import ContextualHelpButton from "../widgets/floating_buttons/help_button.js"; import ContextualHelpButton from "../widgets/floating_buttons/help_button.js";
import CloseZenButton from "../widgets/close_zen_button.js"; import CloseZenButton from "../widgets/close_zen_button.js";
import type { AppContext } from "./../components/app_context.js";
import type { WidgetsByParent } from "../services/bundle.js";
export default class DesktopLayout { export default class DesktopLayout {
constructor(customWidgets) {
private customWidgets: WidgetsByParent;
constructor(customWidgets: WidgetsByParent) {
this.customWidgets = customWidgets; this.customWidgets = customWidgets;
} }
getRootWidget(appContext) { getRootWidget(appContext: AppContext) {
appContext.noteTreeWidget = new NoteTreeWidget(); appContext.noteTreeWidget = new NoteTreeWidget();
const launcherPaneIsHorizontal = options.get("layoutOrientation") === "horizontal"; const launcherPaneIsHorizontal = options.get("layoutOrientation") === "horizontal";
@ -267,7 +272,7 @@ export default class DesktopLayout {
.child(new CloseZenButton()); .child(new CloseZenButton());
} }
#buildLauncherPane(isHorizontal) { #buildLauncherPane(isHorizontal: boolean) {
let launcherPane; let launcherPane;
if (isHorizontal) { if (isHorizontal) {

View File

@ -50,7 +50,7 @@ async function executeStartupBundles() {
} }
} }
class WidgetsByParent { export class WidgetsByParent {
private byParent: Record<string, Widget[]>; private byParent: Record<string, Widget[]>;
constructor() { constructor() {

View File

@ -47,6 +47,7 @@ interface CustomGlobals {
TRILIUM_SAFE_MODE: boolean; TRILIUM_SAFE_MODE: boolean;
platform?: typeof process.platform; platform?: typeof process.platform;
linter: typeof lint; linter: typeof lint;
hasNativeTitleBar: boolean;
} }
type RequireMethod = (moduleName: string) => any; type RequireMethod = (moduleName: string) => any;

View File

@ -5,6 +5,7 @@ import type CommandButtonWidget from "../buttons/command_button.js";
import type FNote from "../../entities/fnote.js"; import type FNote from "../../entities/fnote.js";
import type { NoteType } from "../../entities/fnote.js"; import type { NoteType } from "../../entities/fnote.js";
import type { EventData, EventNames } from "../../components/app_context.js"; import type { EventData, EventNames } from "../../components/app_context.js";
import type NoteActionsWidget from "../buttons/note_actions.js";
const TPL = ` const TPL = `
<div class="ribbon-container"> <div class="ribbon-container">
@ -116,13 +117,15 @@ const TPL = `
<div class="ribbon-body-container"></div> <div class="ribbon-body-container"></div>
</div>`; </div>`;
type ButtonWidget = (CommandButtonWidget | NoteActionsWidget);
export default class RibbonContainer extends NoteContextAwareWidget { export default class RibbonContainer extends NoteContextAwareWidget {
private lastActiveComponentId?: string | null; private lastActiveComponentId?: string | null;
private lastNoteType?: NoteType; private lastNoteType?: NoteType;
private ribbonWidgets: NoteContextAwareWidget[]; private ribbonWidgets: NoteContextAwareWidget[];
private buttonWidgets: CommandButtonWidget[]; private buttonWidgets: ButtonWidget[];
private $tabContainer!: JQuery<HTMLElement>; private $tabContainer!: JQuery<HTMLElement>;
private $buttonContainer!: JQuery<HTMLElement>; private $buttonContainer!: JQuery<HTMLElement>;
private $bodyContainer!: JQuery<HTMLElement>; private $bodyContainer!: JQuery<HTMLElement>;
@ -148,7 +151,7 @@ export default class RibbonContainer extends NoteContextAwareWidget {
return this; return this;
} }
button(widget: CommandButtonWidget) { button(widget: ButtonWidget) {
super.child(widget); super.child(widget);
this.buttonWidgets.push(widget); this.buttonWidgets.push(widget);