@thienvu18/designable-react-settings-form 2.0.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.md +20 -0
- package/README.md +1 -0
- package/esm/SchemaField.d.ts +1580 -0
- package/esm/SchemaField.js +42 -0
- package/esm/SettingsForm.d.ts +4 -0
- package/esm/SettingsForm.js +54 -0
- package/esm/components/BackgroundStyleSetter/index.d.ts +6 -0
- package/esm/components/BackgroundStyleSetter/index.js +43 -0
- package/esm/components/BorderRadiusStyleSetter/index.d.ts +6 -0
- package/esm/components/BorderRadiusStyleSetter/index.js +11 -0
- package/esm/components/BorderStyleSetter/index.d.ts +7 -0
- package/esm/components/BorderStyleSetter/index.js +74 -0
- package/esm/components/BorderStyleSetter/styles.less +70 -0
- package/esm/components/BoxShadowStyleSetter/index.d.ts +8 -0
- package/esm/components/BoxShadowStyleSetter/index.js +25 -0
- package/esm/components/BoxStyleSetter/index.d.ts +9 -0
- package/esm/components/BoxStyleSetter/index.js +49 -0
- package/esm/components/CollapseItem/index.d.ts +8 -0
- package/esm/components/CollapseItem/index.js +16 -0
- package/esm/components/CollapseItem/styles.less +45 -0
- package/esm/components/ColorInput/index.d.ts +7 -0
- package/esm/components/ColorInput/index.js +18 -0
- package/esm/components/ColorInput/styles.less +17 -0
- package/esm/components/CornerInput/index.d.ts +9 -0
- package/esm/components/CornerInput/index.js +22 -0
- package/esm/components/CornerInput/styles.less +25 -0
- package/esm/components/DisplayStyleSetter/index.d.ts +9 -0
- package/esm/components/DisplayStyleSetter/index.js +34 -0
- package/esm/components/DisplayStyleSetter/styles.less +15 -0
- package/esm/components/DrawerSetter/index.d.ts +8 -0
- package/esm/components/DrawerSetter/index.js +43 -0
- package/esm/components/DrawerSetter/styles.less +54 -0
- package/esm/components/FlexStyleSetter/index.d.ts +7 -0
- package/esm/components/FlexStyleSetter/index.js +111 -0
- package/esm/components/FlexStyleSetter/styles.less +23 -0
- package/esm/components/FoldItem/index.d.ts +7 -0
- package/esm/components/FoldItem/index.js +49 -0
- package/esm/components/FoldItem/styles.less +42 -0
- package/esm/components/FontStyleSetter/index.d.ts +6 -0
- package/esm/components/FontStyleSetter/index.js +88 -0
- package/esm/components/ImageInput/index.d.ts +9 -0
- package/esm/components/ImageInput/index.js +41 -0
- package/esm/components/ImageInput/styles.less +3 -0
- package/esm/components/InputItems/index.d.ts +23 -0
- package/esm/components/InputItems/index.js +18 -0
- package/esm/components/InputItems/styles.less +45 -0
- package/esm/components/MonacoInput/config.d.ts +1 -0
- package/esm/components/MonacoInput/config.js +39 -0
- package/esm/components/MonacoInput/format.d.ts +1 -0
- package/esm/components/MonacoInput/format.js +31 -0
- package/esm/components/MonacoInput/index.d.ts +16 -0
- package/esm/components/MonacoInput/index.js +216 -0
- package/esm/components/MonacoInput/styles.less +33 -0
- package/esm/components/MonacoInput/themes/chrome.d.ts +39 -0
- package/esm/components/MonacoInput/themes/chrome.js +106 -0
- package/esm/components/MonacoInput/themes/monokai.d.ts +31 -0
- package/esm/components/MonacoInput/themes/monokai.js +140 -0
- package/esm/components/PolyInput/index.d.ts +21 -0
- package/esm/components/PolyInput/index.js +70 -0
- package/esm/components/PolyInput/styles.less +31 -0
- package/esm/components/PositionInput/index.d.ts +9 -0
- package/esm/components/PositionInput/index.js +22 -0
- package/esm/components/PositionInput/styles.less +28 -0
- package/esm/components/SizeInput/index.d.ts +3 -0
- package/esm/components/SizeInput/index.js +53 -0
- package/esm/components/SizeInput/styles.less +23 -0
- package/esm/components/ValueInput/index.d.ts +2 -0
- package/esm/components/ValueInput/index.js +81 -0
- package/esm/components/ValueInput/styles.less +0 -0
- package/esm/components/index.d.ts +20 -0
- package/esm/components/index.js +20 -0
- package/esm/effects/index.d.ts +2 -0
- package/esm/effects/index.js +2 -0
- package/esm/effects/useLocales.d.ts +2 -0
- package/esm/effects/useLocales.js +63 -0
- package/esm/effects/useSnapshot.d.ts +2 -0
- package/esm/effects/useSnapshot.js +10 -0
- package/esm/index.d.ts +5 -0
- package/esm/index.js +5 -0
- package/esm/locales/en-US.d.ts +13 -0
- package/esm/locales/en-US.js +12 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +5 -0
- package/esm/locales/ko-KR.d.ts +13 -0
- package/esm/locales/ko-KR.js +12 -0
- package/esm/locales/zh-CN.d.ts +13 -0
- package/esm/locales/zh-CN.js +12 -0
- package/esm/registry.d.ts +2 -0
- package/esm/registry.js +13 -0
- package/esm/shared/context.d.ts +3 -0
- package/esm/shared/context.js +2 -0
- package/esm/shared/loadScript.d.ts +7 -0
- package/esm/shared/loadScript.js +29 -0
- package/esm/styles.less +121 -0
- package/esm/types.d.ts +10 -0
- package/esm/types.js +1 -0
- package/lib/SchemaField.d.ts +1580 -0
- package/lib/SchemaField.js +45 -0
- package/lib/SettingsForm.d.ts +4 -0
- package/lib/SettingsForm.js +60 -0
- package/lib/components/BackgroundStyleSetter/index.d.ts +6 -0
- package/lib/components/BackgroundStyleSetter/index.js +49 -0
- package/lib/components/BorderRadiusStyleSetter/index.d.ts +6 -0
- package/lib/components/BorderRadiusStyleSetter/index.js +15 -0
- package/lib/components/BorderStyleSetter/index.d.ts +7 -0
- package/lib/components/BorderStyleSetter/index.js +80 -0
- package/lib/components/BorderStyleSetter/styles.less +70 -0
- package/lib/components/BoxShadowStyleSetter/index.d.ts +8 -0
- package/lib/components/BoxShadowStyleSetter/index.js +31 -0
- package/lib/components/BoxStyleSetter/index.d.ts +9 -0
- package/lib/components/BoxStyleSetter/index.js +55 -0
- package/lib/components/CollapseItem/index.d.ts +8 -0
- package/lib/components/CollapseItem/index.js +22 -0
- package/lib/components/CollapseItem/styles.less +45 -0
- package/lib/components/ColorInput/index.d.ts +7 -0
- package/lib/components/ColorInput/index.js +22 -0
- package/lib/components/ColorInput/styles.less +17 -0
- package/lib/components/CornerInput/index.d.ts +9 -0
- package/lib/components/CornerInput/index.js +29 -0
- package/lib/components/CornerInput/styles.less +25 -0
- package/lib/components/DisplayStyleSetter/index.d.ts +9 -0
- package/lib/components/DisplayStyleSetter/index.js +40 -0
- package/lib/components/DisplayStyleSetter/styles.less +15 -0
- package/lib/components/DrawerSetter/index.d.ts +8 -0
- package/lib/components/DrawerSetter/index.js +49 -0
- package/lib/components/DrawerSetter/styles.less +54 -0
- package/lib/components/FlexStyleSetter/index.d.ts +7 -0
- package/lib/components/FlexStyleSetter/index.js +117 -0
- package/lib/components/FlexStyleSetter/styles.less +23 -0
- package/lib/components/FoldItem/index.d.ts +7 -0
- package/lib/components/FoldItem/index.js +78 -0
- package/lib/components/FoldItem/styles.less +42 -0
- package/lib/components/FontStyleSetter/index.d.ts +6 -0
- package/lib/components/FontStyleSetter/index.js +94 -0
- package/lib/components/ImageInput/index.d.ts +9 -0
- package/lib/components/ImageInput/index.js +49 -0
- package/lib/components/ImageInput/styles.less +3 -0
- package/lib/components/InputItems/index.d.ts +23 -0
- package/lib/components/InputItems/index.js +48 -0
- package/lib/components/InputItems/styles.less +45 -0
- package/lib/components/MonacoInput/config.d.ts +1 -0
- package/lib/components/MonacoInput/config.js +46 -0
- package/lib/components/MonacoInput/format.d.ts +1 -0
- package/lib/components/MonacoInput/format.js +35 -0
- package/lib/components/MonacoInput/index.d.ts +16 -0
- package/lib/components/MonacoInput/index.js +246 -0
- package/lib/components/MonacoInput/styles.less +33 -0
- package/lib/components/MonacoInput/themes/chrome.d.ts +39 -0
- package/lib/components/MonacoInput/themes/chrome.js +108 -0
- package/lib/components/MonacoInput/themes/monokai.d.ts +31 -0
- package/lib/components/MonacoInput/themes/monokai.js +142 -0
- package/lib/components/PolyInput/index.d.ts +21 -0
- package/lib/components/PolyInput/index.js +100 -0
- package/lib/components/PolyInput/styles.less +31 -0
- package/lib/components/PositionInput/index.d.ts +9 -0
- package/lib/components/PositionInput/index.js +29 -0
- package/lib/components/PositionInput/styles.less +28 -0
- package/lib/components/SizeInput/index.d.ts +3 -0
- package/lib/components/SizeInput/index.js +56 -0
- package/lib/components/SizeInput/styles.less +23 -0
- package/lib/components/ValueInput/index.d.ts +2 -0
- package/lib/components/ValueInput/index.js +84 -0
- package/lib/components/ValueInput/styles.less +0 -0
- package/lib/components/index.d.ts +20 -0
- package/lib/components/index.js +36 -0
- package/lib/effects/index.d.ts +2 -0
- package/lib/effects/index.js +18 -0
- package/lib/effects/useLocales.d.ts +2 -0
- package/lib/effects/useLocales.js +67 -0
- package/lib/effects/useSnapshot.d.ts +2 -0
- package/lib/effects/useSnapshot.js +14 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +21 -0
- package/lib/locales/en-US.d.ts +13 -0
- package/lib/locales/en-US.js +14 -0
- package/lib/locales/index.d.ts +1 -0
- package/lib/locales/index.js +10 -0
- package/lib/locales/ko-KR.d.ts +13 -0
- package/lib/locales/ko-KR.js +14 -0
- package/lib/locales/zh-CN.d.ts +13 -0
- package/lib/locales/zh-CN.js +14 -0
- package/lib/registry.d.ts +2 -0
- package/lib/registry.js +21 -0
- package/lib/shared/context.d.ts +3 -0
- package/lib/shared/context.js +5 -0
- package/lib/shared/loadScript.d.ts +7 -0
- package/lib/shared/loadScript.js +33 -0
- package/lib/styles.less +121 -0
- package/lib/types.d.ts +10 -0
- package/lib/types.js +2 -0
- package/package.json +71 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { parse } from '@babel/parser';
|
|
2
|
+
import { getNpmCDNRegistry } from '../../registry';
|
|
3
|
+
const cache = {
|
|
4
|
+
prettier: null,
|
|
5
|
+
};
|
|
6
|
+
export const format = async (language, source) => {
|
|
7
|
+
cache.prettier =
|
|
8
|
+
cache.prettier ||
|
|
9
|
+
new Function(`return import("${getNpmCDNRegistry()}/prettier@2.x/esm/standalone.mjs")`)();
|
|
10
|
+
return cache.prettier.then((module) => {
|
|
11
|
+
if (language === 'javascript.expression' ||
|
|
12
|
+
language === 'typescript.expression') {
|
|
13
|
+
return source;
|
|
14
|
+
}
|
|
15
|
+
if (/(?:javascript|typescript)/gi.test(language)) {
|
|
16
|
+
return module.default.format(source, {
|
|
17
|
+
semi: false,
|
|
18
|
+
parser(text) {
|
|
19
|
+
return parse(text, {
|
|
20
|
+
sourceType: 'module',
|
|
21
|
+
plugins: ['typescript', 'jsx'],
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (language === 'json') {
|
|
27
|
+
return JSON.stringify(JSON.parse(source), null, 2);
|
|
28
|
+
}
|
|
29
|
+
return source;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EditorProps, loader } from '@monaco-editor/react';
|
|
3
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
4
|
+
import './styles.less';
|
|
5
|
+
import './config';
|
|
6
|
+
export type Monaco = typeof monaco;
|
|
7
|
+
export interface MonacoInputProps extends EditorProps {
|
|
8
|
+
helpLink?: string | boolean;
|
|
9
|
+
helpCode?: string;
|
|
10
|
+
helpCodeViewWidth?: number | string;
|
|
11
|
+
extraLib?: string;
|
|
12
|
+
onChange?: (value: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const MonacoInput: React.FC<MonacoInputProps> & {
|
|
15
|
+
loader?: typeof loader;
|
|
16
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import Editor, { loader } from '@monaco-editor/react';
|
|
4
|
+
import { TextWidget, IconWidget, usePrefix, useTheme } from '@thienvu18/designable-react';
|
|
5
|
+
import { Tooltip } from 'antd';
|
|
6
|
+
import { parseExpression, parse } from '@babel/parser';
|
|
7
|
+
import { uid } from '@thienvu18/designable-shared';
|
|
8
|
+
import { format } from './format';
|
|
9
|
+
import cls from 'classnames';
|
|
10
|
+
import './styles.less';
|
|
11
|
+
import './config';
|
|
12
|
+
import { initMonaco } from './config';
|
|
13
|
+
export const MonacoInput = ({ className, language, defaultLanguage, width, helpLink, helpCode, helpCodeViewWidth, height, onMount, onChange, ...props }) => {
|
|
14
|
+
const [loaded, setLoaded] = useState(false);
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
const valueRef = useRef('');
|
|
17
|
+
const validateRef = useRef(null);
|
|
18
|
+
const submitRef = useRef(null);
|
|
19
|
+
const declarationRef = useRef([]);
|
|
20
|
+
const extraLibRef = useRef(null);
|
|
21
|
+
const monacoRef = useRef(null);
|
|
22
|
+
const editorRef = useRef(null);
|
|
23
|
+
const computedLanguage = useRef(language || defaultLanguage);
|
|
24
|
+
const realLanguage = useRef('');
|
|
25
|
+
const unmountedRef = useRef(false);
|
|
26
|
+
const changedRef = useRef(false);
|
|
27
|
+
const uidRef = useRef(uid());
|
|
28
|
+
const prefix = usePrefix('monaco-input');
|
|
29
|
+
const input = props.value || props.defaultValue;
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
unmountedRef.current = false;
|
|
32
|
+
initMonaco();
|
|
33
|
+
return () => {
|
|
34
|
+
if (extraLibRef.current) {
|
|
35
|
+
extraLibRef.current.dispose();
|
|
36
|
+
}
|
|
37
|
+
unmountedRef.current = true;
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (monacoRef.current && props.extraLib) {
|
|
42
|
+
updateExtraLib();
|
|
43
|
+
}
|
|
44
|
+
}, [props.extraLib]);
|
|
45
|
+
const updateExtraLib = () => {
|
|
46
|
+
if (extraLibRef.current) {
|
|
47
|
+
extraLibRef.current.dispose();
|
|
48
|
+
}
|
|
49
|
+
extraLibRef.current =
|
|
50
|
+
monacoRef.current.languages.typescript.typescriptDefaults.addExtraLib(props.extraLib, `${uidRef.current}.d.ts`);
|
|
51
|
+
};
|
|
52
|
+
const isFileLanguage = () => {
|
|
53
|
+
const lang = computedLanguage.current;
|
|
54
|
+
return lang === 'javascript' || lang === 'typescript';
|
|
55
|
+
};
|
|
56
|
+
const isExpLanguage = () => {
|
|
57
|
+
const lang = computedLanguage.current;
|
|
58
|
+
return lang === 'javascript.expression' || lang === 'typescript.expression';
|
|
59
|
+
};
|
|
60
|
+
const renderHelper = () => {
|
|
61
|
+
const getHref = () => {
|
|
62
|
+
if (typeof helpLink === 'string')
|
|
63
|
+
return helpLink;
|
|
64
|
+
if (isFileLanguage()) {
|
|
65
|
+
return 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript';
|
|
66
|
+
}
|
|
67
|
+
if (isExpLanguage()) {
|
|
68
|
+
return 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators';
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
if (helpLink === false)
|
|
72
|
+
return null;
|
|
73
|
+
const href = getHref();
|
|
74
|
+
return (href && (_jsx(Tooltip, { title: _jsx(TextWidget, { token: "SettingComponents.MonacoInput.helpDocument" }), children: _jsx("div", { className: prefix + '-helper', children: _jsx("a", { target: "_blank", href: href, rel: "noreferrer", children: _jsx(IconWidget, { infer: "Help" }) }) }) })));
|
|
75
|
+
};
|
|
76
|
+
const onMountHandler = (editor, monaco) => {
|
|
77
|
+
editorRef.current = editor;
|
|
78
|
+
monacoRef.current = monaco;
|
|
79
|
+
onMount?.(editor, monaco);
|
|
80
|
+
const model = editor.getModel();
|
|
81
|
+
const currentValue = editor.getValue();
|
|
82
|
+
model['getDesignerLanguage'] = () => computedLanguage.current;
|
|
83
|
+
if (currentValue) {
|
|
84
|
+
format(computedLanguage.current, currentValue)
|
|
85
|
+
.then((content) => {
|
|
86
|
+
editor.setValue(content);
|
|
87
|
+
setLoaded(true);
|
|
88
|
+
})
|
|
89
|
+
.catch(() => {
|
|
90
|
+
setLoaded(true);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
setLoaded(true);
|
|
95
|
+
}
|
|
96
|
+
if (props.extraLib) {
|
|
97
|
+
updateExtraLib();
|
|
98
|
+
}
|
|
99
|
+
editor.onDidChangeModelContent(() => {
|
|
100
|
+
onChangeHandler(editor.getValue());
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const submit = () => {
|
|
104
|
+
clearTimeout(submitRef.current);
|
|
105
|
+
submitRef.current = setTimeout(() => {
|
|
106
|
+
onChange?.(valueRef.current);
|
|
107
|
+
}, 1000);
|
|
108
|
+
};
|
|
109
|
+
const validate = () => {
|
|
110
|
+
if (realLanguage.current === 'typescript') {
|
|
111
|
+
clearTimeout(validateRef.current);
|
|
112
|
+
validateRef.current = setTimeout(() => {
|
|
113
|
+
try {
|
|
114
|
+
if (valueRef.current) {
|
|
115
|
+
if (isFileLanguage()) {
|
|
116
|
+
parse(valueRef.current, {
|
|
117
|
+
sourceType: 'module',
|
|
118
|
+
plugins: ['typescript', 'jsx'],
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else if (isExpLanguage()) {
|
|
122
|
+
parseExpression(valueRef.current, {
|
|
123
|
+
plugins: ['typescript', 'jsx'],
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
monacoRef.current.editor.setModelMarkers(editorRef.current.getModel(), computedLanguage.current, []);
|
|
128
|
+
declarationRef.current = editorRef.current.deltaDecorations(declarationRef.current, [
|
|
129
|
+
{
|
|
130
|
+
range: new monacoRef.current.Range(1, 1, 1, 1),
|
|
131
|
+
options: {},
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
submit();
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
declarationRef.current = editorRef.current.deltaDecorations(declarationRef.current, [
|
|
138
|
+
{
|
|
139
|
+
range: new monacoRef.current.Range(e.loc.line, e.loc.column, e.loc.line, e.loc.column),
|
|
140
|
+
options: {
|
|
141
|
+
isWholeLine: true,
|
|
142
|
+
glyphMarginClassName: 'monaco-error-highline',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
]);
|
|
146
|
+
monacoRef.current.editor.setModelMarkers(editorRef.current.getModel(), computedLanguage.current, [
|
|
147
|
+
{
|
|
148
|
+
code: '1003',
|
|
149
|
+
severity: 8,
|
|
150
|
+
startLineNumber: e.loc.line,
|
|
151
|
+
startColumn: e.loc.column,
|
|
152
|
+
endLineNumber: e.loc.line,
|
|
153
|
+
endColumn: e.loc.column,
|
|
154
|
+
message: e.message,
|
|
155
|
+
},
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
}, 240);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
submit();
|
|
162
|
+
declarationRef.current = editorRef.current.deltaDecorations(declarationRef.current, [
|
|
163
|
+
{
|
|
164
|
+
range: new monacoRef.current.Range(1, 1, 1, 1),
|
|
165
|
+
options: {},
|
|
166
|
+
},
|
|
167
|
+
]);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const onChangeHandler = (value) => {
|
|
171
|
+
changedRef.current = true;
|
|
172
|
+
valueRef.current = value;
|
|
173
|
+
validate();
|
|
174
|
+
};
|
|
175
|
+
computedLanguage.current = language || defaultLanguage;
|
|
176
|
+
realLanguage.current = /(?:javascript|typescript)/gi.test(computedLanguage.current)
|
|
177
|
+
? 'typescript'
|
|
178
|
+
: computedLanguage.current;
|
|
179
|
+
const renderHelpCode = () => {
|
|
180
|
+
if (!helpCode)
|
|
181
|
+
return null;
|
|
182
|
+
return (_jsx("div", { className: prefix + '-view', style: { width: helpCodeViewWidth || '50%' }, children: _jsx(Editor, { value: helpCode, theme: theme === 'dark' ? 'monokai' : 'chrome-devtools', defaultLanguage: realLanguage.current, language: realLanguage.current, options: {
|
|
183
|
+
...props.options,
|
|
184
|
+
lineNumbers: 'off',
|
|
185
|
+
readOnly: true,
|
|
186
|
+
glyphMargin: false,
|
|
187
|
+
folding: false,
|
|
188
|
+
lineDecorationsWidth: 0,
|
|
189
|
+
lineNumbersMinChars: 0,
|
|
190
|
+
minimap: {
|
|
191
|
+
enabled: false,
|
|
192
|
+
},
|
|
193
|
+
tabSize: 2,
|
|
194
|
+
smoothScrolling: true,
|
|
195
|
+
scrollbar: {
|
|
196
|
+
verticalScrollbarSize: 5,
|
|
197
|
+
horizontalScrollbarSize: 5,
|
|
198
|
+
alwaysConsumeMouseWheel: false,
|
|
199
|
+
},
|
|
200
|
+
}, width: "100%", height: "100%" }) }));
|
|
201
|
+
};
|
|
202
|
+
return (_jsxs("div", { className: cls(prefix, className, {
|
|
203
|
+
loaded,
|
|
204
|
+
}), style: { width, height }, children: [renderHelper(), _jsx("div", { className: prefix + '-view', children: _jsx(Editor, { ...props, theme: theme === 'dark' ? 'monokai' : 'chrome-devtools', defaultLanguage: realLanguage.current, language: realLanguage.current, options: {
|
|
205
|
+
glyphMargin: true,
|
|
206
|
+
...props.options,
|
|
207
|
+
tabSize: 2,
|
|
208
|
+
smoothScrolling: true,
|
|
209
|
+
scrollbar: {
|
|
210
|
+
verticalScrollbarSize: 5,
|
|
211
|
+
horizontalScrollbarSize: 5,
|
|
212
|
+
alwaysConsumeMouseWheel: false,
|
|
213
|
+
},
|
|
214
|
+
}, value: input, width: "100%", height: "100%", onMount: onMountHandler }) }), renderHelpCode()] }));
|
|
215
|
+
};
|
|
216
|
+
MonacoInput.loader = loader;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.dn-monaco-input {
|
|
2
|
+
position: relative;
|
|
3
|
+
transition: all 0.15s ease-in-out;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
opacity: 0;
|
|
7
|
+
display: flex;
|
|
8
|
+
|
|
9
|
+
&.loaded {
|
|
10
|
+
opacity: 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&-view {
|
|
14
|
+
flex-grow: 2;
|
|
15
|
+
height: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-helper {
|
|
19
|
+
position: absolute;
|
|
20
|
+
bottom: 10px;
|
|
21
|
+
right: 5%;
|
|
22
|
+
z-index: 2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.monaco-error-highline {
|
|
26
|
+
left: 0px !important;
|
|
27
|
+
width: 5px !important;
|
|
28
|
+
height: 5px !important;
|
|
29
|
+
background: red !important;
|
|
30
|
+
border-radius: 100% !important;
|
|
31
|
+
transform: translate(35px, 5px) !important;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
base: string;
|
|
3
|
+
inherit: boolean;
|
|
4
|
+
rules: ({
|
|
5
|
+
foreground: string;
|
|
6
|
+
token: string;
|
|
7
|
+
fontStyle?: undefined;
|
|
8
|
+
background?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
fontStyle: string;
|
|
11
|
+
token: string;
|
|
12
|
+
foreground?: undefined;
|
|
13
|
+
background?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
background: string;
|
|
16
|
+
token: string;
|
|
17
|
+
foreground?: undefined;
|
|
18
|
+
fontStyle?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
foreground: string;
|
|
21
|
+
background: string;
|
|
22
|
+
token: string;
|
|
23
|
+
fontStyle?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
foreground: string;
|
|
26
|
+
fontStyle: string;
|
|
27
|
+
token: string;
|
|
28
|
+
background?: undefined;
|
|
29
|
+
})[];
|
|
30
|
+
colors: {
|
|
31
|
+
'editor.foreground': string;
|
|
32
|
+
'editor.background': string;
|
|
33
|
+
'editor.selectionBackground': string;
|
|
34
|
+
'editor.lineHighlightBackground': string;
|
|
35
|
+
'editorCursor.foreground': string;
|
|
36
|
+
'editorWhitespace.foreground': string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
base: 'vs',
|
|
3
|
+
inherit: true,
|
|
4
|
+
rules: [
|
|
5
|
+
{
|
|
6
|
+
foreground: 'c41a16',
|
|
7
|
+
token: 'string',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
foreground: '1c00cf',
|
|
11
|
+
token: 'constant.numeric',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
foreground: 'aa0d91',
|
|
15
|
+
token: 'keyword',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
foreground: '000000',
|
|
19
|
+
token: 'keyword.operator',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
foreground: 'aa0d91',
|
|
23
|
+
token: 'constant.language',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
foreground: '990000',
|
|
27
|
+
token: 'support.class.exception',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
foreground: '000000',
|
|
31
|
+
token: 'entity.name.function',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
fontStyle: 'bold underline',
|
|
35
|
+
token: 'entity.name.type',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
fontStyle: 'italic',
|
|
39
|
+
token: 'variable.parameter',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
foreground: '007400',
|
|
43
|
+
token: 'comment',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
foreground: 'ff0000',
|
|
47
|
+
token: 'invalid',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
background: 'e71a1100',
|
|
51
|
+
token: 'invalid.deprecated.trailing-whitespace',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
foreground: '000000',
|
|
55
|
+
background: 'fafafafc',
|
|
56
|
+
token: 'text source',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
foreground: 'aa0d91',
|
|
60
|
+
token: 'meta.tag',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
foreground: 'aa0d91',
|
|
64
|
+
token: 'declaration.tag',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
foreground: '000000',
|
|
68
|
+
fontStyle: 'bold',
|
|
69
|
+
token: 'support',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
foreground: 'aa0d91',
|
|
73
|
+
token: 'storage',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
fontStyle: 'bold underline',
|
|
77
|
+
token: 'entity.name.section',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
foreground: '000000',
|
|
81
|
+
fontStyle: 'bold',
|
|
82
|
+
token: 'entity.name.function.frame',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
foreground: '333333',
|
|
86
|
+
token: 'meta.tag.preprocessor.xml',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
foreground: '994500',
|
|
90
|
+
fontStyle: 'italic',
|
|
91
|
+
token: 'entity.other.attribute-name',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
foreground: '881280',
|
|
95
|
+
token: 'entity.name.tag',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
colors: {
|
|
99
|
+
'editor.foreground': '#000000',
|
|
100
|
+
'editor.background': '#FFFFFF',
|
|
101
|
+
'editor.selectionBackground': '#BAD6FD',
|
|
102
|
+
'editor.lineHighlightBackground': '#EFEFFF',
|
|
103
|
+
'editorCursor.foreground': '#000000',
|
|
104
|
+
'editorWhitespace.foreground': '#B3B3B3F4',
|
|
105
|
+
},
|
|
106
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
base: string;
|
|
3
|
+
inherit: boolean;
|
|
4
|
+
rules: ({
|
|
5
|
+
foreground: string;
|
|
6
|
+
token: string;
|
|
7
|
+
fontStyle?: undefined;
|
|
8
|
+
background?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
foreground: string;
|
|
11
|
+
fontStyle: string;
|
|
12
|
+
token: string;
|
|
13
|
+
background?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
foreground: string;
|
|
16
|
+
background: string;
|
|
17
|
+
token: string;
|
|
18
|
+
fontStyle?: undefined;
|
|
19
|
+
})[];
|
|
20
|
+
colors: {
|
|
21
|
+
'editor.foreground': string;
|
|
22
|
+
'editor.background': string;
|
|
23
|
+
'editor.selectionBackground': string;
|
|
24
|
+
'editor.lineHighlightBackground': string;
|
|
25
|
+
'editorCursor.foreground': string;
|
|
26
|
+
'editorWhitespace.foreground': string;
|
|
27
|
+
'editorIndentGuide.activeBackground': string;
|
|
28
|
+
'editor.selectionHighlightBorder': string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export default _default;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
base: 'vs-dark',
|
|
3
|
+
inherit: true,
|
|
4
|
+
rules: [
|
|
5
|
+
{
|
|
6
|
+
foreground: '75715e',
|
|
7
|
+
token: 'comment',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
foreground: 'e6db74',
|
|
11
|
+
token: 'string',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
foreground: 'ae81ff',
|
|
15
|
+
token: 'constant.numeric',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
foreground: 'ae81ff',
|
|
19
|
+
token: 'constant.language',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
foreground: 'ae81ff',
|
|
23
|
+
token: 'constant.character',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
foreground: 'ae81ff',
|
|
27
|
+
token: 'constant.other',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
foreground: 'f92672',
|
|
31
|
+
token: 'keyword',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
foreground: 'f92672',
|
|
35
|
+
token: 'storage',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
foreground: '66d9ef',
|
|
39
|
+
fontStyle: 'italic',
|
|
40
|
+
token: 'storage.type',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
foreground: 'a6e22e',
|
|
44
|
+
fontStyle: 'underline',
|
|
45
|
+
token: 'entity.name.class',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
foreground: 'a6e22e',
|
|
49
|
+
fontStyle: 'italic underline',
|
|
50
|
+
token: 'entity.other.inherited-class',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
foreground: 'a6e22e',
|
|
54
|
+
token: 'entity.name.function',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
foreground: 'fd971f',
|
|
58
|
+
fontStyle: 'italic',
|
|
59
|
+
token: 'variable.parameter',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
foreground: 'f92672',
|
|
63
|
+
token: 'entity.name.tag',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
foreground: 'a6e22e',
|
|
67
|
+
token: 'entity.other.attribute-name',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
foreground: '66d9ef',
|
|
71
|
+
token: 'support.function',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
foreground: '66d9ef',
|
|
75
|
+
token: 'support.constant',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
foreground: '66d9ef',
|
|
79
|
+
fontStyle: 'italic',
|
|
80
|
+
token: 'support.type',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
foreground: '66d9ef',
|
|
84
|
+
fontStyle: 'italic',
|
|
85
|
+
token: 'support.class',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
foreground: 'f8f8f0',
|
|
89
|
+
background: 'f92672',
|
|
90
|
+
token: 'invalid',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
foreground: 'f8f8f0',
|
|
94
|
+
background: 'ae81ff',
|
|
95
|
+
token: 'invalid.deprecated',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
foreground: 'cfcfc2',
|
|
99
|
+
token: 'meta.structure.dictionary.json string.quoted.double.json',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
foreground: '75715e',
|
|
103
|
+
token: 'meta.diff',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
foreground: '75715e',
|
|
107
|
+
token: 'meta.diff.header',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
foreground: 'f92672',
|
|
111
|
+
token: 'markup.deleted',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
foreground: 'a6e22e',
|
|
115
|
+
token: 'markup.inserted',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
foreground: 'e6db74',
|
|
119
|
+
token: 'markup.changed',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
foreground: 'ae81ffa0',
|
|
123
|
+
token: 'constant.numeric.line-number.find-in-files - match',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
foreground: 'e6db74',
|
|
127
|
+
token: 'entity.name.filename.find-in-files',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
colors: {
|
|
131
|
+
'editor.foreground': '#F8F8F2',
|
|
132
|
+
'editor.background': '#222222',
|
|
133
|
+
'editor.selectionBackground': '#49483E',
|
|
134
|
+
'editor.lineHighlightBackground': '#3E3D32',
|
|
135
|
+
'editorCursor.foreground': '#F8F8F0',
|
|
136
|
+
'editorWhitespace.foreground': '#3B3A32',
|
|
137
|
+
'editorIndentGuide.activeBackground': '#9D550FB0',
|
|
138
|
+
'editor.selectionHighlightBorder': '#222218',
|
|
139
|
+
},
|
|
140
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './styles.less';
|
|
3
|
+
export interface IInput {
|
|
4
|
+
style?: React.CSSProperties;
|
|
5
|
+
className?: string;
|
|
6
|
+
value: any;
|
|
7
|
+
onChange: (value: any) => void;
|
|
8
|
+
exclude?: string[];
|
|
9
|
+
include?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface IPolyType {
|
|
12
|
+
type: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
component?: any;
|
|
16
|
+
checker: (value: any) => boolean;
|
|
17
|
+
toInputValue?: (value: any) => any;
|
|
18
|
+
toChangeValue?: (value: any) => any;
|
|
19
|
+
}
|
|
20
|
+
export type PolyTypes = IPolyType[];
|
|
21
|
+
export declare function createPolyInput(polyTypes?: PolyTypes): React.FC<IInput>;
|