@atmo-dev/kit 0.19.0 → 0.19.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.
|
@@ -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}
|
|
@@ -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) => {
|