@pyreon/code 0.11.5 → 0.11.6
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 +18 -18
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +4 -4
- package/package.json +28 -28
- package/src/components/code-editor.tsx +4 -4
- package/src/components/diff-editor.tsx +17 -17
- package/src/components/tabbed-editor.tsx +8 -8
- package/src/editor.ts +38 -38
- package/src/index.ts +8 -8
- package/src/languages.ts +19 -19
- package/src/minimap.ts +16 -16
- package/src/tabbed-editor.ts +11 -11
- package/src/tests/code.test.ts +193 -193
- package/src/themes.ts +48 -48
- package/src/types.ts +27 -27
package/src/themes.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { Extension } from
|
|
2
|
-
import { EditorView } from
|
|
3
|
-
import type { EditorTheme } from
|
|
1
|
+
import type { Extension } from '@codemirror/state'
|
|
2
|
+
import { EditorView } from '@codemirror/view'
|
|
3
|
+
import type { EditorTheme } from './types'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Light theme — clean, minimal.
|
|
7
7
|
*/
|
|
8
8
|
export const lightTheme: Extension = EditorView.theme({
|
|
9
|
-
|
|
10
|
-
backgroundColor:
|
|
11
|
-
color:
|
|
9
|
+
'&': {
|
|
10
|
+
backgroundColor: '#ffffff',
|
|
11
|
+
color: '#1e293b',
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
caretColor:
|
|
13
|
+
'.cm-content': {
|
|
14
|
+
caretColor: '#1e293b',
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
borderLeftColor:
|
|
16
|
+
'.cm-cursor': {
|
|
17
|
+
borderLeftColor: '#1e293b',
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
backgroundColor:
|
|
19
|
+
'&.cm-focused .cm-selectionBackground, .cm-selectionBackground': {
|
|
20
|
+
backgroundColor: '#dbeafe',
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
backgroundColor:
|
|
24
|
-
color:
|
|
25
|
-
borderRight:
|
|
22
|
+
'.cm-gutters': {
|
|
23
|
+
backgroundColor: '#f8fafc',
|
|
24
|
+
color: '#94a3b8',
|
|
25
|
+
borderRight: '1px solid #e2e8f0',
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
backgroundColor:
|
|
29
|
-
color:
|
|
27
|
+
'.cm-activeLineGutter': {
|
|
28
|
+
backgroundColor: '#f1f5f9',
|
|
29
|
+
color: '#475569',
|
|
30
30
|
},
|
|
31
|
-
|
|
32
|
-
backgroundColor:
|
|
31
|
+
'.cm-activeLine': {
|
|
32
|
+
backgroundColor: '#f8fafc',
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
color:
|
|
34
|
+
'.cm-foldGutter': {
|
|
35
|
+
color: '#94a3b8',
|
|
36
36
|
},
|
|
37
37
|
})
|
|
38
38
|
|
|
@@ -41,37 +41,37 @@ export const lightTheme: Extension = EditorView.theme({
|
|
|
41
41
|
*/
|
|
42
42
|
export const darkTheme: Extension = EditorView.theme(
|
|
43
43
|
{
|
|
44
|
-
|
|
45
|
-
backgroundColor:
|
|
46
|
-
color:
|
|
44
|
+
'&': {
|
|
45
|
+
backgroundColor: '#1e1e2e',
|
|
46
|
+
color: '#cdd6f4',
|
|
47
47
|
},
|
|
48
|
-
|
|
49
|
-
caretColor:
|
|
48
|
+
'.cm-content': {
|
|
49
|
+
caretColor: '#f5e0dc',
|
|
50
50
|
},
|
|
51
|
-
|
|
52
|
-
borderLeftColor:
|
|
51
|
+
'.cm-cursor': {
|
|
52
|
+
borderLeftColor: '#f5e0dc',
|
|
53
53
|
},
|
|
54
|
-
|
|
55
|
-
backgroundColor:
|
|
54
|
+
'&.cm-focused .cm-selectionBackground, .cm-selectionBackground': {
|
|
55
|
+
backgroundColor: '#45475a',
|
|
56
56
|
},
|
|
57
|
-
|
|
58
|
-
backgroundColor:
|
|
59
|
-
color:
|
|
60
|
-
borderRight:
|
|
57
|
+
'.cm-gutters': {
|
|
58
|
+
backgroundColor: '#181825',
|
|
59
|
+
color: '#585b70',
|
|
60
|
+
borderRight: '1px solid #313244',
|
|
61
61
|
},
|
|
62
|
-
|
|
63
|
-
backgroundColor:
|
|
64
|
-
color:
|
|
62
|
+
'.cm-activeLineGutter': {
|
|
63
|
+
backgroundColor: '#1e1e2e',
|
|
64
|
+
color: '#a6adc8',
|
|
65
65
|
},
|
|
66
|
-
|
|
67
|
-
backgroundColor:
|
|
66
|
+
'.cm-activeLine': {
|
|
67
|
+
backgroundColor: '#1e1e2e80',
|
|
68
68
|
},
|
|
69
|
-
|
|
70
|
-
color:
|
|
69
|
+
'.cm-foldGutter': {
|
|
70
|
+
color: '#585b70',
|
|
71
71
|
},
|
|
72
|
-
|
|
73
|
-
backgroundColor:
|
|
74
|
-
color:
|
|
72
|
+
'.cm-matchingBracket': {
|
|
73
|
+
backgroundColor: '#45475a',
|
|
74
|
+
color: '#f5e0dc',
|
|
75
75
|
},
|
|
76
76
|
},
|
|
77
77
|
{ dark: true },
|
|
@@ -81,7 +81,7 @@ export const darkTheme: Extension = EditorView.theme(
|
|
|
81
81
|
* Resolve a theme value to a CodeMirror extension.
|
|
82
82
|
*/
|
|
83
83
|
export function resolveTheme(theme: EditorTheme): Extension {
|
|
84
|
-
if (theme ===
|
|
85
|
-
if (theme ===
|
|
84
|
+
if (theme === 'light') return lightTheme
|
|
85
|
+
if (theme === 'dark') return darkTheme
|
|
86
86
|
return theme // custom Extension
|
|
87
87
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import type { Extension } from
|
|
2
|
-
import type { EditorView } from
|
|
3
|
-
import type { Computed, Signal } from
|
|
1
|
+
import type { Extension } from '@codemirror/state'
|
|
2
|
+
import type { EditorView } from '@codemirror/view'
|
|
3
|
+
import type { Computed, Signal } from '@pyreon/reactivity'
|
|
4
4
|
|
|
5
5
|
// ─── Editor config ───────────────────────────────────────────────────────────
|
|
6
6
|
|
|
7
7
|
export type EditorLanguage =
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
29
|
-
export type EditorTheme =
|
|
8
|
+
| 'javascript'
|
|
9
|
+
| 'typescript'
|
|
10
|
+
| 'jsx'
|
|
11
|
+
| 'tsx'
|
|
12
|
+
| 'html'
|
|
13
|
+
| 'css'
|
|
14
|
+
| 'json'
|
|
15
|
+
| 'markdown'
|
|
16
|
+
| 'python'
|
|
17
|
+
| 'rust'
|
|
18
|
+
| 'sql'
|
|
19
|
+
| 'xml'
|
|
20
|
+
| 'yaml'
|
|
21
|
+
| 'cpp'
|
|
22
|
+
| 'java'
|
|
23
|
+
| 'go'
|
|
24
|
+
| 'php'
|
|
25
|
+
| 'ruby'
|
|
26
|
+
| 'shell'
|
|
27
|
+
| 'plain'
|
|
28
|
+
|
|
29
|
+
export type EditorTheme = 'light' | 'dark' | Extension
|
|
30
30
|
|
|
31
31
|
export interface EditorConfig {
|
|
32
32
|
/** Initial value */
|
|
@@ -146,7 +146,7 @@ export interface Diagnostic {
|
|
|
146
146
|
/** End position (character offset) */
|
|
147
147
|
to: number
|
|
148
148
|
/** Severity */
|
|
149
|
-
severity:
|
|
149
|
+
severity: 'error' | 'warning' | 'info' | 'hint'
|
|
150
150
|
/** Message */
|
|
151
151
|
message: string
|
|
152
152
|
/** Optional source (e.g., "typescript", "eslint") */
|
|
@@ -212,7 +212,7 @@ export interface TabbedEditorConfig {
|
|
|
212
212
|
/** Theme — 'light', 'dark', or custom */
|
|
213
213
|
theme?: EditorTheme
|
|
214
214
|
/** Editor config applied to all tabs */
|
|
215
|
-
editorConfig?: Omit<EditorConfig,
|
|
215
|
+
editorConfig?: Omit<EditorConfig, 'value' | 'language' | 'theme'>
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
export interface TabbedEditorInstance {
|