@tntd/monaco-editor 1.0.4 → 1.1.1
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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/src/FormulaEditor.js +5 -2
- package/src/I18N.js +40 -0
- package/src/plugins/cascader/Cascader.js +5 -2
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tntd/monaco-editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "webpack-dev-server --config webpack.config.js",
|
|
6
6
|
"build": "rm -rf ./dist && webpack --config webpack.config.build.js",
|
|
7
|
+
"build:umd": "webpack --config webpack.umd.config.js",
|
|
7
8
|
"prepublishOnly": "npm run build"
|
|
8
9
|
},
|
|
9
10
|
"peerDependencies": {
|
|
@@ -47,7 +48,9 @@
|
|
|
47
48
|
"terser-webpack-plugin": "^5.3.14",
|
|
48
49
|
"webpack": "^5.98.0",
|
|
49
50
|
"webpack-cli": "^4.10.0",
|
|
50
|
-
"webpack-dev-server": "^4.15.2"
|
|
51
|
+
"webpack-dev-server": "^4.15.2",
|
|
52
|
+
"mini-css-extract-plugin": "^2.6.0",
|
|
53
|
+
"babel-plugin-lodash": "^3.3.4"
|
|
51
54
|
},
|
|
52
55
|
"author": "zefei.zhou",
|
|
53
56
|
"license": "ISC",
|
|
@@ -71,4 +74,4 @@
|
|
|
71
74
|
"README.md",
|
|
72
75
|
".octopus"
|
|
73
76
|
]
|
|
74
|
-
}
|
|
77
|
+
}
|
package/src/FormulaEditor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useCallback, forwardRef, useImperativeHandle, useState, useMemo } from 'react';
|
|
2
|
+
import { WrapLocaleReceiverWithForwardRef } from './I18N'
|
|
2
3
|
import BaseMonacoEditor from './BaseMonacoEditor';
|
|
3
4
|
import { ConverterPlugin } from './plugins/converter';
|
|
4
5
|
import { CascaderPlugin } from './plugins/cascader';
|
|
@@ -18,13 +19,14 @@ const defaultCascaderOptions = {
|
|
|
18
19
|
showSourceName: true
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
const FormulaEditor =
|
|
22
|
+
const FormulaEditor = WrapLocaleReceiverWithForwardRef((props) => {
|
|
22
23
|
const {
|
|
23
24
|
isDiff,
|
|
24
25
|
modified: preModified,
|
|
25
26
|
original: preOriginal,
|
|
26
27
|
defaultValue: preDefaultValue,
|
|
27
|
-
|
|
28
|
+
ref,
|
|
29
|
+
I18N,
|
|
28
30
|
fieldList,
|
|
29
31
|
methodList,
|
|
30
32
|
normalList,
|
|
@@ -139,6 +141,7 @@ const FormulaEditor = forwardRef((props, ref) => {
|
|
|
139
141
|
regExpState: regExp,
|
|
140
142
|
searchCb,
|
|
141
143
|
isDiff,
|
|
144
|
+
locale: I18N,
|
|
142
145
|
...cascaderOptions,
|
|
143
146
|
triggerSuggest: (methodInfo) => {
|
|
144
147
|
baseEditor?.plugins?.get('suggestion')?.triggerSuggest?.(methodInfo);
|
package/src/I18N.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { forwardRef } from 'react'
|
|
2
|
+
import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'
|
|
1
3
|
import Cookies from 'universal-cookie';
|
|
2
4
|
const cookies = new Cookies();
|
|
3
5
|
|
|
@@ -5,3 +7,41 @@ export const getLang = () => {
|
|
|
5
7
|
return cookies.get('lang') || 'cn';
|
|
6
8
|
};
|
|
7
9
|
|
|
10
|
+
const mapLocale = {
|
|
11
|
+
'zh-cn': {
|
|
12
|
+
noData: '暂无数据',
|
|
13
|
+
},
|
|
14
|
+
'zh-tw': {
|
|
15
|
+
noData: '暫無資料',
|
|
16
|
+
},
|
|
17
|
+
en: {
|
|
18
|
+
noData: 'No data',
|
|
19
|
+
},
|
|
20
|
+
th: {
|
|
21
|
+
noData: 'ไม่มีข้อมูล',
|
|
22
|
+
}, // 泰语
|
|
23
|
+
ar: {
|
|
24
|
+
noData: 'مفيش بيانات'
|
|
25
|
+
}, // 阿拉伯语(埃及)
|
|
26
|
+
ko: {
|
|
27
|
+
noData: '데이터가 없습니다',
|
|
28
|
+
}, // 韩语
|
|
29
|
+
es: {
|
|
30
|
+
noData: 'Sin datos',
|
|
31
|
+
} // 西班牙语
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** 包的组件含有forwardRef, 去掉组件原有的forwardRef, 从props里获取ref **/
|
|
35
|
+
export const WrapLocaleReceiverWithForwardRef = (Component, ref) => {
|
|
36
|
+
return forwardRef((props) => (
|
|
37
|
+
<LocaleReceiver componentName="TntdMonacoEditor">
|
|
38
|
+
{(locale, localeCode) => {
|
|
39
|
+
const I18N = !!Object.keys(locale).length ? locale : (mapLocale[localeCode] || mapLocale[getLang()]);
|
|
40
|
+
const transformLocaleCode = localeCode === 'zh-cn' ? 'cn' : localeCode;
|
|
41
|
+
return (
|
|
42
|
+
<Component ref={ref} locale={locale} localeCode={transformLocaleCode} I18N={I18N} {...props} />
|
|
43
|
+
)
|
|
44
|
+
}}
|
|
45
|
+
</LocaleReceiver>
|
|
46
|
+
))
|
|
47
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
|
|
1
2
|
import { useEffect, useState, useMemo } from 'react';
|
|
2
|
-
import { TntdCascader, Tooltip } from 'tntd';
|
|
3
|
+
import { Empty, TntdCascader, Tooltip } from 'tntd';
|
|
3
4
|
import TdTag from '@tntd/cascader-tag';
|
|
4
5
|
import './Cascader.less';
|
|
5
6
|
|
|
@@ -16,7 +17,8 @@ export default (props) => {
|
|
|
16
17
|
showSourceName = true,
|
|
17
18
|
placement,
|
|
18
19
|
fieldNames,
|
|
19
|
-
dropdownClassName
|
|
20
|
+
dropdownClassName,
|
|
21
|
+
locale
|
|
20
22
|
} = props;
|
|
21
23
|
const [popupVisible, setPopupVisible] = useState(true); // 初始展开状态为true
|
|
22
24
|
const [options, setOptions] = useState([]);
|
|
@@ -110,6 +112,7 @@ export default (props) => {
|
|
|
110
112
|
fieldNames={fieldNames}
|
|
111
113
|
// searchValue={content || undefined}
|
|
112
114
|
options={options}
|
|
115
|
+
notFoundContent={<Empty size="mini" locale={locale} />}
|
|
113
116
|
open={popupVisible}
|
|
114
117
|
changeOnSelect={changeOnSelect}
|
|
115
118
|
renderItem={renderItem}
|