@dryui/ui 0.1.2 → 0.1.4
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/accordion/accordion-trigger.svelte +5 -6
- package/dist/alert-dialog/alert-dialog-action.svelte +42 -6
- package/dist/alert-dialog/alert-dialog-cancel.svelte +44 -5
- package/dist/alert-dialog/alert-dialog-footer.svelte +3 -2
- package/dist/aurora/aurora.svelte.d.ts +6 -0
- package/dist/beam/beam.svelte +17 -10
- package/dist/button/button.svelte +51 -1
- package/dist/button-group/button-group.svelte +7 -62
- package/dist/button-group/context.svelte.d.ts +5 -0
- package/dist/button-group/context.svelte.js +11 -0
- package/dist/chromatic-aberration/chromatic-aberration.svelte +60 -18
- package/dist/collapsible/collapsible-trigger.svelte +4 -7
- package/dist/color-picker/color-picker-eyedropper.svelte +4 -11
- package/dist/combobox/combobox-group.svelte +1 -1
- package/dist/data-grid/data-grid-pagination.svelte +20 -2
- package/dist/data-grid/data-grid-root.svelte +1 -0
- package/dist/date-field/date-field-root.svelte +66 -20
- package/dist/date-field/date-field-segment.svelte +11 -9
- package/dist/date-field/date-field-separator.svelte +9 -1
- package/dist/date-picker/datepicker-calendar.svelte +168 -13
- package/dist/date-picker/datepicker-trigger.svelte +3 -8
- package/dist/date-range-picker/date-range-picker-calendar.svelte +177 -13
- package/dist/date-range-picker/date-range-picker-root.svelte +0 -6
- package/dist/date-range-picker/date-range-picker-trigger.svelte +18 -12
- package/dist/dialog/dialog-content.svelte +1 -0
- package/dist/field/field-root.svelte +0 -1
- package/dist/file-select/file-select-clear.svelte +2 -8
- package/dist/file-upload/file-upload-item-delete.svelte +4 -7
- package/dist/file-upload/file-upload-root.svelte +0 -4
- package/dist/flip-card/flip-card-back.svelte +2 -2
- package/dist/flip-card/flip-card-front.svelte +2 -2
- package/dist/flip-card/flip-card-root.svelte +2 -0
- package/dist/float-button/float-button-root.svelte +2 -1
- package/dist/image-comparison/image-comparison.svelte +16 -24
- package/dist/input-group/input-group-action.svelte +5 -0
- package/dist/input-group/input-group-input.svelte +7 -2
- package/dist/input-group/input-group-prefix.svelte +5 -0
- package/dist/input-group/input-group-root.svelte +10 -2
- package/dist/input-group/input-group-select.svelte +5 -0
- package/dist/input-group/input-group-separator.svelte +10 -0
- package/dist/input-group/input-group-suffix.svelte +5 -0
- package/dist/list/list-item-icon.svelte +8 -0
- package/dist/list/list-item-text.svelte +19 -0
- package/dist/list/list-item.svelte +42 -0
- package/dist/list/list-root.svelte +0 -71
- package/dist/list/list-subheader.svelte +11 -0
- package/dist/map/map-marker.svelte +10 -0
- package/dist/map/map-popup.svelte +7 -0
- package/dist/map/map-root.svelte +0 -30
- package/dist/multi-select-combobox/multi-select-combobox-group.svelte +1 -1
- package/dist/option-swatch-group/option-swatch-group-item.svelte +46 -0
- package/dist/option-swatch-group/option-swatch-group-label.svelte +10 -0
- package/dist/option-swatch-group/option-swatch-group-meta.svelte +10 -0
- package/dist/option-swatch-group/option-swatch-group-root.svelte +0 -79
- package/dist/option-swatch-group/option-swatch-group-swatch.svelte +25 -6
- package/dist/pin-input/pin-input-cell.svelte +4 -1
- package/dist/radio-group/radio-group-item.svelte +90 -0
- package/dist/radio-group/radio-group.svelte +0 -89
- package/dist/range-calendar/range-calendar-grid.svelte +217 -179
- package/dist/range-calendar/range-calendar-root.svelte +24 -10
- package/dist/rich-text-editor/rich-text-editor-content.svelte +91 -3
- package/dist/rich-text-editor/rich-text-editor-root.svelte +168 -3
- package/dist/rich-text-editor/rich-text-editor-toolbar.svelte +318 -275
- package/dist/select/select-trigger.svelte +5 -8
- package/dist/shader-canvas/shader-canvas.svelte +0 -3
- package/dist/sidebar/sidebar-trigger.svelte +3 -2
- package/dist/system-map/system-map.svelte +120 -674
- package/dist/tabs/tabs-trigger.svelte +7 -4
- package/dist/tags-input/tags-input-input.svelte +3 -0
- package/dist/tags-input/tags-input-root.svelte +4 -13
- package/dist/tags-input/tags-input-tag.svelte +3 -0
- package/dist/themes/dark.css +6 -0
- package/dist/themes/default.css +3 -0
- package/dist/toast/toast-action.svelte +1 -0
- package/dist/toast/toast-close.svelte +4 -0
- package/dist/toast/toast-provider.svelte +5 -26
- package/dist/toast/toast-root.svelte +5 -10
- package/dist/virtual-list/virtual-list.svelte +187 -3
- package/package.json +3 -3
|
@@ -1,25 +1,72 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import {
|
|
3
|
+
import { getRichTextEditorCtx } from '@dryui/primitives/rich-text-editor';
|
|
4
4
|
|
|
5
5
|
interface Props extends HTMLAttributes<HTMLDivElement> {}
|
|
6
6
|
|
|
7
7
|
let { ...rest }: Props = $props();
|
|
8
8
|
|
|
9
|
+
const ctx = getRichTextEditorCtx();
|
|
10
|
+
|
|
11
|
+
let toolbarEl: HTMLDivElement;
|
|
12
|
+
|
|
9
13
|
let showLinkInput = $state(false);
|
|
10
14
|
let linkUrl = $state('');
|
|
11
15
|
let linkInputEl = $state<HTMLInputElement>();
|
|
12
16
|
let savedSelection = $state<Range | null>(null);
|
|
13
17
|
|
|
18
|
+
// Roving tabindex keyboard navigation
|
|
19
|
+
function getFocusableItems(toolbar: HTMLElement): HTMLElement[] {
|
|
20
|
+
return Array.from(
|
|
21
|
+
toolbar.querySelectorAll<HTMLElement>(
|
|
22
|
+
'button:not([disabled]), [role="button"]:not([disabled])'
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
$effect(() => {
|
|
28
|
+
if (!toolbarEl) return;
|
|
29
|
+
const items = getFocusableItems(toolbarEl);
|
|
30
|
+
if (items.length > 0 && !items.some((el) => el.getAttribute('tabindex') === '0')) {
|
|
31
|
+
items[0]!.setAttribute('tabindex', '0');
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
36
|
+
const toolbar = event.currentTarget as HTMLElement;
|
|
37
|
+
const items = getFocusableItems(toolbar);
|
|
38
|
+
if (items.length === 0) return;
|
|
39
|
+
|
|
40
|
+
const currentIndex = items.indexOf(event.target as HTMLElement);
|
|
41
|
+
if (currentIndex === -1) return;
|
|
42
|
+
|
|
43
|
+
let nextIndex: number | null = null;
|
|
44
|
+
|
|
45
|
+
if (event.key === 'ArrowLeft') {
|
|
46
|
+
nextIndex = currentIndex - 1 < 0 ? items.length - 1 : currentIndex - 1;
|
|
47
|
+
} else if (event.key === 'ArrowRight') {
|
|
48
|
+
nextIndex = currentIndex + 1 >= items.length ? 0 : currentIndex + 1;
|
|
49
|
+
} else if (event.key === 'Home') {
|
|
50
|
+
nextIndex = 0;
|
|
51
|
+
} else if (event.key === 'End') {
|
|
52
|
+
nextIndex = items.length - 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (nextIndex !== null) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
items[currentIndex]!.setAttribute('tabindex', '-1');
|
|
58
|
+
items[nextIndex]!.setAttribute('tabindex', '0');
|
|
59
|
+
items[nextIndex]!.focus();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
14
63
|
function openLinkInput(currentLink: string | null) {
|
|
15
|
-
// Save the current selection so we can restore it when applying
|
|
16
64
|
const sel = window.getSelection();
|
|
17
65
|
if (sel && sel.rangeCount > 0) {
|
|
18
66
|
savedSelection = sel.getRangeAt(0).cloneRange();
|
|
19
67
|
}
|
|
20
68
|
linkUrl = currentLink ?? 'https://';
|
|
21
69
|
showLinkInput = true;
|
|
22
|
-
// Focus input after render
|
|
23
70
|
requestAnimationFrame(() => {
|
|
24
71
|
linkInputEl?.focus();
|
|
25
72
|
linkInputEl?.select();
|
|
@@ -43,210 +90,245 @@
|
|
|
43
90
|
}
|
|
44
91
|
</script>
|
|
45
92
|
|
|
46
|
-
<
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
<div
|
|
94
|
+
bind:this={toolbarEl}
|
|
95
|
+
role="toolbar"
|
|
96
|
+
aria-orientation="horizontal"
|
|
97
|
+
aria-label="Text formatting"
|
|
98
|
+
data-part="toolbar"
|
|
99
|
+
data-rte-toolbar
|
|
100
|
+
onkeydown={handleKeydown}
|
|
101
|
+
{...rest}
|
|
102
|
+
>
|
|
103
|
+
<div data-part="toolbarGroup">
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
data-part="button"
|
|
107
|
+
data-active={ctx.isBold}
|
|
108
|
+
aria-pressed={ctx.isBold}
|
|
109
|
+
aria-label="Bold"
|
|
110
|
+
title="Bold (Ctrl+B)"
|
|
111
|
+
tabindex={-1}
|
|
112
|
+
onmousedown={(e) => e.preventDefault()}
|
|
113
|
+
onclick={() => ctx.toggleBold()}><strong>B</strong></button
|
|
114
|
+
>
|
|
115
|
+
|
|
116
|
+
<button
|
|
117
|
+
type="button"
|
|
118
|
+
data-part="button"
|
|
119
|
+
data-format="italic"
|
|
120
|
+
data-active={ctx.isItalic}
|
|
121
|
+
aria-pressed={ctx.isItalic}
|
|
122
|
+
aria-label="Italic"
|
|
123
|
+
title="Italic (Ctrl+I)"
|
|
124
|
+
tabindex={-1}
|
|
125
|
+
onmousedown={(e) => e.preventDefault()}
|
|
126
|
+
onclick={() => ctx.toggleItalic()}>I</button
|
|
127
|
+
>
|
|
128
|
+
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
data-part="button"
|
|
132
|
+
data-format="underline"
|
|
133
|
+
data-active={ctx.isUnderline}
|
|
134
|
+
aria-pressed={ctx.isUnderline}
|
|
135
|
+
aria-label="Underline"
|
|
136
|
+
title="Underline (Ctrl+U)"
|
|
137
|
+
tabindex={-1}
|
|
138
|
+
onmousedown={(e) => e.preventDefault()}
|
|
139
|
+
onclick={() => ctx.toggleUnderline()}>U</button
|
|
140
|
+
>
|
|
141
|
+
|
|
142
|
+
<button
|
|
143
|
+
type="button"
|
|
144
|
+
data-part="button"
|
|
145
|
+
data-format="strikethrough"
|
|
146
|
+
data-active={ctx.isStrikethrough}
|
|
147
|
+
aria-pressed={ctx.isStrikethrough}
|
|
148
|
+
aria-label="Strikethrough"
|
|
149
|
+
title="Strikethrough"
|
|
150
|
+
tabindex={-1}
|
|
151
|
+
onmousedown={(e) => e.preventDefault()}
|
|
152
|
+
onclick={() => ctx.toggleStrikethrough()}>S</button
|
|
153
|
+
>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div data-part="separator" role="separator"></div>
|
|
157
|
+
|
|
158
|
+
<div data-part="toolbarGroup">
|
|
159
|
+
<button
|
|
160
|
+
type="button"
|
|
161
|
+
data-part="button"
|
|
162
|
+
data-active={ctx.currentHeading === 'h1'}
|
|
163
|
+
aria-pressed={ctx.currentHeading === 'h1'}
|
|
164
|
+
aria-label="Heading 1"
|
|
165
|
+
title="Heading 1"
|
|
166
|
+
tabindex={-1}
|
|
167
|
+
onmousedown={(e) => e.preventDefault()}
|
|
168
|
+
onclick={() => ctx.setHeading('h1')}>H1</button
|
|
169
|
+
>
|
|
170
|
+
|
|
171
|
+
<button
|
|
172
|
+
type="button"
|
|
173
|
+
data-part="button"
|
|
174
|
+
data-active={ctx.currentHeading === 'h2'}
|
|
175
|
+
aria-pressed={ctx.currentHeading === 'h2'}
|
|
176
|
+
aria-label="Heading 2"
|
|
177
|
+
title="Heading 2"
|
|
178
|
+
tabindex={-1}
|
|
179
|
+
onmousedown={(e) => e.preventDefault()}
|
|
180
|
+
onclick={() => ctx.setHeading('h2')}>H2</button
|
|
181
|
+
>
|
|
182
|
+
|
|
183
|
+
<button
|
|
184
|
+
type="button"
|
|
185
|
+
data-part="button"
|
|
186
|
+
data-active={ctx.currentHeading === 'h3'}
|
|
187
|
+
aria-pressed={ctx.currentHeading === 'h3'}
|
|
188
|
+
aria-label="Heading 3"
|
|
189
|
+
title="Heading 3"
|
|
190
|
+
tabindex={-1}
|
|
191
|
+
onmousedown={(e) => e.preventDefault()}
|
|
192
|
+
onclick={() => ctx.setHeading('h3')}>H3</button
|
|
193
|
+
>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<div data-part="separator" role="separator"></div>
|
|
197
|
+
|
|
198
|
+
<div data-part="toolbarGroup">
|
|
199
|
+
<button
|
|
200
|
+
type="button"
|
|
201
|
+
data-part="button"
|
|
202
|
+
data-active={ctx.isUnorderedList}
|
|
203
|
+
aria-pressed={ctx.isUnorderedList}
|
|
204
|
+
aria-label="Bullet list"
|
|
205
|
+
title="Bullet list"
|
|
206
|
+
tabindex={-1}
|
|
207
|
+
onmousedown={(e) => e.preventDefault()}
|
|
208
|
+
onclick={() => ctx.toggleUnorderedList()}
|
|
209
|
+
>
|
|
210
|
+
<svg
|
|
211
|
+
width="16"
|
|
212
|
+
height="16"
|
|
213
|
+
viewBox="0 0 16 16"
|
|
214
|
+
fill="none"
|
|
215
|
+
stroke="currentColor"
|
|
216
|
+
stroke-width="2"
|
|
217
|
+
stroke-linecap="round"
|
|
218
|
+
stroke-linejoin="round"
|
|
219
|
+
aria-hidden="true"
|
|
72
220
|
>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
221
|
+
<circle cx="3" cy="4" r="1" fill="currentColor" stroke="none" />
|
|
222
|
+
<circle cx="3" cy="8" r="1" fill="currentColor" stroke="none" />
|
|
223
|
+
<circle cx="3" cy="12" r="1" fill="currentColor" stroke="none" />
|
|
224
|
+
<line x1="6.5" y1="4" x2="14" y2="4" />
|
|
225
|
+
<line x1="6.5" y1="8" x2="14" y2="8" />
|
|
226
|
+
<line x1="6.5" y1="12" x2="14" y2="12" />
|
|
227
|
+
</svg>
|
|
228
|
+
</button>
|
|
229
|
+
|
|
230
|
+
<button
|
|
231
|
+
type="button"
|
|
232
|
+
data-part="button"
|
|
233
|
+
data-active={ctx.isOrderedList}
|
|
234
|
+
aria-pressed={ctx.isOrderedList}
|
|
235
|
+
aria-label="Numbered list"
|
|
236
|
+
title="Numbered list"
|
|
237
|
+
tabindex={-1}
|
|
238
|
+
onmousedown={(e) => e.preventDefault()}
|
|
239
|
+
onclick={() => ctx.toggleOrderedList()}
|
|
240
|
+
>
|
|
241
|
+
<svg
|
|
242
|
+
width="16"
|
|
243
|
+
height="16"
|
|
244
|
+
viewBox="0 0 16 16"
|
|
245
|
+
fill="none"
|
|
246
|
+
stroke="currentColor"
|
|
247
|
+
stroke-width="2"
|
|
248
|
+
stroke-linecap="round"
|
|
249
|
+
stroke-linejoin="round"
|
|
250
|
+
aria-hidden="true"
|
|
85
251
|
>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
title="Strikethrough"
|
|
95
|
-
tabindex={-1}
|
|
96
|
-
onmousedown={(e) => e.preventDefault()}
|
|
97
|
-
onclick={() => ctx.toggleStrikethrough()}>S</button
|
|
98
|
-
>
|
|
99
|
-
</div>
|
|
100
|
-
|
|
101
|
-
<div data-part="separator" role="separator"></div>
|
|
102
|
-
|
|
103
|
-
<div data-part="toolbarGroup">
|
|
104
|
-
<button
|
|
105
|
-
type="button"
|
|
106
|
-
data-part="button"
|
|
107
|
-
data-active={ctx.currentHeading === 'h1'}
|
|
108
|
-
aria-pressed={ctx.currentHeading === 'h1'}
|
|
109
|
-
aria-label="Heading 1"
|
|
110
|
-
title="Heading 1"
|
|
111
|
-
tabindex={-1}
|
|
112
|
-
onmousedown={(e) => e.preventDefault()}
|
|
113
|
-
onclick={() => ctx.setHeading('h1')}>H1</button
|
|
114
|
-
>
|
|
115
|
-
|
|
116
|
-
<button
|
|
117
|
-
type="button"
|
|
118
|
-
data-part="button"
|
|
119
|
-
data-active={ctx.currentHeading === 'h2'}
|
|
120
|
-
aria-pressed={ctx.currentHeading === 'h2'}
|
|
121
|
-
aria-label="Heading 2"
|
|
122
|
-
title="Heading 2"
|
|
123
|
-
tabindex={-1}
|
|
124
|
-
onmousedown={(e) => e.preventDefault()}
|
|
125
|
-
onclick={() => ctx.setHeading('h2')}>H2</button
|
|
126
|
-
>
|
|
127
|
-
|
|
128
|
-
<button
|
|
129
|
-
type="button"
|
|
130
|
-
data-part="button"
|
|
131
|
-
data-active={ctx.currentHeading === 'h3'}
|
|
132
|
-
aria-pressed={ctx.currentHeading === 'h3'}
|
|
133
|
-
aria-label="Heading 3"
|
|
134
|
-
title="Heading 3"
|
|
135
|
-
tabindex={-1}
|
|
136
|
-
onmousedown={(e) => e.preventDefault()}
|
|
137
|
-
onclick={() => ctx.setHeading('h3')}>H3</button
|
|
138
|
-
>
|
|
139
|
-
</div>
|
|
140
|
-
|
|
141
|
-
<div data-part="separator" role="separator"></div>
|
|
142
|
-
|
|
143
|
-
<div data-part="toolbarGroup">
|
|
144
|
-
<button
|
|
145
|
-
type="button"
|
|
146
|
-
data-part="button"
|
|
147
|
-
data-active={ctx.isUnorderedList}
|
|
148
|
-
aria-pressed={ctx.isUnorderedList}
|
|
149
|
-
aria-label="Bullet list"
|
|
150
|
-
title="Bullet list"
|
|
151
|
-
tabindex={-1}
|
|
152
|
-
onmousedown={(e) => e.preventDefault()}
|
|
153
|
-
onclick={() => ctx.toggleUnorderedList()}
|
|
154
|
-
>
|
|
155
|
-
<svg
|
|
156
|
-
width="16"
|
|
157
|
-
height="16"
|
|
158
|
-
viewBox="0 0 16 16"
|
|
159
|
-
fill="none"
|
|
160
|
-
stroke="currentColor"
|
|
161
|
-
stroke-width="2"
|
|
162
|
-
stroke-linecap="round"
|
|
163
|
-
stroke-linejoin="round"
|
|
164
|
-
aria-hidden="true"
|
|
252
|
+
<text
|
|
253
|
+
x="1"
|
|
254
|
+
y="5.5"
|
|
255
|
+
font-size="5"
|
|
256
|
+
fill="currentColor"
|
|
257
|
+
stroke="none"
|
|
258
|
+
font-family="sans-serif"
|
|
259
|
+
font-weight="bold">1</text
|
|
165
260
|
>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
<button
|
|
176
|
-
type="button"
|
|
177
|
-
data-part="button"
|
|
178
|
-
data-active={ctx.isOrderedList}
|
|
179
|
-
aria-pressed={ctx.isOrderedList}
|
|
180
|
-
aria-label="Numbered list"
|
|
181
|
-
title="Numbered list"
|
|
182
|
-
tabindex={-1}
|
|
183
|
-
onmousedown={(e) => e.preventDefault()}
|
|
184
|
-
onclick={() => ctx.toggleOrderedList()}
|
|
185
|
-
>
|
|
186
|
-
<svg
|
|
187
|
-
width="16"
|
|
188
|
-
height="16"
|
|
189
|
-
viewBox="0 0 16 16"
|
|
190
|
-
fill="none"
|
|
191
|
-
stroke="currentColor"
|
|
192
|
-
stroke-width="2"
|
|
193
|
-
stroke-linecap="round"
|
|
194
|
-
stroke-linejoin="round"
|
|
195
|
-
aria-hidden="true"
|
|
261
|
+
<text
|
|
262
|
+
x="1"
|
|
263
|
+
y="9.5"
|
|
264
|
+
font-size="5"
|
|
265
|
+
fill="currentColor"
|
|
266
|
+
stroke="none"
|
|
267
|
+
font-family="sans-serif"
|
|
268
|
+
font-weight="bold">2</text
|
|
196
269
|
>
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
270
|
+
<text
|
|
271
|
+
x="1"
|
|
272
|
+
y="13.5"
|
|
273
|
+
font-size="5"
|
|
274
|
+
fill="currentColor"
|
|
275
|
+
stroke="none"
|
|
276
|
+
font-family="sans-serif"
|
|
277
|
+
font-weight="bold">3</text
|
|
278
|
+
>
|
|
279
|
+
<line x1="6.5" y1="4" x2="14" y2="4" />
|
|
280
|
+
<line x1="6.5" y1="8" x2="14" y2="8" />
|
|
281
|
+
<line x1="6.5" y1="12" x2="14" y2="12" />
|
|
282
|
+
</svg>
|
|
283
|
+
</button>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<div data-part="separator" role="separator"></div>
|
|
287
|
+
|
|
288
|
+
<div data-part="toolbarGroup" class="toolbarGroupRelative">
|
|
289
|
+
<button
|
|
290
|
+
type="button"
|
|
291
|
+
data-part="button"
|
|
292
|
+
data-active={ctx.currentLink !== null}
|
|
293
|
+
aria-pressed={ctx.currentLink !== null}
|
|
294
|
+
aria-label={ctx.currentLink ? 'Edit link' : 'Insert link'}
|
|
295
|
+
title="Link (Ctrl+K)"
|
|
296
|
+
tabindex={-1}
|
|
297
|
+
onmousedown={(e) => e.preventDefault()}
|
|
298
|
+
onclick={() => {
|
|
299
|
+
if (ctx.currentLink) {
|
|
300
|
+
openLinkInput(ctx.currentLink);
|
|
301
|
+
} else {
|
|
302
|
+
openLinkInput(null);
|
|
303
|
+
}
|
|
304
|
+
}}
|
|
305
|
+
>
|
|
306
|
+
<svg
|
|
307
|
+
width="16"
|
|
308
|
+
height="16"
|
|
309
|
+
viewBox="0 0 16 16"
|
|
310
|
+
fill="none"
|
|
311
|
+
stroke="currentColor"
|
|
312
|
+
stroke-width="2"
|
|
313
|
+
stroke-linecap="round"
|
|
314
|
+
stroke-linejoin="round"
|
|
315
|
+
aria-hidden="true"
|
|
316
|
+
>
|
|
317
|
+
<path d="M6.5 9.5L9.5 6.5" />
|
|
318
|
+
<path d="M8.5 10.5L7 12C5.9 13.1 4.1 13.1 3 12C1.9 10.9 1.9 9.1 3 8L4.5 6.5" />
|
|
319
|
+
<path d="M7.5 5.5L9 4C10.1 2.9 11.9 2.9 13 4C14.1 5.1 14.1 6.9 13 8L11.5 9.5" />
|
|
320
|
+
</svg>
|
|
321
|
+
</button>
|
|
232
322
|
|
|
233
|
-
|
|
323
|
+
{#if ctx.currentLink}
|
|
234
324
|
<button
|
|
235
325
|
type="button"
|
|
236
326
|
data-part="button"
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
aria-label={ctx.currentLink ? 'Edit link' : 'Insert link'}
|
|
240
|
-
title="Link (Ctrl+K)"
|
|
327
|
+
aria-label="Remove link"
|
|
328
|
+
title="Remove link"
|
|
241
329
|
tabindex={-1}
|
|
242
330
|
onmousedown={(e) => e.preventDefault()}
|
|
243
|
-
onclick={() =>
|
|
244
|
-
if (ctx.currentLink) {
|
|
245
|
-
openLinkInput(ctx.currentLink);
|
|
246
|
-
} else {
|
|
247
|
-
openLinkInput(null);
|
|
248
|
-
}
|
|
249
|
-
}}
|
|
331
|
+
onclick={() => ctx.removeLink()}
|
|
250
332
|
>
|
|
251
333
|
<svg
|
|
252
334
|
width="16"
|
|
@@ -262,83 +344,56 @@
|
|
|
262
344
|
<path d="M6.5 9.5L9.5 6.5" />
|
|
263
345
|
<path d="M8.5 10.5L7 12C5.9 13.1 4.1 13.1 3 12C1.9 10.9 1.9 9.1 3 8L4.5 6.5" />
|
|
264
346
|
<path d="M7.5 5.5L9 4C10.1 2.9 11.9 2.9 13 4C14.1 5.1 14.1 6.9 13 8L11.5 9.5" />
|
|
347
|
+
<path d="M3 13L13 3" />
|
|
265
348
|
</svg>
|
|
266
349
|
</button>
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
height="16"
|
|
281
|
-
viewBox="0 0 16 16"
|
|
282
|
-
fill="none"
|
|
283
|
-
stroke="currentColor"
|
|
284
|
-
stroke-width="2"
|
|
285
|
-
stroke-linecap="round"
|
|
286
|
-
stroke-linejoin="round"
|
|
287
|
-
aria-hidden="true"
|
|
288
|
-
>
|
|
289
|
-
<path d="M6.5 9.5L9.5 6.5" />
|
|
290
|
-
<path d="M8.5 10.5L7 12C5.9 13.1 4.1 13.1 3 12C1.9 10.9 1.9 9.1 3 8L4.5 6.5" />
|
|
291
|
-
<path d="M7.5 5.5L9 4C10.1 2.9 11.9 2.9 13 4C14.1 5.1 14.1 6.9 13 8L11.5 9.5" />
|
|
292
|
-
<path d="M3 13L13 3" />
|
|
293
|
-
</svg>
|
|
294
|
-
</button>
|
|
295
|
-
{/if}
|
|
296
|
-
|
|
297
|
-
{#if showLinkInput}
|
|
298
|
-
<div data-part="linkPopover">
|
|
299
|
-
<input
|
|
300
|
-
bind:value={linkUrl}
|
|
301
|
-
bind:this={linkInputEl}
|
|
302
|
-
data-part="linkInput"
|
|
303
|
-
type="url"
|
|
304
|
-
placeholder="https://example.com"
|
|
305
|
-
onkeydown={(e) => {
|
|
306
|
-
if (e.key === 'Enter') {
|
|
307
|
-
e.preventDefault();
|
|
308
|
-
if (linkUrl) {
|
|
309
|
-
restoreSelection();
|
|
310
|
-
ctx.insertLink(linkUrl);
|
|
311
|
-
}
|
|
312
|
-
closeLinkInput();
|
|
313
|
-
} else if (e.key === 'Escape') {
|
|
314
|
-
closeLinkInput();
|
|
315
|
-
}
|
|
316
|
-
}}
|
|
317
|
-
/>
|
|
318
|
-
<button
|
|
319
|
-
type="button"
|
|
320
|
-
data-part="linkApply"
|
|
321
|
-
onclick={() => {
|
|
350
|
+
{/if}
|
|
351
|
+
|
|
352
|
+
{#if showLinkInput}
|
|
353
|
+
<div data-part="linkPopover">
|
|
354
|
+
<input
|
|
355
|
+
bind:value={linkUrl}
|
|
356
|
+
bind:this={linkInputEl}
|
|
357
|
+
data-part="linkInput"
|
|
358
|
+
type="url"
|
|
359
|
+
placeholder="https://example.com"
|
|
360
|
+
onkeydown={(e) => {
|
|
361
|
+
if (e.key === 'Enter') {
|
|
362
|
+
e.preventDefault();
|
|
322
363
|
if (linkUrl) {
|
|
323
364
|
restoreSelection();
|
|
324
365
|
ctx.insertLink(linkUrl);
|
|
325
366
|
}
|
|
326
367
|
closeLinkInput();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
368
|
+
} else if (e.key === 'Escape') {
|
|
369
|
+
closeLinkInput();
|
|
370
|
+
}
|
|
371
|
+
}}
|
|
372
|
+
/>
|
|
373
|
+
<button
|
|
374
|
+
type="button"
|
|
375
|
+
data-part="linkApply"
|
|
376
|
+
onclick={() => {
|
|
377
|
+
if (linkUrl) {
|
|
378
|
+
restoreSelection();
|
|
379
|
+
ctx.insertLink(linkUrl);
|
|
380
|
+
}
|
|
381
|
+
closeLinkInput();
|
|
382
|
+
}}>Apply</button
|
|
383
|
+
>
|
|
384
|
+
<button type="button" data-part="linkCancel" onclick={() => closeLinkInput()}
|
|
385
|
+
>Cancel</button
|
|
386
|
+
>
|
|
387
|
+
</div>
|
|
388
|
+
{/if}
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
337
391
|
|
|
338
392
|
<style>
|
|
339
393
|
[data-part='toolbar'] {
|
|
340
394
|
display: grid;
|
|
341
|
-
grid-
|
|
395
|
+
grid-auto-flow: column;
|
|
396
|
+
grid-auto-columns: max-content;
|
|
342
397
|
align-items: center;
|
|
343
398
|
gap: var(--dry-space-1);
|
|
344
399
|
padding: var(--dry-space-1) var(--dry-space-2);
|
|
@@ -398,18 +453,6 @@
|
|
|
398
453
|
background: var(--dry-color-fill-brand-hover);
|
|
399
454
|
}
|
|
400
455
|
|
|
401
|
-
[data-part='buttonItalic'] {
|
|
402
|
-
font-style: italic;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
[data-part='buttonUnderline'] {
|
|
406
|
-
text-decoration: underline;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
[data-part='buttonStrikethrough'] {
|
|
410
|
-
text-decoration: line-through;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
456
|
.toolbarGroupRelative {
|
|
414
457
|
position: relative;
|
|
415
458
|
}
|