@sveltia/ui 0.88.1 → 0.88.3
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/components/listbox/option.svelte +7 -4
- package/dist/components/resizable-pane/resizable-handle.svelte +15 -7
- package/dist/components/resizable-pane/resizable-pane-group.svelte +204 -20
- package/dist/components/resizable-pane/resizable-pane.svelte +25 -6
- package/dist/components/scroll/infinite-scroll.svelte +32 -11
- package/dist/components/slider/slider.svelte +10 -1
- package/dist/components/text-editor/core.js +30 -7
- package/dist/components/text-editor/markdown.d.ts +1 -1
- package/dist/components/text-editor/markdown.js +137 -59
- package/dist/components/text-editor/shiki/version.d.ts +1 -1
- package/dist/components/text-editor/shiki/version.js +1 -1
- package/dist/components/text-editor/transformers/block-escape.d.ts +4 -0
- package/dist/components/text-editor/transformers/block-escape.js +53 -2
- package/dist/components/text-editor/transformers/raw-syntax.js +70 -8
- package/dist/components/text-editor/transformers/table.js +43 -3
- package/dist/components/text-field/emoji-autocomplete.svelte +11 -9
- package/dist/components/text-field/masked-input.svelte +1 -13
- package/dist/components/text-field/text-input.svelte +1 -1
- package/dist/components/toast/toast.svelte +19 -8
- package/dist/components/tree/tree-item.svelte +7 -4
- package/dist/components/util/popup.svelte +1 -1
- package/dist/services/popup-position.js +20 -10
- package/dist/services/popup.svelte.d.ts +10 -1
- package/dist/services/popup.svelte.js +18 -5
- package/dist/services/tree.svelte.js +23 -7
- package/dist/typedefs.d.ts +9 -4
- package/dist/typedefs.js +6 -3
- package/package.json +15 -15
|
@@ -37,10 +37,8 @@
|
|
|
37
37
|
class: className,
|
|
38
38
|
disabled = false,
|
|
39
39
|
label,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// svelte-ignore state_referenced_locally
|
|
43
|
-
searchValue = label,
|
|
40
|
+
value: _value = undefined,
|
|
41
|
+
searchValue: _searchValue = undefined,
|
|
44
42
|
wrap = false,
|
|
45
43
|
children,
|
|
46
44
|
checkIcon,
|
|
@@ -58,6 +56,11 @@
|
|
|
58
56
|
*/
|
|
59
57
|
const fallbackId = $props.id();
|
|
60
58
|
|
|
59
|
+
// The label is the default, followed when it changes, like on a locale switch. A prop fallback
|
|
60
|
+
// would only take its first value
|
|
61
|
+
const value = $derived(_value === undefined ? label : _value);
|
|
62
|
+
const searchValue = $derived(_searchValue === undefined ? label : _searchValue);
|
|
63
|
+
|
|
61
64
|
/**
|
|
62
65
|
* The registry provided by an ancestor `<Combobox>`. This is `undefined` when the option is used
|
|
63
66
|
* standalone within a `<Listbox>`, in which case it always renders itself.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
8
|
import { isRTL } from '@sveltia/i18n';
|
|
9
|
-
import { getContext } from 'svelte';
|
|
9
|
+
import { getContext, onDestroy } from 'svelte';
|
|
10
10
|
import { getHandleKeyAction } from './sizing.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -51,7 +51,20 @@
|
|
|
51
51
|
throw new Error('<ResizableHandle> must be used inside a <ResizablePaneGroup>');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
/**
|
|
55
|
+
* A reference to the handle element.
|
|
56
|
+
* @type {HTMLElement | undefined}
|
|
57
|
+
*/
|
|
58
|
+
let element = $state();
|
|
59
|
+
|
|
60
|
+
const handle = ctx.registerHandle(() => element);
|
|
61
|
+
// The handles are counted in the order they are in the group, which changes as panes are shown
|
|
62
|
+
// and hidden
|
|
63
|
+
const handleIndex = $derived(handle.index);
|
|
64
|
+
|
|
65
|
+
onDestroy(() => {
|
|
66
|
+
handle.unregister();
|
|
67
|
+
});
|
|
55
68
|
const isHorizontal = $derived(ctx.direction === 'horizontal');
|
|
56
69
|
const sizes = $derived(ctx.sizes);
|
|
57
70
|
// The value reported via aria-valuenow is the size of the pane immediately before this handle
|
|
@@ -68,11 +81,6 @@
|
|
|
68
81
|
Math.min(currentPaneConstraints.maxSize, pairSize - nextPaneConstraints.minSize),
|
|
69
82
|
);
|
|
70
83
|
|
|
71
|
-
/**
|
|
72
|
-
* A reference to the handle element.
|
|
73
|
-
* @type {HTMLElement | undefined}
|
|
74
|
-
*/
|
|
75
|
-
let element = $state();
|
|
76
84
|
let dragging = $state(false);
|
|
77
85
|
let startScreenPos = $state(0);
|
|
78
86
|
/**
|
|
@@ -50,11 +50,18 @@
|
|
|
50
50
|
} = $props();
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* `ResizablePane` definitions in
|
|
54
|
-
*
|
|
53
|
+
* `ResizablePane` definitions in the order of the panes in the group. Child `<ResizablePane>`
|
|
54
|
+
* components register in the order they’re mounted, which is only the order in the group the
|
|
55
|
+
* first time; one shown later with `{#if}` comes last until {@link syncOrder} puts it in place.
|
|
55
56
|
* @type {PaneDef[]}
|
|
56
57
|
*/
|
|
57
|
-
|
|
58
|
+
let _paneDefs = $state.raw([]);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Functions to get the `<ResizableHandle>` elements, in the order of the handles in the group.
|
|
62
|
+
* @type {(() => HTMLElement | undefined)[]}
|
|
63
|
+
*/
|
|
64
|
+
let _handles = $state.raw([]);
|
|
58
65
|
|
|
59
66
|
/** @type {HTMLDivElement | undefined} */
|
|
60
67
|
let element = $state();
|
|
@@ -71,8 +78,6 @@
|
|
|
71
78
|
*/
|
|
72
79
|
const _savedSizes = $state([]);
|
|
73
80
|
|
|
74
|
-
let _handleCount = 0;
|
|
75
|
-
|
|
76
81
|
/**
|
|
77
82
|
* Measure the space the panes share: the group’s size along its direction, less the handles
|
|
78
83
|
* between them. Every pane size is a percentage of this, so the panes and handles together fill
|
|
@@ -119,6 +124,11 @@
|
|
|
119
124
|
const getPaneConstraints = (paneIndex) =>
|
|
120
125
|
resolvePaneConstraints(_paneDefs[paneIndex], getSizeEnvironment());
|
|
121
126
|
|
|
127
|
+
/**
|
|
128
|
+
* The sizes last reported with `onResize`, to report a change only once.
|
|
129
|
+
*/
|
|
130
|
+
let reportedSizes = '';
|
|
131
|
+
|
|
122
132
|
/**
|
|
123
133
|
* Initialize pane sizes from `defaultSize` props. Called once all panes have registered. Panes
|
|
124
134
|
* without `defaultSize` share the remaining space equally, and every size is kept within its
|
|
@@ -139,6 +149,21 @@
|
|
|
139
149
|
const constraints = _paneDefs.map((p) => resolvePaneConstraints(p, env));
|
|
140
150
|
|
|
141
151
|
sizes.splice(0, sizes.length, ...getInitialSizes(resolvedDefaults, constraints));
|
|
152
|
+
// The initial sizes aren’t reported, only the changes from them
|
|
153
|
+
reportedSizes = sizes.map((size) => Number(size.toFixed(1))).join();
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Call `onResize` with the current sizes, if they’ve changed since the last call.
|
|
158
|
+
*/
|
|
159
|
+
const reportSizes = () => {
|
|
160
|
+
const rounded = sizes.map((size) => Number(size.toFixed(1)));
|
|
161
|
+
const key = rounded.join();
|
|
162
|
+
|
|
163
|
+
if (key !== reportedSizes) {
|
|
164
|
+
reportedSizes = key;
|
|
165
|
+
onResize?.({ sizes: rounded });
|
|
166
|
+
}
|
|
142
167
|
};
|
|
143
168
|
|
|
144
169
|
/**
|
|
@@ -166,7 +191,7 @@
|
|
|
166
191
|
sizes[beforeIdx] = prevBefore + delta;
|
|
167
192
|
sizes[afterIdx] = prevAfter - delta;
|
|
168
193
|
|
|
169
|
-
|
|
194
|
+
reportSizes();
|
|
170
195
|
};
|
|
171
196
|
|
|
172
197
|
/**
|
|
@@ -177,7 +202,9 @@
|
|
|
177
202
|
const toggleCollapse = (handleIndex) => {
|
|
178
203
|
const { minSize: minBefore } = getPaneConstraints(handleIndex);
|
|
179
204
|
|
|
180
|
-
|
|
205
|
+
// The saved size is only restored while the pane is still collapsed; once it has been resized
|
|
206
|
+
// since, it’s collapsed again from where it is
|
|
207
|
+
if (_savedSizes[handleIndex] !== undefined && Math.abs(sizes[handleIndex] - minBefore) < 0.1) {
|
|
181
208
|
const delta = /** @type {number} */ (_savedSizes[handleIndex]) - sizes[handleIndex];
|
|
182
209
|
|
|
183
210
|
_savedSizes[handleIndex] = undefined;
|
|
@@ -188,6 +215,113 @@
|
|
|
188
215
|
}
|
|
189
216
|
};
|
|
190
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Give the given space to the given panes, the first one first, then to the others, as far as
|
|
220
|
+
* their maximum sizes allow, or take it from them with a negative amount, as far as their minimum
|
|
221
|
+
* sizes allow.
|
|
222
|
+
* @param {number[]} neighbors Indexes of the panes to give the space to first.
|
|
223
|
+
* @param {number} amount Space in percentage points.
|
|
224
|
+
* @param {number} [exclude] Index of a pane to leave alone.
|
|
225
|
+
* @returns {number} Space that couldn’t be given or taken.
|
|
226
|
+
*/
|
|
227
|
+
const shareSpace = (neighbors, amount, exclude) => {
|
|
228
|
+
let rest = amount;
|
|
229
|
+
|
|
230
|
+
[...neighbors, ...sizes.map((_size, index) => index)].forEach((neighbor) => {
|
|
231
|
+
if (Math.abs(rest) < 0.001 || neighbor === exclude || sizes[neighbor] === undefined) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const { minSize, maxSize } = getPaneConstraints(neighbor);
|
|
236
|
+
const size = Math.min(Math.max(sizes[neighbor] + rest, minSize), maxSize);
|
|
237
|
+
|
|
238
|
+
rest -= size - sizes[neighbor];
|
|
239
|
+
sizes[neighbor] = size;
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
return rest;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Put the panes and handles in the order they are in the group, and size a pane shown after the
|
|
247
|
+
* initial layout, taking its space from the panes next to it.
|
|
248
|
+
*/
|
|
249
|
+
const syncOrder = () => {
|
|
250
|
+
// Only called once the group is mounted
|
|
251
|
+
/* v8 ignore next */
|
|
252
|
+
if (!element || !sizes.length) return;
|
|
253
|
+
|
|
254
|
+
const paneIds = [...element.querySelectorAll(':scope > .resizable-pane')].map(({ id }) => id);
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Get the position of the given pane in the group, or the end if it isn’t in it yet.
|
|
258
|
+
* @param {PaneDef} def Pane definition.
|
|
259
|
+
* @returns {number} Position.
|
|
260
|
+
*/
|
|
261
|
+
const getPosition = (def) => {
|
|
262
|
+
const position = paneIds.indexOf(def.id);
|
|
263
|
+
|
|
264
|
+
return position === -1 ? Infinity : position;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const defs = _paneDefs.toSorted((a, b) => getPosition(a) - getPosition(b));
|
|
268
|
+
const newSizes = defs.map((def) => sizes[_paneDefs.indexOf(def)]);
|
|
269
|
+
const isReordered = defs.some((def, index) => def !== _paneDefs[index]);
|
|
270
|
+
|
|
271
|
+
if (isReordered) {
|
|
272
|
+
_paneDefs = defs;
|
|
273
|
+
sizes.splice(0, sizes.length, ...newSizes);
|
|
274
|
+
_savedSizes.length = 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
sizes.forEach((size, index) => {
|
|
278
|
+
if (!Number.isNaN(size)) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const env = getSizeEnvironment();
|
|
283
|
+
const def = _paneDefs[index];
|
|
284
|
+
const { minSize, maxSize } = resolvePaneConstraints(def, env);
|
|
285
|
+
|
|
286
|
+
const defaultSize =
|
|
287
|
+
def.defaultSize === undefined ? NaN : resolveToPercent(def.defaultSize, NaN, env);
|
|
288
|
+
|
|
289
|
+
const wanted = Math.min(
|
|
290
|
+
Math.max(Number.isNaN(defaultSize) ? 100 / sizes.length : defaultSize, minSize),
|
|
291
|
+
maxSize,
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
sizes[index] = 0;
|
|
295
|
+
sizes[index] = wanted + shareSpace([index - 1, index + 1], -wanted, index);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
const handleElements = [...element.querySelectorAll(':scope > .resizable-handle')];
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Get the position of the given handle in the group, or the end if it isn’t in it yet.
|
|
302
|
+
* @param {() => HTMLElement | undefined} getElement Function to get the handle element.
|
|
303
|
+
* @returns {number} Position.
|
|
304
|
+
*/
|
|
305
|
+
const getHandlePosition = (getElement) => {
|
|
306
|
+
const position = handleElements.indexOf(/** @type {HTMLElement} */ (getElement()));
|
|
307
|
+
|
|
308
|
+
return position === -1 ? Infinity : position;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const handles = _handles.toSorted((a, b) => getHandlePosition(a) - getHandlePosition(b));
|
|
312
|
+
|
|
313
|
+
if (handles.some((handle, index) => handle !== _handles[index])) {
|
|
314
|
+
_handles = handles;
|
|
315
|
+
_savedSizes.length = 0;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Reported here rather than as a pane leaves, which also happens when the whole group is
|
|
319
|
+
// removed: this observer callback doesn’t run then, as the observer is disconnected first
|
|
320
|
+
if (!sizes.some((size) => Number.isNaN(size))) {
|
|
321
|
+
reportSizes();
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
191
325
|
setContext(
|
|
192
326
|
'paneGroup',
|
|
193
327
|
/* eslint-disable jsdoc/require-jsdoc */
|
|
@@ -196,25 +330,60 @@
|
|
|
196
330
|
return direction;
|
|
197
331
|
},
|
|
198
332
|
sizes,
|
|
199
|
-
registerPane: (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
333
|
+
registerPane: (def) => {
|
|
334
|
+
_paneDefs = [..._paneDefs, def];
|
|
335
|
+
|
|
336
|
+
// A pane shown after the initial layout is sized once it’s in place; see `syncOrder()`
|
|
337
|
+
if (sizes.length) {
|
|
338
|
+
sizes.push(NaN);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return {
|
|
342
|
+
get index() {
|
|
343
|
+
return _paneDefs.indexOf(def);
|
|
344
|
+
},
|
|
345
|
+
unregister: () => {
|
|
346
|
+
const index = _paneDefs.indexOf(def);
|
|
347
|
+
|
|
348
|
+
if (index === -1) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
_paneDefs = _paneDefs.toSpliced(index, 1);
|
|
353
|
+
|
|
354
|
+
// Its space goes to the panes next to it
|
|
355
|
+
if (sizes.length) {
|
|
356
|
+
const [size] = sizes.splice(index, 1);
|
|
357
|
+
|
|
358
|
+
_savedSizes.length = 0;
|
|
359
|
+
|
|
360
|
+
if (sizes.length && !Number.isNaN(size)) {
|
|
361
|
+
shareSpace([index - 1, index], size);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
};
|
|
205
366
|
},
|
|
206
|
-
registerHandle: () => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
367
|
+
registerHandle: (getElement) => {
|
|
368
|
+
_handles = [..._handles, getElement];
|
|
369
|
+
|
|
370
|
+
return {
|
|
371
|
+
get index() {
|
|
372
|
+
return _handles.indexOf(getElement);
|
|
373
|
+
},
|
|
374
|
+
unregister: () => {
|
|
375
|
+
_handles = _handles.filter((handle) => handle !== getElement);
|
|
376
|
+
_savedSizes.length = 0;
|
|
377
|
+
},
|
|
378
|
+
};
|
|
212
379
|
},
|
|
213
380
|
resize,
|
|
214
381
|
toggleCollapse,
|
|
215
382
|
getPaneConstraints,
|
|
216
383
|
measurePaneSpace,
|
|
217
|
-
paneDefs
|
|
384
|
+
get paneDefs() {
|
|
385
|
+
return _paneDefs;
|
|
386
|
+
},
|
|
218
387
|
}),
|
|
219
388
|
/* eslint-enable jsdoc/require-jsdoc */
|
|
220
389
|
);
|
|
@@ -224,6 +393,21 @@
|
|
|
224
393
|
initSizes();
|
|
225
394
|
}
|
|
226
395
|
});
|
|
396
|
+
|
|
397
|
+
// Panes and handles can be shown and hidden after the initial layout, with `{#if}` for example
|
|
398
|
+
$effect(() => {
|
|
399
|
+
if (!element) {
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const observer = new MutationObserver(() => syncOrder());
|
|
404
|
+
|
|
405
|
+
observer.observe(element, { childList: true });
|
|
406
|
+
|
|
407
|
+
return () => {
|
|
408
|
+
observer.disconnect();
|
|
409
|
+
};
|
|
410
|
+
});
|
|
227
411
|
</script>
|
|
228
412
|
|
|
229
413
|
<div
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
`<ResizablePaneGroup>`.
|
|
5
5
|
-->
|
|
6
6
|
<script>
|
|
7
|
-
import { getContext, untrack } from 'svelte';
|
|
7
|
+
import { getContext, onDestroy, untrack } from 'svelte';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @import { Snippet } from 'svelte';
|
|
@@ -51,11 +51,24 @@
|
|
|
51
51
|
throw new Error('<ResizablePane> must be used inside a <ResizablePaneGroup>');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
//
|
|
55
|
-
|
|
54
|
+
// The sizes are read when they’re needed, so a change to them is followed
|
|
55
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
56
|
+
const pane = ctx.registerPane({
|
|
57
|
+
id,
|
|
58
|
+
get defaultSize() {
|
|
59
|
+
return defaultSize;
|
|
60
|
+
},
|
|
61
|
+
get minSize() {
|
|
62
|
+
return minSize;
|
|
63
|
+
},
|
|
64
|
+
get maxSize() {
|
|
65
|
+
return maxSize;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
/* eslint-enable jsdoc/require-jsdoc */
|
|
56
69
|
|
|
57
70
|
const direction = $derived(ctx.direction);
|
|
58
|
-
const size = $derived(ctx.sizes[
|
|
71
|
+
const size = $derived(ctx.sizes[pane.index]);
|
|
59
72
|
/**
|
|
60
73
|
* The size as a flex basis. The percentages are of the space the panes share rather than of the
|
|
61
74
|
* group, while a flex basis is a percentage of the group, so the panes are made shrinkable: the
|
|
@@ -63,7 +76,8 @@
|
|
|
63
76
|
* exactly the intended percentages, and the group is never overflowed.
|
|
64
77
|
*/
|
|
65
78
|
const sizeStyle = $derived.by(() => {
|
|
66
|
-
|
|
79
|
+
// A pane shown after the initial layout has no size until it’s in place
|
|
80
|
+
if (size !== undefined && !Number.isNaN(size)) {
|
|
67
81
|
return `${size}%`;
|
|
68
82
|
}
|
|
69
83
|
|
|
@@ -74,8 +88,13 @@
|
|
|
74
88
|
return defaultSize ?? '0%';
|
|
75
89
|
});
|
|
76
90
|
|
|
91
|
+
// Leave the group when removed, giving the space to the panes next to it
|
|
92
|
+
onDestroy(() => {
|
|
93
|
+
pane.unregister();
|
|
94
|
+
});
|
|
95
|
+
|
|
77
96
|
$effect(() => {
|
|
78
|
-
if (size !== undefined) {
|
|
97
|
+
if (size !== undefined && !Number.isNaN(size)) {
|
|
79
98
|
untrack(() => onResize?.({ size: Number(size.toFixed(1)) }));
|
|
80
99
|
}
|
|
81
100
|
});
|
|
@@ -36,15 +36,23 @@
|
|
|
36
36
|
const loading = $derived(items.length > loadedItemSize);
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* The scroll container found for the spinner
|
|
40
|
-
*
|
|
41
|
-
* rendered. The list only grows from then on, so a container that scrolls keeps doing so.
|
|
39
|
+
* The scroll container found for the spinner. Looking it up reads the computed style and the
|
|
40
|
+
* scroll size of every ancestor, which forces a layout each time a chunk has been rendered.
|
|
42
41
|
* @type {HTMLElement | null}
|
|
43
42
|
*/
|
|
44
43
|
let scrollContainer = null;
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
|
-
*
|
|
46
|
+
* Whether {@link scrollContainer} is final: the nearest ancestor that can scroll, or the document
|
|
47
|
+
* if none can. The list only grows from then on, so a container that scrolls keeps doing so.
|
|
48
|
+
* Until then, a nearer one, like a pane the first chunk didn’t fill or one that was hidden, may
|
|
49
|
+
* start scrolling, and an outer container kept instead would miss the margin that loads the next
|
|
50
|
+
* chunk ahead of the view, so it’s looked up again for each chunk.
|
|
51
|
+
*/
|
|
52
|
+
let isScrollContainerFinal = false;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Find the nearest ancestor of the given element that scrolls vertically. An ancestor that can
|
|
48
56
|
* scroll but whose content fits, like one growing with the list or a horizontal scroller, doesn’t
|
|
49
57
|
* clip the element, and as the observer’s root it would let every chunk load at once. The heights
|
|
50
58
|
* are rounded separately, so a 1px difference doesn’t count as scrolling.
|
|
@@ -52,16 +60,29 @@
|
|
|
52
60
|
* @returns {HTMLElement | null} Scroll container, or `null` if the document itself scrolls.
|
|
53
61
|
*/
|
|
54
62
|
const getScrollContainer = (element) => {
|
|
63
|
+
if (isScrollContainerFinal) {
|
|
64
|
+
return scrollContainer;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** @type {HTMLElement | null} */
|
|
68
|
+
let nearest = null;
|
|
69
|
+
|
|
70
|
+
scrollContainer = null;
|
|
71
|
+
|
|
55
72
|
for (let parent = element.parentElement; parent; parent = parent.parentElement) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
73
|
+
if (/^(auto|scroll)$/.test(getComputedStyle(parent).overflowY)) {
|
|
74
|
+
nearest ??= parent;
|
|
75
|
+
|
|
76
|
+
if (parent.scrollHeight - parent.clientHeight > 1) {
|
|
77
|
+
scrollContainer = parent;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
61
80
|
}
|
|
62
81
|
}
|
|
63
82
|
|
|
64
|
-
|
|
83
|
+
isScrollContainerFinal = scrollContainer === nearest;
|
|
84
|
+
|
|
85
|
+
return scrollContainer;
|
|
65
86
|
};
|
|
66
87
|
|
|
67
88
|
// Observe the spinner anew once each chunk is rendered: the observer only reports changes, so a
|
|
@@ -88,7 +109,7 @@
|
|
|
88
109
|
loadedItemSize += itemChunkSize;
|
|
89
110
|
}
|
|
90
111
|
},
|
|
91
|
-
{ root:
|
|
112
|
+
{ root: getScrollContainer(spinner), rootMargin: '0px 0px 500px 0px' },
|
|
92
113
|
);
|
|
93
114
|
|
|
94
115
|
observer.observe(spinner);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
-->
|
|
10
10
|
<script>
|
|
11
11
|
import { isRTL } from '@sveltia/i18n';
|
|
12
|
-
import { onMount } from 'svelte';
|
|
12
|
+
import { onMount, untrack } from 'svelte';
|
|
13
13
|
import {
|
|
14
14
|
findNearestStepIndex,
|
|
15
15
|
getNearestThumbIndex,
|
|
@@ -356,6 +356,15 @@
|
|
|
356
356
|
void values;
|
|
357
357
|
updatePositions();
|
|
358
358
|
});
|
|
359
|
+
|
|
360
|
+
// The steps are worked out from the range, so they have to follow a change to it, or the keys,
|
|
361
|
+
// the thumbs and the drag would keep using the old range
|
|
362
|
+
$effect(() => {
|
|
363
|
+
void min;
|
|
364
|
+
void max;
|
|
365
|
+
void step;
|
|
366
|
+
untrack(init);
|
|
367
|
+
});
|
|
359
368
|
</script>
|
|
360
369
|
|
|
361
370
|
<svelte:body
|
|
@@ -122,7 +122,6 @@ import { HR } from './transformers/hr.js';
|
|
|
122
122
|
import {
|
|
123
123
|
getImportedRawSyntax,
|
|
124
124
|
HTML_BLOCK_PLACEHOLDER,
|
|
125
|
-
INLINE_HTML_REGEX,
|
|
126
125
|
RAW_HTML,
|
|
127
126
|
RAW_SYNTAX,
|
|
128
127
|
} from './transformers/raw-syntax.js';
|
|
@@ -804,19 +803,41 @@ export const $replaceLineBreak = (node) => {
|
|
|
804
803
|
|
|
805
804
|
const space = createTextNode(' ');
|
|
806
805
|
|
|
807
|
-
|
|
806
|
+
// A link split over lines, like the ones `splitMultilineFormatting()` makes from a link within
|
|
807
|
+
// formatting, is joined back into one link
|
|
808
|
+
const isSameLink =
|
|
809
|
+
isLinkNode(previous) &&
|
|
810
|
+
isLinkNode(next) &&
|
|
811
|
+
previous.getURL() === next.getURL() &&
|
|
812
|
+
previous.getTitle() === next.getTitle() &&
|
|
813
|
+
previous.getTarget() === next.getTarget() &&
|
|
814
|
+
previous.getRel() === next.getRel();
|
|
815
|
+
|
|
816
|
+
// The text next to the line break, also within an inline element like a link
|
|
817
|
+
const before = isElementNode(previous) ? previous.getLastDescendant() : previous;
|
|
818
|
+
const after = isElementNode(next) ? next.getFirstDescendant() : next;
|
|
819
|
+
|
|
820
|
+
if (isTextNode(before) && isTextNode(after)) {
|
|
808
821
|
// Keep the formats both sides share, e.g. italic between italic and bold italic text
|
|
809
822
|
TEXT_FORMAT_BUTTON_TYPES.forEach((format) => {
|
|
810
|
-
if (
|
|
823
|
+
if (before.hasFormat(format) && after.hasFormat(format)) {
|
|
811
824
|
space.toggleFormat(format);
|
|
812
825
|
}
|
|
813
826
|
});
|
|
814
827
|
|
|
815
|
-
if (
|
|
816
|
-
space.setStyle(
|
|
828
|
+
if (before.getStyle() === after.getStyle()) {
|
|
829
|
+
space.setStyle(before.getStyle());
|
|
817
830
|
}
|
|
818
831
|
}
|
|
819
832
|
|
|
833
|
+
if (isSameLink) {
|
|
834
|
+
previous.append(space, ...next.getChildren());
|
|
835
|
+
next.remove();
|
|
836
|
+
node.remove();
|
|
837
|
+
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
|
|
820
841
|
node.replace(space);
|
|
821
842
|
};
|
|
822
843
|
|
|
@@ -1571,8 +1592,10 @@ export const convertMarkdownToLexical = async (editor, value, enabledTransformer
|
|
|
1571
1592
|
addCodeSpanSplit(enabledTransformers),
|
|
1572
1593
|
);
|
|
1573
1594
|
|
|
1574
|
-
// The text of raw HTML is restored as well. The lines of an HTML block have a
|
|
1575
|
-
|
|
1595
|
+
// The text of raw HTML and raw syntax is restored as well. The lines of an HTML block have a
|
|
1596
|
+
// placeholder. Other raw syntax, like an autolink or a definition label, only differs from
|
|
1597
|
+
// its text if Lexical has decoded an escape or a character reference in it
|
|
1598
|
+
if (markedValue !== splitValue || /[\\&]/.test(markedValue)) {
|
|
1576
1599
|
removePlaceholders();
|
|
1577
1600
|
}
|
|
1578
1601
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function splitMultilineFormatting(value: string): string;
|
|
2
1
|
export function findCodeSpans(line: string): CodeSpan[];
|
|
2
|
+
export function splitMultilineFormatting(value: string): string;
|
|
3
3
|
export function addImportPlaceholders(value: string): string;
|
|
4
4
|
export function removeImportPlaceholders(text: string): string;
|
|
5
5
|
export function convertTildeFences(value: string): string;
|