react-codemirror-editor 0.1.0
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/LICENSE +21 -0
- package/README.md +211 -0
- package/dist/core/diagnostics/index.d.ts +2 -0
- package/dist/core/diagnostics/index.d.ts.map +1 -0
- package/dist/core/diagnostics/index.js +1 -0
- package/dist/core/diagnostics/jsonDiagnostics.d.ts +4 -0
- package/dist/core/diagnostics/jsonDiagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics/jsonDiagnostics.js +78 -0
- package/dist/core/editor/createEditor.d.ts +4 -0
- package/dist/core/editor/createEditor.d.ts.map +1 -0
- package/dist/core/editor/createEditor.js +26 -0
- package/dist/core/editor/editorController.d.ts +3 -0
- package/dist/core/editor/editorController.d.ts.map +1 -0
- package/dist/core/editor/editorController.js +24 -0
- package/dist/core/editor/index.d.ts +3 -0
- package/dist/core/editor/index.d.ts.map +1 -0
- package/dist/core/editor/index.js +2 -0
- package/dist/core/extensions/copy.d.ts +3 -0
- package/dist/core/extensions/copy.d.ts.map +1 -0
- package/dist/core/extensions/copy.js +34 -0
- package/dist/core/extensions/fold.d.ts +4 -0
- package/dist/core/extensions/fold.d.ts.map +1 -0
- package/dist/core/extensions/fold.js +11 -0
- package/dist/core/extensions/format.d.ts +3 -0
- package/dist/core/extensions/format.d.ts.map +1 -0
- package/dist/core/extensions/format.js +25 -0
- package/dist/core/extensions/index.d.ts +5 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +4 -0
- package/dist/core/extensions/readOnly.d.ts +2 -0
- package/dist/core/extensions/readOnly.d.ts.map +1 -0
- package/dist/core/extensions/readOnly.js +4 -0
- package/dist/core/invariants/controlled.d.ts +3 -0
- package/dist/core/invariants/controlled.d.ts.map +1 -0
- package/dist/core/invariants/controlled.js +23 -0
- package/dist/core/invariants/index.d.ts +2 -0
- package/dist/core/invariants/index.d.ts.map +1 -0
- package/dist/core/invariants/index.js +1 -0
- package/dist/core/languages/buildExtensions.d.ts +4 -0
- package/dist/core/languages/buildExtensions.d.ts.map +1 -0
- package/dist/core/languages/buildExtensions.js +13 -0
- package/dist/core/languages/index.d.ts +3 -0
- package/dist/core/languages/index.d.ts.map +1 -0
- package/dist/core/languages/index.js +2 -0
- package/dist/core/languages/json.d.ts +3 -0
- package/dist/core/languages/json.d.ts.map +1 -0
- package/dist/core/languages/json.js +4 -0
- package/dist/core/themes/dark/barf.d.ts +9 -0
- package/dist/core/themes/dark/barf.d.ts.map +1 -0
- package/dist/core/themes/dark/barf.js +84 -0
- package/dist/core/themes/dark/base.d.ts +4 -0
- package/dist/core/themes/dark/base.d.ts.map +1 -0
- package/dist/core/themes/dark/base.js +34 -0
- package/dist/core/themes/dark/cobalt.d.ts +9 -0
- package/dist/core/themes/dark/cobalt.d.ts.map +1 -0
- package/dist/core/themes/dark/cobalt.js +91 -0
- package/dist/core/themes/dark/cool-glow.d.ts +9 -0
- package/dist/core/themes/dark/cool-glow.d.ts.map +1 -0
- package/dist/core/themes/dark/cool-glow.js +84 -0
- package/dist/core/themes/dark/dracula.d.ts +9 -0
- package/dist/core/themes/dark/dracula.d.ts.map +1 -0
- package/dist/core/themes/dark/dracula.js +66 -0
- package/dist/core/themes/dark/index.d.ts +3 -0
- package/dist/core/themes/dark/index.d.ts.map +1 -0
- package/dist/core/themes/dark/index.js +16 -0
- package/dist/core/themes/index.d.ts +4 -0
- package/dist/core/themes/index.d.ts.map +1 -0
- package/dist/core/themes/index.js +9 -0
- package/dist/core/themes/light/ayu.d.ts +9 -0
- package/dist/core/themes/light/ayu.d.ts.map +1 -0
- package/dist/core/themes/light/ayu.js +60 -0
- package/dist/core/themes/light/base.d.ts +4 -0
- package/dist/core/themes/light/base.d.ts.map +1 -0
- package/dist/core/themes/light/base.js +34 -0
- package/dist/core/themes/light/clouds.d.ts +9 -0
- package/dist/core/themes/light/clouds.d.ts.map +1 -0
- package/dist/core/themes/light/clouds.js +46 -0
- package/dist/core/themes/light/espresso.d.ts +9 -0
- package/dist/core/themes/light/espresso.d.ts.map +1 -0
- package/dist/core/themes/light/espresso.js +62 -0
- package/dist/core/themes/light/index.d.ts +3 -0
- package/dist/core/themes/light/index.d.ts.map +1 -0
- package/dist/core/themes/light/index.js +34 -0
- package/dist/core/themes/light/noctis-lilac.d.ts +9 -0
- package/dist/core/themes/light/noctis-lilac.d.ts.map +1 -0
- package/dist/core/themes/light/noctis-lilac.js +76 -0
- package/dist/core/themes/light/rose-pine-dawn.d.ts +9 -0
- package/dist/core/themes/light/rose-pine-dawn.d.ts.map +1 -0
- package/dist/core/themes/light/rose-pine-dawn.js +46 -0
- package/dist/core/themes/light/smoothy.d.ts +9 -0
- package/dist/core/themes/light/smoothy.d.ts.map +1 -0
- package/dist/core/themes/light/smoothy.js +67 -0
- package/dist/core/themes/light/tomorrow.d.ts +9 -0
- package/dist/core/themes/light/tomorrow.d.ts.map +1 -0
- package/dist/core/themes/light/tomorrow.js +63 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/types/editor.d.ts +64 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/editor.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/ui/CodeEditor.d.ts +3 -0
- package/dist/ui/CodeEditor.d.ts.map +1 -0
- package/dist/ui/CodeEditor.js +21 -0
- package/dist/ui/EditorContainer.d.ts +3 -0
- package/dist/ui/EditorContainer.d.ts.map +1 -0
- package/dist/ui/EditorContainer.js +41 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +2 -0
- package/package.json +53 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { EditorView } from '@codemirror/view';
|
|
7
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
8
|
+
import { tags } from '@lezer/highlight';
|
|
9
|
+
export const espressoLightTheme = EditorView.theme({
|
|
10
|
+
'&': {
|
|
11
|
+
backgroundColor: '#FFFFFF',
|
|
12
|
+
color: '#000000',
|
|
13
|
+
},
|
|
14
|
+
'.cm-content': {
|
|
15
|
+
caretColor: '#000000',
|
|
16
|
+
},
|
|
17
|
+
'.cm-cursor, .cm-dropCursor': {
|
|
18
|
+
borderLeftColor: '#000000',
|
|
19
|
+
},
|
|
20
|
+
'.cm-activeLine': {
|
|
21
|
+
backgroundColor: '#C1E2F8',
|
|
22
|
+
},
|
|
23
|
+
'.cm-selectionBackground, ::selection': {
|
|
24
|
+
backgroundColor: '#80C7FF',
|
|
25
|
+
},
|
|
26
|
+
'.cm-gutters': {
|
|
27
|
+
backgroundColor: '#FFFFFF',
|
|
28
|
+
color: '#00000070',
|
|
29
|
+
border: 'none',
|
|
30
|
+
},
|
|
31
|
+
}, { dark: false });
|
|
32
|
+
export const espressoLightHighlight = HighlightStyle.define([
|
|
33
|
+
{ tag: tags.comment, color: '#AAAAAA' },
|
|
34
|
+
{
|
|
35
|
+
tag: [
|
|
36
|
+
tags.keyword,
|
|
37
|
+
tags.operator,
|
|
38
|
+
tags.typeName,
|
|
39
|
+
tags.tagName,
|
|
40
|
+
tags.propertyName,
|
|
41
|
+
],
|
|
42
|
+
color: '#2F6F9F',
|
|
43
|
+
fontWeight: 'bold',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
tag: [tags.attributeName, tags.definition(tags.propertyName)],
|
|
47
|
+
color: '#4F9FD0',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
tag: [tags.className, tags.string, tags.special(tags.brace)],
|
|
51
|
+
color: '#CF4F5F',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
tag: tags.number,
|
|
55
|
+
color: '#CF4F5F',
|
|
56
|
+
fontWeight: 'bold',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
tag: tags.variableName,
|
|
60
|
+
fontWeight: 'bold',
|
|
61
|
+
},
|
|
62
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/themes/light/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAkBnD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAwBjD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { syntaxHighlighting } from '@codemirror/language';
|
|
2
|
+
import { lightTheme, lightHighlight } from './base';
|
|
3
|
+
import { ayuLightTheme, ayuLightHighlight } from './ayu';
|
|
4
|
+
import { cloudsLightTheme, cloudsLightHighlight } from './clouds';
|
|
5
|
+
import { espressoLightTheme, espressoLightHighlight } from './espresso';
|
|
6
|
+
import { noctisLilacLightTheme, noctisLilacLightHighlight, } from './noctis-lilac';
|
|
7
|
+
import { rosePineDawnLightTheme, rosePineDawnLightHighlight, } from './rose-pine-dawn';
|
|
8
|
+
import { smoothyLightTheme, smoothyLightHighlight } from './smoothy';
|
|
9
|
+
import { tomorrowLightTheme, tomorrowLightHighlight } from './tomorrow';
|
|
10
|
+
export const lightThemes = {
|
|
11
|
+
light: [lightTheme, syntaxHighlighting(lightHighlight)],
|
|
12
|
+
ayu_light: [ayuLightTheme, syntaxHighlighting(ayuLightHighlight)],
|
|
13
|
+
clouds_light: [cloudsLightTheme, syntaxHighlighting(cloudsLightHighlight)],
|
|
14
|
+
espresso_light: [
|
|
15
|
+
espressoLightTheme,
|
|
16
|
+
syntaxHighlighting(espressoLightHighlight),
|
|
17
|
+
],
|
|
18
|
+
noctis_lilac_light: [
|
|
19
|
+
noctisLilacLightTheme,
|
|
20
|
+
syntaxHighlighting(noctisLilacLightHighlight),
|
|
21
|
+
],
|
|
22
|
+
rose_pine_dawn_light: [
|
|
23
|
+
rosePineDawnLightTheme,
|
|
24
|
+
syntaxHighlighting(rosePineDawnLightHighlight),
|
|
25
|
+
],
|
|
26
|
+
smoothy_light: [
|
|
27
|
+
smoothyLightTheme,
|
|
28
|
+
syntaxHighlighting(smoothyLightHighlight),
|
|
29
|
+
],
|
|
30
|
+
tomorrow_light: [
|
|
31
|
+
tomorrowLightTheme,
|
|
32
|
+
syntaxHighlighting(tomorrowLightHighlight),
|
|
33
|
+
],
|
|
34
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
7
|
+
export declare const noctisLilacLightTheme: import("@codemirror/state").Extension;
|
|
8
|
+
export declare const noctisLilacLightHighlight: HighlightStyle;
|
|
9
|
+
//# sourceMappingURL=noctis-lilac.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noctis-lilac.d.ts","sourceRoot":"","sources":["../../../../src/core/themes/light/noctis-lilac.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,eAAO,MAAM,qBAAqB,uCAyBjC,CAAC;AAEF,eAAO,MAAM,yBAAyB,gBA4CpC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { EditorView } from '@codemirror/view';
|
|
7
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
8
|
+
import { tags } from '@lezer/highlight';
|
|
9
|
+
export const noctisLilacLightTheme = EditorView.theme({
|
|
10
|
+
'&': {
|
|
11
|
+
backgroundColor: '#f2f1f8',
|
|
12
|
+
color: '#0c006b',
|
|
13
|
+
},
|
|
14
|
+
'.cm-content': {
|
|
15
|
+
caretColor: '#5c49e9',
|
|
16
|
+
},
|
|
17
|
+
'.cm-cursor, .cm-dropCursor': {
|
|
18
|
+
borderLeftColor: '#5c49e9',
|
|
19
|
+
},
|
|
20
|
+
'.cm-activeLine': {
|
|
21
|
+
backgroundColor: '#e1def3',
|
|
22
|
+
},
|
|
23
|
+
'.cm-selectionBackground, ::selection': {
|
|
24
|
+
backgroundColor: '#d5d1f2',
|
|
25
|
+
},
|
|
26
|
+
'.cm-gutters': {
|
|
27
|
+
backgroundColor: '#f2f1f8',
|
|
28
|
+
color: '#0c006b70',
|
|
29
|
+
border: 'none',
|
|
30
|
+
},
|
|
31
|
+
}, { dark: false });
|
|
32
|
+
export const noctisLilacLightHighlight = HighlightStyle.define([
|
|
33
|
+
{ tag: tags.comment, color: '#9995b7' },
|
|
34
|
+
{
|
|
35
|
+
tag: tags.keyword,
|
|
36
|
+
color: '#ff5792',
|
|
37
|
+
fontWeight: 'bold',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
tag: [tags.definitionKeyword, tags.modifier],
|
|
41
|
+
color: '#ff5792',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
tag: [tags.className, tags.tagName, tags.definition(tags.typeName)],
|
|
45
|
+
color: '#0094f0',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
tag: [tags.number, tags.bool, tags.null, tags.special(tags.brace)],
|
|
49
|
+
color: '#5842ff',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
tag: [
|
|
53
|
+
tags.definition(tags.propertyName),
|
|
54
|
+
tags.function(tags.variableName),
|
|
55
|
+
],
|
|
56
|
+
color: '#0095a8',
|
|
57
|
+
},
|
|
58
|
+
{ tag: tags.typeName, color: '#b3694d' },
|
|
59
|
+
{
|
|
60
|
+
tag: [tags.propertyName, tags.variableName],
|
|
61
|
+
color: '#fa8900',
|
|
62
|
+
},
|
|
63
|
+
{ tag: tags.operator, color: '#ff5792' },
|
|
64
|
+
{ tag: tags.self, color: '#e64100' },
|
|
65
|
+
{
|
|
66
|
+
tag: [tags.string, tags.regexp],
|
|
67
|
+
color: '#00b368',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
tag: [tags.paren, tags.bracket],
|
|
71
|
+
color: '#0431fa',
|
|
72
|
+
},
|
|
73
|
+
{ tag: tags.labelName, color: '#00bdd6' },
|
|
74
|
+
{ tag: tags.attributeName, color: '#e64100' },
|
|
75
|
+
{ tag: tags.angleBracket, color: '#9995b7' },
|
|
76
|
+
]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
7
|
+
export declare const rosePineDawnLightTheme: import("@codemirror/state").Extension;
|
|
8
|
+
export declare const rosePineDawnLightHighlight: HighlightStyle;
|
|
9
|
+
//# sourceMappingURL=rose-pine-dawn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rose-pine-dawn.d.ts","sourceRoot":"","sources":["../../../../src/core/themes/light/rose-pine-dawn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,eAAO,MAAM,sBAAsB,uCAyBlC,CAAC;AAEF,eAAO,MAAM,0BAA0B,gBAcrC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { EditorView } from '@codemirror/view';
|
|
7
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
8
|
+
import { tags } from '@lezer/highlight';
|
|
9
|
+
export const rosePineDawnLightTheme = EditorView.theme({
|
|
10
|
+
'&': {
|
|
11
|
+
backgroundColor: '#faf4ed',
|
|
12
|
+
color: '#575279',
|
|
13
|
+
},
|
|
14
|
+
'.cm-content': {
|
|
15
|
+
caretColor: '#575279',
|
|
16
|
+
},
|
|
17
|
+
'.cm-cursor, .cm-dropCursor': {
|
|
18
|
+
borderLeftColor: '#575279',
|
|
19
|
+
},
|
|
20
|
+
'.cm-activeLine': {
|
|
21
|
+
backgroundColor: '#6e6a860d',
|
|
22
|
+
},
|
|
23
|
+
'.cm-selectionBackground, ::selection': {
|
|
24
|
+
backgroundColor: '#6e6a8614',
|
|
25
|
+
},
|
|
26
|
+
'.cm-gutters': {
|
|
27
|
+
backgroundColor: '#faf4ed',
|
|
28
|
+
color: '#57527970',
|
|
29
|
+
border: 'none',
|
|
30
|
+
},
|
|
31
|
+
}, { dark: false });
|
|
32
|
+
export const rosePineDawnLightHighlight = HighlightStyle.define([
|
|
33
|
+
{ tag: tags.comment, color: '#9893a5' },
|
|
34
|
+
{ tag: [tags.bool, tags.null], color: '#286983' },
|
|
35
|
+
{ tag: tags.number, color: '#d7827e' },
|
|
36
|
+
{ tag: tags.className, color: '#d7827e' },
|
|
37
|
+
{
|
|
38
|
+
tag: [tags.angleBracket, tags.tagName, tags.typeName],
|
|
39
|
+
color: '#56949f',
|
|
40
|
+
},
|
|
41
|
+
{ tag: tags.attributeName, color: '#907aa9' },
|
|
42
|
+
{ tag: tags.punctuation, color: '#797593' },
|
|
43
|
+
{ tag: [tags.keyword, tags.modifier], color: '#286983' },
|
|
44
|
+
{ tag: [tags.string, tags.regexp], color: '#ea9d34' },
|
|
45
|
+
{ tag: tags.variableName, color: '#d7827e' },
|
|
46
|
+
]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
7
|
+
export declare const smoothyLightTheme: import("@codemirror/state").Extension;
|
|
8
|
+
export declare const smoothyLightHighlight: HighlightStyle;
|
|
9
|
+
//# sourceMappingURL=smoothy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smoothy.d.ts","sourceRoot":"","sources":["../../../../src/core/themes/light/smoothy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,eAAO,MAAM,iBAAiB,uCAyB7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,gBAmChC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { EditorView } from '@codemirror/view';
|
|
7
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
8
|
+
import { tags } from '@lezer/highlight';
|
|
9
|
+
export const smoothyLightTheme = EditorView.theme({
|
|
10
|
+
'&': {
|
|
11
|
+
backgroundColor: '#FFFFFF',
|
|
12
|
+
color: '#000000',
|
|
13
|
+
},
|
|
14
|
+
'.cm-content': {
|
|
15
|
+
caretColor: '#000000',
|
|
16
|
+
},
|
|
17
|
+
'.cm-cursor, .cm-dropCursor': {
|
|
18
|
+
borderLeftColor: '#000000',
|
|
19
|
+
},
|
|
20
|
+
'.cm-activeLine': {
|
|
21
|
+
backgroundColor: '#00000008',
|
|
22
|
+
},
|
|
23
|
+
'.cm-selectionBackground, ::selection': {
|
|
24
|
+
backgroundColor: '#FFFD0054',
|
|
25
|
+
},
|
|
26
|
+
'.cm-gutters': {
|
|
27
|
+
backgroundColor: '#FFFFFF',
|
|
28
|
+
color: '#00000070',
|
|
29
|
+
border: 'none',
|
|
30
|
+
},
|
|
31
|
+
}, { dark: false });
|
|
32
|
+
export const smoothyLightHighlight = HighlightStyle.define([
|
|
33
|
+
{ tag: tags.comment, color: '#CFCFCF' },
|
|
34
|
+
{ tag: [tags.number, tags.bool, tags.null], color: '#E66C29' },
|
|
35
|
+
{
|
|
36
|
+
tag: [
|
|
37
|
+
tags.className,
|
|
38
|
+
tags.definition(tags.propertyName),
|
|
39
|
+
tags.function(tags.variableName),
|
|
40
|
+
tags.labelName,
|
|
41
|
+
tags.definition(tags.typeName),
|
|
42
|
+
],
|
|
43
|
+
color: '#2EB43B',
|
|
44
|
+
},
|
|
45
|
+
{ tag: tags.keyword, color: '#D8B229' },
|
|
46
|
+
{
|
|
47
|
+
tag: tags.operator,
|
|
48
|
+
color: '#4EA44E',
|
|
49
|
+
fontWeight: 'bold',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
tag: [tags.definitionKeyword, tags.modifier],
|
|
53
|
+
color: '#925A47',
|
|
54
|
+
},
|
|
55
|
+
{ tag: tags.string, color: '#704D3D' },
|
|
56
|
+
{ tag: tags.typeName, color: '#2F8996' },
|
|
57
|
+
{ tag: [tags.variableName, tags.propertyName], color: '#77ACB0' },
|
|
58
|
+
{
|
|
59
|
+
tag: tags.self,
|
|
60
|
+
color: '#77ACB0',
|
|
61
|
+
fontWeight: 'bold',
|
|
62
|
+
},
|
|
63
|
+
{ tag: tags.regexp, color: '#E3965E' },
|
|
64
|
+
{ tag: [tags.tagName, tags.angleBracket], color: '#BAA827' },
|
|
65
|
+
{ tag: tags.attributeName, color: '#B06520' },
|
|
66
|
+
{ tag: tags.derefOperator, color: '#000000' },
|
|
67
|
+
]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
7
|
+
export declare const tomorrowLightTheme: import("@codemirror/state").Extension;
|
|
8
|
+
export declare const tomorrowLightHighlight: HighlightStyle;
|
|
9
|
+
//# sourceMappingURL=tomorrow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tomorrow.d.ts","sourceRoot":"","sources":["../../../../src/core/themes/light/tomorrow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,eAAO,MAAM,kBAAkB,uCAyB9B,CAAC;AAEF,eAAO,MAAM,sBAAsB,gBA+BjC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme inspired by Thememirror
|
|
3
|
+
* https://github.com/vadimdemedes/thememirror
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { EditorView } from '@codemirror/view';
|
|
7
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
8
|
+
import { tags } from '@lezer/highlight';
|
|
9
|
+
export const tomorrowLightTheme = EditorView.theme({
|
|
10
|
+
'&': {
|
|
11
|
+
backgroundColor: '#FFFFFF',
|
|
12
|
+
color: '#4D4D4C',
|
|
13
|
+
},
|
|
14
|
+
'.cm-content': {
|
|
15
|
+
caretColor: '#AEAFAD',
|
|
16
|
+
},
|
|
17
|
+
'.cm-cursor, .cm-dropCursor': {
|
|
18
|
+
borderLeftColor: '#AEAFAD',
|
|
19
|
+
},
|
|
20
|
+
'.cm-activeLine': {
|
|
21
|
+
backgroundColor: '#EFEFEF',
|
|
22
|
+
},
|
|
23
|
+
'.cm-selectionBackground, ::selection': {
|
|
24
|
+
backgroundColor: '#D6D6D6',
|
|
25
|
+
},
|
|
26
|
+
'.cm-gutters': {
|
|
27
|
+
backgroundColor: '#FFFFFF',
|
|
28
|
+
color: '#4D4D4C80',
|
|
29
|
+
border: 'none',
|
|
30
|
+
},
|
|
31
|
+
}, { dark: false });
|
|
32
|
+
export const tomorrowLightHighlight = HighlightStyle.define([
|
|
33
|
+
{ tag: tags.comment, color: '#8E908C' },
|
|
34
|
+
{
|
|
35
|
+
tag: [
|
|
36
|
+
tags.variableName,
|
|
37
|
+
tags.self,
|
|
38
|
+
tags.propertyName,
|
|
39
|
+
tags.attributeName,
|
|
40
|
+
tags.regexp,
|
|
41
|
+
],
|
|
42
|
+
color: '#C82829',
|
|
43
|
+
},
|
|
44
|
+
{ tag: [tags.number, tags.bool, tags.null], color: '#F5871F' },
|
|
45
|
+
{
|
|
46
|
+
tag: [tags.className, tags.typeName, tags.definition(tags.typeName)],
|
|
47
|
+
color: '#C99E00',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
tag: [tags.string, tags.special(tags.brace)],
|
|
51
|
+
color: '#718C00',
|
|
52
|
+
},
|
|
53
|
+
{ tag: tags.operator, color: '#3E999F' },
|
|
54
|
+
{
|
|
55
|
+
tag: [
|
|
56
|
+
tags.definition(tags.propertyName),
|
|
57
|
+
tags.function(tags.variableName),
|
|
58
|
+
],
|
|
59
|
+
color: '#4271AE',
|
|
60
|
+
},
|
|
61
|
+
{ tag: tags.keyword, color: '#8959A8' },
|
|
62
|
+
{ tag: tags.derefOperator, color: '#4D4D4C' },
|
|
63
|
+
]);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CodeEditor } from './ui';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { EditorView } from 'codemirror';
|
|
2
|
+
export type ThemeName = 'light' | 'dark' | 'ayu_light' | 'clouds_light' | 'espresso_light' | 'noctis_lilac_light' | 'rose_pine_dawn_light' | 'smoothy_light' | 'tomorrow_light' | 'barf_dark' | 'cobalt_dark' | 'cool_glow_dark' | 'dracula_dark';
|
|
3
|
+
export type EditorLanguage = keyof LanguageOptions;
|
|
4
|
+
export interface LanguageOptions {
|
|
5
|
+
json?: JsonEditorConfig;
|
|
6
|
+
}
|
|
7
|
+
export interface EditorController {
|
|
8
|
+
getView(): EditorView | null;
|
|
9
|
+
setView(view: EditorView | null): void;
|
|
10
|
+
copy(): Promise<boolean | undefined>;
|
|
11
|
+
foldAll(): boolean;
|
|
12
|
+
unfoldAll(): boolean;
|
|
13
|
+
format(formatter: (code: string) => string): boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CreateEditorOptions {
|
|
16
|
+
parent: HTMLElement;
|
|
17
|
+
value: string;
|
|
18
|
+
theme?: ThemeName;
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
language: EditorLanguage;
|
|
21
|
+
languageOptions?: LanguageOptions;
|
|
22
|
+
onChange?: (value: string) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface EditorContainerProps {
|
|
25
|
+
value: string;
|
|
26
|
+
controller: EditorController;
|
|
27
|
+
theme?: ThemeName;
|
|
28
|
+
readOnly?: boolean;
|
|
29
|
+
language: EditorLanguage;
|
|
30
|
+
languageOptions?: LanguageOptions;
|
|
31
|
+
onChange?: (value: string) => void;
|
|
32
|
+
}
|
|
33
|
+
interface BaseCodeEditorProps {
|
|
34
|
+
theme?: ThemeName;
|
|
35
|
+
readOnly?: boolean;
|
|
36
|
+
language: EditorLanguage;
|
|
37
|
+
languageOptions?: LanguageOptions;
|
|
38
|
+
onReady?: (controller: EditorController) => void;
|
|
39
|
+
}
|
|
40
|
+
interface ControlledCodeEditorProps {
|
|
41
|
+
value: string;
|
|
42
|
+
onChange: (value: string) => void;
|
|
43
|
+
defaultValue?: never;
|
|
44
|
+
}
|
|
45
|
+
interface UncontrolledCodeEditorProps {
|
|
46
|
+
defaultValue: string;
|
|
47
|
+
value?: never;
|
|
48
|
+
onChange?: never;
|
|
49
|
+
}
|
|
50
|
+
export type CodeEditorProps = (BaseCodeEditorProps & ControlledCodeEditorProps) | (BaseCodeEditorProps & UncontrolledCodeEditorProps);
|
|
51
|
+
export interface ResolvedControlledInvariant {
|
|
52
|
+
mode: 'controlled' | 'uncontrolled';
|
|
53
|
+
value: string;
|
|
54
|
+
}
|
|
55
|
+
export interface JsonEditorConfig {
|
|
56
|
+
diagnostics?: boolean;
|
|
57
|
+
gutter?: boolean;
|
|
58
|
+
schema?: Record<string, any>;
|
|
59
|
+
schemaLint?: boolean;
|
|
60
|
+
hover?: boolean;
|
|
61
|
+
autocomplete?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/types/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,SAAS,GACf,OAAO,GACP,MAAM,GACN,WAAW,GACX,cAAc,GACd,gBAAgB,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,eAAe,GACf,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,gBAAgB,GAChB,cAAc,CAAC;AAErB,MAAM,MAAM,cAAc,GAAG,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC5B,IAAI,CAAC,EAAE,gBAAgB,CAAC;CAQ3B;AAED,MAAM,WAAW,gBAAgB;IAC7B,OAAO,IAAI,UAAU,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;IACvC,IAAI,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IACrC,OAAO,IAAI,OAAO,CAAC;IACnB,SAAS,IAAI,OAAO,CAAC;IACrB,MAAM,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC;CACxD;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,oBAAoB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,gBAAgB,CAAC;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,UAAU,mBAAmB;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACpD;AAED,UAAU,yBAAyB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,KAAK,CAAC;CACxB;AAED,UAAU,2BAA2B;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,MAAM,MAAM,eAAe,GACrB,CAAC,mBAAmB,GAAG,yBAAyB,CAAC,GACjD,CAAC,mBAAmB,GAAG,2BAA2B,CAAC,CAAC;AAE1D,MAAM,WAAW,2BAA2B;IACxC,IAAI,EAAE,YAAY,GAAG,cAAc,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../src/ui/CodeEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAkChD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
3
|
+
import { createEditorController } from '../core/editor';
|
|
4
|
+
import { resolveControlledInvariant } from '../core/invariants';
|
|
5
|
+
import { EditorContainer } from './';
|
|
6
|
+
export const CodeEditor = (props) => {
|
|
7
|
+
const { theme, readOnly, language, languageOptions, onChange, onReady } = props;
|
|
8
|
+
const { mode, value: resolvedContent } = resolveControlledInvariant(props);
|
|
9
|
+
const [internalContent, setInternalContent] = useState(resolvedContent);
|
|
10
|
+
const controller = useMemo(() => createEditorController(), []);
|
|
11
|
+
const handleEditorChange = (value) => {
|
|
12
|
+
if (mode === 'uncontrolled') {
|
|
13
|
+
setInternalContent(value);
|
|
14
|
+
}
|
|
15
|
+
onChange?.(value);
|
|
16
|
+
};
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
onReady?.(controller);
|
|
19
|
+
}, [controller, onReady]);
|
|
20
|
+
return (_jsx(EditorContainer, { value: mode === 'controlled' ? resolvedContent : internalContent, theme: theme, readOnly: readOnly, language: language, languageOptions: languageOptions, onChange: handleEditorChange, controller: controller }));
|
|
21
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EditorContainerProps } from '../types';
|
|
2
|
+
export declare const EditorContainer: ({ value, theme, readOnly, language, languageOptions, controller, onChange, }: EditorContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=EditorContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../src/ui/EditorContainer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,eAAO,MAAM,eAAe,iFAQzB,oBAAoB,4CA0CtB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { createEditor } from '../core/editor';
|
|
4
|
+
export const EditorContainer = ({ value, theme, readOnly, language, languageOptions, controller, onChange, }) => {
|
|
5
|
+
const editorRef = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const editor = editorRef.current;
|
|
8
|
+
if (!editor)
|
|
9
|
+
return;
|
|
10
|
+
const view = createEditor({
|
|
11
|
+
value,
|
|
12
|
+
parent: editor,
|
|
13
|
+
theme,
|
|
14
|
+
readOnly,
|
|
15
|
+
language,
|
|
16
|
+
languageOptions,
|
|
17
|
+
onChange,
|
|
18
|
+
});
|
|
19
|
+
controller.setView(view);
|
|
20
|
+
return () => {
|
|
21
|
+
controller.setView(null);
|
|
22
|
+
view.destroy();
|
|
23
|
+
};
|
|
24
|
+
}, [theme, readOnly, language, languageOptions]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const view = controller.getView();
|
|
27
|
+
if (!view)
|
|
28
|
+
return;
|
|
29
|
+
const currentValue = view.state.doc.toString();
|
|
30
|
+
if (value !== currentValue) {
|
|
31
|
+
view.dispatch({
|
|
32
|
+
changes: {
|
|
33
|
+
from: 0,
|
|
34
|
+
to: currentValue.length,
|
|
35
|
+
insert: value,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, [value]);
|
|
40
|
+
return _jsx("div", { className: "cm-editor-container", ref: editorRef });
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/ui/index.js
ADDED