@thienvu18/designable-react-settings-form 2.0.0 → 2.0.2
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/esm/SchemaField.d.ts +5115 -1578
- package/esm/SchemaField.js +76 -41
- package/esm/SettingsForm.d.ts +4 -4
- package/esm/SettingsForm.js +99 -49
- package/esm/components/BackgroundStyleSetter/index.d.ts +4 -4
- package/esm/components/BackgroundStyleSetter/index.js +95 -42
- package/esm/components/BorderRadiusStyleSetter/index.d.ts +4 -4
- package/esm/components/BorderRadiusStyleSetter/index.js +13 -10
- package/esm/components/BorderStyleSetter/index.d.ts +5 -5
- package/esm/components/BorderStyleSetter/index.js +121 -68
- package/esm/components/BoxShadowStyleSetter/index.d.ts +6 -6
- package/esm/components/BoxShadowStyleSetter/index.js +72 -24
- package/esm/components/BoxStyleSetter/index.d.ts +7 -7
- package/esm/components/BoxStyleSetter/index.js +98 -46
- package/esm/components/CollapseItem/index.d.ts +6 -6
- package/esm/components/CollapseItem/index.js +35 -15
- package/esm/components/ColorInput/index.d.ts +5 -5
- package/esm/components/ColorInput/index.js +35 -17
- package/esm/components/ColorInput/styles.less +0 -5
- package/esm/components/CornerInput/index.d.ts +7 -7
- package/esm/components/CornerInput/index.js +50 -21
- package/esm/components/DisplayStyleSetter/index.d.ts +7 -7
- package/esm/components/DisplayStyleSetter/index.js +62 -33
- package/esm/components/DrawerSetter/index.d.ts +6 -6
- package/esm/components/DrawerSetter/index.js +82 -42
- package/esm/components/DrawerSetter/styles.less +2 -2
- package/esm/components/FlexStyleSetter/index.d.ts +5 -5
- package/esm/components/FlexStyleSetter/index.js +160 -110
- package/esm/components/FoldItem/index.d.ts +9 -7
- package/esm/components/FoldItem/index.js +80 -46
- package/esm/components/FontStyleSetter/index.d.ts +4 -4
- package/esm/components/FontStyleSetter/index.js +169 -85
- package/esm/components/ImageInput/index.d.ts +7 -7
- package/esm/components/ImageInput/index.js +59 -39
- package/esm/components/InputItems/index.d.ts +19 -17
- package/esm/components/InputItems/index.js +42 -16
- package/esm/components/MonacoInput/config.d.ts +1 -1
- package/esm/components/MonacoInput/config.js +40 -38
- package/esm/components/MonacoInput/format.d.ts +4 -1
- package/esm/components/MonacoInput/format.js +33 -29
- package/esm/components/MonacoInput/index.d.ts +13 -13
- package/esm/components/MonacoInput/index.js +298 -212
- package/esm/components/MonacoInput/themes/chrome.d.ts +44 -38
- package/esm/components/MonacoInput/themes/chrome.js +105 -105
- package/esm/components/MonacoInput/themes/monokai.d.ts +34 -30
- package/esm/components/MonacoInput/themes/monokai.js +139 -139
- package/esm/components/PolyInput/index.d.ts +17 -17
- package/esm/components/PolyInput/index.js +96 -66
- package/esm/components/PositionInput/index.d.ts +7 -7
- package/esm/components/PositionInput/index.js +48 -21
- package/esm/components/PositionInput/styles.less +0 -1
- package/esm/components/SizeInput/index.d.ts +6 -2
- package/esm/components/SizeInput/index.js +44 -46
- package/esm/components/SizeInput/styles.less +0 -1
- package/esm/components/ValueInput/index.d.ts +2 -2
- package/esm/components/ValueInput/index.js +89 -72
- package/esm/components/index.d.ts +20 -20
- package/esm/components/index.js +20 -20
- package/esm/effects/index.d.ts +2 -2
- package/esm/effects/index.js +2 -2
- package/esm/effects/useLocales.d.ts +2 -2
- package/esm/effects/useLocales.js +57 -59
- package/esm/effects/useSnapshot.d.ts +2 -2
- package/esm/effects/useSnapshot.js +9 -9
- package/esm/index.d.ts +5 -5
- package/esm/index.js +5 -5
- package/esm/locales/en-US.d.ts +12 -12
- package/esm/locales/en-US.js +10 -10
- package/esm/locales/index.d.ts +1 -1
- package/esm/locales/index.js +5 -5
- package/esm/locales/ko-KR.d.ts +12 -12
- package/esm/locales/ko-KR.js +10 -10
- package/esm/locales/zh-CN.d.ts +12 -12
- package/esm/locales/zh-CN.js +10 -10
- package/esm/registry.d.ts +2 -2
- package/esm/registry.js +11 -11
- package/esm/shared/context.d.ts +2 -2
- package/esm/shared/context.js +2 -2
- package/esm/shared/loadScript.d.ts +5 -5
- package/esm/shared/loadScript.js +27 -28
- package/esm/styles.less +5 -4
- package/esm/types.d.ts +8 -8
- package/esm/types.js +1 -1
- package/lib/SchemaField.d.ts +5115 -1578
- package/lib/SchemaField.js +44 -44
- package/lib/SettingsForm.d.ts +4 -4
- package/lib/SettingsForm.js +108 -55
- package/lib/components/BackgroundStyleSetter/index.d.ts +4 -4
- package/lib/components/BackgroundStyleSetter/index.js +106 -48
- package/lib/components/BorderRadiusStyleSetter/index.d.ts +4 -4
- package/lib/components/BorderRadiusStyleSetter/index.js +33 -14
- package/lib/components/BorderStyleSetter/index.d.ts +5 -5
- package/lib/components/BorderStyleSetter/index.js +138 -74
- package/lib/components/BoxShadowStyleSetter/index.d.ts +6 -6
- package/lib/components/BoxShadowStyleSetter/index.js +82 -30
- package/lib/components/BoxStyleSetter/index.d.ts +7 -7
- package/lib/components/BoxStyleSetter/index.js +122 -52
- package/lib/components/CollapseItem/index.d.ts +6 -6
- package/lib/components/CollapseItem/index.js +49 -21
- package/lib/components/ColorInput/index.d.ts +5 -5
- package/lib/components/ColorInput/index.js +39 -21
- package/lib/components/ColorInput/styles.less +0 -5
- package/lib/components/CornerInput/index.d.ts +7 -7
- package/lib/components/CornerInput/index.js +70 -28
- package/lib/components/DisplayStyleSetter/index.d.ts +7 -7
- package/lib/components/DisplayStyleSetter/index.js +75 -39
- package/lib/components/DrawerSetter/index.d.ts +6 -6
- package/lib/components/DrawerSetter/index.js +99 -48
- package/lib/components/DrawerSetter/styles.less +2 -2
- package/lib/components/FlexStyleSetter/index.d.ts +5 -5
- package/lib/components/FlexStyleSetter/index.js +208 -116
- package/lib/components/FoldItem/index.d.ts +9 -7
- package/lib/components/FoldItem/index.js +140 -72
- package/lib/components/FontStyleSetter/index.d.ts +4 -4
- package/lib/components/FontStyleSetter/index.js +216 -91
- package/lib/components/ImageInput/index.d.ts +7 -7
- package/lib/components/ImageInput/index.js +69 -47
- package/lib/components/InputItems/index.d.ts +19 -17
- package/lib/components/InputItems/index.js +101 -46
- package/lib/components/MonacoInput/config.d.ts +1 -1
- package/lib/components/MonacoInput/config.js +49 -45
- package/lib/components/MonacoInput/format.d.ts +4 -1
- package/lib/components/MonacoInput/format.js +38 -33
- package/lib/components/MonacoInput/index.d.ts +13 -13
- package/lib/components/MonacoInput/index.js +347 -241
- package/lib/components/MonacoInput/themes/chrome.d.ts +44 -38
- package/lib/components/MonacoInput/themes/chrome.js +107 -107
- package/lib/components/MonacoInput/themes/monokai.d.ts +34 -30
- package/lib/components/MonacoInput/themes/monokai.js +141 -141
- package/lib/components/PolyInput/index.d.ts +17 -17
- package/lib/components/PolyInput/index.js +151 -96
- package/lib/components/PositionInput/index.d.ts +7 -7
- package/lib/components/PositionInput/index.js +68 -28
- package/lib/components/PositionInput/styles.less +0 -1
- package/lib/components/SizeInput/index.d.ts +6 -2
- package/lib/components/SizeInput/index.js +47 -49
- package/lib/components/SizeInput/styles.less +0 -1
- package/lib/components/ValueInput/index.d.ts +2 -2
- package/lib/components/ValueInput/index.js +92 -75
- package/lib/components/index.d.ts +20 -20
- package/lib/components/index.js +52 -36
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +34 -18
- package/lib/effects/useLocales.d.ts +2 -2
- package/lib/effects/useLocales.js +67 -63
- package/lib/effects/useSnapshot.d.ts +2 -2
- package/lib/effects/useSnapshot.js +13 -13
- package/lib/index.d.ts +5 -5
- package/lib/index.js +37 -21
- package/lib/locales/en-US.d.ts +12 -12
- package/lib/locales/en-US.js +12 -12
- package/lib/locales/index.d.ts +1 -1
- package/lib/locales/index.js +16 -10
- package/lib/locales/ko-KR.d.ts +12 -12
- package/lib/locales/ko-KR.js +12 -12
- package/lib/locales/zh-CN.d.ts +12 -12
- package/lib/locales/zh-CN.js +12 -12
- package/lib/registry.d.ts +2 -2
- package/lib/registry.js +21 -19
- package/lib/shared/context.d.ts +2 -2
- package/lib/shared/context.js +5 -5
- package/lib/shared/loadScript.d.ts +5 -5
- package/lib/shared/loadScript.js +32 -32
- package/lib/styles.less +5 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +2 -2
- package/package.json +26 -27
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import './
|
|
5
|
-
import './
|
|
6
|
-
export type Monaco = typeof monaco
|
|
1
|
+
import { EditorProps, loader } from '@monaco-editor/react'
|
|
2
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import './config'
|
|
5
|
+
import './styles.less'
|
|
6
|
+
export type Monaco = typeof monaco
|
|
7
7
|
export interface MonacoInputProps extends EditorProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
helpLink?: string | boolean
|
|
9
|
+
helpCode?: string
|
|
10
|
+
helpCodeViewWidth?: number | string
|
|
11
|
+
extraLib?: string
|
|
12
|
+
onChange?: (value: string) => void
|
|
13
13
|
}
|
|
14
14
|
export declare const MonacoInput: React.FC<MonacoInputProps> & {
|
|
15
|
-
|
|
16
|
-
}
|
|
15
|
+
loader?: typeof loader
|
|
16
|
+
}
|
|
@@ -1,216 +1,302 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import '
|
|
11
|
-
import '
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
import { parse, parseExpression } from '@babel/parser'
|
|
2
|
+
import Editor, { loader } from '@monaco-editor/react'
|
|
3
|
+
import {
|
|
4
|
+
IconWidget,
|
|
5
|
+
TextWidget,
|
|
6
|
+
usePrefix,
|
|
7
|
+
useTheme,
|
|
8
|
+
} from '@thienvu18/designable-react'
|
|
9
|
+
import { uid } from '@thienvu18/designable-shared'
|
|
10
|
+
import { Tooltip } from 'antd'
|
|
11
|
+
import cls from 'classnames'
|
|
12
|
+
import { useEffect, useRef, useState } from 'react'
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime'
|
|
14
|
+
import './config'
|
|
15
|
+
import { initMonaco } from './config'
|
|
16
|
+
import { format } from './format'
|
|
17
|
+
import './styles.less'
|
|
18
|
+
export const MonacoInput = ({
|
|
19
|
+
className,
|
|
20
|
+
language,
|
|
21
|
+
defaultLanguage,
|
|
22
|
+
width,
|
|
23
|
+
helpLink,
|
|
24
|
+
helpCode,
|
|
25
|
+
helpCodeViewWidth,
|
|
26
|
+
height,
|
|
27
|
+
onMount,
|
|
28
|
+
onChange,
|
|
29
|
+
...props
|
|
30
|
+
}) => {
|
|
31
|
+
const [loaded, setLoaded] = useState(false)
|
|
32
|
+
const theme = useTheme()
|
|
33
|
+
const valueRef = useRef('')
|
|
34
|
+
const validateRef = useRef(null)
|
|
35
|
+
const submitRef = useRef(null)
|
|
36
|
+
const declarationRef = useRef([])
|
|
37
|
+
const extraLibRef = useRef(null)
|
|
38
|
+
const monacoRef = useRef(null)
|
|
39
|
+
const editorRef = useRef(null)
|
|
40
|
+
const computedLanguage = useRef(language || defaultLanguage)
|
|
41
|
+
const realLanguage = useRef('')
|
|
42
|
+
const unmountedRef = useRef(false)
|
|
43
|
+
const changedRef = useRef(false)
|
|
44
|
+
const uidRef = useRef(uid())
|
|
45
|
+
const prefix = usePrefix('monaco-input')
|
|
46
|
+
const input = props.value || props.defaultValue
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
unmountedRef.current = false
|
|
49
|
+
initMonaco()
|
|
50
|
+
return () => {
|
|
51
|
+
if (extraLibRef.current) {
|
|
52
|
+
extraLibRef.current.dispose()
|
|
53
|
+
}
|
|
54
|
+
unmountedRef.current = true
|
|
55
|
+
}
|
|
56
|
+
}, [])
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (monacoRef.current && props.extraLib) {
|
|
59
|
+
updateExtraLib()
|
|
60
|
+
}
|
|
61
|
+
}, [props.extraLib])
|
|
62
|
+
const updateExtraLib = () => {
|
|
63
|
+
if (extraLibRef.current) {
|
|
64
|
+
extraLibRef.current.dispose()
|
|
65
|
+
}
|
|
66
|
+
extraLibRef.current =
|
|
67
|
+
monacoRef.current.languages.typescript.typescriptDefaults.addExtraLib(
|
|
68
|
+
props.extraLib,
|
|
69
|
+
`${uidRef.current}.d.ts`
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
const isFileLanguage = () => {
|
|
73
|
+
const lang = computedLanguage.current
|
|
74
|
+
return lang === 'javascript' || lang === 'typescript'
|
|
75
|
+
}
|
|
76
|
+
const isExpLanguage = () => {
|
|
77
|
+
const lang = computedLanguage.current
|
|
78
|
+
return lang === 'javascript.expression' || lang === 'typescript.expression'
|
|
79
|
+
}
|
|
80
|
+
const renderHelper = () => {
|
|
81
|
+
const getHref = () => {
|
|
82
|
+
if (typeof helpLink === 'string') return helpLink
|
|
83
|
+
if (isFileLanguage()) {
|
|
84
|
+
return 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript'
|
|
85
|
+
}
|
|
86
|
+
if (isExpLanguage()) {
|
|
87
|
+
return 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (helpLink === false) return null
|
|
91
|
+
const href = getHref()
|
|
92
|
+
return (
|
|
93
|
+
href &&
|
|
94
|
+
_jsx(Tooltip, {
|
|
95
|
+
title: _jsx(TextWidget, {
|
|
96
|
+
token: 'SettingComponents.MonacoInput.helpDocument',
|
|
97
|
+
}),
|
|
98
|
+
children: _jsx('div', {
|
|
99
|
+
className: prefix + '-helper',
|
|
100
|
+
children: _jsx('a', {
|
|
101
|
+
target: '_blank',
|
|
102
|
+
href: href,
|
|
103
|
+
rel: 'noreferrer',
|
|
104
|
+
children: _jsx(IconWidget, { infer: 'Help' }),
|
|
105
|
+
}),
|
|
106
|
+
}),
|
|
107
|
+
})
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
const onMountHandler = (editor, monaco) => {
|
|
111
|
+
editorRef.current = editor
|
|
112
|
+
monacoRef.current = monaco
|
|
113
|
+
onMount?.(editor, monaco)
|
|
114
|
+
const model = editor.getModel()
|
|
115
|
+
const currentValue = editor.getValue()
|
|
116
|
+
model['getDesignerLanguage'] = () => computedLanguage.current
|
|
117
|
+
if (currentValue) {
|
|
118
|
+
format(computedLanguage.current, currentValue)
|
|
119
|
+
.then((content) => {
|
|
120
|
+
editor.setValue(content)
|
|
121
|
+
setLoaded(true)
|
|
122
|
+
})
|
|
123
|
+
.catch(() => {
|
|
124
|
+
setLoaded(true)
|
|
125
|
+
})
|
|
126
|
+
} else {
|
|
127
|
+
setLoaded(true)
|
|
128
|
+
}
|
|
129
|
+
if (props.extraLib) {
|
|
130
|
+
updateExtraLib()
|
|
131
|
+
}
|
|
132
|
+
editor.onDidChangeModelContent(() => {
|
|
133
|
+
onChangeHandler(editor.getValue())
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
const submit = () => {
|
|
137
|
+
clearTimeout(submitRef.current)
|
|
138
|
+
submitRef.current = setTimeout(() => {
|
|
139
|
+
onChange?.(valueRef.current)
|
|
140
|
+
}, 1000)
|
|
141
|
+
}
|
|
142
|
+
const validate = () => {
|
|
143
|
+
if (realLanguage.current === 'typescript') {
|
|
144
|
+
clearTimeout(validateRef.current)
|
|
145
|
+
validateRef.current = setTimeout(() => {
|
|
146
|
+
try {
|
|
147
|
+
if (valueRef.current) {
|
|
64
148
|
if (isFileLanguage()) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
149
|
+
parse(valueRef.current, {
|
|
150
|
+
sourceType: 'module',
|
|
151
|
+
plugins: ['typescript', 'jsx'],
|
|
152
|
+
})
|
|
153
|
+
} else if (isExpLanguage()) {
|
|
154
|
+
parseExpression(valueRef.current, {
|
|
155
|
+
plugins: ['typescript', 'jsx'],
|
|
156
|
+
})
|
|
69
157
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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: {},
|
|
158
|
+
}
|
|
159
|
+
monacoRef.current.editor.setModelMarkers(
|
|
160
|
+
editorRef.current.getModel(),
|
|
161
|
+
computedLanguage.current,
|
|
162
|
+
[]
|
|
163
|
+
)
|
|
164
|
+
declarationRef.current = editorRef.current.deltaDecorations(
|
|
165
|
+
declarationRef.current,
|
|
166
|
+
[
|
|
167
|
+
{
|
|
168
|
+
range: new monacoRef.current.Range(1, 1, 1, 1),
|
|
169
|
+
options: {},
|
|
170
|
+
},
|
|
171
|
+
]
|
|
172
|
+
)
|
|
173
|
+
submit()
|
|
174
|
+
} catch (e) {
|
|
175
|
+
declarationRef.current = editorRef.current.deltaDecorations(
|
|
176
|
+
declarationRef.current,
|
|
177
|
+
[
|
|
178
|
+
{
|
|
179
|
+
range: new monacoRef.current.Range(
|
|
180
|
+
e.loc.line,
|
|
181
|
+
e.loc.column,
|
|
182
|
+
e.loc.line,
|
|
183
|
+
e.loc.column
|
|
184
|
+
),
|
|
185
|
+
options: {
|
|
186
|
+
isWholeLine: true,
|
|
187
|
+
glyphMarginClassName: 'monaco-error-highline',
|
|
166
188
|
},
|
|
167
|
-
|
|
189
|
+
},
|
|
190
|
+
]
|
|
191
|
+
)
|
|
192
|
+
monacoRef.current.editor.setModelMarkers(
|
|
193
|
+
editorRef.current.getModel(),
|
|
194
|
+
computedLanguage.current,
|
|
195
|
+
[
|
|
196
|
+
{
|
|
197
|
+
code: '1003',
|
|
198
|
+
severity: 8,
|
|
199
|
+
startLineNumber: e.loc.line,
|
|
200
|
+
startColumn: e.loc.column,
|
|
201
|
+
endLineNumber: e.loc.line,
|
|
202
|
+
endColumn: e.loc.column,
|
|
203
|
+
message: e.message,
|
|
204
|
+
},
|
|
205
|
+
]
|
|
206
|
+
)
|
|
168
207
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
208
|
+
}, 240)
|
|
209
|
+
} else {
|
|
210
|
+
submit()
|
|
211
|
+
declarationRef.current = editorRef.current.deltaDecorations(
|
|
212
|
+
declarationRef.current,
|
|
213
|
+
[
|
|
214
|
+
{
|
|
215
|
+
range: new monacoRef.current.Range(1, 1, 1, 1),
|
|
216
|
+
options: {},
|
|
217
|
+
},
|
|
218
|
+
]
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const onChangeHandler = (value) => {
|
|
223
|
+
changedRef.current = true
|
|
224
|
+
valueRef.current = value
|
|
225
|
+
validate()
|
|
226
|
+
}
|
|
227
|
+
computedLanguage.current = language || defaultLanguage
|
|
228
|
+
realLanguage.current = /(?:javascript|typescript)/gi.test(
|
|
229
|
+
computedLanguage.current
|
|
230
|
+
)
|
|
231
|
+
? 'typescript'
|
|
232
|
+
: computedLanguage.current
|
|
233
|
+
const renderHelpCode = () => {
|
|
234
|
+
if (!helpCode) return null
|
|
235
|
+
return _jsx('div', {
|
|
236
|
+
className: prefix + '-view',
|
|
237
|
+
style: { width: helpCodeViewWidth || '50%' },
|
|
238
|
+
children: _jsx(Editor, {
|
|
239
|
+
value: helpCode,
|
|
240
|
+
theme: theme === 'dark' ? 'monokai' : 'chrome-devtools',
|
|
241
|
+
defaultLanguage: realLanguage.current,
|
|
242
|
+
language: realLanguage.current,
|
|
243
|
+
options: {
|
|
244
|
+
...props.options,
|
|
245
|
+
lineNumbers: 'off',
|
|
246
|
+
readOnly: true,
|
|
247
|
+
glyphMargin: false,
|
|
248
|
+
folding: false,
|
|
249
|
+
lineDecorationsWidth: 0,
|
|
250
|
+
lineNumbersMinChars: 0,
|
|
251
|
+
minimap: {
|
|
252
|
+
enabled: false,
|
|
253
|
+
},
|
|
254
|
+
tabSize: 2,
|
|
255
|
+
smoothScrolling: true,
|
|
256
|
+
scrollbar: {
|
|
257
|
+
verticalScrollbarSize: 5,
|
|
258
|
+
horizontalScrollbarSize: 5,
|
|
259
|
+
alwaysConsumeMouseWheel: false,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
width: '100%',
|
|
263
|
+
height: '100%',
|
|
264
|
+
}),
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
return _jsxs('div', {
|
|
268
|
+
className: cls(prefix, className, {
|
|
269
|
+
loaded,
|
|
270
|
+
}),
|
|
271
|
+
style: { width, height },
|
|
272
|
+
children: [
|
|
273
|
+
renderHelper(),
|
|
274
|
+
_jsx('div', {
|
|
275
|
+
className: prefix + '-view',
|
|
276
|
+
children: _jsx(Editor, {
|
|
277
|
+
...props,
|
|
278
|
+
theme: theme === 'dark' ? 'monokai' : 'chrome-devtools',
|
|
279
|
+
defaultLanguage: realLanguage.current,
|
|
280
|
+
language: realLanguage.current,
|
|
281
|
+
options: {
|
|
282
|
+
glyphMargin: true,
|
|
283
|
+
...props.options,
|
|
284
|
+
tabSize: 2,
|
|
285
|
+
smoothScrolling: true,
|
|
286
|
+
scrollbar: {
|
|
287
|
+
verticalScrollbarSize: 5,
|
|
288
|
+
horizontalScrollbarSize: 5,
|
|
289
|
+
alwaysConsumeMouseWheel: false,
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
value: input,
|
|
293
|
+
width: '100%',
|
|
294
|
+
height: '100%',
|
|
295
|
+
onMount: onMountHandler,
|
|
296
|
+
}),
|
|
297
|
+
}),
|
|
298
|
+
renderHelpCode(),
|
|
299
|
+
],
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
MonacoInput.loader = loader
|
|
@@ -1,39 +1,45 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
background
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
foreground
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
2
|
+
base: string
|
|
3
|
+
inherit: boolean
|
|
4
|
+
rules: (
|
|
5
|
+
| {
|
|
6
|
+
foreground: string
|
|
7
|
+
token: string
|
|
8
|
+
fontStyle?: undefined
|
|
9
|
+
background?: undefined
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
fontStyle: string
|
|
13
|
+
token: string
|
|
14
|
+
foreground?: undefined
|
|
15
|
+
background?: undefined
|
|
16
|
+
}
|
|
17
|
+
| {
|
|
18
|
+
background: string
|
|
19
|
+
token: string
|
|
20
|
+
foreground?: undefined
|
|
21
|
+
fontStyle?: undefined
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
foreground: string
|
|
25
|
+
background: string
|
|
26
|
+
token: string
|
|
27
|
+
fontStyle?: undefined
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
foreground: string
|
|
31
|
+
fontStyle: string
|
|
32
|
+
token: string
|
|
33
|
+
background?: undefined
|
|
34
|
+
}
|
|
35
|
+
)[]
|
|
36
|
+
colors: {
|
|
37
|
+
'editor.foreground': string
|
|
38
|
+
'editor.background': string
|
|
39
|
+
'editor.selectionBackground': string
|
|
40
|
+
'editor.lineHighlightBackground': string
|
|
41
|
+
'editorCursor.foreground': string
|
|
42
|
+
'editorWhitespace.foreground': string
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export default _default
|