diff --git a/AGENTS.md b/AGENTS.md index 54ddca98..1746549c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -286,7 +286,7 @@ frontend/ │ │ VersionRender │ ├── layouts/ IconButton, Dropdown, Tabs, ColorPicker (reusable UI atoms) │ └── viewer/ TopBar, statusbar/{StatusBar,FetchStatus}, topbar/{TopSearchBar,SearchResult}, - │ content/{Content,NoteContainer,Note}, widgets/{TableWidget,TestWidget, + │ content/{Content,NoteContainer,Note}, map/MapViewerPane, widgets/{TableWidget,TestWidget, │ inline/RollWidgetInline,display/RollWidgetDisplay} ├── composables/ useTheme.ts (theme+accent singletons, localStorage, data-* attrs), │ useEmitter.ts (BROKEN, see §9) @@ -300,7 +300,10 @@ There is no `app/pages/`. `app/app.vue` renders a fixed shell of managers. "Scre - **Windows** — floating, draggable/resizable overlays (login, main menu, settings…), or - **Content** — the campaign workspace (`TopBar` + `ContentSidebar` + note column + `StatusBar`), - shown when `Campaign` state is non-null. + shown when `Campaign` state is non-null. The note column shows the open notes, or the map anchored + on it (`AnchorMap` / `ActivePane` in `services/Content.js`); the sidebar's notes and maps buttons + switch between the two while both keep their state, and `viewer/map/MapViewerPane.vue` renders the + map there and inside the `map_viewer` window (a detached anchored map). Boot sequence (`app.vue` → `start()`): @@ -363,7 +366,7 @@ Plain modules with module-scope `ref()`s imported directly. No DI, no Pinia. Sin | `Server.js` | axios instance (fallback baseURL `http://localhost:5000/api`), `initApi(baseURL)` called by `plugins/api.ts`, request interceptor adding `Authorization: Bearer `, `getBaseUrl()`. Default export is a factory: call `Server()` then `.get/.post`. | | `User.js` | `UserStatus` ref, `GetUser()` (decodes JWT, auto-logout on `exp`), `SetUser(token)`, `LoadUser`, `LogoutUser`, `IsAdmin`, `HasAdmin()`, `GetUserSetting(key)` / `SetUserSetting(key,value)` (server-backed, in `User.settings`) | | `Campaign.js` | `useCampaignService()` → `Campaign` (`useState('campaign')`), `SetCampaign(data)` (also writes `localStorage.selectedCampaignId`), `RestoreCampaign()` | -| `Content.js` | `ShowContent` ref (drives the campaign workspace). `SetShowContent` is exported but unused — `ContentManager.vue` sets it from a `watch(Campaign)` and never turns it back off | +| `Content.js` | `ShowContent` ref (drives the campaign workspace: `ContentManager.vue` turns it on from a `watch(Campaign)`, `TopBar` off when leaving a campaign) and the anchored map: `ActivePane` (`'notes'`\|`'map'`), `AnchoredMap`, `SetActivePane`, `AnchorMap`, `ClearAnchoredMap` | | `Emitter.js` | `export const emitter = mitt()` — the app-wide event bus | | `Toaster.js` | `DisplayToast(color, text, duration)` → emits `toast`; `ToastManager.vue` renders it | | `Tooltip.js` | `SetupTooltip()`, `AddTooltip(el, text, {max_width})` (stores on `el._dr_tooltip`), polled visibility via `elementsFromPoint` | diff --git a/frontend/app/components/partials/ContentSidebar.vue b/frontend/app/components/partials/ContentSidebar.vue index f163f7fe..281ce0b9 100644 --- a/frontend/app/components/partials/ContentSidebar.vue +++ b/frontend/app/components/partials/ContentSidebar.vue @@ -3,6 +3,7 @@ import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue' import { useI18n } from 'vue-i18n'; import { useCampaignService } from '~/services/Campaign.js'; +import { AnchorMap, AnchoredMap, ClearAnchoredMap, SetActivePane } from '~/services/Content.js'; import { emitter } from '~/services/Emitter'; import Server from '~/services/Server'; import { ClearWindow, CreateWindow, GetFirstWindowId } from '~/services/Windows'; @@ -207,6 +208,9 @@ async function fetchCampaignEntries(entityType = activeSection.value, silent = f function selectSection(section) { activeSection.value = section; if (isEntrySection(section)) fetchCampaignEntries(section); + // The content area follows the sidebar: maps shows the anchored map, everything else the + // notes that are currently open. + SetActivePane(section === 'maps' && AnchoredMap.value ? 'map' : 'notes'); } function createEntry(entityType) { @@ -272,6 +276,7 @@ function showEntryMenu(entry, entityType) { const response = await Server().post(`/${entityType}/delete`, { id: entry._id }); if (response.data.status === 'ok' && list) { list.value = list.value.filter((current) => current._id !== entry._id); + if (entityType === 'map' && isAnchoredMap(entry)) ClearAnchoredMap(); } } catch (error) {} finally { HideContextMenu(); } } @@ -294,13 +299,17 @@ async function openCharacterSheet(actor) { CreateWindow('character_sheet', { actor }); } -async function openMapViewer(map) { - const existingWindowId = GetFirstWindowId('map_viewer'); - if (existingWindowId !== undefined) { - ClearWindow({ id: existingWindowId }); - await nextTick(); - } - CreateWindow('map_viewer', { map, campaign: campaignId.value }); +// Maps are anchored on the note container instead of opening a window: the notes that were open +// stay open, and the sidebar's notes/maps buttons switch between the two. +function openMapViewer(map) { + if (!map) return; + const floatingViewer = GetFirstWindowId('map_viewer'); + if (floatingViewer !== undefined) ClearWindow({ id: floatingViewer }); + AnchorMap(map); +} + +function isAnchoredMap(map) { + return AnchoredMap.value?._id === map._id; } function createNote() { @@ -324,6 +333,7 @@ watch(campaignId, (newVal) => { actors.value = []; items.value = []; maps.value = []; + ClearAnchoredMap(); fetchCampaignNotes(); if (isEntrySection(activeSection.value)) fetchCampaignEntries(activeSection.value); } else { @@ -334,6 +344,7 @@ watch(campaignId, (newVal) => { maps.value = []; notesError.value = ''; entriesError.value = ''; + ClearAnchoredMap(); } }); @@ -502,8 +513,11 @@ onBeforeUnmount(() => { -
- {{ map.name }} +
+ + {{ map.name }} + {{ t('campaigns.map.anchored') }} + {{ t('campaigns.map.no-image') }}
@@ -654,6 +668,8 @@ onBeforeUnmount(() => { } .entity-entry:hover { border-color: var(--color-border); background: var(--color-background-soft); } .entity-entry:focus-visible { outline: 1px solid var(--color-link); } +/* The map currently anchored on the note container. */ +.entity-entry.anchored { border-color: var(--color-link); background: var(--color-background-soft); } .entity-entry-name-row { display: flex; align-items: baseline; gap: 6px; } .entity-entry-name { font-weight: bold; } .entity-entry-sync { diff --git a/frontend/app/components/viewer/content/Content.vue b/frontend/app/components/viewer/content/Content.vue index 1de52c96..6e201d89 100644 --- a/frontend/app/components/viewer/content/Content.vue +++ b/frontend/app/components/viewer/content/Content.vue @@ -1,13 +1,30 @@ @@ -21,4 +38,14 @@ import NoteContainer from './NoteContainer.vue'; align-items: center; } - \ No newline at end of file +/* Hidden with v-show so the open notes stay mounted while the anchored map is displayed. */ +.anchored-map { + width: 100%; + height: 100%; + min-width: 0; + flex-grow: 1; + display: flex; + flex-direction: column; +} + + diff --git a/frontend/app/components/viewer/content/NoteContainer.vue b/frontend/app/components/viewer/content/NoteContainer.vue index 9ce4cb5e..dfdc261f 100644 --- a/frontend/app/components/viewer/content/NoteContainer.vue +++ b/frontend/app/components/viewer/content/NoteContainer.vue @@ -2,6 +2,7 @@ import { onMounted, onUnmounted, ref } from 'vue'; import Note from './Note.vue'; import { emitter } from '~/services/Emitter'; +import { SetActivePane } from '~/services/Content.js'; let noteData = ref([]); @@ -34,6 +35,9 @@ function pushNote(note){ } function handlePushNote(note) { + // A note opened from the sidebar or the search palette always comes to the front, even when + // the content area is showing an anchored map. + SetActivePane('notes'); pushNote(note); } diff --git a/frontend/app/components/viewer/map/MapViewerPane.vue b/frontend/app/components/viewer/map/MapViewerPane.vue new file mode 100644 index 00000000..f18cea8c --- /dev/null +++ b/frontend/app/components/viewer/map/MapViewerPane.vue @@ -0,0 +1,233 @@ + + + + + diff --git a/frontend/app/components/windows/CreateMapWindow.vue b/frontend/app/components/windows/CreateMapWindow.vue index e847096b..0f9002c2 100644 --- a/frontend/app/components/windows/CreateMapWindow.vue +++ b/frontend/app/components/windows/CreateMapWindow.vue @@ -129,7 +129,8 @@ async function saveMap() {