@sveltia/ui 0.85.0 → 0.85.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/dist/components/text-editor/code-editor.svelte +18 -1
- package/dist/components/text-editor/lexical-root.svelte +1 -1
- 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/store.svelte.js +8 -0
- package/dist/components/text-editor/text-editor.svelte +18 -1
- package/dist/components/text-editor/toolbar/toolbar-wrapper.svelte +27 -3
- package/dist/styles/mixins.scss +19 -0
- package/dist/typedefs.d.ts +5 -0
- package/dist/typedefs.js +2 -0
- package/package.json +3 -3
|
@@ -138,7 +138,14 @@
|
|
|
138
138
|
});
|
|
139
139
|
</script>
|
|
140
140
|
|
|
141
|
-
<div
|
|
141
|
+
<div
|
|
142
|
+
{...restProps}
|
|
143
|
+
role="none"
|
|
144
|
+
class="sui code-editor"
|
|
145
|
+
class:flex
|
|
146
|
+
{hidden}
|
|
147
|
+
style:--sui-text-editor-toolbar-height="{editorStore.toolbarHeight}px"
|
|
148
|
+
>
|
|
142
149
|
{#if showLanguageSwitcher}
|
|
143
150
|
<CodeEditorToolbar {disabled} {readonly} />
|
|
144
151
|
{/if}
|
|
@@ -162,4 +169,14 @@
|
|
|
162
169
|
}
|
|
163
170
|
.code-editor.flex:not([hidden]) {
|
|
164
171
|
display: block;
|
|
172
|
+
}
|
|
173
|
+
.code-editor {
|
|
174
|
+
--sui-text-editor-toolbar-top: var(--sui-text-editor-inner-toolbar-top, 0px);
|
|
175
|
+
--sui-text-editor-toolbar-z-index: var(--sui-text-editor-inner-toolbar-z-index, 100);
|
|
176
|
+
}
|
|
177
|
+
.code-editor > :global(*) {
|
|
178
|
+
--sui-text-editor-inner-toolbar-top: calc(
|
|
179
|
+
var(--sui-text-editor-toolbar-top) + var(--sui-text-editor-toolbar-height)
|
|
180
|
+
);
|
|
181
|
+
--sui-text-editor-inner-toolbar-z-index: calc(var(--sui-text-editor-toolbar-z-index) - 1);
|
|
165
182
|
}</style>
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
></div>
|
|
199
199
|
|
|
200
200
|
<style>.lexical-root {
|
|
201
|
-
overflow:
|
|
201
|
+
overflow: clip;
|
|
202
202
|
border: 1px solid var(--sui-textbox-border-color);
|
|
203
203
|
border-radius: var(--sui-textbox-border-radius) !important;
|
|
204
204
|
padding: var(--sui-textbox-multiline-padding);
|
|
@@ -39,6 +39,8 @@ export const createEditorStore = () => {
|
|
|
39
39
|
let useRichText = $state(true);
|
|
40
40
|
/** @type {HTMLTextAreaElement | undefined} */
|
|
41
41
|
let textArea = $state();
|
|
42
|
+
/** @type {number} */
|
|
43
|
+
let toolbarHeight = $state(0);
|
|
42
44
|
/** @type {boolean} */
|
|
43
45
|
let hasConverterError = $state(false);
|
|
44
46
|
/** @type {boolean} */
|
|
@@ -180,6 +182,12 @@ export const createEditorStore = () => {
|
|
|
180
182
|
set textArea(newValue) {
|
|
181
183
|
textArea = newValue;
|
|
182
184
|
},
|
|
185
|
+
get toolbarHeight() {
|
|
186
|
+
return toolbarHeight;
|
|
187
|
+
},
|
|
188
|
+
set toolbarHeight(newValue) {
|
|
189
|
+
toolbarHeight = newValue;
|
|
190
|
+
},
|
|
183
191
|
get useRichText() {
|
|
184
192
|
return useRichText;
|
|
185
193
|
},
|
|
@@ -304,7 +304,14 @@
|
|
|
304
304
|
});
|
|
305
305
|
</script>
|
|
306
306
|
|
|
307
|
-
<div
|
|
307
|
+
<div
|
|
308
|
+
{...restProps}
|
|
309
|
+
role="none"
|
|
310
|
+
class="sui text-editor"
|
|
311
|
+
class:flex
|
|
312
|
+
{hidden}
|
|
313
|
+
style:--sui-text-editor-toolbar-height="{editorStore.toolbarHeight}px"
|
|
314
|
+
>
|
|
308
315
|
<TextEditorToolbar {disabled} {readonly} />
|
|
309
316
|
<LexicalRoot
|
|
310
317
|
{...labelAttrs}
|
|
@@ -371,4 +378,14 @@
|
|
|
371
378
|
border-start-end-radius: 0 !important;
|
|
372
379
|
border-end-start-radius: var(--sui-textbox-border-radius) !important;
|
|
373
380
|
border-end-end-radius: var(--sui-textbox-border-radius) !important;
|
|
381
|
+
}
|
|
382
|
+
.text-editor {
|
|
383
|
+
--sui-text-editor-toolbar-top: var(--sui-text-editor-inner-toolbar-top, 0px);
|
|
384
|
+
--sui-text-editor-toolbar-z-index: var(--sui-text-editor-inner-toolbar-z-index, 100);
|
|
385
|
+
}
|
|
386
|
+
.text-editor > :global(*) {
|
|
387
|
+
--sui-text-editor-inner-toolbar-top: calc(
|
|
388
|
+
var(--sui-text-editor-toolbar-top) + var(--sui-text-editor-toolbar-height)
|
|
389
|
+
);
|
|
390
|
+
--sui-text-editor-inner-toolbar-z-index: calc(var(--sui-text-editor-toolbar-z-index) - 1);
|
|
374
391
|
}</style>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { getContext } from 'svelte';
|
|
2
3
|
import Toolbar from '../../toolbar/toolbar.svelte';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @import { Snippet } from 'svelte';
|
|
7
|
+
* @import { TextEditorStore } from '../../../typedefs.js';
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -22,10 +24,32 @@
|
|
|
22
24
|
...restProps
|
|
23
25
|
/* eslint-enable prefer-const */
|
|
24
26
|
} = $props();
|
|
27
|
+
|
|
28
|
+
/** @type {TextEditorStore} */
|
|
29
|
+
const editorStore = getContext('editorStore');
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Keep the toolbar height in the store, so the sticky toolbars of nested editors can be placed
|
|
33
|
+
* below this one.
|
|
34
|
+
* @param {HTMLElement} toolbar Toolbar element.
|
|
35
|
+
* @returns {() => void} Cleanup function.
|
|
36
|
+
*/
|
|
37
|
+
const observeHeight = (toolbar) => {
|
|
38
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
39
|
+
editorStore.toolbarHeight = entry.borderBoxSize[0].blockSize;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
observer.observe(toolbar);
|
|
43
|
+
|
|
44
|
+
return () => {
|
|
45
|
+
observer.disconnect();
|
|
46
|
+
editorStore.toolbarHeight = 0;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
25
49
|
</script>
|
|
26
50
|
|
|
27
51
|
<div role="none" class="wrapper">
|
|
28
|
-
<Toolbar {...restProps} {disabled}>
|
|
52
|
+
<Toolbar {...restProps} {disabled} {@attach observeHeight}>
|
|
29
53
|
{@render children?.()}
|
|
30
54
|
</Toolbar>
|
|
31
55
|
</div>
|
|
@@ -35,8 +59,8 @@
|
|
|
35
59
|
}
|
|
36
60
|
.wrapper :global([role=toolbar]) {
|
|
37
61
|
position: sticky;
|
|
38
|
-
top:
|
|
39
|
-
z-index: 100;
|
|
62
|
+
top: var(--sui-text-editor-toolbar-top, 0px);
|
|
63
|
+
z-index: var(--sui-text-editor-toolbar-z-index, 100);
|
|
40
64
|
display: flex;
|
|
41
65
|
flex-wrap: wrap;
|
|
42
66
|
gap: 4px;
|
package/dist/styles/mixins.scss
CHANGED
|
@@ -124,3 +124,22 @@
|
|
|
124
124
|
@content;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
|
|
128
|
+
// The root of a text or code editor, whose sticky toolbar stays below the toolbars of the outer
|
|
129
|
+
// editors when nested, e.g. in an editor component. The root sets the toolbar height inline, which
|
|
130
|
+
// is added to the offset for the inner editors, while their z-index goes down so the outer
|
|
131
|
+
// toolbars stay on top of an inner toolbar being scrolled away.
|
|
132
|
+
@mixin nestable-editor {
|
|
133
|
+
// Wrapped in `&` to keep the declarations before any nested rules of the including block
|
|
134
|
+
& {
|
|
135
|
+
--sui-text-editor-toolbar-top: var(--sui-text-editor-inner-toolbar-top, 0px);
|
|
136
|
+
--sui-text-editor-toolbar-z-index: var(--sui-text-editor-inner-toolbar-z-index, 100);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
& > :global(*) {
|
|
140
|
+
--sui-text-editor-inner-toolbar-top: calc(
|
|
141
|
+
var(--sui-text-editor-toolbar-top) + var(--sui-text-editor-toolbar-height)
|
|
142
|
+
);
|
|
143
|
+
--sui-text-editor-inner-toolbar-z-index: calc(var(--sui-text-editor-toolbar-z-index) - 1);
|
|
144
|
+
}
|
|
145
|
+
}
|
package/dist/typedefs.d.ts
CHANGED
|
@@ -1048,6 +1048,11 @@ export type TextEditorStore = {
|
|
|
1048
1048
|
* mode.
|
|
1049
1049
|
*/
|
|
1050
1050
|
textArea: HTMLTextAreaElement | undefined;
|
|
1051
|
+
/**
|
|
1052
|
+
* Height of the sticky toolbar in pixels, which the toolbars of
|
|
1053
|
+
* nested editors are placed below. `0` while the toolbar isn’t rendered.
|
|
1054
|
+
*/
|
|
1055
|
+
toolbarHeight: number;
|
|
1051
1056
|
/**
|
|
1052
1057
|
* ID of the editable element currently shown: the Lexical root in the
|
|
1053
1058
|
* rich text mode, or the `<textarea>` in the plain text mode.
|
package/dist/typedefs.js
CHANGED
|
@@ -455,6 +455,8 @@
|
|
|
455
455
|
* plain text editor.
|
|
456
456
|
* @property {HTMLTextAreaElement | undefined} textArea The `<textarea>` element of the plain text
|
|
457
457
|
* mode.
|
|
458
|
+
* @property {number} toolbarHeight Height of the sticky toolbar in pixels, which the toolbars of
|
|
459
|
+
* nested editors are placed below. `0` while the toolbar isn’t rendered.
|
|
458
460
|
* @property {string} controlId ID of the editable element currently shown: the Lexical root in the
|
|
459
461
|
* rich text mode, or the `<textarea>` in the plain text mode.
|
|
460
462
|
* @property {boolean} hasConverterError Whether there was an error while converting Markdown or
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltia/ui",
|
|
3
|
-
"version": "0.85.
|
|
3
|
+
"version": "0.85.1",
|
|
4
4
|
"description": "A collection of Svelte components and utilities for building user interfaces.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
77
77
|
"@vitest/browser-playwright": "^5.0.4",
|
|
78
78
|
"@vitest/coverage-v8": "^5.0.4",
|
|
79
|
-
"cspell": "^10.
|
|
79
|
+
"cspell": "^10.4.0",
|
|
80
80
|
"eslint": "^9.39.5",
|
|
81
81
|
"eslint-config-airbnb-extended": "^3.3.0",
|
|
82
82
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"postcss-html": "^2.0.0",
|
|
93
93
|
"prettier": "^3.9.10",
|
|
94
94
|
"prettier-plugin-svelte": "^4.1.1",
|
|
95
|
-
"rolldown": "^1.2.
|
|
95
|
+
"rolldown": "^1.2.14",
|
|
96
96
|
"sass": "^1.105.1",
|
|
97
97
|
"shiki": "^4.5.0",
|
|
98
98
|
"stylelint": "^17.16.0",
|