amis 1.2.4-beta.10 → 1.2.4-beta.11
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/components/Radios.d.ts +21 -21
- package/lib/components/Select.d.ts +239 -238
- package/lib/components/Select.js +6 -2
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Tree.d.ts +352 -84
- package/lib/components/Tree.js +71 -12
- package/lib/components/Tree.js.map +2 -2
- package/lib/components/icons.js +3 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/helper.css.map +1 -1
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +2 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +2 -0
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +2 -0
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +108 -90
- package/lib/renderers/Form/Editor.d.ts +108 -90
- package/lib/renderers/Form/InputImage.d.ts +1 -1
- package/lib/renderers/Form/InputImage.js +6 -5
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputTree.d.ts +14 -0
- package/lib/renderers/Form/InputTree.js +5 -3
- package/lib/renderers/Form/InputTree.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +6 -1
- package/lib/renderers/Form/NestedSelect.js +7 -3
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.d.ts +1 -0
- package/lib/renderers/Form/Options.js +21 -3
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +19 -1
- package/lib/renderers/Form/TreeSelect.js +10 -4
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Table/index.js +24 -16
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/store/app.js +4 -7
- package/lib/store/app.js.map +2 -2
- package/lib/store/combo.d.ts +120 -100
- package/lib/store/form.d.ts +48 -40
- package/lib/store/formItem.d.ts +2 -1
- package/lib/store/formItem.js +83 -6
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/table.d.ts +96 -80
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +8 -2
- package/lib/themes/cxd.css +8 -2
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +8 -2
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/helper.d.ts +15 -0
- package/lib/utils/helper.js +58 -4
- package/lib/utils/helper.js.map +2 -2
- package/lib/utils/markdown.js +3 -0
- package/lib/utils/markdown.js.map +2 -2
- package/package.json +5 -4
- package/schema.json +49 -21
- package/scss/_functions.scss +3 -1
- package/scss/components/_images.scss +4 -2
- package/scss/components/form/_form.scss +3 -2
- package/scss/components/form/_group.scss +4 -2
- package/scss/layout/_grid.scss +12 -10
- package/scss/themes/_cxd-variables.scss +8 -2
- package/sdk/charts.js +13 -13
- package/sdk/color-picker.js +67 -67
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +8 -8
- package/sdk/cxd.css +8 -2
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css.map +1 -0
- package/sdk/markdown.js +70 -68
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +19 -19
- package/sdk/rich-text.js +68 -68
- package/sdk/sdk-ie11.css +8 -8
- package/sdk/sdk.css +8 -2
- package/sdk/sdk.js +1132 -1130
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +2 -2
- package/sdk/tinymce.js +59 -59
- package/src/components/Select.tsx +30 -5
- package/src/components/Tree.tsx +115 -20
- package/src/components/icons.tsx +4 -0
- package/src/locale/de-DE.ts +2 -0
- package/src/locale/en-US.ts +2 -0
- package/src/locale/zh-CN.ts +2 -0
- package/src/renderers/Form/InputImage.tsx +12 -6
- package/src/renderers/Form/InputTree.tsx +30 -2
- package/src/renderers/Form/NestedSelect.tsx +15 -3
- package/src/renderers/Form/Options.tsx +46 -4
- package/src/renderers/Form/TreeSelect.tsx +36 -3
- package/src/renderers/Table/index.tsx +48 -44
- package/src/store/app.ts +4 -7
- package/src/store/formItem.ts +107 -3
- package/src/utils/helper.ts +68 -7
- package/src/utils/markdown.ts +4 -0
package/src/components/icons.tsx
CHANGED
@@ -149,6 +149,9 @@ import ExpandAltIcon from '../icons/expand-alt.svg';
|
|
149
149
|
// @ts-ignore
|
150
150
|
import CompressAltIcon from '../icons/compress-alt.svg';
|
151
151
|
|
152
|
+
// @ts-ignore
|
153
|
+
import TransparentIcon from '../icons/transparent.svg';
|
154
|
+
|
152
155
|
// 兼容原来的用法,后续不直接试用。
|
153
156
|
// @ts-ignore
|
154
157
|
export const closeIcon = <CloseIcon />;
|
@@ -245,6 +248,7 @@ registerIcon('plus-cicle', PlusCicleIcon);
|
|
245
248
|
registerIcon('ellipsis-v', EllipsisVIcon);
|
246
249
|
registerIcon('expand-alt', ExpandAltIcon);
|
247
250
|
registerIcon('compress-alt', CompressAltIcon);
|
251
|
+
registerIcon('transparent', TransparentIcon);
|
248
252
|
|
249
253
|
export function Icon({
|
250
254
|
icon,
|
package/src/locale/de-DE.ts
CHANGED
@@ -4,6 +4,8 @@ register('de-DE', {
|
|
4
4
|
'Action.countDown': '${timeLeft} warten',
|
5
5
|
'Alert.info': 'Systeminformationen',
|
6
6
|
'asc': 'Aufsteigend',
|
7
|
+
'App.home': 'Startseite',
|
8
|
+
'App.navigation': 'Navigation',
|
7
9
|
'cancel': 'Abbrechen',
|
8
10
|
'Card.dragTip': 'Obere Schaltfläche zum Sortieren ziehen',
|
9
11
|
'Card.toggleDrag': 'Zum Sortieren umschalten',
|
package/src/locale/en-US.ts
CHANGED
@@ -3,6 +3,8 @@ import {register} from '../locale';
|
|
3
3
|
register('en-US', {
|
4
4
|
'Action.countDown': 'Wait for ${timeLeft}s',
|
5
5
|
'Alert.info': 'System Info',
|
6
|
+
'App.home': 'Home',
|
7
|
+
'App.navigation': 'Navigation',
|
6
8
|
'asc': 'Asc',
|
7
9
|
'cancel': 'Cancel',
|
8
10
|
'Card.dragTip': 'Drag top button to sort',
|
package/src/locale/zh-CN.ts
CHANGED
@@ -370,7 +370,7 @@ export default class ImageControl extends React.Component<
|
|
370
370
|
file: any;
|
371
371
|
executor: () => void;
|
372
372
|
}> = [];
|
373
|
-
cropper
|
373
|
+
cropper: Cropper;
|
374
374
|
dropzone = React.createRef<any>();
|
375
375
|
frameImageRef = React.createRef<any>();
|
376
376
|
current: FileValue | FileX | null = null;
|
@@ -512,8 +512,8 @@ export default class ImageControl extends React.Component<
|
|
512
512
|
guides: true,
|
513
513
|
dragMode: 'move',
|
514
514
|
viewMode: 1,
|
515
|
-
rotatable:
|
516
|
-
scalable:
|
515
|
+
rotatable: true,
|
516
|
+
scalable: true,
|
517
517
|
...crop
|
518
518
|
};
|
519
519
|
}
|
@@ -862,7 +862,7 @@ export default class ImageControl extends React.Component<
|
|
862
862
|
}
|
863
863
|
|
864
864
|
handleCrop() {
|
865
|
-
this.cropper.
|
865
|
+
this.cropper.getCroppedCanvas().toBlob((file: File) => {
|
866
866
|
this.addFiles([file]);
|
867
867
|
this.setState({
|
868
868
|
cropFile: undefined,
|
@@ -884,7 +884,7 @@ export default class ImageControl extends React.Component<
|
|
884
884
|
}
|
885
885
|
|
886
886
|
rotatableCrop() {
|
887
|
-
this.cropper.
|
887
|
+
this.cropper.rotate(45);
|
888
888
|
}
|
889
889
|
|
890
890
|
addFiles(files: Array<FileX>) {
|
@@ -1211,7 +1211,13 @@ export default class ImageControl extends React.Component<
|
|
1211
1211
|
{cropFile ? (
|
1212
1212
|
<div className={cx('ImageControl-cropperWrapper')}>
|
1213
1213
|
<Suspense fallback={<div>...</div>}>
|
1214
|
-
<Cropper
|
1214
|
+
<Cropper
|
1215
|
+
{...crop}
|
1216
|
+
onInitialized={instance => {
|
1217
|
+
this.cropper = instance;
|
1218
|
+
}}
|
1219
|
+
src={cropFile.preview}
|
1220
|
+
/>
|
1215
1221
|
</Suspense>
|
1216
1222
|
<div className={cx('ImageControl-croperToolbar')}>
|
1217
1223
|
{crop.rotatable && (
|
@@ -56,6 +56,21 @@ export interface TreeControlSchema extends FormOptionsControl {
|
|
56
56
|
*/
|
57
57
|
rootCreatable?: boolean;
|
58
58
|
|
59
|
+
/**
|
60
|
+
* 是否开启节点路径模式
|
61
|
+
*/
|
62
|
+
enableNodePath?: boolean;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* 开启节点路径模式后,节点路径的分隔符
|
66
|
+
*/
|
67
|
+
pathSeparator?: string;
|
68
|
+
|
69
|
+
/**
|
70
|
+
* 是否显示展开线
|
71
|
+
*/
|
72
|
+
showOutline?: boolean;
|
73
|
+
|
59
74
|
deferApi?: SchemaApi;
|
60
75
|
}
|
61
76
|
|
@@ -68,7 +83,10 @@ export interface TreeProps
|
|
68
83
|
| 'className'
|
69
84
|
| 'inputClassName'
|
70
85
|
| 'descriptionClassName'
|
71
|
-
> {
|
86
|
+
> {
|
87
|
+
enableNodePath?: boolean;
|
88
|
+
pathSeparator?: string;
|
89
|
+
}
|
72
90
|
|
73
91
|
export default class TreeControl extends React.Component<TreeProps> {
|
74
92
|
static defaultProps: Partial<TreeProps> = {
|
@@ -76,7 +94,9 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
76
94
|
multiple: false,
|
77
95
|
rootLabel: '顶级',
|
78
96
|
rootValue: '',
|
79
|
-
showIcon: true
|
97
|
+
showIcon: true,
|
98
|
+
enableNodePath: false,
|
99
|
+
pathSeparator: '/'
|
80
100
|
};
|
81
101
|
|
82
102
|
reload() {
|
@@ -90,6 +110,8 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
90
110
|
treeContainerClassName,
|
91
111
|
classPrefix: ns,
|
92
112
|
value,
|
113
|
+
enableNodePath,
|
114
|
+
pathSeparator = '/',
|
93
115
|
onChange,
|
94
116
|
disabled,
|
95
117
|
joinValues,
|
@@ -125,7 +147,9 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
125
147
|
rootCreatable,
|
126
148
|
rootCreateTip,
|
127
149
|
labelField,
|
150
|
+
nodePath,
|
128
151
|
deferLoad,
|
152
|
+
expandTreeOptions,
|
129
153
|
translate: __
|
130
154
|
} = this.props;
|
131
155
|
|
@@ -160,6 +184,9 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
160
184
|
cascade={cascade}
|
161
185
|
foldedField="collapsed"
|
162
186
|
value={value || ''}
|
187
|
+
nodePath={nodePath}
|
188
|
+
enableNodePath={enableNodePath}
|
189
|
+
pathSeparator={pathSeparator}
|
163
190
|
selfDisabledAffectChildren={false}
|
164
191
|
onAdd={onAdd}
|
165
192
|
creatable={creatable}
|
@@ -174,6 +201,7 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
174
201
|
onDelete={onDelete}
|
175
202
|
bultinCUD={!addControls && !editControls}
|
176
203
|
onDeferLoad={deferLoad}
|
204
|
+
onExpandTree={expandTreeOptions}
|
177
205
|
/>
|
178
206
|
)}
|
179
207
|
</div>
|
@@ -39,12 +39,18 @@ export interface NestedSelectControlSchema extends FormOptionsControl {
|
|
39
39
|
* 弹框的 css 类
|
40
40
|
*/
|
41
41
|
menuClassName?: string;
|
42
|
+
|
43
|
+
/**
|
44
|
+
* 是否隐藏选择框中已选中节点的祖先节点的文本信息
|
45
|
+
*/
|
46
|
+
hideNodePathLabel?: boolean;
|
42
47
|
}
|
43
48
|
|
44
49
|
export interface NestedSelectProps extends OptionsControlProps {
|
45
50
|
cascade?: boolean;
|
46
51
|
noResultsText?: string;
|
47
52
|
withChildren?: boolean;
|
53
|
+
hideNodePathLabel?: boolean;
|
48
54
|
}
|
49
55
|
|
50
56
|
export interface NestedSelectState {
|
@@ -64,7 +70,8 @@ export default class NestedSelectControl extends React.Component<
|
|
64
70
|
searchPromptText: 'Select.searchPromptText',
|
65
71
|
noResultsText: 'noResult',
|
66
72
|
checkAll: true,
|
67
|
-
checkAllLabel: '全选'
|
73
|
+
checkAllLabel: '全选',
|
74
|
+
hideNodePathLabel: false
|
68
75
|
};
|
69
76
|
target: any;
|
70
77
|
input: HTMLInputElement;
|
@@ -134,7 +141,11 @@ export default class NestedSelectControl extends React.Component<
|
|
134
141
|
|
135
142
|
@autobind
|
136
143
|
renderValue(item: Option, key?: any) {
|
137
|
-
const {classnames: cx, labelField, options} = this.props;
|
144
|
+
const {classnames: cx, labelField, options, hideNodePathLabel} = this.props;
|
145
|
+
|
146
|
+
if (hideNodePathLabel) {
|
147
|
+
return item[labelField || 'label'];
|
148
|
+
}
|
138
149
|
const ancestors = getTreeAncestors(options, item, true);
|
139
150
|
|
140
151
|
return (
|
@@ -561,7 +572,8 @@ export default class NestedSelectControl extends React.Component<
|
|
561
572
|
selectedOptions,
|
562
573
|
clearable,
|
563
574
|
loading,
|
564
|
-
borderMode
|
575
|
+
borderMode,
|
576
|
+
hideNodePathLabel
|
565
577
|
} = this.props;
|
566
578
|
|
567
579
|
return (
|
@@ -14,7 +14,8 @@ import {
|
|
14
14
|
findTreeIndex,
|
15
15
|
getTree,
|
16
16
|
isEmpty,
|
17
|
-
getTreeAncestors
|
17
|
+
getTreeAncestors,
|
18
|
+
normalizeNodePath
|
18
19
|
} from '../../utils/helper';
|
19
20
|
import {reaction} from 'mobx';
|
20
21
|
import {
|
@@ -203,6 +204,7 @@ export interface OptionsControlProps
|
|
203
204
|
setLoading: (value: boolean) => void;
|
204
205
|
reloadOptions: (setError?: boolean) => void;
|
205
206
|
deferLoad: (option: Option) => void;
|
207
|
+
expandTreeOptions: (nodePathArr: any[]) => void;
|
206
208
|
onAdd?: (
|
207
209
|
idx?: number | Array<number>,
|
208
210
|
value?: any,
|
@@ -478,6 +480,8 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
478
480
|
multiple,
|
479
481
|
formItem,
|
480
482
|
valueField,
|
483
|
+
enableNodePath,
|
484
|
+
pathSeparator,
|
481
485
|
onChange
|
482
486
|
} = this.props;
|
483
487
|
|
@@ -704,7 +708,6 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
704
708
|
@autobind
|
705
709
|
deferLoad(option: Option) {
|
706
710
|
const {deferApi, source, env, formItem, data} = this.props;
|
707
|
-
|
708
711
|
const api = option.deferApi || deferApi || source;
|
709
712
|
|
710
713
|
if (!api) {
|
@@ -718,6 +721,22 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
718
721
|
formItem?.deferLoadOptions(option, api, createObject(data, option));
|
719
722
|
}
|
720
723
|
|
724
|
+
@autobind
|
725
|
+
expandTreeOptions(nodePathArr: any[]) {
|
726
|
+
const {deferApi, source, env, formItem, data} = this.props;
|
727
|
+
const api = deferApi || source;
|
728
|
+
|
729
|
+
if (!api) {
|
730
|
+
env.notify(
|
731
|
+
'error',
|
732
|
+
'请在选项中设置 `deferApi` 或者表单项中设置 `deferApi`,用来加载子选项。'
|
733
|
+
);
|
734
|
+
return;
|
735
|
+
}
|
736
|
+
|
737
|
+
formItem?.expandTreeOptions(nodePathArr, api, createObject(data));
|
738
|
+
}
|
739
|
+
|
721
740
|
@autobind
|
722
741
|
async initOptions(data: any) {
|
723
742
|
await this.reloadOptions(false, true);
|
@@ -1070,9 +1089,23 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
1070
1089
|
deleteApi,
|
1071
1090
|
creatable,
|
1072
1091
|
editable,
|
1073
|
-
removable
|
1092
|
+
removable,
|
1093
|
+
enableNodePath,
|
1094
|
+
pathSeparator,
|
1095
|
+
delimiter = ',',
|
1096
|
+
labelField = 'label',
|
1097
|
+
valueField = 'value'
|
1074
1098
|
} = this.props;
|
1075
1099
|
|
1100
|
+
const {nodePathArray, nodeValueArray} = normalizeNodePath(
|
1101
|
+
value,
|
1102
|
+
enableNodePath,
|
1103
|
+
labelField,
|
1104
|
+
valueField,
|
1105
|
+
pathSeparator,
|
1106
|
+
delimiter
|
1107
|
+
);
|
1108
|
+
|
1076
1109
|
return (
|
1077
1110
|
<Control
|
1078
1111
|
{...this.props}
|
@@ -1080,13 +1113,22 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
1080
1113
|
options={formItem ? formItem.filteredOptions : []}
|
1081
1114
|
onToggle={this.handleToggle}
|
1082
1115
|
onToggleAll={this.handleToggleAll}
|
1083
|
-
selectedOptions={
|
1116
|
+
selectedOptions={
|
1117
|
+
formItem
|
1118
|
+
? formItem.getSelectedOptions(
|
1119
|
+
value,
|
1120
|
+
enableNodePath ? nodeValueArray : undefined
|
1121
|
+
)
|
1122
|
+
: []
|
1123
|
+
}
|
1124
|
+
nodePath={nodePathArray}
|
1084
1125
|
loading={formItem ? formItem.loading : false}
|
1085
1126
|
setLoading={this.setLoading}
|
1086
1127
|
setOptions={this.setOptions}
|
1087
1128
|
syncOptions={this.syncOptions}
|
1088
1129
|
reloadOptions={this.reload}
|
1089
1130
|
deferLoad={this.deferLoad}
|
1131
|
+
expandTreeOptions={this.expandTreeOptions}
|
1090
1132
|
creatable={
|
1091
1133
|
creatable !== false && isEffectiveApi(addApi) ? true : creatable
|
1092
1134
|
}
|
@@ -67,11 +67,29 @@ export interface TreeSelectControlSchema extends FormOptionsControl {
|
|
67
67
|
* 顶级节点是否可以创建子节点
|
68
68
|
*/
|
69
69
|
rootCreatable?: boolean;
|
70
|
+
|
71
|
+
/**
|
72
|
+
* 是否隐藏选择框中已选中节点的祖先节点的文本信息
|
73
|
+
*/
|
74
|
+
hideNodePathLabel?: boolean;
|
75
|
+
|
76
|
+
/**
|
77
|
+
* 是否开启节点路径模式
|
78
|
+
*/
|
79
|
+
enableNodePath?: boolean;
|
80
|
+
|
81
|
+
/**
|
82
|
+
* 开启节点路径模式后,节点路径的分隔符
|
83
|
+
*/
|
84
|
+
pathSeparator?: string;
|
70
85
|
}
|
71
86
|
|
72
87
|
export interface TreeSelectProps extends OptionsControlProps {
|
73
88
|
placeholder?: any;
|
74
89
|
autoComplete?: Api;
|
90
|
+
hideNodePathLabel?: boolean;
|
91
|
+
enableNodePath?: boolean;
|
92
|
+
pathSeparator?: string;
|
75
93
|
}
|
76
94
|
|
77
95
|
export interface TreeSelectState {
|
@@ -95,7 +113,10 @@ export default class TreeSelectControl extends React.Component<
|
|
95
113
|
joinValues: true,
|
96
114
|
extractValue: false,
|
97
115
|
delimiter: ',',
|
98
|
-
resetValue: ''
|
116
|
+
resetValue: '',
|
117
|
+
hideNodePathLabel: false,
|
118
|
+
enableNodePath: false,
|
119
|
+
pathSeparator: '/'
|
99
120
|
};
|
100
121
|
|
101
122
|
container: React.RefObject<HTMLDivElement> = React.createRef();
|
@@ -411,7 +432,11 @@ export default class TreeSelectControl extends React.Component<
|
|
411
432
|
|
412
433
|
@autobind
|
413
434
|
renderItem(item: Option) {
|
414
|
-
const {labelField, options} = this.props;
|
435
|
+
const {labelField, options, hideNodePathLabel} = this.props;
|
436
|
+
|
437
|
+
if (hideNodePathLabel) {
|
438
|
+
return item[labelField || 'label'];
|
439
|
+
}
|
415
440
|
|
416
441
|
// 将所有祖先节点也展现出来
|
417
442
|
const ancestors = getTreeAncestors(options, item, true);
|
@@ -425,6 +450,8 @@ export default class TreeSelectControl extends React.Component<
|
|
425
450
|
renderOuter() {
|
426
451
|
const {
|
427
452
|
value,
|
453
|
+
enableNodePath,
|
454
|
+
pathSeparator = '/',
|
428
455
|
disabled,
|
429
456
|
joinValues,
|
430
457
|
extractValue,
|
@@ -450,8 +477,10 @@ export default class TreeSelectControl extends React.Component<
|
|
450
477
|
maxLength,
|
451
478
|
minLength,
|
452
479
|
labelField,
|
480
|
+
nodePath,
|
453
481
|
translate: __,
|
454
|
-
deferLoad
|
482
|
+
deferLoad,
|
483
|
+
expandTreeOptions
|
455
484
|
} = this.props;
|
456
485
|
|
457
486
|
let filtedOptions =
|
@@ -499,9 +528,13 @@ export default class TreeSelectControl extends React.Component<
|
|
499
528
|
foldedField="collapsed"
|
500
529
|
hideRoot
|
501
530
|
value={value || ''}
|
531
|
+
nodePath={nodePath}
|
532
|
+
enableNodePath={enableNodePath}
|
533
|
+
pathSeparator={pathSeparator}
|
502
534
|
maxLength={maxLength}
|
503
535
|
minLength={minLength}
|
504
536
|
onDeferLoad={deferLoad}
|
537
|
+
onExpandTree={expandTreeOptions}
|
505
538
|
/>
|
506
539
|
</PopOver>
|
507
540
|
</Overlay>
|
@@ -1967,53 +1967,57 @@ export default class Table extends React.Component<TableProps, object> {
|
|
1967
1967
|
|
1968
1968
|
const type = (column as BaseSchema).type || 'plain';
|
1969
1969
|
if (type === 'image') {
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
if (imageWidth >
|
1978
|
-
|
1979
|
-
|
1970
|
+
try {
|
1971
|
+
const imageData = await toDataURL(value);
|
1972
|
+
const imageDimensions = await getImageDimensions(imageData);
|
1973
|
+
let imageWidth = imageDimensions.width;
|
1974
|
+
let imageHeight = imageDimensions.height;
|
1975
|
+
// 限制一下图片高宽
|
1976
|
+
const imageMaxSize = 100;
|
1977
|
+
if (imageWidth > imageHeight) {
|
1978
|
+
if (imageWidth > imageMaxSize) {
|
1979
|
+
imageHeight = (imageMaxSize * imageHeight) / imageWidth;
|
1980
|
+
imageWidth = imageMaxSize;
|
1981
|
+
}
|
1982
|
+
} else {
|
1983
|
+
if (imageHeight > imageMaxSize) {
|
1984
|
+
imageWidth = (imageMaxSize * imageWidth) / imageHeight;
|
1985
|
+
imageHeight = imageMaxSize;
|
1986
|
+
}
|
1980
1987
|
}
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1988
|
+
const imageMatch = imageData.match(/data:image\/(.*);/);
|
1989
|
+
let imageExt = 'png';
|
1990
|
+
if (imageMatch) {
|
1991
|
+
imageExt = imageMatch[1];
|
1985
1992
|
}
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
imageExt != 'png' &&
|
1995
|
-
imageExt != 'jpeg' &&
|
1996
|
-
imageExt != 'gif'
|
1997
|
-
) {
|
1998
|
-
sheetRow.getCell(columIndex).value = value;
|
1999
|
-
continue;
|
2000
|
-
}
|
2001
|
-
const imageId = workbook.addImage({
|
2002
|
-
base64: imageData,
|
2003
|
-
extension: imageExt
|
2004
|
-
});
|
2005
|
-
const linkURL = getAbsoluteUrl(value);
|
2006
|
-
worksheet.addImage(imageId, {
|
2007
|
-
// 这里坐标位置是从 0 开始的,所以要减一
|
2008
|
-
tl: {col: columIndex - 1, row: rowIndex - 1},
|
2009
|
-
ext: {
|
2010
|
-
width: imageWidth,
|
2011
|
-
height: imageHeight
|
2012
|
-
},
|
2013
|
-
hyperlinks: {
|
2014
|
-
tooltip: linkURL
|
1993
|
+
// 目前 excel 只支持这些格式,所以其它格式直接输出 url
|
1994
|
+
if (
|
1995
|
+
imageExt != 'png' &&
|
1996
|
+
imageExt != 'jpeg' &&
|
1997
|
+
imageExt != 'gif'
|
1998
|
+
) {
|
1999
|
+
sheetRow.getCell(columIndex).value = value;
|
2000
|
+
continue;
|
2015
2001
|
}
|
2016
|
-
|
2002
|
+
const imageId = workbook.addImage({
|
2003
|
+
base64: imageData,
|
2004
|
+
extension: imageExt
|
2005
|
+
});
|
2006
|
+
const linkURL = getAbsoluteUrl(value);
|
2007
|
+
worksheet.addImage(imageId, {
|
2008
|
+
// 这里坐标位置是从 0 开始的,所以要减一
|
2009
|
+
tl: {col: columIndex - 1, row: rowIndex - 1},
|
2010
|
+
ext: {
|
2011
|
+
width: imageWidth,
|
2012
|
+
height: imageHeight
|
2013
|
+
},
|
2014
|
+
hyperlinks: {
|
2015
|
+
tooltip: linkURL
|
2016
|
+
}
|
2017
|
+
});
|
2018
|
+
} catch (e) {
|
2019
|
+
console.warn(e.stack);
|
2020
|
+
}
|
2017
2021
|
} else if (type == 'link') {
|
2018
2022
|
const linkURL = getAbsoluteUrl(value);
|
2019
2023
|
sheetRow.getCell(columIndex).value = {
|