@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.
Files changed (95) hide show
  1. package/dist/components/ExternalEmbed.svelte +30 -29
  2. package/dist/components/ExternalEmbed.svelte.d.ts +8 -0
  3. package/dist/components/InlineEditor.svelte +15 -95
  4. package/dist/components/InlineEditor.svelte.d.ts +1 -1
  5. package/dist/components/LinkCard.svelte +54 -25
  6. package/dist/components/LinkCard.svelte.d.ts +2 -0
  7. package/dist/components/LinkEmbed.svelte +75 -0
  8. package/dist/components/LinkEmbed.svelte.d.ts +13 -0
  9. package/dist/components/PostContent.svelte +12 -3
  10. package/dist/components/PostContent.svelte.d.ts +3 -0
  11. package/dist/components/RichText.svelte +47 -5
  12. package/dist/components/RichText.svelte.d.ts +5 -2
  13. package/dist/components/RichTextEditor.svelte +272 -0
  14. package/dist/components/RichTextEditor.svelte.d.ts +44 -0
  15. package/dist/components/composer/AltText.svelte +63 -0
  16. package/dist/components/composer/AltText.svelte.d.ts +11 -0
  17. package/dist/components/composer/CharRing.svelte +39 -0
  18. package/dist/components/composer/CharRing.svelte.d.ts +7 -0
  19. package/dist/components/composer/ComposerPost.svelte +321 -0
  20. package/dist/components/composer/ComposerPost.svelte.d.ts +29 -0
  21. package/dist/components/composer/Drafts.svelte +82 -0
  22. package/dist/components/composer/Drafts.svelte.d.ts +9 -0
  23. package/dist/components/composer/EmojiPicker.svelte +55 -0
  24. package/dist/components/composer/EmojiPicker.svelte.d.ts +7 -0
  25. package/dist/components/composer/GifPicker.svelte +118 -0
  26. package/dist/components/composer/GifPicker.svelte.d.ts +11 -0
  27. package/dist/components/composer/PostComposer.svelte +599 -0
  28. package/dist/components/composer/PostComposer.svelte.d.ts +71 -0
  29. package/dist/components/composer/PostComposerDialog.svelte +75 -0
  30. package/dist/components/composer/PostComposerDialog.svelte.d.ts +10 -0
  31. package/dist/components/composer/ReplySettings.svelte +150 -0
  32. package/dist/components/composer/ReplySettings.svelte.d.ts +18 -0
  33. package/dist/components/login/search.d.ts +29 -1
  34. package/dist/components/login/search.js +31 -3
  35. package/dist/editor/EditorLinkEmbed.svelte +35 -0
  36. package/dist/editor/EditorLinkEmbed.svelte.d.ts +12 -0
  37. package/dist/editor/detect-plugin.d.ts +5 -0
  38. package/dist/editor/detect-plugin.js +51 -0
  39. package/dist/editor/document.d.ts +17 -0
  40. package/dist/editor/document.js +269 -0
  41. package/dist/editor/link-embed-node.d.ts +17 -0
  42. package/dist/editor/link-embed-node.js +96 -0
  43. package/dist/editor/markdown-extensions.d.ts +6 -0
  44. package/dist/editor/markdown-extensions.js +42 -0
  45. package/dist/editor/markdown.d.ts +3 -0
  46. package/dist/editor/markdown.js +4 -0
  47. package/dist/embeds/PlayerLinkEmbed.svelte +9 -0
  48. package/dist/embeds/PlayerLinkEmbed.svelte.d.ts +7 -0
  49. package/dist/{events/event-view → embeds}/PostLinkEmbed.svelte +7 -7
  50. package/dist/{events/event-view → embeds}/PostLinkEmbed.svelte.d.ts +1 -1
  51. package/dist/{events/event-view → embeds}/ProfileLinkEmbed.svelte +7 -7
  52. package/dist/{events/event-view → embeds}/ProfileLinkEmbed.svelte.d.ts +1 -1
  53. package/dist/embeds/context.d.ts +10 -0
  54. package/dist/embeds/context.js +20 -0
  55. package/dist/embeds/defaults.d.ts +27 -0
  56. package/dist/embeds/defaults.js +38 -0
  57. package/dist/embeds/resolve.d.ts +9 -0
  58. package/dist/embeds/resolve.js +27 -0
  59. package/dist/embeds/types.d.ts +39 -0
  60. package/dist/embeds/types.js +1 -0
  61. package/dist/events/EventEditor.svelte +29 -6
  62. package/dist/events/EventView.svelte +21 -38
  63. package/dist/events/PostToBlueskyModal.svelte +12 -4
  64. package/dist/events/event-link-embed.d.ts +22 -0
  65. package/dist/events/event-link-embed.js +15 -0
  66. package/dist/events/event-view/EventLinkEmbed.svelte +12 -30
  67. package/dist/events/event-view/EventLinkEmbed.svelte.d.ts +3 -12
  68. package/dist/events.d.ts +2 -0
  69. package/dist/events.js +1 -0
  70. package/dist/index.d.ts +16 -2
  71. package/dist/index.js +10 -2
  72. package/dist/richtext/detect.js +1 -1
  73. package/dist/richtext/document.d.ts +10 -0
  74. package/dist/richtext/document.js +44 -4
  75. package/dist/richtext/markdown.js +9 -8
  76. package/dist/richtext/serialize.d.ts +11 -0
  77. package/dist/richtext/serialize.js +462 -0
  78. package/dist/richtext/vendor/markdown-tree.d.ts +5 -0
  79. package/dist/richtext/vendor/markdown-tree.js +11032 -0
  80. package/dist/richtext.d.ts +1 -0
  81. package/dist/richtext.js +1 -0
  82. package/dist/social/MentionOptions.svelte +30 -0
  83. package/dist/social/MentionOptions.svelte.d.ts +12 -0
  84. package/dist/social/composer.d.ts +143 -0
  85. package/dist/social/composer.js +141 -0
  86. package/dist/social/{mention-suggestions.d.ts → mention-suggestions.svelte.d.ts} +1 -1
  87. package/dist/social/{mention-suggestions.js → mention-suggestions.svelte.js} +36 -46
  88. package/dist/social/richtext.js +2 -0
  89. package/dist/social.d.ts +2 -0
  90. package/dist/social.js +1 -0
  91. package/dist/styles.d.ts +5 -0
  92. package/dist/styles.js +5 -0
  93. package/package.json +8 -4
  94. package/dist/components/PostComposer.svelte +0 -41
  95. package/dist/components/PostComposer.svelte.d.ts +0 -16
@@ -11,6 +11,7 @@ export type RichTextParseOptions = PlainTextOptions & {
11
11
  };
12
12
  export declare function parseRichText(text: string, options?: RichTextParseOptions): RichTextDocument;
13
13
  export { parseMarkdown, parsePlainText };
14
+ export { richTextToMarkdown, sameRichText } from './richtext/serialize.js';
14
15
  export { richTextToPlainText, safeWebUrl, paragraphParts } from './richtext/document.js';
15
16
  export type { RichTextDocument, RichTextBlock, RichTextInline, RichTextLinkOptions } from './richtext/document.js';
16
17
  export type { PlainTextOptions };
package/dist/richtext.js CHANGED
@@ -8,5 +8,6 @@ export function parseRichText(text, options = {}) {
8
8
  return options.markdown ? parseMarkdown(text, options) : parsePlainText(text, options);
9
9
  }
10
10
  export { parseMarkdown, parsePlainText };
11
+ export { richTextToMarkdown, sameRichText } from './richtext/serialize.js';
11
12
  export { richTextToPlainText, safeWebUrl, paragraphParts } from './richtext/document.js';
12
13
  export { detectTokens } from './richtext/detect.js';
@@ -0,0 +1,30 @@
1
+ <script lang="ts">
2
+ import Avatar from '../components/Avatar.svelte';
3
+ import { actorName, type ActorSummary } from '../components/login/types.js';
4
+
5
+ // The same rows as the login form's account search.
6
+ let {
7
+ state
8
+ }: {
9
+ state: { id: string; items: ActorSummary[]; selected: number; choose: (index: number) => void };
10
+ } = $props();
11
+ </script>
12
+
13
+ {#each state.items as actor, index (actor.did)}
14
+ <button
15
+ type="button"
16
+ role="option"
17
+ id={`${state.id}-${index}`}
18
+ aria-selected={index === state.selected}
19
+ onmousedown={(event) => event.preventDefault()}
20
+ onclick={() => state.choose(index)}
21
+ class="flex min-h-14 w-full cursor-pointer items-center gap-3 rounded-ui px-2.5 py-2 text-left outline-none hover:bg-accent-50 hover:text-accent-700 aria-selected:bg-accent-50 aria-selected:text-accent-700 dark:hover:bg-[color-mix(in_srgb,var(--accent-950)_65%,var(--base-950))] dark:hover:text-accent-300 dark:aria-selected:bg-[color-mix(in_srgb,var(--accent-950)_65%,var(--base-950))] dark:aria-selected:text-accent-300"
22
+ ><Avatar name={actorName(actor)} src={actor.avatar} size={32} aria-hidden="true" /><span
23
+ class="grid min-w-0 gap-0.5"
24
+ ><strong class="truncate text-[.8125rem] font-medium">{actorName(actor)}</strong
25
+ >{#if actor.displayName}<span class="truncate text-xs text-base-600 dark:text-base-400"
26
+ >@{actor.handle}</span
27
+ >{/if}</span
28
+ ></button
29
+ >
30
+ {/each}
@@ -0,0 +1,12 @@
1
+ import { type ActorSummary } from '../components/login/types.js';
2
+ type $$ComponentProps = {
3
+ state: {
4
+ id: string;
5
+ items: ActorSummary[];
6
+ selected: number;
7
+ choose: (index: number) => void;
8
+ };
9
+ };
10
+ declare const MentionOptions: import("svelte").Component<$$ComponentProps, {}, "">;
11
+ type MentionOptions = ReturnType<typeof MentionOptions>;
12
+ export default MentionOptions;
@@ -0,0 +1,143 @@
1
+ import type { Facet } from './richtext.js';
2
+ export type ComposerImage = {
3
+ id: string;
4
+ file: File;
5
+ url: string;
6
+ alt: string;
7
+ };
8
+ export type ComposerVideo = {
9
+ file: File;
10
+ url: string;
11
+ alt: string;
12
+ width: number;
13
+ height: number;
14
+ captions: {
15
+ lang: string;
16
+ file: File;
17
+ }[];
18
+ };
19
+ export type ComposerGif = {
20
+ /** The link to post, with whatever size and format hints readers need. */
21
+ uri: string;
22
+ title: string;
23
+ alt: string;
24
+ /** Small animated preview shown in the picker and the composer. */
25
+ preview: string;
26
+ /** Still image for the posted link card. */
27
+ thumb: string;
28
+ width: number;
29
+ height: number;
30
+ };
31
+ export type ComposerLink = {
32
+ uri: string;
33
+ title: string;
34
+ description: string;
35
+ image?: string;
36
+ };
37
+ /** One post of the thread being written. */
38
+ export type ComposerPost = {
39
+ id: string;
40
+ text: string;
41
+ facets: Facet[];
42
+ images: ComposerImage[];
43
+ video?: ComposerVideo;
44
+ gif?: ComposerGif;
45
+ link?: ComposerLink;
46
+ /** Content warning for the attached media; empty for none. */
47
+ label: string;
48
+ };
49
+ /** Who may reply. `undefined` is everyone; an empty list is nobody. */
50
+ export type ComposerReplyRule = {
51
+ type: 'mention' | 'follower' | 'following';
52
+ } | {
53
+ type: 'list';
54
+ list: string;
55
+ };
56
+ /** Everything the composer hands over for publishing or saving. */
57
+ export type ComposerContent = {
58
+ posts: ComposerPost[];
59
+ languages: string[];
60
+ replyRules?: ComposerReplyRule[];
61
+ allowQuotes: boolean;
62
+ };
63
+ export type ComposerLimits = {
64
+ /** Graphemes per post. */
65
+ length: number;
66
+ images: number;
67
+ /** Posts in one thread; 1 turns threads off. */
68
+ posts: number;
69
+ videoBytes: number;
70
+ captionBytes: number;
71
+ languages: number;
72
+ altLength: number;
73
+ };
74
+ export declare const defaultComposerLimits: ComposerLimits;
75
+ /** Each control can be turned off. GIFs, link previews and drafts also need their function. */
76
+ export type ComposerFeatures = {
77
+ images: boolean;
78
+ video: boolean;
79
+ gifs: boolean;
80
+ emoji: boolean;
81
+ languages: boolean;
82
+ /** Who can reply and quote. */
83
+ interactions: boolean;
84
+ contentWarnings: boolean;
85
+ linkPreviews: boolean;
86
+ drafts: boolean;
87
+ };
88
+ export type ComposerLabels = {
89
+ placeholder: string;
90
+ /** Placeholder of the second and later posts of a thread. */
91
+ threadPlaceholder: string;
92
+ submit: string;
93
+ /** Submit button when the thread has several posts. */
94
+ submitAll: string;
95
+ cancel: string;
96
+ };
97
+ export type ComposerGifResult = ComposerGif & {
98
+ id: string;
99
+ };
100
+ export type ComposerGifSearch = (query: string, cursor?: string, signal?: AbortSignal) => Promise<{
101
+ gifs: ComposerGifResult[];
102
+ cursor?: string;
103
+ }>;
104
+ export type ComposerLinkPreview = (uri: string, signal?: AbortSignal) => Promise<ComposerLink | undefined>;
105
+ export type ComposerDraftSummary = {
106
+ id: string;
107
+ text: string;
108
+ updatedAt?: string | Date;
109
+ /** A short note under the text, such as "2 posts · 1 attached". */
110
+ detail?: string;
111
+ };
112
+ /**
113
+ * Where drafts are kept. The composer passes back the summaries it was given, so they can
114
+ * carry whatever else the store needs.
115
+ */
116
+ export type ComposerDrafts<Summary extends ComposerDraftSummary = ComposerDraftSummary> = {
117
+ list(): Promise<Summary[]>;
118
+ load(draft: Summary): Promise<ComposerContent>;
119
+ /** `current` is the draft that was opened, when the content came from one. */
120
+ save(content: ComposerContent, current?: Summary): Promise<void>;
121
+ delete(draft: Summary): Promise<void>;
122
+ };
123
+ export type ComposerContentWarning = {
124
+ value: string;
125
+ label: string;
126
+ };
127
+ export declare const defaultContentWarnings: readonly ComposerContentWarning[];
128
+ export declare const defaultComposerLanguages: readonly string[];
129
+ export declare const browserLanguage: () => string;
130
+ export declare function blankComposerPost(text?: string): ComposerPost;
131
+ /** Free the object URLs of attached files once posts are discarded. */
132
+ export declare function releaseComposerPosts(posts: readonly ComposerPost[]): void;
133
+ export declare function videoDimensions(file: File): Promise<{
134
+ width: number;
135
+ height: number;
136
+ }>;
137
+ /**
138
+ * GIF search through Bluesky's Klipy service. Posted links carry the size and video
139
+ * formats that `klipyEmbedProvider` and other clients read.
140
+ */
141
+ export declare const blueskyGifSearch: ComposerGifSearch;
142
+ /** Link preview metadata from Bluesky's card service. */
143
+ export declare const blueskyLinkPreview: ComposerLinkPreview;
@@ -0,0 +1,141 @@
1
+ export const defaultComposerLimits = {
2
+ length: 300,
3
+ images: 4,
4
+ posts: 25,
5
+ videoBytes: 300_000_000,
6
+ captionBytes: 20_000,
7
+ languages: 3,
8
+ altLength: 2000
9
+ };
10
+ export const defaultContentWarnings = [
11
+ { value: 'sexual', label: 'Suggestive' },
12
+ { value: 'nudity', label: 'Nudity' },
13
+ { value: 'porn', label: 'Adult' },
14
+ { value: 'graphic-media', label: 'Graphic media' }
15
+ ];
16
+ export const defaultComposerLanguages = [
17
+ 'en',
18
+ 'de',
19
+ 'es',
20
+ 'fr',
21
+ 'it',
22
+ 'pt',
23
+ 'nl',
24
+ 'pl',
25
+ 'sv',
26
+ 'da',
27
+ 'fi',
28
+ 'nb',
29
+ 'cs',
30
+ 'tr',
31
+ 'uk',
32
+ 'ru',
33
+ 'el',
34
+ 'he',
35
+ 'ar',
36
+ 'fa',
37
+ 'hi',
38
+ 'id',
39
+ 'th',
40
+ 'vi',
41
+ 'ko',
42
+ 'ja',
43
+ 'zh'
44
+ ];
45
+ export const browserLanguage = () => typeof navigator === 'undefined' ? 'en' : navigator.language.split('-')[0];
46
+ export function blankComposerPost(text = '') {
47
+ return { id: crypto.randomUUID(), text, facets: [], images: [], label: '' };
48
+ }
49
+ /** Free the object URLs of attached files once posts are discarded. */
50
+ export function releaseComposerPosts(posts) {
51
+ for (const post of posts) {
52
+ for (const image of post.images)
53
+ URL.revokeObjectURL(image.url);
54
+ if (post.video)
55
+ URL.revokeObjectURL(post.video.url);
56
+ }
57
+ }
58
+ export function videoDimensions(file) {
59
+ return new Promise((resolve) => {
60
+ const video = document.createElement('video');
61
+ const url = URL.createObjectURL(file);
62
+ const done = (width, height) => {
63
+ URL.revokeObjectURL(url);
64
+ resolve({ width, height });
65
+ };
66
+ video.onloadedmetadata = () => done(video.videoWidth, video.videoHeight);
67
+ video.onerror = () => done(0, 0);
68
+ video.src = url;
69
+ });
70
+ }
71
+ const slug = (url) => url
72
+ ?.split('/')
73
+ .pop()
74
+ ?.replace(/\.[^.]+$/, '');
75
+ /**
76
+ * GIF search through Bluesky's Klipy service. Posted links carry the size and video
77
+ * formats that `klipyEmbedProvider` and other clients read.
78
+ */
79
+ export const blueskyGifSearch = async (query, cursor, signal) => {
80
+ const params = new URLSearchParams({
81
+ client_key: 'bluesky-web',
82
+ limit: '30',
83
+ contentfilter: 'low'
84
+ });
85
+ const region = navigator.language.split('-')[1];
86
+ if (region)
87
+ params.set('locale', region.toLowerCase());
88
+ if (query)
89
+ params.set('q', query);
90
+ if (cursor)
91
+ params.set('pos', cursor);
92
+ const response = await fetch(`https://gifs.bsky.app/klipy/v2/${query ? 'search' : 'featured'}?${params}`, { signal });
93
+ if (!response.ok)
94
+ throw new Error('GIF search is unavailable');
95
+ const body = (await response.json());
96
+ const gifs = [];
97
+ for (const gif of body.results ?? []) {
98
+ const formats = gif.media_formats;
99
+ const full = formats.gif;
100
+ if (!full)
101
+ continue;
102
+ const hints = new URLSearchParams({ hh: String(full.dims[1]), ww: String(full.dims[0]) });
103
+ const mp4 = slug(formats.mp4?.url);
104
+ const webm = slug(formats.webm?.url);
105
+ if (mp4)
106
+ hints.set('mp4', mp4);
107
+ if (webm)
108
+ hints.set('webm', webm);
109
+ gifs.push({
110
+ id: gif.id,
111
+ uri: `${full.url}?${hints}`,
112
+ title: gif.content_description || gif.title || 'GIF',
113
+ alt: '',
114
+ preview: (formats.tinygif ?? full).url,
115
+ thumb: (formats.preview ?? formats.gifpreview ?? full).url,
116
+ width: full.dims[0],
117
+ height: full.dims[1]
118
+ });
119
+ }
120
+ return { gifs, cursor: body.next || undefined };
121
+ };
122
+ /** Link preview metadata from Bluesky's card service. */
123
+ export const blueskyLinkPreview = async (uri, signal) => {
124
+ try {
125
+ const response = await fetch(`https://cardyb.bsky.app/v1/extract?url=${encodeURIComponent(uri)}`, { signal });
126
+ if (!response.ok)
127
+ return;
128
+ const data = await response.json();
129
+ if (data.error)
130
+ return;
131
+ return {
132
+ uri,
133
+ title: String(data.title ?? ''),
134
+ description: String(data.description ?? ''),
135
+ image: typeof data.image === 'string' && data.image ? data.image : undefined
136
+ };
137
+ }
138
+ catch {
139
+ return;
140
+ }
141
+ };
@@ -1,6 +1,6 @@
1
1
  import type { Editor } from '@tiptap/core';
2
2
  import type { ActorSearch, ActorSummary } from '../components/login/types.js';
3
- /** DOM is constructed with textContent: profile data never becomes HTML. */
3
+ /** Rows are rendered by Svelte, so profile data never becomes HTML. */
4
4
  export declare function mentionSuggestions(search: ActorSearch, host: () => HTMLElement): {
5
5
  char: string;
6
6
  debounce: number;
@@ -1,70 +1,58 @@
1
- /** DOM is constructed with textContent: profile data never becomes HTML. */
1
+ import { mount, unmount } from 'svelte';
2
+ import MentionOptions from './MentionOptions.svelte';
3
+ /** Rows are rendered by Svelte, so profile data never becomes HTML. */
2
4
  export function mentionSuggestions(search, host) {
3
5
  let controller;
4
6
  let menu;
5
- let selected = 0;
7
+ let options;
6
8
  let current;
9
+ const state = $state({
10
+ id: '',
11
+ items: [],
12
+ selected: 0,
13
+ choose: (index) => {
14
+ const actor = current.items[index];
15
+ if (actor)
16
+ current.command({ id: actor.did, label: actor.handle });
17
+ }
18
+ });
7
19
  const close = () => {
20
+ if (options)
21
+ void unmount(options);
22
+ options = undefined;
8
23
  menu?.remove();
9
24
  menu = undefined;
10
25
  current?.editor.view.dom.removeAttribute('aria-controls');
11
26
  current?.editor.view.dom.removeAttribute('aria-activedescendant');
12
27
  current?.editor.view.dom.setAttribute('aria-expanded', 'false');
13
28
  };
14
- const choose = (index) => {
15
- const actor = current.items[index];
16
- if (actor)
17
- current.command({ id: actor.did, label: actor.handle });
18
- };
19
29
  function draw() {
20
30
  if (!menu)
21
31
  return;
22
- menu.replaceChildren();
32
+ state.items = current.items;
23
33
  const rect = current.clientRect?.();
24
34
  const bounds = host().getBoundingClientRect();
25
35
  if (rect) {
26
36
  menu.style.top = `${rect.bottom - bounds.top + host().scrollTop + 6}px`;
27
- menu.style.left = `${Math.max(0, Math.min(rect.left - bounds.left, bounds.width - 280))}px`;
37
+ menu.style.left = `${Math.max(0, Math.min(rect.left - bounds.left, bounds.width - 288))}px`;
28
38
  }
39
+ // Nothing to choose from: stay out of the way instead of saying so.
40
+ menu.hidden = !current.items.length;
29
41
  if (!current.items.length) {
30
- const empty = document.createElement('p');
31
- empty.role = 'option';
32
- empty.setAttribute('aria-disabled', 'true');
33
- empty.setAttribute('aria-selected', 'false');
34
- empty.className = 'p-3 text-xs text-base-600 dark:text-base-400';
35
- empty.textContent = 'No accounts found';
36
- menu.append(empty);
42
+ current.editor.view.dom.removeAttribute('aria-controls');
43
+ current.editor.view.dom.removeAttribute('aria-activedescendant');
44
+ current.editor.view.dom.setAttribute('aria-expanded', 'false');
45
+ return;
37
46
  }
38
- current.items.forEach((actor, index) => {
39
- const option = document.createElement('button');
40
- option.type = 'button';
41
- option.role = 'option';
42
- option.id = `${menu.id}-${index}`;
43
- option.setAttribute('aria-selected', String(index === selected));
44
- option.className =
45
- 'block w-full rounded-ui px-3 py-2 text-left text-xs text-base-950 dark:text-base-50 hover:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:hover:bg-base-950 aria-selected:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:aria-selected:bg-base-950';
46
- const name = document.createElement('strong');
47
- name.className = 'block truncate font-medium';
48
- name.textContent = actor.displayName || actor.handle;
49
- const handle = document.createElement('span');
50
- handle.className = 'block truncate text-base-600 dark:text-base-400';
51
- handle.textContent = `@${actor.handle}`;
52
- option.append(name, handle);
53
- option.onmousedown = (event) => event.preventDefault();
54
- option.onclick = () => choose(index);
55
- menu.append(option);
56
- });
57
47
  current.editor.view.dom.setAttribute('aria-controls', menu.id);
58
48
  current.editor.view.dom.setAttribute('aria-expanded', 'true');
59
- if (current.items.length)
60
- current.editor.view.dom.setAttribute('aria-activedescendant', `${menu.id}-${selected}`);
61
- else
62
- current.editor.view.dom.removeAttribute('aria-activedescendant');
49
+ current.editor.view.dom.setAttribute('aria-activedescendant', `${menu.id}-${state.selected}`);
63
50
  }
64
51
  return {
65
52
  char: '@',
66
53
  debounce: 200,
67
- minQueryLength: 1,
54
+ // One letter matches almost anyone; wait for a second one.
55
+ minQueryLength: 2,
68
56
  items: async ({ query }) => {
69
57
  controller?.abort();
70
58
  controller = new AbortController();
@@ -78,19 +66,21 @@ export function mentionSuggestions(search, host) {
78
66
  render: () => ({
79
67
  onStart: (props) => {
80
68
  current = props;
81
- selected = 0;
69
+ state.selected = 0;
82
70
  menu = document.createElement('div');
83
71
  menu.id = `${props.editor.view.dom.id}-mentions`;
84
72
  menu.role = 'listbox';
85
73
  menu.setAttribute('aria-label', 'Mention suggestions');
86
74
  menu.className =
87
- 'absolute z-60 w-70 max-w-full overflow-hidden rounded-ui border border-base-300 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] bg-base-50 dark:bg-base-925 p-1 font-sans text-base-950 dark:text-base-50';
75
+ 'absolute z-60 w-72 max-w-full overflow-hidden rounded-ui border border-base-300 bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] p-1.5 font-sans text-base-950 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] dark:bg-base-975 dark:text-base-50';
76
+ state.id = menu.id;
88
77
  host().append(menu);
78
+ options = mount(MentionOptions, { target: menu, props: { state } });
89
79
  draw();
90
80
  },
91
81
  onUpdate: (props) => {
92
82
  current = props;
93
- selected = 0;
83
+ state.selected = 0;
94
84
  draw();
95
85
  },
96
86
  onKeyDown: ({ event }) => {
@@ -101,14 +91,14 @@ export function mentionSuggestions(search, host) {
101
91
  if (!current.items.length)
102
92
  return false;
103
93
  if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
104
- selected =
105
- (selected + (event.key === 'ArrowDown' ? 1 : -1) + current.items.length) %
94
+ state.selected =
95
+ (state.selected + (event.key === 'ArrowDown' ? 1 : -1) + current.items.length) %
106
96
  current.items.length;
107
97
  draw();
108
98
  return true;
109
99
  }
110
100
  if (event.key === 'Enter' || event.key === 'Tab') {
111
- choose(selected);
101
+ state.choose(state.selected);
112
102
  return true;
113
103
  }
114
104
  return false;
@@ -18,6 +18,8 @@ export function editorJsonToBlueskyPost(doc) {
18
18
  text += node.text ?? '';
19
19
  else if (node.type === 'hardBreak')
20
20
  text += '\n';
21
+ else if (node.type === 'linkEmbed')
22
+ text += typeof node.attrs?.url === 'string' ? node.attrs.url : '';
21
23
  else if (node.type === 'mention') {
22
24
  const label = `@${node.attrs?.label ?? node.attrs?.id ?? ''}`;
23
25
  const byteStart = bytes(text);
package/dist/social.d.ts CHANGED
@@ -5,3 +5,5 @@ export type { ExternalPostEmbed, ExternalEmbedProvider, ExternalEmbedPlayer } fr
5
5
  export { blueskyPostToPostData, hasModerationLabel } from './social/posts.js';
6
6
  export type { PostData, PostEmbed, BlueskyPostView } from './social/posts.js';
7
7
  export { blueskyProfileUrl, socialProfileUrl, socialPostUrl, socialHashtagUrl, parseSocialPostUrl, parseSocialProfileUrl } from './social/urls.js';
8
+ export { blueskyGifSearch, blueskyLinkPreview, defaultComposerLimits, defaultComposerLanguages, defaultContentWarnings } from './social/composer.js';
9
+ export type { ComposerContent, ComposerPost, ComposerImage, ComposerVideo, ComposerGif, ComposerLink, ComposerReplyRule, ComposerLimits, ComposerFeatures, ComposerLabels, ComposerGifSearch, ComposerGifResult, ComposerLinkPreview, ComposerDrafts, ComposerDraftSummary, ComposerContentWarning } from './social/composer.js';
package/dist/social.js CHANGED
@@ -2,3 +2,4 @@ export { PREFERRED_CLIENT_COLLECTION, PREFERRED_CLIENT_RKEY, PREFERRED_CLIENT_SC
2
2
  export { defaultExternalEmbedProviders, youtubeEmbedProvider, klipyEmbedProvider, resolveExternalEmbed } from './social/external-embeds.js';
3
3
  export { blueskyPostToPostData, hasModerationLabel } from './social/posts.js';
4
4
  export { blueskyProfileUrl, socialProfileUrl, socialPostUrl, socialHashtagUrl, parseSocialPostUrl, parseSocialProfileUrl } from './social/urls.js';
5
+ export { blueskyGifSearch, blueskyLinkPreview, defaultComposerLimits, defaultComposerLanguages, defaultContentWarnings } from './social/composer.js';
package/dist/styles.d.ts CHANGED
@@ -1,2 +1,7 @@
1
1
  export declare const focus = "focus-visible:outline-2 focus-visible:outline-offset-3 focus-visible:outline-accent-700 dark:focus-visible:outline-accent-300";
2
2
  export declare const control = "block min-h-11 w-full min-w-0 rounded-ui border border-base-300 dark:border-base-800 bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:bg-base-975 px-3 py-2.5 text-base leading-normal text-base-950 dark:text-base-50 shadow-[inset_0_2px_4px_color-mix(in_srgb,var(--base-950)_8%,transparent),inset_0_5px_12px_color-mix(in_srgb,var(--base-950)_2%,transparent)] dark:shadow-[inset_0_2px_4px_#0006,inset_0_5px_12px_#0002] placeholder:text-base-600 dark:placeholder:text-base-400 transition-colors duration-(--atmo-duration) motion-reduce:transition-none hover:border-base-400 dark:hover:border-base-700 focus:ring-0 focus:ring-offset-0 focus-visible:border-accent-700 dark:focus-visible:border-accent-300 focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-accent-700 dark:focus-visible:outline-accent-300 disabled:cursor-not-allowed disabled:opacity-45 disabled:hover:border-base-300 dark:disabled:hover:border-base-800 aria-invalid:border-accent-700 dark:aria-invalid:border-accent-300 aria-invalid:hover:border-accent-700 dark:aria-invalid:hover:border-accent-300 sm:text-sm";
3
+ export declare const line = "border-base-300 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))]";
4
+ export declare const recess = "bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:bg-base-950";
5
+ export declare const muted = "text-base-600 dark:text-base-400";
6
+ export declare const action = "text-accent-700 dark:text-accent-300";
7
+ export declare const hoverRecess = "hover:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:hover:bg-base-950";
package/dist/styles.js CHANGED
@@ -1,3 +1,8 @@
1
1
  // Shared Tailwind recipes, not an additional component stylesheet.
2
2
  export const focus = 'focus-visible:outline-2 focus-visible:outline-offset-3 focus-visible:outline-accent-700 dark:focus-visible:outline-accent-300';
3
3
  export const control = 'block min-h-11 w-full min-w-0 rounded-ui border border-base-300 dark:border-base-800 bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:bg-base-975 px-3 py-2.5 text-base leading-normal text-base-950 dark:text-base-50 shadow-[inset_0_2px_4px_color-mix(in_srgb,var(--base-950)_8%,transparent),inset_0_5px_12px_color-mix(in_srgb,var(--base-950)_2%,transparent)] dark:shadow-[inset_0_2px_4px_#0006,inset_0_5px_12px_#0002] placeholder:text-base-600 dark:placeholder:text-base-400 transition-colors duration-(--atmo-duration) motion-reduce:transition-none hover:border-base-400 dark:hover:border-base-700 focus:ring-0 focus:ring-offset-0 focus-visible:border-accent-700 dark:focus-visible:border-accent-300 focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-accent-700 dark:focus-visible:outline-accent-300 disabled:cursor-not-allowed disabled:opacity-45 disabled:hover:border-base-300 dark:disabled:hover:border-base-800 aria-invalid:border-accent-700 dark:aria-invalid:border-accent-300 aria-invalid:hover:border-accent-700 dark:aria-invalid:hover:border-accent-300 sm:text-sm';
4
+ export const line = 'border-base-300 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))]';
5
+ export const recess = 'bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:bg-base-950';
6
+ export const muted = 'text-base-600 dark:text-base-400';
7
+ export const action = 'text-accent-700 dark:text-accent-300';
8
+ export const hoverRecess = 'hover:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:hover:bg-base-950';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmo-dev/kit",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "The shared UI foundation for Atmo apps.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -107,6 +107,7 @@
107
107
  "@tailwindcss/vite": "^4.3.0",
108
108
  "@types/canvas-confetti": "^1.9.0",
109
109
  "@types/mdast": "^4.0.4",
110
+ "mdast-util-from-markdown": "^2.1.0",
110
111
  "@types/node": "^24",
111
112
  "@vitest/browser-playwright": "^4.1.8",
112
113
  "axe-core": "^4.14.0",
@@ -115,6 +116,8 @@
115
116
  "eslint-plugin-svelte": "^3.19.0",
116
117
  "globals": "^17.6.0",
117
118
  "maplibre-gl": "^6.16.0",
119
+ "mdast-util-gfm-strikethrough": "^2.0.1",
120
+ "micromark-extension-gfm-strikethrough": "^2.1.0",
118
121
  "playwright": "^1.60.0",
119
122
  "prettier": "^3.8.3",
120
123
  "prettier-plugin-svelte": "^4.1.0",
@@ -153,16 +156,16 @@
153
156
  "@tiptap/extension-paragraph": "^3.32.0",
154
157
  "@tiptap/extension-placeholder": "^3.32.0",
155
158
  "@tiptap/extension-text": "^3.32.0",
159
+ "@tiptap/pm": "^3.32.0",
160
+ "@tiptap/starter-kit": "^3.32.0",
156
161
  "bits-ui": "^2.20.2",
157
162
  "canvas-confetti": "^1.9.4",
158
163
  "clsx": "^2.1.1",
164
+ "emoji-picker-element": "^1.29.1",
159
165
  "esm-env": "^1.2.2",
160
166
  "h3-js": "^4.5.0",
161
167
  "hls.js": "^1.7.3",
162
168
  "i18n-iso-countries": "^7.14.0",
163
- "mdast-util-from-markdown": "^2.1.0",
164
- "mdast-util-gfm-strikethrough": "^2.0.1",
165
- "micromark-extension-gfm-strikethrough": "^2.1.0",
166
169
  "svelte-boring-avatars": "^1.2.6",
167
170
  "tailwind-merge": "^3.7.0",
168
171
  "valibot": "^1.5.0"
@@ -182,6 +185,7 @@
182
185
  "test:package": "pnpm prepack && pnpm test:package:built",
183
186
  "test:package:built": "node --test scripts/test-*-package.mjs",
184
187
  "changeset": "changeset",
188
+ "vendor:markdown": "node scripts/vendor-markdown.mjs",
185
189
  "version-packages": "changeset version && pnpm install --lockfile-only --no-frozen-lockfile --ignore-scripts",
186
190
  "release": "pnpm prepack && changeset publish"
187
191
  }
@@ -1,41 +0,0 @@
1
- <script lang="ts">
2
- import type { Editor, JSONContent } from '@tiptap/core';
3
- import InlineEditor from './InlineEditor.svelte';
4
- import type { ActorSearch } from './login/types.js';
5
- import { graphemeLength } from '../social/richtext.js';
6
- let {
7
- value = $bindable(''),
8
- editor = $bindable<Editor | null>(null),
9
- searchActors,
10
- maxLength = 300,
11
- disabled = false,
12
- onupdate
13
- }: {
14
- value?: string;
15
- editor?: Editor | null;
16
- searchActors?: ActorSearch;
17
- maxLength?: number;
18
- disabled?: boolean;
19
- onupdate?: (content: { text: string; json: JSONContent }) => void;
20
- } = $props();
21
- let length = $derived(graphemeLength(value));
22
- </script>
23
-
24
- <InlineEditor
25
- bind:value
26
- bind:editor
27
- label="Post text"
28
- placeholder="What’s happening?"
29
- {searchActors}
30
- {disabled}
31
- {onupdate}
32
- class="min-h-24 text-sm leading-relaxed"
33
- />
34
- <p
35
- class={length > maxLength
36
- ? 'red mt-2 text-right text-xs text-accent-700 dark:text-accent-300'
37
- : 'mt-2 text-right text-xs text-base-600 dark:text-base-400'}
38
- aria-live="polite"
39
- >
40
- {length} / {maxLength}
41
- </p>
@@ -1,16 +0,0 @@
1
- import type { Editor, JSONContent } from '@tiptap/core';
2
- import type { ActorSearch } from './login/types.js';
3
- type $$ComponentProps = {
4
- value?: string;
5
- editor?: Editor | null;
6
- searchActors?: ActorSearch;
7
- maxLength?: number;
8
- disabled?: boolean;
9
- onupdate?: (content: {
10
- text: string;
11
- json: JSONContent;
12
- }) => void;
13
- };
14
- declare const PostComposer: import("svelte").Component<$$ComponentProps, {}, "value" | "editor">;
15
- type PostComposer = ReturnType<typeof PostComposer>;
16
- export default PostComposer;