@atmo-dev/kit 0.14.0 → 0.15.1
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/dist/components/ExternalEmbed.svelte +30 -29
- package/dist/components/ExternalEmbed.svelte.d.ts +8 -0
- package/dist/components/InlineEditor.svelte +15 -95
- package/dist/components/InlineEditor.svelte.d.ts +1 -1
- package/dist/components/LinkCard.svelte +54 -25
- package/dist/components/LinkCard.svelte.d.ts +2 -0
- package/dist/components/LinkEmbed.svelte +75 -0
- package/dist/components/LinkEmbed.svelte.d.ts +13 -0
- package/dist/components/PostContent.svelte +12 -3
- package/dist/components/PostContent.svelte.d.ts +3 -0
- package/dist/components/RichText.svelte +47 -5
- package/dist/components/RichText.svelte.d.ts +5 -2
- package/dist/components/RichTextEditor.svelte +272 -0
- package/dist/components/RichTextEditor.svelte.d.ts +44 -0
- package/dist/components/composer/AltText.svelte +63 -0
- package/dist/components/composer/AltText.svelte.d.ts +11 -0
- package/dist/components/composer/CharRing.svelte +39 -0
- package/dist/components/composer/CharRing.svelte.d.ts +7 -0
- package/dist/components/composer/ComposerPost.svelte +321 -0
- package/dist/components/composer/ComposerPost.svelte.d.ts +29 -0
- package/dist/components/composer/Drafts.svelte +82 -0
- package/dist/components/composer/Drafts.svelte.d.ts +9 -0
- package/dist/components/composer/EmojiPicker.svelte +55 -0
- package/dist/components/composer/EmojiPicker.svelte.d.ts +7 -0
- package/dist/components/composer/GifPicker.svelte +118 -0
- package/dist/components/composer/GifPicker.svelte.d.ts +11 -0
- package/dist/components/composer/PostComposer.svelte +599 -0
- package/dist/components/composer/PostComposer.svelte.d.ts +71 -0
- package/dist/components/composer/PostComposerDialog.svelte +75 -0
- package/dist/components/composer/PostComposerDialog.svelte.d.ts +10 -0
- package/dist/components/composer/ReplySettings.svelte +150 -0
- package/dist/components/composer/ReplySettings.svelte.d.ts +18 -0
- package/dist/components/login/search.d.ts +29 -1
- package/dist/components/login/search.js +31 -3
- package/dist/editor/EditorLinkEmbed.svelte +35 -0
- package/dist/editor/EditorLinkEmbed.svelte.d.ts +12 -0
- package/dist/editor/detect-plugin.d.ts +5 -0
- package/dist/editor/detect-plugin.js +51 -0
- package/dist/editor/document.d.ts +17 -0
- package/dist/editor/document.js +269 -0
- package/dist/editor/link-embed-node.d.ts +17 -0
- package/dist/editor/link-embed-node.js +96 -0
- package/dist/editor/markdown-extensions.d.ts +6 -0
- package/dist/editor/markdown-extensions.js +42 -0
- package/dist/editor/markdown.d.ts +3 -0
- package/dist/editor/markdown.js +4 -0
- package/dist/embeds/PlayerLinkEmbed.svelte +9 -0
- package/dist/embeds/PlayerLinkEmbed.svelte.d.ts +7 -0
- package/dist/{events/event-view → embeds}/PostLinkEmbed.svelte +7 -7
- package/dist/{events/event-view → embeds}/PostLinkEmbed.svelte.d.ts +1 -1
- package/dist/{events/event-view → embeds}/ProfileLinkEmbed.svelte +7 -7
- package/dist/{events/event-view → embeds}/ProfileLinkEmbed.svelte.d.ts +1 -1
- package/dist/embeds/context.d.ts +10 -0
- package/dist/embeds/context.js +20 -0
- package/dist/embeds/defaults.d.ts +27 -0
- package/dist/embeds/defaults.js +38 -0
- package/dist/embeds/resolve.d.ts +9 -0
- package/dist/embeds/resolve.js +27 -0
- package/dist/embeds/types.d.ts +39 -0
- package/dist/embeds/types.js +1 -0
- package/dist/events/EventEditor.svelte +29 -6
- package/dist/events/EventView.svelte +21 -38
- package/dist/events/PostToBlueskyModal.svelte +12 -4
- package/dist/events/event-link-embed.d.ts +22 -0
- package/dist/events/event-link-embed.js +15 -0
- package/dist/events/event-view/EventLinkEmbed.svelte +12 -30
- package/dist/events/event-view/EventLinkEmbed.svelte.d.ts +3 -12
- package/dist/events.d.ts +2 -0
- package/dist/events.js +1 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +10 -2
- package/dist/richtext/detect.js +1 -1
- package/dist/richtext/document.d.ts +10 -0
- package/dist/richtext/document.js +44 -4
- package/dist/richtext/markdown.js +9 -8
- package/dist/richtext/serialize.d.ts +11 -0
- package/dist/richtext/serialize.js +462 -0
- package/dist/richtext/vendor/markdown-tree.d.ts +5 -0
- package/dist/richtext/vendor/markdown-tree.js +11032 -0
- package/dist/richtext.d.ts +1 -0
- package/dist/richtext.js +1 -0
- package/dist/social/MentionOptions.svelte +30 -0
- package/dist/social/MentionOptions.svelte.d.ts +12 -0
- package/dist/social/composer.d.ts +143 -0
- package/dist/social/composer.js +141 -0
- package/dist/social/{mention-suggestions.d.ts → mention-suggestions.svelte.d.ts} +1 -1
- package/dist/social/{mention-suggestions.js → mention-suggestions.svelte.js} +36 -46
- package/dist/social/richtext.js +2 -0
- package/dist/social.d.ts +2 -0
- package/dist/social.js +1 -0
- package/dist/styles.d.ts +5 -0
- package/dist/styles.js +5 -0
- package/package.json +8 -4
- package/dist/components/PostComposer.svelte +0 -41
- package/dist/components/PostComposer.svelte.d.ts +0 -16
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { safeHttpUrl } from '../urls.js';
|
|
2
|
+
/** The first embed that can render this link. Syntax only; nothing is fetched. */
|
|
3
|
+
export function resolveLinkEmbed(value, embeds) {
|
|
4
|
+
const href = safeHttpUrl(value);
|
|
5
|
+
if (!href)
|
|
6
|
+
return null;
|
|
7
|
+
const url = new URL(href);
|
|
8
|
+
if (url.port || url.username || url.password)
|
|
9
|
+
return null;
|
|
10
|
+
for (const embed of embeds) {
|
|
11
|
+
let ref;
|
|
12
|
+
try {
|
|
13
|
+
ref = embed.match(new URL(url));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (ref !== null && ref !== undefined)
|
|
19
|
+
return { embed, ref, url: href };
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
export function isClickToLoad(embed, clickToLoad) {
|
|
24
|
+
if (embed.requests === 'click')
|
|
25
|
+
return false;
|
|
26
|
+
return typeof clickToLoad === 'function' ? clickToLoad(embed) : !!clickToLoad;
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
import type { PreferredSocialClient } from '../social/preferred-client.js';
|
|
3
|
+
export type LinkEmbedProps<Ref = unknown> = {
|
|
4
|
+
url: string;
|
|
5
|
+
/** What `match` extracted from the link. */
|
|
6
|
+
ref: Ref;
|
|
7
|
+
/** The ordinary link. Render it until the content has loaded and whenever it can't be shown. */
|
|
8
|
+
fallback: Snippet;
|
|
9
|
+
socialClient?: PreferredSocialClient | null;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A richer rendering for links to a particular kind of page or record. Matching uses the URL
|
|
13
|
+
* alone and performs no network IO, so it is safe on the server and for untrusted text.
|
|
14
|
+
*/
|
|
15
|
+
export type LinkEmbed<Ref = any> = {
|
|
16
|
+
id: string;
|
|
17
|
+
/** Names the content in a load button, e.g. "Bluesky post". */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Trusted app-owned code. Return a reference when this embed can render the link, otherwise null. */
|
|
20
|
+
match: (url: URL) => Ref | null;
|
|
21
|
+
/** Loaded on first use, so an embed costs nothing until one is on screen. */
|
|
22
|
+
load: () => Promise<{
|
|
23
|
+
default: Component<LinkEmbedProps<Ref>>;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* When the embed contacts other servers: as soon as it is shown (the default), or only
|
|
27
|
+
* after its own play or load button is clicked, as video players do.
|
|
28
|
+
*/
|
|
29
|
+
requests?: 'mount' | 'click';
|
|
30
|
+
};
|
|
31
|
+
export type LinkEmbedOptions = {
|
|
32
|
+
/** Ordered; the first match wins. Defaults to `defaultLinkEmbeds`. */
|
|
33
|
+
embeds?: readonly LinkEmbed[];
|
|
34
|
+
/**
|
|
35
|
+
* Put embeds that load on mount behind a load button. Embeds with their own play button
|
|
36
|
+
* are never gated twice.
|
|
37
|
+
*/
|
|
38
|
+
clickToLoad?: boolean | ((embed: LinkEmbed) => boolean);
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import { getEventThumbnail } from './event-media.js';
|
|
4
4
|
import { Avatar, Button, ToggleGroup, ToggleGroupItem } from '../index.js';
|
|
5
5
|
import { onMount, untrack } from 'svelte';
|
|
6
|
-
import { InlineEditor, type Editor } from '../index.js';
|
|
6
|
+
import { InlineEditor, RichTextEditor, type Editor } from '../index.js';
|
|
7
|
+
import { linkEmbedOptions, selectLinkEmbeds } from '../embeds/context.js';
|
|
8
|
+
import { eventLinkEmbed } from './event-link-embed.js';
|
|
7
9
|
import DateTimePicker from '../components/DateTimePicker.svelte';
|
|
8
10
|
import TimezonePicker from '../components/TimezonePicker.svelte';
|
|
9
11
|
import { parseDateTime } from '@internationalized/date';
|
|
@@ -95,6 +97,25 @@
|
|
|
95
97
|
initialThumbnailFile ? null : eventData === null ? DEFAULT_PRESET : null
|
|
96
98
|
);
|
|
97
99
|
let images = $derived(adapter.features.images !== false);
|
|
100
|
+
const embedOptions = linkEmbedOptions();
|
|
101
|
+
/** As on the event page: the app's embeds, plus cards for links to other events. */
|
|
102
|
+
let descriptionEmbeds = $derived.by(() => {
|
|
103
|
+
const loadEvent = adapter.linkedRecords?.getEvent;
|
|
104
|
+
const origin = globalThis.location?.origin;
|
|
105
|
+
return [
|
|
106
|
+
...(loadEvent
|
|
107
|
+
? [
|
|
108
|
+
eventLinkEmbed({
|
|
109
|
+
loadEvent,
|
|
110
|
+
origins: [...new Set(['https://atmo.rsvp', ...(origin ? [origin] : [])])],
|
|
111
|
+
skip: (link) =>
|
|
112
|
+
link.rkey === rkey && (link.actor === actorDid || link.actor === viewer.handle)
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
: []),
|
|
116
|
+
...selectLinkEmbeds(true, embedOptions())
|
|
117
|
+
];
|
|
118
|
+
});
|
|
98
119
|
let showVisibility = $derived(adapter.features.visibility !== false);
|
|
99
120
|
let submitting = $state(false);
|
|
100
121
|
let error: string | null = $state(null);
|
|
@@ -435,13 +456,15 @@
|
|
|
435
456
|
>
|
|
436
457
|
About
|
|
437
458
|
</p>
|
|
438
|
-
<
|
|
439
|
-
|
|
459
|
+
<RichTextEditor
|
|
460
|
+
label="Event description"
|
|
440
461
|
bind:value={description}
|
|
441
|
-
|
|
462
|
+
markdown
|
|
463
|
+
embeds={descriptionEmbeds}
|
|
464
|
+
socialClient={viewer.preferredSocialClient}
|
|
442
465
|
placeholder="What's this event about? @mentions, #hashtags and links will be detected automatically."
|
|
443
|
-
class="
|
|
444
|
-
|
|
466
|
+
class="min-h-24 leading-relaxed text-base-700 focus-within:outline-none dark:text-base-300"
|
|
467
|
+
/>
|
|
445
468
|
<p class="mt-2 text-xs text-base-600 dark:text-base-400">
|
|
446
469
|
Add a hashtag like <span class="font-medium">#webdev</span> or
|
|
447
470
|
<span class="font-medium">#music</span>
|
|
@@ -28,19 +28,12 @@
|
|
|
28
28
|
import EventHostedBy from './event-view/EventHostedBy.svelte';
|
|
29
29
|
import EventLinksList from './event-view/EventLinksList.svelte';
|
|
30
30
|
import { GrainAlbumView, SembleCollectionView } from '../index.js';
|
|
31
|
-
import {
|
|
32
|
-
eventStreamLink,
|
|
33
|
-
eventTabLink,
|
|
34
|
-
parseEventLink,
|
|
35
|
-
parseSembleLink
|
|
36
|
-
} from './linked-records.js';
|
|
31
|
+
import { eventStreamLink, eventTabLink, parseSembleLink } from './linked-records.js';
|
|
37
32
|
import AddToCalendarButton from './event-view/AddToCalendarButton.svelte';
|
|
38
33
|
import ExternalRsvpNotice from './event-view/ExternalRsvpNotice.svelte';
|
|
39
34
|
import RichText from '../components/RichText.svelte';
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import ProfileLinkEmbed from './event-view/ProfileLinkEmbed.svelte';
|
|
43
|
-
import { parseSocialPostUrl, parseSocialProfileUrl } from '../social/urls.js';
|
|
35
|
+
import { linkEmbedOptions, selectLinkEmbeds } from '../embeds/context.js';
|
|
36
|
+
import { eventLinkEmbed } from './event-link-embed.js';
|
|
44
37
|
import { richTextToPlainText } from '../richtext/document.js';
|
|
45
38
|
import { resolveEventUrls } from './urls.js';
|
|
46
39
|
import { getLocations, resolveGeoLocation, type GeoLocation } from './event-view/locations.js';
|
|
@@ -164,13 +157,22 @@
|
|
|
164
157
|
// Event links are recognized on the canonical site and on this page's own origin.
|
|
165
158
|
let eventOrigins = $derived([...new Set(['https://atmo.rsvp', pageUrl.origin])]);
|
|
166
159
|
let loadEvent = $derived(adapter.linkedRecords?.getEvent);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
const embedOptions = linkEmbedOptions();
|
|
161
|
+
/** The app's embeds, plus cards for links to other events when the host can load them. */
|
|
162
|
+
let descriptionEmbeds = $derived([
|
|
163
|
+
...(loadEvent
|
|
164
|
+
? [
|
|
165
|
+
eventLinkEmbed({
|
|
166
|
+
loadEvent,
|
|
167
|
+
origins: eventOrigins,
|
|
168
|
+
local: !embedMode,
|
|
169
|
+
skip: (link) =>
|
|
170
|
+
link.rkey === rkey && (link.actor === did || link.actor === hostProfile?.handle)
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
: []),
|
|
174
|
+
...selectLinkEmbeds(true, embedOptions())
|
|
175
|
+
]);
|
|
174
176
|
let photosOpened = $state(false);
|
|
175
177
|
let collectionsOpened = $state(false);
|
|
176
178
|
$effect(() => {
|
|
@@ -482,28 +484,9 @@
|
|
|
482
484
|
socialClient={viewer.preferredSocialClient}
|
|
483
485
|
detectLinks
|
|
484
486
|
headingOffset={1}
|
|
485
|
-
|
|
486
|
-
!!parseSocialPostUrl(url) || !!parseSocialProfileUrl(url) || otherEvent(url)}
|
|
487
|
+
embeds={descriptionEmbeds}
|
|
487
488
|
class="text-base-700 dark:text-base-300"
|
|
488
|
-
|
|
489
|
-
{#snippet linkEmbed(url, fallback)}
|
|
490
|
-
{#if loadEvent && otherEvent(url)}<EventLinkEmbed
|
|
491
|
-
{url}
|
|
492
|
-
origins={eventOrigins}
|
|
493
|
-
local={!embedMode}
|
|
494
|
-
{loadEvent}
|
|
495
|
-
{fallback}
|
|
496
|
-
/>{:else if parseSocialProfileUrl(url)}<ProfileLinkEmbed
|
|
497
|
-
{url}
|
|
498
|
-
{fallback}
|
|
499
|
-
socialClient={viewer.preferredSocialClient}
|
|
500
|
-
/>{:else}<PostLinkEmbed
|
|
501
|
-
{url}
|
|
502
|
-
{fallback}
|
|
503
|
-
socialClient={viewer.preferredSocialClient}
|
|
504
|
-
/>{/if}
|
|
505
|
-
{/snippet}
|
|
506
|
-
</RichText>
|
|
489
|
+
/>
|
|
507
490
|
{:else if activeTab === 'comments' && eventData.bskyPostRef?.uri}
|
|
508
491
|
<EventComments
|
|
509
492
|
postUri={eventData.bskyPostRef.uri}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
Button,
|
|
5
5
|
Checkbox,
|
|
6
6
|
Label,
|
|
7
|
-
|
|
7
|
+
InlineEditor,
|
|
8
|
+
CharRing,
|
|
8
9
|
editorJsonToBlueskyPost,
|
|
9
10
|
createActorSearch,
|
|
10
11
|
LinkCard,
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
graphemeLength,
|
|
13
14
|
type Editor
|
|
14
15
|
} from '../index.js';
|
|
16
|
+
import { configuredActorSearch } from '../components/login/search.js';
|
|
15
17
|
import { detectTokens } from '../richtext/detect.js';
|
|
16
18
|
import { tokensToFacets } from './editor/save.js';
|
|
17
19
|
import { appviewUrl } from './atproto-helpers.js';
|
|
@@ -45,7 +47,10 @@
|
|
|
45
47
|
onPosted?: (ref: { uri: string; cid: string; showComments: boolean }) => void;
|
|
46
48
|
} = $props();
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
// The app's account search if it chose one, otherwise the configured AppView.
|
|
51
|
+
const searchActors = createActorSearch({
|
|
52
|
+
host: configuredActorSearch() ? undefined : appviewUrl()
|
|
53
|
+
});
|
|
49
54
|
let text = $state('');
|
|
50
55
|
let editor = $state<Editor | null>(null);
|
|
51
56
|
let prefilledForOpen = $state(false);
|
|
@@ -203,13 +208,16 @@
|
|
|
203
208
|
<div
|
|
204
209
|
class="space-y-3 rounded-xl border border-base-200 bg-base-50 p-3 dark:border-base-800 dark:bg-base-950/30"
|
|
205
210
|
>
|
|
206
|
-
<
|
|
211
|
+
<InlineEditor
|
|
207
212
|
bind:editor
|
|
208
213
|
bind:value={text}
|
|
214
|
+
label="Post text"
|
|
215
|
+
placeholder="What’s happening?"
|
|
209
216
|
{searchActors}
|
|
210
217
|
disabled={posting}
|
|
211
|
-
|
|
218
|
+
class="min-h-24 text-sm leading-relaxed"
|
|
212
219
|
/>
|
|
220
|
+
<div class="flex justify-end"><CharRing length={graphemeLength(text)} max={300} /></div>
|
|
213
221
|
<LinkCard
|
|
214
222
|
href={eventUrl}
|
|
215
223
|
meta={{
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LinkEmbed } from '../embeds/types.js';
|
|
2
|
+
import { type LinkedRecordsClient } from './linked-records.js';
|
|
3
|
+
export type EventLinkEmbedRef = {
|
|
4
|
+
actor: string;
|
|
5
|
+
rkey: string;
|
|
6
|
+
path: string;
|
|
7
|
+
local: boolean;
|
|
8
|
+
loadEvent: NonNullable<LinkedRecordsClient['getEvent']>;
|
|
9
|
+
};
|
|
10
|
+
/** Links to event pages on the given origins, shown as event cards. */
|
|
11
|
+
export declare function eventLinkEmbed(options: {
|
|
12
|
+
loadEvent: NonNullable<LinkedRecordsClient['getEvent']>;
|
|
13
|
+
/** Defaults to atmo.rsvp. */
|
|
14
|
+
origins?: readonly string[];
|
|
15
|
+
/** Whether this app serves event pages itself; otherwise the card opens the linked URL. */
|
|
16
|
+
local?: boolean;
|
|
17
|
+
/** Leave some event links as ordinary links, e.g. the event being shown. */
|
|
18
|
+
skip?: (link: {
|
|
19
|
+
actor: string;
|
|
20
|
+
rkey: string;
|
|
21
|
+
}) => boolean;
|
|
22
|
+
}): LinkEmbed<EventLinkEmbedRef>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { parseEventLink } from './linked-records.js';
|
|
2
|
+
/** Links to event pages on the given origins, shown as event cards. */
|
|
3
|
+
export function eventLinkEmbed(options) {
|
|
4
|
+
return {
|
|
5
|
+
id: 'event',
|
|
6
|
+
label: 'event',
|
|
7
|
+
match(url) {
|
|
8
|
+
const link = parseEventLink(url.href, options.origins);
|
|
9
|
+
return link && !options.skip?.(link)
|
|
10
|
+
? { ...link, local: !!options.local, loadEvent: options.loadEvent }
|
|
11
|
+
: null;
|
|
12
|
+
},
|
|
13
|
+
load: () => import('./event-view/EventLinkEmbed.svelte')
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,49 +1,31 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
2
|
import Surface from '../../components/Surface.svelte';
|
|
3
|
+
import type { LinkEmbedProps } from '../../embeds/types.js';
|
|
4
4
|
import EventCard from '../EventCard.svelte';
|
|
5
5
|
import type { FlatEventRecord } from '../contrail.js';
|
|
6
|
-
import {
|
|
6
|
+
import type { EventLinkEmbedRef } from '../event-link-embed.js';
|
|
7
7
|
|
|
8
|
-
let {
|
|
9
|
-
url,
|
|
10
|
-
origins,
|
|
11
|
-
local,
|
|
12
|
-
loadEvent,
|
|
13
|
-
fallback
|
|
14
|
-
}: {
|
|
15
|
-
url: string;
|
|
16
|
-
origins: readonly string[];
|
|
17
|
-
/** Whether this app serves event pages itself; otherwise the card opens the linked URL. */
|
|
18
|
-
local: boolean;
|
|
19
|
-
loadEvent: NonNullable<LinkedRecordsClient['getEvent']>;
|
|
20
|
-
/** The ordinary link, shown until the event loads and whenever it can't be shown. */
|
|
21
|
-
fallback: Snippet;
|
|
22
|
-
} = $props();
|
|
8
|
+
let { url, ref, fallback }: LinkEmbedProps<EventLinkEmbedRef> = $props();
|
|
23
9
|
|
|
24
|
-
let ref = $derived(parseEventLink(url, origins));
|
|
25
10
|
let event = $state<FlatEventRecord | null>(null);
|
|
26
11
|
$effect(() => {
|
|
27
|
-
const
|
|
28
|
-
const transport = loadEvent;
|
|
12
|
+
const { actor, rkey, loadEvent } = ref;
|
|
29
13
|
let current = true;
|
|
30
14
|
event = null;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.catch(() => {});
|
|
38
|
-
}
|
|
15
|
+
void Promise.resolve()
|
|
16
|
+
.then(() => loadEvent(actor, rkey))
|
|
17
|
+
.then((result) => {
|
|
18
|
+
if (current && result?.rkey === rkey && result.startsAt) event = result;
|
|
19
|
+
})
|
|
20
|
+
.catch(() => {});
|
|
39
21
|
return () => {
|
|
40
22
|
current = false;
|
|
41
23
|
};
|
|
42
24
|
});
|
|
43
25
|
</script>
|
|
44
26
|
|
|
45
|
-
{#if event
|
|
27
|
+
{#if event}
|
|
46
28
|
<Surface class="p-4"
|
|
47
|
-
><EventCard {event} actor={ref.actor} href={local ? ref.path : url} /></Surface
|
|
29
|
+
><EventCard {event} actor={ref.actor} href={ref.local ? ref.path : url} /></Surface
|
|
48
30
|
>
|
|
49
31
|
{:else}{@render fallback()}{/if}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
url: string;
|
|
5
|
-
origins: readonly string[];
|
|
6
|
-
/** Whether this app serves event pages itself; otherwise the card opens the linked URL. */
|
|
7
|
-
local: boolean;
|
|
8
|
-
loadEvent: NonNullable<LinkedRecordsClient['getEvent']>;
|
|
9
|
-
/** The ordinary link, shown until the event loads and whenever it can't be shown. */
|
|
10
|
-
fallback: Snippet;
|
|
11
|
-
};
|
|
12
|
-
declare const EventLinkEmbed: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
1
|
+
import type { LinkEmbedProps } from '../../embeds/types.js';
|
|
2
|
+
import type { EventLinkEmbedRef } from '../event-link-embed.js';
|
|
3
|
+
declare const EventLinkEmbed: import("svelte").Component<LinkEmbedProps<EventLinkEmbedRef>, {}, "">;
|
|
13
4
|
type EventLinkEmbed = ReturnType<typeof EventLinkEmbed>;
|
|
14
5
|
export default EventLinkEmbed;
|
package/dist/events.d.ts
CHANGED
|
@@ -18,3 +18,5 @@ export { default as TimePicker } from './components/TimePicker.svelte';
|
|
|
18
18
|
export { default as DateTimePicker } from './components/DateTimePicker.svelte';
|
|
19
19
|
export { default as TimezonePicker } from './components/TimezonePicker.svelte';
|
|
20
20
|
export { default as ImageDropper } from './components/ImageDropper.svelte';
|
|
21
|
+
export { eventLinkEmbed } from './events/event-link-embed.js';
|
|
22
|
+
export type { EventLinkEmbedRef } from './events/event-link-embed.js';
|
package/dist/events.js
CHANGED
|
@@ -16,3 +16,4 @@ export { default as TimePicker } from './components/TimePicker.svelte';
|
|
|
16
16
|
export { default as DateTimePicker } from './components/DateTimePicker.svelte';
|
|
17
17
|
export { default as TimezonePicker } from './components/TimezonePicker.svelte';
|
|
18
18
|
export { default as ImageDropper } from './components/ImageDropper.svelte';
|
|
19
|
+
export { eventLinkEmbed } from './events/event-link-embed.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,8 @@ export type { SignupPermissionsProps } from './components/login/SignupPermission
|
|
|
74
74
|
export { default as ActorSearchField } from './components/login/ActorSearchField.svelte';
|
|
75
75
|
export { default as RecentAccounts } from './components/login/RecentAccounts.svelte';
|
|
76
76
|
export type { ActorSummary, ActorSearch, LoginCallback, LoginResult, LoginPermission, LoginOptions, LoginStep } from './components/login/types.js';
|
|
77
|
-
export { createActorSearch } from './components/login/search.js';
|
|
77
|
+
export { createActorSearch, configureActorSearch, actorSearchProviders } from './components/login/search.js';
|
|
78
|
+
export type { ActorSearchProvider } from './components/login/search.js';
|
|
78
79
|
export { normalizeHandle, isValidHandle, normalizeIdentifier, isValidIdentifier } from './components/login/handle.js';
|
|
79
80
|
export { resolveLoginOptions, isPermissionSelected } from './components/login/permissions.js';
|
|
80
81
|
export { loadRecentAccounts, writeRecentAccounts, saveRecentAccount, removeRecentAccount, RECENT_ACCOUNTS_STORAGE_KEY } from './components/login/recent-accounts.js';
|
|
@@ -84,7 +85,14 @@ export { default as ToggleGroupItem } from './components/ToggleGroupItem.svelte'
|
|
|
84
85
|
export { default as Popover } from './components/Popover.svelte';
|
|
85
86
|
export { default as LinkCard } from './components/LinkCard.svelte';
|
|
86
87
|
export { default as InlineEditor } from './components/InlineEditor.svelte';
|
|
87
|
-
export { default as
|
|
88
|
+
export { default as RichTextEditor } from './components/RichTextEditor.svelte';
|
|
89
|
+
export type { RichTextEditorProps, RichTextEditorContent } from './components/RichTextEditor.svelte';
|
|
90
|
+
export { default as PostComposer } from './components/composer/PostComposer.svelte';
|
|
91
|
+
export type { PostComposerProps } from './components/composer/PostComposer.svelte';
|
|
92
|
+
export { default as PostComposerDialog } from './components/composer/PostComposerDialog.svelte';
|
|
93
|
+
export { default as CharRing } from './components/composer/CharRing.svelte';
|
|
94
|
+
export { blueskyGifSearch, blueskyLinkPreview, defaultComposerLimits, defaultComposerLanguages, defaultContentWarnings } from './social/composer.js';
|
|
95
|
+
export type { ComposerContent, ComposerPost, ComposerImage, ComposerVideo, ComposerGif, ComposerLink, ComposerReplyRule, ComposerLimits, ComposerFeatures, ComposerLabels, ComposerGifSearch, ComposerGifResult, ComposerLinkPreview, ComposerDrafts, ComposerDraftSummary, ComposerContentWarning } from './social/composer.js';
|
|
88
96
|
export { default as NestedComments } from './components/NestedComments.svelte';
|
|
89
97
|
export { default as PostContent } from './components/PostContent.svelte';
|
|
90
98
|
export { safeHttpUrl, safeLinkHref } from './urls.js';
|
|
@@ -92,6 +100,12 @@ export { default as RichText } from './components/RichText.svelte';
|
|
|
92
100
|
export type { RichTextProps } from './components/RichText.svelte';
|
|
93
101
|
export type { RichTextDocument, RichTextLinkOptions } from './richtext/document.js';
|
|
94
102
|
export { default as ExternalEmbed } from './components/ExternalEmbed.svelte';
|
|
103
|
+
export { default as LinkEmbed } from './components/LinkEmbed.svelte';
|
|
104
|
+
export type { LinkEmbedComponentProps } from './components/LinkEmbed.svelte';
|
|
105
|
+
export { defaultLinkEmbeds, postLinkEmbed, profileLinkEmbed, youtubeLinkEmbed, klipyLinkEmbed, playerLinkEmbed } from './embeds/defaults.js';
|
|
106
|
+
export { resolveLinkEmbed } from './embeds/resolve.js';
|
|
107
|
+
export { setLinkEmbeds } from './embeds/context.js';
|
|
108
|
+
export type { LinkEmbed as LinkEmbedDefinition, LinkEmbedProps, LinkEmbedOptions } from './embeds/types.js';
|
|
95
109
|
export { defaultExternalEmbedProviders, youtubeEmbedProvider, klipyEmbedProvider, resolveExternalEmbed } from './social/external-embeds.js';
|
|
96
110
|
export type { ExternalPostEmbed, ExternalEmbedProvider, ExternalEmbedPlayer } from './social/external-embeds.js';
|
|
97
111
|
export { blueskyPostToPostData, hasModerationLabel } from './social/posts.js';
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ export { default as LoginDialog } from './components/login/LoginDialog.svelte';
|
|
|
48
48
|
export { default as SignupPermissions } from './components/login/SignupPermissions.svelte';
|
|
49
49
|
export { default as ActorSearchField } from './components/login/ActorSearchField.svelte';
|
|
50
50
|
export { default as RecentAccounts } from './components/login/RecentAccounts.svelte';
|
|
51
|
-
export { createActorSearch } from './components/login/search.js';
|
|
51
|
+
export { createActorSearch, configureActorSearch, actorSearchProviders } from './components/login/search.js';
|
|
52
52
|
export { normalizeHandle, isValidHandle, normalizeIdentifier, isValidIdentifier } from './components/login/handle.js';
|
|
53
53
|
export { resolveLoginOptions, isPermissionSelected } from './components/login/permissions.js';
|
|
54
54
|
export { loadRecentAccounts, writeRecentAccounts, saveRecentAccount, removeRecentAccount, RECENT_ACCOUNTS_STORAGE_KEY } from './components/login/recent-accounts.js';
|
|
@@ -57,12 +57,20 @@ export { default as ToggleGroupItem } from './components/ToggleGroupItem.svelte'
|
|
|
57
57
|
export { default as Popover } from './components/Popover.svelte';
|
|
58
58
|
export { default as LinkCard } from './components/LinkCard.svelte';
|
|
59
59
|
export { default as InlineEditor } from './components/InlineEditor.svelte';
|
|
60
|
-
export { default as
|
|
60
|
+
export { default as RichTextEditor } from './components/RichTextEditor.svelte';
|
|
61
|
+
export { default as PostComposer } from './components/composer/PostComposer.svelte';
|
|
62
|
+
export { default as PostComposerDialog } from './components/composer/PostComposerDialog.svelte';
|
|
63
|
+
export { default as CharRing } from './components/composer/CharRing.svelte';
|
|
64
|
+
export { blueskyGifSearch, blueskyLinkPreview, defaultComposerLimits, defaultComposerLanguages, defaultContentWarnings } from './social/composer.js';
|
|
61
65
|
export { default as NestedComments } from './components/NestedComments.svelte';
|
|
62
66
|
export { default as PostContent } from './components/PostContent.svelte';
|
|
63
67
|
export { safeHttpUrl, safeLinkHref } from './urls.js';
|
|
64
68
|
export { default as RichText } from './components/RichText.svelte';
|
|
65
69
|
export { default as ExternalEmbed } from './components/ExternalEmbed.svelte';
|
|
70
|
+
export { default as LinkEmbed } from './components/LinkEmbed.svelte';
|
|
71
|
+
export { defaultLinkEmbeds, postLinkEmbed, profileLinkEmbed, youtubeLinkEmbed, klipyLinkEmbed, playerLinkEmbed } from './embeds/defaults.js';
|
|
72
|
+
export { resolveLinkEmbed } from './embeds/resolve.js';
|
|
73
|
+
export { setLinkEmbeds } from './embeds/context.js';
|
|
66
74
|
export { defaultExternalEmbedProviders, youtubeEmbedProvider, klipyEmbedProvider, resolveExternalEmbed } from './social/external-embeds.js';
|
|
67
75
|
export { blueskyPostToPostData, hasModerationLabel } from './social/posts.js';
|
|
68
76
|
export { parseSocialPostUrl, parseSocialProfileUrl } from './social/urls.js';
|
package/dist/richtext/detect.js
CHANGED
|
@@ -9,7 +9,7 @@ const ESCAPE_RE = /\\[^0-9A-Za-z\s]/y;
|
|
|
9
9
|
const BOUNDARY_RE = /[\s(){}/\\[\]\-|:;'".,=+*_~`]/;
|
|
10
10
|
function trimAutolink(url) {
|
|
11
11
|
let end = url.length;
|
|
12
|
-
while (end > 0 && '
|
|
12
|
+
while (end > 0 && '.,;>'.includes(url[end - 1]))
|
|
13
13
|
end--;
|
|
14
14
|
if (end > 0 && url[end - 1] === ')' && url.lastIndexOf('(', end - 1) === -1)
|
|
15
15
|
end--;
|
|
@@ -29,6 +29,7 @@ export type RichTextBlock = {
|
|
|
29
29
|
} | {
|
|
30
30
|
type: 'codeBlock';
|
|
31
31
|
value: string;
|
|
32
|
+
lang?: string;
|
|
32
33
|
} | {
|
|
33
34
|
type: 'thematicBreak';
|
|
34
35
|
};
|
|
@@ -72,11 +73,20 @@ export type ParagraphPart = {
|
|
|
72
73
|
children: Record<string, unknown>[];
|
|
73
74
|
embed?: string;
|
|
74
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Whether a link's label is its own destination, as for a pasted or detected URL. Clients also
|
|
78
|
+
* shorten such labels (`example.com/a-long-pa…`) and drop the scheme.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isBareLink(link: Record<string, unknown>): boolean;
|
|
81
|
+
/** Plain text keeps its newlines inside text nodes; make them explicit breaks. */
|
|
82
|
+
export declare function lineBreaks(children: unknown): Record<string, unknown>[];
|
|
75
83
|
/**
|
|
76
84
|
* Split a paragraph into runs of lines, so that a bare link alone on its line can be shown as
|
|
77
85
|
* an embed. Labeled links and links inside a sentence stay ordinary links.
|
|
78
86
|
*/
|
|
79
87
|
export declare function paragraphParts(children: unknown, isEmbed?: (url: string) => boolean): ParagraphPart[];
|
|
88
|
+
/** Blank lines next to an embed are already expressed by the space around it. */
|
|
89
|
+
export declare function trimBreaks(children: Record<string, unknown>[]): Record<string, unknown>[];
|
|
80
90
|
/** Documents from the parser nest far less; deeper (tampered) nodes are cut off. */
|
|
81
91
|
export declare const MAX_RENDER_DEPTH = 32;
|
|
82
92
|
/** Text content of any node, including unknown ones. */
|
|
@@ -46,6 +46,39 @@ function nodes(value) {
|
|
|
46
46
|
function string(value) {
|
|
47
47
|
return typeof value === 'string' ? value : '';
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether a link's label is its own destination, as for a pasted or detected URL. Clients also
|
|
51
|
+
* shorten such labels (`example.com/a-long-pa…`) and drop the scheme.
|
|
52
|
+
*/
|
|
53
|
+
export function isBareLink(link) {
|
|
54
|
+
const label = nodes(link.children);
|
|
55
|
+
const url = safeWebUrl(link.url);
|
|
56
|
+
if (!url || label.length !== 1 || label[0].type !== 'text')
|
|
57
|
+
return false;
|
|
58
|
+
const text = string(label[0].value).trim();
|
|
59
|
+
if (!text || /\s/.test(text))
|
|
60
|
+
return false;
|
|
61
|
+
if (text === link.url || safeWebUrl(text) === url)
|
|
62
|
+
return true;
|
|
63
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(text) && !/^https?:\/\//i.test(text))
|
|
64
|
+
return false;
|
|
65
|
+
const shortened = text.replace(/^https?:\/\//i, '').replace(/(?:…|\.\.\.)$/, '');
|
|
66
|
+
const target = url.replace(/^https?:\/\//i, '');
|
|
67
|
+
return shortened.includes('.') && shortened.length >= 4 && shortened !== text
|
|
68
|
+
? target.startsWith(shortened) || safeWebUrl(`https://${shortened}`) === url
|
|
69
|
+
: safeWebUrl(`https://${text}`) === url;
|
|
70
|
+
}
|
|
71
|
+
/** Plain text keeps its newlines inside text nodes; make them explicit breaks. */
|
|
72
|
+
export function lineBreaks(children) {
|
|
73
|
+
return nodes(children).flatMap((node) => node.type === 'text' && string(node.value).includes('\n')
|
|
74
|
+
? string(node.value)
|
|
75
|
+
.split('\n')
|
|
76
|
+
.flatMap((value, index) => [
|
|
77
|
+
...(index ? [{ type: 'break' }] : []),
|
|
78
|
+
...(value ? [{ type: 'text', value }] : [])
|
|
79
|
+
])
|
|
80
|
+
: [node]);
|
|
81
|
+
}
|
|
49
82
|
/**
|
|
50
83
|
* Split a paragraph into runs of lines, so that a bare link alone on its line can be shown as
|
|
51
84
|
* an embed. Labeled links and links inside a sentence stay ordinary links.
|
|
@@ -63,10 +96,7 @@ export function paragraphParts(children, isEmbed) {
|
|
|
63
96
|
const line = all.slice(start, end);
|
|
64
97
|
const content = line.filter((node) => node.type !== 'text' || string(node.value).trim());
|
|
65
98
|
const link = content.length === 1 && content[0].type === 'link' ? content[0] : undefined;
|
|
66
|
-
const
|
|
67
|
-
const url = link && label?.length === 1 && label[0].type === 'text' && label[0].value === link.url
|
|
68
|
-
? safeWebUrl(link.url)
|
|
69
|
-
: undefined;
|
|
99
|
+
const url = link && isBareLink(link) ? safeWebUrl(link.url) : undefined;
|
|
70
100
|
if (url && isEmbed(url)) {
|
|
71
101
|
parts.push({ children: line, embed: url });
|
|
72
102
|
text = undefined;
|
|
@@ -81,6 +111,16 @@ export function paragraphParts(children, isEmbed) {
|
|
|
81
111
|
}
|
|
82
112
|
return parts;
|
|
83
113
|
}
|
|
114
|
+
/** Blank lines next to an embed are already expressed by the space around it. */
|
|
115
|
+
export function trimBreaks(children) {
|
|
116
|
+
let start = 0;
|
|
117
|
+
let end = children.length;
|
|
118
|
+
while (start < end && children[start].type === 'break')
|
|
119
|
+
start++;
|
|
120
|
+
while (end > start && children[end - 1].type === 'break')
|
|
121
|
+
end--;
|
|
122
|
+
return children.slice(start, end);
|
|
123
|
+
}
|
|
84
124
|
/** Documents from the parser nest far less; deeper (tampered) nodes are cut off. */
|
|
85
125
|
export const MAX_RENDER_DEPTH = 32;
|
|
86
126
|
/** Text content of any node, including unknown ones. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
// The parser is bundled into the kit. Its packages' development builds need bundler setup in
|
|
2
|
+
// every app (they import CommonJS), and this is the same production build everywhere.
|
|
3
|
+
import { markdownTree } from './vendor/markdown-tree.js';
|
|
4
4
|
import { safeWebUrl } from './document.js';
|
|
5
5
|
import { applyRanges, detectLinks, hasFacets, resolveFacets } from './facets.js';
|
|
6
6
|
import { parsePlainText } from './plain.js';
|
|
@@ -184,7 +184,11 @@ function blocks(nodes, context, depth) {
|
|
|
184
184
|
});
|
|
185
185
|
break;
|
|
186
186
|
case 'code':
|
|
187
|
-
result.push({
|
|
187
|
+
result.push({
|
|
188
|
+
type: 'codeBlock',
|
|
189
|
+
value: node.value,
|
|
190
|
+
...(node.lang ? { lang: node.lang } : {})
|
|
191
|
+
});
|
|
188
192
|
break;
|
|
189
193
|
case 'thematicBreak':
|
|
190
194
|
result.push({ type: 'thematicBreak' });
|
|
@@ -220,10 +224,7 @@ function collectDefinitions(node, definitions, depth = 0) {
|
|
|
220
224
|
export function parseMarkdown(text, options = {}) {
|
|
221
225
|
if (exceedsMarkdownLimits(text))
|
|
222
226
|
return parsePlainText(text, options);
|
|
223
|
-
const tree =
|
|
224
|
-
extensions: [gfmStrikethrough({ singleTilde: false })],
|
|
225
|
-
mdastExtensions: [gfmStrikethroughFromMarkdown()]
|
|
226
|
-
});
|
|
227
|
+
const tree = markdownTree(text);
|
|
227
228
|
const definitions = new Map();
|
|
228
229
|
collectDefinitions(tree, definitions);
|
|
229
230
|
const context = {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type RichTextDocument } from './document.js';
|
|
2
|
+
/**
|
|
3
|
+
* A document as Markdown that `parseRichText(text, { markdown: true })` reads back as the same
|
|
4
|
+
* document. Only characters that would otherwise be syntax are escaped, so plain links,
|
|
5
|
+
* mentions and hashtags stay detectable in the source. Mentions and hashtags are written as
|
|
6
|
+
* their text; a link labeled with its own URL is written as that URL. Output that fails to
|
|
7
|
+
* read back (unusual punctuation next to formatting) is escaped more heavily instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare function richTextToMarkdown(content: RichTextDocument): string;
|
|
10
|
+
/** Whether two documents render the same, ignoring how links, mentions and tags were found. */
|
|
11
|
+
export declare function sameRichText(a: RichTextDocument, b: RichTextDocument): boolean;
|