More things
This commit is contained in:
@@ -18,6 +18,7 @@ import NestedNoteList from './NestedNoteList.vue';
|
||||
const { Campaign } = useCampaignService();
|
||||
const { t } = useI18n();
|
||||
const notes = ref([]);
|
||||
const media = ref([]);
|
||||
const folders = ref([]);
|
||||
const actors = ref([]);
|
||||
const items = ref([]);
|
||||
@@ -40,14 +41,16 @@ const activeSection = ref('notes');
|
||||
const isDragOverSidebar = ref(false);
|
||||
const expandedFolderIds = ref([]);
|
||||
const nestedNoteListRef = ref(null);
|
||||
const mediaInput = ref(null);
|
||||
let entryRefreshInterval;
|
||||
|
||||
async function handleSidebarDrop(event) {
|
||||
if (activeSection.value !== 'notes') return;
|
||||
const noteKey = event.dataTransfer.getData('text/plain');
|
||||
if (!noteKey) return;
|
||||
const row = event.dataTransfer.getData('text/plain');
|
||||
if (!row) return;
|
||||
const mediaId = row.startsWith('media:') ? row.slice(6) : null;
|
||||
try {
|
||||
await Server().post('/note/update', { id: noteKey, folder: null });
|
||||
await Server().post(mediaId ? '/media/update' : '/note/update', { id: mediaId ?? row, folder: null });
|
||||
if (nestedNoteListRef.value) {
|
||||
nestedNoteListRef.value.clearCacheAndReloadExpanded();
|
||||
} else {
|
||||
@@ -118,6 +121,11 @@ function handleNoteDeleted(noteKey) {
|
||||
notes.value = notes.value.filter(n => n.key !== noteKey);
|
||||
}
|
||||
|
||||
// A media row deleted from the tree anywhere under the sidebar.
|
||||
function handleMediaDeleted(mediaId) {
|
||||
media.value = media.value.filter((item) => item._id !== mediaId);
|
||||
}
|
||||
|
||||
function sectionForTarget(target) {
|
||||
if (target === 'actor') return 'actors';
|
||||
if (target === 'item') return 'items';
|
||||
@@ -167,6 +175,7 @@ const campaignId = computed(() => {
|
||||
async function fetchCampaignNotes() {
|
||||
if (!campaignId.value) {
|
||||
notes.value = [];
|
||||
media.value = [];
|
||||
folders.value = [];
|
||||
notesError.value = '';
|
||||
return;
|
||||
@@ -180,6 +189,7 @@ async function fetchCampaignNotes() {
|
||||
|
||||
if (response.data.status !== 'ok') {
|
||||
notes.value = [];
|
||||
media.value = [];
|
||||
folders.value = [];
|
||||
notesError.value = response.data.msg ?? 'Unable to load notes.';
|
||||
return;
|
||||
@@ -192,8 +202,10 @@ async function fetchCampaignNotes() {
|
||||
notes.value = response.data.notes.map((note) => {
|
||||
return { key: note._id, title: note.title, text: note.content ?? '', date: note.date, color: note.color };
|
||||
});
|
||||
media.value = response.data.media ?? [];
|
||||
} catch (error) {
|
||||
notes.value = [];
|
||||
media.value = [];
|
||||
folders.value = [];
|
||||
notesError.value = 'Unable to load notes.';
|
||||
} finally {
|
||||
@@ -503,6 +515,34 @@ function createNote() {
|
||||
CreateWindow('new_note', { campaign: campaignId.value });
|
||||
}
|
||||
|
||||
function chooseMedia() {
|
||||
mediaInput.value?.click();
|
||||
}
|
||||
|
||||
// The picked files are uploaded to the root of the note tree, one request per file, and their
|
||||
// rows join the list as each lands.
|
||||
async function uploadMedia(event) {
|
||||
const files = Array.from(event.target.files ?? []);
|
||||
event.target.value = '';
|
||||
if (!campaignId.value) return;
|
||||
|
||||
for (const file of files) {
|
||||
const body = new FormData();
|
||||
body.append('file', file);
|
||||
body.append('campaign', campaignId.value);
|
||||
try {
|
||||
const response = await Server().post('/media/upload', body);
|
||||
if (response.data.status !== 'ok') {
|
||||
DisplayToast('red', t(response.data.msg || 'campaigns.media.upload-error'), 3000);
|
||||
continue;
|
||||
}
|
||||
media.value = [response.data.media, ...media.value];
|
||||
} catch (error) {
|
||||
DisplayToast('red', t('campaigns.media.upload-error'), 3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSidebar() {
|
||||
sidebarCollapsed.value = !sidebarCollapsed.value;
|
||||
}
|
||||
@@ -536,6 +576,7 @@ watch(campaignId, (newVal) => {
|
||||
actors.value = [];
|
||||
items.value = [];
|
||||
maps.value = [];
|
||||
media.value = [];
|
||||
for (const sectionFolders of Object.values(entryFolders)) sectionFolders.value = [];
|
||||
collapsedFolderIds.value = [];
|
||||
ClearAnchoredMap();
|
||||
@@ -543,6 +584,7 @@ watch(campaignId, (newVal) => {
|
||||
if (isEntrySection(activeSection.value)) fetchCampaignEntries(activeSection.value);
|
||||
} else {
|
||||
notes.value = [];
|
||||
media.value = [];
|
||||
folders.value = [];
|
||||
actors.value = [];
|
||||
items.value = [];
|
||||
@@ -559,6 +601,7 @@ onMounted(() => {
|
||||
emitter.on('note-created', handleNoteCreated);
|
||||
emitter.on('note-renamed', handleNoteRenamed);
|
||||
emitter.on('delete-note', handleNoteDeleted);
|
||||
emitter.on('media-deleted', handleMediaDeleted);
|
||||
emitter.on('folder-saved', handleFolderSaved);
|
||||
emitter.on('folder-deleted', handleFolderDeleted);
|
||||
emitter.on('campaign-entry-created', handleCampaignEntryCreated);
|
||||
@@ -580,6 +623,7 @@ onBeforeUnmount(() => {
|
||||
emitter.off('note-created', handleNoteCreated);
|
||||
emitter.off('note-renamed', handleNoteRenamed);
|
||||
emitter.off('delete-note', handleNoteDeleted);
|
||||
emitter.off('media-deleted', handleMediaDeleted);
|
||||
emitter.off('folder-saved', handleFolderSaved);
|
||||
emitter.off('folder-deleted', handleFolderDeleted);
|
||||
emitter.off('campaign-entry-created', handleCampaignEntryCreated);
|
||||
@@ -659,6 +703,10 @@ onBeforeUnmount(() => {
|
||||
<button class="sidebar-action" type="button" @click="createNote" :disabled="!Campaign" :title="t('campaigns.actions.new-note')" :aria-label="t('campaigns.actions.new-note')">
|
||||
<img class="sidebar-action-icon" src="/icons/iconoir/regular/plus.svg" alt="" aria-hidden="true">
|
||||
</button>
|
||||
<button class="sidebar-action" type="button" @click="chooseMedia" :disabled="!Campaign" :title="t('campaigns.media.upload')" :aria-label="t('campaigns.media.upload')">
|
||||
<img class="sidebar-action-icon" src="/icons/iconoir/regular/media-image-plus.svg" alt="" aria-hidden="true">
|
||||
</button>
|
||||
<input ref="mediaInput" class="media-input" type="file" multiple @change="uploadMedia">
|
||||
<button class="sidebar-action" type="button" @click="createFolder()" :disabled="!Campaign" :title="t('campaigns.actions.new-folder')" :aria-label="t('campaigns.actions.new-folder')">
|
||||
<img class="sidebar-action-icon" src="/icons/iconoir/regular/folder.svg" alt="" aria-hidden="true">
|
||||
</button>
|
||||
@@ -684,9 +732,9 @@ onBeforeUnmount(() => {
|
||||
<template v-if="activeSection === 'notes'">
|
||||
<div v-if="loadingNotes" class="sidebar-state">{{ t('campaigns.states.loading-notes') }}</div>
|
||||
<div v-else-if="notesError" class="sidebar-state error">{{ notesError }}</div>
|
||||
<div v-else-if="folders.length === 0 && notes.length === 0" class="sidebar-state">{{ t('campaigns.states.empty-notes') }}</div>
|
||||
<div v-else-if="folders.length === 0 && notes.length === 0 && media.length === 0" class="sidebar-state">{{ t('campaigns.states.empty-notes') }}</div>
|
||||
<NestedNoteList v-else ref="nestedNoteListRef"
|
||||
:parent-folder-id="null" :folders="folders" :notes="rootNotes" :campaign-id="campaignId"
|
||||
:parent-folder-id="null" :folders="folders" :notes="rootNotes" :media="media" :campaign-id="campaignId"
|
||||
:expanded-folder-ids="expandedFolderIds" @open-note="openNote"
|
||||
@reload-notes="fetchCampaignNotes" @toggle-expanded-folder="toggleExpandedFolder" />
|
||||
</template>
|
||||
@@ -706,7 +754,10 @@ onBeforeUnmount(() => {
|
||||
@toggle="toggleFolder(row.folder._id)"
|
||||
/>
|
||||
<div v-else class="entity-entry" :style="rowIndent(row.depth)" role="button" tabindex="0" draggable="true" :title="t('campaigns.map.tokens.drag')" @click="openCharacterSheet(row.item)" @keydown.enter="openCharacterSheet(row.item)" @keydown.space.prevent="openCharacterSheet(row.item)" @dragstart="startActorDrag($event, row.item)" @contextmenu.prevent="showEntryMenu(row.item, 'actor')">
|
||||
<span class="entity-entry-name">{{ row.item.name }}</span>
|
||||
<span class="entity-entry-title">
|
||||
<img class="entity-entry-icon" src="/icons/iconoir/regular/user.svg" alt="" aria-hidden="true">
|
||||
<span class="entity-entry-name">{{ row.item.name }}</span>
|
||||
</span>
|
||||
<span class="entity-entry-meta">{{ entrySummary(row.item) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -731,6 +782,7 @@ onBeforeUnmount(() => {
|
||||
<span v-if="row.item.image" class="entity-entry-image" aria-hidden="true">
|
||||
<img :src="itemImageUrl(row.item.image)" alt="">
|
||||
</span>
|
||||
<img v-else class="entity-entry-icon" src="/icons/iconoir/regular/box.svg" alt="" aria-hidden="true">
|
||||
<span class="entity-entry-name" :class="rarityClass(row.item)">{{ row.item.name }}</span>
|
||||
</span>
|
||||
</div>
|
||||
@@ -752,9 +804,12 @@ onBeforeUnmount(() => {
|
||||
@toggle="toggleFolder(row.folder._id)"
|
||||
/>
|
||||
<div v-else class="entity-entry" :style="rowIndent(row.depth)" :class="{ anchored: isAnchoredMap(row.item) }" role="button" tabindex="0" @click="openMapViewer(row.item)" @keydown.enter="openMapViewer(row.item)" @keydown.space.prevent="openMapViewer(row.item)" @contextmenu.prevent="showEntryMenu(row.item, 'map')">
|
||||
<span class="entity-entry-name-row">
|
||||
<span class="entity-entry-name">{{ row.item.name }}</span>
|
||||
<span v-if="isAnchoredMap(row.item)" class="entity-entry-sync">{{ t('campaigns.map.anchored') }}</span>
|
||||
<span class="entity-entry-title">
|
||||
<img class="entity-entry-icon" src="/icons/iconoir/regular/map.svg" alt="" aria-hidden="true">
|
||||
<span class="entity-entry-name-row">
|
||||
<span class="entity-entry-name">{{ row.item.name }}</span>
|
||||
<span v-if="isAnchoredMap(row.item)" class="entity-entry-sync">{{ t('campaigns.map.anchored') }}</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="entity-entry-meta">{{ mapSummary(row.item) }}</span>
|
||||
<span v-if="!row.item.image" class="entity-entry-description">{{ t('campaigns.map.no-image') }}</span>
|
||||
@@ -850,6 +905,7 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
|
||||
.sidebar-header-actions { display: flex; align-items: center; gap: 4px; }
|
||||
.media-input { display: none; }
|
||||
.sidebar-header-actions .sidebar-action { width: 30px; height: 30px; }
|
||||
.sidebar-header-actions .sidebar-action-icon { width: 16px; height: 16px; }
|
||||
|
||||
@@ -923,6 +979,8 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
.entity-entry-meta, .entity-entry-description { font-size: 12px; opacity: 0.72; }
|
||||
.entity-entry-description { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
|
||||
/* Every entry row leads with an icon of what it is: an actor, an item, a map. */
|
||||
.entity-entry-icon { width: 16px; height: 16px; flex: 0 0 16px; filter: invert(var(--color-icon-invert)); }
|
||||
/* An item row leads with the item's own icon on the left of its name, standing in for the
|
||||
"SYNCED" text it used to show (Syndria98/dragonroll#53). */
|
||||
.entity-entry-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
import { ref, onBeforeUnmount, onMounted, watch } from 'vue';
|
||||
import { emitter } from '~/services/Emitter';
|
||||
import { BuildColorMenu } from '~/services/EntryColors';
|
||||
import Server from '~/services/Server';
|
||||
import Server, { getBaseUrl } from '~/services/Server';
|
||||
import { CreateWindow } from '~/services/Windows';
|
||||
import { ShowContextMenu, HideContextMenu } from '~/services/ContextMenu';
|
||||
|
||||
const props = defineProps({
|
||||
folders: Array,
|
||||
notes: Array,
|
||||
// Media files standing beside the notes at this level of the tree.
|
||||
media: { type: Array, default: () => [] },
|
||||
campaignId: String,
|
||||
level: { type: Number, default: 0 },
|
||||
parentFolderId: String,
|
||||
@@ -44,6 +46,7 @@ onMounted(() => {
|
||||
emitter.on('note-created', handleNoteCreated);
|
||||
emitter.on('note-renamed', handleNoteRenamed);
|
||||
emitter.on('delete-note', handleNoteDeleted);
|
||||
emitter.on('media-deleted', handleMediaDeleted);
|
||||
emitter.on('folder-saved', handleFolderSaved);
|
||||
});
|
||||
|
||||
@@ -51,6 +54,7 @@ onBeforeUnmount(() => {
|
||||
emitter.off('note-created', handleNoteCreated);
|
||||
emitter.off('note-renamed', handleNoteRenamed);
|
||||
emitter.off('delete-note', handleNoteDeleted);
|
||||
emitter.off('media-deleted', handleMediaDeleted);
|
||||
emitter.off('folder-saved', handleFolderSaved);
|
||||
});
|
||||
|
||||
@@ -80,6 +84,12 @@ function handleNoteDeleted(noteKey) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleMediaDeleted(mediaId) {
|
||||
for (const entry of Object.values(folderContentCache.value)) {
|
||||
entry.media = entry.media.filter((m) => m._id !== mediaId);
|
||||
}
|
||||
}
|
||||
|
||||
function handleFolderSaved(folder) {
|
||||
const folderId = folder?._id ?? folder?.id;
|
||||
if (!folderId) return;
|
||||
@@ -98,6 +108,7 @@ function loadFolderContents(folderId) {
|
||||
if (res.data.status !== 'ok') return;
|
||||
folderContentCache.value[folderId] = {
|
||||
notes: res.data.notes.map(n => ({ key: n._id, title: n.title, text: n.content || '', color: n.color })),
|
||||
media: res.data.media || [],
|
||||
subfolders: res.data.subfolders || []
|
||||
};
|
||||
}).catch(() => {}).finally(() => {
|
||||
@@ -113,6 +124,10 @@ function getFolderSubfolders(folderId) {
|
||||
return folderContentCache.value[folderId]?.subfolders || [];
|
||||
}
|
||||
|
||||
function getFolderMedia(folderId) {
|
||||
return folderContentCache.value[folderId]?.media || [];
|
||||
}
|
||||
|
||||
// Load contents for all currently-expanded folders
|
||||
function loadExpandedFolders() {
|
||||
const idsToLoad = props.level === 0
|
||||
@@ -125,26 +140,32 @@ function loadExpandedFolders() {
|
||||
}
|
||||
}
|
||||
|
||||
// A row dragged into a folder is either a note (its key) or a media file ("media:<id>").
|
||||
async function moveDraggedRow(payload, folderId) {
|
||||
const mediaId = payload.startsWith('media:') ? payload.slice(6) : null;
|
||||
await Server().post(mediaId ? '/media/update' : '/note/update', { id: mediaId ?? payload, folder: folderId });
|
||||
}
|
||||
|
||||
async function handleDropNoteOnFolder(folderId, event) {
|
||||
const noteKey = event.dataTransfer.getData('text/plain');
|
||||
if (!noteKey || !folderId) return;
|
||||
const row = event.dataTransfer.getData('text/plain');
|
||||
if (!row || !folderId) return;
|
||||
|
||||
dragHoveredFolderId.value = null;
|
||||
|
||||
try {
|
||||
await Server().post('/note/update', { id: noteKey, folder: folderId });
|
||||
await moveDraggedRow(row, folderId);
|
||||
clearCacheAndReloadExpanded();
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function handleDropNoteOnRoot(event) {
|
||||
const noteKey = event.dataTransfer.getData('text/plain');
|
||||
if (!noteKey) return;
|
||||
const row = event.dataTransfer.getData('text/plain');
|
||||
if (!row) return;
|
||||
|
||||
dragHoveredFolderId.value = null;
|
||||
|
||||
try {
|
||||
await Server().post('/note/update', { id: noteKey, folder: null });
|
||||
await moveDraggedRow(row, null);
|
||||
clearCacheAndReloadExpanded();
|
||||
} catch (e) {}
|
||||
}
|
||||
@@ -172,6 +193,31 @@ function startDragNote(event, note) {
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
}
|
||||
|
||||
// A media row drags into a folder like a note does, under a prefixed key so the drop knows
|
||||
// which of the two lists it is moving.
|
||||
function startDragMedia(event, media) {
|
||||
event.dataTransfer.setData('text/plain', `media:${media._id}`);
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
}
|
||||
|
||||
// The icon a media row leads with, the way the sidebar tells a picture from a sound at a glance.
|
||||
function mediaIcon(media) {
|
||||
const type = media?.mimeType ?? '';
|
||||
if (type.startsWith('image/')) return '/icons/iconoir/regular/media-image.svg';
|
||||
if (type.startsWith('audio/')) return '/icons/iconoir/regular/music-note.svg';
|
||||
if (type.startsWith('video/')) return '/icons/iconoir/regular/media-video.svg';
|
||||
if (type === 'application/pdf') return '/icons/iconoir/regular/page.svg';
|
||||
return '/icons/iconoir/regular/attachment.svg';
|
||||
}
|
||||
|
||||
function mediaUrl(media) {
|
||||
return media?.file ? `${getBaseUrl()}/public/${media.file}` : '';
|
||||
}
|
||||
|
||||
function openMedia(media) {
|
||||
CreateWindow('media_viewer', { media });
|
||||
}
|
||||
|
||||
function setDragHover(id) {
|
||||
dragHoveredFolderId.value = id;
|
||||
}
|
||||
@@ -194,6 +240,18 @@ function buildNoteContextMenu(note) {
|
||||
];
|
||||
}
|
||||
|
||||
function buildMediaContextMenu(media) {
|
||||
return [
|
||||
{ name: 'Open', icon: '/icons/iconoir/regular/attachment.svg', action: () => openMedia(media) },
|
||||
{
|
||||
name: 'Move to Folder...', icon: '/icons/iconoir/regular/folder.svg',
|
||||
context: buildMediaMoveToMenu(media)
|
||||
},
|
||||
{ divider: true },
|
||||
{ name: 'Delete', icon: '/icons/iconoir/regular/trash.svg', action: () => deleteMedia(media) }
|
||||
];
|
||||
}
|
||||
|
||||
function buildFolderContextMenu(folder) {
|
||||
if (!folder || !folder._id) return [];
|
||||
return [
|
||||
@@ -262,6 +320,35 @@ async function deleteFolder(folderId) {
|
||||
HideContextMenu();
|
||||
}
|
||||
|
||||
function buildMediaMoveToMenu(media) {
|
||||
const moveItems = (props.folders || []).map(folder => ({
|
||||
name: folder.name, icon: '/icons/iconoir/regular/folder.svg', action: () => moveMediaToFolder(media, folder._id)
|
||||
}));
|
||||
|
||||
if (moveItems.length > 0) moveItems.push({ divider: true });
|
||||
|
||||
moveItems.push({ name: '(Root)', icon: '/icons/iconoir/regular/attachment.svg', action: () => moveMediaToFolder(media, null) });
|
||||
return moveItems;
|
||||
}
|
||||
|
||||
async function moveMediaToFolder(media, folderId) {
|
||||
try {
|
||||
const response = await Server().post('/media/update', { id: media._id, folder: folderId || null });
|
||||
if (response.data.status !== 'ok') return;
|
||||
clearCacheAndReloadExpanded();
|
||||
} catch (e) {}
|
||||
HideContextMenu();
|
||||
}
|
||||
|
||||
async function deleteMedia(media) {
|
||||
try {
|
||||
const response = await Server().post('/media/delete', { id: media._id });
|
||||
if (response.data.status === 'ok') emitter.emit('media-deleted', media._id);
|
||||
} catch (error) {} finally {
|
||||
HideContextMenu();
|
||||
}
|
||||
}
|
||||
|
||||
async function moveNoteToFolder(note, folderId) {
|
||||
try {
|
||||
const response = await Server().post('/note/update', { id: note.key, folder: folderId || null });
|
||||
@@ -308,6 +395,7 @@ function createNoteInFolder(folderId) {
|
||||
v-if="expandedFolderIds.includes(folder._id)"
|
||||
:folders="getFolderSubfolders(folder._id)"
|
||||
:notes="getFolderNotes(folder._id)"
|
||||
:media="getFolderMedia(folder._id)"
|
||||
:campaign-id="campaignId"
|
||||
:level="level + 1"
|
||||
:parent-folder-id="folder._id"
|
||||
@@ -323,15 +411,24 @@ function createNoteInFolder(folderId) {
|
||||
<!-- Notes at this level -->
|
||||
<template v-for="note in notes" :key="note.key">
|
||||
<button type="button" class="note-link" :class="{ 'has-color': !!note.color }" :style="entryColorStyle(note)" draggable="true" @dragstart="startDragNote($event, note)" @click.stop="$emit('open-note', note)" @contextmenu.prevent="ShowContextMenu(buildNoteContextMenu(note))">
|
||||
<img class="note-link-icon" src="/icons/iconoir/regular/journal-page.svg" alt="" aria-hidden="true">
|
||||
<span class="note-link-title">{{ note.title }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<!-- Media files at this level, VSCode-explorer style: the type's icon, then the file name -->
|
||||
<template v-for="item in media" :key="item._id">
|
||||
<button type="button" class="note-link media-link" draggable="true" :title="item.name" @dragstart="startDragMedia($event, item)" @click.stop="openMedia(item)" @contextmenu.prevent="ShowContextMenu(buildMediaContextMenu(item))">
|
||||
<img class="media-link-icon" :src="mediaIcon(item)" alt="" aria-hidden="true">
|
||||
<span class="media-link-name">{{ item.name }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<!-- Drop zone for root-level notes -->
|
||||
<div v-if="level === 0" class="root-drop-zone" :class="{ 'drag-over': dragHoveredFolderId === 'root' }" @drop.stop="handleDropNoteOnRoot($event)">
|
||||
</div>
|
||||
|
||||
<div v-if="folders.length === 0 && (!notes || notes.length === 0) && level === 0" class="sidebar-state">Empty</div>
|
||||
<div v-if="folders.length === 0 && (!notes || notes.length === 0) && (!media || media.length === 0) && level === 0" class="sidebar-state">Empty</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -353,10 +450,17 @@ function createNoteInFolder(folderId) {
|
||||
.folder-children { padding-left: 20px; margin-top: 2px; cursor: default; }
|
||||
.folder-children.drag-over { background: #ffffff22; border-radius: 10px; }
|
||||
|
||||
.note-link { width: 100%; padding: 6px; margin: 0; box-shadow: none; border: none; display: flex; flex-direction: column; align-items: flex-start; text-align: left; cursor: grab; border-radius: 8px; }
|
||||
.note-link { width: 100%; padding: 6px; margin: 0; box-shadow: none; border: none; display: flex; flex-direction: row; align-items: center; gap: 8px; text-align: left; cursor: grab; border-radius: 8px; }
|
||||
.note-link.has-color { background: color-mix(in srgb, var(--entry-color) 32%, transparent); }
|
||||
.note-link.has-color:hover { background: color-mix(in srgb, var(--entry-color) 50%, transparent); }
|
||||
.note-link-title { font-weight: 600; word-break: break-word; }
|
||||
/* Every note row leads with the page icon, like a media row with the icon of its type. */
|
||||
.note-link-icon { width: 15px; height: 15px; flex: 0 0 15px; filter: invert(var(--color-icon-invert)); }
|
||||
.note-link-title { flex: 1; min-width: 0; font-weight: 600; word-break: break-word; }
|
||||
|
||||
/* Media rows share the note row's box, with the file type's icon where a note has none. */
|
||||
.media-link { flex-direction: row; align-items: center; gap: 8px; }
|
||||
.media-link-icon { width: 15px; height: 15px; flex: 0 0 15px; filter: invert(var(--color-icon-invert)); }
|
||||
.media-link-name { min-width: 0; font-weight: 500; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
||||
.sidebar-state { padding: 12px; border-radius: 10px; background: var(--color-background-soft); font-size: 14px; }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow } from '@/services/Windows';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow, Top } from '@/services/Windows';
|
||||
import WindowHandle from './partials/WindowHandle.vue';
|
||||
import Server from '~/services/Server';
|
||||
import { emitter } from '~/services/Emitter';
|
||||
@@ -34,6 +34,7 @@ function initialForm() {
|
||||
const form = ref(initialForm());
|
||||
|
||||
onMounted(() => {
|
||||
Top(wrapper);
|
||||
SetupHandle(id, handle);
|
||||
SetSize(id, isActor ? { width: 420, height: 220 } : { width: 500, height: 560 });
|
||||
ResetPosition(id, 'center');
|
||||
@@ -71,7 +72,6 @@ async function saveEntry() {
|
||||
<WindowHandle :window="id" ref="handle" />
|
||||
<div class="body">
|
||||
<h3>{{ $t(editing ? 'campaigns.item.edit' : (isActor ? 'campaigns.actor.new' : 'campaigns.item.new')) }}</h3>
|
||||
<p v-if="!isActor && editing?.foundryItemId" class="sync-note">{{ $t('campaigns.item.foundry-sync-note') }}</p>
|
||||
<form @submit.prevent="saveEntry">
|
||||
<label class="form-field">
|
||||
<span>{{ $t('campaigns.fields.name') }}</span>
|
||||
@@ -134,7 +134,6 @@ async function saveEntry() {
|
||||
.window-wrapper { display: flex; align-items: center; flex-direction: column; }
|
||||
.body { width: 100%; padding: 10px 18px 16px; overflow-y: auto; }
|
||||
h3 { margin: 0 0 12px; font-family: MrEavesRemake; }
|
||||
.sync-note { margin: -8px 0 12px; font-size: 12px; opacity: 0.72; }
|
||||
form { display: flex; flex-direction: column; gap: 10px; }
|
||||
.form-field { min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
|
||||
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
||||
|
||||
57
frontend/app/components/windows/MediaViewerWindow.vue
Normal file
57
frontend/app/components/windows/MediaViewerWindow.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { SetupHandle, SetSize, ResetPosition, Top } from '@/services/Windows';
|
||||
import { getBaseUrl } from '~/services/Server';
|
||||
import WindowHandle from './partials/WindowHandle.vue';
|
||||
|
||||
// One media file of the note tree, shown in a window of its own: an image fills it, a sound and a
|
||||
// video play in it, and anything else (a PDF, a document) is offered as a link to open.
|
||||
const props = defineProps(['data']);
|
||||
const id = props.data.id;
|
||||
const media = props.data.media;
|
||||
const handle = ref(null);
|
||||
const wrapper = ref(null);
|
||||
|
||||
const url = computed(() => media?.file ? `${getBaseUrl()}/public/${media.file}` : '');
|
||||
const kind = computed(() => {
|
||||
const type = media?.mimeType ?? '';
|
||||
if (type.startsWith('image/')) return 'image';
|
||||
if (type.startsWith('audio/')) return 'audio';
|
||||
if (type.startsWith('video/')) return 'video';
|
||||
return 'file';
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
Top(wrapper);
|
||||
SetupHandle(id, handle);
|
||||
SetSize(id, {
|
||||
width: Math.max(420, Math.min(900, window.innerWidth - 24)),
|
||||
height: Math.max(320, Math.min(700, window.innerHeight - 32))
|
||||
});
|
||||
ResetPosition(id, 'center');
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="window-wrapper media-window" :id="'window-wrapper-' + id" ref="wrapper">
|
||||
<WindowHandle :window="id" ref="handle" />
|
||||
|
||||
<div class="media-body">
|
||||
<img v-if="kind === 'image'" class="media-image" :src="url" :alt="media?.name">
|
||||
<audio v-else-if="kind === 'audio'" :src="url" controls></audio>
|
||||
<video v-else-if="kind === 'video'" :src="url" controls></video>
|
||||
<a v-else class="media-file" :href="url" target="_blank" rel="noopener">{{ media?.name }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.media-window { min-width: 320px; min-height: 0; }
|
||||
.media-body {
|
||||
flex: 1; min-height: 0; box-sizing: border-box; padding: 10px;
|
||||
display: flex; align-items: center; justify-content: center; overflow: auto;
|
||||
}
|
||||
.media-image { max-width: 100%; max-height: 100%; object-fit: contain; }
|
||||
audio, video { max-width: 100%; }
|
||||
.media-file { color: var(--color-link); word-break: break-word; }
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow } from '@/services/Windows';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow, Top } from '@/services/Windows';
|
||||
import WindowHandle from './partials/WindowHandle.vue';
|
||||
import Server from '~/services/Server';
|
||||
import { emitter } from '~/services/Emitter';
|
||||
@@ -18,6 +18,7 @@ const creating = !!data.name;
|
||||
|
||||
onMounted(() => {
|
||||
newName.value = data.name || '';
|
||||
Top(wrapper);
|
||||
SetupHandle(id, handle);
|
||||
SetSize(id, { width: 420, height: 200 });
|
||||
ResetPosition(id, 'center');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow } from '@/services/Windows';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow, Top } from '@/services/Windows';
|
||||
import WindowHandle from './partials/WindowHandle.vue';
|
||||
import Server from '~/services/Server';
|
||||
import { emitter } from '~/services/Emitter';
|
||||
@@ -17,6 +17,7 @@ const newName = ref('');
|
||||
|
||||
onMounted(() => {
|
||||
newName.value = data.title || '';
|
||||
Top(wrapper);
|
||||
SetupHandle(id, handle);
|
||||
SetSize(id, { width: 420, height: 200 });
|
||||
ResetPosition(id, 'center');
|
||||
|
||||
@@ -28,6 +28,14 @@ what matters.
|
||||
Deleting a folder does not delete your notes: the notes it held move up to its parent folder, its
|
||||
sub-folders move up with them, and only the empty folders go away.
|
||||
|
||||
## Images and media
|
||||
|
||||
The notes sidebar lists media files as well as notes. Upload them with the picture button in the
|
||||
notes header: images, sounds, videos and PDFs all work, and each row leads with an icon of its type,
|
||||
the way a file explorer does. Clicking a row opens the file in a window of its own, and a media row
|
||||
moves into a folder like a note — drag it there, or use **Move to Folder…** in its right-click menu.
|
||||
Right-clicking a media row also deletes it, file included.
|
||||
|
||||
## Markdown
|
||||
|
||||
Headings, **bold**, *italic*, lists, quotes, tables, code and links all work:
|
||||
@@ -102,10 +110,6 @@ Either way the widget shows the expression as a button: press it and the dice la
|
||||
the total spelled out. Press it again to roll again. Only the expression itself goes between `@roll`
|
||||
and `@end` — write the note about the roll next to the widget, not inside it.
|
||||
|
||||
When the note reaches a linked [Foundry world](/docs/foundry), its dice widgets are buttons on the
|
||||
journal page too: pressing one rolls the expression with Foundry's dice and posts the result to chat,
|
||||
where the whole table sees it.
|
||||
|
||||
The expression understands:
|
||||
|
||||
| Written | Meaning |
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Characters and items
|
||||
|
||||
The **Actors & Characters** and **Items** sections of the sidebar hold the people and things of a
|
||||
campaign as entries of their own, with a sheet each. They can be written by hand, and they are also
|
||||
what a linked [Foundry VTT](/docs/foundry) world keeps itself in step with.
|
||||
campaign as entries of their own, with a sheet each. They can be written by hand, and the actors and
|
||||
items of a linked [Foundry VTT](/docs/foundry) world are sent into them.
|
||||
|
||||
## Actors
|
||||
|
||||
|
||||
@@ -49,18 +49,3 @@ the actor it stands for, and **Enter** does the same on a token focused with the
|
||||
|
||||
Tokens belong to the map, not to the actor: the same character can stand on several maps, and taking a
|
||||
token off does not remove the character from the campaign.
|
||||
|
||||
## Maps from a linked Foundry world
|
||||
|
||||
With a Foundry world linked to the campaign, its scenes arrive as maps of their own: each one with the
|
||||
scene's background picture and the grid laid over it, in the scene's own cell size and where the world
|
||||
shifts that grid onto the picture. That is all a scene lends a map — what one of your cells stands
|
||||
for, the folder a map stands in, and whatever you pin or stand on it stay yours, and nothing about a
|
||||
map goes back to the world.
|
||||
|
||||
A scene renamed in Foundry, or its grid moved, updates its map. Take the background picture off a
|
||||
scene and its map keeps the one it has; delete the scene and its map goes with it the next time the
|
||||
world sends its whole scene list, which is when the world loads. For the same reason a map you delete
|
||||
in the campaign comes back on the next world load while its scene is still there — take the scene off
|
||||
in Foundry to be rid of the map. A map you made yourself is never doubled by the scene of it: a scene
|
||||
arriving with the name of an unmapped map adopts that one. See [Foundry VTT](/docs/foundry).
|
||||
|
||||
@@ -27,8 +27,7 @@ What a service may do is decided by the campaign you pick, so check the name bef
|
||||
screen tells you which service is asking, and what it wants:
|
||||
|
||||
- a **Discord server** reads the campaign's characters, so whoever is in that server can read them,
|
||||
- a **Foundry world** keeps its actors and items in step with the campaign, which means it writes into
|
||||
it, and Dragonroll writes into it,
|
||||
- a **Foundry world** sends its actors and items into the campaign,
|
||||
- **Obsidian** reads the campaign's notes and pushes the ones you tell it to.
|
||||
|
||||
A campaign holds one link per service: linking a second Foundry world, or a second Discord server,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Foundry VTT
|
||||
|
||||
The Foundry integration keeps a Dragonroll campaign and a Foundry world in step: the world's
|
||||
characters, item directory and scenes arrive in the campaign, and what you change in Dragonroll of
|
||||
those characters and items goes back to the world.
|
||||
characters and item directory arrive in the campaign. Sync runs one way only — from Foundry to
|
||||
Dragonroll — so nothing you change in the campaign is written back into the world.
|
||||
|
||||
There are two separate parts, and you only need the first of them:
|
||||
|
||||
@@ -56,56 +56,30 @@ Worth knowing:
|
||||
| Character, NPC and creature actors | Actors with the same sheet: abilities, saving throws, skills, combat stats, proficiencies, tools, languages, traits, spells, carried gear with its icons, coins, portrait |
|
||||
| The world's **item directory** (the items tab) | The campaign's item list, with category, rarity, quantity, weight, properties and description |
|
||||
| The folders grouping that item directory | Item folders with the same names and nesting |
|
||||
| A folder's colour | The campaign's folder colour — and the other way round, what you colour in Dragonroll lands on the world's folder |
|
||||
| The world's **scenes** | The campaign's maps: the scene's background picture and the grid laid over it, in the scene's own cell size |
|
||||
| A journal per note folder, named after its path — one page per note | Your campaign's notes. They arrive **from** Dragonroll: what you write in a journal does not go back |
|
||||
| A folder's colour | The campaign's folder colour |
|
||||
|
||||
The item list is the world's item directory and nothing else. The gear a character carries is that
|
||||
character's inventory: it travels with the character and stays on its sheet, so a sword a fighter owns
|
||||
does not turn up in the campaign's item list. Spells, classes, subclasses, backgrounds, feats and
|
||||
species are not gear and are not imported.
|
||||
|
||||
The world's scenes are the campaign's maps, and only their **background picture** and their **grid**
|
||||
cross over: a map arrives with the scene's picture and its cell size, and with the grid where the
|
||||
world shifts it. That is where the two stop — what one of your cells stands for, the folder a map
|
||||
stands in, the notes pinned onto it and the characters standing on it as tokens stay in the campaign,
|
||||
and nothing about a map is written back into the world. The scene list goes over when the world links
|
||||
and when it loads, which is also when the map of a scene the GM deleted goes with it; scenes changed
|
||||
afterwards arrive as they happen. A scene with no background picture makes no map, and the full list
|
||||
leaves a map the campaign already had alone, so a grid you lined up yourself survives a reload.
|
||||
|
||||
An actor or item keeps the Dragonroll id it was given in a `dragonroll-foundry.actorId` /
|
||||
`dragonroll-foundry.itemId` flag, and that is what makes the two sides recognise each other. A world
|
||||
item that carries no flag is matched by name, so a hand-written item in Dragonroll is adopted instead of
|
||||
doubled, and renaming it in either place does not resurrect a duplicate.
|
||||
|
||||
Changes flow both ways as they happen, and Dragonroll's own edits are applied back in Foundry within a
|
||||
few seconds. A **full** snapshot — the one taken when the world links, or forced from the actor
|
||||
directory — is the only thing that prunes: it is the only moment either side can see the whole list and
|
||||
notice what is gone. Live edits never delete anything.
|
||||
|
||||
Notes are the exception that runs one way, because notes are written in Dragonroll: each folder
|
||||
stands as a journal named after its path. Notes in the root of the campaign share the journal called
|
||||
**Dragonroll**, while notes in a folder called *Sessions* with a subfolder *Arc 1* share the journal
|
||||
**Sessions / Arc 1**; every note is a page of the journal of its folder. A note's dice widgets are
|
||||
buttons there as well: press one in the journal and Foundry rolls it and posts the result to chat, so
|
||||
advantage and disadvantage roll the way the campaign's notes describe them. The note's `[[links]]`
|
||||
work in the page too: a link to a note page, a character, an item or a scene opens it in Foundry, and
|
||||
`![[a character or item]]` is drawn as a sheet preview inside the page. Renaming a folder renames
|
||||
its journal, and moving a note to another folder moves its page along. The module only pulls the notes
|
||||
over when something has changed, checking every fifteen seconds, so a note you make, edit or move in
|
||||
the app appears in its journal within that time, and deleting one takes its page with it. Pages the
|
||||
campaign does not own — ones the GM made in those journals themselves — are left alone, and nothing
|
||||
written in a journal travels back to the campaign. A folder journal whose notes have all left is
|
||||
removed too, unless the GM keeps pages of their own in it.
|
||||
Changes flow one way: as you create, change or delete actors and world items in Foundry, they reach
|
||||
the campaign. Nothing is written back, so editing a character, an item, a map or a note in Dragonroll
|
||||
leaves the world alone. A **full** snapshot — the one taken when the world links, or forced from the
|
||||
actor directory — is the only thing that prunes: it is the only moment the campaign can see the whole
|
||||
list and notice what is gone. Live edits never delete anything.
|
||||
|
||||
## Auto-sync, and sending one actor on purpose
|
||||
|
||||
**Dragonroll Auto-sync** is what keeps the two in step: actors and world items you create, change or
|
||||
delete are sent to the campaign, and both sides reconcile every few seconds. Turning it off stops all
|
||||
of it — nothing is sent, and Dragonroll stops rewriting your Foundry documents, so the campaign keeps
|
||||
whatever it already holds. Turn it back on and both sides reconcile again, including the edits queued
|
||||
while it was off.
|
||||
delete are sent to the campaign. Turning it off stops all of it — nothing is sent, and the campaign
|
||||
keeps whatever it already holds. Turn it back on and the world's current state is sent again, including
|
||||
the edits queued while it was off.
|
||||
|
||||
To send one character across right now, or to cross over while autosync is off, right-click the actor
|
||||
(or several) in the Foundry actor directory and pick **Dragonroll: Force Sync**. Those actors, with the
|
||||
|
||||
@@ -127,6 +127,12 @@ const defWindows = {
|
||||
close: () => ClearWindow({type: 'pinned_note'}),
|
||||
movable: true
|
||||
},
|
||||
media_viewer: {
|
||||
title: 'windows.media-viewer',
|
||||
component: () => import('~/components/windows/MediaViewerWindow.vue'),
|
||||
close: () => ClearWindow({type: 'media_viewer'}),
|
||||
movable: true
|
||||
},
|
||||
documentation: {
|
||||
title: 'windows.documentation',
|
||||
component: () => import('~/components/windows/DocumentationWindow.vue'),
|
||||
|
||||
Reference in New Issue
Block a user