uncial-cms 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -16
- package/dist/astro/index.d.ts +2 -1
- package/dist/astro/index.js +7 -2
- package/dist/content-sources.d.ts +10 -0
- package/dist/content-sources.js +25 -1
- package/dist/dashboard/ConfirmDialog.svelte +76 -0
- package/dist/dashboard/ConfirmDialog.svelte.d.ts +10 -0
- package/dist/dashboard/Dashboard.svelte +639 -0
- package/dist/dashboard/Dashboard.svelte.d.ts +4 -0
- package/dist/dashboard/FallbackEditor.svelte +42 -0
- package/dist/dashboard/FallbackEditor.svelte.d.ts +14 -0
- package/dist/dashboard/GlobalForm.svelte +405 -0
- package/dist/dashboard/GlobalForm.svelte.d.ts +17 -0
- package/dist/dashboard/GlobalsList.svelte +62 -0
- package/dist/dashboard/GlobalsList.svelte.d.ts +7 -0
- package/dist/dashboard/MediaSection.svelte +221 -0
- package/dist/dashboard/MediaSection.svelte.d.ts +16 -0
- package/dist/dashboard/PagesSection.svelte +477 -0
- package/dist/dashboard/PagesSection.svelte.d.ts +23 -0
- package/dist/dashboard/element.d.ts +39 -0
- package/dist/dashboard/element.js +107 -0
- package/dist/dashboard/pages-list.d.ts +18 -0
- package/dist/dashboard/pages-list.js +29 -0
- package/dist/dashboard/routes.d.ts +25 -0
- package/dist/dashboard/routes.js +81 -0
- package/dist/dashboard/types.d.ts +32 -0
- package/dist/dashboard/types.js +1 -0
- package/dist/define-site.d.ts +11 -6
- package/dist/define-site.js +4 -7
- package/dist/editor-controller.d.ts +1 -0
- package/dist/editor-controller.js +1 -0
- package/dist/editor-session.d.ts +5 -0
- package/dist/editor-session.js +1 -1
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +14 -0
- package/dist/globals.d.ts +12 -0
- package/dist/globals.js +29 -0
- package/dist/image-source.d.ts +0 -10
- package/dist/image-source.js +15 -44
- package/dist/index-actions.d.ts +29 -2
- package/dist/index-actions.js +36 -4
- package/dist/index-page.d.ts +2 -0
- package/dist/index-page.js +6 -256
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -2
- package/dist/media-source.d.ts +45 -0
- package/dist/media-source.js +113 -0
- package/dist/mount.d.ts +1 -0
- package/dist/mount.js +2 -0
- package/dist/server/handlers.d.ts +1 -1
- package/dist/server/handlers.js +32 -5
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +2 -1
- package/dist/server/media.d.ts +1 -10
- package/dist/server/media.js +7 -11
- package/dist/server/postgres-store.d.ts +5 -0
- package/dist/server/postgres-store.js +50 -5
- package/dist/server-forge/adapter.d.ts +1 -0
- package/dist/server-forge/adapter.js +7 -4
- package/dist/server-forge/protocol.d.ts +3 -1
- package/dist/server-forge/protocol.js +2 -1
- package/dist/svelte/MediaLibrary.svelte +109 -53
- package/dist/svelte/MediaLibrary.svelte.d.ts +10 -2
- package/dist/svelte/index.d.ts +1 -4
- package/dist/svelte/index.js +1 -4
- package/dist/sveltekit/index.d.ts +2 -1
- package/dist/sveltekit/index.js +7 -2
- package/package.json +12 -3
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
<svelte:options css="injected" />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { onMount, tick, untrack } from 'svelte';
|
|
5
|
+
import { defaultSessionProvider, forgeAdapter } from '../editor-session.js';
|
|
6
|
+
import { SignedOutError } from '../errors.js';
|
|
7
|
+
import { globalTitle } from '../globals.js';
|
|
8
|
+
import { defaultMapPathToSource } from '../paths/index.js';
|
|
9
|
+
import { UNCIAL_CMS_RUNTIME_SENTINEL } from '../sentinel.js';
|
|
10
|
+
import { clearCachedSession } from '../session.js';
|
|
11
|
+
import type {
|
|
12
|
+
ForgeAdapter,
|
|
13
|
+
ForgeSession,
|
|
14
|
+
SessionProvider,
|
|
15
|
+
UncialCmsSiteConfig
|
|
16
|
+
} from '../types.js';
|
|
17
|
+
import FallbackEditor from './FallbackEditor.svelte';
|
|
18
|
+
import GlobalForm from './GlobalForm.svelte';
|
|
19
|
+
import GlobalsList from './GlobalsList.svelte';
|
|
20
|
+
import MediaSection from './MediaSection.svelte';
|
|
21
|
+
import PagesSection from './PagesSection.svelte';
|
|
22
|
+
import {
|
|
23
|
+
hashForRoute,
|
|
24
|
+
routeFromHash,
|
|
25
|
+
type DashboardRoute,
|
|
26
|
+
type DashboardSection,
|
|
27
|
+
type PagesQuery
|
|
28
|
+
} from './routes.js';
|
|
29
|
+
import type { DashboardProps } from './types.js';
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
config,
|
|
33
|
+
blocks,
|
|
34
|
+
schema,
|
|
35
|
+
globals,
|
|
36
|
+
editorHref,
|
|
37
|
+
can = () => true,
|
|
38
|
+
appSections = [],
|
|
39
|
+
signOutHref,
|
|
40
|
+
basePath = '',
|
|
41
|
+
theme = 'system',
|
|
42
|
+
sessionProvider,
|
|
43
|
+
mapPathToSource,
|
|
44
|
+
mapSourceToPath,
|
|
45
|
+
editorStylesheets,
|
|
46
|
+
staticDir,
|
|
47
|
+
sections = ['pages', 'media', 'globals']
|
|
48
|
+
}: DashboardProps = $props();
|
|
49
|
+
|
|
50
|
+
const uid = $props.id();
|
|
51
|
+
|
|
52
|
+
const LABELS: Record<DashboardSection, string> = {
|
|
53
|
+
pages: 'Pages',
|
|
54
|
+
media: 'Media',
|
|
55
|
+
globals: 'Globals'
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const site = $derived<UncialCmsSiteConfig | undefined>(
|
|
59
|
+
config && ('forge' in config ? config : config.config)
|
|
60
|
+
);
|
|
61
|
+
const globalSchemas = $derived(globals ?? (config && 'globals' in config ? config.globals : {}));
|
|
62
|
+
const branchLabel = $derived(
|
|
63
|
+
site?.forge === 'github'
|
|
64
|
+
? site.branch
|
|
65
|
+
: site?.forge === 'server'
|
|
66
|
+
? 'the server'
|
|
67
|
+
: 'the local checkout'
|
|
68
|
+
);
|
|
69
|
+
const locationLabel = $derived(
|
|
70
|
+
site?.forge === 'github' ? `${site.repo}@${site.branch}` : site ? branchLabel : ''
|
|
71
|
+
);
|
|
72
|
+
const sourceFor = $derived.by(() => {
|
|
73
|
+
if (mapPathToSource) return mapPathToSource;
|
|
74
|
+
if (site?.forge === 'server') return (path: string) => (path === '' ? '/' : `/${path}/`);
|
|
75
|
+
const contentDir = site?.contentDir ?? '';
|
|
76
|
+
return (path: string) => defaultMapPathToSource(path, contentDir);
|
|
77
|
+
});
|
|
78
|
+
const schemaFor = (pagePath: string) =>
|
|
79
|
+
typeof schema === 'function' ? (schema as (path: string) => unknown)(pagePath) : schema;
|
|
80
|
+
|
|
81
|
+
let connection = $state.raw<{ adapter: ForgeAdapter; session: ForgeSession }>();
|
|
82
|
+
let signedOut = $state<string>();
|
|
83
|
+
const user = $derived(connection?.session.user);
|
|
84
|
+
|
|
85
|
+
let route = $state<DashboardRoute>({ section: 'pages' });
|
|
86
|
+
let pagesQuery = $state<PagesQuery>({});
|
|
87
|
+
const pagesHref = $derived(hashForRoute({ section: 'pages', query: pagesQuery }));
|
|
88
|
+
const openGlobal = $derived(
|
|
89
|
+
route.section === 'globals' && route.name && Object.hasOwn(globalSchemas, route.name)
|
|
90
|
+
? { name: route.name, schema: globalSchemas[route.name]! }
|
|
91
|
+
: undefined
|
|
92
|
+
);
|
|
93
|
+
let hash = '';
|
|
94
|
+
let heading = $state<HTMLElement>();
|
|
95
|
+
let editor = $state<{ isDirty(): boolean }>();
|
|
96
|
+
let menuOpen = $state(false);
|
|
97
|
+
let menuButton = $state<HTMLButtonElement>();
|
|
98
|
+
|
|
99
|
+
const navItems = $derived([
|
|
100
|
+
...sections.map((id) => ({
|
|
101
|
+
id,
|
|
102
|
+
label: LABELS[id],
|
|
103
|
+
href: id === 'pages' ? pagesHref : `#/${id}`
|
|
104
|
+
})),
|
|
105
|
+
...appSections.map((app) => ({
|
|
106
|
+
id: `app/${app.id}`,
|
|
107
|
+
label: app.label,
|
|
108
|
+
href: app.href ?? hashForRoute({ section: 'app', id: app.id })
|
|
109
|
+
}))
|
|
110
|
+
]);
|
|
111
|
+
const showNav = $derived(navItems.length > 1 && signedOut === undefined);
|
|
112
|
+
const activeId = $derived(
|
|
113
|
+
route.section === 'edit' ? 'pages' : route.section === 'app' ? `app/${route.id}` : route.section
|
|
114
|
+
);
|
|
115
|
+
const title = $derived(
|
|
116
|
+
signedOut !== undefined
|
|
117
|
+
? 'Signed out'
|
|
118
|
+
: route.section === 'edit'
|
|
119
|
+
? route.pagePath === ''
|
|
120
|
+
? 'Editing site root'
|
|
121
|
+
: `Editing /${route.pagePath}/`
|
|
122
|
+
: openGlobal
|
|
123
|
+
? (globalTitle(openGlobal.schema) ?? openGlobal.name)
|
|
124
|
+
: (navItems.find((item) => item.id === activeId)?.label ?? LABELS.pages)
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const reason = (error: unknown) =>
|
|
128
|
+
error instanceof Error ? error.message : 'Failed to sign in.';
|
|
129
|
+
const provideSession: SessionProvider = async (current) => {
|
|
130
|
+
try {
|
|
131
|
+
const session = await (sessionProvider ?? defaultSessionProvider(current))(current);
|
|
132
|
+
if (current === site && connection) connection = { ...connection, session };
|
|
133
|
+
return session;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
throw new SignedOutError(reason(error));
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
async function signIn(current: UncialCmsSiteConfig) {
|
|
140
|
+
const adapter = forgeAdapter(current);
|
|
141
|
+
try {
|
|
142
|
+
const session = await adapter.authenticate(current, provideSession);
|
|
143
|
+
if (current !== site) return;
|
|
144
|
+
connection = { adapter, session };
|
|
145
|
+
signedOut = undefined;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if (current !== site) return;
|
|
148
|
+
signedOut = reason(error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function retrySignIn() {
|
|
153
|
+
if (!site) return;
|
|
154
|
+
await signIn(site);
|
|
155
|
+
await tick();
|
|
156
|
+
if (connection) heading?.focus();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function endSession(why: string) {
|
|
160
|
+
connection = undefined;
|
|
161
|
+
signedOut = why;
|
|
162
|
+
menuOpen = false;
|
|
163
|
+
await tick();
|
|
164
|
+
heading?.focus();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function signOut() {
|
|
168
|
+
if (site?.forge === 'github') clearCachedSession(site.repo);
|
|
169
|
+
void endSession('You signed out.');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
$effect(() => {
|
|
173
|
+
const current = site;
|
|
174
|
+
if (current) untrack(() => void signIn(current));
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
function resolve(next: string): DashboardRoute {
|
|
178
|
+
const parsed = routeFromHash(next);
|
|
179
|
+
if (parsed.section === 'edit') return parsed;
|
|
180
|
+
if (parsed.section === 'app') {
|
|
181
|
+
return appSections.some((app) => app.id === parsed.id && !app.href)
|
|
182
|
+
? parsed
|
|
183
|
+
: { section: 'pages' };
|
|
184
|
+
}
|
|
185
|
+
if (!sections.includes(parsed.section)) return { section: 'pages' };
|
|
186
|
+
if (parsed.section === 'globals' && parsed.name && !Object.hasOwn(globalSchemas, parsed.name)) {
|
|
187
|
+
return { section: 'globals' };
|
|
188
|
+
}
|
|
189
|
+
return parsed;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function apply(next: string) {
|
|
193
|
+
const resolved = resolve(next);
|
|
194
|
+
const canonical = hashForRoute(resolved);
|
|
195
|
+
if (next !== '' && next !== canonical) history.replaceState(history.state, '', canonical);
|
|
196
|
+
hash = next === '' ? '' : canonical;
|
|
197
|
+
route = resolved;
|
|
198
|
+
if (resolved.section === 'pages') pagesQuery = resolved.query ?? {};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// A query change keeps focus where it is, so it replaces the hash without a hashchange.
|
|
202
|
+
function setPagesQuery(query: PagesQuery) {
|
|
203
|
+
pagesQuery = query;
|
|
204
|
+
route = { section: 'pages', query };
|
|
205
|
+
hash = hashForRoute(route);
|
|
206
|
+
history.replaceState(history.state, '', hash);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function onHashChange() {
|
|
210
|
+
if (location.hash === hash) return;
|
|
211
|
+
if (route.section === 'edit' && editor?.isDirty() && !confirm('Discard unsaved changes?')) {
|
|
212
|
+
history.replaceState(history.state, '', hash);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
apply(location.hash);
|
|
216
|
+
menuOpen = false;
|
|
217
|
+
void tick().then(() => heading?.focus());
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function onBeforeUnload(event: BeforeUnloadEvent) {
|
|
221
|
+
if (route.section === 'edit' && editor?.isDirty()) event.preventDefault();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function onKeydown(event: KeyboardEvent) {
|
|
225
|
+
if (event.key !== 'Escape' || !menuOpen) return;
|
|
226
|
+
menuOpen = false;
|
|
227
|
+
menuButton?.focus();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
onMount(() => {
|
|
231
|
+
apply(location.hash);
|
|
232
|
+
});
|
|
233
|
+
</script>
|
|
234
|
+
|
|
235
|
+
<svelte:window onhashchange={onHashChange} onbeforeunload={onBeforeUnload} onkeydown={onKeydown} />
|
|
236
|
+
|
|
237
|
+
<div
|
|
238
|
+
class="dashboard uncial-dashboard"
|
|
239
|
+
data-theme={theme}
|
|
240
|
+
data-uncial-cms-runtime={UNCIAL_CMS_RUNTIME_SENTINEL}
|
|
241
|
+
>
|
|
242
|
+
<div class="topbar">
|
|
243
|
+
{#if showNav}
|
|
244
|
+
<button
|
|
245
|
+
bind:this={menuButton}
|
|
246
|
+
type="button"
|
|
247
|
+
class="btn menu-button"
|
|
248
|
+
aria-expanded={menuOpen}
|
|
249
|
+
aria-controls="{uid}-nav"
|
|
250
|
+
onclick={() => (menuOpen = !menuOpen)}
|
|
251
|
+
>
|
|
252
|
+
<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
|
|
253
|
+
<path d="M2 4h12M2 8h12M2 12h12" stroke="currentColor" stroke-width="1.5" />
|
|
254
|
+
</svg>
|
|
255
|
+
Menu
|
|
256
|
+
</button>
|
|
257
|
+
{/if}
|
|
258
|
+
<div class="identity">
|
|
259
|
+
<p class="name">Dashboard</p>
|
|
260
|
+
{#if locationLabel}<p class="location">{locationLabel}</p>{/if}
|
|
261
|
+
</div>
|
|
262
|
+
<div class="session">
|
|
263
|
+
{#if signedOut === undefined}
|
|
264
|
+
<p class="status" role="status">
|
|
265
|
+
{#if user}Signed in as <strong>{user.name || user.login}</strong>{:else}Signing in…{/if}
|
|
266
|
+
</p>
|
|
267
|
+
{/if}
|
|
268
|
+
{#if user && site?.forge === 'github'}
|
|
269
|
+
<button type="button" class="btn" onclick={signOut}>Sign out</button>
|
|
270
|
+
{:else if user && site?.forge === 'server' && signOutHref}
|
|
271
|
+
<a class="btn" href={signOutHref}>Sign out</a>
|
|
272
|
+
{/if}
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<div class="body">
|
|
277
|
+
{#if showNav}
|
|
278
|
+
<nav id="{uid}-nav" class="nav" class:open={menuOpen} aria-label="Dashboard">
|
|
279
|
+
<ul>
|
|
280
|
+
{#each navItems as item (item.id)}
|
|
281
|
+
<li>
|
|
282
|
+
<a
|
|
283
|
+
href={item.href}
|
|
284
|
+
aria-current={activeId === item.id ? 'page' : undefined}
|
|
285
|
+
onclick={() => (menuOpen = false)}>{item.label}</a
|
|
286
|
+
>
|
|
287
|
+
</li>
|
|
288
|
+
{/each}
|
|
289
|
+
</ul>
|
|
290
|
+
</nav>
|
|
291
|
+
{/if}
|
|
292
|
+
|
|
293
|
+
<div class="content">
|
|
294
|
+
{#if route.section === 'edit' && signedOut === undefined}
|
|
295
|
+
<a class="back" href={pagesHref}><span aria-hidden="true">←</span> Back to pages</a>
|
|
296
|
+
{:else if openGlobal && signedOut === undefined}
|
|
297
|
+
<a class="back" href="#/globals"><span aria-hidden="true">←</span> Back to globals</a>
|
|
298
|
+
{/if}
|
|
299
|
+
<h1 bind:this={heading} tabindex="-1">{title}</h1>
|
|
300
|
+
|
|
301
|
+
{#if signedOut !== undefined}
|
|
302
|
+
<p class="reason" role="status">{signedOut}</p>
|
|
303
|
+
<!-- The first attempt runs outside a click, where browsers block the sign-in popup. -->
|
|
304
|
+
<button type="button" class="btn btn-primary" onclick={retrySignIn}>Sign in</button>
|
|
305
|
+
{:else if route.section === 'edit'}
|
|
306
|
+
{#if connection && site}
|
|
307
|
+
{#if can('save-draft', route.pagePath)}
|
|
308
|
+
{#key route.pagePath}
|
|
309
|
+
<FallbackEditor
|
|
310
|
+
bind:this={editor}
|
|
311
|
+
options={{
|
|
312
|
+
config: site,
|
|
313
|
+
sourcePath: sourceFor(route.pagePath),
|
|
314
|
+
pagePath: route.pagePath,
|
|
315
|
+
blocks,
|
|
316
|
+
schema: schemaFor(route.pagePath),
|
|
317
|
+
sessionProvider: provideSession,
|
|
318
|
+
editorStylesheets
|
|
319
|
+
}}
|
|
320
|
+
{basePath}
|
|
321
|
+
{staticDir}
|
|
322
|
+
{can}
|
|
323
|
+
onsignedout={endSession}
|
|
324
|
+
/>
|
|
325
|
+
{/key}
|
|
326
|
+
{:else}
|
|
327
|
+
<p>You don’t have permission to edit this page.</p>
|
|
328
|
+
{/if}
|
|
329
|
+
{/if}
|
|
330
|
+
{:else if route.section === 'app'}
|
|
331
|
+
{#if connection}
|
|
332
|
+
<svelte:element this={'slot'} name={route.id} />
|
|
333
|
+
{/if}
|
|
334
|
+
{:else if route.section === 'pages'}
|
|
335
|
+
{#if connection && site}
|
|
336
|
+
<PagesSection
|
|
337
|
+
config={site}
|
|
338
|
+
adapter={connection.adapter}
|
|
339
|
+
session={connection.session}
|
|
340
|
+
{blocks}
|
|
341
|
+
{schemaFor}
|
|
342
|
+
{sourceFor}
|
|
343
|
+
{mapSourceToPath}
|
|
344
|
+
{basePath}
|
|
345
|
+
{editorHref}
|
|
346
|
+
{branchLabel}
|
|
347
|
+
{can}
|
|
348
|
+
query={(route.section === 'pages' && route.query) || {}}
|
|
349
|
+
onquery={setPagesQuery}
|
|
350
|
+
onfocusheading={() => heading?.focus()}
|
|
351
|
+
onsignedout={endSession}
|
|
352
|
+
/>
|
|
353
|
+
{/if}
|
|
354
|
+
{:else if route.section === 'media'}
|
|
355
|
+
{#if connection && site}
|
|
356
|
+
<MediaSection
|
|
357
|
+
config={site}
|
|
358
|
+
adapter={connection.adapter}
|
|
359
|
+
session={connection.session}
|
|
360
|
+
{staticDir}
|
|
361
|
+
{basePath}
|
|
362
|
+
{mapSourceToPath}
|
|
363
|
+
{branchLabel}
|
|
364
|
+
{can}
|
|
365
|
+
onsignedout={endSession}
|
|
366
|
+
/>
|
|
367
|
+
{/if}
|
|
368
|
+
{:else if route.section === 'globals'}
|
|
369
|
+
{#if connection && site}
|
|
370
|
+
{#if openGlobal}
|
|
371
|
+
{#key openGlobal}
|
|
372
|
+
<GlobalForm
|
|
373
|
+
config={site}
|
|
374
|
+
adapter={connection.adapter}
|
|
375
|
+
session={connection.session}
|
|
376
|
+
name={openGlobal.name}
|
|
377
|
+
schema={openGlobal.schema}
|
|
378
|
+
{branchLabel}
|
|
379
|
+
{can}
|
|
380
|
+
onfocusheading={() => heading?.focus()}
|
|
381
|
+
onsignedout={endSession}
|
|
382
|
+
/>
|
|
383
|
+
{/key}
|
|
384
|
+
{:else}
|
|
385
|
+
<GlobalsList globals={globalSchemas} />
|
|
386
|
+
{/if}
|
|
387
|
+
{/if}
|
|
388
|
+
{/if}
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
|
|
393
|
+
<style>
|
|
394
|
+
@layer uncial-tokens {
|
|
395
|
+
:global(:host),
|
|
396
|
+
:global(:root) .dashboard {
|
|
397
|
+
--uncial-color-bg: light-dark(oklch(99% 0.006 85), oklch(18% 0.015 60));
|
|
398
|
+
--uncial-color-surface: light-dark(oklch(99% 0.006 85), oklch(18% 0.015 60));
|
|
399
|
+
--uncial-color-surface-elevated: light-dark(oklch(96% 0.022 85), oklch(22% 0.02 60));
|
|
400
|
+
--uncial-color-border: light-dark(oklch(91% 0.032 82), oklch(27% 0.025 60));
|
|
401
|
+
--uncial-color-border-strong: color-mix(
|
|
402
|
+
in srgb,
|
|
403
|
+
var(--uncial-color-text) 22%,
|
|
404
|
+
var(--uncial-color-border)
|
|
405
|
+
);
|
|
406
|
+
--uncial-color-text: light-dark(oklch(22% 0.04 45), oklch(92% 0.015 85));
|
|
407
|
+
--uncial-color-primary: light-dark(oklch(46% 0.14 260), oklch(72% 0.13 260));
|
|
408
|
+
--uncial-color-primary-contrast: light-dark(oklch(98% 0.015 85), oklch(16% 0.03 260));
|
|
409
|
+
--uncial-color-danger: light-dark(oklch(48% 0.18 25), oklch(72% 0.16 25));
|
|
410
|
+
--uncial-color-focus-ring: var(--uncial-color-primary);
|
|
411
|
+
--uncial-font-body: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;
|
|
412
|
+
--uncial-font-mono:
|
|
413
|
+
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
|
|
414
|
+
monospace;
|
|
415
|
+
--uncial-font-size-base: 1rem;
|
|
416
|
+
--uncial-radius-md: 0.375rem;
|
|
417
|
+
--uncial-radius-lg: 0.5rem;
|
|
418
|
+
--uncial-space-1: 0.25rem;
|
|
419
|
+
--uncial-space-2: 0.5rem;
|
|
420
|
+
--uncial-space-3: 0.75rem;
|
|
421
|
+
--uncial-space-4: 1rem;
|
|
422
|
+
--uncial-space-5: 1.25rem;
|
|
423
|
+
--uncial-space-6: 1.5rem;
|
|
424
|
+
--uncial-shadow-sm: 0 1px 2px color-mix(in srgb, black 8%, transparent);
|
|
425
|
+
--uncial-shadow-md: 0 10px 25px color-mix(in srgb, black 14%, transparent);
|
|
426
|
+
--uncial-transition: 140ms ease;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.dashboard {
|
|
431
|
+
--uncial-dashboard-muted: color-mix(
|
|
432
|
+
in srgb,
|
|
433
|
+
var(--uncial-color-text) 78%,
|
|
434
|
+
var(--uncial-color-bg)
|
|
435
|
+
);
|
|
436
|
+
color-scheme: light dark;
|
|
437
|
+
border: 1px solid var(--uncial-color-border);
|
|
438
|
+
border-radius: var(--uncial-radius-lg);
|
|
439
|
+
background: var(--uncial-color-bg);
|
|
440
|
+
color: var(--uncial-color-text);
|
|
441
|
+
font-family: var(--uncial-font-body);
|
|
442
|
+
font-size: var(--uncial-font-size-base);
|
|
443
|
+
line-height: 1.5;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.dashboard[data-theme='light'] {
|
|
447
|
+
color-scheme: light;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.dashboard[data-theme='dark'] {
|
|
451
|
+
color-scheme: dark;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.topbar {
|
|
455
|
+
display: flex;
|
|
456
|
+
flex-wrap: wrap;
|
|
457
|
+
align-items: center;
|
|
458
|
+
gap: var(--uncial-space-3);
|
|
459
|
+
padding: var(--uncial-space-3) var(--uncial-space-4);
|
|
460
|
+
border-bottom: 1px solid var(--uncial-color-border);
|
|
461
|
+
border-radius: var(--uncial-radius-lg) var(--uncial-radius-lg) 0 0;
|
|
462
|
+
background: var(--uncial-color-surface-elevated);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.identity {
|
|
466
|
+
flex: 1 1 10rem;
|
|
467
|
+
min-width: 0;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.identity p,
|
|
471
|
+
.status {
|
|
472
|
+
margin: 0;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.name {
|
|
476
|
+
font-weight: 700;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.location {
|
|
480
|
+
color: var(--uncial-dashboard-muted);
|
|
481
|
+
font-family: var(--uncial-font-mono);
|
|
482
|
+
font-size: 0.8125rem;
|
|
483
|
+
overflow-wrap: anywhere;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.session {
|
|
487
|
+
display: flex;
|
|
488
|
+
flex-wrap: wrap;
|
|
489
|
+
align-items: center;
|
|
490
|
+
gap: var(--uncial-space-2);
|
|
491
|
+
font-size: 0.875rem;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.body {
|
|
495
|
+
display: grid;
|
|
496
|
+
grid-template-columns: 11rem minmax(0, 1fr);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
.nav {
|
|
500
|
+
padding: var(--uncial-space-3);
|
|
501
|
+
border-right: 1px solid var(--uncial-color-border);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.nav ul {
|
|
505
|
+
display: grid;
|
|
506
|
+
gap: var(--uncial-space-1);
|
|
507
|
+
margin: 0;
|
|
508
|
+
padding: 0;
|
|
509
|
+
list-style: none;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.nav a {
|
|
513
|
+
display: block;
|
|
514
|
+
padding: var(--uncial-space-2) var(--uncial-space-3);
|
|
515
|
+
border-radius: var(--uncial-radius-md);
|
|
516
|
+
color: var(--uncial-color-text);
|
|
517
|
+
font-weight: 600;
|
|
518
|
+
text-decoration: none;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.nav a:hover {
|
|
522
|
+
background: var(--uncial-color-surface-elevated);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.nav a[aria-current='page'] {
|
|
526
|
+
background: var(--uncial-color-primary);
|
|
527
|
+
color: var(--uncial-color-primary-contrast);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.content {
|
|
531
|
+
min-width: 0;
|
|
532
|
+
padding: var(--uncial-space-6);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.content:only-child {
|
|
536
|
+
grid-column: 1 / -1;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
h1 {
|
|
540
|
+
margin: 0 0 var(--uncial-space-5);
|
|
541
|
+
font-size: 1.5rem;
|
|
542
|
+
line-height: 1.25;
|
|
543
|
+
overflow-wrap: anywhere;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.back {
|
|
547
|
+
display: inline-block;
|
|
548
|
+
margin-bottom: var(--uncial-space-3);
|
|
549
|
+
color: var(--uncial-color-primary);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.reason {
|
|
553
|
+
margin: 0 0 var(--uncial-space-4);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.dashboard .topbar .menu-button {
|
|
557
|
+
display: none;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
.dashboard :global(:is(a, button, input, h1, [tabindex]):focus-visible) {
|
|
561
|
+
outline: 2px solid var(--uncial-color-focus-ring);
|
|
562
|
+
outline-offset: 2px;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.dashboard :global(:is(.btn, .uncial-cms-media-upload, .uncial-cms-media-delete)) {
|
|
566
|
+
display: inline-flex;
|
|
567
|
+
align-items: center;
|
|
568
|
+
justify-content: center;
|
|
569
|
+
gap: 0.375rem;
|
|
570
|
+
min-height: 2.25rem;
|
|
571
|
+
padding: 0 var(--uncial-space-3);
|
|
572
|
+
border: 1px solid var(--uncial-color-border-strong);
|
|
573
|
+
border-radius: var(--uncial-radius-md);
|
|
574
|
+
background: var(--uncial-color-surface);
|
|
575
|
+
color: var(--uncial-color-text);
|
|
576
|
+
font: inherit;
|
|
577
|
+
font-size: 0.875rem;
|
|
578
|
+
font-weight: 600;
|
|
579
|
+
line-height: 1;
|
|
580
|
+
text-decoration: none;
|
|
581
|
+
cursor: pointer;
|
|
582
|
+
transition: background var(--uncial-transition);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
.dashboard
|
|
586
|
+
:global(:is(.btn, .uncial-cms-media-upload, .uncial-cms-media-delete):hover:not(:disabled)) {
|
|
587
|
+
background: var(--uncial-color-surface-elevated);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.dashboard :global(:is(.btn, .uncial-cms-media-upload):disabled) {
|
|
591
|
+
cursor: not-allowed;
|
|
592
|
+
opacity: 0.6;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.dashboard :global(:is(.btn-primary, .uncial-cms-media-upload)),
|
|
596
|
+
.dashboard :global(:is(.btn-primary, .uncial-cms-media-upload):hover:not(:disabled)) {
|
|
597
|
+
border-color: var(--uncial-color-primary);
|
|
598
|
+
background: var(--uncial-color-primary);
|
|
599
|
+
color: var(--uncial-color-primary-contrast);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
.dashboard :global(:is(.btn-danger, .uncial-cms-media-delete)) {
|
|
603
|
+
border-color: color-mix(in srgb, var(--uncial-color-danger) 70%, var(--uncial-color-border));
|
|
604
|
+
color: var(--uncial-color-danger);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.dashboard :global(.visually-hidden) {
|
|
608
|
+
position: absolute;
|
|
609
|
+
width: 1px;
|
|
610
|
+
height: 1px;
|
|
611
|
+
overflow: hidden;
|
|
612
|
+
clip-path: inset(50%);
|
|
613
|
+
white-space: nowrap;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
@media (max-width: 40rem) {
|
|
617
|
+
.dashboard .topbar .menu-button {
|
|
618
|
+
display: inline-flex;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.body {
|
|
622
|
+
grid-template-columns: minmax(0, 1fr);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
.nav {
|
|
626
|
+
display: none;
|
|
627
|
+
border-right: 0;
|
|
628
|
+
border-bottom: 1px solid var(--uncial-color-border);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.nav.open {
|
|
632
|
+
display: block;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
.content {
|
|
636
|
+
padding: var(--uncial-space-4);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { mountEditorPage, type MountEditorPageOptions } from '../mount.js';
|
|
4
|
+
import { cmsImageSource } from '../image-source.js';
|
|
5
|
+
import { SignedOutError } from '../errors.js';
|
|
6
|
+
import type { DashboardAction } from './types.js';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
options,
|
|
10
|
+
basePath,
|
|
11
|
+
staticDir,
|
|
12
|
+
can,
|
|
13
|
+
onsignedout
|
|
14
|
+
}: {
|
|
15
|
+
options: MountEditorPageOptions;
|
|
16
|
+
basePath: string;
|
|
17
|
+
staticDir?: string;
|
|
18
|
+
can: (action: DashboardAction, subject?: unknown) => boolean;
|
|
19
|
+
onsignedout: (reason: string) => void;
|
|
20
|
+
} = $props();
|
|
21
|
+
|
|
22
|
+
let target: HTMLDivElement;
|
|
23
|
+
let handle: ReturnType<typeof mountEditorPage> | undefined;
|
|
24
|
+
|
|
25
|
+
onMount(() => {
|
|
26
|
+
const source = cmsImageSource(options.config, { base: basePath, staticDir });
|
|
27
|
+
handle = mountEditorPage(target, {
|
|
28
|
+
...options,
|
|
29
|
+
imageSource: { ...source, upload: can('media-upload') ? source.upload : undefined },
|
|
30
|
+
onerror: (error) => {
|
|
31
|
+
if (error instanceof SignedOutError) onsignedout(error.message);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return () => handle?.destroy();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export function isDirty(): boolean {
|
|
38
|
+
return handle?.isDirty() ?? false;
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<div bind:this={target}></div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type MountEditorPageOptions } from '../mount.js';
|
|
2
|
+
import type { DashboardAction } from './types.js';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
options: MountEditorPageOptions;
|
|
5
|
+
basePath: string;
|
|
6
|
+
staticDir?: string;
|
|
7
|
+
can: (action: DashboardAction, subject?: unknown) => boolean;
|
|
8
|
+
onsignedout: (reason: string) => void;
|
|
9
|
+
};
|
|
10
|
+
declare const FallbackEditor: import("svelte").Component<$$ComponentProps, {
|
|
11
|
+
isDirty: () => boolean;
|
|
12
|
+
}, "">;
|
|
13
|
+
type FallbackEditor = ReturnType<typeof FallbackEditor>;
|
|
14
|
+
export default FallbackEditor;
|