Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(views/geo): set default theme
Elian Doran60e7b9ffb047
diff --git a/apps/client/src/widgets/ribbon_widgets/book_properties.ts b/apps/client/src/widgets/ribbon_widgets/book_properties.tsindex c93267715d..a81153a489 100644--- a/apps/client/src/widgets/ribbon_widgets/book_properties.ts+++ b/apps/client/src/widgets/ribbon_widgets/book_properties.ts@@ -207,12 +207,13 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget {const $select = $("<select>", {class: "form-select form-select-sm"});+ const actualValue = note.getLabelValue(property.bindToLabel) ?? property.defaultValue;for (const option of property.options) {const $option = $("<option>", {value: option.value,text: option.label});- if (note.getLabelValue(property.bindToLabel) === option.value) {+ if (actualValue === option.value) {$option.prop("selected", true);}$select.append($option);diff --git a/apps/client/src/widgets/ribbon_widgets/book_properties_config.ts b/apps/client/src/widgets/ribbon_widgets/book_properties_config.tsindex e4a08a1286..1daed6a241 100644--- a/apps/client/src/widgets/ribbon_widgets/book_properties_config.ts+++ b/apps/client/src/widgets/ribbon_widgets/book_properties_config.ts@@ -3,7 +3,7 @@ import FNote from "../../entities/fnote";import attributes from "../../services/attributes";import { ViewTypeOptions } from "../../services/note_list_renderer"import NoteContextAwareWidget from "../note_context_aware_widget";-import { MAP_LAYERS } from "../view_widgets/geo_view/map_layer";+import { DEFAULT_MAP_LAYER_NAME, MAP_LAYERS } from "../view_widgets/geo_view/map_layer";interface BookConfig {properties: BookProperty[];@@ -35,6 +35,10 @@ interface ComboBoxProperty {type: "combobox",label: string;bindToLabel: string;+ /**+ * The default value is used when the label is not set.+ */+ defaultValue?: string;options: { value: string; label: string }[];}@@ -103,6 +107,7 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {label: t("book_properties_config.map-style"),type: "combobox",bindToLabel: "mapStyle",+ defaultValue: DEFAULT_MAP_LAYER_NAME,options: Object.entries(MAP_LAYERS).map(([id, layer]) => ({value: id,label: layer.namediff --git a/apps/client/src/widgets/view_widgets/geo_view/index.ts b/apps/client/src/widgets/view_widgets/geo_view/index.tsindex 09b0ca0bf7..166c3ec17b 100644--- a/apps/client/src/widgets/view_widgets/geo_view/index.ts+++ b/apps/client/src/widgets/view_widgets/geo_view/index.ts@@ -11,7 +11,7 @@ import { CommandListenerData, EventData } from "../../../components/app_context.import { createNewNote, moveMarker, setupDragging } from "./editing.js";import { openMapContextMenu } from "./context_menu.js";import attributes from "../../../services/attributes.js";-import { MAP_LAYERS } from "./map_layer.js";+import { DEFAULT_MAP_LAYER_NAME, MAP_LAYERS } from "./map_layer.js";const TPL = /*html*/`<div class="geo-view">@@ -146,9 +146,9 @@ export default class GeoView extends ViewMode<MapData> {worldCopyJump: true});- const layerName = this.parentNote.getLabelValue("mapStyle") ?? "openstreetmap";+ const layerName = this.parentNote.getLabelValue("mapStyle") ?? DEFAULT_MAP_LAYER_NAME;let layer: Layer;- const layerData = MAP_LAYERS[layerName] ?? MAP_LAYERS["openstreetmap"];+ const layerData = MAP_LAYERS[layerName];if (layerData.type === "vector") {const style = (typeof layerData.style === "string" ? layerData.style : await layerData.style());diff --git a/apps/client/src/widgets/view_widgets/geo_view/map_layer.ts b/apps/client/src/widgets/view_widgets/geo_view/map_layer.tsindex 43a7c0db41..163dadc554 100644--- a/apps/client/src/widgets/view_widgets/geo_view/map_layer.ts+++ b/apps/client/src/widgets/view_widgets/geo_view/map_layer.ts@@ -50,3 +50,4 @@ export const MAP_LAYERS: Record<string, VectorLayer | RasterLayer> = {}};+export const DEFAULT_MAP_LAYER_NAME: keyof typeof MAP_LAYERS = "versatiles-colorful";