Skip to content

Build your personal knowledge base with Trilium Notes

chore(client/ts): port desktop_layout

Elian Doranc2a7b92660a6
diff --git a/src/public/app/components/app_context.ts b/src/public/app/components/app_context.ts
index 2d95e86320..7063a8de37 100644
--- a/src/public/app/components/app_context.ts
+++ b/src/public/app/components/app_context.ts
@@ -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>>;
-class AppContext extends Component {
+export class AppContext extends Component {
isMainWindow: boolean;
components: Component[];
beforeUnloadListeners: WeakRef<BeforeUploadListener>[];
diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.ts
similarity index 98%
rename from src/public/app/layouts/desktop_layout.js
rename to src/public/app/layouts/desktop_layout.ts
index ecb97fe5f6..129173838a 100644
--- a/src/public/app/layouts/desktop_layout.js
+++ b/src/public/app/layouts/desktop_layout.ts
@@ -88,13 +88,18 @@ import utils from "../services/utils.js";
import GeoMapButtons from "../widgets/floating_buttons/geo_map_button.js";
import ContextualHelpButton from "../widgets/floating_buttons/help_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 {
- constructor(customWidgets) {
+
+ private customWidgets: WidgetsByParent;
+
+ constructor(customWidgets: WidgetsByParent) {
this.customWidgets = customWidgets;
}
- getRootWidget(appContext) {
+ getRootWidget(appContext: AppContext) {
appContext.noteTreeWidget = new NoteTreeWidget();
const launcherPaneIsHorizontal = options.get("layoutOrientation") === "horizontal";
@@ -267,7 +272,7 @@ export default class DesktopLayout {
.child(new CloseZenButton());
}
- #buildLauncherPane(isHorizontal) {
+ #buildLauncherPane(isHorizontal: boolean) {
let launcherPane;
if (isHorizontal) {
diff --git a/src/public/app/services/bundle.ts b/src/public/app/services/bundle.ts
index e4fc31de20..e6eea7ef1c 100644
--- a/src/public/app/services/bundle.ts
+++ b/src/public/app/services/bundle.ts
@@ -50,7 +50,7 @@ async function executeStartupBundles() {
}
}
-class WidgetsByParent {
+export class WidgetsByParent {
private byParent: Record<string, Widget[]>;
constructor() {
diff --git a/src/public/app/types.d.ts b/src/public/app/types.d.ts
index 3c672e7a3b..05b533f731 100644
--- a/src/public/app/types.d.ts
+++ b/src/public/app/types.d.ts
@@ -47,6 +47,7 @@ interface CustomGlobals {
TRILIUM_SAFE_MODE: boolean;
platform?: typeof process.platform;
linter: typeof lint;
+ hasNativeTitleBar: boolean;
}
type RequireMethod = (moduleName: string) => any;
diff --git a/src/public/app/widgets/containers/ribbon_container.ts b/src/public/app/widgets/containers/ribbon_container.ts
index cd1cebdcf2..e4e78b43f9 100644
--- a/src/public/app/widgets/containers/ribbon_container.ts
+++ b/src/public/app/widgets/containers/ribbon_container.ts
@@ -5,6 +5,7 @@ import type CommandButtonWidget from "../buttons/command_button.js";
import type FNote from "../../entities/fnote.js";
import type { NoteType } from "../../entities/fnote.js";
import type { EventData, EventNames } from "../../components/app_context.js";
+import type NoteActionsWidget from "../buttons/note_actions.js";
const TPL = `
<div class="ribbon-container">
@@ -116,13 +117,15 @@ const TPL = `
<div class="ribbon-body-container"></div>
</div>`;
+type ButtonWidget = (CommandButtonWidget | NoteActionsWidget);
+
export default class RibbonContainer extends NoteContextAwareWidget {
private lastActiveComponentId?: string | null;
private lastNoteType?: NoteType;
private ribbonWidgets: NoteContextAwareWidget[];
- private buttonWidgets: CommandButtonWidget[];
+ private buttonWidgets: ButtonWidget[];
private $tabContainer!: JQuery<HTMLElement>;
private $buttonContainer!: JQuery<HTMLElement>;
private $bodyContainer!: JQuery<HTMLElement>;
@@ -148,7 +151,7 @@ export default class RibbonContainer extends NoteContextAwareWidget {
return this;
}
- button(widget: CommandButtonWidget) {
+ button(widget: ButtonWidget) {
super.child(widget);
this.buttonWidgets.push(widget);