@atmo-dev/kit 0.13.2 → 0.15.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/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/NestedComments.svelte +205 -52
- package/dist/components/NestedComments.svelte.d.ts +49 -6
- package/dist/components/PostContent.svelte +26 -25
- package/dist/components/PostContent.svelte.d.ts +3 -0
- package/dist/components/PostImages.svelte +85 -0
- package/dist/components/PostImages.svelte.d.ts +9 -0
- package/dist/components/PostVideo.svelte +16 -2
- package/dist/components/PostVideo.svelte.d.ts +4 -0
- package/dist/components/RichText.svelte +47 -5
- package/dist/components/RichText.svelte.d.ts +5 -2
- package/dist/components/RichTextEditor.svelte +271 -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/EventComments.svelte +5 -5
- package/dist/events/EventEditor.svelte +7 -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 +5 -1
- package/dist/richtext/serialize.d.ts +11 -0
- package/dist/richtext/serialize.js +462 -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/posts.d.ts +10 -0
- package/dist/social/posts.js +5 -1
- 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 +4 -1
- package/dist/components/PostComposer.svelte +0 -41
- package/dist/components/PostComposer.svelte.d.ts +0 -16
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { browserLanguage } from '../../social/composer.js';
|
|
3
|
+
import Modal from '../Modal.svelte';
|
|
4
|
+
import PostComposer, { type PostComposerProps } from './PostComposer.svelte';
|
|
5
|
+
|
|
6
|
+
// The composer in a dialog that fills small screens and stays above the on-screen keyboard.
|
|
7
|
+
let {
|
|
8
|
+
open = $bindable(false),
|
|
9
|
+
title,
|
|
10
|
+
languages = $bindable([browserLanguage()]),
|
|
11
|
+
replyRules = $bindable(),
|
|
12
|
+
allowQuotes = $bindable(true),
|
|
13
|
+
onsubmit,
|
|
14
|
+
oncancel,
|
|
15
|
+
...rest
|
|
16
|
+
}: PostComposerProps & { open?: boolean; title?: string } = $props();
|
|
17
|
+
|
|
18
|
+
let composer = $state<PostComposer>();
|
|
19
|
+
/** Attach files to the post being written; does nothing while closed. */
|
|
20
|
+
export function addFiles(files: Iterable<File>) {
|
|
21
|
+
return composer?.addFiles(files);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// An on-screen keyboard covers the bottom of the page without resizing it. Fit the
|
|
25
|
+
// full-screen composer to what is actually visible, so its toolbar sits on the keyboard.
|
|
26
|
+
let visible = $state<{ top: number; height: number; keyboard: boolean }>();
|
|
27
|
+
$effect(() => {
|
|
28
|
+
const viewport = window.visualViewport;
|
|
29
|
+
if (!open || !viewport) return;
|
|
30
|
+
const measure = () =>
|
|
31
|
+
(visible = {
|
|
32
|
+
top: viewport.offsetTop,
|
|
33
|
+
height: viewport.height,
|
|
34
|
+
keyboard: innerHeight - viewport.height > 120
|
|
35
|
+
});
|
|
36
|
+
measure();
|
|
37
|
+
viewport.addEventListener('resize', measure);
|
|
38
|
+
viewport.addEventListener('scroll', measure);
|
|
39
|
+
return () => {
|
|
40
|
+
viewport.removeEventListener('resize', measure);
|
|
41
|
+
viewport.removeEventListener('scroll', measure);
|
|
42
|
+
visible = undefined;
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<Modal
|
|
48
|
+
bind:open
|
|
49
|
+
title={title ?? (rest.replyTo ? 'Reply' : rest.quote ? 'Quote post' : 'New post')}
|
|
50
|
+
dismissible={false}
|
|
51
|
+
class="flex max-h-[min(46rem,calc(100dvh-3rem))] max-w-[38rem] flex-col overflow-hidden p-0 max-sm:top-(--composer-top,0px) max-sm:left-0 max-sm:h-(--composer-height,100dvh) max-sm:max-h-none max-sm:w-full max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-none max-sm:border-0 max-sm:pt-[env(safe-area-inset-top)] {visible?.keyboard
|
|
52
|
+
? ''
|
|
53
|
+
: 'max-sm:pb-[env(safe-area-inset-bottom)]'} sm:p-0 [&>header]:hidden"
|
|
54
|
+
style={visible
|
|
55
|
+
? `--composer-top: ${visible.top}px; --composer-height: ${visible.height}px`
|
|
56
|
+
: undefined}
|
|
57
|
+
onOpenAutoFocus={(event) => event.preventDefault()}
|
|
58
|
+
>
|
|
59
|
+
<PostComposer
|
|
60
|
+
bind:this={composer}
|
|
61
|
+
autofocus
|
|
62
|
+
{...rest}
|
|
63
|
+
bind:languages
|
|
64
|
+
bind:replyRules
|
|
65
|
+
bind:allowQuotes
|
|
66
|
+
onsubmit={async (content, status) => {
|
|
67
|
+
await onsubmit(content, status);
|
|
68
|
+
open = false;
|
|
69
|
+
}}
|
|
70
|
+
oncancel={() => {
|
|
71
|
+
open = false;
|
|
72
|
+
oncancel?.();
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
</Modal>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PostComposerProps } from './PostComposer.svelte';
|
|
2
|
+
type $$ComponentProps = PostComposerProps & {
|
|
3
|
+
open?: boolean;
|
|
4
|
+
title?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const PostComposerDialog: import("svelte").Component<$$ComponentProps, {
|
|
7
|
+
addFiles: (files: Iterable<File>) => Promise<void> | undefined;
|
|
8
|
+
}, "open" | "allowQuotes" | "languages" | "replyRules">;
|
|
9
|
+
type PostComposerDialog = ReturnType<typeof PostComposerDialog>;
|
|
10
|
+
export default PostComposerDialog;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComposerReplyRule } from '../../social/composer.js';
|
|
3
|
+
import { line } from '../../styles.js';
|
|
4
|
+
import Button from '../Button.svelte';
|
|
5
|
+
import Checkbox from '../Checkbox.svelte';
|
|
6
|
+
import Modal from '../Modal.svelte';
|
|
7
|
+
import Subheading from '../Subheading.svelte';
|
|
8
|
+
|
|
9
|
+
type List = { uri: string; name: string };
|
|
10
|
+
let {
|
|
11
|
+
open = $bindable(false),
|
|
12
|
+
rules = $bindable<ComposerReplyRule[] | undefined>(),
|
|
13
|
+
allowQuotes = $bindable(true),
|
|
14
|
+
reply = false,
|
|
15
|
+
lists: listSource,
|
|
16
|
+
onsavedefault
|
|
17
|
+
}: {
|
|
18
|
+
open?: boolean;
|
|
19
|
+
rules?: ComposerReplyRule[];
|
|
20
|
+
allowQuotes?: boolean;
|
|
21
|
+
/** Reply rules belong to the thread's first post; replies only choose quoting. */
|
|
22
|
+
reply?: boolean;
|
|
23
|
+
/** Lists whose members may reply. */
|
|
24
|
+
lists?: List[] | (() => Promise<List[]>);
|
|
25
|
+
onsavedefault?: (rules: ComposerReplyRule[] | undefined, allowQuotes: boolean) => Promise<void>;
|
|
26
|
+
} = $props();
|
|
27
|
+
|
|
28
|
+
type Mode = 'everyone' | 'nobody' | 'some';
|
|
29
|
+
let mode = $state<Mode>('everyone');
|
|
30
|
+
let picked = $state<Record<string, boolean>>({});
|
|
31
|
+
let quotes = $state(true);
|
|
32
|
+
let loaded = $state.raw<List[]>();
|
|
33
|
+
let lists = $derived(Array.isArray(listSource) ? listSource : (loaded ?? []));
|
|
34
|
+
let saving = $state(false);
|
|
35
|
+
let error = $state('');
|
|
36
|
+
|
|
37
|
+
let wasOpen = false;
|
|
38
|
+
$effect(() => {
|
|
39
|
+
if (open && !wasOpen) {
|
|
40
|
+
mode = !rules ? 'everyone' : rules.length ? 'some' : 'nobody';
|
|
41
|
+
picked = Object.fromEntries(
|
|
42
|
+
(rules ?? []).map((r) => [r.type === 'list' ? r.list : r.type, true])
|
|
43
|
+
);
|
|
44
|
+
quotes = allowQuotes;
|
|
45
|
+
error = '';
|
|
46
|
+
if (!reply && !loaded && typeof listSource === 'function')
|
|
47
|
+
void listSource()
|
|
48
|
+
.then((result) => (loaded = result))
|
|
49
|
+
.catch(() => {});
|
|
50
|
+
}
|
|
51
|
+
wasOpen = open;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const groups = [
|
|
55
|
+
{ id: 'mention', label: 'People you mention' },
|
|
56
|
+
{ id: 'follower', label: 'Your followers' },
|
|
57
|
+
{ id: 'following', label: 'People you follow' }
|
|
58
|
+
] as const;
|
|
59
|
+
|
|
60
|
+
function result(): ComposerReplyRule[] | undefined {
|
|
61
|
+
if (mode === 'everyone') return undefined;
|
|
62
|
+
if (mode === 'nobody') return [];
|
|
63
|
+
const chosen: ComposerReplyRule[] = [
|
|
64
|
+
...groups.filter((g) => picked[g.id]).map((g) => ({ type: g.id })),
|
|
65
|
+
...lists.filter((l) => picked[l.uri]).map((l) => ({ type: 'list' as const, list: l.uri }))
|
|
66
|
+
];
|
|
67
|
+
return chosen.slice(0, 5);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function apply() {
|
|
71
|
+
if (!reply) rules = result();
|
|
72
|
+
allowQuotes = quotes;
|
|
73
|
+
open = false;
|
|
74
|
+
}
|
|
75
|
+
async function saveDefault() {
|
|
76
|
+
if (!onsavedefault) return;
|
|
77
|
+
saving = true;
|
|
78
|
+
error = '';
|
|
79
|
+
try {
|
|
80
|
+
await onsavedefault(result(), quotes);
|
|
81
|
+
apply();
|
|
82
|
+
} catch (e) {
|
|
83
|
+
error = e instanceof Error ? e.message : 'Could not save';
|
|
84
|
+
} finally {
|
|
85
|
+
saving = false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<Modal bind:open title="Post interactions" class="max-w-md">
|
|
91
|
+
<div class="grid gap-6">
|
|
92
|
+
{#if !reply}
|
|
93
|
+
<section>
|
|
94
|
+
<Subheading>Who can reply</Subheading>
|
|
95
|
+
<div class="mt-2.5 grid gap-2" role="radiogroup" aria-label="Who can reply">
|
|
96
|
+
{#each [['everyone', 'Anyone'], ['some', 'Some people'], ['nobody', 'Nobody']] as [value, label] (value)}
|
|
97
|
+
<label
|
|
98
|
+
class="flex cursor-pointer items-center gap-3 rounded-ui border px-3.5 py-3 text-sm has-checked:border-accent-500 has-checked:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:has-checked:border-accent-500 dark:has-checked:bg-base-950 {line}"
|
|
99
|
+
>
|
|
100
|
+
<input
|
|
101
|
+
type="radio"
|
|
102
|
+
name="reply-mode"
|
|
103
|
+
{value}
|
|
104
|
+
bind:group={mode}
|
|
105
|
+
class="accent-accent-500"
|
|
106
|
+
/>
|
|
107
|
+
{label}
|
|
108
|
+
</label>
|
|
109
|
+
{/each}
|
|
110
|
+
</div>
|
|
111
|
+
{#if mode === 'some'}
|
|
112
|
+
<div class="mt-3 grid gap-1 pl-1">
|
|
113
|
+
{#each groups as group (group.id)}
|
|
114
|
+
<label class="flex cursor-pointer items-center gap-3 py-1.5 text-sm">
|
|
115
|
+
<Checkbox
|
|
116
|
+
checked={!!picked[group.id]}
|
|
117
|
+
onchange={(e) => (picked[group.id] = e.currentTarget.checked)}
|
|
118
|
+
/>{group.label}
|
|
119
|
+
</label>
|
|
120
|
+
{/each}
|
|
121
|
+
{#each lists as list (list.uri)}
|
|
122
|
+
<label class="flex cursor-pointer items-center gap-3 py-1.5 text-sm">
|
|
123
|
+
<Checkbox
|
|
124
|
+
checked={!!picked[list.uri]}
|
|
125
|
+
onchange={(e) => (picked[list.uri] = e.currentTarget.checked)}
|
|
126
|
+
/>
|
|
127
|
+
<span class="min-w-0 truncate">People on “{list.name}”</span>
|
|
128
|
+
</label>
|
|
129
|
+
{/each}
|
|
130
|
+
</div>
|
|
131
|
+
{/if}
|
|
132
|
+
</section>
|
|
133
|
+
{/if}
|
|
134
|
+
<label class="flex cursor-pointer items-center justify-between gap-3 text-sm">
|
|
135
|
+
<span>Allow quote posts</span>
|
|
136
|
+
<Checkbox bind:checked={quotes} />
|
|
137
|
+
</label>
|
|
138
|
+
{#if error}<p class="red text-sm text-accent-700 dark:text-accent-300" role="alert">
|
|
139
|
+
{error}
|
|
140
|
+
</p>{/if}
|
|
141
|
+
<div class="flex items-center justify-between gap-2">
|
|
142
|
+
{#if !reply && onsavedefault}
|
|
143
|
+
<Button variant="ghost" size="sm" loading={saving} onclick={saveDefault}>
|
|
144
|
+
Save as default
|
|
145
|
+
</Button>
|
|
146
|
+
{:else}<span></span>{/if}
|
|
147
|
+
<Button onclick={apply}>Done</Button>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</Modal>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComposerReplyRule } from '../../social/composer.js';
|
|
2
|
+
type List = {
|
|
3
|
+
uri: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
type $$ComponentProps = {
|
|
7
|
+
open?: boolean;
|
|
8
|
+
rules?: ComposerReplyRule[];
|
|
9
|
+
allowQuotes?: boolean;
|
|
10
|
+
/** Reply rules belong to the thread's first post; replies only choose quoting. */
|
|
11
|
+
reply?: boolean;
|
|
12
|
+
/** Lists whose members may reply. */
|
|
13
|
+
lists?: List[] | (() => Promise<List[]>);
|
|
14
|
+
onsavedefault?: (rules: ComposerReplyRule[] | undefined, allowQuotes: boolean) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
declare const ReplySettings: import("svelte").Component<$$ComponentProps, {}, "open" | "rules" | "allowQuotes">;
|
|
17
|
+
type ReplySettings = ReturnType<typeof ReplySettings>;
|
|
18
|
+
export default ReplySettings;
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import type { ActorSearch, ActorSummary } from './types.js';
|
|
2
2
|
export declare function isActorSummary(value: unknown): value is ActorSummary;
|
|
3
3
|
export declare function cleanActors(values: readonly unknown[], limit?: number): ActorSummary[];
|
|
4
|
-
/**
|
|
4
|
+
/** Where account suggestions come from: a host serving the typeahead endpoint, or a function. */
|
|
5
|
+
export type ActorSearchProvider = {
|
|
6
|
+
host: string;
|
|
7
|
+
} | ActorSearch;
|
|
8
|
+
/**
|
|
9
|
+
* Services with `app.bsky.actor.searchActorsTypeahead`. `bluesky` is the default; `waow` is the
|
|
10
|
+
* independent typeahead.waow.tech.
|
|
11
|
+
*/
|
|
12
|
+
export declare const actorSearchProviders: {
|
|
13
|
+
readonly bluesky: {
|
|
14
|
+
readonly host: "https://public.api.bsky.app";
|
|
15
|
+
};
|
|
16
|
+
readonly waow: {
|
|
17
|
+
readonly host: "https://typeahead.waow.tech";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Choose the account search for the whole app: every `createActorSearch()` without its own
|
|
22
|
+
* `host` uses it, including the ones inside kit components. Call once before rendering, e.g.
|
|
23
|
+
* at the top of the root layout. Takes effect for searches already created.
|
|
24
|
+
*/
|
|
25
|
+
export declare function configureActorSearch(provider: ActorSearchProvider | undefined): void;
|
|
26
|
+
/** The provider set with `configureActorSearch`, if any. */
|
|
27
|
+
export declare function configuredActorSearch(): ActorSearchProvider | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Account suggestions from the app's provider (see `configureActorSearch`), by default
|
|
30
|
+
* Bluesky's public AppView. Explicitly opt in: no kit form searches unless given one. A `host`
|
|
31
|
+
* here applies to this search only and wins over the app's provider.
|
|
32
|
+
*/
|
|
5
33
|
export declare function createActorSearch({ host, limit, fetch: fetcher }?: {
|
|
6
34
|
host?: string;
|
|
7
35
|
limit?: number;
|
|
@@ -30,11 +30,39 @@ export function cleanActors(values, limit = 6) {
|
|
|
30
30
|
: undefined
|
|
31
31
|
}));
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Services with `app.bsky.actor.searchActorsTypeahead`. `bluesky` is the default; `waow` is the
|
|
35
|
+
* independent typeahead.waow.tech.
|
|
36
|
+
*/
|
|
37
|
+
export const actorSearchProviders = {
|
|
38
|
+
bluesky: { host: 'https://public.api.bsky.app' },
|
|
39
|
+
waow: { host: 'https://typeahead.waow.tech' }
|
|
40
|
+
};
|
|
41
|
+
let configured;
|
|
42
|
+
/**
|
|
43
|
+
* Choose the account search for the whole app: every `createActorSearch()` without its own
|
|
44
|
+
* `host` uses it, including the ones inside kit components. Call once before rendering, e.g.
|
|
45
|
+
* at the top of the root layout. Takes effect for searches already created.
|
|
46
|
+
*/
|
|
47
|
+
export function configureActorSearch(provider) {
|
|
48
|
+
configured = provider;
|
|
49
|
+
}
|
|
50
|
+
/** The provider set with `configureActorSearch`, if any. */
|
|
51
|
+
export function configuredActorSearch() {
|
|
52
|
+
return configured;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Account suggestions from the app's provider (see `configureActorSearch`), by default
|
|
56
|
+
* Bluesky's public AppView. Explicitly opt in: no kit form searches unless given one. A `host`
|
|
57
|
+
* here applies to this search only and wins over the app's provider.
|
|
58
|
+
*/
|
|
59
|
+
export function createActorSearch({ host, limit = 6, fetch: fetcher = globalThis.fetch } = {}) {
|
|
35
60
|
const count = Number.isFinite(limit) ? Math.max(1, Math.min(25, Math.trunc(limit))) : 6;
|
|
36
61
|
return async (query, signal) => {
|
|
37
|
-
const
|
|
62
|
+
const provider = host ? { host } : (configured ?? actorSearchProviders.bluesky);
|
|
63
|
+
if (typeof provider === 'function')
|
|
64
|
+
return cleanActors(await provider(query, signal), count);
|
|
65
|
+
const url = new URL('/xrpc/app.bsky.actor.searchActorsTypeahead', provider.host);
|
|
38
66
|
url.searchParams.set('q', query.trim());
|
|
39
67
|
url.searchParams.set('limit', String(count));
|
|
40
68
|
const response = await fetcher(url, { signal, headers: { accept: 'application/json' } });
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { X } from '@sketchyicons/svelte';
|
|
3
|
+
import Icon from '../components/Icon.svelte';
|
|
4
|
+
import LinkEmbed from '../components/LinkEmbed.svelte';
|
|
5
|
+
import type { LinkEmbedOptions } from '../embeds/types.js';
|
|
6
|
+
import type { PreferredSocialClient } from '../social/preferred-client.js';
|
|
7
|
+
import { focus } from '../styles.js';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
url,
|
|
11
|
+
options,
|
|
12
|
+
onremove
|
|
13
|
+
}: {
|
|
14
|
+
url: string;
|
|
15
|
+
options: () => LinkEmbedOptions & { socialClient?: PreferredSocialClient | null };
|
|
16
|
+
onremove: () => void;
|
|
17
|
+
} = $props();
|
|
18
|
+
let current = $derived(options());
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div class="group/embed relative">
|
|
22
|
+
<LinkEmbed
|
|
23
|
+
{url}
|
|
24
|
+
embeds={current.embeds}
|
|
25
|
+
clickToLoad={current.clickToLoad}
|
|
26
|
+
socialClient={current.socialClient}
|
|
27
|
+
/>
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
aria-label="Remove embed"
|
|
31
|
+
onclick={onremove}
|
|
32
|
+
class={`absolute top-2 right-2 inline-flex size-7 items-center justify-center rounded-full border border-base-300 bg-base-50 text-base-700 opacity-0 transition-opacity group-hover/embed:opacity-100 focus-visible:opacity-100 dark:border-base-700 dark:bg-base-900 dark:text-base-200 pointer-coarse:opacity-100 [.ProseMirror-selectednode_&]:opacity-100 ${focus}`}
|
|
33
|
+
><Icon img={X} size={14} /></button
|
|
34
|
+
>
|
|
35
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LinkEmbedOptions } from '../embeds/types.js';
|
|
2
|
+
import type { PreferredSocialClient } from '../social/preferred-client.js';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
url: string;
|
|
5
|
+
options: () => LinkEmbedOptions & {
|
|
6
|
+
socialClient?: PreferredSocialClient | null;
|
|
7
|
+
};
|
|
8
|
+
onremove: () => void;
|
|
9
|
+
};
|
|
10
|
+
declare const EditorLinkEmbed: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
11
|
+
type EditorLinkEmbed = ReturnType<typeof EditorLinkEmbed>;
|
|
12
|
+
export default EditorLinkEmbed;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
3
|
+
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
4
|
+
import { detectTokens } from '../richtext/detect.js';
|
|
5
|
+
const key = new PluginKey('atmoDetectedTokens');
|
|
6
|
+
function decorations(doc, className) {
|
|
7
|
+
const found = [];
|
|
8
|
+
doc.descendants((node, pos) => {
|
|
9
|
+
if (!node.isTextblock)
|
|
10
|
+
return true;
|
|
11
|
+
if (node.type.spec.code)
|
|
12
|
+
return false;
|
|
13
|
+
// Offsets stay aligned with positions: every inline node is one character or its text.
|
|
14
|
+
let text = '';
|
|
15
|
+
node.forEach((child) => {
|
|
16
|
+
const plain = child.isText &&
|
|
17
|
+
!child.marks.some((mark) => mark.type.name === 'code' || mark.type.name === 'link');
|
|
18
|
+
text += child.isText
|
|
19
|
+
? plain
|
|
20
|
+
? child.text
|
|
21
|
+
: ' '.repeat(child.nodeSize)
|
|
22
|
+
: '\n'.repeat(child.nodeSize);
|
|
23
|
+
});
|
|
24
|
+
let offset = pos + 1;
|
|
25
|
+
for (const token of detectTokens(text)) {
|
|
26
|
+
if (token.type !== 'text')
|
|
27
|
+
found.push(Decoration.inline(offset, offset + token.raw.length, { class: className }));
|
|
28
|
+
offset += token.raw.length;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
});
|
|
32
|
+
return DecorationSet.create(doc, found);
|
|
33
|
+
}
|
|
34
|
+
/** Show typed links, mentions and hashtags the way they will be shown once saved. */
|
|
35
|
+
export const DetectedTokens = Extension.create({
|
|
36
|
+
name: 'detectedTokens',
|
|
37
|
+
addOptions: () => ({ class: '' }),
|
|
38
|
+
addProseMirrorPlugins() {
|
|
39
|
+
const className = this.options.class;
|
|
40
|
+
return [
|
|
41
|
+
new Plugin({
|
|
42
|
+
key,
|
|
43
|
+
state: {
|
|
44
|
+
init: (_, state) => decorations(state.doc, className),
|
|
45
|
+
apply: (tr, old) => (tr.docChanged ? decorations(tr.doc, className) : old)
|
|
46
|
+
},
|
|
47
|
+
props: { decorations: (state) => key.getState(state) }
|
|
48
|
+
})
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
import { type RichTextDocument } from '../richtext/document.js';
|
|
3
|
+
import type { Facet } from '../social/richtext.js';
|
|
4
|
+
export declare const LINK_EMBED = "linkEmbed";
|
|
5
|
+
type EmbedTest = ((url: string) => boolean) | undefined;
|
|
6
|
+
/** A URL alone, e.g. the whole text of a line; undefined for anything else. */
|
|
7
|
+
export declare function bareUrl(text: string): string | undefined;
|
|
8
|
+
/** A parsed document as editor content. Links that would be shown as embeds become embed blocks. */
|
|
9
|
+
export declare function documentToEditor(document: RichTextDocument, isEmbed?: EmbedTest): JSONContent;
|
|
10
|
+
/** Editor content as a Markdown document, ready for `richTextToMarkdown`. */
|
|
11
|
+
export declare function editorToDocument(json: JSONContent): RichTextDocument;
|
|
12
|
+
/**
|
|
13
|
+
* Facets for Markdown source: links and hashtags found in the text, and mentions picked from
|
|
14
|
+
* the suggestions (typed handles have no DID yet; resolve those before saving).
|
|
15
|
+
*/
|
|
16
|
+
export declare function markdownFacets(text: string, json: JSONContent): Facet[];
|
|
17
|
+
export {};
|