@atmo-dev/kit 0.19.0 → 0.19.2
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.
|
@@ -386,6 +386,8 @@
|
|
|
386
386
|
});
|
|
387
387
|
</script>
|
|
388
388
|
|
|
389
|
+
<!-- Pointer-only: the editor inside is what keyboards reach. -->
|
|
390
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
389
391
|
<div
|
|
390
392
|
bind:this={host}
|
|
391
393
|
class={cn(
|
|
@@ -393,6 +395,13 @@
|
|
|
393
395
|
className
|
|
394
396
|
)}
|
|
395
397
|
data-slot="rich-text-editor"
|
|
398
|
+
onmousedown={(event) => {
|
|
399
|
+
// Room the class gives beyond the text still places the cursor, at the end.
|
|
400
|
+
if (event.button !== 0 || (event.target !== host && event.target !== element)) return;
|
|
401
|
+
if (!editor?.isEditable) return;
|
|
402
|
+
event.preventDefault();
|
|
403
|
+
editor.commands.focus('end');
|
|
404
|
+
}}
|
|
396
405
|
>
|
|
397
406
|
<div bind:this={element}></div>
|
|
398
407
|
{#if menuTools && editor && host}
|
|
@@ -70,6 +70,11 @@
|
|
|
70
70
|
notice?: string;
|
|
71
71
|
/** More toolbar buttons, after the built-in ones. */
|
|
72
72
|
actions?: Snippet<[{ post: Post; insert: (text: string) => void; disabled: boolean }]>;
|
|
73
|
+
/**
|
|
74
|
+
* `inline` sits in the page, e.g. a reply field under a post: no header or dividers,
|
|
75
|
+
* with Cancel and the submit button at the end of the toolbar.
|
|
76
|
+
*/
|
|
77
|
+
layout?: 'default' | 'inline';
|
|
73
78
|
class?: string;
|
|
74
79
|
};
|
|
75
80
|
</script>
|
|
@@ -134,8 +139,10 @@
|
|
|
134
139
|
notice,
|
|
135
140
|
drafts: draftStore,
|
|
136
141
|
actions,
|
|
142
|
+
layout = 'default',
|
|
137
143
|
class: className
|
|
138
144
|
}: PostComposerProps = $props();
|
|
145
|
+
const inline = untrack(() => layout === 'inline');
|
|
139
146
|
|
|
140
147
|
let limits = $derived({ ...defaultComposerLimits, ...limitOverrides });
|
|
141
148
|
const on = (feature: keyof ComposerFeatures) => features[feature] !== false;
|
|
@@ -395,6 +402,26 @@
|
|
|
395
402
|
}
|
|
396
403
|
</script>
|
|
397
404
|
|
|
405
|
+
{#snippet controls()}
|
|
406
|
+
{#if oncancel}
|
|
407
|
+
<Button variant="ghost" size="sm" onclick={cancel} disabled={busy}>
|
|
408
|
+
{labels.cancel ?? 'Cancel'}
|
|
409
|
+
</Button>
|
|
410
|
+
{/if}
|
|
411
|
+
<span class="min-w-0 flex-1 truncate text-right text-xs {muted}" aria-live="polite">{status}</span
|
|
412
|
+
>
|
|
413
|
+
{#if canDraft}
|
|
414
|
+
<Button variant="ghost" size="sm" onclick={() => (draftsOpen = true)} disabled={busy}>
|
|
415
|
+
Drafts
|
|
416
|
+
</Button>
|
|
417
|
+
{/if}
|
|
418
|
+
<Button size="sm" class="min-w-16" onclick={submit} disabled={!canPost} loading={busy}>
|
|
419
|
+
{posts.length > 1
|
|
420
|
+
? (labels.submitAll ?? 'Post all')
|
|
421
|
+
: (labels.submit ?? (reply ? 'Reply' : 'Post'))}
|
|
422
|
+
</Button>
|
|
423
|
+
{/snippet}
|
|
424
|
+
|
|
398
425
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
399
426
|
<div
|
|
400
427
|
class={cn('relative flex min-h-0 flex-1 flex-col', className)}
|
|
@@ -406,28 +433,13 @@
|
|
|
406
433
|
ondragover={(e) => hasFiles(e) && e.preventDefault()}
|
|
407
434
|
ondrop={drop}
|
|
408
435
|
>
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
{/if}
|
|
415
|
-
<span class="min-w-0 flex-1 truncate text-right text-xs {muted}" aria-live="polite"
|
|
416
|
-
>{status}</span
|
|
417
|
-
>
|
|
418
|
-
{#if canDraft}
|
|
419
|
-
<Button variant="ghost" size="sm" onclick={() => (draftsOpen = true)} disabled={busy}>
|
|
420
|
-
Drafts
|
|
421
|
-
</Button>
|
|
422
|
-
{/if}
|
|
423
|
-
<Button size="sm" class="min-w-16" onclick={submit} disabled={!canPost} loading={busy}>
|
|
424
|
-
{posts.length > 1
|
|
425
|
-
? (labels.submitAll ?? 'Post all')
|
|
426
|
-
: (labels.submit ?? (reply ? 'Reply' : 'Post'))}
|
|
427
|
-
</Button>
|
|
428
|
-
</div>
|
|
436
|
+
{#if !inline}
|
|
437
|
+
<div class="flex shrink-0 items-center gap-2 px-3 py-2.5">
|
|
438
|
+
{@render controls()}
|
|
439
|
+
</div>
|
|
440
|
+
{/if}
|
|
429
441
|
|
|
430
|
-
<div class="min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pt-2">
|
|
442
|
+
<div class="min-h-0 flex-1 overflow-y-auto overscroll-contain {inline ? 'pt-1' : 'px-4 pt-2'}">
|
|
431
443
|
{#if replyTo}
|
|
432
444
|
<div class="mb-3 flex gap-3 border-b pb-3 {line}">
|
|
433
445
|
{#if author}<span class="w-10 shrink-0"></span>{/if}
|
|
@@ -466,10 +478,10 @@
|
|
|
466
478
|
{/if}
|
|
467
479
|
</div>
|
|
468
480
|
|
|
469
|
-
{#if notice}<p class="shrink-0
|
|
481
|
+
{#if notice}<p class="shrink-0 pb-2 text-xs {inline ? '' : 'px-4'} {muted}">{notice}</p>{/if}
|
|
470
482
|
|
|
471
483
|
{#if on('interactions') || (on('contentWarnings') && contentWarnings.length && hasMedia(current))}
|
|
472
|
-
<div class="flex shrink-0 flex-wrap items-center gap-2
|
|
484
|
+
<div class="flex shrink-0 flex-wrap items-center gap-2 pb-1.5 {inline ? '' : 'px-4'}">
|
|
473
485
|
{#if on('interactions')}
|
|
474
486
|
<Button
|
|
475
487
|
variant="secondary"
|
|
@@ -498,7 +510,11 @@
|
|
|
498
510
|
</div>
|
|
499
511
|
{/if}
|
|
500
512
|
|
|
501
|
-
<div
|
|
513
|
+
<div
|
|
514
|
+
class="flex shrink-0 items-center gap-0.5 {inline
|
|
515
|
+
? '-ml-2 pb-1'
|
|
516
|
+
: `border-t px-2 py-1.5 ${line}`}"
|
|
517
|
+
>
|
|
502
518
|
{#if on('images')}
|
|
503
519
|
<input
|
|
504
520
|
bind:this={imageInput}
|
|
@@ -592,6 +608,7 @@
|
|
|
592
608
|
onclick={addPost}><Icon img={Plus} /></IconButton
|
|
593
609
|
>
|
|
594
610
|
{/if}
|
|
611
|
+
{#if inline}<span class="ml-1.5 flex items-center gap-2">{@render controls()}</span>{/if}
|
|
595
612
|
</div>
|
|
596
613
|
|
|
597
614
|
{#if dragging}
|
|
@@ -72,6 +72,11 @@ export type PostComposerProps = {
|
|
|
72
72
|
insert: (text: string) => void;
|
|
73
73
|
disabled: boolean;
|
|
74
74
|
}]>;
|
|
75
|
+
/**
|
|
76
|
+
* `inline` sits in the page, e.g. a reply field under a post: no header or dividers,
|
|
77
|
+
* with Cancel and the submit button at the end of the toolbar.
|
|
78
|
+
*/
|
|
79
|
+
layout?: 'default' | 'inline';
|
|
75
80
|
class?: string;
|
|
76
81
|
};
|
|
77
82
|
declare const PostComposer: import("svelte").Component<PostComposerProps, {
|
|
@@ -17,6 +17,8 @@ export function mentionSuggestions(search, host) {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const close = () => {
|
|
20
|
+
removeEventListener('scroll', draw, true);
|
|
21
|
+
removeEventListener('resize', draw);
|
|
20
22
|
if (options)
|
|
21
23
|
void unmount(options);
|
|
22
24
|
options = undefined;
|
|
@@ -30,14 +32,18 @@ export function mentionSuggestions(search, host) {
|
|
|
30
32
|
if (!menu)
|
|
31
33
|
return;
|
|
32
34
|
state.items = current.items;
|
|
33
|
-
const rect = current.clientRect?.();
|
|
34
|
-
const bounds = host().getBoundingClientRect();
|
|
35
|
-
if (rect) {
|
|
36
|
-
menu.style.top = `${rect.bottom - bounds.top + host().scrollTop + 6}px`;
|
|
37
|
-
menu.style.left = `${Math.max(0, Math.min(rect.left - bounds.left, bounds.width - 288))}px`;
|
|
38
|
-
}
|
|
39
35
|
// Nothing to choose from: stay out of the way instead of saying so.
|
|
40
36
|
menu.hidden = !current.items.length;
|
|
37
|
+
const rect = current.clientRect?.();
|
|
38
|
+
if (rect && !menu.hidden) {
|
|
39
|
+
// In the top layer, so a dialog's clipping cannot cut it off. Below the text, or above
|
|
40
|
+
// it when there is more room there than the tallest list needs below.
|
|
41
|
+
const room = innerHeight - rect.bottom;
|
|
42
|
+
const up = room < 360 && rect.top > room;
|
|
43
|
+
menu.style.top = up ? 'auto' : `${rect.bottom + 6}px`;
|
|
44
|
+
menu.style.bottom = up ? `${innerHeight - rect.top + 6}px` : 'auto';
|
|
45
|
+
menu.style.left = `${Math.max(8, Math.min(rect.left, innerWidth - Math.min(288, innerWidth - 16) - 8))}px`;
|
|
46
|
+
}
|
|
41
47
|
if (!current.items.length) {
|
|
42
48
|
current.editor.view.dom.removeAttribute('aria-controls');
|
|
43
49
|
current.editor.view.dom.removeAttribute('aria-activedescendant');
|
|
@@ -72,10 +78,15 @@ export function mentionSuggestions(search, host) {
|
|
|
72
78
|
menu.role = 'listbox';
|
|
73
79
|
menu.setAttribute('aria-label', 'Mention suggestions');
|
|
74
80
|
menu.className =
|
|
75
|
-
'
|
|
81
|
+
'fixed inset-auto z-60 m-0 w-72 max-w-[calc(100vw-1rem)] 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
82
|
state.id = menu.id;
|
|
83
|
+
// Kept inside the editor, so a dialog around it still counts clicks on it as its own.
|
|
84
|
+
menu.popover = 'manual';
|
|
77
85
|
host().append(menu);
|
|
86
|
+
menu.showPopover();
|
|
78
87
|
options = mount(MentionOptions, { target: menu, props: { state } });
|
|
88
|
+
addEventListener('scroll', draw, true);
|
|
89
|
+
addEventListener('resize', draw);
|
|
79
90
|
draw();
|
|
80
91
|
},
|
|
81
92
|
onUpdate: (props) => {
|