@aionbuilders/nabu 0.1.0-beta.0 → 0.1.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/CHANGELOG.md +531 -0
- package/LICENSE +21 -0
- package/README.md +72 -341
- package/dist/behaviors/text/RichText.svelte +24 -4
- package/dist/behaviors/text/markdown-shortcuts.extension.d.ts +3 -0
- package/dist/behaviors/text/markdown-shortcuts.extension.js +35 -10
- package/dist/behaviors/text/markdown-syntax.d.ts +42 -0
- package/dist/behaviors/text/markdown-syntax.js +81 -0
- package/dist/behaviors/text/rich-text.extension.d.ts +3 -0
- package/dist/behaviors/text/rich-text.extension.js +95 -38
- package/dist/behaviors/text/text.behavior.svelte.d.ts +195 -55
- package/dist/behaviors/text/text.behavior.svelte.js +531 -103
- package/dist/behaviors/text/typography.extension.d.ts +2 -1
- package/dist/behaviors/text/typography.extension.js +3 -2
- package/dist/blocks/BlockList.svelte +48 -0
- package/dist/blocks/BlockList.svelte.d.ts +17 -0
- package/dist/blocks/Nabu.svelte +169 -25
- package/dist/blocks/Nabu.svelte.d.ts +13 -0
- package/dist/blocks/block.extension.d.ts +3 -0
- package/dist/blocks/block.extension.js +4 -7
- package/dist/blocks/block.svelte.d.ts +350 -86
- package/dist/blocks/block.svelte.js +370 -59
- package/dist/blocks/blockquote/Blockquote.svelte +1 -2
- package/dist/blocks/blockquote/blockquote.extension.d.ts +4 -1
- package/dist/blocks/blockquote/blockquote.extension.js +14 -5
- package/dist/blocks/blockquote/blockquote.svelte.d.ts +19 -11
- package/dist/blocks/blockquote/blockquote.svelte.js +58 -13
- package/dist/blocks/callout/Callout.svelte +6 -8
- package/dist/blocks/callout/callout.extension.d.ts +4 -1
- package/dist/blocks/callout/callout.extension.js +19 -3
- package/dist/blocks/callout/callout.svelte.d.ts +5 -3
- package/dist/blocks/callout/callout.svelte.js +11 -6
- package/dist/blocks/chunks.d.ts +49 -0
- package/dist/blocks/chunks.js +90 -0
- package/dist/blocks/code/Code.svelte +7 -8
- package/dist/blocks/code/code.extension.d.ts +4 -1
- package/dist/blocks/code/code.extension.js +22 -2
- package/dist/blocks/code/code.svelte.d.ts +9 -2
- package/dist/blocks/code/code.svelte.js +49 -25
- package/dist/blocks/container.utils.d.ts +85 -13
- package/dist/blocks/container.utils.js +338 -178
- package/dist/blocks/dialogue/Dialogue.svelte +8 -4
- package/dist/blocks/dialogue/dialogue.svelte.d.ts +33 -2
- package/dist/blocks/dialogue/dialogue.svelte.js +58 -4
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.d.ts +2 -2
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.js +6 -4
- package/dist/blocks/dialogue/index.d.ts +12 -1
- package/dist/blocks/dialogue/index.js +51 -35
- package/dist/blocks/divider/divider.extension.d.ts +23 -1
- package/dist/blocks/divider/divider.extension.js +85 -19
- package/dist/blocks/divider/divider.svelte.d.ts +7 -2
- package/dist/blocks/divider/divider.svelte.js +9 -4
- package/dist/blocks/file/File.svelte +13 -6
- package/dist/blocks/file/file.extension.d.ts +4 -1
- package/dist/blocks/file/file.extension.js +9 -1
- package/dist/blocks/file/file.svelte.d.ts +3 -3
- package/dist/blocks/file/file.svelte.js +20 -14
- package/dist/blocks/heading/Heading.svelte +1 -2
- package/dist/blocks/heading/heading.svelte.d.ts +23 -11
- package/dist/blocks/heading/heading.svelte.js +68 -13
- package/dist/blocks/heading/hooks/onBeforeInput.hook.js +7 -5
- package/dist/blocks/heading/index.d.ts +2 -2
- package/dist/blocks/heading/index.js +33 -8
- package/dist/blocks/image/Image.svelte +5 -2
- package/dist/blocks/image/image.extension.d.ts +4 -1
- package/dist/blocks/image/image.extension.js +9 -1
- package/dist/blocks/image/image.svelte.d.ts +17 -6
- package/dist/blocks/image/image.svelte.js +33 -11
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/index.js +1 -1
- package/dist/blocks/list/List.svelte +1 -0
- package/dist/blocks/list/ListItem.svelte +1 -0
- package/dist/blocks/list/convert.d.ts +20 -0
- package/dist/blocks/list/convert.js +92 -0
- package/dist/blocks/list/hooks/onBeforeInput.hook.js +49 -28
- package/dist/blocks/list/html-flat.d.ts +78 -0
- package/dist/blocks/list/html-flat.js +244 -0
- package/dist/blocks/list/indent.d.ts +86 -0
- package/dist/blocks/list/indent.js +205 -0
- package/dist/blocks/list/index.d.ts +6 -3
- package/dist/blocks/list/index.js +42 -31
- package/dist/blocks/list/list-item.svelte.d.ts +32 -18
- package/dist/blocks/list/list-item.svelte.js +99 -100
- package/dist/blocks/list/list.behavior.svelte.d.ts +4 -1
- package/dist/blocks/list/list.behavior.svelte.js +6 -1
- package/dist/blocks/list/list.svelte.d.ts +89 -18
- package/dist/blocks/list/list.svelte.js +129 -125
- package/dist/blocks/list/markdown.d.ts +149 -0
- package/dist/blocks/list/markdown.js +442 -0
- package/dist/blocks/list/normalize.d.ts +11 -0
- package/dist/blocks/list/normalize.js +396 -0
- package/dist/blocks/list/paste.d.ts +45 -0
- package/dist/blocks/list/paste.js +242 -0
- package/dist/blocks/list/step-back.d.ts +24 -0
- package/dist/blocks/list/step-back.js +87 -0
- package/dist/blocks/list/to-list.d.ts +7 -0
- package/dist/blocks/list/to-list.js +44 -0
- package/dist/blocks/list/todos-toggle.d.ts +20 -0
- package/dist/blocks/list/todos-toggle.js +48 -0
- package/dist/blocks/media/markdown.d.ts +12 -0
- package/dist/blocks/media/markdown.js +26 -0
- package/dist/blocks/media/media-block.svelte.d.ts +77 -2
- package/dist/blocks/media/media-block.svelte.js +124 -12
- package/dist/blocks/media/media.helpers.d.ts +6 -1
- package/dist/blocks/media/media.helpers.js +43 -6
- package/dist/blocks/megablock.svelte.d.ts +50 -19
- package/dist/blocks/megablock.svelte.js +114 -74
- package/dist/blocks/move.d.ts +23 -0
- package/dist/blocks/move.js +92 -0
- package/dist/blocks/nabu.svelte.d.ts +764 -71
- package/dist/blocks/nabu.svelte.js +1753 -189
- package/dist/blocks/paragraph/Paragraph.svelte +1 -2
- package/dist/blocks/paragraph/index.d.ts +2 -2
- package/dist/blocks/paragraph/index.js +35 -13
- package/dist/blocks/paragraph/paragraph.svelte.d.ts +46 -14
- package/dist/blocks/paragraph/paragraph.svelte.js +77 -16
- package/dist/blocks/paragraph/table.html.d.ts +9 -0
- package/dist/blocks/paragraph/table.html.js +111 -0
- package/dist/blocks/paragraph/table.markdown.d.ts +32 -0
- package/dist/blocks/paragraph/table.markdown.js +90 -0
- package/dist/blocks/region/Region.svelte +264 -0
- package/dist/blocks/region/Region.svelte.d.ts +11 -0
- package/dist/blocks/region/actions.d.ts +135 -0
- package/dist/blocks/region/actions.js +402 -0
- package/dist/blocks/region/close.d.ts +35 -0
- package/dist/blocks/region/close.js +130 -0
- package/dist/blocks/region/commands.d.ts +6 -0
- package/dist/blocks/region/commands.js +277 -0
- package/dist/blocks/region/create.d.ts +72 -0
- package/dist/blocks/region/create.js +208 -0
- package/dist/blocks/region/end-marker.d.ts +35 -0
- package/dist/blocks/region/end-marker.js +51 -0
- package/dist/blocks/region/facts.d.ts +69 -0
- package/dist/blocks/region/facts.js +152 -0
- package/dist/blocks/region/format.d.ts +91 -0
- package/dist/blocks/region/format.js +260 -0
- package/dist/blocks/region/index.d.ts +14 -0
- package/dist/blocks/region/index.js +14 -0
- package/dist/blocks/region/insert.d.ts +59 -0
- package/dist/blocks/region/insert.js +102 -0
- package/dist/blocks/region/messages.d.ts +254 -0
- package/dist/blocks/region/messages.js +131 -0
- package/dist/blocks/region/normalize.d.ts +7 -0
- package/dist/blocks/region/normalize.js +170 -0
- package/dist/blocks/region/region.extension.d.ts +58 -0
- package/dist/blocks/region/region.extension.js +119 -0
- package/dist/blocks/region/region.svelte.d.ts +221 -0
- package/dist/blocks/region/region.svelte.js +582 -0
- package/dist/blocks/region/regions.svelte.d.ts +141 -0
- package/dist/blocks/region/regions.svelte.js +276 -0
- package/dist/blocks/region/serialize.d.ts +57 -0
- package/dist/blocks/region/serialize.js +112 -0
- package/dist/blocks/region/types.d.ts +255 -0
- package/dist/blocks/region/types.js +204 -0
- package/dist/blocks/selection.svelte.d.ts +106 -8
- package/dist/blocks/selection.svelte.js +622 -74
- package/dist/blocks/subthread.d.ts +80 -0
- package/dist/blocks/subthread.js +167 -0
- package/dist/blocks/text-block.svelte.d.ts +35 -14
- package/dist/blocks/text-block.svelte.js +42 -8
- package/dist/blocks/toggle/Toggle.svelte +4 -15
- package/dist/blocks/toggle/markdown.d.ts +20 -0
- package/dist/blocks/toggle/markdown.js +112 -0
- package/dist/blocks/toggle/toggle.extension.d.ts +4 -1
- package/dist/blocks/toggle/toggle.extension.js +6 -0
- package/dist/blocks/toggle/toggle.svelte.d.ts +55 -8
- package/dist/blocks/toggle/toggle.svelte.js +134 -34
- package/dist/blocks/undo-selection.d.ts +175 -0
- package/dist/blocks/undo-selection.js +360 -0
- package/dist/blocks/video/Video.svelte +5 -2
- package/dist/blocks/video/video.extension.d.ts +4 -1
- package/dist/blocks/video/video.extension.js +9 -1
- package/dist/blocks/video/video.svelte.d.ts +6 -5
- package/dist/blocks/video/video.svelte.js +18 -9
- package/dist/extend.d.ts +55 -0
- package/dist/extend.js +88 -0
- package/dist/files/assets.clipboard.d.ts +77 -0
- package/dist/files/assets.clipboard.js +152 -0
- package/dist/files/files.svelte.d.ts +321 -19
- package/dist/files/files.svelte.js +847 -43
- package/dist/files/index.d.ts +3 -1
- package/dist/files/index.js +3 -1
- package/dist/files/outbox.d.ts +69 -0
- package/dist/files/outbox.js +48 -0
- package/dist/files/status.d.ts +65 -0
- package/dist/files/status.js +87 -0
- package/dist/files/store.d.ts +97 -0
- package/dist/files/store.js +65 -0
- package/dist/files/uploads.svelte.d.ts +174 -0
- package/dist/files/uploads.svelte.js +504 -0
- package/dist/index.d.ts +68 -9
- package/dist/index.js +117 -10
- package/dist/nabu-theme.css +21 -1
- package/dist/paste/html.paste.d.ts +74 -3
- package/dist/paste/html.paste.js +550 -86
- package/dist/paste/markdown-inline.d.ts +86 -0
- package/dist/paste/markdown-inline.js +528 -0
- package/dist/paste/markdown.paste.d.ts +2 -8
- package/dist/paste/markdown.paste.js +78 -94
- package/dist/paste/nabu.paste.d.ts +3 -0
- package/dist/paste/nabu.paste.js +29 -3
- package/dist/paste/plain-text.paste.d.ts +2 -2
- package/dist/paste/plain-text.paste.js +3 -3
- package/dist/persistence/asset-store.d.ts +51 -0
- package/dist/persistence/asset-store.js +103 -0
- package/dist/persistence/autosave.d.ts +53 -0
- package/dist/persistence/autosave.js +62 -0
- package/dist/persistence/compact.d.ts +162 -0
- package/dist/persistence/compact.js +141 -0
- package/dist/persistence/history.d.ts +77 -0
- package/dist/persistence/history.js +176 -0
- package/dist/persistence/indexeddb.d.ts +190 -4
- package/dist/persistence/indexeddb.js +333 -29
- package/dist/persistence/merge.d.ts +38 -0
- package/dist/persistence/merge.js +36 -0
- package/dist/persistence/outbox.d.ts +25 -0
- package/dist/persistence/outbox.js +40 -0
- package/dist/persistence/persistence.d.ts +70 -9
- package/dist/persistence/persistence.js +507 -35
- package/dist/persistence/recovery.d.ts +79 -0
- package/dist/persistence/recovery.js +79 -0
- package/dist/persistence/release.d.ts +34 -0
- package/dist/persistence/release.js +64 -0
- package/dist/persistence/state.svelte.d.ts +53 -0
- package/dist/persistence/state.svelte.js +48 -0
- package/dist/persistence/sync.d.ts +39 -0
- package/dist/persistence/sync.js +138 -0
- package/dist/persistence/tail.d.ts +42 -0
- package/dist/persistence/tail.js +103 -0
- package/dist/presets.d.ts +29 -26
- package/dist/presets.js +35 -13
- package/dist/themes/atelier.css +318 -0
- package/dist/ui/CommandChooser.svelte +153 -0
- package/dist/ui/CommandChooser.svelte.d.ts +13 -0
- package/dist/ui/CommandInvite.svelte +99 -0
- package/dist/ui/CommandInvite.svelte.d.ts +12 -0
- package/dist/ui/DragHandle.svelte +97 -21
- package/dist/ui/FloatingToolbar.svelte +75 -27
- package/dist/ui/FloatingToolbar.svelte.d.ts +10 -0
- package/dist/ui/SlashMenu.svelte +147 -15
- package/dist/ui/SlashMenu.svelte.d.ts +20 -0
- package/dist/ui/anchor.d.ts +112 -0
- package/dist/ui/anchor.js +136 -0
- package/dist/ui/index.d.ts +7 -1
- package/dist/ui/index.js +12 -1
- package/dist/ui/slash-menu.svelte.d.ts +79 -7
- package/dist/ui/slash-menu.svelte.js +85 -51
- package/dist/utils/command-confirm.svelte.d.ts +349 -0
- package/dist/utils/command-confirm.svelte.js +673 -0
- package/dist/utils/commands.d.ts +328 -0
- package/dist/utils/commands.js +416 -0
- package/dist/utils/composition.d.ts +28 -0
- package/dist/utils/composition.js +51 -0
- package/dist/utils/dom-scope.d.ts +14 -0
- package/dist/utils/dom-scope.js +20 -0
- package/dist/utils/drop.d.ts +160 -0
- package/dist/utils/drop.js +305 -0
- package/dist/utils/extensions.d.ts +439 -45
- package/dist/utils/extensions.js +271 -29
- package/dist/utils/html.d.ts +44 -0
- package/dist/utils/html.js +183 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/keys.d.ts +120 -0
- package/dist/utils/keys.js +248 -0
- package/dist/utils/links.d.ts +22 -0
- package/dist/utils/links.js +34 -0
- package/dist/utils/placeholders.d.ts +81 -3
- package/dist/utils/placeholders.js +73 -3
- package/dist/utils/selection.svelte.d.ts +48 -20
- package/dist/utils/selection.svelte.js +60 -10
- package/dist/utils/spellcheck.d.ts +9 -0
- package/dist/utils/spellcheck.js +17 -0
- package/dist/utils/tab.d.ts +31 -0
- package/dist/utils/tab.js +117 -0
- package/dist/utils/words.d.ts +42 -0
- package/dist/utils/words.js +147 -0
- package/dist/vite.d.ts +9 -3
- package/dist/vite.js +19 -8
- package/package.json +56 -20
- package/dist/blocks/variable.svelte.d.ts +0 -47
- package/dist/blocks/variable.svelte.js +0 -51
- package/dist/blocks/zone/TemplateEditor.svelte +0 -308
- package/dist/blocks/zone/TemplateEditor.svelte.d.ts +0 -11
- package/dist/blocks/zone/Zone.svelte +0 -272
- package/dist/blocks/zone/Zone.svelte.d.ts +0 -11
- package/dist/blocks/zone/ZoneEditor.svelte +0 -289
- package/dist/blocks/zone/ZoneEditor.svelte.d.ts +0 -11
- package/dist/blocks/zone/ZoneTemplatesList.svelte +0 -188
- package/dist/blocks/zone/ZoneTemplatesList.svelte.d.ts +0 -11
- package/dist/blocks/zone/hooks/onBeforeInput.hook.d.ts +0 -3
- package/dist/blocks/zone/hooks/onBeforeInput.hook.js +0 -30
- package/dist/blocks/zone/index.d.ts +0 -2
- package/dist/blocks/zone/index.js +0 -2
- package/dist/blocks/zone/zone.extension.d.ts +0 -2
- package/dist/blocks/zone/zone.extension.js +0 -237
- package/dist/blocks/zone/zone.svelte.d.ts +0 -221
- package/dist/blocks/zone/zone.svelte.js +0 -608
- package/dist/overlays/context/Context.svelte +0 -182
- package/dist/overlays/context/Context.svelte.d.ts +0 -17
- package/dist/overlays/context/collect.d.ts +0 -17
- package/dist/overlays/context/collect.js +0 -33
- package/dist/overlays/context/context.extension.d.ts +0 -2
- package/dist/overlays/context/context.extension.js +0 -8
- package/dist/overlays/context/context.svelte.d.ts +0 -82
- package/dist/overlays/context/context.svelte.js +0 -159
- package/dist/overlays/context/index.d.ts +0 -3
- package/dist/overlays/context/index.js +0 -3
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
// Default NEUTRAL rendering of the `invite` strategy (ADR 017 §3.4b): a small hint at the caret. It also serves as the
|
|
3
|
+
// fallback of `hold` when the hold's target cannot draw the progress (no target, or not mounted): see `hold`.
|
|
4
|
+
// Screen readers get the same text from the editor's live region, so the hint itself is aria-hidden.
|
|
5
|
+
import { commandTargetElement } from '../utils/command-confirm.svelte.js';
|
|
6
|
+
import { anchorRect, placeNear } from './anchor.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @type {{
|
|
10
|
+
* engine: import('../blocks/nabu.svelte.js').Nabu,
|
|
11
|
+
* hold?: 'auto' | boolean,
|
|
12
|
+
* }}
|
|
13
|
+
* `hold`: `'auto'` (default) shows the hint, with a progress bar, for a hold whose target has no element to draw on;
|
|
14
|
+
* `true` always shows it; `false` never (the target draws everything).
|
|
15
|
+
*/
|
|
16
|
+
let { engine, hold = 'auto' } = $props();
|
|
17
|
+
|
|
18
|
+
const pending = $derived(engine.pendingCommand);
|
|
19
|
+
const visible = $derived.by(() => {
|
|
20
|
+
const p = pending;
|
|
21
|
+
if (!p) return false;
|
|
22
|
+
if (p.strategy === 'invite') return true;
|
|
23
|
+
if (p.strategy !== 'hold' || hold === false) return false;
|
|
24
|
+
return hold === true || !commandTargetElement(p.target);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/** @type {HTMLElement | null} */
|
|
28
|
+
let el = $state(null);
|
|
29
|
+
/** @type {import('./anchor.js').Placement} */
|
|
30
|
+
let pos = $state({ top: 0, bottom: null, left: 0, maxHeight: 120 });
|
|
31
|
+
|
|
32
|
+
function place() {
|
|
33
|
+
if (!el) return;
|
|
34
|
+
const rect = anchorRect(engine);
|
|
35
|
+
if (rect) pos = placeNear(rect, el, { maxHeight: 120, minHeight: 24 });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
$effect(() => {
|
|
39
|
+
if (!visible) return;
|
|
40
|
+
pending?.message; el; // re-place when the text changes / the element mounts
|
|
41
|
+
place();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
$effect(() => {
|
|
45
|
+
if (!visible) return;
|
|
46
|
+
window.addEventListener('scroll', place, true);
|
|
47
|
+
window.addEventListener('resize', place);
|
|
48
|
+
return () => { window.removeEventListener('scroll', place, true); window.removeEventListener('resize', place); };
|
|
49
|
+
});
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
{#if visible && pending}
|
|
53
|
+
<div
|
|
54
|
+
bind:this={el}
|
|
55
|
+
class="nabu-command-invite"
|
|
56
|
+
data-nabu-ui
|
|
57
|
+
data-strategy={pending.strategy}
|
|
58
|
+
contenteditable="false"
|
|
59
|
+
aria-hidden="true"
|
|
60
|
+
style:top={pos.top === null ? null : `${pos.top}px`}
|
|
61
|
+
style:bottom={pos.bottom === null ? null : `${pos.bottom}px`}
|
|
62
|
+
style:left="{pos.left}px"
|
|
63
|
+
>
|
|
64
|
+
<span class="nabu-command-invite-text">{pending.message}</span>
|
|
65
|
+
{#if pending.strategy === 'hold'}
|
|
66
|
+
<span class="nabu-command-invite-bar"><span class="nabu-command-invite-fill" style:width="{pending.progress * 100}%"></span></span>
|
|
67
|
+
{/if}
|
|
68
|
+
</div>
|
|
69
|
+
{/if}
|
|
70
|
+
|
|
71
|
+
<style>
|
|
72
|
+
.nabu-command-invite {
|
|
73
|
+
position: fixed;
|
|
74
|
+
z-index: var(--nb-command-z, 200);
|
|
75
|
+
max-width: min(360px, calc(100vw - 16px));
|
|
76
|
+
padding: var(--nb-command-padding, 6px 10px);
|
|
77
|
+
background: var(--nb-command-bg, var(--nb-bg-surface, #1a1a1a));
|
|
78
|
+
color: var(--nb-command-text, var(--nb-text-primary, rgba(255,255,255,0.85)));
|
|
79
|
+
border: 1px solid var(--nb-command-border, var(--nb-border, rgba(255,255,255,0.12)));
|
|
80
|
+
border-radius: var(--nb-command-radius, 8px);
|
|
81
|
+
box-shadow: var(--nb-command-shadow, 0 8px 24px rgba(0,0,0,0.35));
|
|
82
|
+
font-size: var(--nb-command-font-size, 12px);
|
|
83
|
+
line-height: 1.4;
|
|
84
|
+
pointer-events: none;
|
|
85
|
+
}
|
|
86
|
+
.nabu-command-invite-bar {
|
|
87
|
+
display: block;
|
|
88
|
+
height: 2px;
|
|
89
|
+
margin-top: 6px;
|
|
90
|
+
background: var(--nb-command-track, color-mix(in srgb, currentColor 18%, transparent));
|
|
91
|
+
border-radius: 1px;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
}
|
|
94
|
+
.nabu-command-invite-fill {
|
|
95
|
+
display: block;
|
|
96
|
+
height: 100%;
|
|
97
|
+
background: var(--nb-command-accent, currentColor);
|
|
98
|
+
}
|
|
99
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default CommandInvite;
|
|
2
|
+
type CommandInvite = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<{
|
|
5
|
+
engine: Nabu;
|
|
6
|
+
hold?: boolean | "auto" | undefined;
|
|
7
|
+
}>): void;
|
|
8
|
+
};
|
|
9
|
+
declare const CommandInvite: import("svelte").Component<{
|
|
10
|
+
engine: import("../blocks/nabu.svelte.js").Nabu;
|
|
11
|
+
hold?: "auto" | boolean;
|
|
12
|
+
}, {}, "">;
|
|
@@ -9,23 +9,86 @@
|
|
|
9
9
|
/** @type {{ blockId: string, position: 'before'|'after' } | null} */
|
|
10
10
|
let dropTarget = null;
|
|
11
11
|
let draggedId = /** @type {string|null} */ (null);
|
|
12
|
+
/** Ids of every block travelling with the dragged one (see `Block#dragRange`): hidden from the drop targets, dimmed while dragging. */
|
|
13
|
+
let draggedIds = /** @type {Set<string>} */ (new Set());
|
|
12
14
|
|
|
13
15
|
const HANDLE_W = 24;
|
|
16
|
+
const HANDLE_H = 22; // keep in sync with the CSS height
|
|
17
|
+
/** First lines at least this tall (body text and up) keep the handle flush with the block's top (+2px), see `handleTop`. */
|
|
18
|
+
const FLUSH_LINE = 16;
|
|
19
|
+
/** Blocks thinner than this (dividers, region seams) are a hard target: the pointer may be within `NEAR` px of them. */
|
|
20
|
+
const THIN = 14;
|
|
21
|
+
const NEAR = 6;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The block's FIRST line box, in viewport coordinates: the client rect of its own first text (not a nested block's), else
|
|
25
|
+
* — void blocks (divider, media, empty text) — the block's top strip: its computed line height (the whole block when it is
|
|
26
|
+
* thinner than that).
|
|
27
|
+
* @param {Element} b
|
|
28
|
+
* @returns {{ cy: number, h: number }} vertical centre and height of the first line
|
|
29
|
+
*/
|
|
30
|
+
function firstLine(b) {
|
|
31
|
+
const walker = document.createTreeWalker(b, NodeFilter.SHOW_TEXT, {
|
|
32
|
+
acceptNode: (n) => (n.nodeValue?.trim() && n.parentElement?.closest('[data-block-id]') === b && !n.parentElement?.closest('[data-nabu-ui]'))
|
|
33
|
+
? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT,
|
|
34
|
+
});
|
|
35
|
+
const text = walker.nextNode();
|
|
36
|
+
if (text) {
|
|
37
|
+
const range = document.createRange();
|
|
38
|
+
range.selectNodeContents(text);
|
|
39
|
+
const line = range.getClientRects()[0];
|
|
40
|
+
if (line && line.height) return { cy: line.top + line.height / 2, h: line.height };
|
|
41
|
+
}
|
|
42
|
+
const r = b.getBoundingClientRect();
|
|
43
|
+
const cs = getComputedStyle(b);
|
|
44
|
+
const lh = parseFloat(cs.lineHeight) || (parseFloat(cs.fontSize) || 16) * 1.2;
|
|
45
|
+
const h = Math.min(lh, r.height);
|
|
46
|
+
return { cy: r.top + h / 2, h };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Viewport `top` of the handle for block `b`: its centre on the centre of the block's first line. Blocks with a normal-size
|
|
51
|
+
* first line (body text, headings, media) keep the handle from sticking out above the block (flush at +2px, as for every
|
|
52
|
+
* paragraph); a small first line (a region seam's caption) or a hairline block (divider) is centred exactly.
|
|
53
|
+
* @param {Element} b
|
|
54
|
+
*/
|
|
55
|
+
function handleTop(b) {
|
|
56
|
+
const { cy, h } = firstLine(b);
|
|
57
|
+
const top = cy - HANDLE_H / 2;
|
|
58
|
+
return h >= FLUSH_LINE ? Math.max(top, b.getBoundingClientRect().top + 2) : top;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The block under the pointer; failing that, a THIN block (divider, seam) within `NEAR` px above / below it — a 1px hairline
|
|
63
|
+
* would otherwise be nearly impossible to hover.
|
|
64
|
+
* @param {number} x
|
|
65
|
+
* @param {number} y
|
|
66
|
+
* @returns {Element|null}
|
|
67
|
+
*/
|
|
68
|
+
function hoveredBlock(x, y) {
|
|
69
|
+
const b = blockElAt(x, y, null);
|
|
70
|
+
if (b) return b;
|
|
71
|
+
for (const d of [3, -3, NEAR, -NEAR]) {
|
|
72
|
+
const near = blockElAt(x, y + d, null);
|
|
73
|
+
if (near && near.getBoundingClientRect().height < THIN) return near;
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
14
77
|
|
|
15
78
|
/**
|
|
16
79
|
* Find the nearest block element under a point (skipping the dragged one + UI islands).
|
|
17
80
|
* @param {number} x
|
|
18
81
|
* @param {number} y
|
|
19
|
-
* @param {string|null}
|
|
82
|
+
* @param {Set<string> | null} excluded
|
|
20
83
|
* @returns {Element|null}
|
|
21
84
|
*/
|
|
22
|
-
function blockElAt(x, y,
|
|
85
|
+
function blockElAt(x, y, excluded) {
|
|
23
86
|
let el = /** @type {Element|null} */ (document.elementFromPoint(x, y));
|
|
24
87
|
const root = el?.closest?.('.nabu-editor');
|
|
25
88
|
if (!root) return null;
|
|
26
89
|
const b = el?.closest?.('[data-block-id]');
|
|
27
90
|
if (!b) return null;
|
|
28
|
-
if (
|
|
91
|
+
if (excluded && excluded.has(/** @type {string} */ (b.getAttribute('data-block-id')))) return null;
|
|
29
92
|
// don't target a UI island
|
|
30
93
|
if (b.closest('[data-nabu-ui]')) return null;
|
|
31
94
|
return b;
|
|
@@ -33,16 +96,17 @@
|
|
|
33
96
|
|
|
34
97
|
/** @param {PointerEvent} e */
|
|
35
98
|
function onPointerMove(e) {
|
|
99
|
+
if (engine.readonly) { handle.visible = false; return; } // nothing to reorder
|
|
36
100
|
if (dragging) { onDragMove(e); return; }
|
|
37
101
|
// The handle lives OUTSIDE the editor; while the pointer is over the handle
|
|
38
102
|
// itself, keep it visible — else moving onto it to grab it would hide it.
|
|
39
103
|
const over = document.elementFromPoint(e.clientX, e.clientY);
|
|
40
104
|
if (over?.closest?.('.nabu-drag-handle')) return;
|
|
41
|
-
const b =
|
|
105
|
+
const b = hoveredBlock(e.clientX, e.clientY);
|
|
42
106
|
if (!b) { handle.visible = false; return; }
|
|
43
107
|
const r = b.getBoundingClientRect();
|
|
44
|
-
// Flush against the block's left edge — no dead gap to cross when grabbing.
|
|
45
|
-
handle = { visible: true, top:
|
|
108
|
+
// Flush against the block's left edge — no dead gap to cross when grabbing; centred on the block's first line.
|
|
109
|
+
handle = { visible: true, top: handleTop(b), left: r.left - HANDLE_W, blockId: b.getAttribute('data-block-id') };
|
|
46
110
|
}
|
|
47
111
|
|
|
48
112
|
/** @param {PointerEvent} e */
|
|
@@ -52,16 +116,17 @@
|
|
|
52
116
|
draggedId = handle.blockId;
|
|
53
117
|
if (!draggedId) return;
|
|
54
118
|
dragging = true;
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
119
|
+
// the dragged block and what travels with it (a region seam carries its region): dimmed, and not a drop target
|
|
120
|
+
draggedIds = new Set((engine.blocks.get(draggedId)?.dragRange() ?? []).map((b) => b.id));
|
|
121
|
+
draggedIds.add(draggedId);
|
|
122
|
+
for (const id of draggedIds) document.querySelector(`[data-block-id="${cssEscape(id)}"]`)?.classList.add('nabu-dragging');
|
|
58
123
|
try { /** @type {any} */ (e.target).setPointerCapture?.(e.pointerId); } catch {}
|
|
59
124
|
}
|
|
60
125
|
|
|
61
126
|
/** @param {PointerEvent} e */
|
|
62
127
|
function onDragMove(e) {
|
|
63
128
|
handle.visible = false;
|
|
64
|
-
const b = blockElAt(e.clientX, e.clientY,
|
|
129
|
+
const b = blockElAt(e.clientX, e.clientY, draggedIds);
|
|
65
130
|
if (!b) { indicator.visible = false; dropTarget = null; return; }
|
|
66
131
|
const r = b.getBoundingClientRect();
|
|
67
132
|
const after = e.clientY > r.top + r.height / 2;
|
|
@@ -71,23 +136,34 @@
|
|
|
71
136
|
|
|
72
137
|
function onPointerUp() {
|
|
73
138
|
if (dragging) {
|
|
74
|
-
const
|
|
75
|
-
el?.classList.remove('nabu-dragging');
|
|
139
|
+
for (const id of draggedIds) document.querySelector(`[data-block-id="${cssEscape(id)}"]`)?.classList.remove('nabu-dragging');
|
|
76
140
|
performDrop();
|
|
77
141
|
}
|
|
78
|
-
dragging = false; draggedId = null; indicator.visible = false; dropTarget = null;
|
|
142
|
+
dragging = false; draggedId = null; draggedIds = new Set(); indicator.visible = false; dropTarget = null;
|
|
79
143
|
}
|
|
80
144
|
|
|
81
145
|
function performDrop() {
|
|
82
146
|
const id = draggedId;
|
|
83
|
-
if (!dropTarget || !id) return;
|
|
147
|
+
if (!dropTarget || !id || engine.readonly) return;
|
|
84
148
|
const dragged = engine.blocks.get(id);
|
|
85
|
-
const
|
|
86
|
-
if (!dragged || !
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
149
|
+
const hit = engine.blocks.get(dropTarget.blockId);
|
|
150
|
+
if (!dragged || !hit) return;
|
|
151
|
+
// The range travelling with the block (itself alone, or e.g. a region seam + its region), in document order.
|
|
152
|
+
const moving = dragged.dragRange();
|
|
153
|
+
// never drop a block into itself or into its own subtree (cycle)
|
|
154
|
+
if (moving.some((m) => m === hit || hit.parents?.some((p) => p.id === m.id))) return;
|
|
155
|
+
// A range of several blocks keeps its level (a region's blocks all live at the root): a drop on a block nested in another
|
|
156
|
+
// parent lands next to the ancestor of that block which sits at the range's own level.
|
|
157
|
+
let target = hit;
|
|
158
|
+
if (moving.length > 1) {
|
|
159
|
+
while (target.parent && target.parent !== dragged.parent) target = /** @type {typeof hit} */ (target.parent);
|
|
160
|
+
}
|
|
161
|
+
if (dropTarget.position === 'after') {
|
|
162
|
+
let anchor = target.node;
|
|
163
|
+
for (const m of moving) { m.node.moveAfter(anchor); anchor = m.node; }
|
|
164
|
+
} else {
|
|
165
|
+
for (const m of moving) m.node.moveBefore(target.node);
|
|
166
|
+
}
|
|
91
167
|
// repair structural integrity (e.g. a list-item dropped at root → wrap in a list).
|
|
92
168
|
// No-op for blocks without a requiredParent (paragraph, heading, …).
|
|
93
169
|
const orphan = /** @type {any} */ (dragged);
|
|
@@ -105,7 +181,7 @@
|
|
|
105
181
|
|
|
106
182
|
<svelte:window onpointermove={onPointerMove} onpointerup={onPointerUp} />
|
|
107
183
|
|
|
108
|
-
{#if handle.visible && !dragging}
|
|
184
|
+
{#if handle.visible && !dragging && !engine.readonly}
|
|
109
185
|
<button
|
|
110
186
|
class="nabu-drag-handle"
|
|
111
187
|
data-nabu-ui
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { clipBounds, isOutside, placeAround } from './anchor.js';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* Floating mark toolbar. Appears above the current (non-collapsed) selection.
|
|
4
6
|
* Positioned with `position: fixed` in viewport coordinates, so it works
|
|
5
7
|
* inside any layout (scrollable containers, overflow: hidden ancestors…)
|
|
6
8
|
* without a positioning wrapper.
|
|
7
9
|
*
|
|
10
|
+
* Placement (see `anchor.js`): centred above the selection; flipped BELOW it when there is no room above, measured against
|
|
11
|
+
* the part of the viewport where the selection is visible (the viewport intersected with its scroll containers, so a
|
|
12
|
+
* selection at the top edge of a scroll container gets the toolbar below it); clamped horizontally inside the viewport
|
|
13
|
+
* (and the container); repositioned on scroll (window or any scrollable ancestor) and resize; hidden while the selection
|
|
14
|
+
* is entirely scrolled out of view.
|
|
15
|
+
*
|
|
16
|
+
* A host with a sticky / fixed header over the top of the viewport (outside any scroll container) can reserve room for it
|
|
17
|
+
* with the CSS custom property `--nb-toolbar-inset-top` (a length in px, set on the toolbar or any ancestor, e.g.
|
|
18
|
+
* `--nb-toolbar-inset-top: 56px`): the toolbar never goes above that line, and a selection hidden under it hides the toolbar.
|
|
19
|
+
*
|
|
8
20
|
* @type {{ engine: import('../blocks/nabu.svelte.js').Nabu }}
|
|
9
21
|
*/
|
|
10
22
|
let { engine } = $props();
|
|
@@ -12,40 +24,61 @@
|
|
|
12
24
|
/** @type {HTMLElement | null} */
|
|
13
25
|
let toolbarEl = $state(null);
|
|
14
26
|
let visible = $state(false);
|
|
27
|
+
/** A drag is in progress (dragging the selected text, a file…): the toolbar steps aside, it would sit over the drop targets. */
|
|
28
|
+
let dragging = $state(false);
|
|
15
29
|
let position = $state({ top: 0, left: 0 });
|
|
30
|
+
let lastTop = 0;
|
|
31
|
+
let lastLeft = 0;
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
/** Recompute visibility + placement from the current selection (viewport coordinates; no reactive state is read). */
|
|
34
|
+
function update() {
|
|
18
35
|
const sel = engine.selection;
|
|
19
|
-
if (!sel || sel.isCollapsed) {
|
|
20
|
-
visible = false;
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
36
|
+
if (!sel || sel.isCollapsed) { visible = false; return; }
|
|
23
37
|
// Position above the selection via Range.getBoundingClientRect()
|
|
24
38
|
const range = sel.firstRange;
|
|
25
|
-
if (!range) {
|
|
26
|
-
visible = false;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
39
|
+
if (!range) { visible = false; return; }
|
|
29
40
|
const rect = range.getBoundingClientRect();
|
|
30
41
|
// Collapsed-looking rect (e.g. selection cleared mid-update) → hide
|
|
31
|
-
if (rect.width === 0 && rect.height === 0) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
if (rect.width === 0 && rect.height === 0) { visible = false; return; }
|
|
43
|
+
const inset = toolbarEl ? parseFloat(getComputedStyle(toolbarEl).getPropertyValue('--nb-toolbar-inset-top')) : 0;
|
|
44
|
+
const bounds = clipBounds(range.commonAncestorContainer, { topInset: Number.isFinite(inset) ? inset : 0 });
|
|
45
|
+
// scrolled out of its container / off the viewport: nothing to point at
|
|
46
|
+
if (isOutside(rect, bounds)) { visible = false; return; }
|
|
35
47
|
visible = true;
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
if (!toolbarEl) return; // placed once mounted (this effect re-runs on `toolbarEl`)
|
|
49
|
+
const { top, left } = placeAround(rect, toolbarEl, bounds);
|
|
50
|
+
if (top !== lastTop || left !== lastLeft) { lastTop = top; lastLeft = left; position = { top, left }; }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
$effect(() => {
|
|
54
|
+
toolbarEl; // re-place once the element is mounted (its size is needed)
|
|
55
|
+
update();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// The toolbar is fixed: follow the selection when the window or any scroll container scrolls, and on resize.
|
|
59
|
+
$effect(() => {
|
|
60
|
+
if (!visible) return;
|
|
61
|
+
/** @param {Event} e */
|
|
62
|
+
const onScroll = (e) => { if (!toolbarEl || !(e.target instanceof Node) || !toolbarEl.contains(e.target)) update(); };
|
|
63
|
+
window.addEventListener('scroll', onScroll, true);
|
|
64
|
+
window.addEventListener('resize', update);
|
|
65
|
+
return () => {
|
|
66
|
+
window.removeEventListener('scroll', onScroll, true);
|
|
67
|
+
window.removeEventListener('resize', update);
|
|
40
68
|
};
|
|
41
69
|
});
|
|
42
70
|
|
|
71
|
+
/** The drop is handled after this listener (capture phase): the toolbar comes back only once it is done, else it would cover the drop point. */
|
|
72
|
+
function endDrag() {
|
|
73
|
+
setTimeout(() => { dragging = false; update(); }, 0);
|
|
74
|
+
}
|
|
75
|
+
|
|
43
76
|
const marks = [
|
|
44
|
-
{ key: 'bold', label: 'B', title: 'Bold (Ctrl+B)' },
|
|
45
|
-
{ key: 'italic', label: 'I', title: 'Italic (Ctrl+I)' },
|
|
46
|
-
{ key: 'underline', label: 'U', title: 'Underline (Ctrl+U)' },
|
|
47
|
-
{ key: 'code', label: '<>', title: 'Code (Ctrl+E)' },
|
|
48
|
-
{ key: 'strikethrough', label: 'S', title: 'Strikethrough (Ctrl+Shift+X)' },
|
|
77
|
+
{ key: 'bold', label: 'B', name: 'Bold', title: 'Bold (Ctrl+B)' },
|
|
78
|
+
{ key: 'italic', label: 'I', name: 'Italic', title: 'Italic (Ctrl+I)' },
|
|
79
|
+
{ key: 'underline', label: 'U', name: 'Underline', title: 'Underline (Ctrl+U)' },
|
|
80
|
+
{ key: 'code', label: '<>', name: 'Code', title: 'Code (Ctrl+E)' },
|
|
81
|
+
{ key: 'strikethrough', label: 'S', name: 'Strikethrough', title: 'Strikethrough (Ctrl+Shift+X)' },
|
|
49
82
|
];
|
|
50
83
|
|
|
51
84
|
function toggleLink() {
|
|
@@ -58,18 +91,30 @@
|
|
|
58
91
|
}
|
|
59
92
|
</script>
|
|
60
93
|
|
|
61
|
-
|
|
94
|
+
<svelte:window
|
|
95
|
+
ondragstart={() => { dragging = true; }}
|
|
96
|
+
ondragend={() => { dragging = false; update(); }}
|
|
97
|
+
ondropcapture={endDrag}
|
|
98
|
+
onpointerdowncapture={() => { dragging = false; }}
|
|
99
|
+
/>
|
|
100
|
+
|
|
101
|
+
{#if visible && !dragging && !engine.readonly}
|
|
62
102
|
<div
|
|
63
103
|
bind:this={toolbarEl}
|
|
64
104
|
class="nabu-toolbar"
|
|
105
|
+
role="toolbar"
|
|
106
|
+
aria-label="Text formatting"
|
|
65
107
|
style="top: {position.top}px; left: {position.left}px;"
|
|
66
108
|
contenteditable="false"
|
|
67
109
|
data-nabu-ui
|
|
68
110
|
>
|
|
69
111
|
{#each marks as mark}
|
|
70
112
|
<button
|
|
113
|
+
type="button"
|
|
71
114
|
class="nabu-toolbar-btn"
|
|
72
115
|
class:active={engine.isMarkActive(mark.key)}
|
|
116
|
+
aria-pressed={engine.isMarkActive(mark.key)}
|
|
117
|
+
aria-label={mark.name}
|
|
73
118
|
title={mark.title}
|
|
74
119
|
onmousedown={(e) => { e.preventDefault(); engine.exec('mark:toggle', { mark: mark.key }); }}
|
|
75
120
|
>
|
|
@@ -77,12 +122,15 @@
|
|
|
77
122
|
</button>
|
|
78
123
|
{/each}
|
|
79
124
|
<button
|
|
125
|
+
type="button"
|
|
80
126
|
class="nabu-toolbar-btn"
|
|
81
127
|
class:active={engine.isMarkActive('link')}
|
|
128
|
+
aria-pressed={engine.isMarkActive('link')}
|
|
129
|
+
aria-label="Link"
|
|
82
130
|
title="Link"
|
|
83
131
|
onmousedown={(e) => { e.preventDefault(); toggleLink(); }}
|
|
84
132
|
>
|
|
85
|
-
|
|
133
|
+
<svg class="nabu-toolbar-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6.5 9.5a2.5 2.5 0 0 0 3.54 0l2.46-2.46a2.5 2.5 0 0 0-3.54-3.54l-.7.7"/><path d="M9.5 6.5a2.5 2.5 0 0 0-3.54 0L3.5 8.96a2.5 2.5 0 0 0 3.54 3.54l.7-.7"/></svg>
|
|
86
134
|
</button>
|
|
87
135
|
</div>
|
|
88
136
|
{/if}
|
|
@@ -90,14 +138,13 @@
|
|
|
90
138
|
<style>
|
|
91
139
|
.nabu-toolbar {
|
|
92
140
|
position: fixed;
|
|
93
|
-
transform: translateX(-50%);
|
|
94
141
|
display: flex;
|
|
95
142
|
gap: 2px;
|
|
96
143
|
padding: 4px;
|
|
97
144
|
background: var(--nb-bg-surface, #1a1a1a);
|
|
98
145
|
border: 1px solid var(--nb-border, rgba(255,255,255,0.1));
|
|
99
|
-
border-radius: 8px;
|
|
100
|
-
box-shadow: 0 4px 16px rgba(0,0,0,0.3);
|
|
146
|
+
border-radius: var(--nb-floating-radius, 8px);
|
|
147
|
+
box-shadow: var(--nb-floating-shadow, 0 4px 16px rgba(0,0,0,0.3));
|
|
101
148
|
z-index: 100;
|
|
102
149
|
pointer-events: all;
|
|
103
150
|
}
|
|
@@ -112,6 +159,7 @@
|
|
|
112
159
|
font-weight: 600;
|
|
113
160
|
transition: background 0.1s;
|
|
114
161
|
}
|
|
162
|
+
.nabu-toolbar-icon { display: block; margin: 1px 0; pointer-events: none; }
|
|
115
163
|
.nabu-toolbar-btn:hover { background: var(--nb-bg-surface-hover, rgba(255,255,255,0.08)); }
|
|
116
164
|
.nabu-toolbar-btn.active { background: var(--nb-bg-surface-active, rgba(255,255,255,0.15)); }
|
|
117
165
|
</style>
|
|
@@ -11,6 +11,16 @@ declare const FloatingToolbar: import("svelte").Component<{
|
|
|
11
11
|
* Positioned with `position: fixed` in viewport coordinates, so it works
|
|
12
12
|
* inside any layout (scrollable containers, overflow: hidden ancestors…)
|
|
13
13
|
* without a positioning wrapper.
|
|
14
|
+
*
|
|
15
|
+
* Placement (see `anchor.js`): centred above the selection; flipped BELOW it when there is no room above, measured against
|
|
16
|
+
* the part of the viewport where the selection is visible (the viewport intersected with its scroll containers, so a
|
|
17
|
+
* selection at the top edge of a scroll container gets the toolbar below it); clamped horizontally inside the viewport
|
|
18
|
+
* (and the container); repositioned on scroll (window or any scrollable ancestor) and resize; hidden while the selection
|
|
19
|
+
* is entirely scrolled out of view.
|
|
20
|
+
*
|
|
21
|
+
* A host with a sticky / fixed header over the top of the viewport (outside any scroll container) can reserve room for it
|
|
22
|
+
* with the CSS custom property `--nb-toolbar-inset-top` (a length in px, set on the toolbar or any ancestor, e.g.
|
|
23
|
+
* `--nb-toolbar-inset-top: 56px`): the toolbar never goes above that line, and a selection hidden under it hides the toolbar.
|
|
14
24
|
*/
|
|
15
25
|
type $$ComponentProps = {
|
|
16
26
|
engine: import("../blocks/nabu.svelte.js").Nabu;
|