@thienvu18/designable-react-settings-form 2.0.1 → 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.
Files changed (167) hide show
  1. package/esm/SchemaField.d.ts +5115 -1578
  2. package/esm/SchemaField.js +76 -41
  3. package/esm/SettingsForm.d.ts +4 -4
  4. package/esm/SettingsForm.js +99 -49
  5. package/esm/components/BackgroundStyleSetter/index.d.ts +4 -4
  6. package/esm/components/BackgroundStyleSetter/index.js +95 -42
  7. package/esm/components/BorderRadiusStyleSetter/index.d.ts +4 -4
  8. package/esm/components/BorderRadiusStyleSetter/index.js +13 -10
  9. package/esm/components/BorderStyleSetter/index.d.ts +5 -5
  10. package/esm/components/BorderStyleSetter/index.js +121 -68
  11. package/esm/components/BoxShadowStyleSetter/index.d.ts +6 -6
  12. package/esm/components/BoxShadowStyleSetter/index.js +72 -24
  13. package/esm/components/BoxStyleSetter/index.d.ts +7 -7
  14. package/esm/components/BoxStyleSetter/index.js +98 -46
  15. package/esm/components/CollapseItem/index.d.ts +6 -6
  16. package/esm/components/CollapseItem/index.js +35 -15
  17. package/esm/components/ColorInput/index.d.ts +5 -5
  18. package/esm/components/ColorInput/index.js +35 -17
  19. package/esm/components/ColorInput/styles.less +0 -5
  20. package/esm/components/CornerInput/index.d.ts +7 -7
  21. package/esm/components/CornerInput/index.js +50 -21
  22. package/esm/components/DisplayStyleSetter/index.d.ts +7 -7
  23. package/esm/components/DisplayStyleSetter/index.js +62 -33
  24. package/esm/components/DrawerSetter/index.d.ts +6 -6
  25. package/esm/components/DrawerSetter/index.js +82 -42
  26. package/esm/components/DrawerSetter/styles.less +2 -2
  27. package/esm/components/FlexStyleSetter/index.d.ts +5 -5
  28. package/esm/components/FlexStyleSetter/index.js +160 -110
  29. package/esm/components/FoldItem/index.d.ts +9 -7
  30. package/esm/components/FoldItem/index.js +80 -46
  31. package/esm/components/FontStyleSetter/index.d.ts +4 -4
  32. package/esm/components/FontStyleSetter/index.js +169 -85
  33. package/esm/components/ImageInput/index.d.ts +7 -7
  34. package/esm/components/ImageInput/index.js +59 -39
  35. package/esm/components/InputItems/index.d.ts +19 -17
  36. package/esm/components/InputItems/index.js +42 -16
  37. package/esm/components/MonacoInput/config.d.ts +1 -1
  38. package/esm/components/MonacoInput/config.js +40 -38
  39. package/esm/components/MonacoInput/format.d.ts +4 -1
  40. package/esm/components/MonacoInput/format.js +33 -29
  41. package/esm/components/MonacoInput/index.d.ts +13 -13
  42. package/esm/components/MonacoInput/index.js +298 -212
  43. package/esm/components/MonacoInput/themes/chrome.d.ts +44 -38
  44. package/esm/components/MonacoInput/themes/chrome.js +105 -105
  45. package/esm/components/MonacoInput/themes/monokai.d.ts +34 -30
  46. package/esm/components/MonacoInput/themes/monokai.js +139 -139
  47. package/esm/components/PolyInput/index.d.ts +17 -17
  48. package/esm/components/PolyInput/index.js +96 -66
  49. package/esm/components/PositionInput/index.d.ts +7 -7
  50. package/esm/components/PositionInput/index.js +48 -21
  51. package/esm/components/PositionInput/styles.less +0 -1
  52. package/esm/components/SizeInput/index.d.ts +6 -2
  53. package/esm/components/SizeInput/index.js +44 -46
  54. package/esm/components/SizeInput/styles.less +0 -1
  55. package/esm/components/ValueInput/index.d.ts +2 -2
  56. package/esm/components/ValueInput/index.js +89 -72
  57. package/esm/components/index.d.ts +20 -20
  58. package/esm/components/index.js +20 -20
  59. package/esm/effects/index.d.ts +2 -2
  60. package/esm/effects/index.js +2 -2
  61. package/esm/effects/useLocales.d.ts +2 -2
  62. package/esm/effects/useLocales.js +57 -59
  63. package/esm/effects/useSnapshot.d.ts +2 -2
  64. package/esm/effects/useSnapshot.js +9 -9
  65. package/esm/index.d.ts +5 -5
  66. package/esm/index.js +5 -5
  67. package/esm/locales/en-US.d.ts +12 -12
  68. package/esm/locales/en-US.js +10 -10
  69. package/esm/locales/index.d.ts +1 -1
  70. package/esm/locales/index.js +5 -5
  71. package/esm/locales/ko-KR.d.ts +12 -12
  72. package/esm/locales/ko-KR.js +10 -10
  73. package/esm/locales/zh-CN.d.ts +12 -12
  74. package/esm/locales/zh-CN.js +10 -10
  75. package/esm/registry.d.ts +2 -2
  76. package/esm/registry.js +11 -11
  77. package/esm/shared/context.d.ts +2 -2
  78. package/esm/shared/context.js +2 -2
  79. package/esm/shared/loadScript.d.ts +5 -5
  80. package/esm/shared/loadScript.js +27 -28
  81. package/esm/styles.less +5 -4
  82. package/esm/types.d.ts +8 -8
  83. package/esm/types.js +1 -1
  84. package/lib/SchemaField.d.ts +5115 -1578
  85. package/lib/SchemaField.js +44 -44
  86. package/lib/SettingsForm.d.ts +4 -4
  87. package/lib/SettingsForm.js +108 -55
  88. package/lib/components/BackgroundStyleSetter/index.d.ts +4 -4
  89. package/lib/components/BackgroundStyleSetter/index.js +106 -48
  90. package/lib/components/BorderRadiusStyleSetter/index.d.ts +4 -4
  91. package/lib/components/BorderRadiusStyleSetter/index.js +33 -14
  92. package/lib/components/BorderStyleSetter/index.d.ts +5 -5
  93. package/lib/components/BorderStyleSetter/index.js +138 -74
  94. package/lib/components/BoxShadowStyleSetter/index.d.ts +6 -6
  95. package/lib/components/BoxShadowStyleSetter/index.js +82 -30
  96. package/lib/components/BoxStyleSetter/index.d.ts +7 -7
  97. package/lib/components/BoxStyleSetter/index.js +122 -52
  98. package/lib/components/CollapseItem/index.d.ts +6 -6
  99. package/lib/components/CollapseItem/index.js +49 -21
  100. package/lib/components/ColorInput/index.d.ts +5 -5
  101. package/lib/components/ColorInput/index.js +39 -21
  102. package/lib/components/ColorInput/styles.less +0 -5
  103. package/lib/components/CornerInput/index.d.ts +7 -7
  104. package/lib/components/CornerInput/index.js +70 -28
  105. package/lib/components/DisplayStyleSetter/index.d.ts +7 -7
  106. package/lib/components/DisplayStyleSetter/index.js +75 -39
  107. package/lib/components/DrawerSetter/index.d.ts +6 -6
  108. package/lib/components/DrawerSetter/index.js +99 -48
  109. package/lib/components/DrawerSetter/styles.less +2 -2
  110. package/lib/components/FlexStyleSetter/index.d.ts +5 -5
  111. package/lib/components/FlexStyleSetter/index.js +208 -116
  112. package/lib/components/FoldItem/index.d.ts +9 -7
  113. package/lib/components/FoldItem/index.js +140 -72
  114. package/lib/components/FontStyleSetter/index.d.ts +4 -4
  115. package/lib/components/FontStyleSetter/index.js +216 -91
  116. package/lib/components/ImageInput/index.d.ts +7 -7
  117. package/lib/components/ImageInput/index.js +69 -47
  118. package/lib/components/InputItems/index.d.ts +19 -17
  119. package/lib/components/InputItems/index.js +101 -46
  120. package/lib/components/MonacoInput/config.d.ts +1 -1
  121. package/lib/components/MonacoInput/config.js +49 -45
  122. package/lib/components/MonacoInput/format.d.ts +4 -1
  123. package/lib/components/MonacoInput/format.js +38 -33
  124. package/lib/components/MonacoInput/index.d.ts +13 -13
  125. package/lib/components/MonacoInput/index.js +347 -241
  126. package/lib/components/MonacoInput/themes/chrome.d.ts +44 -38
  127. package/lib/components/MonacoInput/themes/chrome.js +107 -107
  128. package/lib/components/MonacoInput/themes/monokai.d.ts +34 -30
  129. package/lib/components/MonacoInput/themes/monokai.js +141 -141
  130. package/lib/components/PolyInput/index.d.ts +17 -17
  131. package/lib/components/PolyInput/index.js +151 -96
  132. package/lib/components/PositionInput/index.d.ts +7 -7
  133. package/lib/components/PositionInput/index.js +68 -28
  134. package/lib/components/PositionInput/styles.less +0 -1
  135. package/lib/components/SizeInput/index.d.ts +6 -2
  136. package/lib/components/SizeInput/index.js +47 -49
  137. package/lib/components/SizeInput/styles.less +0 -1
  138. package/lib/components/ValueInput/index.d.ts +2 -2
  139. package/lib/components/ValueInput/index.js +92 -75
  140. package/lib/components/index.d.ts +20 -20
  141. package/lib/components/index.js +52 -36
  142. package/lib/effects/index.d.ts +2 -2
  143. package/lib/effects/index.js +34 -18
  144. package/lib/effects/useLocales.d.ts +2 -2
  145. package/lib/effects/useLocales.js +67 -63
  146. package/lib/effects/useSnapshot.d.ts +2 -2
  147. package/lib/effects/useSnapshot.js +13 -13
  148. package/lib/index.d.ts +5 -5
  149. package/lib/index.js +37 -21
  150. package/lib/locales/en-US.d.ts +12 -12
  151. package/lib/locales/en-US.js +12 -12
  152. package/lib/locales/index.d.ts +1 -1
  153. package/lib/locales/index.js +16 -10
  154. package/lib/locales/ko-KR.d.ts +12 -12
  155. package/lib/locales/ko-KR.js +12 -12
  156. package/lib/locales/zh-CN.d.ts +12 -12
  157. package/lib/locales/zh-CN.js +12 -12
  158. package/lib/registry.d.ts +2 -2
  159. package/lib/registry.js +21 -19
  160. package/lib/shared/context.d.ts +2 -2
  161. package/lib/shared/context.js +5 -5
  162. package/lib/shared/loadScript.d.ts +5 -5
  163. package/lib/shared/loadScript.js +32 -32
  164. package/lib/styles.less +5 -4
  165. package/lib/types.d.ts +8 -8
  166. package/lib/types.js +2 -2
  167. package/package.json +4 -4
@@ -1,16 +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;
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
- helpLink?: string | boolean;
9
- helpCode?: string;
10
- helpCodeViewWidth?: number | string;
11
- extraLib?: string;
12
- onChange?: (value: string) => void;
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
- loader?: typeof loader;
16
- };
15
+ loader?: typeof loader
16
+ }
@@ -1,216 +1,302 @@
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;
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
- 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';
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
- 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: {},
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
- 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;
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
- 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;
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