@atmo-dev/kit 0.21.0 → 0.23.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 +1 -1
- package/dist/articles/ArticleView.svelte +21 -7
- package/dist/articles/ArticleView.svelte.d.ts +8 -4
- package/dist/articles/styles.js +3 -2
- package/dist/articles-data.d.ts +1 -0
- package/dist/components/RichText.svelte +34 -17
- package/dist/components/RichText.svelte.d.ts +4 -1
- package/dist/components/RichTextEditor.svelte +67 -11
- package/dist/components/RichTextEditor.svelte.d.ts +0 -2
- package/dist/components/StreamplacePicker.svelte +2 -2
- package/dist/components/StreamplacePicker.svelte.d.ts +1 -1
- package/dist/components/composer/EmojiPanel.svelte +55 -0
- package/dist/components/composer/EmojiPanel.svelte.d.ts +6 -0
- package/dist/components/composer/EmojiPicker.svelte +2 -38
- package/dist/components/data/DataLabel.svelte +120 -0
- package/dist/components/data/DataLabel.svelte.d.ts +10 -0
- package/dist/components/data/issues.d.ts +5 -0
- package/dist/components/data/issues.js +52 -0
- package/dist/components/data/types.d.ts +28 -0
- package/dist/components/data/types.js +1 -0
- package/dist/components/data/visibility.d.ts +7 -0
- package/dist/components/data/visibility.js +15 -0
- package/dist/components/legal/links.js +1 -0
- package/dist/components/legal/types.d.ts +1 -1
- package/dist/components/notifications/NotificationList.svelte +137 -0
- package/dist/components/notifications/NotificationList.svelte.d.ts +19 -0
- package/dist/components/notifications/NotificationPushToggle.svelte +76 -0
- package/dist/components/notifications/NotificationPushToggle.svelte.d.ts +19 -0
- package/dist/components/notifications/NotificationSettings.svelte +125 -0
- package/dist/components/notifications/NotificationSettings.svelte.d.ts +16 -0
- package/dist/components/notifications/types.d.ts +37 -0
- package/dist/components/notifications/types.js +1 -0
- package/dist/editor/ImageDialog.svelte +87 -0
- package/dist/editor/ImageDialog.svelte.d.ts +16 -0
- package/dist/editor/image-node.d.ts +6 -2
- package/dist/editor/image-node.js +36 -37
- package/dist/events/EventCard.svelte +6 -1
- package/dist/events/VodPlayer.svelte +1 -1
- package/dist/events/atmo-rsvp.d.ts +6 -0
- package/dist/events/atmo-rsvp.js +34 -0
- package/dist/events/atproto-helpers.d.ts +1 -0
- package/dist/events/atproto-helpers.js +3 -0
- package/dist/events/event-link-embed.d.ts +7 -3
- package/dist/events/event-link-embed.js +11 -5
- package/dist/events/event-view/StreamPlacePlayer.svelte +14 -108
- package/dist/events/linked-records.d.ts +1 -1
- package/dist/events/linked-records.js +2 -2
- package/dist/events-card.d.ts +9 -0
- package/dist/events-card.js +7 -0
- package/dist/events-data.d.ts +1 -0
- package/dist/events-data.js +1 -0
- package/dist/grain/xrpc.js +11 -4
- package/dist/index.d.ts +14 -2
- package/dist/index.js +7 -1
- package/dist/legal.d.ts +3 -0
- package/dist/legal.js +2 -0
- package/dist/media.d.ts +33 -0
- package/dist/media.js +74 -1
- package/dist/richtext/serialize.js +13 -8
- package/dist/streamplace/StreamCard.svelte +184 -0
- package/dist/streamplace/StreamCard.svelte.d.ts +24 -0
- package/dist/streamplace/StreamLinkEmbed.svelte +59 -0
- package/dist/streamplace/StreamLinkEmbed.svelte.d.ts +5 -0
- package/dist/streamplace/StreamPlayer.svelte +539 -0
- package/dist/streamplace/StreamPlayer.svelte.d.ts +42 -0
- package/dist/streamplace/VideoCard.svelte +159 -0
- package/dist/streamplace/VideoCard.svelte.d.ts +17 -0
- package/dist/streamplace/api.d.ts +74 -0
- package/dist/streamplace/api.js +182 -0
- package/dist/streamplace/broadcast.d.ts +3 -0
- package/dist/streamplace/broadcast.js +110 -0
- package/dist/streamplace/channel.svelte.d.ts +74 -0
- package/dist/streamplace/channel.svelte.js +515 -0
- package/dist/streamplace/chat/Composer.svelte +232 -0
- package/dist/streamplace/chat/Composer.svelte.d.ts +15 -0
- package/dist/streamplace/chat/Embeds.svelte +135 -0
- package/dist/streamplace/chat/Embeds.svelte.d.ts +13 -0
- package/dist/streamplace/chat/Message.svelte +303 -0
- package/dist/streamplace/chat/Message.svelte.d.ts +25 -0
- package/dist/streamplace/chat/StreamChat.svelte +463 -0
- package/dist/streamplace/chat/StreamChat.svelte.d.ts +33 -0
- package/dist/streamplace/chat/StreamChatPopups.svelte +151 -0
- package/dist/streamplace/chat/StreamChatPopups.svelte.d.ts +15 -0
- package/dist/streamplace/chat/UserCard.svelte +76 -0
- package/dist/streamplace/chat/UserCard.svelte.d.ts +12 -0
- package/dist/streamplace/chat/color.d.ts +7 -0
- package/dist/streamplace/chat/color.js +33 -0
- package/dist/streamplace/chat/links.d.ts +10 -0
- package/dist/streamplace/chat/links.js +29 -0
- package/dist/streamplace/facets.d.ts +15 -0
- package/dist/streamplace/facets.js +112 -0
- package/dist/streamplace/link-embed.d.ts +13 -0
- package/dist/streamplace/link-embed.js +16 -0
- package/dist/streamplace/links.d.ts +6 -0
- package/dist/streamplace/links.js +1 -0
- package/dist/streamplace/reactions.d.ts +21 -0
- package/dist/streamplace/reactions.js +46 -0
- package/dist/streamplace/types.d.ts +200 -0
- package/dist/streamplace/types.js +1 -0
- package/dist/streamplace-data.d.ts +11 -0
- package/dist/streamplace-data.js +10 -0
- package/dist/streamplace.d.ts +14 -6
- package/dist/streamplace.js +11 -1
- package/dist/{events/event-view → video}/Player.svelte +69 -21
- package/dist/video/Player.svelte.d.ts +38 -0
- package/dist/video/engines.d.ts +59 -0
- package/dist/video/engines.js +647 -0
- package/package.json +11 -1
- package/dist/events/event-view/Player.svelte.d.ts +0 -24
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ pnpm dev
|
|
|
36
36
|
|
|
37
37
|
Browse `/components` for visual previews of every public component. Select one
|
|
38
38
|
for its interactive example at `/components/<name>`. The combined playgrounds
|
|
39
|
-
remain at `/`, `/examples`, `/navigation`, `/login`, and `/
|
|
39
|
+
remain at `/`, `/examples`, `/navigation`, `/login`, `/legal`, and `/data`.
|
|
40
40
|
|
|
41
41
|
Run `pnpm lint`, `pnpm check`, `pnpm test:ci`, and `pnpm build` to validate changes.
|
|
42
42
|
See [development](docs/development.md) for tests and package checks, and
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import ArticleCodeBlock from './ArticleCodeBlock.svelte';
|
|
10
10
|
import { formatArticleDate } from './dates.js';
|
|
11
11
|
import { articleCodeKey, articleMathKey } from './markdown.js';
|
|
12
|
+
import { sizedImage, type SizedImage } from '../media.js';
|
|
12
13
|
import type { ArticleSummary } from './records.js';
|
|
13
14
|
import { articleClass } from './styles.js';
|
|
14
15
|
|
|
@@ -35,11 +36,14 @@
|
|
|
35
36
|
content?: RichTextDocument;
|
|
36
37
|
/** Shown under the title: a description the author wrote. */
|
|
37
38
|
subtitle?: string;
|
|
38
|
-
/**
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The cover image: its address, or a `SizedImage` with its size (space is kept while it
|
|
41
|
+
* loads), a `srcset` and its priority.
|
|
42
|
+
*/
|
|
43
|
+
cover?: string | SizedImage;
|
|
40
44
|
author?: { name: string; avatar?: string; href?: string };
|
|
41
|
-
/** The address to load an uploaded image (`cid:` destination) from
|
|
42
|
-
imageSrc?: (url: string) => string | undefined;
|
|
45
|
+
/** The address to load an uploaded image (`cid:` destination) from, or a `SizedImage`. */
|
|
46
|
+
imageSrc?: (url: string) => string | SizedImage | undefined;
|
|
43
47
|
/**
|
|
44
48
|
* Highlighted markup of code blocks by `articleCodeKey`, inserted as is: only pass a
|
|
45
49
|
* highlighter's output. Blocks without an entry are shown plain.
|
|
@@ -66,13 +70,23 @@
|
|
|
66
70
|
} = $props();
|
|
67
71
|
|
|
68
72
|
let authorHref = $derived(safeLinkHref(author?.href));
|
|
73
|
+
// A plain address is shown as before; a `SizedImage` is checked like the text's images.
|
|
74
|
+
let coverImage = $derived<SizedImage | undefined>(
|
|
75
|
+
typeof cover === 'string' ? (cover ? { src: cover } : undefined) : sizedImage(cover)
|
|
76
|
+
);
|
|
69
77
|
</script>
|
|
70
78
|
|
|
71
79
|
<article class={cn('w-full', className)}>
|
|
72
|
-
{#if
|
|
73
|
-
src={
|
|
80
|
+
{#if coverImage}<img
|
|
81
|
+
src={coverImage.src}
|
|
82
|
+
srcset={coverImage.srcset}
|
|
83
|
+
sizes={coverImage.sizes}
|
|
84
|
+
width={coverImage.width}
|
|
85
|
+
height={coverImage.height}
|
|
74
86
|
alt=""
|
|
75
|
-
|
|
87
|
+
loading={coverImage.loading}
|
|
88
|
+
fetchpriority={coverImage.fetchpriority}
|
|
89
|
+
class="mb-8 h-auto max-h-[90dvh] w-full rounded-xl object-cover"
|
|
76
90
|
/>{/if}
|
|
77
91
|
{#if header}{@render header()}{/if}
|
|
78
92
|
<h1
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { LinkEmbed } from '../embeds/types.js';
|
|
3
3
|
import type { RichTextDocument } from '../richtext/document.js';
|
|
4
|
+
import { type SizedImage } from '../media.js';
|
|
4
5
|
import type { ArticleSummary } from './records.js';
|
|
5
6
|
type $$ComponentProps = {
|
|
6
7
|
article: Pick<ArticleSummary, 'title' | 'publishedAt'>;
|
|
@@ -8,15 +9,18 @@ type $$ComponentProps = {
|
|
|
8
9
|
content?: RichTextDocument;
|
|
9
10
|
/** Shown under the title: a description the author wrote. */
|
|
10
11
|
subtitle?: string;
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The cover image: its address, or a `SizedImage` with its size (space is kept while it
|
|
14
|
+
* loads), a `srcset` and its priority.
|
|
15
|
+
*/
|
|
16
|
+
cover?: string | SizedImage;
|
|
13
17
|
author?: {
|
|
14
18
|
name: string;
|
|
15
19
|
avatar?: string;
|
|
16
20
|
href?: string;
|
|
17
21
|
};
|
|
18
|
-
/** The address to load an uploaded image (`cid:` destination) from
|
|
19
|
-
imageSrc?: (url: string) => string | undefined;
|
|
22
|
+
/** The address to load an uploaded image (`cid:` destination) from, or a `SizedImage`. */
|
|
23
|
+
imageSrc?: (url: string) => string | SizedImage | undefined;
|
|
20
24
|
/**
|
|
21
25
|
* Highlighted markup of code blocks by `articleCodeKey`, inserted as is: only pass a
|
|
22
26
|
* highlighter's output. Blocks without an entry are shown plain.
|
package/dist/articles/styles.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Long-form typography, shared by the editor and the published article so that what is
|
|
3
3
|
* written is what will be shown. `!` because the components bring their own compact sizes.
|
|
4
|
-
* An image is never taller than the window, so that it can be seen whole.
|
|
4
|
+
* An image is never taller than the window, so that it can be seen whole. One with its size
|
|
5
|
+
* (`--atmo-image-ratio`) is narrowed to match, since a set width would otherwise stretch it.
|
|
5
6
|
* Nothing here reaches into an embed (`[data-link-embed]`), which brings its own headings
|
|
6
7
|
* and images. The classes are written out in full so that Tailwind finds them.
|
|
7
8
|
*/
|
|
8
|
-
const base = 'text-[1.0625rem] leading-[1.75]! space-y-5! [&_.ProseMirror]:space-y-5! [&_.ProseMirror]:leading-[1.75]! [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:tracking-tight [&_img:not([data-link-embed]_*)]:mx-auto [&_img:not([data-link-embed]_*)]:max-h-[90dvh] [&_pre:not([data-link-embed]_*)]:text-sm! [&_pre:not([data-link-embed]_*)]:leading-relaxed [&_table:not([data-link-embed]_*)]:text-[0.9375rem]';
|
|
9
|
+
const base = 'text-[1.0625rem] leading-[1.75]! space-y-5! [&_.ProseMirror]:space-y-5! [&_.ProseMirror]:leading-[1.75]! [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:tracking-tight [&_img:not([data-link-embed]_*)]:mx-auto [&_img:not([data-link-embed]_*)]:max-h-[90dvh] [&_img[style*=--atmo-image-ratio]:not([data-link-embed]_*)]:max-w-[min(100%,calc(90dvh*var(--atmo-image-ratio)))] [&_pre:not([data-link-embed]_*)]:text-sm! [&_pre:not([data-link-embed]_*)]:leading-relaxed [&_table:not([data-link-embed]_*)]:text-[0.9375rem]';
|
|
9
10
|
/** For `RichTextEditor markdown="article"`, where `#` is an h1. */
|
|
10
11
|
export const articleEditorClass = base +
|
|
11
12
|
' [&_h1:not([data-link-embed]_*)]:mt-10 [&_h1:not([data-link-embed]_*)]:text-3xl! [&_h2:not([data-link-embed]_*)]:mt-10 [&_h2:not([data-link-embed]_*)]:text-2xl! [&_h3:not([data-link-embed]_*)]:mt-8 [&_h3:not([data-link-embed]_*)]:text-xl! [&_h4:not([data-link-embed]_*)]:mt-6 [&_h4:not([data-link-embed]_*)]:text-lg!';
|
package/dist/articles-data.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { readPastedArticle, type PastedArticle } from './articles/paste.js';
|
|
|
5
5
|
export { prepareArticleImage } from './articles/images.js';
|
|
6
6
|
export { formatArticleDate } from './articles/dates.js';
|
|
7
7
|
export { articleClass, articleEditorClass } from './articles/styles.js';
|
|
8
|
+
export type { SizedImage } from './media.js';
|
|
8
9
|
export { accentColors, baseColors, isAccentColor, isBaseColor, type AccentColor, type BaseColor, type Palette } from './palettes.js';
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
import LinkEmbed from './LinkEmbed.svelte';
|
|
30
30
|
import { cn } from '../utils.js';
|
|
31
31
|
import { safeHttpUrl } from '../urls.js';
|
|
32
|
+
import { sizedImage, type SizedImage } from '../media.js';
|
|
32
33
|
|
|
33
34
|
export type RichTextProps = RichTextLinkOptions & {
|
|
34
35
|
/** From `parseRichText`, usually on the server. Takes precedence over `text`. */
|
|
@@ -58,8 +59,10 @@
|
|
|
58
59
|
/**
|
|
59
60
|
* The address to load an article's image from, for destinations that are not HTTP(S),
|
|
60
61
|
* e.g. an app's own scheme for uploaded files. Other images are shown as their description.
|
|
62
|
+
* Return a `SizedImage` to give the image its size (no layout shift when it loads), a
|
|
63
|
+
* `srcset` and how it loads.
|
|
61
64
|
*/
|
|
62
|
-
imageSrc?: (url: string) => string | undefined;
|
|
65
|
+
imageSrc?: (url: string) => string | SizedImage | undefined;
|
|
63
66
|
/** Renders a code block in place of the plain `<pre>`, e.g. with highlighting. */
|
|
64
67
|
codeBlock?: Snippet<[value: string, lang: string | undefined]>;
|
|
65
68
|
/**
|
|
@@ -133,14 +136,12 @@
|
|
|
133
136
|
? `text-align: ${value}`
|
|
134
137
|
: undefined;
|
|
135
138
|
}
|
|
136
|
-
function
|
|
139
|
+
function image(node: Node): SizedImage | undefined {
|
|
137
140
|
const url = string(node.url);
|
|
138
|
-
const resolved = safeHttpUrl(url) ?? (url ? imageSrc?.(url) : undefined);
|
|
139
141
|
// An app's own address is a path on its origin or HTTP(S), never a script.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
: safeHttpUrl(resolved);
|
|
142
|
+
return sizedImage(safeHttpUrl(url) ?? (url ? imageSrc?.(url) : undefined), {
|
|
143
|
+
loading: 'lazy'
|
|
144
|
+
});
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
function href(node: Node): string | undefined {
|
|
@@ -293,16 +294,32 @@
|
|
|
293
294
|
class="border-base-300 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))]"
|
|
294
295
|
/>
|
|
295
296
|
{:else if node.type === 'image'}
|
|
296
|
-
{@const source =
|
|
297
|
-
{
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
297
|
+
{@const source = image(node)}
|
|
298
|
+
{@const caption = string(node.title).trim()}
|
|
299
|
+
{#if source}
|
|
300
|
+
<figure>
|
|
301
|
+
<img
|
|
302
|
+
src={source.src}
|
|
303
|
+
srcset={source.srcset}
|
|
304
|
+
sizes={source.sizes}
|
|
305
|
+
width={source.width}
|
|
306
|
+
height={source.height}
|
|
307
|
+
style:--atmo-image-ratio={source.width && source.height
|
|
308
|
+
? source.width / source.height
|
|
309
|
+
: undefined}
|
|
310
|
+
alt={string(node.alt)}
|
|
311
|
+
loading={source.loading}
|
|
312
|
+
fetchpriority={source.fetchpriority}
|
|
313
|
+
decoding="async"
|
|
314
|
+
referrerpolicy="no-referrer"
|
|
315
|
+
class="mx-auto h-auto max-w-full rounded-md"
|
|
316
|
+
/>
|
|
317
|
+
{#if caption}
|
|
318
|
+
<figcaption class="mt-2 text-center text-sm text-base-600 dark:text-base-400">
|
|
319
|
+
{caption}
|
|
320
|
+
</figcaption>
|
|
321
|
+
{/if}
|
|
322
|
+
</figure>
|
|
306
323
|
{:else if string(node.alt)}<p>{string(node.alt)}</p>{/if}
|
|
307
324
|
{:else if node.type === 'table'}
|
|
308
325
|
{@const rows = cells(node.rows)}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import { type RichTextDocument, type RichTextLinkOptions } from '../richtext/document.js';
|
|
3
3
|
import type { LinkEmbed as LinkEmbedDefinition } from '../embeds/types.js';
|
|
4
|
+
import { type SizedImage } from '../media.js';
|
|
4
5
|
export type RichTextProps = RichTextLinkOptions & {
|
|
5
6
|
/** From `parseRichText`, usually on the server. Takes precedence over `text`. */
|
|
6
7
|
content?: RichTextDocument | null;
|
|
@@ -29,8 +30,10 @@ export type RichTextProps = RichTextLinkOptions & {
|
|
|
29
30
|
/**
|
|
30
31
|
* The address to load an article's image from, for destinations that are not HTTP(S),
|
|
31
32
|
* e.g. an app's own scheme for uploaded files. Other images are shown as their description.
|
|
33
|
+
* Return a `SizedImage` to give the image its size (no layout shift when it loads), a
|
|
34
|
+
* `srcset` and how it loads.
|
|
32
35
|
*/
|
|
33
|
-
imageSrc?: (url: string) => string | undefined;
|
|
36
|
+
imageSrc?: (url: string) => string | SizedImage | undefined;
|
|
34
37
|
/** Renders a code block in place of the plain `<pre>`, e.g. with highlighting. */
|
|
35
38
|
codeBlock?: Snippet<[value: string, lang: string | undefined]>;
|
|
36
39
|
/**
|
|
@@ -50,8 +50,6 @@
|
|
|
50
50
|
upload?: (file: File) => Promise<string>;
|
|
51
51
|
/** The address to load a destination from, for those that are not HTTP(S). */
|
|
52
52
|
src?: (url: string) => string | undefined;
|
|
53
|
-
/** Label of the description field below an image. */
|
|
54
|
-
altLabel?: string;
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
export type RichTextEditorProps = {
|
|
@@ -135,6 +133,42 @@
|
|
|
135
133
|
};
|
|
136
134
|
const imageSrc = (url: string) => safeHttpUrl(url) ?? images?.src?.(url);
|
|
137
135
|
|
|
136
|
+
/** The dialog for an image's description and caption, loaded when one is first opened. */
|
|
137
|
+
let ImageDialog = $state.raw<typeof import('../editor/ImageDialog.svelte').default>();
|
|
138
|
+
let imageOpen = $state(false);
|
|
139
|
+
/** The image the dialog is about. */
|
|
140
|
+
let image = $state.raw<{ position: number; url: string; alt: string; title: string }>();
|
|
141
|
+
|
|
142
|
+
function editImage(position: number): void {
|
|
143
|
+
if (!editor || editor.isDestroyed || !editor.isEditable) return;
|
|
144
|
+
if (position < 0 || position > editor.state.doc.content.size) return;
|
|
145
|
+
const node = editor.state.doc.nodeAt(position);
|
|
146
|
+
if (node?.type.name !== IMAGE) return;
|
|
147
|
+
editor.commands.setNodeSelection(position);
|
|
148
|
+
image = {
|
|
149
|
+
position,
|
|
150
|
+
url: String(node.attrs.url ?? ''),
|
|
151
|
+
alt: String(node.attrs.alt ?? ''),
|
|
152
|
+
title: String(node.attrs.title ?? '')
|
|
153
|
+
};
|
|
154
|
+
imageOpen = true;
|
|
155
|
+
if (!ImageDialog)
|
|
156
|
+
void import('../editor/ImageDialog.svelte').then(
|
|
157
|
+
(module) => (ImageDialog = module.default),
|
|
158
|
+
() => (imageOpen = false)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
/** Applies `change` to the image the dialog is about, if it is still where it was. */
|
|
162
|
+
function withImage(
|
|
163
|
+
change: (position: number, attrs: Record<string, unknown>, size: number) => void
|
|
164
|
+
): void {
|
|
165
|
+
if (!image || !editor || editor.isDestroyed || !editor.isEditable) return;
|
|
166
|
+
if (image.position < 0 || image.position > editor.state.doc.content.size) return;
|
|
167
|
+
const node = editor.state.doc.nodeAt(image.position);
|
|
168
|
+
if (node?.type.name !== IMAGE || node.attrs.url !== image.url) return;
|
|
169
|
+
change(image.position, node.attrs, node.nodeSize);
|
|
170
|
+
}
|
|
171
|
+
|
|
138
172
|
function load(text: string, textFacets?: unknown): JSONContent {
|
|
139
173
|
const document = markdownTools
|
|
140
174
|
? markdownTools.parseMarkdown(text, {
|
|
@@ -222,7 +256,7 @@
|
|
|
222
256
|
// The same look as `RichText`, so that what is typed is what will be shown.
|
|
223
257
|
// Nothing here reaches into an embed, which brings its own lists, links and code.
|
|
224
258
|
const markdownClass =
|
|
225
|
-
'space-y-3 leading-relaxed whitespace-pre-wrap [&_strong:not([data-link-embed]_*)]:font-semibold [&_h1:not([data-link-embed]_*)]:text-xl [&_h2:not([data-link-embed]_*)]:text-lg [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:leading-snug [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:font-semibold [&_blockquote:not([data-link-embed]_*)]:space-y-3 [&_blockquote:not([data-link-embed]_*)]:border-l-2 [&_blockquote:not([data-link-embed]_*)]:border-base-300 [&_blockquote:not([data-link-embed]_*)]:pl-4 dark:[&_blockquote:not([data-link-embed]_*)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_:is(ul,ol):not([data-link-embed]_*)]:space-y-1 [&_:is(ul,ol):not([data-link-embed]_*)]:pl-6 [&_ul:not([data-link-embed]_*)]:list-disc [&_ol:not([data-link-embed]_*)]:list-decimal [&_li:not([data-link-embed]_*)]:space-y-3 [&_:not(pre)>code:not([data-link-embed]_*)]:rounded [&_:not(pre)>code:not([data-link-embed]_*)]:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] [&_:not(pre)>code:not([data-link-embed]_*)]:px-1 [&_:not(pre)>code:not([data-link-embed]_*)]:py-0.5 [&_:not(pre)>code:not([data-link-embed]_*)]:font-mono [&_:not(pre)>code:not([data-link-embed]_*)]:text-[0.875em] dark:[&_:not(pre)>code:not([data-link-embed]_*)]:bg-base-950 [&_pre:not([data-link-embed]_*)]:overflow-x-auto [&_pre:not([data-link-embed]_*)]:rounded-md [&_pre:not([data-link-embed]_*)]:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] [&_pre:not([data-link-embed]_*)]:p-3 [&_pre:not([data-link-embed]_*)]:font-mono [&_pre:not([data-link-embed]_*)]:text-[0.875em] dark:[&_pre:not([data-link-embed]_*)]:bg-base-950 [&_hr:not([data-link-embed]_*)]:border-base-300 dark:[&_hr:not([data-link-embed]_*)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_a:not([data-link-embed]_*)]:text-accent-700 [&_a:not([data-link-embed]_*)]:underline [&_a:not([data-link-embed]_*)]:decoration-accent-700/40 [&_a:not([data-link-embed]_*)]:underline-offset-2 dark:[&_a:not([data-link-embed]_*)]:text-accent-300 dark:[&_a:not([data-link-embed]_*)]:decoration-accent-300/40 [&
|
|
259
|
+
'space-y-3 leading-relaxed whitespace-pre-wrap [&_strong:not([data-link-embed]_*)]:font-semibold [&_h1:not([data-link-embed]_*)]:text-xl [&_h2:not([data-link-embed]_*)]:text-lg [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:leading-snug [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:font-semibold [&_blockquote:not([data-link-embed]_*)]:space-y-3 [&_blockquote:not([data-link-embed]_*)]:border-l-2 [&_blockquote:not([data-link-embed]_*)]:border-base-300 [&_blockquote:not([data-link-embed]_*)]:pl-4 dark:[&_blockquote:not([data-link-embed]_*)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_:is(ul,ol):not([data-link-embed]_*)]:space-y-1 [&_:is(ul,ol):not([data-link-embed]_*)]:pl-6 [&_ul:not([data-link-embed]_*)]:list-disc [&_ol:not([data-link-embed]_*)]:list-decimal [&_li:not([data-link-embed]_*)]:space-y-3 [&_:not(pre)>code:not([data-link-embed]_*)]:rounded [&_:not(pre)>code:not([data-link-embed]_*)]:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] [&_:not(pre)>code:not([data-link-embed]_*)]:px-1 [&_:not(pre)>code:not([data-link-embed]_*)]:py-0.5 [&_:not(pre)>code:not([data-link-embed]_*)]:font-mono [&_:not(pre)>code:not([data-link-embed]_*)]:text-[0.875em] dark:[&_:not(pre)>code:not([data-link-embed]_*)]:bg-base-950 [&_pre:not([data-link-embed]_*)]:overflow-x-auto [&_pre:not([data-link-embed]_*)]:rounded-md [&_pre:not([data-link-embed]_*)]:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] [&_pre:not([data-link-embed]_*)]:p-3 [&_pre:not([data-link-embed]_*)]:font-mono [&_pre:not([data-link-embed]_*)]:text-[0.875em] dark:[&_pre:not([data-link-embed]_*)]:bg-base-950 [&_hr:not([data-link-embed]_*)]:border-base-300 dark:[&_hr:not([data-link-embed]_*)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_a:not([data-link-embed]_*)]:text-accent-700 [&_a:not([data-link-embed]_*)]:underline [&_a:not([data-link-embed]_*)]:decoration-accent-700/40 [&_a:not([data-link-embed]_*)]:underline-offset-2 dark:[&_a:not([data-link-embed]_*)]:text-accent-300 dark:[&_a:not([data-link-embed]_*)]:decoration-accent-300/40 [&[contenteditable=true]_[data-image]]:cursor-pointer [&_[data-image]]:whitespace-normal [&_[data-image]>img]:mx-auto [&_[data-image]>img]:max-w-full [&_[data-image]>img]:rounded-md [&_[data-image]>figcaption]:mt-2 [&_[data-image]>figcaption]:text-center [&_[data-image]>figcaption]:text-sm [&_[data-image]>figcaption]:text-base-600 dark:[&_[data-image]>figcaption]:text-base-400 [&_.tableWrapper]:overflow-x-auto [&_table]:border-collapse [&_table]:text-left [&_table]:whitespace-normal [&_:is(th,td)]:border [&_:is(th,td)]:border-base-300 [&_:is(th,td)]:px-3 [&_:is(th,td)]:py-1.5 [&_:is(th,td)]:align-top [&_:is(th,td)]:min-w-16 dark:[&_:is(th,td)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_th]:font-semibold [&_.selectedCell]:bg-accent-500/10';
|
|
226
260
|
// Task lists, math and footnotes of article Markdown.
|
|
227
261
|
const articleClass =
|
|
228
262
|
"[&_li[data-task]]:relative [&_li[data-task]]:list-none [&_li[data-task]]:before:absolute [&_li[data-task]]:before:-left-5 [&_li[data-task=false]]:before:content-['☐'] [&_li[data-task=true]]:before:content-['☑'] [&_ul[data-type=taskList]]:list-none! [&_ul[data-type=taskList]]:pl-0! [&_ul[data-type=taskList]>li]:flex [&_ul[data-type=taskList]>li]:gap-2 [&_ul[data-type=taskList]>li>label]:mt-0.5 [&_ul[data-type=taskList]>li>div]:min-w-0 [&_ul[data-type=taskList]>li>div]:flex-1 [&_ul[data-type=taskList]>li>div]:space-y-3 [&_ul[data-type=taskList]_input]:accent-accent-600 [&_[data-math]]:font-mono [&_[data-math]]:text-[0.875em] [&_[data-math]]:text-accent-700 [&_[data-math]]:before:content-['$'] [&_[data-math]]:after:content-['$'] [&_[data-math]]:before:opacity-50 [&_[data-math]]:after:opacity-50 dark:[&_[data-math]]:text-accent-300 [&_[data-footnote-ref]]:text-accent-700 dark:[&_[data-footnote-ref]]:text-accent-300 [&_[data-footnote]]:relative [&_[data-footnote]]:space-y-3 [&_[data-footnote]]:pl-10 [&_[data-footnote]]:text-[0.9em] [&_[data-footnote]]:before:absolute [&_[data-footnote]]:before:left-0 [&_[data-footnote]]:before:text-base-500 [&_[data-footnote]]:before:content-['['_attr(data-footnote)_']']";
|
|
@@ -242,14 +276,7 @@
|
|
|
242
276
|
...(markdownTools
|
|
243
277
|
? [
|
|
244
278
|
...markdownTools.markdownExtensions(article),
|
|
245
|
-
...(article
|
|
246
|
-
? [
|
|
247
|
-
ImageNode.configure({
|
|
248
|
-
src: imageSrc,
|
|
249
|
-
altLabel: images?.altLabel ?? 'Alt text'
|
|
250
|
-
})
|
|
251
|
-
]
|
|
252
|
-
: [])
|
|
279
|
+
...(article ? [ImageNode.configure({ src: imageSrc, edit: editImage })] : [])
|
|
253
280
|
]
|
|
254
281
|
: ([Document, Paragraph, Text, HardBreak, History] as AnyExtension[])),
|
|
255
282
|
Placeholder.configure({
|
|
@@ -377,12 +404,14 @@
|
|
|
377
404
|
if (editor && (value !== current || facetsKey !== currentFacets)) {
|
|
378
405
|
current = value;
|
|
379
406
|
currentFacets = facetsKey;
|
|
407
|
+
imageOpen = false;
|
|
380
408
|
editor.commands.setContent(load(value, facets), { emitUpdate: false });
|
|
381
409
|
}
|
|
382
410
|
});
|
|
383
411
|
$effect(() => {
|
|
384
412
|
editor?.setEditable(!disabled, false);
|
|
385
413
|
editor?.view.dom.setAttribute('aria-disabled', String(disabled));
|
|
414
|
+
if (disabled) imageOpen = false;
|
|
386
415
|
});
|
|
387
416
|
</script>
|
|
388
417
|
|
|
@@ -404,6 +433,33 @@
|
|
|
404
433
|
}}
|
|
405
434
|
>
|
|
406
435
|
<div bind:this={element}></div>
|
|
436
|
+
{#if ImageDialog && image}
|
|
437
|
+
<ImageDialog
|
|
438
|
+
bind:open={imageOpen}
|
|
439
|
+
src={imageSrc(image.url)}
|
|
440
|
+
alt={image.alt}
|
|
441
|
+
caption={image.title}
|
|
442
|
+
onCloseAutoFocus={(event) => {
|
|
443
|
+
if (editor && !editor.isDestroyed && editor.isEditable) {
|
|
444
|
+
event.preventDefault();
|
|
445
|
+
editor.commands.focus();
|
|
446
|
+
}
|
|
447
|
+
}}
|
|
448
|
+
onsave={({ alt, caption }) =>
|
|
449
|
+
withImage((position, attrs) =>
|
|
450
|
+
editor?.view.dispatch(
|
|
451
|
+
editor.state.tr.setNodeMarkup(position, undefined, { ...attrs, alt, title: caption })
|
|
452
|
+
)
|
|
453
|
+
)}
|
|
454
|
+
onremove={() =>
|
|
455
|
+
withImage((position, _attrs, size) =>
|
|
456
|
+
editor
|
|
457
|
+
?.chain()
|
|
458
|
+
.deleteRange({ from: position, to: position + size })
|
|
459
|
+
.run()
|
|
460
|
+
)}
|
|
461
|
+
/>
|
|
462
|
+
{/if}
|
|
407
463
|
{#if menuTools && editor && host}
|
|
408
464
|
<menuTools.EditorMenus {editor} context={commandContext} />
|
|
409
465
|
{#if images?.upload}
|
|
@@ -22,8 +22,6 @@ export type RichTextEditorImages = {
|
|
|
22
22
|
upload?: (file: File) => Promise<string>;
|
|
23
23
|
/** The address to load a destination from, for those that are not HTTP(S). */
|
|
24
24
|
src?: (url: string) => string | undefined;
|
|
25
|
-
/** Label of the description field below an image. */
|
|
26
|
-
altLabel?: string;
|
|
27
25
|
};
|
|
28
26
|
export type RichTextEditorProps = {
|
|
29
27
|
/** Markdown source with `markdown`, otherwise plain text. */
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import Button from './Button.svelte';
|
|
3
3
|
import Input from './Input.svelte';
|
|
4
4
|
import Modal from './Modal.svelte';
|
|
5
|
-
import { parseStreamplaceLink } from '../streamplace.js';
|
|
6
|
-
import type { StreamplaceSelection } from '../streamplace.js';
|
|
5
|
+
import { parseStreamplaceLink } from '../streamplace/links.js';
|
|
6
|
+
import type { StreamplaceSelection } from '../streamplace/links.js';
|
|
7
7
|
|
|
8
8
|
export type StreamplacePickerProps = {
|
|
9
9
|
open?: boolean;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
// Once loaded, later panels open without a loading state.
|
|
3
|
+
let loaded = false;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { muted } from '../../styles.js';
|
|
8
|
+
|
|
9
|
+
let { onselect }: { onselect: (emoji: string) => void } = $props();
|
|
10
|
+
|
|
11
|
+
// The picker and its emoji data are only fetched when a panel is first shown.
|
|
12
|
+
let ready = $state(loaded);
|
|
13
|
+
$effect(() => {
|
|
14
|
+
if (ready) return;
|
|
15
|
+
let current = true;
|
|
16
|
+
void import('emoji-picker-element').then(() => {
|
|
17
|
+
loaded = true;
|
|
18
|
+
if (current) ready = true;
|
|
19
|
+
});
|
|
20
|
+
return () => (current = false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function attach(node: HTMLElement) {
|
|
24
|
+
const pick = (event: Event) => {
|
|
25
|
+
const detail = (event as CustomEvent<{ unicode?: string }>).detail;
|
|
26
|
+
if (detail.unicode) onselect(detail.unicode);
|
|
27
|
+
};
|
|
28
|
+
node.addEventListener('emoji-click', pick);
|
|
29
|
+
return () => node.removeEventListener('emoji-click', pick);
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
{#if ready}
|
|
34
|
+
<emoji-picker
|
|
35
|
+
{@attach attach}
|
|
36
|
+
class="emoji [--button-active-background:var(--base-300)] [--button-hover-background:var(--base-200)] [--input-border-color:var(--base-300)] [--input-font-color:var(--base-950)] [--input-placeholder-color:var(--base-600)] dark:[--button-active-background:var(--base-700)] dark:[--button-hover-background:var(--base-800)] dark:[--input-border-color:var(--base-800)] dark:[--input-font-color:var(--base-50)] dark:[--input-placeholder-color:var(--base-400)]"
|
|
37
|
+
></emoji-picker>
|
|
38
|
+
{:else}
|
|
39
|
+
<div class="grid h-80 w-80 place-items-center text-sm {muted}">Loading…</div>
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
<style>
|
|
43
|
+
.emoji {
|
|
44
|
+
--background: transparent;
|
|
45
|
+
--border-size: 0;
|
|
46
|
+
--border-color: transparent;
|
|
47
|
+
--indicator-color: var(--accent-500);
|
|
48
|
+
--outline-color: var(--accent-500);
|
|
49
|
+
--num-columns: 8;
|
|
50
|
+
--emoji-size: 1.35rem;
|
|
51
|
+
width: 21rem;
|
|
52
|
+
height: 22rem;
|
|
53
|
+
max-width: calc(100vw - 2rem);
|
|
54
|
+
}
|
|
55
|
+
</style>
|
|
@@ -1,55 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Smile } from '@sketchyicons/svelte';
|
|
3
|
-
import { muted } from '../../styles.js';
|
|
4
3
|
import Icon from '../Icon.svelte';
|
|
5
4
|
import IconButton from '../IconButton.svelte';
|
|
6
5
|
import Popover from '../Popover.svelte';
|
|
6
|
+
import EmojiPanel from './EmojiPanel.svelte';
|
|
7
7
|
|
|
8
8
|
let { onselect, disabled = false }: { onselect: (emoji: string) => void; disabled?: boolean } =
|
|
9
9
|
$props();
|
|
10
10
|
|
|
11
11
|
let open = $state(false);
|
|
12
|
-
let ready = $state(false);
|
|
13
|
-
// The picker and its emoji data are only fetched when first opened.
|
|
14
|
-
$effect(() => {
|
|
15
|
-
if (open && !ready) void import('emoji-picker-element').then(() => (ready = true));
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
function attach(node: HTMLElement) {
|
|
19
|
-
const pick = (event: Event) => {
|
|
20
|
-
const detail = (event as CustomEvent<{ unicode?: string }>).detail;
|
|
21
|
-
if (detail.unicode) onselect(detail.unicode);
|
|
22
|
-
};
|
|
23
|
-
node.addEventListener('emoji-click', pick);
|
|
24
|
-
return () => node.removeEventListener('emoji-click', pick);
|
|
25
|
-
}
|
|
26
12
|
</script>
|
|
27
13
|
|
|
28
14
|
<Popover bind:open class="overflow-hidden p-0" align="start">
|
|
29
15
|
{#snippet trigger({ props })}
|
|
30
16
|
<IconButton {...props} label="Emoji" {disabled}><Icon img={Smile} /></IconButton>
|
|
31
17
|
{/snippet}
|
|
32
|
-
{
|
|
33
|
-
<emoji-picker
|
|
34
|
-
{@attach attach}
|
|
35
|
-
class="emoji [--button-active-background:var(--base-300)] [--button-hover-background:var(--base-200)] [--input-border-color:var(--base-300)] [--input-font-color:var(--base-950)] [--input-placeholder-color:var(--base-600)] dark:[--button-active-background:var(--base-700)] dark:[--button-hover-background:var(--base-800)] dark:[--input-border-color:var(--base-800)] dark:[--input-font-color:var(--base-50)] dark:[--input-placeholder-color:var(--base-400)]"
|
|
36
|
-
></emoji-picker>
|
|
37
|
-
{:else}
|
|
38
|
-
<div class="grid h-80 w-80 place-items-center text-sm {muted}">Loading…</div>
|
|
39
|
-
{/if}
|
|
18
|
+
<EmojiPanel {onselect} />
|
|
40
19
|
</Popover>
|
|
41
|
-
|
|
42
|
-
<style>
|
|
43
|
-
.emoji {
|
|
44
|
-
--background: transparent;
|
|
45
|
-
--border-size: 0;
|
|
46
|
-
--border-color: transparent;
|
|
47
|
-
--indicator-color: var(--accent-500);
|
|
48
|
-
--outline-color: var(--accent-500);
|
|
49
|
-
--num-columns: 8;
|
|
50
|
-
--emoji-size: 1.35rem;
|
|
51
|
-
width: 21rem;
|
|
52
|
-
height: 22rem;
|
|
53
|
-
max-width: calc(100vw - 2rem);
|
|
54
|
-
}
|
|
55
|
-
</style>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { DataLabelData } from './types.js';
|
|
4
|
+
export type DataLabelProps = Omit<HTMLAttributes<HTMLElement>, 'children' | 'title'> & {
|
|
5
|
+
label: DataLabelData;
|
|
6
|
+
/** Pass an empty string when the page already has a heading. */
|
|
7
|
+
title?: string;
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { Globe, Users, Server, MonitorSmartphone, type IconNode } from '@sketchyicons/svelte';
|
|
13
|
+
import Icon from '../Icon.svelte';
|
|
14
|
+
import { cn } from '../../utils.js';
|
|
15
|
+
import { focus } from '../../styles.js';
|
|
16
|
+
import { safeRemovalHref } from './issues.js';
|
|
17
|
+
import { dataVisibilityLevels } from './visibility.js';
|
|
18
|
+
import type { DataVisibility } from './types.js';
|
|
19
|
+
|
|
20
|
+
let { label, title = 'Your data', class: className, ...rest }: DataLabelProps = $props();
|
|
21
|
+
const uid = $props.id();
|
|
22
|
+
const icons: Record<DataVisibility, IconNode> = {
|
|
23
|
+
public: Globe,
|
|
24
|
+
space: Users,
|
|
25
|
+
app: Server,
|
|
26
|
+
device: MonitorSmartphone
|
|
27
|
+
};
|
|
28
|
+
const groups = $derived(
|
|
29
|
+
dataVisibilityLevels
|
|
30
|
+
.map((level) => ({
|
|
31
|
+
...level,
|
|
32
|
+
entries: label.entries.filter((entry) => entry.visibility === level.id)
|
|
33
|
+
}))
|
|
34
|
+
.filter((group) => group.entries.length)
|
|
35
|
+
);
|
|
36
|
+
const hasIcons = $derived(label.entries.some((entry) => entry.icon));
|
|
37
|
+
const removalLabel = $derived(label.removal?.label.trim() ?? '');
|
|
38
|
+
const removalHref = $derived(
|
|
39
|
+
removalLabel && label.removal ? safeRemovalHref(label.removal.href) : undefined
|
|
40
|
+
);
|
|
41
|
+
const removalExternal = $derived(!!removalHref && /^https?:/i.test(removalHref));
|
|
42
|
+
const muted = 'text-base-600 dark:text-base-400';
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<article
|
|
46
|
+
{...rest}
|
|
47
|
+
class={cn('mx-auto max-w-3xl px-6 py-10 text-sm text-base-950 dark:text-base-50', className)}
|
|
48
|
+
>
|
|
49
|
+
{#if title || label.withoutAccount}
|
|
50
|
+
<header class="mb-8">
|
|
51
|
+
{#if title}<h1 class="m-0 text-3xl font-semibold tracking-tight">{title}</h1>{/if}
|
|
52
|
+
{#if label.withoutAccount}
|
|
53
|
+
<p class={cn('leading-relaxed', muted, title && 'mt-3')}>{label.withoutAccount}</p>
|
|
54
|
+
{/if}
|
|
55
|
+
</header>
|
|
56
|
+
{/if}
|
|
57
|
+
<div class="space-y-10">
|
|
58
|
+
{#each groups as group (group.id)}
|
|
59
|
+
<section aria-labelledby={`${uid}-${group.id}`} data-visibility={group.id}>
|
|
60
|
+
<div
|
|
61
|
+
class="border-b border-base-300 pb-3 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))]"
|
|
62
|
+
>
|
|
63
|
+
<h2 id={`${uid}-${group.id}`} class="m-0 flex items-center gap-2 text-lg font-semibold">
|
|
64
|
+
<Icon
|
|
65
|
+
img={icons[group.id]}
|
|
66
|
+
size={20}
|
|
67
|
+
class={cn(
|
|
68
|
+
'shrink-0',
|
|
69
|
+
group.id === 'public' ? 'text-accent-700 dark:text-accent-300' : muted
|
|
70
|
+
)}
|
|
71
|
+
/>{group.label}
|
|
72
|
+
</h2>
|
|
73
|
+
<p class={cn('mt-1 leading-relaxed', muted)}>{group.description}</p>
|
|
74
|
+
</div>
|
|
75
|
+
<ul class="m-0 grid list-none gap-5 p-0 pt-5">
|
|
76
|
+
{#each group.entries as entry, index (index)}
|
|
77
|
+
<li class="flex items-start gap-3">
|
|
78
|
+
{#if hasIcons}
|
|
79
|
+
<span class="mt-0.5 flex size-5 shrink-0 justify-center">
|
|
80
|
+
{#if entry.icon}<Icon img={entry.icon} size={20} class={muted} />{/if}
|
|
81
|
+
</span>
|
|
82
|
+
{/if}
|
|
83
|
+
<div class="min-w-0 flex-1 space-y-1 wrap-anywhere">
|
|
84
|
+
<p class="leading-snug font-medium">
|
|
85
|
+
{entry.action}{#if entry.optional}<span class={cn('font-normal', muted)}
|
|
86
|
+
> (optional)</span
|
|
87
|
+
>{/if}
|
|
88
|
+
</p>
|
|
89
|
+
<p class={cn('leading-relaxed', muted)}>{entry.saves}</p>
|
|
90
|
+
{#if entry.note}<p class="leading-relaxed">{entry.note}</p>{/if}
|
|
91
|
+
{#if entry.collection}
|
|
92
|
+
<p class={cn('font-mono text-xs break-all', muted)}>{entry.collection}</p>
|
|
93
|
+
{/if}
|
|
94
|
+
</div>
|
|
95
|
+
</li>
|
|
96
|
+
{/each}
|
|
97
|
+
</ul>
|
|
98
|
+
</section>
|
|
99
|
+
{/each}
|
|
100
|
+
</div>
|
|
101
|
+
{#if removalHref || label.updated}
|
|
102
|
+
<footer class={cn('mt-10 space-y-2', muted)}>
|
|
103
|
+
{#if removalHref}
|
|
104
|
+
<p>
|
|
105
|
+
<a
|
|
106
|
+
href={removalHref}
|
|
107
|
+
rel={removalExternal ? 'noopener noreferrer' : undefined}
|
|
108
|
+
class={cn(
|
|
109
|
+
'rounded text-base-950 underline underline-offset-4 dark:text-base-50',
|
|
110
|
+
focus
|
|
111
|
+
)}>{removalLabel}</a
|
|
112
|
+
>
|
|
113
|
+
</p>
|
|
114
|
+
{/if}
|
|
115
|
+
{#if label.updated}
|
|
116
|
+
<p>Last updated: <time datetime={label.updated}>{label.updated}</time></p>
|
|
117
|
+
{/if}
|
|
118
|
+
</footer>
|
|
119
|
+
{/if}
|
|
120
|
+
</article>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { DataLabelData } from './types.js';
|
|
3
|
+
export type DataLabelProps = Omit<HTMLAttributes<HTMLElement>, 'children' | 'title'> & {
|
|
4
|
+
label: DataLabelData;
|
|
5
|
+
/** Pass an empty string when the page already has a heading. */
|
|
6
|
+
title?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const DataLabel: import("svelte").Component<DataLabelProps, {}, "">;
|
|
9
|
+
type DataLabel = ReturnType<typeof DataLabel>;
|
|
10
|
+
export default DataLabel;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DataLabelData } from './types.js';
|
|
2
|
+
/** Same-page fragment anchors are allowed alongside paths, web URLs and mailto links. */
|
|
3
|
+
export declare function safeRemovalHref(value: string): string | undefined;
|
|
4
|
+
/** Completeness checks only. They cannot tell whether the label matches what the app does. */
|
|
5
|
+
export declare function getDataLabelIssues(label: DataLabelData): string[];
|