svelte-multistyle-ui 0.0.11-alpha → 0.0.13-alpha
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/README.md +1 -1
- package/cli/registry.js +2 -0
- package/dist/components/CodeEditor.svelte +130 -0
- package/dist/components/CodeEditor.svelte.d.ts +25 -0
- package/dist/components/codeeditor-styles.css +292 -0
- package/dist/components/text-editor-core/editor-core.js +10 -2
- package/dist/components/text-editor-core/toolbar-config.d.ts +0 -22
- package/dist/components/text-editor-core/toolbar-config.js +7 -7
- package/dist/components/texteditor-styles.css +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ A Svelte action for portaling content to `document.body`:
|
|
|
84
84
|
The library exports the following components from `svelte-multistyle-ui`:
|
|
85
85
|
|
|
86
86
|
- Actions: `Button`, `IconButton`, `FAB`, `ButtonGroup`, `DropdownMenu`, `Popover`
|
|
87
|
-
- Form: `Input`, `Textarea`, `Select`, `MultiSelect`, `Checkbox`, `Radio`, `Toggle`, `Slider`, `FileUpload`, `DatePicker`, `SortableList`
|
|
87
|
+
- Form: `Input`, `Textarea`, `TextEditor`, `Select`, `MultiSelect`, `Checkbox`, `Radio`, `Toggle`, `Slider`, `FileUpload`, `DatePicker`, `SortableList`
|
|
88
88
|
- Layout: `Card`, `Divider`, `Tabs`, `Accordion`, `Modal`, `Drawer`, `CommandPalette`, `Row`, `Column`, `Grid`
|
|
89
89
|
- Navigation: `Breadcrumb`, `Pagination`, `Stepper`
|
|
90
90
|
- Data display: `Avatar`, `Chip`, `Tooltip`, `ProgressBar`, `Table`, `Spinner`, `Skeleton`, `Rating`
|
package/cli/registry.js
CHANGED
|
@@ -23,6 +23,8 @@ const registry = {
|
|
|
23
23
|
// ---------------- Form ----------------
|
|
24
24
|
Input: { importName: "Input", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
25
25
|
Textarea: { importName: "Textarea", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
26
|
+
TextEditor: { importName: "TextEditor", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
27
|
+
CodeEditor: { importName: "CodeEditor", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
26
28
|
Select: { importName: "Select", kind: "leaf", bindable: ["value"], primaryBindable: "value", listProps: ["options"] },
|
|
27
29
|
MultiSelect: { importName: "MultiSelect", kind: "leaf", bindable: ["selected"], primaryBindable: "selected", listProps: ["options"] },
|
|
28
30
|
Checkbox: { importName: "Checkbox", kind: "leaf", bindable: ["checked"], primaryBindable: "checked" },
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "./codeeditor-styles.css";
|
|
3
|
+
import { defaults } from "../config.js";
|
|
4
|
+
import { cn } from "../utils/cn.js";
|
|
5
|
+
import Prism from "prismjs";
|
|
6
|
+
// Core ships markup, css, clike, javascript. Register the rest of the curated set.
|
|
7
|
+
import "prismjs/components/prism-typescript";
|
|
8
|
+
import "prismjs/components/prism-json";
|
|
9
|
+
import "prismjs/components/prism-bash";
|
|
10
|
+
import "prismjs/components/prism-python";
|
|
11
|
+
|
|
12
|
+
// prismjs does not ship a svelte component; alias it to markup (HTML-like)
|
|
13
|
+
// so Svelte code still gets tag/attribute/string highlighting.
|
|
14
|
+
if (!Prism.languages.svelte) {
|
|
15
|
+
Prism.languages.svelte = Prism.languages.markup;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
style: styleProp,
|
|
20
|
+
theme: themeProp,
|
|
21
|
+
value = $bindable(""),
|
|
22
|
+
language = "javascript",
|
|
23
|
+
editable = true,
|
|
24
|
+
label = "",
|
|
25
|
+
rows = 10,
|
|
26
|
+
class: className = "",
|
|
27
|
+
...rest
|
|
28
|
+
} = $props();
|
|
29
|
+
|
|
30
|
+
const style = $derived(styleProp ?? defaults.style);
|
|
31
|
+
const theme = $derived(themeProp ?? defaults.theme);
|
|
32
|
+
const styleClass = $derived(`s-codeeditor-${style}`);
|
|
33
|
+
const themeClass = $derived(`theme-${theme}`);
|
|
34
|
+
|
|
35
|
+
const LANG_LABELS = {
|
|
36
|
+
javascript: "JS",
|
|
37
|
+
typescript: "TS",
|
|
38
|
+
markup: "HTML",
|
|
39
|
+
css: "CSS",
|
|
40
|
+
json: "JSON",
|
|
41
|
+
svelte: "Svelte",
|
|
42
|
+
bash: "Bash",
|
|
43
|
+
python: "Python",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function escapeHtml(s) {
|
|
47
|
+
return String(s)
|
|
48
|
+
.replace(/&/g, "&")
|
|
49
|
+
.replace(/</g, "<")
|
|
50
|
+
.replace(/>/g, ">")
|
|
51
|
+
.replace(/"/g, """)
|
|
52
|
+
.replace(/'/g, "'");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function highlight(code, lang) {
|
|
56
|
+
const grammar = Prism.languages[lang];
|
|
57
|
+
if (!grammar) return escapeHtml(code);
|
|
58
|
+
try {
|
|
59
|
+
return Prism.highlight(code, grammar, lang);
|
|
60
|
+
} catch {
|
|
61
|
+
return escapeHtml(code);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const highlighted = $derived(highlight(value, language));
|
|
66
|
+
const langLabel = $derived(
|
|
67
|
+
LANG_LABELS[language] ?? String(language).toUpperCase(),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
let copyStatus = $state(""); // "" | "copied" | "failed"
|
|
71
|
+
async function copyCode() {
|
|
72
|
+
try {
|
|
73
|
+
await navigator.clipboard.writeText(value);
|
|
74
|
+
copyStatus = "copied";
|
|
75
|
+
} catch {
|
|
76
|
+
copyStatus = "failed";
|
|
77
|
+
}
|
|
78
|
+
setTimeout(() => (copyStatus = ""), 1800);
|
|
79
|
+
}
|
|
80
|
+
const copyLabel = $derived(
|
|
81
|
+
copyStatus === "copied"
|
|
82
|
+
? "Copied!"
|
|
83
|
+
: copyStatus === "failed"
|
|
84
|
+
? "Failed"
|
|
85
|
+
: "Copy",
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Scroll sync: keep the highlighted <pre> (behind) aligned with the
|
|
89
|
+
// transparent <textarea> (front) so the caret tracks the tokens.
|
|
90
|
+
let preEl = $state(null);
|
|
91
|
+
let taEl = $state(null);
|
|
92
|
+
function syncScroll() {
|
|
93
|
+
if (preEl && taEl) {
|
|
94
|
+
preEl.scrollTop = taEl.scrollTop;
|
|
95
|
+
preEl.scrollLeft = taEl.scrollLeft;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<div class={cn("s-codeeditor-wrapper", styleClass, themeClass, className)}>
|
|
101
|
+
{#if label}
|
|
102
|
+
<label class="s-codeeditor-label">{label}</label>
|
|
103
|
+
{/if}
|
|
104
|
+
<div class="s-codeeditor-toolbar">
|
|
105
|
+
<span class="s-codeeditor-lang">{langLabel}</span>
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
class={cn("s-codeeditor-copy-btn", copyStatus)}
|
|
109
|
+
onclick={copyCode}
|
|
110
|
+
aria-label="Copy code"
|
|
111
|
+
>
|
|
112
|
+
{copyLabel}
|
|
113
|
+
</button>
|
|
114
|
+
</div>
|
|
115
|
+
<div class="s-codeeditor-code" style:--codeeditor-rows={rows}>
|
|
116
|
+
<pre class="s-codeeditor-pre" bind:this={preEl} aria-hidden="true"><code
|
|
117
|
+
>{@html highlighted}</code></pre>
|
|
118
|
+
{#if editable}
|
|
119
|
+
<textarea
|
|
120
|
+
class="s-codeeditor-textarea"
|
|
121
|
+
bind:value
|
|
122
|
+
bind:this={taEl}
|
|
123
|
+
onscroll={syncScroll}
|
|
124
|
+
spellcheck="false"
|
|
125
|
+
aria-label={label || "code editor"}
|
|
126
|
+
{...rest}
|
|
127
|
+
></textarea>
|
|
128
|
+
{/if}
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default CodeEditor;
|
|
2
|
+
type CodeEditor = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const CodeEditor: import("svelte").Component<{
|
|
7
|
+
style: any;
|
|
8
|
+
theme: any;
|
|
9
|
+
value?: string;
|
|
10
|
+
language?: string;
|
|
11
|
+
editable?: boolean;
|
|
12
|
+
label?: string;
|
|
13
|
+
rows?: number;
|
|
14
|
+
class?: string;
|
|
15
|
+
} & Record<string, any>, {}, "value">;
|
|
16
|
+
type $$ComponentProps = {
|
|
17
|
+
style: any;
|
|
18
|
+
theme: any;
|
|
19
|
+
value?: string;
|
|
20
|
+
language?: string;
|
|
21
|
+
editable?: boolean;
|
|
22
|
+
label?: string;
|
|
23
|
+
rows?: number;
|
|
24
|
+
class?: string;
|
|
25
|
+
} & Record<string, any>;
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/* ===== BASE ===== */
|
|
2
|
+
/* Theme-controlled: colors, border-width, shadow, radius. Style-controlled: shape. */
|
|
3
|
+
.s-codeeditor-wrapper {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
width: 100%;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
background: var(--t-card-bg);
|
|
9
|
+
color: var(--t-text);
|
|
10
|
+
border: var(--t-border-width) solid var(--t-border);
|
|
11
|
+
border-radius: var(--t-card-radius);
|
|
12
|
+
box-shadow: var(--t-shadow-xs);
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
.s-codeeditor-label {
|
|
16
|
+
display: block;
|
|
17
|
+
padding: 10px 14px 0;
|
|
18
|
+
font-size: 13px;
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
color: var(--t-text);
|
|
21
|
+
}
|
|
22
|
+
.s-codeeditor-toolbar {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
gap: 8px;
|
|
27
|
+
padding: 8px 12px;
|
|
28
|
+
border-bottom: var(--t-border-width) solid var(--t-border);
|
|
29
|
+
background: color-mix(in srgb, var(--t-surface) 60%, transparent);
|
|
30
|
+
}
|
|
31
|
+
.s-codeeditor-lang {
|
|
32
|
+
font-size: 11px;
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
text-transform: uppercase;
|
|
35
|
+
letter-spacing: 0.06em;
|
|
36
|
+
color: var(--t-text-muted);
|
|
37
|
+
}
|
|
38
|
+
.s-codeeditor-copy-btn {
|
|
39
|
+
appearance: none;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
font-size: 12px;
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
padding: 4px 10px;
|
|
44
|
+
border: var(--t-border-width) solid var(--t-primary);
|
|
45
|
+
border-radius: var(--t-input-radius);
|
|
46
|
+
background: var(--t-primary);
|
|
47
|
+
color: var(--t-text-on-primary);
|
|
48
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
49
|
+
}
|
|
50
|
+
.s-codeeditor-copy-btn:hover {
|
|
51
|
+
filter: brightness(1.08);
|
|
52
|
+
}
|
|
53
|
+
.s-codeeditor-copy-btn:active {
|
|
54
|
+
transform: translateY(1px);
|
|
55
|
+
}
|
|
56
|
+
.s-codeeditor-copy-btn.copied {
|
|
57
|
+
border-color: var(--t-success);
|
|
58
|
+
background: var(--t-success);
|
|
59
|
+
}
|
|
60
|
+
.s-codeeditor-copy-btn.failed {
|
|
61
|
+
border-color: var(--t-error);
|
|
62
|
+
background: var(--t-error);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Code area + overlay. pre (highlighted, behind) and textarea (transparent, front)
|
|
66
|
+
MUST share identical font metrics, padding, line-height, white-space and tab-size
|
|
67
|
+
so the caret lines up with the tokens. */
|
|
68
|
+
.s-codeeditor-code {
|
|
69
|
+
position: relative;
|
|
70
|
+
height: calc(var(--codeeditor-rows, 10) * 1.5em + 24px);
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
background: var(--t-surface);
|
|
73
|
+
}
|
|
74
|
+
.s-codeeditor-pre,
|
|
75
|
+
.s-codeeditor-textarea {
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 12px 14px;
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
|
|
80
|
+
"Liberation Mono", monospace;
|
|
81
|
+
font-size: 13px;
|
|
82
|
+
line-height: 1.5;
|
|
83
|
+
tab-size: 2;
|
|
84
|
+
-moz-tab-size: 2;
|
|
85
|
+
white-space: pre;
|
|
86
|
+
overflow: auto;
|
|
87
|
+
}
|
|
88
|
+
.s-codeeditor-pre {
|
|
89
|
+
position: absolute;
|
|
90
|
+
inset: 0;
|
|
91
|
+
color: var(--t-text);
|
|
92
|
+
background: transparent;
|
|
93
|
+
border: 0;
|
|
94
|
+
pointer-events: none;
|
|
95
|
+
}
|
|
96
|
+
.s-codeeditor-pre code {
|
|
97
|
+
font: inherit;
|
|
98
|
+
color: inherit;
|
|
99
|
+
background: none;
|
|
100
|
+
}
|
|
101
|
+
.s-codeeditor-textarea {
|
|
102
|
+
position: absolute;
|
|
103
|
+
inset: 0;
|
|
104
|
+
color: transparent;
|
|
105
|
+
caret-color: var(--t-text);
|
|
106
|
+
background: transparent;
|
|
107
|
+
border: 0;
|
|
108
|
+
resize: none;
|
|
109
|
+
outline: none;
|
|
110
|
+
-webkit-text-fill-color: transparent;
|
|
111
|
+
}
|
|
112
|
+
.s-codeeditor-textarea::selection {
|
|
113
|
+
background: color-mix(in srgb, var(--t-primary) 30%, transparent);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* ===== PRISM TOKEN COLORS (re-hosted from demo app.css; package does not export app.css) ===== */
|
|
117
|
+
.token.comment,
|
|
118
|
+
.token.prolog,
|
|
119
|
+
.token.doctype,
|
|
120
|
+
.token.cdata {
|
|
121
|
+
color: var(--t-text-hint, #94a3b8);
|
|
122
|
+
}
|
|
123
|
+
.token.punctuation {
|
|
124
|
+
color: color-mix(in srgb, var(--t-text) 60%, transparent);
|
|
125
|
+
}
|
|
126
|
+
.token.property,
|
|
127
|
+
.token.tag,
|
|
128
|
+
.token.boolean,
|
|
129
|
+
.token.number,
|
|
130
|
+
.token.constant,
|
|
131
|
+
.token.symbol,
|
|
132
|
+
.token.deleted {
|
|
133
|
+
color: #f472b6;
|
|
134
|
+
}
|
|
135
|
+
.token.selector,
|
|
136
|
+
.token.attr-name,
|
|
137
|
+
.token.string,
|
|
138
|
+
.token.char,
|
|
139
|
+
.token.builtin,
|
|
140
|
+
.token.inserted {
|
|
141
|
+
color: #34d399;
|
|
142
|
+
}
|
|
143
|
+
.token.operator,
|
|
144
|
+
.token.entity,
|
|
145
|
+
.token.url {
|
|
146
|
+
color: #fbbf24;
|
|
147
|
+
}
|
|
148
|
+
.token.atrule,
|
|
149
|
+
.token.attr-value,
|
|
150
|
+
.token.keyword {
|
|
151
|
+
color: #818cf8;
|
|
152
|
+
}
|
|
153
|
+
.token.function,
|
|
154
|
+
.token.class-name {
|
|
155
|
+
color: #60a5fa;
|
|
156
|
+
}
|
|
157
|
+
.token.regex,
|
|
158
|
+
.token.important,
|
|
159
|
+
.token.variable {
|
|
160
|
+
color: #f97316;
|
|
161
|
+
}
|
|
162
|
+
.token.bold {
|
|
163
|
+
font-weight: bold;
|
|
164
|
+
}
|
|
165
|
+
.token.italic {
|
|
166
|
+
font-style: italic;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* ===== STYLE OVERRIDES ===== */
|
|
170
|
+
/* Material is the base default. */
|
|
171
|
+
.s-codeeditor-material3 {
|
|
172
|
+
border-radius: var(--t-input-radius);
|
|
173
|
+
box-shadow: none;
|
|
174
|
+
}
|
|
175
|
+
.s-codeeditor-material3 .s-codeeditor-toolbar {
|
|
176
|
+
background: color-mix(in srgb, var(--t-primary) 6%, var(--t-surface));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.s-codeeditor-fluent {
|
|
180
|
+
border-radius: 6px;
|
|
181
|
+
box-shadow: var(--t-shadow-xs);
|
|
182
|
+
}
|
|
183
|
+
.s-codeeditor-fluent .s-codeeditor-toolbar {
|
|
184
|
+
border-bottom-width: 1px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.s-codeeditor-brutalist {
|
|
188
|
+
border: 2px solid var(--t-text);
|
|
189
|
+
border-radius: 0;
|
|
190
|
+
box-shadow: 5px 5px 0 var(--t-text);
|
|
191
|
+
}
|
|
192
|
+
.s-codeeditor-brutalist .s-codeeditor-copy-btn {
|
|
193
|
+
border-radius: 0;
|
|
194
|
+
border: 2px solid var(--t-text);
|
|
195
|
+
font-weight: 800;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.s-codeeditor-pixel {
|
|
199
|
+
border-radius: 0;
|
|
200
|
+
border: var(--t-border-width) solid var(--t-primary);
|
|
201
|
+
box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.25),
|
|
202
|
+
inset 3px 3px 0 rgba(255, 255, 255, 0.1);
|
|
203
|
+
}
|
|
204
|
+
.s-codeeditor-pixel .s-codeeditor-pre,
|
|
205
|
+
.s-codeeditor-pixel .s-codeeditor-textarea {
|
|
206
|
+
font-family: "Courier New", monospace;
|
|
207
|
+
}
|
|
208
|
+
.s-codeeditor-pixel .s-codeeditor-copy-btn {
|
|
209
|
+
border-radius: 0;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.s-codeeditor-neon {
|
|
213
|
+
border-radius: var(--t-input-radius);
|
|
214
|
+
border-color: var(--t-primary);
|
|
215
|
+
box-shadow: 0 0 8px var(--t-primary), 0 0 16px var(--t-shadow);
|
|
216
|
+
}
|
|
217
|
+
.s-codeeditor-neon .s-codeeditor-copy-btn {
|
|
218
|
+
box-shadow: 0 0 6px var(--t-primary);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.s-codeeditor-metro {
|
|
222
|
+
border-radius: 0;
|
|
223
|
+
border: var(--t-border-width) solid var(--t-primary);
|
|
224
|
+
box-shadow: none;
|
|
225
|
+
}
|
|
226
|
+
.s-codeeditor-metro .s-codeeditor-toolbar {
|
|
227
|
+
background: var(--t-primary);
|
|
228
|
+
color: var(--t-text-on-primary);
|
|
229
|
+
}
|
|
230
|
+
.s-codeeditor-metro .s-codeeditor-lang {
|
|
231
|
+
color: var(--t-text-on-primary);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.s-codeeditor-bootstrap {
|
|
235
|
+
border-radius: 6px;
|
|
236
|
+
box-shadow: var(--t-shadow-xs);
|
|
237
|
+
}
|
|
238
|
+
.s-codeeditor-bootstrap .s-codeeditor-copy-btn {
|
|
239
|
+
border-radius: 4px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.s-codeeditor-cartoon {
|
|
243
|
+
border-radius: 16px;
|
|
244
|
+
border: 2px solid var(--t-text);
|
|
245
|
+
box-shadow: 4px 4px 0 var(--t-primary);
|
|
246
|
+
}
|
|
247
|
+
.s-codeeditor-cartoon .s-codeeditor-copy-btn {
|
|
248
|
+
border-radius: 999px;
|
|
249
|
+
font-weight: 800;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.s-codeeditor-illustration {
|
|
253
|
+
border-radius: 12px;
|
|
254
|
+
border: var(--t-border-width) solid var(--t-text);
|
|
255
|
+
box-shadow: 3px 3px 0 var(--t-border);
|
|
256
|
+
}
|
|
257
|
+
.s-codeeditor-illustration .s-codeeditor-toolbar {
|
|
258
|
+
font-style: italic;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.s-codeeditor-carbon {
|
|
262
|
+
border-radius: 0;
|
|
263
|
+
border: var(--t-border-width) solid var(--t-border);
|
|
264
|
+
border-bottom-width: 2px;
|
|
265
|
+
box-shadow: none;
|
|
266
|
+
}
|
|
267
|
+
.s-codeeditor-carbon .s-codeeditor-pre,
|
|
268
|
+
.s-codeeditor-carbon .s-codeeditor-textarea {
|
|
269
|
+
font-family: "IBM Plex Mono", ui-monospace, monospace;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.s-codeeditor-liquid-glass {
|
|
273
|
+
background: rgba(255, 255, 255, 0.08);
|
|
274
|
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
275
|
+
border-radius: 16px;
|
|
276
|
+
backdrop-filter: blur(24px) saturate(1.6);
|
|
277
|
+
-webkit-backdrop-filter: blur(24px) saturate(1.6);
|
|
278
|
+
box-shadow: var(--t-shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.3);
|
|
279
|
+
}
|
|
280
|
+
.s-codeeditor-liquid-glass .s-codeeditor-toolbar {
|
|
281
|
+
background: rgba(255, 255, 255, 0.06);
|
|
282
|
+
border-bottom-color: rgba(255, 255, 255, 0.15);
|
|
283
|
+
}
|
|
284
|
+
.s-codeeditor-liquid-glass .s-codeeditor-code {
|
|
285
|
+
background: rgba(0, 0, 0, 0.12);
|
|
286
|
+
}
|
|
287
|
+
.s-codeeditor-liquid-glass .s-codeeditor-copy-btn {
|
|
288
|
+
background: rgba(255, 255, 255, 0.15);
|
|
289
|
+
border-color: rgba(255, 255, 255, 0.3);
|
|
290
|
+
color: var(--t-text);
|
|
291
|
+
backdrop-filter: blur(8px);
|
|
292
|
+
}
|
|
@@ -309,7 +309,9 @@ export class TextEditorCore {
|
|
|
309
309
|
title: action.title || action.label,
|
|
310
310
|
"data-command": action.command,
|
|
311
311
|
"data-active": action.active || "",
|
|
312
|
-
|
|
312
|
+
...(action.icon
|
|
313
|
+
? { innerHTML: `<span class="${action.icon}">${action.label}</span>` }
|
|
314
|
+
: { textContent: action.label }),
|
|
313
315
|
onclick: (e) => {
|
|
314
316
|
e.preventDefault();
|
|
315
317
|
this._handleCommand(action);
|
|
@@ -337,9 +339,15 @@ export class TextEditorCore {
|
|
|
337
339
|
|
|
338
340
|
if (action.type === "color") {
|
|
339
341
|
const label = createElement("label", {
|
|
340
|
-
className: `s-texteditor-color-btn s-texteditor-color-${action.id}`,
|
|
342
|
+
className: `s-texteditor-color-btn s-texteditor-color-${action.id}${action.label ? " s-texteditor-color-btn--icon" : ""}`,
|
|
341
343
|
title: action.title,
|
|
342
344
|
});
|
|
345
|
+
if (action.label) {
|
|
346
|
+
label.appendChild(createElement("span", {
|
|
347
|
+
className: "s-texteditor-color-icon",
|
|
348
|
+
textContent: action.label,
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
343
351
|
const input = createElement("input", {
|
|
344
352
|
type: "color",
|
|
345
353
|
"data-command": action.command,
|
|
@@ -52,21 +52,6 @@ export const DEFAULT_TOOLBAR: ({
|
|
|
52
52
|
label: string;
|
|
53
53
|
value: string;
|
|
54
54
|
}[];
|
|
55
|
-
} | {
|
|
56
|
-
id: string;
|
|
57
|
-
type: string;
|
|
58
|
-
title: string;
|
|
59
|
-
command: string;
|
|
60
|
-
options?: undefined;
|
|
61
|
-
})[] | ({
|
|
62
|
-
id: string;
|
|
63
|
-
type: string;
|
|
64
|
-
title: string;
|
|
65
|
-
command: string;
|
|
66
|
-
options: {
|
|
67
|
-
label: string;
|
|
68
|
-
value: string;
|
|
69
|
-
}[];
|
|
70
55
|
label?: undefined;
|
|
71
56
|
active?: undefined;
|
|
72
57
|
} | {
|
|
@@ -103,11 +88,4 @@ export const FLOATING_TOOLBAR: ({
|
|
|
103
88
|
title: string;
|
|
104
89
|
command: string;
|
|
105
90
|
active?: undefined;
|
|
106
|
-
} | {
|
|
107
|
-
id: string;
|
|
108
|
-
type: string;
|
|
109
|
-
title: string;
|
|
110
|
-
command: string;
|
|
111
|
-
label?: undefined;
|
|
112
|
-
active?: undefined;
|
|
113
91
|
})[];
|
|
@@ -93,8 +93,8 @@ export const DEFAULT_TOOLBAR = [
|
|
|
93
93
|
[
|
|
94
94
|
{ id: "fontName", type: "select", title: "Font family", command: "fontName", options: FONT_FAMILIES },
|
|
95
95
|
{ id: "fontSize", type: "select", title: "Font size", command: "fontSize", options: FONT_SIZES },
|
|
96
|
-
{ id: "foreColor", type: "color", title: "Text color", command: "foreColor" },
|
|
97
|
-
{ id: "hiliteColor", type: "color", title: "Highlight", command: "hiliteColor" },
|
|
96
|
+
{ id: "foreColor", type: "color", title: "Text color", command: "foreColor", label: "🎨" },
|
|
97
|
+
{ id: "hiliteColor", type: "color", title: "Highlight", command: "hiliteColor", label: "🖍️" },
|
|
98
98
|
],
|
|
99
99
|
// Paragraph formatting
|
|
100
100
|
[
|
|
@@ -115,14 +115,14 @@ export const DEFAULT_TOOLBAR = [
|
|
|
115
115
|
// Insert
|
|
116
116
|
[
|
|
117
117
|
{ id: "insertLink", type: "button", label: "🔗", title: "Insert link", command: "createLink" },
|
|
118
|
-
{ id: "insertImage", type: "button", label: "
|
|
119
|
-
{ id: "insertVideo", type: "button", label: "
|
|
120
|
-
{ id: "insertTable", type: "button", label: "
|
|
118
|
+
{ id: "insertImage", type: "button", label: "🖼️", title: "Insert image", command: "insertImage" },
|
|
119
|
+
{ id: "insertVideo", type: "button", label: "🎥", title: "Insert video", command: "insertVideo" },
|
|
120
|
+
{ id: "insertTable", type: "button", label: "📋", title: "Insert table", command: "insertTable" },
|
|
121
121
|
{ id: "insertHorizontalRule", type: "button", label: "—", title: "Horizontal rule", command: "insertHorizontalRule" },
|
|
122
122
|
],
|
|
123
123
|
// View
|
|
124
124
|
[
|
|
125
|
-
{ id: "toggleCodeView", type: "button", label: "
|
|
125
|
+
{ id: "toggleCodeView", type: "button", label: "</>", title: "Toggle code view", command: "toggleCodeView" },
|
|
126
126
|
],
|
|
127
127
|
];
|
|
128
128
|
|
|
@@ -134,5 +134,5 @@ export const FLOATING_TOOLBAR = [
|
|
|
134
134
|
{ id: "italic", type: "button", label: "I", title: "Italic", command: "italic", active: "italic" },
|
|
135
135
|
{ id: "underline", type: "button", label: "U", title: "Underline", command: "underline", active: "underline" },
|
|
136
136
|
{ id: "createLink", type: "button", label: "🔗", title: "Link", command: "createLink" },
|
|
137
|
-
{ id: "foreColor", type: "color", title: "Color", command: "foreColor" },
|
|
137
|
+
{ id: "foreColor", type: "color", title: "Color", command: "foreColor", label: "🎨" },
|
|
138
138
|
];
|
|
@@ -145,6 +145,16 @@
|
|
|
145
145
|
border: 1px solid var(--t-border);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
.s-texteditor-color-btn--icon::before {
|
|
149
|
+
display: none;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.s-texteditor-color-icon {
|
|
153
|
+
font-size: 18px;
|
|
154
|
+
line-height: 1;
|
|
155
|
+
pointer-events: none;
|
|
156
|
+
}
|
|
157
|
+
|
|
148
158
|
.s-texteditor-color-btn input[type="color"] {
|
|
149
159
|
position: absolute;
|
|
150
160
|
inset: 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as Button } from "./components/Button.svelte";
|
|
|
7
7
|
export { default as IconButton } from "./components/IconButton.svelte";
|
|
8
8
|
export { default as Textarea } from "./components/Textarea.svelte";
|
|
9
9
|
export { default as TextEditor } from "./components/TextEditor.svelte";
|
|
10
|
+
export { default as CodeEditor } from "./components/CodeEditor.svelte";
|
|
10
11
|
export { default as Select } from "./components/Select.svelte";
|
|
11
12
|
export { default as MultiSelect } from "./components/MultiSelect.svelte";
|
|
12
13
|
export { default as Checkbox } from "./components/Checkbox.svelte";
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { default as Button } from "./components/Button.svelte";
|
|
|
17
17
|
export { default as IconButton } from "./components/IconButton.svelte";
|
|
18
18
|
export { default as Textarea } from "./components/Textarea.svelte";
|
|
19
19
|
export { default as TextEditor } from "./components/TextEditor.svelte";
|
|
20
|
+
export { default as CodeEditor } from "./components/CodeEditor.svelte";
|
|
20
21
|
export { default as Select } from "./components/Select.svelte";
|
|
21
22
|
export { default as MultiSelect } from "./components/MultiSelect.svelte";
|
|
22
23
|
export { default as Checkbox } from "./components/Checkbox.svelte";
|
package/package.json
CHANGED