dtable-ui-component 4.3.7 → 4.3.8
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/AutoNumberFormatter/index.js +11 -24
- package/lib/ButtonFormatter/index.js +29 -45
- package/lib/CTimeFormatter/index.js +17 -32
- package/lib/CheckboxEditor/index.js +42 -49
- package/lib/CheckboxFormatter/index.js +17 -30
- package/lib/CollaboratorEditor/index.js +118 -135
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
- package/lib/CollaboratorFormatter/index.js +26 -42
- package/lib/CollaboratorItem/index.js +31 -44
- package/lib/CreatorFormatter/index.js +24 -40
- package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
- package/lib/DTableCustomizeSelect/index.js +92 -103
- package/lib/DTablePopover/index.js +52 -71
- package/lib/DTablePopover/utils.js +1 -1
- package/lib/DTableRadio/index.js +9 -7
- package/lib/DTableSearchInput/index.js +89 -99
- package/lib/DTableSearchInput/utils.js +2 -2
- package/lib/DTableSelect/dtable-select-label.js +5 -3
- package/lib/DTableSelect/index.js +50 -64
- package/lib/DTableSelect/utils.js +36 -41
- package/lib/DTableSwitch/index.js +7 -5
- package/lib/DateEditor/index.js +88 -94
- package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
- package/lib/DateEditor/pc-date-editor-popover.js +70 -77
- package/lib/DateFormatter/index.js +15 -28
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
- package/lib/DigitalSignFormatter/index.js +55 -65
- package/lib/DigitalSignFormatter/utils.js +9 -8
- package/lib/DurationFormatter/index.js +14 -27
- package/lib/EditEditorButton/index.js +10 -22
- package/lib/EmailFormatter/index.js +11 -24
- package/lib/FieldDisplaySetting/field-item.js +18 -20
- package/lib/FieldDisplaySetting/index.js +41 -43
- package/lib/FileEditor/index.js +18 -29
- package/lib/FileFormatter/index.js +29 -43
- package/lib/FileItemFormatter/index.js +17 -32
- package/lib/FileItemFormatter/utils.js +5 -5
- package/lib/FileUploader/index.js +20 -33
- package/lib/FormulaFormatter/cell-value-validator.js +23 -8
- package/lib/FormulaFormatter/index.js +77 -83
- package/lib/FormulaFormatter/utils.js +27 -21
- package/lib/GeolocationFormatter/index.js +19 -32
- package/lib/HtmlLongTextFormatter/index.js +43 -52
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
- package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
- package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
- package/lib/ImageFormatter/images-lazy-load.js +71 -79
- package/lib/ImageFormatter/index.js +86 -97
- package/lib/ImageFormatter/utils.js +1 -1
- package/lib/ImagePreviewerLightbox/index.js +20 -18
- package/lib/ImagePreviewerLightbox/utils.js +3 -3
- package/lib/LastModifierFormatter/index.js +24 -40
- package/lib/LinkEditor/index.js +163 -167
- package/lib/LinkEditor/link-editor-option.js +41 -56
- package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
- package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
- package/lib/LinkFormatter/index.js +75 -77
- package/lib/LongTextFormatter/index.js +5 -3
- package/lib/MBEditorHeader/index.js +25 -38
- package/lib/MTimeFormatter/index.js +17 -32
- package/lib/ModalPortal/index.js +15 -32
- package/lib/MultipleSelectEditor/index.js +118 -136
- package/lib/MultipleSelectFormatter/index.js +24 -40
- package/lib/NotificationPopover/index.js +68 -95
- package/lib/NumberEditor/index.js +75 -82
- package/lib/NumberFormatter/index.js +15 -28
- package/lib/RateFormatter/index.js +29 -45
- package/lib/RoleStatusEditor/index.js +20 -22
- package/lib/RowExpandEmailFormatter/index.js +24 -37
- package/lib/RowExpandFileFormatter/index.js +28 -42
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
- package/lib/RowExpandFormatter/index.js +92 -96
- package/lib/RowExpandFormulaFormatter/index.js +85 -91
- package/lib/RowExpandImageFormatter/index.js +65 -82
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
- package/lib/RowExpandImageFormatter/utils.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
- package/lib/RowExpandLinkFormatter/index.js +131 -137
- package/lib/RowExpandLinkFormatter/utils.js +23 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
- package/lib/RowExpandRateFormatter/index.js +27 -42
- package/lib/RowExpandUrlFormatter/index.js +27 -40
- package/lib/SelectItem/index.js +17 -33
- package/lib/SelectOptionGroup/index.js +141 -159
- package/lib/SelectOptionGroup/option.js +24 -40
- package/lib/SimpleLongTextFormatter/index.js +55 -67
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
- package/lib/SingleSelectEditor/index.js +108 -119
- package/lib/SingleSelectFormatter/index.js +21 -37
- package/lib/TextEditor/index.js +45 -51
- package/lib/TextFormatter/index.js +17 -32
- package/lib/UrlFormatter/index.js +11 -24
- package/lib/cellFormatterFactory/index.js +8 -17
- package/lib/common/ClickOutside.js +22 -43
- package/lib/common/delete-tip.js +40 -65
- package/lib/common/modal-portal.js +15 -33
- package/lib/constants/index.js +5 -5
- package/lib/data/dtable-value.js +4 -4
- package/lib/formatterConfig/base-formatter-config.js +24 -3
- package/lib/formatterConfig/index.js +5 -4
- package/lib/lang/index.js +6 -6
- package/lib/locals/de.js +1 -1
- package/lib/locals/en.js +1 -1
- package/lib/locals/fr.js +1 -1
- package/lib/locals/zh-CN.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
- package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
- package/lib/select-editor/select-editor-option.js +41 -56
- package/lib/toaster/alert.js +73 -88
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +75 -102
- package/lib/toaster/toastManager.js +55 -91
- package/lib/toaster/toaster.js +58 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- package/package.json +4 -4
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
1
|
import React from 'react';
|
|
7
2
|
import { CellType, FORMULA_RESULT_TYPE, getFormulaDisplayString } from 'dtable-utils';
|
|
8
3
|
import BaseFormatterConfig from '../formatterConfig/base-formatter-config';
|
|
@@ -10,17 +5,10 @@ import TextFormatter from '../TextFormatter';
|
|
|
10
5
|
import { isArrayFormatColumn, isSimpleCellFormatter, isFunction, getFormulaArrayValue, convertValueToDtableLongTextValue } from './utils';
|
|
11
6
|
import cellValueValidator from './cell-value-validator';
|
|
12
7
|
import './index.css';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _this;
|
|
18
|
-
_classCallCheck(this, FormulaFormatter);
|
|
19
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
-
args[_key] = arguments[_key];
|
|
21
|
-
}
|
|
22
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
23
|
-
_this.getGridCellClassName = function (resultType) {
|
|
8
|
+
class FormulaFormatter extends React.Component {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.getGridCellClassName = resultType => {
|
|
24
12
|
switch (resultType) {
|
|
25
13
|
case FORMULA_RESULT_TYPE.NUMBER:
|
|
26
14
|
{
|
|
@@ -32,44 +20,51 @@ var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
32
20
|
}
|
|
33
21
|
}
|
|
34
22
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
value
|
|
38
|
-
column
|
|
39
|
-
collaborators
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
this.renderOtherColumnFormatter = () => {
|
|
24
|
+
const {
|
|
25
|
+
value,
|
|
26
|
+
column,
|
|
27
|
+
collaborators
|
|
28
|
+
} = this.props;
|
|
29
|
+
const {
|
|
30
|
+
data: columnData
|
|
31
|
+
} = column;
|
|
32
|
+
const {
|
|
33
|
+
array_type,
|
|
34
|
+
array_data
|
|
35
|
+
} = columnData;
|
|
43
36
|
if (!array_type || array_type === CellType.LINK) {
|
|
44
37
|
return null;
|
|
45
38
|
}
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
const Formatter = BaseFormatterConfig[array_type];
|
|
40
|
+
let formatterProps = this.getFormatterProps(array_type, array_data, collaborators);
|
|
48
41
|
if (isArrayFormatColumn(array_type)) {
|
|
49
42
|
formatterProps.value = value;
|
|
50
|
-
return
|
|
43
|
+
return this.createColumnFormatter(Formatter, formatterProps);
|
|
51
44
|
}
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
const _isSimpleCellFormatterColumn = isSimpleCellFormatter(array_type);
|
|
46
|
+
let cellValue = value;
|
|
54
47
|
if (!Array.isArray(value)) {
|
|
55
48
|
cellValue = cellValueValidator(value, array_type) ? [value] : [];
|
|
56
49
|
}
|
|
57
|
-
|
|
50
|
+
const contentItemClassName = "formula-formatter-content-item ".concat(_isSimpleCellFormatterColumn ? 'simple-cell-formatter' : '');
|
|
58
51
|
return /*#__PURE__*/React.createElement("div", {
|
|
59
52
|
className: "dtable-ui formula-formatter multiple"
|
|
60
|
-
}, cellValue.map(
|
|
53
|
+
}, cellValue.map((v, index) => {
|
|
61
54
|
formatterProps.value = v;
|
|
62
55
|
return /*#__PURE__*/React.createElement("div", {
|
|
63
56
|
className: contentItemClassName,
|
|
64
57
|
key: "formula-formatter-content-item-".concat(index)
|
|
65
|
-
},
|
|
58
|
+
}, this.createColumnFormatter(Formatter, formatterProps));
|
|
66
59
|
}));
|
|
67
60
|
};
|
|
68
|
-
|
|
61
|
+
this.getFormatterProps = (array_type, array_data, collaborators) => {
|
|
69
62
|
switch (array_type) {
|
|
70
63
|
case CellType.DURATION:
|
|
71
64
|
{
|
|
72
|
-
|
|
65
|
+
const {
|
|
66
|
+
duration_format
|
|
67
|
+
} = array_data;
|
|
73
68
|
return {
|
|
74
69
|
format: duration_format
|
|
75
70
|
};
|
|
@@ -84,60 +79,59 @@ var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
84
79
|
}
|
|
85
80
|
default:
|
|
86
81
|
{
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
return {
|
|
83
|
+
...array_data,
|
|
84
|
+
collaborators
|
|
85
|
+
};
|
|
90
86
|
}
|
|
91
87
|
}
|
|
92
88
|
};
|
|
93
|
-
return _this;
|
|
94
89
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
return /*#__PURE__*/React.createElement(TextFormatter, formatterProps);
|
|
90
|
+
createColumnFormatter(Formatter, formatterProps) {
|
|
91
|
+
if (React.isValidElement(Formatter)) {
|
|
92
|
+
return React.cloneElement(Formatter, {
|
|
93
|
+
...formatterProps
|
|
94
|
+
});
|
|
95
|
+
} else if (isFunction(Formatter)) {
|
|
96
|
+
return /*#__PURE__*/React.createElement(Formatter, formatterProps);
|
|
104
97
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return this.renderOtherColumnFormatter();
|
|
126
|
-
}
|
|
127
|
-
if (typeof value === 'object') {
|
|
128
|
-
return null;
|
|
98
|
+
return /*#__PURE__*/React.createElement(TextFormatter, formatterProps);
|
|
99
|
+
}
|
|
100
|
+
render() {
|
|
101
|
+
const {
|
|
102
|
+
containerClassName,
|
|
103
|
+
column,
|
|
104
|
+
collaborators
|
|
105
|
+
} = this.props;
|
|
106
|
+
const {
|
|
107
|
+
data
|
|
108
|
+
} = column;
|
|
109
|
+
const {
|
|
110
|
+
array_type,
|
|
111
|
+
result_type: resultType
|
|
112
|
+
} = data;
|
|
113
|
+
let value = this.props.value;
|
|
114
|
+
if (Array.isArray(value)) {
|
|
115
|
+
value = getFormulaArrayValue(value);
|
|
116
|
+
if (array_type === CellType.LONG_TEXT) {
|
|
117
|
+
value = value.map(item => convertValueToDtableLongTextValue(item));
|
|
129
118
|
}
|
|
130
|
-
var gridCellClassName = this.getGridCellClassName(resultType);
|
|
131
|
-
var formattedValue = getFormulaDisplayString(value, data, {
|
|
132
|
-
collaborators: collaborators
|
|
133
|
-
});
|
|
134
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
135
|
-
className: "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(gridCellClassName),
|
|
136
|
-
title: formattedValue,
|
|
137
|
-
"aria-label": formattedValue
|
|
138
|
-
}, formattedValue);
|
|
139
119
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
120
|
+
if (resultType === FORMULA_RESULT_TYPE.ARRAY) {
|
|
121
|
+
return this.renderOtherColumnFormatter();
|
|
122
|
+
}
|
|
123
|
+
if (typeof value === 'object') {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const gridCellClassName = this.getGridCellClassName(resultType);
|
|
127
|
+
const formattedValue = getFormulaDisplayString(value, data, {
|
|
128
|
+
collaborators
|
|
129
|
+
});
|
|
130
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(gridCellClassName),
|
|
132
|
+
title: formattedValue,
|
|
133
|
+
"aria-label": formattedValue
|
|
134
|
+
}, formattedValue);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
143
137
|
export default FormulaFormatter;
|
|
@@ -6,11 +6,11 @@ export function isSimpleCellFormatter(type) {
|
|
|
6
6
|
export function isArrayFormatColumn(columnType) {
|
|
7
7
|
return ARRAY_FORMAT_COLUMNS.includes(columnType);
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
9
|
+
export const isFunction = functionToCheck => {
|
|
10
|
+
const getType = {};
|
|
11
11
|
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export const isValidCellValue = value => {
|
|
14
14
|
if (value === undefined) return false;
|
|
15
15
|
if (value === null) return false;
|
|
16
16
|
if (value === '') return false;
|
|
@@ -18,63 +18,69 @@ export var isValidCellValue = function isValidCellValue(value) {
|
|
|
18
18
|
if (JSON.stringify(value) === '[]') return false;
|
|
19
19
|
return true;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
22
|
-
|
|
21
|
+
export const getFormulaArrayValue = function (value) {
|
|
22
|
+
let isFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
23
23
|
if (!Array.isArray(value)) {
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
26
|
if (!isFlat) {
|
|
27
27
|
return getTwoDimensionArrayValue(value);
|
|
28
28
|
}
|
|
29
|
-
return value.map(
|
|
29
|
+
return value.map(item => {
|
|
30
30
|
if (Object.prototype.toString.call(item) !== '[object Object]' || !Object.prototype.hasOwnProperty.call(item, 'display_value')) {
|
|
31
31
|
return item;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
const {
|
|
34
|
+
display_value
|
|
35
|
+
} = item;
|
|
34
36
|
if (!Array.isArray(display_value) || display_value.length === 0) {
|
|
35
37
|
return display_value;
|
|
36
38
|
}
|
|
37
|
-
return display_value.map(
|
|
39
|
+
return display_value.map(i => {
|
|
38
40
|
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
39
41
|
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) {
|
|
40
42
|
return i;
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
const {
|
|
45
|
+
display_value
|
|
46
|
+
} = i;
|
|
47
|
+
return display_value;
|
|
44
48
|
}
|
|
45
49
|
return i;
|
|
46
50
|
});
|
|
47
|
-
}).flat().filter(
|
|
48
|
-
return isValidCellValue(item);
|
|
49
|
-
});
|
|
51
|
+
}).flat().filter(item => isValidCellValue(item));
|
|
50
52
|
};
|
|
51
|
-
export
|
|
53
|
+
export const getTwoDimensionArrayValue = value => {
|
|
52
54
|
if (!Array.isArray(value)) return [];
|
|
53
|
-
return value.map(
|
|
55
|
+
return value.map(item => {
|
|
54
56
|
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
55
57
|
return item;
|
|
56
58
|
}
|
|
57
59
|
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) {
|
|
58
60
|
return item;
|
|
59
61
|
}
|
|
60
|
-
|
|
62
|
+
const {
|
|
63
|
+
display_value
|
|
64
|
+
} = item;
|
|
61
65
|
if (!Array.isArray(display_value) || display_value.length === 0) {
|
|
62
66
|
return display_value;
|
|
63
67
|
}
|
|
64
|
-
return display_value.map(
|
|
68
|
+
return display_value.map(i => {
|
|
65
69
|
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
66
70
|
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) {
|
|
67
71
|
return i;
|
|
68
72
|
}
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
const {
|
|
74
|
+
display_value
|
|
75
|
+
} = i;
|
|
76
|
+
return display_value;
|
|
71
77
|
}
|
|
72
78
|
return i;
|
|
73
79
|
});
|
|
74
80
|
});
|
|
75
81
|
};
|
|
76
|
-
export
|
|
77
|
-
|
|
82
|
+
export const convertValueToDtableLongTextValue = value => {
|
|
83
|
+
const valueType = Object.prototype.toString.call(value);
|
|
78
84
|
if (value && valueType === '[object String]') {
|
|
79
85
|
return getPreviewContent(value);
|
|
80
86
|
}
|
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import classnames from 'classnames';
|
|
7
3
|
import { getGeolocationDisplayString } from 'dtable-utils';
|
|
8
4
|
import './index.css';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
value
|
|
19
|
-
|
|
20
|
-
value = _this$props.value,
|
|
21
|
-
data = _this$props.data,
|
|
22
|
-
containerClassName = _this$props.containerClassName,
|
|
23
|
-
isBaiduMap = _this$props.isBaiduMap;
|
|
24
|
-
var className = classnames('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
|
|
25
|
-
if (typeof value !== 'object') {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
-
className: className
|
|
30
|
-
}, getGeolocationDisplayString(value, data, {
|
|
31
|
-
isBaiduMap: isBaiduMap,
|
|
32
|
-
hyphen: ' '
|
|
33
|
-
}));
|
|
5
|
+
class GeolocationFormatter extends React.Component {
|
|
6
|
+
render() {
|
|
7
|
+
let {
|
|
8
|
+
value,
|
|
9
|
+
data,
|
|
10
|
+
containerClassName,
|
|
11
|
+
isBaiduMap
|
|
12
|
+
} = this.props;
|
|
13
|
+
let className = classnames('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
|
|
14
|
+
if (typeof value !== 'object') {
|
|
15
|
+
return null;
|
|
34
16
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}(
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: className
|
|
19
|
+
}, getGeolocationDisplayString(value, data, {
|
|
20
|
+
isBaiduMap,
|
|
21
|
+
hyphen: ' '
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
38
25
|
GeolocationFormatter.defaultProps = {
|
|
39
26
|
value: {
|
|
40
27
|
province: '',
|
|
@@ -1,78 +1,69 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React, { Component } from 'react';
|
|
6
2
|
import classnames from 'classnames';
|
|
7
3
|
import { processor } from './markdown2html';
|
|
8
4
|
import './index.css';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_this.translateValue = function (props) {
|
|
17
|
-
var value = props.value;
|
|
5
|
+
class HtmlLongTextFormatter extends Component {
|
|
6
|
+
constructor(_props) {
|
|
7
|
+
super(_props);
|
|
8
|
+
this.translateValue = props => {
|
|
9
|
+
const {
|
|
10
|
+
value
|
|
11
|
+
} = props;
|
|
18
12
|
if (!value) {
|
|
19
|
-
|
|
13
|
+
this.setState({
|
|
20
14
|
innerHtml: null
|
|
21
15
|
});
|
|
22
16
|
return;
|
|
23
17
|
}
|
|
24
|
-
|
|
18
|
+
const valueType = Object.prototype.toString.call(value);
|
|
25
19
|
if (valueType === '[object String]') {
|
|
26
|
-
|
|
20
|
+
this.convertMarkdown(value);
|
|
27
21
|
return;
|
|
28
22
|
}
|
|
29
23
|
if (valueType === '[object Object]') {
|
|
30
|
-
|
|
24
|
+
this.convertMarkdown(value.text);
|
|
31
25
|
return;
|
|
32
26
|
}
|
|
33
27
|
return;
|
|
34
28
|
};
|
|
35
|
-
|
|
36
|
-
processor.process(mdFile).then(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
innerHtml
|
|
29
|
+
this.convertMarkdown = mdFile => {
|
|
30
|
+
processor.process(mdFile).then(result => {
|
|
31
|
+
let innerHtml = String(result).replace(/<a /ig, '<a target="_blank" ');
|
|
32
|
+
this.setState({
|
|
33
|
+
innerHtml
|
|
40
34
|
});
|
|
41
35
|
});
|
|
42
36
|
};
|
|
43
|
-
|
|
37
|
+
this.state = {
|
|
44
38
|
innerHtml: null
|
|
45
39
|
};
|
|
46
|
-
return _this;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
componentDidMount() {
|
|
42
|
+
this.translateValue(this.props);
|
|
43
|
+
}
|
|
44
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
45
|
+
const {
|
|
46
|
+
value
|
|
47
|
+
} = this.props;
|
|
48
|
+
if (nextProps.value !== value) {
|
|
49
|
+
this.translateValue(nextProps);
|
|
52
50
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
}
|
|
52
|
+
render() {
|
|
53
|
+
const {
|
|
54
|
+
innerHtml
|
|
55
|
+
} = this.state;
|
|
56
|
+
const {
|
|
57
|
+
containerClassName
|
|
58
|
+
} = this.props;
|
|
59
|
+
const className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
|
|
60
|
+
if (!innerHtml) return null;
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: "".concat(className, " article"),
|
|
63
|
+
dangerouslySetInnerHTML: {
|
|
64
|
+
__html: innerHtml
|
|
59
65
|
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
value: function render() {
|
|
64
|
-
var innerHtml = this.state.innerHtml;
|
|
65
|
-
var containerClassName = this.props.containerClassName;
|
|
66
|
-
var className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
|
|
67
|
-
if (!innerHtml) return null;
|
|
68
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
69
|
-
className: "".concat(className, " article"),
|
|
70
|
-
dangerouslySetInnerHTML: {
|
|
71
|
-
__html: innerHtml
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}]);
|
|
76
|
-
return HtmlLongTextFormatter;
|
|
77
|
-
}(Component);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
78
69
|
export default HtmlLongTextFormatter;
|
|
@@ -9,8 +9,8 @@ var toHTML = require('hast-util-to-html');
|
|
|
9
9
|
var sanitize = require('hast-util-sanitize');
|
|
10
10
|
var gh = require('hast-util-sanitize/lib/github');
|
|
11
11
|
var deepmerge = require('deepmerge').default;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const mathjax = require('rehype-mathjax/browser');
|
|
13
|
+
const math = require('remark-math/block');
|
|
14
14
|
var unified = require('./unified').default;
|
|
15
15
|
function stringify(config) {
|
|
16
16
|
var settings = xtend(config, this.data('settings'));
|
|
@@ -58,10 +58,10 @@ function VFile(options) {
|
|
|
58
58
|
|
|
59
59
|
/* Access full path (`~/index.min.js`). */
|
|
60
60
|
Object.defineProperty(proto, 'path', {
|
|
61
|
-
get: function
|
|
61
|
+
get: function () {
|
|
62
62
|
return this.history[this.history.length - 1];
|
|
63
63
|
},
|
|
64
|
-
set: function
|
|
64
|
+
set: function (path) {
|
|
65
65
|
assertNonEmpty(path, 'path');
|
|
66
66
|
if (path !== this.path) {
|
|
67
67
|
this.history.push(path);
|
|
@@ -71,10 +71,10 @@ Object.defineProperty(proto, 'path', {
|
|
|
71
71
|
|
|
72
72
|
/* Access parent path (`~`). */
|
|
73
73
|
Object.defineProperty(proto, 'dirname', {
|
|
74
|
-
get: function
|
|
74
|
+
get: function () {
|
|
75
75
|
return typeof this.path === 'string' ? path.dirname(this.path) : undefined;
|
|
76
76
|
},
|
|
77
|
-
set: function
|
|
77
|
+
set: function (dirname) {
|
|
78
78
|
assertPath(this.path, 'dirname');
|
|
79
79
|
this.path = path.join(dirname || '', this.basename);
|
|
80
80
|
}
|
|
@@ -82,10 +82,10 @@ Object.defineProperty(proto, 'dirname', {
|
|
|
82
82
|
|
|
83
83
|
/* Access basename (`index.min.js`). */
|
|
84
84
|
Object.defineProperty(proto, 'basename', {
|
|
85
|
-
get: function
|
|
85
|
+
get: function () {
|
|
86
86
|
return typeof this.path === 'string' ? path.basename(this.path) : undefined;
|
|
87
87
|
},
|
|
88
|
-
set: function
|
|
88
|
+
set: function (basename) {
|
|
89
89
|
assertNonEmpty(basename, 'basename');
|
|
90
90
|
assertPart(basename, 'basename');
|
|
91
91
|
this.path = path.join(this.dirname || '', basename);
|
|
@@ -94,10 +94,10 @@ Object.defineProperty(proto, 'basename', {
|
|
|
94
94
|
|
|
95
95
|
/* Access extname (`.js`). */
|
|
96
96
|
Object.defineProperty(proto, 'extname', {
|
|
97
|
-
get: function
|
|
97
|
+
get: function () {
|
|
98
98
|
return typeof this.path === 'string' ? path.extname(this.path) : undefined;
|
|
99
99
|
},
|
|
100
|
-
set: function
|
|
100
|
+
set: function (extname) {
|
|
101
101
|
var ext = extname || '';
|
|
102
102
|
assertPart(ext, 'extname');
|
|
103
103
|
assertPath(this.path, 'extname');
|
|
@@ -115,10 +115,10 @@ Object.defineProperty(proto, 'extname', {
|
|
|
115
115
|
|
|
116
116
|
/* Access stem (`index.min`). */
|
|
117
117
|
Object.defineProperty(proto, 'stem', {
|
|
118
|
-
get: function
|
|
118
|
+
get: function () {
|
|
119
119
|
return typeof this.path === 'string' ? path.basename(this.path, this.extname) : undefined;
|
|
120
120
|
},
|
|
121
|
-
set: function
|
|
121
|
+
set: function (stem) {
|
|
122
122
|
assertNonEmpty(stem, 'stem');
|
|
123
123
|
assertPart(stem, 'stem');
|
|
124
124
|
this.path = path.join(this.dirname || '', stem + (this.extname || ''));
|