@finos/legend-lego 0.1.12 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/{src/code-editor/CodeEditorConfig.ts → lib/application/ActivityBar.d.ts} +7 -16
- package/lib/application/ActivityBar.d.ts.map +1 -0
- package/lib/application/ActivityBar.js +19 -0
- package/lib/application/ActivityBar.js.map +1 -0
- package/lib/application/index.d.ts +1 -0
- package/lib/application/index.d.ts.map +1 -1
- package/lib/application/index.js +1 -0
- package/lib/application/index.js.map +1 -1
- package/lib/code-editor/CodeDiffView.d.ts +1 -1
- package/lib/code-editor/CodeDiffView.d.ts.map +1 -1
- package/lib/code-editor/CodeDiffView.js +4 -11
- package/lib/code-editor/CodeDiffView.js.map +1 -1
- package/lib/code-editor/CodeEditor.d.ts +5 -2
- package/lib/code-editor/CodeEditor.d.ts.map +1 -1
- package/lib/code-editor/CodeEditor.js +15 -17
- package/lib/code-editor/CodeEditor.js.map +1 -1
- package/lib/code-editor/CodeEditorTheme.d.ts +39 -0
- package/lib/code-editor/CodeEditorTheme.d.ts.map +1 -0
- package/lib/code-editor/CodeEditorTheme.js +72 -0
- package/lib/code-editor/CodeEditorTheme.js.map +1 -0
- package/lib/code-editor/CodeEditorUtils.d.ts +11 -0
- package/lib/code-editor/CodeEditorUtils.d.ts.map +1 -1
- package/lib/code-editor/CodeEditorUtils.js +23 -0
- package/lib/code-editor/CodeEditorUtils.js.map +1 -1
- package/lib/code-editor/PureLanguage.d.ts +38 -0
- package/lib/code-editor/PureLanguage.d.ts.map +1 -0
- package/lib/code-editor/PureLanguage.js +39 -0
- package/lib/code-editor/PureLanguage.js.map +1 -0
- package/lib/code-editor/PureLanguageService.d.ts +0 -22
- package/lib/code-editor/PureLanguageService.d.ts.map +1 -1
- package/lib/code-editor/PureLanguageService.js +3 -48
- package/lib/code-editor/PureLanguageService.js.map +1 -1
- package/lib/code-editor/index.d.ts +3 -2
- package/lib/code-editor/index.d.ts.map +1 -1
- package/lib/code-editor/index.js +3 -2
- package/lib/code-editor/index.js.map +1 -1
- package/lib/code-editor/themes/Github-Theme-dark-dimmed.json +613 -0
- package/lib/code-editor/themes/Github-Theme-dark.json +513 -0
- package/lib/code-editor/themes/Material-Theme-Darker.json +816 -0
- package/lib/code-editor/themes/Material-Theme-Default.json +816 -0
- package/lib/code-editor/themes/MonacoEditorThemeUtils.d.ts +31 -0
- package/lib/code-editor/themes/MonacoEditorThemeUtils.d.ts.map +1 -0
- package/lib/code-editor/themes/MonacoEditorThemeUtils.js +88 -0
- package/lib/code-editor/themes/MonacoEditorThemeUtils.js.map +1 -0
- package/lib/code-editor/themes/OneDark-Pro-darker.json +2061 -0
- package/lib/code-editor/themes/OneDark-Pro.json +2090 -0
- package/lib/code-editor/themes/solarized-dark-color-theme.json +398 -0
- package/lib/data-grid/DataGrid.d.ts.map +1 -1
- package/lib/data-grid/DataGrid.js +13 -1
- package/lib/data-grid/DataGrid.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/package.json +7 -7
- package/{lib/code-editor/CodeEditorConfig.d.ts → src/application/ActivityBar.tsx} +16 -15
- package/src/application/index.ts +1 -0
- package/src/code-editor/CodeDiffView.tsx +4 -12
- package/src/code-editor/CodeEditor.tsx +25 -22
- package/src/code-editor/CodeEditorTheme.ts +118 -0
- package/src/code-editor/CodeEditorUtils.ts +55 -0
- package/src/code-editor/PureLanguage.ts +42 -0
- package/src/code-editor/PureLanguageService.ts +3 -56
- package/src/code-editor/index.ts +3 -5
- package/src/code-editor/themes/Github-Theme-dark-dimmed.json +613 -0
- package/src/code-editor/themes/Github-Theme-dark.json +513 -0
- package/src/code-editor/themes/Material-Theme-Darker.json +816 -0
- package/src/code-editor/themes/Material-Theme-Default.json +816 -0
- package/src/code-editor/themes/MonacoEditorThemeUtils.ts +128 -0
- package/src/code-editor/themes/OneDark-Pro-darker.json +2061 -0
- package/src/code-editor/themes/OneDark-Pro.json +2090 -0
- package/src/code-editor/themes/README.md +8 -0
- package/src/code-editor/themes/solarized-dark-color-theme.json +423 -0
- package/src/data-grid/DataGrid.tsx +12 -1
- package/tsconfig.json +12 -2
- package/lib/code-editor/CodeEditorConfig.d.ts.map +0 -1
- package/lib/code-editor/CodeEditorConfig.js +0 -33
- package/lib/code-editor/CodeEditorConfig.js.map +0 -1
@@ -22,23 +22,23 @@ import {
|
|
22
22
|
resetLineNumberGutterWidth,
|
23
23
|
getCodeEditorValue,
|
24
24
|
normalizeLineEnding,
|
25
|
+
type CODE_EDITOR_LANGUAGE,
|
25
26
|
} from './CodeEditorUtils.js';
|
26
|
-
import { useResizeDetector } from '@finos/legend-art';
|
27
27
|
import {
|
28
28
|
DEFAULT_TAB_SIZE,
|
29
29
|
useApplicationStore,
|
30
30
|
} from '@finos/legend-application';
|
31
|
-
import {
|
32
|
-
|
33
|
-
type CODE_EDITOR_LANGUAGE,
|
34
|
-
} from './CodeEditorConfig.js';
|
31
|
+
import { CODE_EDITOR_THEME } from './CodeEditorTheme.js';
|
32
|
+
import { clsx } from '@finos/legend-art';
|
35
33
|
|
36
34
|
export const CodeEditor: React.FC<{
|
37
35
|
inputValue: string;
|
38
36
|
isReadOnly?: boolean | undefined;
|
37
|
+
lightTheme?: CODE_EDITOR_THEME;
|
39
38
|
language: CODE_EDITOR_LANGUAGE;
|
40
|
-
|
39
|
+
hideMinimap?: boolean | undefined;
|
41
40
|
hideGutter?: boolean | undefined;
|
41
|
+
hidePadding?: boolean | undefined;
|
42
42
|
extraEditorOptions?:
|
43
43
|
| (monacoEditorAPI.IEditorOptions & monacoEditorAPI.IGlobalEditorOptions)
|
44
44
|
| undefined;
|
@@ -47,10 +47,12 @@ export const CodeEditor: React.FC<{
|
|
47
47
|
const {
|
48
48
|
inputValue,
|
49
49
|
updateInput,
|
50
|
+
lightTheme,
|
50
51
|
language,
|
51
52
|
isReadOnly,
|
52
|
-
|
53
|
+
hideMinimap,
|
53
54
|
hideGutter,
|
55
|
+
hidePadding,
|
54
56
|
extraEditorOptions,
|
55
57
|
} = props;
|
56
58
|
const applicationStore = useApplicationStore();
|
@@ -71,13 +73,6 @@ export const CodeEditor: React.FC<{
|
|
71
73
|
*/
|
72
74
|
const value = normalizeLineEnding(inputValue);
|
73
75
|
const textInputRef = useRef<HTMLDivElement>(null);
|
74
|
-
const { ref, width, height } = useResizeDetector<HTMLDivElement>();
|
75
|
-
|
76
|
-
useEffect(() => {
|
77
|
-
if (width !== undefined && height !== undefined) {
|
78
|
-
editor?.layout({ width, height });
|
79
|
-
}
|
80
|
-
}, [editor, width, height]);
|
81
76
|
|
82
77
|
useEffect(() => {
|
83
78
|
if (!editor && textInputRef.current) {
|
@@ -86,14 +81,19 @@ export const CodeEditor: React.FC<{
|
|
86
81
|
...getBaseCodeEditorOptions(),
|
87
82
|
theme: applicationStore.layoutService
|
88
83
|
.TEMPORARY__isLightColorThemeEnabled
|
89
|
-
? CODE_EDITOR_THEME.
|
90
|
-
: CODE_EDITOR_THEME.
|
84
|
+
? lightTheme ?? CODE_EDITOR_THEME.BUILT_IN__VSCODE_LIGHT
|
85
|
+
: CODE_EDITOR_THEME.DEFAULT_DARK,
|
86
|
+
|
87
|
+
// layout
|
88
|
+
glyphMargin: !hidePadding,
|
89
|
+
padding: !hidePadding ? { top: 20, bottom: 20 } : { top: 0, bottom: 0 },
|
90
|
+
|
91
91
|
formatOnType: true,
|
92
92
|
formatOnPaste: true,
|
93
93
|
});
|
94
94
|
setEditor(_editor);
|
95
95
|
}
|
96
|
-
}, [applicationStore, editor]);
|
96
|
+
}, [applicationStore, lightTheme, hidePadding, editor]);
|
97
97
|
|
98
98
|
useEffect(() => {
|
99
99
|
if (editor) {
|
@@ -124,16 +124,15 @@ export const CodeEditor: React.FC<{
|
|
124
124
|
}
|
125
125
|
editor.updateOptions({
|
126
126
|
readOnly: Boolean(isReadOnly),
|
127
|
-
minimap: { enabled:
|
127
|
+
minimap: { enabled: !hideMinimap },
|
128
128
|
// Hide the line number gutter
|
129
129
|
// See https://github.com/microsoft/vscode/issues/30795
|
130
130
|
...(hideGutter
|
131
131
|
? {
|
132
|
-
glyphMargin:
|
132
|
+
glyphMargin: !hidePadding,
|
133
133
|
folding: false,
|
134
134
|
lineNumbers: 'off',
|
135
|
-
lineDecorationsWidth:
|
136
|
-
lineNumbersMinChars: 0,
|
135
|
+
lineDecorationsWidth: 0,
|
137
136
|
}
|
138
137
|
: {}),
|
139
138
|
...(extraEditorOptions ?? {}),
|
@@ -153,7 +152,11 @@ export const CodeEditor: React.FC<{
|
|
153
152
|
);
|
154
153
|
|
155
154
|
return (
|
156
|
-
<div
|
155
|
+
<div
|
156
|
+
className={clsx('code-editor__container', {
|
157
|
+
'code-editor__container--padding': !hidePadding,
|
158
|
+
})}
|
159
|
+
>
|
157
160
|
<div className="code-editor__body" ref={textInputRef} />
|
158
161
|
</div>
|
159
162
|
);
|
@@ -0,0 +1,118 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
import { PURE_GRAMMAR_TOKEN } from './PureLanguage.js';
|
18
|
+
import type { editor as monacoEditorAPI } from 'monaco-editor';
|
19
|
+
import { buildCodeEditorTheme } from './themes/MonacoEditorThemeUtils.js';
|
20
|
+
import SOLARIZED_DARK_THEME_DATA from './themes/solarized-dark-color-theme.json';
|
21
|
+
import GITHUB_DARK_THEME_DATA from './themes/Github-Theme-dark.json';
|
22
|
+
import GITHUB_DARK_DIMMED_THEME_DATA from './themes/Github-Theme-dark-dimmed.json';
|
23
|
+
import MATERIAL_DEFAULT_THEME_DATA from './themes/Material-Theme-Default.json';
|
24
|
+
import MATERIAL_DARKER_THEME_DATA from './themes/Material-Theme-Darker.json';
|
25
|
+
import ONE_DARK_PRO_THEME_DATA from './themes/OneDark-Pro.json';
|
26
|
+
import ONE_DARK_PRO_DARKER_THEME_DATA from './themes/OneDark-Pro-darker.json';
|
27
|
+
|
28
|
+
const BASE_PURE_LANGUAGE_COLOR_TOKENS: monacoEditorAPI.ITokenThemeRule[] = [
|
29
|
+
// NOTE: `monaco-editor` only accepts HEX values, not CSS variables
|
30
|
+
{ token: PURE_GRAMMAR_TOKEN.IDENTIFIER, foreground: 'dcdcaa' },
|
31
|
+
{ token: PURE_GRAMMAR_TOKEN.NUMBER, foreground: 'b5cea8' },
|
32
|
+
{ token: PURE_GRAMMAR_TOKEN.DATE, foreground: 'b5cea8' },
|
33
|
+
{ token: PURE_GRAMMAR_TOKEN.COLOR, foreground: 'b5cea8' },
|
34
|
+
{ token: PURE_GRAMMAR_TOKEN.PACKAGE, foreground: '808080' },
|
35
|
+
{ token: PURE_GRAMMAR_TOKEN.PARSER, foreground: 'c586c0' },
|
36
|
+
{ token: PURE_GRAMMAR_TOKEN.LANGUAGE_STRUCT, foreground: 'c586c0' },
|
37
|
+
{ token: PURE_GRAMMAR_TOKEN.MULTIPLICITY, foreground: '2d796b' },
|
38
|
+
{ token: PURE_GRAMMAR_TOKEN.GENERICS, foreground: '2d796b' },
|
39
|
+
{ token: PURE_GRAMMAR_TOKEN.PROPERTY, foreground: '9cdcfe' },
|
40
|
+
{ token: PURE_GRAMMAR_TOKEN.PARAMETER, foreground: '9cdcfe' },
|
41
|
+
{ token: PURE_GRAMMAR_TOKEN.VARIABLE, foreground: '4fc1ff' },
|
42
|
+
{ token: PURE_GRAMMAR_TOKEN.TYPE, foreground: '3dc9b0' },
|
43
|
+
{ token: `${PURE_GRAMMAR_TOKEN.STRING}.escape`, foreground: 'd7ba7d' },
|
44
|
+
];
|
45
|
+
|
46
|
+
export enum CODE_EDITOR_THEME {
|
47
|
+
DEFAULT_DARK = 'default-dark',
|
48
|
+
GITHUB_DARK = 'github-dark',
|
49
|
+
GITHUB_DARK_DIMMED = 'github-dark-dimmed',
|
50
|
+
SOLARIZED_DARK = 'solarized-dark',
|
51
|
+
ONE_DARK_PRO = 'one-dark-pro',
|
52
|
+
ONE_DARK_PRO_DARKER = 'one-dark-pro-darker',
|
53
|
+
MATERIAL_DEFAULT = 'material-default',
|
54
|
+
MATERIAL_DARKER = 'material-darker',
|
55
|
+
|
56
|
+
// default themes in Monaco editor
|
57
|
+
// See https://github.com/microsoft/vscode/blob/main/src/vs/editor/standalone/common/themes.ts
|
58
|
+
BUILT_IN__VSCODE_LIGHT = 'vs',
|
59
|
+
BUILT_IN__VSCODE_DARK = 'vs-dark',
|
60
|
+
BUILT_IN__VSCODE_HC_BLACK = 'hc-black',
|
61
|
+
BUILT_IN__VSCODE_HC_LIGHT = 'hc-light',
|
62
|
+
}
|
63
|
+
|
64
|
+
export const DEFAULT_DARK_THEME: monacoEditorAPI.IStandaloneThemeData = {
|
65
|
+
base: 'vs-dark',
|
66
|
+
inherit: true,
|
67
|
+
colors: {},
|
68
|
+
rules: BASE_PURE_LANGUAGE_COLOR_TOKENS,
|
69
|
+
};
|
70
|
+
|
71
|
+
export const SOLARIZED_DARK_THEME = buildCodeEditorTheme(
|
72
|
+
SOLARIZED_DARK_THEME_DATA,
|
73
|
+
CODE_EDITOR_THEME.BUILT_IN__VSCODE_DARK,
|
74
|
+
{},
|
75
|
+
[],
|
76
|
+
);
|
77
|
+
|
78
|
+
export const GITHUB_DARK_THEME = buildCodeEditorTheme(
|
79
|
+
GITHUB_DARK_THEME_DATA,
|
80
|
+
CODE_EDITOR_THEME.BUILT_IN__VSCODE_DARK,
|
81
|
+
{},
|
82
|
+
[],
|
83
|
+
);
|
84
|
+
|
85
|
+
export const GITHUB_DARK_DIMMED_THEME = buildCodeEditorTheme(
|
86
|
+
GITHUB_DARK_DIMMED_THEME_DATA,
|
87
|
+
CODE_EDITOR_THEME.BUILT_IN__VSCODE_DARK,
|
88
|
+
{},
|
89
|
+
[],
|
90
|
+
);
|
91
|
+
|
92
|
+
export const MATERIAL_DEFAULT_THEME = buildCodeEditorTheme(
|
93
|
+
MATERIAL_DEFAULT_THEME_DATA,
|
94
|
+
CODE_EDITOR_THEME.BUILT_IN__VSCODE_DARK,
|
95
|
+
{},
|
96
|
+
[],
|
97
|
+
);
|
98
|
+
|
99
|
+
export const MATERIAL_DARKER_THEME = buildCodeEditorTheme(
|
100
|
+
MATERIAL_DARKER_THEME_DATA,
|
101
|
+
CODE_EDITOR_THEME.BUILT_IN__VSCODE_DARK,
|
102
|
+
{},
|
103
|
+
[],
|
104
|
+
);
|
105
|
+
|
106
|
+
export const ONE_DARK_PRO_THEME = buildCodeEditorTheme(
|
107
|
+
ONE_DARK_PRO_THEME_DATA,
|
108
|
+
CODE_EDITOR_THEME.BUILT_IN__VSCODE_DARK,
|
109
|
+
{},
|
110
|
+
[],
|
111
|
+
);
|
112
|
+
|
113
|
+
export const ONE_DARK_PRO_DARKER_THEME = buildCodeEditorTheme(
|
114
|
+
ONE_DARK_PRO_DARKER_THEME_DATA,
|
115
|
+
CODE_EDITOR_THEME.BUILT_IN__VSCODE_DARK,
|
116
|
+
{},
|
117
|
+
[],
|
118
|
+
);
|
@@ -26,6 +26,17 @@ import {
|
|
26
26
|
KeyMod,
|
27
27
|
MarkerSeverity,
|
28
28
|
} from 'monaco-editor';
|
29
|
+
import {
|
30
|
+
CODE_EDITOR_THEME,
|
31
|
+
DEFAULT_DARK_THEME,
|
32
|
+
GITHUB_DARK_DIMMED_THEME,
|
33
|
+
GITHUB_DARK_THEME,
|
34
|
+
MATERIAL_DARKER_THEME,
|
35
|
+
MATERIAL_DEFAULT_THEME,
|
36
|
+
ONE_DARK_PRO_DARKER_THEME,
|
37
|
+
ONE_DARK_PRO_THEME,
|
38
|
+
SOLARIZED_DARK_THEME,
|
39
|
+
} from './CodeEditorTheme.js';
|
29
40
|
|
30
41
|
export type CodeEditorPosition = {
|
31
42
|
lineNumber: number;
|
@@ -93,6 +104,7 @@ export const getBaseCodeEditorOptions =
|
|
93
104
|
// The typing is currently not correct for `bracketPairColorization`, until this is fixed, we will remove the cast
|
94
105
|
// See https://github.com/microsoft/monaco-editor/issues/3013
|
95
106
|
'bracketPairColorization.enabled': false,
|
107
|
+
automaticLayout: true,
|
96
108
|
} as monacoEditorAPI.IStandaloneEditorConstructionOptions);
|
97
109
|
|
98
110
|
export const getBaseConsoleOptions =
|
@@ -273,4 +285,47 @@ export const configureCodeEditorComponent = async (
|
|
273
285
|
commandArgs: keyCombination,
|
274
286
|
})),
|
275
287
|
);
|
288
|
+
|
289
|
+
// themes
|
290
|
+
monacoEditorAPI.defineTheme(
|
291
|
+
CODE_EDITOR_THEME.DEFAULT_DARK,
|
292
|
+
DEFAULT_DARK_THEME,
|
293
|
+
);
|
294
|
+
monacoEditorAPI.defineTheme(
|
295
|
+
CODE_EDITOR_THEME.SOLARIZED_DARK,
|
296
|
+
SOLARIZED_DARK_THEME,
|
297
|
+
);
|
298
|
+
monacoEditorAPI.defineTheme(CODE_EDITOR_THEME.GITHUB_DARK, GITHUB_DARK_THEME);
|
299
|
+
monacoEditorAPI.defineTheme(
|
300
|
+
CODE_EDITOR_THEME.GITHUB_DARK_DIMMED,
|
301
|
+
GITHUB_DARK_DIMMED_THEME,
|
302
|
+
);
|
303
|
+
monacoEditorAPI.defineTheme(
|
304
|
+
CODE_EDITOR_THEME.MATERIAL_DEFAULT,
|
305
|
+
MATERIAL_DEFAULT_THEME,
|
306
|
+
);
|
307
|
+
monacoEditorAPI.defineTheme(
|
308
|
+
CODE_EDITOR_THEME.MATERIAL_DARKER,
|
309
|
+
MATERIAL_DARKER_THEME,
|
310
|
+
);
|
311
|
+
monacoEditorAPI.defineTheme(
|
312
|
+
CODE_EDITOR_THEME.ONE_DARK_PRO,
|
313
|
+
ONE_DARK_PRO_THEME,
|
314
|
+
);
|
315
|
+
monacoEditorAPI.defineTheme(
|
316
|
+
CODE_EDITOR_THEME.ONE_DARK_PRO_DARKER,
|
317
|
+
ONE_DARK_PRO_DARKER_THEME,
|
318
|
+
);
|
276
319
|
};
|
320
|
+
|
321
|
+
export enum CODE_EDITOR_LANGUAGE {
|
322
|
+
TEXT = 'plaintext',
|
323
|
+
PURE = 'pure',
|
324
|
+
JSON = 'json',
|
325
|
+
JAVA = 'java',
|
326
|
+
MARKDOWN = 'markdown',
|
327
|
+
SQL = 'sql',
|
328
|
+
XML = 'xml',
|
329
|
+
YAML = 'yaml',
|
330
|
+
GRAPHQL = 'graphql',
|
331
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
export enum PURE_GRAMMAR_TOKEN {
|
18
|
+
WHITESPACE = '',
|
19
|
+
|
20
|
+
KEYWORD = 'keyword',
|
21
|
+
IDENTIFIER = 'identifier',
|
22
|
+
OPERATOR = 'operator',
|
23
|
+
DELIMITER = 'delimiter',
|
24
|
+
|
25
|
+
PARSER = 'parser',
|
26
|
+
NUMBER = 'number',
|
27
|
+
DATE = 'date',
|
28
|
+
COLOR = 'color',
|
29
|
+
PACKAGE = 'package',
|
30
|
+
STRING = 'string',
|
31
|
+
COMMENT = 'comment',
|
32
|
+
|
33
|
+
LANGUAGE_STRUCT = 'language-struct',
|
34
|
+
MULTIPLICITY = 'multiplicity',
|
35
|
+
GENERICS = 'generics',
|
36
|
+
PROPERTY = 'property',
|
37
|
+
PARAMETER = 'property',
|
38
|
+
VARIABLE = 'variable',
|
39
|
+
TYPE = 'type',
|
40
|
+
|
41
|
+
INVALID = 'invalid',
|
42
|
+
}
|
@@ -21,67 +21,15 @@ import {
|
|
21
21
|
PURE_CONNECTION_NAME,
|
22
22
|
PURE_PARSER,
|
23
23
|
} from '@finos/legend-graph';
|
24
|
-
import {
|
25
|
-
|
26
|
-
|
27
|
-
} from 'monaco-editor';
|
28
|
-
import { CODE_EDITOR_LANGUAGE, CODE_EDITOR_THEME } from './CodeEditorConfig.js';
|
24
|
+
import { languages as monacoLanguagesAPI } from 'monaco-editor';
|
25
|
+
import { PURE_GRAMMAR_TOKEN } from './PureLanguage.js';
|
26
|
+
import { CODE_EDITOR_LANGUAGE } from './CodeEditorUtils.js';
|
29
27
|
|
30
28
|
/**
|
31
29
|
* The postfix to be added to all token types, i.e. identifier.pure, number.pure, etc.
|
32
30
|
*/
|
33
31
|
const PURE_GRAMMAR_TOKEN_POSTFIX = '.pure';
|
34
32
|
|
35
|
-
export enum PURE_GRAMMAR_TOKEN {
|
36
|
-
WHITESPACE = '',
|
37
|
-
|
38
|
-
KEYWORD = 'keyword',
|
39
|
-
IDENTIFIER = 'identifier',
|
40
|
-
OPERATOR = 'operator',
|
41
|
-
DELIMITER = 'delimiter',
|
42
|
-
|
43
|
-
PARSER = 'parser',
|
44
|
-
NUMBER = 'number',
|
45
|
-
DATE = 'date',
|
46
|
-
COLOR = 'color',
|
47
|
-
PACKAGE = 'package',
|
48
|
-
STRING = 'string',
|
49
|
-
COMMENT = 'comment',
|
50
|
-
|
51
|
-
LANGUAGE_STRUCT = 'language-struct',
|
52
|
-
MULTIPLICITY = 'multiplicity',
|
53
|
-
GENERICS = 'generics',
|
54
|
-
PROPERTY = 'property',
|
55
|
-
PARAMETER = 'property',
|
56
|
-
VARIABLE = 'variable',
|
57
|
-
TYPE = 'type',
|
58
|
-
|
59
|
-
INVALID = 'invalid',
|
60
|
-
}
|
61
|
-
|
62
|
-
const theme: monacoEditorAPI.IStandaloneThemeData = {
|
63
|
-
base: 'vs-dark', // can also be vs-dark or hc-black
|
64
|
-
inherit: true, // can also be false to completely replace the builtin rules
|
65
|
-
colors: {},
|
66
|
-
rules: [
|
67
|
-
// NOTE: unfortunately, `monaco-editor` only accepts HEX values, not CSS variables
|
68
|
-
{ token: PURE_GRAMMAR_TOKEN.IDENTIFIER, foreground: 'dcdcaa' },
|
69
|
-
{ token: PURE_GRAMMAR_TOKEN.NUMBER, foreground: 'b5cea8' },
|
70
|
-
{ token: PURE_GRAMMAR_TOKEN.DATE, foreground: 'b5cea8' },
|
71
|
-
{ token: PURE_GRAMMAR_TOKEN.COLOR, foreground: 'b5cea8' },
|
72
|
-
{ token: PURE_GRAMMAR_TOKEN.PACKAGE, foreground: '808080' },
|
73
|
-
{ token: PURE_GRAMMAR_TOKEN.PARSER, foreground: 'c586c0' },
|
74
|
-
{ token: PURE_GRAMMAR_TOKEN.LANGUAGE_STRUCT, foreground: 'c586c0' },
|
75
|
-
{ token: PURE_GRAMMAR_TOKEN.MULTIPLICITY, foreground: '2d796b' },
|
76
|
-
{ token: PURE_GRAMMAR_TOKEN.GENERICS, foreground: '2d796b' },
|
77
|
-
{ token: PURE_GRAMMAR_TOKEN.PROPERTY, foreground: '9cdcfe' },
|
78
|
-
{ token: PURE_GRAMMAR_TOKEN.PARAMETER, foreground: '9cdcfe' },
|
79
|
-
{ token: PURE_GRAMMAR_TOKEN.VARIABLE, foreground: '4fc1ff' },
|
80
|
-
{ token: PURE_GRAMMAR_TOKEN.TYPE, foreground: '3dc9b0' },
|
81
|
-
{ token: `${PURE_GRAMMAR_TOKEN.STRING}.escape`, foreground: 'd7ba7d' },
|
82
|
-
],
|
83
|
-
};
|
84
|
-
|
85
33
|
// Taken from `monaco-languages` configuration for Java in order to do propert brace matching
|
86
34
|
// See https://github.com/microsoft/monaco-languages/blob/master/src/java/java.ts
|
87
35
|
const configuration: monacoLanguagesAPI.LanguageConfiguration = {
|
@@ -485,7 +433,6 @@ export function setupPureLanguageService(options?: {
|
|
485
433
|
extraKeywords?: string[] | undefined;
|
486
434
|
extraParserKeywords?: string[] | undefined;
|
487
435
|
}): void {
|
488
|
-
monacoEditorAPI.defineTheme(CODE_EDITOR_THEME.LEGEND, theme);
|
489
436
|
monacoLanguagesAPI.register({ id: CODE_EDITOR_LANGUAGE.PURE });
|
490
437
|
monacoLanguagesAPI.setLanguageConfiguration(
|
491
438
|
CODE_EDITOR_LANGUAGE.PURE,
|
package/src/code-editor/index.ts
CHANGED
@@ -14,13 +14,11 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
export {
|
18
|
-
|
19
|
-
setupPureLanguageService,
|
20
|
-
} from './PureLanguageService.js';
|
17
|
+
export { setupPureLanguageService } from './PureLanguageService.js';
|
18
|
+
export { PURE_GRAMMAR_TOKEN } from './PureLanguage.js';
|
21
19
|
export * from './PureLanguageCodeEditorSupport.js';
|
22
20
|
|
23
|
-
export * from './CodeEditorConfig.js';
|
24
21
|
export * from './CodeEditor.js';
|
25
22
|
export * from './CodeEditorUtils.js';
|
23
|
+
export * from './CodeEditorTheme.js';
|
26
24
|
export * from './CodeDiffView.js';
|