@nonoun/native-codemirror 0.2.3 → 0.2.5
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/codemirror-element-DqgpO8qM.js +563 -0
- package/dist/codemirror-element.d.ts +42 -0
- package/dist/codemirror-element.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/native-codemirror.css +69 -10
- package/dist/native-codemirror.js +45 -379
- package/dist/register.d.ts +2 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +3 -0
- package/dist/theme.d.ts +6 -0
- package/dist/theme.d.ts.map +1 -1
- package/package.json +8 -1
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import { EditorView as e, drawSelection as t, highlightActiveLine as n, highlightActiveLineGutter as r, highlightSpecialChars as i, keymap as a, lineNumbers as o, placeholder as s } from "@codemirror/view";
|
|
2
|
+
import { HighlightStyle as c, bracketMatching as l, foldGutter as u, foldKeymap as d, indentOnInput as f, syntaxHighlighting as p } from "@codemirror/language";
|
|
3
|
+
import { tags as m } from "@lezer/highlight";
|
|
4
|
+
import { defaultKeymap as h, history as g, historyKeymap as _ } from "@codemirror/commands";
|
|
5
|
+
import { autocompletion as v, closeBrackets as y, closeBracketsKeymap as b, completionKeymap as x } from "@codemirror/autocomplete";
|
|
6
|
+
import { Compartment as S, EditorState as C } from "@codemirror/state";
|
|
7
|
+
import { NativeElement as w, createDisabledEffect as T, signal as E } from "@nonoun/native-ui";
|
|
8
|
+
/**
|
|
9
|
+
* NativeUI CodeMirror Theme
|
|
10
|
+
*
|
|
11
|
+
* Dark theme inspired by one-dark, designed to harmonize with the
|
|
12
|
+
* @nonoun/native-ui OKLCH design system. Uses EditorView.theme()
|
|
13
|
+
* with { dark: true } and HighlightStyle.define() for syntax tokens.
|
|
14
|
+
*
|
|
15
|
+
* All colors flow through --n-code-* CSS custom properties (defined in
|
|
16
|
+
* codemirror.css). When native-ui foundation CSS is loaded, tokens like
|
|
17
|
+
* --n-body and --n-ink provide automatic theme integration. Without it,
|
|
18
|
+
* the one-dark hex fallbacks apply. Consumers can override any
|
|
19
|
+
* --n-code-* var directly on .cm-editor.
|
|
20
|
+
*/
|
|
21
|
+
var D = "var(--n-code-bg, #282c34)", O = "var(--n-code-bg-raised, #21252b)", k = "var(--n-code-text, #abb2bf)", A = "var(--n-code-text-muted, #7d8799)", j = "var(--n-code-cursor, #528bff)", M = "var(--n-code-selection, #3E4451)", N = "var(--n-code-line-active, #2c313a)", P = "var(--n-code-bracket, #515a6b)", F = "var(--n-code-border, #3E4451)", I = "var(--n-code-button, #3E4451)", L = "var(--n-code-keyword, #c678dd)", R = "var(--n-code-string, #98c379)", z = "var(--n-code-function, #61afef)", B = "var(--n-code-variable, #e06c75)", V = "var(--n-code-type, #e5c07b)", H = "var(--n-code-operator, #56b6c2)", U = "var(--n-code-number, #d19a66)";
|
|
22
|
+
const W = e.theme({
|
|
23
|
+
"&": {
|
|
24
|
+
color: k,
|
|
25
|
+
backgroundColor: D,
|
|
26
|
+
fontSize: "14px",
|
|
27
|
+
fontFamily: "'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, SFMono-Regular, Menlo, monospace"
|
|
28
|
+
},
|
|
29
|
+
".cm-content": {
|
|
30
|
+
caretColor: j,
|
|
31
|
+
padding: "4px 0"
|
|
32
|
+
},
|
|
33
|
+
"&.cm-focused .cm-cursor": {
|
|
34
|
+
borderLeftColor: j,
|
|
35
|
+
borderLeftWidth: "2px"
|
|
36
|
+
},
|
|
37
|
+
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { backgroundColor: M },
|
|
38
|
+
".cm-activeLine": { backgroundColor: N },
|
|
39
|
+
".cm-gutters": {
|
|
40
|
+
backgroundColor: O,
|
|
41
|
+
color: A,
|
|
42
|
+
borderRight: "none",
|
|
43
|
+
paddingRight: "4px"
|
|
44
|
+
},
|
|
45
|
+
".cm-activeLineGutter": {
|
|
46
|
+
backgroundColor: N,
|
|
47
|
+
color: k
|
|
48
|
+
},
|
|
49
|
+
".cm-lineNumbers .cm-gutterElement": {
|
|
50
|
+
padding: "0 8px 0 16px",
|
|
51
|
+
minWidth: "40px"
|
|
52
|
+
},
|
|
53
|
+
".cm-foldGutter .cm-gutterElement": {
|
|
54
|
+
padding: "0 4px",
|
|
55
|
+
cursor: "pointer"
|
|
56
|
+
},
|
|
57
|
+
"&.cm-focused .cm-matchingBracket": {
|
|
58
|
+
backgroundColor: P,
|
|
59
|
+
outline: `1px solid ${P}`
|
|
60
|
+
},
|
|
61
|
+
"&.cm-focused .cm-nonmatchingBracket": { color: B },
|
|
62
|
+
".cm-searchMatch": {
|
|
63
|
+
backgroundColor: "var(--n-code-search, rgba(229, 192, 123, 0.25))",
|
|
64
|
+
outline: "1px solid var(--n-code-search-outline, rgba(229, 192, 123, 0.4))"
|
|
65
|
+
},
|
|
66
|
+
".cm-searchMatch.cm-searchMatch-selected": { backgroundColor: "var(--n-code-search-active, rgba(97, 175, 239, 0.3))" },
|
|
67
|
+
".cm-tooltip": {
|
|
68
|
+
backgroundColor: O,
|
|
69
|
+
color: k,
|
|
70
|
+
border: `1px solid ${F}`,
|
|
71
|
+
borderRadius: "6px",
|
|
72
|
+
boxShadow: "var(--n-code-shadow, 0 4px 16px rgba(0, 0, 0, 0.3))"
|
|
73
|
+
},
|
|
74
|
+
".cm-tooltip .cm-tooltip-arrow::before": {
|
|
75
|
+
borderTopColor: F,
|
|
76
|
+
borderBottomColor: F
|
|
77
|
+
},
|
|
78
|
+
".cm-tooltip .cm-tooltip-arrow::after": {
|
|
79
|
+
borderTopColor: O,
|
|
80
|
+
borderBottomColor: O
|
|
81
|
+
},
|
|
82
|
+
".cm-tooltip-autocomplete": {
|
|
83
|
+
"& > ul": {
|
|
84
|
+
fontFamily: "inherit",
|
|
85
|
+
maxHeight: "240px"
|
|
86
|
+
},
|
|
87
|
+
"& > ul > li": { padding: "4px 8px" },
|
|
88
|
+
"& > ul > li[aria-selected]": {
|
|
89
|
+
backgroundColor: M,
|
|
90
|
+
color: k
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
".cm-panels": {
|
|
94
|
+
backgroundColor: O,
|
|
95
|
+
color: k
|
|
96
|
+
},
|
|
97
|
+
".cm-panels.cm-panels-top": { borderBottom: `1px solid ${F}` },
|
|
98
|
+
".cm-panels.cm-panels-bottom": { borderTop: `1px solid ${F}` },
|
|
99
|
+
".cm-panel input, .cm-panel button, .cm-panel select": { fontSize: "inherit" },
|
|
100
|
+
".cm-panel input": {
|
|
101
|
+
backgroundColor: D,
|
|
102
|
+
color: k,
|
|
103
|
+
border: `1px solid ${F}`,
|
|
104
|
+
borderRadius: "4px",
|
|
105
|
+
padding: "2px 6px"
|
|
106
|
+
},
|
|
107
|
+
".cm-panel button": {
|
|
108
|
+
backgroundColor: I,
|
|
109
|
+
color: k,
|
|
110
|
+
border: "none",
|
|
111
|
+
borderRadius: "4px",
|
|
112
|
+
padding: "2px 8px",
|
|
113
|
+
cursor: "pointer"
|
|
114
|
+
},
|
|
115
|
+
".cm-fat-cursor .cm-cursor": {
|
|
116
|
+
display: "block",
|
|
117
|
+
backgroundColor: `${j}77`,
|
|
118
|
+
borderLeft: "none",
|
|
119
|
+
width: "0.5em"
|
|
120
|
+
},
|
|
121
|
+
".cm-selectionLayer .cm-selectionBackground": { backgroundColor: `${M}80` },
|
|
122
|
+
".cm-foldPlaceholder": {
|
|
123
|
+
backgroundColor: "transparent",
|
|
124
|
+
border: "none",
|
|
125
|
+
color: A
|
|
126
|
+
}
|
|
127
|
+
}, { dark: !0 }), G = c.define([
|
|
128
|
+
{
|
|
129
|
+
tag: m.comment,
|
|
130
|
+
color: A,
|
|
131
|
+
fontStyle: "italic"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
tag: m.lineComment,
|
|
135
|
+
color: A,
|
|
136
|
+
fontStyle: "italic"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
tag: m.blockComment,
|
|
140
|
+
color: A,
|
|
141
|
+
fontStyle: "italic"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
tag: m.docComment,
|
|
145
|
+
color: A,
|
|
146
|
+
fontStyle: "italic"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
tag: m.keyword,
|
|
150
|
+
color: L
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
tag: m.controlKeyword,
|
|
154
|
+
color: L
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
tag: m.operatorKeyword,
|
|
158
|
+
color: L
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
tag: m.definitionKeyword,
|
|
162
|
+
color: L
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
tag: m.moduleKeyword,
|
|
166
|
+
color: L
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
tag: m.string,
|
|
170
|
+
color: R
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
tag: m.special(m.string),
|
|
174
|
+
color: R
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
tag: m.regexp,
|
|
178
|
+
color: R
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
tag: m.escape,
|
|
182
|
+
color: H
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
tag: m.character,
|
|
186
|
+
color: R
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
tag: m.function(m.definition(m.variableName)),
|
|
190
|
+
color: z
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
tag: m.function(m.variableName),
|
|
194
|
+
color: z
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
tag: m.variableName,
|
|
198
|
+
color: B
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
tag: m.definition(m.variableName),
|
|
202
|
+
color: B
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
tag: m.propertyName,
|
|
206
|
+
color: B
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
tag: m.definition(m.propertyName),
|
|
210
|
+
color: B
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
tag: m.typeName,
|
|
214
|
+
color: V
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
tag: m.className,
|
|
218
|
+
color: V
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
tag: m.namespace,
|
|
222
|
+
color: V
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
tag: m.macroName,
|
|
226
|
+
color: V
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
tag: m.annotation,
|
|
230
|
+
color: V
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
tag: m.number,
|
|
234
|
+
color: U
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
tag: m.integer,
|
|
238
|
+
color: U
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
tag: m.float,
|
|
242
|
+
color: U
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
tag: m.bool,
|
|
246
|
+
color: U
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
tag: m.null,
|
|
250
|
+
color: U
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
tag: m.atom,
|
|
254
|
+
color: U
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
tag: m.operator,
|
|
258
|
+
color: H
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
tag: m.punctuation,
|
|
262
|
+
color: k
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
tag: m.paren,
|
|
266
|
+
color: k
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
tag: m.squareBracket,
|
|
270
|
+
color: k
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
tag: m.brace,
|
|
274
|
+
color: k
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
tag: m.derefOperator,
|
|
278
|
+
color: k
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
tag: m.separator,
|
|
282
|
+
color: k
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
tag: m.url,
|
|
286
|
+
color: H,
|
|
287
|
+
textDecoration: "underline"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
tag: m.link,
|
|
291
|
+
color: H
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
tag: m.labelName,
|
|
295
|
+
color: B
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
tag: m.tagName,
|
|
299
|
+
color: B
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
tag: m.attributeName,
|
|
303
|
+
color: U
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
tag: m.attributeValue,
|
|
307
|
+
color: R
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
tag: m.angleBracket,
|
|
311
|
+
color: k
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
tag: m.self,
|
|
315
|
+
color: B
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
tag: m.processingInstruction,
|
|
319
|
+
color: A
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
tag: m.meta,
|
|
323
|
+
color: A
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
tag: m.heading,
|
|
327
|
+
color: B,
|
|
328
|
+
fontWeight: "bold"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
tag: m.heading1,
|
|
332
|
+
color: B,
|
|
333
|
+
fontWeight: "bold"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
tag: m.heading2,
|
|
337
|
+
color: B,
|
|
338
|
+
fontWeight: "bold"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
tag: m.heading3,
|
|
342
|
+
color: B,
|
|
343
|
+
fontWeight: "bold"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
tag: m.emphasis,
|
|
347
|
+
fontStyle: "italic"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
tag: m.strong,
|
|
351
|
+
fontWeight: "bold"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
tag: m.strikethrough,
|
|
355
|
+
textDecoration: "line-through"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
tag: m.invalid,
|
|
359
|
+
color: "var(--n-code-invalid, #ffffff)",
|
|
360
|
+
backgroundColor: B
|
|
361
|
+
}
|
|
362
|
+
]), K = p(G);
|
|
363
|
+
var q = class extends w {
|
|
364
|
+
static observedAttributes = [
|
|
365
|
+
"value",
|
|
366
|
+
"placeholder",
|
|
367
|
+
"readonly",
|
|
368
|
+
"disabled",
|
|
369
|
+
"line-numbers",
|
|
370
|
+
"line-wrapping",
|
|
371
|
+
"tab-size"
|
|
372
|
+
];
|
|
373
|
+
#e;
|
|
374
|
+
#t = null;
|
|
375
|
+
#n = E(!1);
|
|
376
|
+
#r = E(!1);
|
|
377
|
+
#i = E("");
|
|
378
|
+
#a = E(2);
|
|
379
|
+
#o = E(!0);
|
|
380
|
+
#s = E(!1);
|
|
381
|
+
#c = E([]);
|
|
382
|
+
#l = new S();
|
|
383
|
+
#u = new S();
|
|
384
|
+
#d = new S();
|
|
385
|
+
#f = new S();
|
|
386
|
+
#p = new S();
|
|
387
|
+
#m = new S();
|
|
388
|
+
#h = "";
|
|
389
|
+
constructor() {
|
|
390
|
+
super(), this.#e = this.attachInternals();
|
|
391
|
+
}
|
|
392
|
+
get value() {
|
|
393
|
+
return this.#t ? this.#t.state.doc.toString() : this.getAttribute("value") ?? "";
|
|
394
|
+
}
|
|
395
|
+
set value(e) {
|
|
396
|
+
this.#t && this.#t.state.doc.toString() !== e && this.#t.dispatch({ changes: {
|
|
397
|
+
from: 0,
|
|
398
|
+
to: this.#t.state.doc.length,
|
|
399
|
+
insert: e
|
|
400
|
+
} });
|
|
401
|
+
}
|
|
402
|
+
get editorView() {
|
|
403
|
+
return this.#t;
|
|
404
|
+
}
|
|
405
|
+
/** Additional CodeMirror extensions (language modes, etc.). */
|
|
406
|
+
get extensions() {
|
|
407
|
+
return this.#c.value;
|
|
408
|
+
}
|
|
409
|
+
set extensions(e) {
|
|
410
|
+
this.#c.value = e;
|
|
411
|
+
}
|
|
412
|
+
get readOnly() {
|
|
413
|
+
return this.#r.value;
|
|
414
|
+
}
|
|
415
|
+
set readOnly(e) {
|
|
416
|
+
this.#r.value = e, this.toggleAttribute("readonly", e);
|
|
417
|
+
}
|
|
418
|
+
get disabled() {
|
|
419
|
+
return this.#n.value;
|
|
420
|
+
}
|
|
421
|
+
set disabled(e) {
|
|
422
|
+
this.#n.value = e, this.toggleAttribute("disabled", e);
|
|
423
|
+
}
|
|
424
|
+
get placeholder() {
|
|
425
|
+
return this.#i.value;
|
|
426
|
+
}
|
|
427
|
+
set placeholder(e) {
|
|
428
|
+
this.#i.value = e, this.setAttribute("placeholder", e);
|
|
429
|
+
}
|
|
430
|
+
focus() {
|
|
431
|
+
this.#t?.focus();
|
|
432
|
+
}
|
|
433
|
+
attributeChangedCallback(e, t, n) {
|
|
434
|
+
if (t !== n) {
|
|
435
|
+
switch (e) {
|
|
436
|
+
case "value":
|
|
437
|
+
this.#t && this.#t.state.doc.toString() !== (n ?? "") && this.#t.dispatch({ changes: {
|
|
438
|
+
from: 0,
|
|
439
|
+
to: this.#t.state.doc.length,
|
|
440
|
+
insert: n ?? ""
|
|
441
|
+
} });
|
|
442
|
+
break;
|
|
443
|
+
case "placeholder":
|
|
444
|
+
this.#i.value = n ?? "";
|
|
445
|
+
break;
|
|
446
|
+
case "readonly":
|
|
447
|
+
this.#r.value = n !== null;
|
|
448
|
+
break;
|
|
449
|
+
case "disabled":
|
|
450
|
+
this.#n.value = n !== null;
|
|
451
|
+
break;
|
|
452
|
+
case "line-numbers":
|
|
453
|
+
this.#o.value = n !== "false";
|
|
454
|
+
break;
|
|
455
|
+
case "line-wrapping":
|
|
456
|
+
this.#s.value = n !== null;
|
|
457
|
+
break;
|
|
458
|
+
case "tab-size":
|
|
459
|
+
this.#a.value = n === null ? 2 : parseInt(n, 10) || 2;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
super.attributeChangedCallback(e, t, n);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
setup() {
|
|
466
|
+
super.setup(), this.#n.value = this.hasAttribute("disabled"), this.#r.value = this.hasAttribute("readonly"), this.#i.value = this.getAttribute("placeholder") ?? "", this.#o.value = this.getAttribute("line-numbers") !== "false", this.#s.value = this.hasAttribute("line-wrapping");
|
|
467
|
+
let t = this.getAttribute("tab-size");
|
|
468
|
+
t && (this.#a.value = parseInt(t, 10) || 2);
|
|
469
|
+
let n = this.#g();
|
|
470
|
+
this.#h = n, this.#_(n), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.addEffect(T(this, this.#n, this.#e, { manageTabindex: !0 })), this.addEffect(() => {
|
|
471
|
+
let t = this.#r.value || this.#n.value;
|
|
472
|
+
this.#t && this.#t.dispatch({ effects: this.#l.reconfigure([C.readOnly.of(t), e.editable.of(!t)]) });
|
|
473
|
+
}), this.addEffect(() => {
|
|
474
|
+
let e = this.#i.value;
|
|
475
|
+
this.#t && this.#t.dispatch({ effects: this.#u.reconfigure(e ? s(e) : []) });
|
|
476
|
+
}), this.addEffect(() => {
|
|
477
|
+
let e = this.#c.value;
|
|
478
|
+
this.#t && this.#t.dispatch({ effects: this.#d.reconfigure(e) });
|
|
479
|
+
}), this.addEffect(() => {
|
|
480
|
+
let e = this.#o.value;
|
|
481
|
+
this.#t && this.#t.dispatch({ effects: this.#f.reconfigure(e ? [
|
|
482
|
+
o(),
|
|
483
|
+
u(),
|
|
484
|
+
r()
|
|
485
|
+
] : []) });
|
|
486
|
+
}), this.addEffect(() => {
|
|
487
|
+
let t = this.#s.value;
|
|
488
|
+
this.#t && this.#t.dispatch({ effects: this.#p.reconfigure(t ? e.lineWrapping : []) });
|
|
489
|
+
}), this.addEffect(() => {
|
|
490
|
+
let e = this.#a.value;
|
|
491
|
+
this.#t && this.#t.dispatch({ effects: this.#m.reconfigure(C.tabSize.of(e)) });
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
teardown() {
|
|
495
|
+
this.#t?.destroy(), this.#t = null, super.teardown();
|
|
496
|
+
}
|
|
497
|
+
#g() {
|
|
498
|
+
let e = this.querySelector("script[type=\"text/plain\"]");
|
|
499
|
+
if (e) {
|
|
500
|
+
let t = e.textContent ?? "";
|
|
501
|
+
return e.remove(), t.replace(/^\n/, "");
|
|
502
|
+
}
|
|
503
|
+
return this.getAttribute("value") ?? "";
|
|
504
|
+
}
|
|
505
|
+
#_(c) {
|
|
506
|
+
let p = this.#r.value || this.#n.value, m = this.#i.value, S = this.#o.value, w = this.#s.value, T = this.#a.value, E = [
|
|
507
|
+
W,
|
|
508
|
+
K,
|
|
509
|
+
i(),
|
|
510
|
+
t(),
|
|
511
|
+
f(),
|
|
512
|
+
g(),
|
|
513
|
+
l(),
|
|
514
|
+
y(),
|
|
515
|
+
v(),
|
|
516
|
+
n(),
|
|
517
|
+
a.of([
|
|
518
|
+
...b,
|
|
519
|
+
...h,
|
|
520
|
+
..._,
|
|
521
|
+
...d,
|
|
522
|
+
...x
|
|
523
|
+
]),
|
|
524
|
+
this.#l.of([C.readOnly.of(p), e.editable.of(!p)]),
|
|
525
|
+
this.#u.of(m ? s(m) : []),
|
|
526
|
+
this.#d.of(this.#c.value),
|
|
527
|
+
this.#f.of(S ? [
|
|
528
|
+
o(),
|
|
529
|
+
u(),
|
|
530
|
+
r()
|
|
531
|
+
] : []),
|
|
532
|
+
this.#p.of(w ? e.lineWrapping : []),
|
|
533
|
+
this.#m.of(C.tabSize.of(T)),
|
|
534
|
+
e.updateListener.of((e) => {
|
|
535
|
+
if (e.docChanged) {
|
|
536
|
+
let t = e.state.doc.toString();
|
|
537
|
+
this.dispatchEvent(new CustomEvent("native:input", {
|
|
538
|
+
bubbles: !0,
|
|
539
|
+
composed: !0,
|
|
540
|
+
detail: { value: t }
|
|
541
|
+
}));
|
|
542
|
+
}
|
|
543
|
+
if (e.focusChanged && !e.view.hasFocus) {
|
|
544
|
+
let t = e.state.doc.toString();
|
|
545
|
+
t !== this.#h && (this.#h = t, this.dispatchEvent(new CustomEvent("native:change", {
|
|
546
|
+
bubbles: !0,
|
|
547
|
+
composed: !0,
|
|
548
|
+
detail: { value: t }
|
|
549
|
+
})));
|
|
550
|
+
}
|
|
551
|
+
})
|
|
552
|
+
];
|
|
553
|
+
this.#t = new e({
|
|
554
|
+
state: C.create({
|
|
555
|
+
doc: c,
|
|
556
|
+
extensions: E
|
|
557
|
+
}),
|
|
558
|
+
parent: this,
|
|
559
|
+
root: this.ownerDocument
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
export { W as i, G as n, K as r, q as t };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <native-codemirror> Custom Element
|
|
3
|
+
*
|
|
4
|
+
* Declarative wrapper around CodeMirror 6 for the NativeUI ecosystem.
|
|
5
|
+
* Provides reactive attribute-driven config, event dispatch, and
|
|
6
|
+
* lifecycle management around a themed EditorView.
|
|
7
|
+
*
|
|
8
|
+
* @attr {string} value - Document content
|
|
9
|
+
* @attr {string} placeholder - Placeholder text for empty editor
|
|
10
|
+
* @attr {boolean} readonly - Disable editing (still selectable)
|
|
11
|
+
* @attr {boolean} disabled - Full disabled state
|
|
12
|
+
* @attr {boolean} line-numbers - Show line numbers (default: true)
|
|
13
|
+
* @attr {boolean} line-wrapping - Enable soft line wrapping
|
|
14
|
+
* @attr {number} tab-size - Tab size (default: 2)
|
|
15
|
+
* @fires native:input - On every document change, detail: { value }
|
|
16
|
+
* @fires native:change - On blur (final commit), detail: { value }
|
|
17
|
+
*/
|
|
18
|
+
import type { Extension } from '@codemirror/state';
|
|
19
|
+
import { NativeElement } from '@nonoun/native-ui';
|
|
20
|
+
import { EditorView } from '@codemirror/view';
|
|
21
|
+
export declare class NCodemirror extends NativeElement {
|
|
22
|
+
#private;
|
|
23
|
+
static observedAttributes: string[];
|
|
24
|
+
constructor();
|
|
25
|
+
get value(): string;
|
|
26
|
+
set value(val: string);
|
|
27
|
+
get editorView(): EditorView | null;
|
|
28
|
+
/** Additional CodeMirror extensions (language modes, etc.). */
|
|
29
|
+
get extensions(): Extension[];
|
|
30
|
+
set extensions(val: Extension[]);
|
|
31
|
+
get readOnly(): boolean;
|
|
32
|
+
set readOnly(val: boolean);
|
|
33
|
+
get disabled(): boolean;
|
|
34
|
+
set disabled(val: boolean);
|
|
35
|
+
get placeholder(): string;
|
|
36
|
+
set placeholder(val: string);
|
|
37
|
+
focus(): void;
|
|
38
|
+
attributeChangedCallback(name: string, old: string | null, val: string | null): void;
|
|
39
|
+
setup(): void;
|
|
40
|
+
teardown(): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=codemirror-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemirror-element.d.ts","sourceRoot":"","sources":["../src/codemirror-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAgC,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EACL,UAAU,EAQX,MAAM,kBAAkB,CAAC;AAgB1B,qBAAa,WAAY,SAAQ,aAAa;;IAC5C,MAAM,CAAC,kBAAkB,WAGvB;;IAgCF,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM,EASpB;IAED,IAAI,UAAU,IAAI,UAAU,GAAG,IAAI,CAElC;IAED,+DAA+D;IAC/D,IAAI,UAAU,IAAI,SAAS,EAAE,CAE5B;IAED,IAAI,UAAU,CAAC,GAAG,EAAE,SAAS,EAAE,EAE9B;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAGxB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,CAAC,GAAG,EAAE,OAAO,EAGxB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,WAAW,CAAC,GAAG,EAAE,MAAM,EAG1B;IAEQ,KAAK,IAAI,IAAI;IAMtB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAqCpF,KAAK,IAAI,IAAI;IAmGb,QAAQ,IAAI,IAAI;CAiGjB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { NTheme, NHighlightStyle, NSyntaxHighlighting } from './theme.ts';
|
|
|
11
11
|
export { NBaseExtensions } from './base-extensions.ts';
|
|
12
12
|
export { createEditorView } from './factory.ts';
|
|
13
13
|
export type { CreateEditorOptions } from './factory.ts';
|
|
14
|
+
export { NCodemirror } from './codemirror-element.ts';
|
|
14
15
|
export { EditorView, keymap, Decoration, ViewPlugin, WidgetType, lineNumbers, highlightActiveLine, highlightActiveLineGutter, drawSelection, } from '@codemirror/view';
|
|
15
16
|
export type { DecorationSet, ViewUpdate } from '@codemirror/view';
|
|
16
17
|
export { EditorState, Compartment, StateField, StateEffect } from '@codemirror/state';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,EACL,UAAU,EACV,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtF,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAMzF,OAAO,EACL,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -7,20 +7,79 @@
|
|
|
7
7
|
* These styles handle structural concerns (scrolling, gutter borders,
|
|
8
8
|
* scrollbar appearance, border-radius) that complement the JS-driven
|
|
9
9
|
* EditorView.theme() in theme.ts.
|
|
10
|
+
*
|
|
11
|
+
* All colors flow through --n-code-* CSS custom properties defined here.
|
|
12
|
+
* When native-ui foundation CSS is loaded, tokens like --n-body, --n-ink
|
|
13
|
+
* provide automatic theme integration. Without it, hex fallbacks apply.
|
|
14
|
+
* Consumers can override any --n-code-* var directly on .cm-editor.
|
|
10
15
|
*/
|
|
11
16
|
|
|
12
17
|
@layer ui {
|
|
13
18
|
/* -----------------------------------------------------------------------
|
|
14
|
-
*
|
|
19
|
+
* Host element — <native-codemirror>
|
|
20
|
+
* --------------------------------------------------------------------- */
|
|
21
|
+
|
|
22
|
+
:where(native-codemirror) {
|
|
23
|
+
display: block;
|
|
24
|
+
position: relative;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
border-radius: var(--n-radius, 0.5rem);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:where(native-codemirror) :where(.cm-editor) {
|
|
30
|
+
height: 100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:where(native-codemirror)[aria-disabled="true"] {
|
|
34
|
+
opacity: 0.5;
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* -----------------------------------------------------------------------
|
|
39
|
+
* Editor root — color bridge vars
|
|
15
40
|
* --------------------------------------------------------------------- */
|
|
16
41
|
|
|
17
42
|
:where(.cm-editor) {
|
|
18
|
-
/*
|
|
19
|
-
--n-
|
|
20
|
-
--n-
|
|
21
|
-
--n-
|
|
43
|
+
/* Grounds */
|
|
44
|
+
--n-code-bg: var(--n-color-neutral-base, #282c34);
|
|
45
|
+
--n-code-bg-raised: var(--n-color-neutral-higher, #21252b);
|
|
46
|
+
--n-code-bg-deeper: var(--n-color-neutral-lower, #1e2127);
|
|
47
|
+
--n-code-bg-inline: var(--n-card, #333843);
|
|
48
|
+
|
|
49
|
+
/* Ink */
|
|
50
|
+
--n-code-text: var(--n-ink, #abb2bf);
|
|
51
|
+
--n-code-text-muted: var(--n-ink-muted, #7d8799);
|
|
52
|
+
|
|
53
|
+
/* Interactive */
|
|
54
|
+
--n-code-cursor: var(--n-surface-accent, #528bff);
|
|
55
|
+
--n-code-selection: var(--n-color-neutral-300, #3E4451);
|
|
56
|
+
--n-code-line-active: var(--n-color-neutral-200-scrim, #2c313a) !important;
|
|
57
|
+
--n-code-bracket: var(--n-color-neutral-600, #515a6b);
|
|
58
|
+
--n-code-accent: var(--n-surface-accent, #61afef);
|
|
59
|
+
|
|
60
|
+
/* Chrome */
|
|
61
|
+
--n-code-border: var(--n-border, #3E4451);
|
|
62
|
+
--n-code-button: var(--n-color-neutral-100-scrim, #3E4451);
|
|
63
|
+
--n-code-scrollbar: var(--n-color-neutral-200-scrim, #484c52);
|
|
64
|
+
--n-code-scrollbar-hover: var(--n-color-neutral-300-scrim, #5e6167);
|
|
65
|
+
--n-code-match: var(--n-color-accent-050-scrim, #314050);
|
|
66
|
+
--n-code-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
|
|
67
|
+
|
|
68
|
+
/* Search */
|
|
69
|
+
--n-code-search: rgba(229, 192, 123, 0.25);
|
|
70
|
+
--n-code-search-outline: rgba(229, 192, 123, 0.4);
|
|
71
|
+
--n-code-search-active: rgba(97, 175, 239, 0.3);
|
|
72
|
+
|
|
73
|
+
/* Syntax palette — curated for dark-on-dark contrast */
|
|
74
|
+
--n-code-keyword: #c678dd;
|
|
75
|
+
--n-code-string: #98c379;
|
|
76
|
+
--n-code-function: #61afef;
|
|
77
|
+
--n-code-variable: #e06c75;
|
|
78
|
+
--n-code-type: #e5c07b;
|
|
79
|
+
--n-code-operator: #56b6c2;
|
|
80
|
+
--n-code-number: #d19a66;
|
|
81
|
+
--n-code-invalid: #ffffff;
|
|
22
82
|
|
|
23
|
-
/*border-radius: var(--n-radius, 8px);*/
|
|
24
83
|
overflow: hidden;
|
|
25
84
|
font-variant-ligatures: contextual;
|
|
26
85
|
line-height: 1.6;
|
|
@@ -69,7 +128,7 @@
|
|
|
69
128
|
|
|
70
129
|
:where(.cm-scroller) {
|
|
71
130
|
scrollbar-width: thin;
|
|
72
|
-
scrollbar-color: var(--n-
|
|
131
|
+
scrollbar-color: var(--n-code-scrollbar) transparent;
|
|
73
132
|
}
|
|
74
133
|
|
|
75
134
|
:where(.cm-scroller)::-webkit-scrollbar {
|
|
@@ -82,12 +141,12 @@
|
|
|
82
141
|
}
|
|
83
142
|
|
|
84
143
|
:where(.cm-scroller)::-webkit-scrollbar-thumb {
|
|
85
|
-
background: var(--n-
|
|
144
|
+
background: var(--n-code-scrollbar);
|
|
86
145
|
border-radius: 4px;
|
|
87
146
|
}
|
|
88
147
|
|
|
89
148
|
:where(.cm-scroller)::-webkit-scrollbar-thumb:hover {
|
|
90
|
-
background: var(--n-
|
|
149
|
+
background: var(--n-code-scrollbar-hover);
|
|
91
150
|
}
|
|
92
151
|
|
|
93
152
|
:where(.cm-scroller)::-webkit-scrollbar-corner {
|
|
@@ -172,7 +231,7 @@
|
|
|
172
231
|
* --------------------------------------------------------------------- */
|
|
173
232
|
|
|
174
233
|
:where(.cm-selectionMatch) {
|
|
175
|
-
background-color: var(--n-
|
|
234
|
+
background-color: var(--n-code-match);
|
|
176
235
|
border-radius: 2px;
|
|
177
236
|
}
|
|
178
237
|
}
|
|
@@ -1,375 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./codemirror-element-DqgpO8qM.js";
|
|
2
|
+
import { Decoration as i, EditorView as a, EditorView as o, ViewPlugin as s, WidgetType as c, drawSelection as l, drawSelection as u, highlightActiveLine as d, highlightActiveLine as f, highlightActiveLineGutter as p, highlightActiveLineGutter as m, highlightSpecialChars as h, keymap as g, keymap as _, lineNumbers as v, lineNumbers as y } from "@codemirror/view";
|
|
3
|
+
import { HighlightStyle as b, bracketMatching as x, bracketMatching as S, foldGutter as C, foldGutter as w, foldKeymap as T, indentOnInput as E, indentOnInput as D, syntaxHighlighting as O, syntaxTree as k } from "@codemirror/language";
|
|
4
|
+
import { tags as A } from "@lezer/highlight";
|
|
5
|
+
import { defaultKeymap as j, defaultKeymap as M, history as N, history as P, historyKeymap as F, historyKeymap as I, redo as L, undo as R } from "@codemirror/commands";
|
|
6
|
+
import { autocompletion as z, autocompletion as B, closeBrackets as V, closeBrackets as H, closeBracketsKeymap as U, closeBracketsKeymap as W, completionKeymap as G, completionKeymap as K } from "@codemirror/autocomplete";
|
|
7
|
+
import { Compartment as q, EditorState as J, EditorState as Y, StateEffect as X, StateField as Z } from "@codemirror/state";
|
|
7
8
|
/**
|
|
8
|
-
* NativeUI CodeMirror
|
|
9
|
+
* Base extension set shared by all NativeUI CodeMirror instances.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Includes:
|
|
12
|
+
* - Default, history, close-brackets, fold, and completion keymaps
|
|
13
|
+
* - Undo/redo history
|
|
14
|
+
* - Bracket matching and auto-close
|
|
15
|
+
* - Autocompletion
|
|
16
|
+
* - Line numbers with fold gutter
|
|
17
|
+
* - Active line + gutter highlighting
|
|
18
|
+
* - Selection drawing and special character highlighting
|
|
19
|
+
* - Indent on input
|
|
13
20
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
padding: "4px 0"
|
|
25
|
-
},
|
|
26
|
-
"&.cm-focused .cm-cursor": {
|
|
27
|
-
borderLeftColor: V,
|
|
28
|
-
borderLeftWidth: "2px"
|
|
29
|
-
},
|
|
30
|
-
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { backgroundColor: H },
|
|
31
|
-
".cm-activeLine": { backgroundColor: "#2c313a" },
|
|
32
|
-
".cm-gutters": {
|
|
33
|
-
backgroundColor: R,
|
|
34
|
-
color: B,
|
|
35
|
-
borderRight: "none",
|
|
36
|
-
paddingRight: "4px"
|
|
37
|
-
},
|
|
38
|
-
".cm-activeLineGutter": {
|
|
39
|
-
backgroundColor: "#2c313a",
|
|
40
|
-
color: z
|
|
41
|
-
},
|
|
42
|
-
".cm-lineNumbers .cm-gutterElement": {
|
|
43
|
-
padding: "0 8px 0 16px",
|
|
44
|
-
minWidth: "40px"
|
|
45
|
-
},
|
|
46
|
-
".cm-foldGutter .cm-gutterElement": {
|
|
47
|
-
padding: "0 4px",
|
|
48
|
-
cursor: "pointer"
|
|
49
|
-
},
|
|
50
|
-
"&.cm-focused .cm-matchingBracket": {
|
|
51
|
-
backgroundColor: "#515a6b",
|
|
52
|
-
outline: "1px solid #515a6b"
|
|
53
|
-
},
|
|
54
|
-
"&.cm-focused .cm-nonmatchingBracket": { color: K },
|
|
55
|
-
".cm-searchMatch": {
|
|
56
|
-
backgroundColor: "rgba(229, 192, 123, 0.25)",
|
|
57
|
-
outline: "1px solid rgba(229, 192, 123, 0.4)"
|
|
58
|
-
},
|
|
59
|
-
".cm-searchMatch.cm-searchMatch-selected": { backgroundColor: "rgba(97, 175, 239, 0.3)" },
|
|
60
|
-
".cm-tooltip": {
|
|
61
|
-
backgroundColor: R,
|
|
62
|
-
color: z,
|
|
63
|
-
border: "1px solid #3E4451",
|
|
64
|
-
borderRadius: "6px",
|
|
65
|
-
boxShadow: "0 4px 16px rgba(0, 0, 0, 0.3)"
|
|
66
|
-
},
|
|
67
|
-
".cm-tooltip .cm-tooltip-arrow::before": {
|
|
68
|
-
borderTopColor: "#3E4451",
|
|
69
|
-
borderBottomColor: "#3E4451"
|
|
70
|
-
},
|
|
71
|
-
".cm-tooltip .cm-tooltip-arrow::after": {
|
|
72
|
-
borderTopColor: R,
|
|
73
|
-
borderBottomColor: R
|
|
74
|
-
},
|
|
75
|
-
".cm-tooltip-autocomplete": {
|
|
76
|
-
"& > ul": {
|
|
77
|
-
fontFamily: "inherit",
|
|
78
|
-
maxHeight: "240px"
|
|
79
|
-
},
|
|
80
|
-
"& > ul > li": { padding: "4px 8px" },
|
|
81
|
-
"& > ul > li[aria-selected]": {
|
|
82
|
-
backgroundColor: H,
|
|
83
|
-
color: z
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
".cm-panels": {
|
|
87
|
-
backgroundColor: R,
|
|
88
|
-
color: z
|
|
89
|
-
},
|
|
90
|
-
".cm-panels.cm-panels-top": { borderBottom: "1px solid #3E4451" },
|
|
91
|
-
".cm-panels.cm-panels-bottom": { borderTop: "1px solid #3E4451" },
|
|
92
|
-
".cm-panel input, .cm-panel button, .cm-panel select": { fontSize: "inherit" },
|
|
93
|
-
".cm-panel input": {
|
|
94
|
-
backgroundColor: L,
|
|
95
|
-
color: z,
|
|
96
|
-
border: "1px solid #3E4451",
|
|
97
|
-
borderRadius: "4px",
|
|
98
|
-
padding: "2px 6px"
|
|
99
|
-
},
|
|
100
|
-
".cm-panel button": {
|
|
101
|
-
backgroundColor: "#3E4451",
|
|
102
|
-
color: z,
|
|
103
|
-
border: "none",
|
|
104
|
-
borderRadius: "4px",
|
|
105
|
-
padding: "2px 8px",
|
|
106
|
-
cursor: "pointer"
|
|
107
|
-
},
|
|
108
|
-
".cm-fat-cursor .cm-cursor": {
|
|
109
|
-
display: "block",
|
|
110
|
-
backgroundColor: `${V}77`,
|
|
111
|
-
borderLeft: "none",
|
|
112
|
-
width: "0.5em"
|
|
113
|
-
},
|
|
114
|
-
".cm-selectionLayer .cm-selectionBackground": { backgroundColor: `${H}80` },
|
|
115
|
-
".cm-foldPlaceholder": {
|
|
116
|
-
backgroundColor: "transparent",
|
|
117
|
-
border: "none",
|
|
118
|
-
color: B
|
|
119
|
-
}
|
|
120
|
-
}, { dark: !0 }), Z = u.define([
|
|
121
|
-
{
|
|
122
|
-
tag: g.comment,
|
|
123
|
-
color: B,
|
|
124
|
-
fontStyle: "italic"
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
tag: g.lineComment,
|
|
128
|
-
color: B,
|
|
129
|
-
fontStyle: "italic"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
tag: g.blockComment,
|
|
133
|
-
color: B,
|
|
134
|
-
fontStyle: "italic"
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
tag: g.docComment,
|
|
138
|
-
color: B,
|
|
139
|
-
fontStyle: "italic"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
tag: g.keyword,
|
|
143
|
-
color: U
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
tag: g.controlKeyword,
|
|
147
|
-
color: U
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
tag: g.operatorKeyword,
|
|
151
|
-
color: U
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
tag: g.definitionKeyword,
|
|
155
|
-
color: U
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
tag: g.moduleKeyword,
|
|
159
|
-
color: U
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
tag: g.string,
|
|
163
|
-
color: W
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
tag: g.special(g.string),
|
|
167
|
-
color: W
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
tag: g.regexp,
|
|
171
|
-
color: W
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
tag: g.escape,
|
|
175
|
-
color: J
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
tag: g.character,
|
|
179
|
-
color: W
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
tag: g.function(g.definition(g.variableName)),
|
|
183
|
-
color: G
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
tag: g.function(g.variableName),
|
|
187
|
-
color: G
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
tag: g.variableName,
|
|
191
|
-
color: K
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
tag: g.definition(g.variableName),
|
|
195
|
-
color: K
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
tag: g.propertyName,
|
|
199
|
-
color: K
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
tag: g.definition(g.propertyName),
|
|
203
|
-
color: K
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
tag: g.typeName,
|
|
207
|
-
color: q
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
tag: g.className,
|
|
211
|
-
color: q
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
tag: g.namespace,
|
|
215
|
-
color: q
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
tag: g.macroName,
|
|
219
|
-
color: q
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
tag: g.annotation,
|
|
223
|
-
color: q
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
tag: g.number,
|
|
227
|
-
color: Y
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
tag: g.integer,
|
|
231
|
-
color: Y
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
tag: g.float,
|
|
235
|
-
color: Y
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
tag: g.bool,
|
|
239
|
-
color: Y
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
tag: g.null,
|
|
243
|
-
color: Y
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
tag: g.atom,
|
|
247
|
-
color: Y
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
tag: g.operator,
|
|
251
|
-
color: J
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
tag: g.punctuation,
|
|
255
|
-
color: z
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
tag: g.paren,
|
|
259
|
-
color: z
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
tag: g.squareBracket,
|
|
263
|
-
color: z
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
tag: g.brace,
|
|
267
|
-
color: z
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
tag: g.derefOperator,
|
|
271
|
-
color: z
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
tag: g.separator,
|
|
275
|
-
color: z
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
tag: g.url,
|
|
279
|
-
color: J,
|
|
280
|
-
textDecoration: "underline"
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
tag: g.link,
|
|
284
|
-
color: J
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
tag: g.labelName,
|
|
288
|
-
color: K
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
tag: g.tagName,
|
|
292
|
-
color: K
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
tag: g.attributeName,
|
|
296
|
-
color: Y
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
tag: g.attributeValue,
|
|
300
|
-
color: W
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
tag: g.angleBracket,
|
|
304
|
-
color: z
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
tag: g.self,
|
|
308
|
-
color: K
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
tag: g.processingInstruction,
|
|
312
|
-
color: B
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
tag: g.meta,
|
|
316
|
-
color: B
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
tag: g.heading,
|
|
320
|
-
color: K,
|
|
321
|
-
fontWeight: "bold"
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
tag: g.heading1,
|
|
325
|
-
color: K,
|
|
326
|
-
fontWeight: "bold"
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
tag: g.heading2,
|
|
330
|
-
color: K,
|
|
331
|
-
fontWeight: "bold"
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
tag: g.heading3,
|
|
335
|
-
color: K,
|
|
336
|
-
fontWeight: "bold"
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
tag: g.emphasis,
|
|
340
|
-
fontStyle: "italic"
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
tag: g.strong,
|
|
344
|
-
fontWeight: "bold"
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
tag: g.strikethrough,
|
|
348
|
-
textDecoration: "line-through"
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
tag: g.invalid,
|
|
352
|
-
color: "#ffffff",
|
|
353
|
-
backgroundColor: K
|
|
354
|
-
}
|
|
355
|
-
]), Q = de(Z), $ = [
|
|
356
|
-
ne(),
|
|
357
|
-
o(),
|
|
358
|
-
le(),
|
|
359
|
-
b(),
|
|
21
|
+
const Q = [
|
|
22
|
+
h(),
|
|
23
|
+
u(),
|
|
24
|
+
D(),
|
|
25
|
+
P(),
|
|
26
|
+
S(),
|
|
27
|
+
H(),
|
|
28
|
+
B(),
|
|
29
|
+
y(),
|
|
30
|
+
w(),
|
|
360
31
|
f(),
|
|
361
|
-
O(),
|
|
362
|
-
E(),
|
|
363
|
-
ae(),
|
|
364
32
|
m(),
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
...
|
|
369
|
-
...
|
|
370
|
-
...
|
|
371
|
-
...se,
|
|
372
|
-
...M
|
|
33
|
+
_.of([
|
|
34
|
+
...W,
|
|
35
|
+
...M,
|
|
36
|
+
...I,
|
|
37
|
+
...T,
|
|
38
|
+
...K
|
|
373
39
|
])
|
|
374
40
|
];
|
|
375
41
|
/**
|
|
@@ -399,20 +65,20 @@ const X = n.theme({
|
|
|
399
65
|
* });
|
|
400
66
|
* ```
|
|
401
67
|
*/
|
|
402
|
-
function
|
|
403
|
-
let { doc:
|
|
404
|
-
|
|
68
|
+
function $(t, r) {
|
|
69
|
+
let { doc: i = "", extensions: a = [], readonly: s = !1 } = r ?? {}, c = [
|
|
70
|
+
e,
|
|
71
|
+
n,
|
|
405
72
|
Q,
|
|
406
|
-
|
|
407
|
-
...i
|
|
73
|
+
...a
|
|
408
74
|
];
|
|
409
|
-
return
|
|
410
|
-
state:
|
|
411
|
-
doc:
|
|
412
|
-
extensions:
|
|
75
|
+
return s && c.push(Y.readOnly.of(!0), o.editable.of(!1)), new o({
|
|
76
|
+
state: Y.create({
|
|
77
|
+
doc: i,
|
|
78
|
+
extensions: c
|
|
413
79
|
}),
|
|
414
|
-
parent:
|
|
415
|
-
root:
|
|
80
|
+
parent: t,
|
|
81
|
+
root: t.ownerDocument
|
|
416
82
|
});
|
|
417
83
|
}
|
|
418
|
-
export {
|
|
84
|
+
export { q as Compartment, i as Decoration, J as EditorState, a as EditorView, b as HighlightStyle, Q as NBaseExtensions, r as NCodemirror, t as NHighlightStyle, n as NSyntaxHighlighting, e as NTheme, X as StateEffect, Z as StateField, s as ViewPlugin, c as WidgetType, z as autocompletion, x as bracketMatching, V as closeBrackets, U as closeBracketsKeymap, G as completionKeymap, $ as createEditorView, j as defaultKeymap, l as drawSelection, C as foldGutter, d as highlightActiveLine, p as highlightActiveLineGutter, N as history, F as historyKeymap, E as indentOnInput, g as keymap, v as lineNumbers, L as redo, O as syntaxHighlighting, k as syntaxTree, A as tags, R as undo };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":""}
|
package/dist/register.js
ADDED
package/dist/theme.d.ts
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* Dark theme inspired by one-dark, designed to harmonize with the
|
|
5
5
|
* @nonoun/native-ui OKLCH design system. Uses EditorView.theme()
|
|
6
6
|
* with { dark: true } and HighlightStyle.define() for syntax tokens.
|
|
7
|
+
*
|
|
8
|
+
* All colors flow through --n-code-* CSS custom properties (defined in
|
|
9
|
+
* codemirror.css). When native-ui foundation CSS is loaded, tokens like
|
|
10
|
+
* --n-body and --n-ink provide automatic theme integration. Without it,
|
|
11
|
+
* the one-dark hex fallbacks apply. Consumers can override any
|
|
12
|
+
* --n-code-* var directly on .cm-editor.
|
|
7
13
|
*/
|
|
8
14
|
import { HighlightStyle } from '@codemirror/language';
|
|
9
15
|
export declare const NTheme: import("@codemirror/state").Extension;
|
package/dist/theme.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,cAAc,EAAsB,MAAM,sBAAsB,CAAC;AAgC1E,eAAO,MAAM,MAAM,uCAqKlB,CAAC;AAMF,eAAO,MAAM,eAAe,gBAoF1B,CAAC;AAEH,eAAO,MAAM,mBAAmB,uCAAsC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nonoun/native-codemirror",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Shared CodeMirror 6 integration layer for @nonoun/native-ui ecosystem",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,11 +12,18 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"default": "./dist/native-codemirror.js"
|
|
14
14
|
},
|
|
15
|
+
"./register": {
|
|
16
|
+
"types": "./dist/register.d.ts",
|
|
17
|
+
"default": "./dist/register.js"
|
|
18
|
+
},
|
|
15
19
|
"./css": "./dist/native-codemirror.css"
|
|
16
20
|
},
|
|
17
21
|
"files": [
|
|
18
22
|
"dist"
|
|
19
23
|
],
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"./dist/register.js"
|
|
26
|
+
],
|
|
20
27
|
"peerDependencies": {
|
|
21
28
|
"@nonoun/native-ui": ">=0.5.0"
|
|
22
29
|
},
|