Skip to content

Build your personal knowledge base with Trilium Notes

fix(share): give the shared geo map's app context a tab manager

Elian Dorancefc94d4b102
diff --git a/packages/share-theme/src/content/geomap_view.tsx b/packages/share-theme/src/content/geomap_view.tsx
index a6f39bee02..30f4a25434 100644
--- a/packages/share-theme/src/content/geomap_view.tsx
+++ b/packages/share-theme/src/content/geomap_view.tsx
@@ -1,6 +1,8 @@
import "./geomap_view.css";
+import appContext from "@triliumnext/client/src/components/app_context.js";
import Component from "@triliumnext/client/src/components/component.js";
+import TabManager from "@triliumnext/client/src/components/tab_manager.js";
import froca from "@triliumnext/client/src/services/froca.js";
import options, { type OptionValue } from "@triliumnext/client/src/services/options.js";
import GeoView from "@triliumnext/client/src/widgets/collections/geomap/index.js";
@@ -43,7 +45,7 @@ export default function mountGeoMap(container: HTMLElement, payload: GeoMapPaylo
}
render(
- <ParentComponent.Provider value={new Component()}>
+ <ParentComponent.Provider value={startAppContext()}>
<GeoView
note={note}
notePath={noteId}
@@ -58,3 +60,19 @@ export default function mountGeoMap(container: HTMLElement, payload: GeoMapPaylo
container
);
}
+
+/**
+ * Gives `appContext` the part of `start()` that the view relies on, a `TabManager` for the note
+ * contexts its panes register, and returns a component under it for the view to mount below.
+ * The app's layout, commands and shortcuts are left out.
+ */
+function startAppContext() {
+ if (!appContext.tabManager) {
+ appContext.tabManager = new TabManager();
+ appContext.child(appContext.tabManager);
+ }
+
+ const component = new Component();
+ appContext.child(component);
+ return component;
+}