@chaoswise/ui 3.1.22 → 3.2.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/lib/BasicLayout/Nav.js +3 -1
- package/lib/BasicLayout/index.js +7 -10
- package/lib/CWMessage/MessageContent/index.js +7 -7
- package/lib/CWRangePicker/DropdownMenu/index.js +3 -3
- package/lib/CWRangePicker/index.js +7 -7
- package/lib/CWRangePicker/utils/generate/dayjs.js +6 -104
- package/lib/CWRangePicker/utils/generate/moment.js +6 -104
- package/lib/CardSelect/index.js +24 -17
- package/lib/CitySelect/index.js +3 -1
- package/lib/ConfigProvider/ConfigProvider.js +45 -37
- package/lib/ConfigProvider/Switch.js +9 -3
- package/lib/ConfigProvider/generate/dayjs.js +67 -16
- package/lib/ConfigProvider/generate/moment.js +66 -12
- package/lib/ConfigProvider/locale.js +25 -0
- package/lib/ErrorBoundary/ErrorPage.js +3 -2
- package/lib/Flow/tools/index.js +1 -1
- package/lib/Header/LocaleSwitcher.js +8 -13
- package/lib/Header/UserSetting/i18n/index.js +9 -0
- package/lib/Header/UserSetting/index.js +8 -26
- package/lib/IconSelect/components/SearchIcon/index.js +3 -3
- package/lib/Pagination/index.js +3 -12
- package/lib/SimpleCard/index.js +3 -1
- package/lib/SingleSpa/index.js +3 -1
- package/lib/ThemeProvider/Switcher.js +3 -1
- package/lib/TimeRangeSlider/index.js +7 -7
- package/lib/TimeRangeSlider/utils/generate/dayjs.js +6 -90
- package/lib/TimeRangeSlider/utils/generate/moment.js +6 -104
- package/lib/WangEditor/i18n/extra.js +18 -0
- package/lib/WangEditor/i18n/index.js +43 -0
- package/lib/WangEditor/i18n/messages.js +52 -0
- package/lib/WangEditor/index.js +6 -13
- package/lib/WangEditor/locale/index.js +1 -0
- package/lib/WangEditor/wangEditor.js +61 -29
- package/lib/locales/en_US.json +1 -1
- package/lib/locales/index.js +54 -47
- package/lib/locales/intl.js +1 -5
- package/lib/locales/ja_JP.json +1 -1
- package/lib/locales/locale.js +33 -0
- package/lib/locales/zh_CN.json +1 -1
- package/lib/locales/zh_HK.json +1 -0
- package/lib/locales/zh_TW.json +1 -1
- package/lib/utils/i18n/getLocaleIntl.js +44 -0
- package/lib/utils/i18n/recently.js +52 -0
- package/lib/utils/index.js +2 -1
- package/package.json +5 -2
|
@@ -30,6 +30,7 @@ import useConfigContext from '../useConfigContext';
|
|
|
30
30
|
import { echoInputValue, getUnit, judgeType, getChangeUnitDate, isInvalidDate, funcValueChangeArrayValue, getCorrectValue, getFinalDateOption, getTruthDateCount, isLessThanMinTimeSpan, isExceedMaxTimeSpan, isWithinTimeSpan, getYears, computedRecentlyValue } from './utils/generate/dayjs';
|
|
31
31
|
import useStyle from './styles/index.style';
|
|
32
32
|
import { useIntl } from '../locales';
|
|
33
|
+
import useLocale from '../ConfigProvider/useLocale';
|
|
33
34
|
var TimeRangeSlider = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
34
35
|
var defaultValue = props.defaultValue,
|
|
35
36
|
value = props.value,
|
|
@@ -70,9 +71,8 @@ var TimeRangeSlider = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
70
71
|
message = _message$useMessage2[0],
|
|
71
72
|
contextHolder = _message$useMessage2[1];
|
|
72
73
|
var intl = useIntl();
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
locale = _ref$currentLocale === void 0 ? 'zh_CN' : _ref$currentLocale;
|
|
74
|
+
var _useLocale = useLocale(),
|
|
75
|
+
locale = _useLocale.locale;
|
|
76
76
|
var _useConfigContext = useConfigContext(),
|
|
77
77
|
getPrefixCls = _useConfigContext.getPrefixCls;
|
|
78
78
|
var prefixCls = getPrefixCls();
|
|
@@ -390,7 +390,7 @@ var TimeRangeSlider = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
390
390
|
if (!isInvalidDate_) {
|
|
391
391
|
var passValue = returnValue.value;
|
|
392
392
|
if (isLessThanMinTimeSpan(passValue, timeSpanBoundaryStart)) {
|
|
393
|
-
message.error(
|
|
393
|
+
message.error(intl.get("e598e58b-604f-4d98-bf6b-5f7813a33fa5").d("小于限制的最小时间跨度,请重新输入"));
|
|
394
394
|
return;
|
|
395
395
|
}
|
|
396
396
|
if (isExceedMaxTimeSpan(passValue, timeSpanBoundary)) {
|
|
@@ -398,7 +398,7 @@ var TimeRangeSlider = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
398
398
|
return;
|
|
399
399
|
}
|
|
400
400
|
if (!isWithinTimeSpan(passValue, days)) {
|
|
401
|
-
message.error(
|
|
401
|
+
message.error(intl.get("af0592fb-8027-4bd3-afb2-48956cf829fa").d("不在要求的时间跨度之内,请重新输入"));
|
|
402
402
|
return;
|
|
403
403
|
}
|
|
404
404
|
_onChange(returnValue);
|
|
@@ -419,7 +419,7 @@ var TimeRangeSlider = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
419
419
|
});
|
|
420
420
|
var _passValue = _returnValue.value;
|
|
421
421
|
if (isLessThanMinTimeSpan(_passValue, timeSpanBoundaryStart)) {
|
|
422
|
-
message.error(
|
|
422
|
+
message.error(intl.get("e598e58b-604f-4d98-bf6b-5f7813a33fa5").d("小于限制的最小时间跨度,请重新输入"));
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
425
|
if (isExceedMaxTimeSpan(_passValue, timeSpanBoundary)) {
|
|
@@ -427,7 +427,7 @@ var TimeRangeSlider = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
427
427
|
return;
|
|
428
428
|
}
|
|
429
429
|
if (!isWithinTimeSpan(_passValue, days)) {
|
|
430
|
-
message.error(
|
|
430
|
+
message.error(intl.get("af0592fb-8027-4bd3-afb2-48956cf829fa").d("不在要求的时间跨度之内,请重新输入"));
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
433
|
_onChange(_returnValue);
|
|
@@ -17,6 +17,9 @@ import isSameOrAfter_dayjs from "dayjs/plugin/isSameOrAfter";
|
|
|
17
17
|
import utc from "dayjs/plugin/utc";
|
|
18
18
|
import timezone from "dayjs/plugin/timezone";
|
|
19
19
|
import { v4 as uuidv4 } from 'uuid';
|
|
20
|
+
import intl from '../../../locales';
|
|
21
|
+
import { formatRecentlyTimeTitle } from '../../../utils/i18n/recently';
|
|
22
|
+
import { getLocaleIntl } from '../../../utils/i18n/getLocaleIntl';
|
|
20
23
|
originalDayjs.extend(isSameOrAfter_dayjs);
|
|
21
24
|
originalDayjs.extend(duration);
|
|
22
25
|
// 扩展 dayjs 支持时区
|
|
@@ -31,57 +34,21 @@ var dayjs = function dayjs() {
|
|
|
31
34
|
// 枚举时间单位
|
|
32
35
|
var ENUM_TimeUnit = {
|
|
33
36
|
s: {
|
|
34
|
-
zh_CN: "秒",
|
|
35
|
-
en_US: {
|
|
36
|
-
singular: "Second",
|
|
37
|
-
plural: "Seconds"
|
|
38
|
-
},
|
|
39
|
-
zh_TW: "秒",
|
|
40
37
|
unit: "seconds"
|
|
41
38
|
},
|
|
42
39
|
m: {
|
|
43
|
-
zh_CN: "分钟",
|
|
44
|
-
en_US: {
|
|
45
|
-
singular: "Minute",
|
|
46
|
-
plural: "Minutes"
|
|
47
|
-
},
|
|
48
|
-
zh_TW: "分鐘",
|
|
49
40
|
unit: "minutes"
|
|
50
41
|
},
|
|
51
42
|
h: {
|
|
52
|
-
zh_CN: "小时",
|
|
53
|
-
en_US: {
|
|
54
|
-
singular: "Hour",
|
|
55
|
-
plural: "Hours"
|
|
56
|
-
},
|
|
57
|
-
zh_TW: "小時",
|
|
58
43
|
unit: "hours"
|
|
59
44
|
},
|
|
60
45
|
d: {
|
|
61
|
-
zh_CN: "天",
|
|
62
|
-
en_US: {
|
|
63
|
-
singular: "Day",
|
|
64
|
-
plural: "Days"
|
|
65
|
-
},
|
|
66
|
-
zh_TW: "天",
|
|
67
46
|
unit: "days"
|
|
68
47
|
},
|
|
69
48
|
mo: {
|
|
70
|
-
zh_CN: "月",
|
|
71
|
-
en_US: {
|
|
72
|
-
singular: "Month",
|
|
73
|
-
plural: "Months"
|
|
74
|
-
},
|
|
75
|
-
zh_TW: "月",
|
|
76
49
|
unit: "mo"
|
|
77
50
|
},
|
|
78
51
|
y: {
|
|
79
|
-
zh_CN: "年",
|
|
80
|
-
en_US: {
|
|
81
|
-
singular: "Year",
|
|
82
|
-
plural: "Years"
|
|
83
|
-
},
|
|
84
|
-
zh_TW: "年",
|
|
85
52
|
unit: "years"
|
|
86
53
|
}
|
|
87
54
|
};
|
|
@@ -168,61 +135,10 @@ export var judgeType = function judgeType(recordDateValue) {
|
|
|
168
135
|
}
|
|
169
136
|
return [isRule, captureUnit, recordUnit];
|
|
170
137
|
};
|
|
171
|
-
export var echoRecentlyTimeTitle = function echoRecentlyTimeTitle(locale, captureUnit) {
|
|
172
|
-
// 参数验证
|
|
173
|
-
if (!captureUnit || !Array.isArray(captureUnit) || captureUnit.length < 2) {
|
|
174
|
-
return "";
|
|
175
|
-
}
|
|
176
|
-
var _captureUnit3 = _slicedToArray(captureUnit, 2),
|
|
177
|
-
count = _captureUnit3[0],
|
|
178
|
-
unit = _captureUnit3[1];
|
|
179
|
-
var timeUnit = ENUM_TimeUnit[unit];
|
|
180
|
-
if (!timeUnit) {
|
|
181
|
-
return "";
|
|
182
|
-
}
|
|
183
|
-
var countNum = parseInt(count, 10);
|
|
184
138
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
template: function template(count, unitText) {
|
|
189
|
-
return "\u6700\u8FD1".concat(count).concat(unit === "mo" ? "个" : "").concat(unitText);
|
|
190
|
-
},
|
|
191
|
-
getUnitText: function getUnitText() {
|
|
192
|
-
return timeUnit.zh_CN;
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
zh: {
|
|
196
|
-
template: function template(count, unitText) {
|
|
197
|
-
return "\u6700\u8FD1".concat(count).concat(unit === "mo" ? "个" : "").concat(unitText);
|
|
198
|
-
},
|
|
199
|
-
getUnitText: function getUnitText() {
|
|
200
|
-
return timeUnit.zh_CN;
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
zh_TW: {
|
|
204
|
-
template: function template(count, unitText) {
|
|
205
|
-
return "\u6700\u8FD1".concat(count).concat(unit === "mo" ? "個" : "").concat(unitText);
|
|
206
|
-
},
|
|
207
|
-
getUnitText: function getUnitText() {
|
|
208
|
-
return timeUnit.zh_TW;
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
"default": {
|
|
212
|
-
template: function template(count, unitText) {
|
|
213
|
-
return "Past ".concat(count, " ").concat(unitText);
|
|
214
|
-
},
|
|
215
|
-
getUnitText: function getUnitText() {
|
|
216
|
-
var isPlural = countNum !== 1;
|
|
217
|
-
return isPlural ? timeUnit.en_US.plural : timeUnit.en_US.singular;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
// 获取当前语言配置,如果不存在则使用默认配置
|
|
223
|
-
var config = localeConfig[locale] || localeConfig["default"];
|
|
224
|
-
var unitText = config.getUnitText();
|
|
225
|
-
return config.template(count, unitText);
|
|
139
|
+
// 复用完整词条消息,同时保留旧工具显式 locale 参数,不回写主语言。
|
|
140
|
+
export var echoRecentlyTimeTitle = function echoRecentlyTimeTitle(locale, captureUnit) {
|
|
141
|
+
return formatRecentlyTimeTitle(getLocaleIntl(locale, intl), captureUnit);
|
|
226
142
|
};
|
|
227
143
|
export var echoAbsoluteTimeTitle = function echoAbsoluteTimeTitle(value, format) {
|
|
228
144
|
var hasTimeSpan = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
@@ -12,66 +12,27 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
12
12
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
13
|
import moment from 'moment';
|
|
14
14
|
import { v4 as uuidv4 } from 'uuid';
|
|
15
|
+
import intl from '../../../locales';
|
|
16
|
+
import { formatRecentlyTimeTitle } from '../../../utils/i18n/recently';
|
|
17
|
+
import { getLocaleIntl } from '../../../utils/i18n/getLocaleIntl';
|
|
15
18
|
// 枚举时间单位
|
|
16
19
|
var ENUM_TimeUnit = {
|
|
17
20
|
s: {
|
|
18
|
-
zh_CN: '秒',
|
|
19
|
-
en_US: {
|
|
20
|
-
singular: 'Second',
|
|
21
|
-
plural: 'Seconds'
|
|
22
|
-
},
|
|
23
|
-
zh_TW: '秒',
|
|
24
|
-
ja_JP: '秒',
|
|
25
21
|
unit: 'seconds'
|
|
26
22
|
},
|
|
27
23
|
m: {
|
|
28
|
-
zh_CN: '分钟',
|
|
29
|
-
en_US: {
|
|
30
|
-
singular: 'Minute',
|
|
31
|
-
plural: 'Minutes'
|
|
32
|
-
},
|
|
33
|
-
zh_TW: '分鐘',
|
|
34
|
-
ja_JP: '分',
|
|
35
24
|
unit: 'minutes'
|
|
36
25
|
},
|
|
37
26
|
h: {
|
|
38
|
-
zh_CN: '小时',
|
|
39
|
-
en_US: {
|
|
40
|
-
singular: 'Hour',
|
|
41
|
-
plural: 'Hours'
|
|
42
|
-
},
|
|
43
|
-
zh_TW: '小時',
|
|
44
|
-
ja_JP: '時間',
|
|
45
27
|
unit: 'hours'
|
|
46
28
|
},
|
|
47
29
|
d: {
|
|
48
|
-
zh_CN: '天',
|
|
49
|
-
en_US: {
|
|
50
|
-
singular: 'Day',
|
|
51
|
-
plural: 'Days'
|
|
52
|
-
},
|
|
53
|
-
zh_TW: '天',
|
|
54
|
-
ja_JP: '日',
|
|
55
30
|
unit: 'days'
|
|
56
31
|
},
|
|
57
32
|
mo: {
|
|
58
|
-
zh_CN: '月',
|
|
59
|
-
en_US: {
|
|
60
|
-
singular: 'Month',
|
|
61
|
-
plural: 'Months'
|
|
62
|
-
},
|
|
63
|
-
zh_TW: '月',
|
|
64
|
-
ja_JP: 'ヶ月',
|
|
65
33
|
unit: 'mo'
|
|
66
34
|
},
|
|
67
35
|
y: {
|
|
68
|
-
zh_CN: '年',
|
|
69
|
-
en_US: {
|
|
70
|
-
singular: 'Year',
|
|
71
|
-
plural: 'Years'
|
|
72
|
-
},
|
|
73
|
-
zh_TW: '年',
|
|
74
|
-
ja_JP: '年',
|
|
75
36
|
unit: 'years'
|
|
76
37
|
}
|
|
77
38
|
};
|
|
@@ -158,69 +119,10 @@ export var judgeType = function judgeType(recordDateValue) {
|
|
|
158
119
|
}
|
|
159
120
|
return [isRule, captureUnit, recordUnit];
|
|
160
121
|
};
|
|
161
|
-
export var echoRecentlyTimeTitle = function echoRecentlyTimeTitle(locale, captureUnit) {
|
|
162
|
-
// 参数验证
|
|
163
|
-
if (!captureUnit || !Array.isArray(captureUnit) || captureUnit.length < 2) {
|
|
164
|
-
return '';
|
|
165
|
-
}
|
|
166
|
-
var _captureUnit3 = _slicedToArray(captureUnit, 2),
|
|
167
|
-
count = _captureUnit3[0],
|
|
168
|
-
unit = _captureUnit3[1];
|
|
169
|
-
var timeUnit = ENUM_TimeUnit[unit];
|
|
170
|
-
if (!timeUnit) {
|
|
171
|
-
return '';
|
|
172
|
-
}
|
|
173
|
-
var countNum = parseInt(count, 10);
|
|
174
|
-
|
|
175
|
-
// 语言配置映射
|
|
176
|
-
var localeConfig = {
|
|
177
|
-
zh_CN: {
|
|
178
|
-
template: function template(count, unitText) {
|
|
179
|
-
return "\u6700\u8FD1".concat(count).concat(unit === 'mo' ? '个' : '').concat(unitText);
|
|
180
|
-
},
|
|
181
|
-
getUnitText: function getUnitText() {
|
|
182
|
-
return timeUnit.zh_CN;
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
zh: {
|
|
186
|
-
template: function template(count, unitText) {
|
|
187
|
-
return "\u6700\u8FD1".concat(count).concat(unit === 'mo' ? '个' : '').concat(unitText);
|
|
188
|
-
},
|
|
189
|
-
getUnitText: function getUnitText() {
|
|
190
|
-
return timeUnit.zh_CN;
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
zh_TW: {
|
|
194
|
-
template: function template(count, unitText) {
|
|
195
|
-
return "\u6700\u8FD1".concat(count).concat(unit === 'mo' ? '個' : '').concat(unitText);
|
|
196
|
-
},
|
|
197
|
-
getUnitText: function getUnitText() {
|
|
198
|
-
return timeUnit.zh_TW;
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
ja_JP: {
|
|
202
|
-
template: function template(count, unitText) {
|
|
203
|
-
return "\u904E\u53BB".concat(count).concat(unitText);
|
|
204
|
-
},
|
|
205
|
-
getUnitText: function getUnitText() {
|
|
206
|
-
return timeUnit.ja_JP;
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
"default": {
|
|
210
|
-
template: function template(count, unitText) {
|
|
211
|
-
return "Past ".concat(count, " ").concat(unitText);
|
|
212
|
-
},
|
|
213
|
-
getUnitText: function getUnitText() {
|
|
214
|
-
var isPlural = countNum !== 1;
|
|
215
|
-
return isPlural ? timeUnit.en_US.plural : timeUnit.en_US.singular;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
122
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return config.template(count, unitText);
|
|
123
|
+
// 复用完整词条消息,同时保留旧工具显式 locale 参数,不回写主语言。
|
|
124
|
+
export var echoRecentlyTimeTitle = function echoRecentlyTimeTitle(locale, captureUnit) {
|
|
125
|
+
return formatRecentlyTimeTitle(getLocaleIntl(locale, intl), captureUnit);
|
|
224
126
|
};
|
|
225
127
|
export var echoAbsoluteTimeTitle = function echoAbsoluteTimeTitle(value, format) {
|
|
226
128
|
var hasTimeSpan = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// 较长的操作文案先匹配,避免“行”“链接”“图片”等旧协议键拆开它们。
|
|
2
|
+
export var createEditorExtraLanguage = function createEditorExtraLanguage(intl) {
|
|
3
|
+
return {
|
|
4
|
+
编辑表格: intl.get("6b9fc39b-ee41-4bf5-91df-bd5fea326afc").d("编辑表格"),
|
|
5
|
+
增加行: intl.get("f2164183-c243-48b0-af98-c34d7911f8e1").d("增加行"),
|
|
6
|
+
删除行: intl.get("9741465f-631b-420c-9d3d-2fd42ec38091").d("删除行"),
|
|
7
|
+
增加列: intl.get("87fe28d0-e61a-4976-a73e-986d4ccc446a").d("增加列"),
|
|
8
|
+
删除列: intl.get("c7670924-564a-444c-82d0-f1c2aa3a47f9").d("删除列"),
|
|
9
|
+
删除表格: intl.get("c357832a-5db1-4d1f-b690-bf33454877b5").d("删除表格"),
|
|
10
|
+
编辑图片: intl.get("4901621b-80e0-4729-ae0a-a4b47051ceb5").d("编辑图片"),
|
|
11
|
+
最大宽度: intl.get("f85b3af5-cf2c-494f-880e-96d778921af0").d("最大宽度"),
|
|
12
|
+
删除图片: intl.get("8197e587-0609-4182-8925-d8c99110b32f").d("删除图片"),
|
|
13
|
+
删除链接: intl.get("89428c42-3c95-4c92-8c9d-93cbacc18cf2").d("删除链接"),
|
|
14
|
+
图片链接: intl.get("35c36863-820d-44a0-b764-bdd87601eb00").d("图片链接"),
|
|
15
|
+
查看链接: intl.get("0008cae5-0e10-4d68-959f-ead9b6ee8ccb").d("查看链接"),
|
|
16
|
+
取消链接: intl.get("cb9eac1e-5ffd-43fe-80f4-158187fdd94e").d("取消链接")
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { createEditorExtraLanguage } from "./extra";
|
|
8
|
+
|
|
9
|
+
// 中文键是编辑器的正则匹配协议,保持稳定;只采集右侧显示文案。
|
|
10
|
+
// 在初始化/切换时传入 UI 的独立 intl 实例,不在模块加载时缓存译文。
|
|
11
|
+
export var createEditorLanguage = function createEditorLanguage(intl) {
|
|
12
|
+
return _objectSpread(_objectSpread({}, createEditorExtraLanguage(intl)), {}, {
|
|
13
|
+
设置标题: intl.get("45c8866a-8104-4ac3-a89a-be49cb479829").d("设置标题"),
|
|
14
|
+
正文: intl.get("421ea9b5-a91c-46d6-a49f-3c4a51d5cf49").d("正文"),
|
|
15
|
+
链接文字: intl.get("cd5e7d99-56b1-4881-a2cd-dc56e5b2f66d").d("链接文字"),
|
|
16
|
+
链接: intl.get("4fa00ba0-cf91-4608-99ac-71477e1c710e").d("链接"),
|
|
17
|
+
上传图片: intl.get("7cc1918f-dfcd-4a40-9d9d-0978b5aef2e7").d("上传图片"),
|
|
18
|
+
上传: intl.get("91569dad-8768-436c-bb00-54440d9ca6a2").d("上传"),
|
|
19
|
+
有序列表: intl.get("a65eabc4-c088-4951-a9d7-1696925abe3c").d("有序列表"),
|
|
20
|
+
无序列表: intl.get("06c57bfc-c0ae-4cc1-886d-d89e026a7265").d("无序列表"),
|
|
21
|
+
靠左: intl.get("d14a16b7-377b-491c-b28c-b827ac10806f").d("靠左"),
|
|
22
|
+
居中: intl.get("1bcdcbc1-f2db-4763-a257-aa13c2111346").d("居中"),
|
|
23
|
+
靠右: intl.get("a03a3849-0988-45eb-bfb0-d65277fc29b7").d("靠右"),
|
|
24
|
+
字号: intl.get("5b64c9ba-7502-4a39-996c-c927773728d4").d("字号"),
|
|
25
|
+
字体: intl.get("f8386447-5899-4ef5-bdf0-5a860ba8a204").d("字体"),
|
|
26
|
+
文字颜色: intl.get("e0fd3aeb-610d-4816-a163-b87081ae24de").d("文字颜色"),
|
|
27
|
+
背景色: intl.get("5f48bebc-4f90-46ac-b0d5-3e0114e06100").d("背景色"),
|
|
28
|
+
设置列表: intl.get("c011935d-58ee-4e6c-a764-94fb4c152d3d").d("设置列表"),
|
|
29
|
+
插入代码: intl.get("9e4a852a-7b35-41fd-acde-1c723b07f23e").d("插入代码"),
|
|
30
|
+
插入视频: intl.get("0cc1d707-1ca3-4794-9983-47facfde1a78").d("插入视频"),
|
|
31
|
+
格式如: intl.get("668c982b-de06-41f3-a07b-19f6f01e5edf").d("格式如"),
|
|
32
|
+
插入表格: intl.get("9ee08e72-f957-4087-b755-53e6ce4dd6d4").d("插入表格"),
|
|
33
|
+
列的表格: intl.get("6c6a70e0-7e26-4f42-8744-7c2b74ca0928").d("列的表格"),
|
|
34
|
+
行: intl.get("788eb48c-a716-4428-9af8-bf47f6d15b66").d("行"),
|
|
35
|
+
默认: intl.get("b8f6f979-a31f-49cd-9b7b-b612327e71ed").d("默认"),
|
|
36
|
+
新浪: intl.get("a9bc109d-8f4c-4d79-a99c-59441026d714").d("新浪"),
|
|
37
|
+
对齐方式: intl.get("2f770372-d9c3-40a6-913b-2a2b2ebaee33").d("对齐方式"),
|
|
38
|
+
网络图片: intl.get("0263f81c-1725-4830-a24c-bd459f46553f").d("网络图片"),
|
|
39
|
+
插入: intl.get("b5312ea1-9065-41b2-aef7-bba61787defb").d("插入"),
|
|
40
|
+
创建: intl.get("597e5392-e33b-4f6c-ab2f-4288a95c610c").d("创建"),
|
|
41
|
+
图片: intl.get("6464f11f-e8dc-44a0-9913-24a0ef53075f").d("图片")
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// 完整消息独立采集;调用时查询 UI intl,不缓存语言或拼接句子片段。
|
|
2
|
+
export var formatEditorMessage = function formatEditorMessage(instance, key, values) {
|
|
3
|
+
// 当前运行时只格式化正式词条,不插值 .d() 兜底;只处理默认文本,
|
|
4
|
+
// 不对已经格式化的译文再次替换(文件名/链接可能自身包含花括号)。
|
|
5
|
+
var intl = {
|
|
6
|
+
get: function get(id, params) {
|
|
7
|
+
var translated = instance.get(id, params);
|
|
8
|
+
return {
|
|
9
|
+
d: function d(defaultText) {
|
|
10
|
+
var fallback = params ? defaultText.replace(/\{(\w+)\}/g, function (match, name) {
|
|
11
|
+
return Object.prototype.hasOwnProperty.call(params, name) ? String(params[name]) : match;
|
|
12
|
+
}) : defaultText;
|
|
13
|
+
return translated.d(fallback);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
switch (key) {
|
|
19
|
+
case "invalidUrl":
|
|
20
|
+
return intl.get("aaea929d-30e5-4b60-a45a-4256691e8a1d").d("请输入合法Url");
|
|
21
|
+
case "insertImageError":
|
|
22
|
+
return intl.get("f47417cf-57e0-46b3-bd1b-142563eeff4a").d("插入图片错误");
|
|
23
|
+
case "validationFailed":
|
|
24
|
+
return intl.get("d1cf4325-4eb7-4c2a-a00d-21b7d1eb2099").d("图片验证未通过:");
|
|
25
|
+
case "timeout":
|
|
26
|
+
return intl.get("e1e58479-43e0-4dc5-ba05-83ef3a6ca8ac").d("上传图片超时");
|
|
27
|
+
case "uploadError":
|
|
28
|
+
return intl.get("8d5855ff-56ed-4a99-b891-92e44120e08e").d("上传图片发生错误");
|
|
29
|
+
case "uploadFailed":
|
|
30
|
+
return intl.get("7aef64cb-4da3-4c9b-ab63-fb8e971b5cfc").d("上传图片失败");
|
|
31
|
+
case "missingArguments":
|
|
32
|
+
return intl.get("984dfd29-6b9c-4b3f-883c-23e25667d6ee").d("错误:初始化编辑器时候未传入任何参数,请查阅文档");
|
|
33
|
+
case "browserOnly":
|
|
34
|
+
return intl.get("354eab79-8f65-4c5f-9b30-980eba5a37f4").d("请在浏览器环境下运行");
|
|
35
|
+
case "downloadFailed":
|
|
36
|
+
return intl.get("5edf680a-b89b-49a9-920f-0fb87d42d387", values).d("wangEditor: 插入图片出错,图片链接是 \"{link}\",下载该链接失败");
|
|
37
|
+
case "notImage":
|
|
38
|
+
return intl.get("38f4f38d-6adf-4f1a-9d31-ee0703c3e5f8", values).d("【{name}】不是图片");
|
|
39
|
+
case "tooLarge":
|
|
40
|
+
return intl.get("b0d3270e-d690-4cb8-8c3b-fe0704d6d8a4", values).d("【{name}】大于 {size}M");
|
|
41
|
+
case "uploadLimit":
|
|
42
|
+
return intl.get("f4777a3e-5c2d-4103-9014-d57dbb47ec9f", values).d("一次最多上传{count}张图片");
|
|
43
|
+
case "serverError":
|
|
44
|
+
return intl.get("e389bbf8-8009-4246-8a85-289a5aef5e92", values).d("上传图片发生错误,服务器返回状态是 {status}");
|
|
45
|
+
case "invalidResult":
|
|
46
|
+
return intl.get("057954f6-3559-4c4c-aa9c-142a0fc382fa", values).d("上传图片返回结果错误,返回结果是: {result}");
|
|
47
|
+
case "invalidErrno":
|
|
48
|
+
return intl.get("875655d1-b72c-4339-a9ec-6f89b22454c4", values).d("上传图片返回结果错误,返回结果 errno={errno}");
|
|
49
|
+
default:
|
|
50
|
+
throw new Error("Unknown editor message: ".concat(key));
|
|
51
|
+
}
|
|
52
|
+
};
|
package/lib/WangEditor/index.js
CHANGED
|
@@ -10,17 +10,11 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
10
10
|
import React, { useEffect, Fragment, useRef, forwardRef } from "react";
|
|
11
11
|
import E from "./wangEditor";
|
|
12
12
|
import PropTypes from "prop-types";
|
|
13
|
-
import {
|
|
13
|
+
import { createEditorLanguage } from "./i18n";
|
|
14
14
|
import { useIntl } from "../locales";
|
|
15
|
+
import useLocale from "../ConfigProvider/useLocale";
|
|
15
16
|
import usePreview from "./usePreview";
|
|
16
17
|
import resizeable from "./resizeable";
|
|
17
|
-
var localOptionsMap = {
|
|
18
|
-
en: localeObj,
|
|
19
|
-
en_US: localeObj,
|
|
20
|
-
zh_TW: localObjTW,
|
|
21
|
-
zh: {},
|
|
22
|
-
zh_CN: {}
|
|
23
|
-
};
|
|
24
18
|
import classnames from "classnames";
|
|
25
19
|
import useConfigContext from "../useConfigContext";
|
|
26
20
|
import useStyle from "./index.style";
|
|
@@ -73,9 +67,8 @@ var WangEditor = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
73
67
|
var separaTopRef = useRef(null);
|
|
74
68
|
var separaBotRef = useRef(null);
|
|
75
69
|
var intl = useIntl();
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
locale = _ref2$currentLocale === void 0 ? "zh_CN" : _ref2$currentLocale;
|
|
70
|
+
var _useLocale = useLocale(),
|
|
71
|
+
locale = _useLocale.locale;
|
|
79
72
|
|
|
80
73
|
// 初始化编辑器
|
|
81
74
|
useEffect(function () {
|
|
@@ -124,7 +117,7 @@ var WangEditor = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
124
117
|
});
|
|
125
118
|
useEffect(function () {
|
|
126
119
|
// 切换语言
|
|
127
|
-
editor.current.customConfig.lang =
|
|
120
|
+
editor.current.customConfig.lang = createEditorLanguage(intl);
|
|
128
121
|
editor.current._initConfig();
|
|
129
122
|
editor.current.$toolbarElem.html("");
|
|
130
123
|
editor.current._initMenus();
|
|
@@ -157,7 +150,7 @@ var WangEditor = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
157
150
|
editor.customConfig.onblur = onBlur;
|
|
158
151
|
editor.customConfig.onfocus = onFocus;
|
|
159
152
|
editor.customConfig.pasteTextHandle = pasteTextHandle;
|
|
160
|
-
editor.customConfig.lang =
|
|
153
|
+
editor.customConfig.lang = createEditorLanguage(intl);
|
|
161
154
|
for (var i in rest) {
|
|
162
155
|
editor.customConfig[i] = rest[i];
|
|
163
156
|
}
|