dtable-ui-component 4.4.3-2 → 4.4.3-alpha1
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 +7 -14
- package/lib/ButtonFormatter/index.js +9 -16
- package/lib/CTimeFormatter/index.js +9 -16
- package/lib/CheckboxEditor/index.js +8 -15
- package/lib/CheckboxFormatter/index.js +8 -15
- package/lib/CollaboratorEditor/index.js +21 -29
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +25 -32
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +18 -25
- package/lib/CollaboratorFormatter/index.js +12 -19
- package/lib/CollaboratorItem/index.js +10 -17
- package/lib/CreatorFormatter/index.js +12 -19
- package/lib/DTableCommonAddTool/index.js +6 -13
- package/lib/DTableCustomizeCollaboratorSelect/index.js +18 -26
- package/lib/DTableCustomizeSelect/index.js +15 -23
- package/lib/DTableFiltersPopover/constants/index.js +33 -38
- package/lib/DTableFiltersPopover/index.js +31 -38
- package/lib/DTableFiltersPopover/utils/filter-item-utils.js +46 -53
- package/lib/DTableFiltersPopover/utils/index.js +99 -128
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +26 -34
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +25 -33
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +26 -34
- package/lib/DTableFiltersPopover/widgets/filter-calendar.js +26 -34
- package/lib/DTableFiltersPopover/widgets/filter-item.js +120 -128
- package/lib/DTableFiltersPopover/widgets/filter-list/index.js +18 -26
- package/lib/DTableFiltersPopover/widgets/rate-item.js +8 -15
- package/lib/DTablePopover/index.js +8 -15
- package/lib/DTablePopover/utils.js +2 -9
- package/lib/DTableRadio/index.js +10 -17
- package/lib/DTableSearchInput/index.js +13 -21
- package/lib/DTableSearchInput/utils.js +2 -9
- package/lib/DTableSelect/dtable-select-label.js +6 -13
- package/lib/DTableSelect/index.js +10 -18
- package/lib/DTableSelect/utils.js +10 -20
- package/lib/DTableSwitch/index.js +7 -14
- package/lib/DateEditor/index.js +22 -30
- package/lib/DateEditor/mb-date-editor-popover/index.js +47 -55
- package/lib/DateEditor/pc-date-editor-popover.js +20 -27
- package/lib/DateFormatter/index.js +9 -16
- package/lib/Department-editor/constants.js +1 -7
- package/lib/Department-editor/department-multiple-select/index.js +24 -32
- package/lib/Department-editor/department-single-select.js +33 -41
- package/lib/Department-editor/index.js +14 -22
- package/lib/Department-editor/selected-departments/index.js +25 -32
- package/lib/Department-editor/utils.js +3 -11
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -16
- package/lib/DigitalSignFormatter/index.js +15 -23
- package/lib/DigitalSignFormatter/utils.js +3 -11
- package/lib/DurationFormatter/index.js +9 -16
- package/lib/EditEditorButton/index.js +5 -12
- package/lib/EmailFormatter/index.js +7 -14
- package/lib/FieldDisplaySetting/field-item.js +14 -21
- package/lib/FieldDisplaySetting/index.js +19 -27
- package/lib/FileEditor/index.js +8 -15
- package/lib/FileEditor/pc-files-addition/index.js +0 -1
- package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
- package/lib/FileEditor/pc-files-preview/index.js +0 -1
- package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
- package/lib/FileFormatter/index.js +11 -19
- package/lib/FileItemFormatter/index.js +6 -14
- package/lib/FileItemFormatter/utils.js +2 -9
- package/lib/FileUploader/index.js +4 -11
- package/lib/FormulaFormatter/cell-value-validator.js +18 -24
- package/lib/FormulaFormatter/index.js +32 -39
- package/lib/FormulaFormatter/utils.js +13 -29
- package/lib/GeolocationFormatter/index.js +9 -16
- package/lib/HtmlLongTextFormatter/index.js +9 -17
- package/lib/HtmlLongTextFormatter/markdown2html.js +47 -0
- package/lib/HtmlLongTextFormatter/unified/index.js +400 -0
- package/lib/HtmlLongTextFormatter/vfile/core.js +155 -0
- package/lib/HtmlLongTextFormatter/vfile/index.js +40 -0
- package/lib/ImageFormatter/images-lazy-load.js +9 -16
- package/lib/ImageFormatter/index.js +16 -24
- package/lib/ImageFormatter/utils.js +2 -9
- package/lib/ImagePreviewerLightbox/index.js +12 -19
- package/lib/ImagePreviewerLightbox/utils.js +3 -11
- package/lib/LastModifierFormatter/index.js +12 -19
- package/lib/LinkEditor/index.js +25 -33
- package/lib/LinkEditor/link-editor-option.js +8 -15
- package/lib/LinkEditor/mb-link-editor-popover/index.js +23 -30
- package/lib/LinkEditor/pc-link-editor-popover/index.js +17 -24
- package/lib/LinkFormatter/index.js +13 -20
- package/lib/Loading/index.js +4 -11
- package/lib/LongTextFormatter/index.js +6 -13
- package/lib/MBEditorHeader/index.js +7 -14
- package/lib/MTimeFormatter/index.js +9 -16
- package/lib/ModalPortal/index.js +5 -12
- package/lib/MultipleSelectEditor/index.js +17 -25
- package/lib/MultipleSelectFormatter/index.js +10 -17
- package/lib/NotificationPopover/index.js +16 -24
- package/lib/NumberEditor/index.js +18 -25
- package/lib/NumberFormatter/index.js +9 -16
- package/lib/RateFormatter/index.js +8 -15
- package/lib/RoleStatusEditor/index.js +14 -22
- package/lib/RowExpandEmailFormatter/index.js +10 -17
- package/lib/RowExpandFileFormatter/index.js +8 -16
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +18 -27
- package/lib/RowExpandFormatter/index.js +78 -86
- package/lib/RowExpandFormulaFormatter/index.js +34 -42
- package/lib/RowExpandImageFormatter/index.js +10 -19
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +18 -27
- package/lib/RowExpandImageFormatter/utils.js +2 -9
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +7 -16
- package/lib/RowExpandLinkFormatter/index.js +37 -46
- package/lib/RowExpandLinkFormatter/utils.js +6 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +5 -12
- package/lib/RowExpandRateFormatter/index.js +8 -15
- package/lib/RowExpandUrlFormatter/index.js +14 -21
- package/lib/SelectItem/index.js +4 -12
- package/lib/SelectOptionGroup/KeyCodes.js +1 -7
- package/lib/SelectOptionGroup/index.js +33 -32
- package/lib/SelectOptionGroup/option.js +4 -19
- package/lib/SimpleLongTextFormatter/index.js +20 -27
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +1 -7
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +8 -15
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +7 -14
- package/lib/SingleSelectEditor/index.js +18 -26
- package/lib/SingleSelectFormatter/index.js +9 -16
- package/lib/TextEditor/index.js +7 -14
- package/lib/TextFormatter/index.js +7 -14
- package/lib/UrlFormatter/index.js +7 -14
- package/lib/cellFormatterFactory/index.js +4 -11
- package/lib/common/ClickOutside.js +4 -12
- package/lib/common/delete-tip.js +12 -20
- package/lib/common/modal-portal.js +5 -13
- package/lib/constants/index.js +9 -28
- package/lib/data/dtable-value.js +6 -11
- package/lib/formatterConfig/base-formatter-config.js +46 -53
- package/lib/formatterConfig/index.js +9 -16
- package/lib/hooks/common-hooks.js +4 -11
- package/lib/index.js +75 -432
- package/lib/lang/index.js +13 -24
- package/lib/locals/de.js +1 -7
- package/lib/locals/en.js +1 -7
- package/lib/locals/fr.js +1 -7
- package/lib/locals/zh-CN.js +1 -7
- package/lib/select-editor/index.js +4 -27
- package/lib/select-editor/mb-select-editor-popover/index.js +33 -41
- package/lib/select-editor/pc-select-editor-popover/index.js +19 -26
- package/lib/select-editor/select-editor-option.js +8 -15
- package/lib/toaster/alert.js +11 -18
- package/lib/toaster/index.js +3 -10
- package/lib/toaster/toast.js +8 -16
- package/lib/toaster/toastManager.js +5 -13
- package/lib/toaster/toaster.js +7 -15
- package/lib/utils/dayjs.js +4 -11
- package/lib/utils/editor-utils.js +5 -15
- package/lib/utils/event-bus.js +1 -7
- package/lib/utils/utils.js +6 -17
- package/package.json +77 -63
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _toaster = _interopRequireDefault(require("../toaster"));
|
|
11
|
-
var _editorUtils = require("../utils/editor-utils");
|
|
12
|
-
require("./index.css");
|
|
13
|
-
class UrlFormatter extends _react.default.Component {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import toaster from '../toaster';
|
|
4
|
+
import { isValidUrl, getTrimmedString } from '../utils/editor-utils';
|
|
5
|
+
import './index.css';
|
|
6
|
+
class UrlFormatter extends React.Component {
|
|
14
7
|
constructor() {
|
|
15
8
|
super(...arguments);
|
|
16
9
|
this.onOpenUrlLink = () => {
|
|
17
10
|
const {
|
|
18
11
|
value
|
|
19
12
|
} = this.props;
|
|
20
|
-
const url =
|
|
21
|
-
const validUrl =
|
|
13
|
+
const url = getTrimmedString(value);
|
|
14
|
+
const validUrl = isValidUrl(url) ? url : "http://".concat(url);
|
|
22
15
|
try {
|
|
23
16
|
let a = document.createElement('a');
|
|
24
17
|
document.body.appendChild(a);
|
|
@@ -28,7 +21,7 @@ class UrlFormatter extends _react.default.Component {
|
|
|
28
21
|
a.click();
|
|
29
22
|
document.body.removeChild(a);
|
|
30
23
|
} catch {
|
|
31
|
-
|
|
24
|
+
toaster.danger('The url is invalid');
|
|
32
25
|
}
|
|
33
26
|
};
|
|
34
27
|
}
|
|
@@ -37,15 +30,15 @@ class UrlFormatter extends _react.default.Component {
|
|
|
37
30
|
containerClassName,
|
|
38
31
|
value
|
|
39
32
|
} = this.props;
|
|
40
|
-
let classname = (
|
|
41
|
-
return /*#__PURE__*/
|
|
33
|
+
let classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
|
|
34
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
42
35
|
className: classname
|
|
43
|
-
}, /*#__PURE__*/
|
|
36
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
44
37
|
className: "url-formatter-value text-truncate"
|
|
45
|
-
}, value),
|
|
38
|
+
}, value), getTrimmedString(value) && /*#__PURE__*/React.createElement("span", {
|
|
46
39
|
className: "dtable-font dtable-icon-url row-expand-jump-link",
|
|
47
40
|
onClick: this.onOpenUrlLink
|
|
48
41
|
}));
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
|
-
|
|
44
|
+
export default UrlFormatter;
|
package/lib/SelectItem/index.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
class SelectItem extends _react.default.PureComponent {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export default class SelectItem extends React.PureComponent {
|
|
10
3
|
constructor() {
|
|
11
4
|
super(...arguments);
|
|
12
5
|
this.getStyle = (option, fontSize) => {
|
|
@@ -31,11 +24,10 @@ class SelectItem extends _react.default.PureComponent {
|
|
|
31
24
|
fontSize
|
|
32
25
|
} = this.props;
|
|
33
26
|
const style = this.getStyle(option, fontSize);
|
|
34
|
-
return /*#__PURE__*/
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
35
28
|
className: "dtable-ui select-item text-truncate",
|
|
36
29
|
style: style,
|
|
37
30
|
title: option.name
|
|
38
31
|
}, option.name);
|
|
39
32
|
}
|
|
40
|
-
}
|
|
41
|
-
exports.default = SelectItem;
|
|
33
|
+
}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _option = _interopRequireDefault(require("./option"));
|
|
11
|
-
var _DTableSearchInput = _interopRequireDefault(require("../DTableSearchInput"));
|
|
12
|
-
var _KeyCodes = _interopRequireDefault(require("./KeyCodes"));
|
|
13
|
-
var _ClickOutside = _interopRequireDefault(require("../common/ClickOutside"));
|
|
14
|
-
require("./index.css");
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import Option from './option';
|
|
3
|
+
import DTableSearchInput from '../DTableSearchInput';
|
|
4
|
+
import KeyCodes from './KeyCodes';
|
|
5
|
+
import ClickOutside from '../common/ClickOutside';
|
|
6
|
+
import './index.css';
|
|
15
7
|
const OPTION_HEIGHT = 32;
|
|
16
|
-
class SelectOptionGroup extends
|
|
8
|
+
class SelectOptionGroup extends Component {
|
|
17
9
|
constructor(props) {
|
|
18
10
|
super(props);
|
|
19
11
|
this.resetMenuStyle = () => {
|
|
@@ -39,11 +31,11 @@ class SelectOptionGroup extends _react.Component {
|
|
|
39
31
|
};
|
|
40
32
|
this.onHotKey = event => {
|
|
41
33
|
const keyCode = event.keyCode;
|
|
42
|
-
if (keyCode ===
|
|
34
|
+
if (keyCode === KeyCodes.UpArrow) {
|
|
43
35
|
this.onPressUp();
|
|
44
|
-
} else if (keyCode ===
|
|
36
|
+
} else if (keyCode === KeyCodes.DownArrow) {
|
|
45
37
|
this.onPressDown();
|
|
46
|
-
} else if (keyCode ===
|
|
38
|
+
} else if (keyCode === KeyCodes.Enter) {
|
|
47
39
|
let option = this.filterOptions && this.filterOptions[this.state.activeIndex];
|
|
48
40
|
if (option) {
|
|
49
41
|
this.props.onSelectOption(option.value);
|
|
@@ -51,7 +43,7 @@ class SelectOptionGroup extends _react.Component {
|
|
|
51
43
|
this.props.closeSelect();
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
|
-
} else if (keyCode ===
|
|
46
|
+
} else if (keyCode === KeyCodes.Tab || keyCode === KeyCodes.Escape) {
|
|
55
47
|
this.props.closeSelect();
|
|
56
48
|
}
|
|
57
49
|
};
|
|
@@ -73,6 +65,16 @@ class SelectOptionGroup extends _react.Component {
|
|
|
73
65
|
});
|
|
74
66
|
}
|
|
75
67
|
};
|
|
68
|
+
this.onMouseDown = e => {
|
|
69
|
+
const {
|
|
70
|
+
isInModal
|
|
71
|
+
} = this.props;
|
|
72
|
+
// prevent event propagation when click option or search input
|
|
73
|
+
if (isInModal) {
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
76
78
|
this.scrollContent = () => {
|
|
77
79
|
const {
|
|
78
80
|
offsetHeight,
|
|
@@ -113,23 +115,21 @@ class SelectOptionGroup extends _react.Component {
|
|
|
113
115
|
this.renderOptGroup = searchVal => {
|
|
114
116
|
let {
|
|
115
117
|
noOptionsPlaceholder,
|
|
116
|
-
onSelectOption
|
|
117
|
-
isInModal
|
|
118
|
+
onSelectOption
|
|
118
119
|
} = this.props;
|
|
119
120
|
this.filterOptions = this.props.getFilterOptions(searchVal);
|
|
120
121
|
if (this.filterOptions.length === 0) {
|
|
121
|
-
return /*#__PURE__*/
|
|
122
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
122
123
|
className: "none-search-result"
|
|
123
124
|
}, noOptionsPlaceholder);
|
|
124
125
|
}
|
|
125
126
|
return this.filterOptions.map((opt, i) => {
|
|
126
127
|
let key = opt.value.column ? opt.value.column.key : i;
|
|
127
128
|
let isActive = this.state.activeIndex === i;
|
|
128
|
-
return /*#__PURE__*/
|
|
129
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
129
130
|
key: key,
|
|
130
131
|
index: i,
|
|
131
132
|
isActive: isActive,
|
|
132
|
-
isInModal: isInModal,
|
|
133
133
|
value: opt.value,
|
|
134
134
|
onSelectOption: onSelectOption,
|
|
135
135
|
changeIndex: this.changeIndex,
|
|
@@ -193,26 +193,27 @@ class SelectOptionGroup extends _react.Component {
|
|
|
193
193
|
opacity: 0
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
-
return /*#__PURE__*/
|
|
196
|
+
return /*#__PURE__*/React.createElement(ClickOutside, {
|
|
197
197
|
onClickOutside: this.props.onClickOutside
|
|
198
|
-
}, /*#__PURE__*/
|
|
198
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
199
199
|
className: "option-group ".concat(isShowSelected ? 'pt-0' : '', " ").concat(className ? 'option-group-' + className : ''),
|
|
200
200
|
ref: ref => this.optionGroupRef = ref,
|
|
201
|
-
style: style
|
|
202
|
-
|
|
201
|
+
style: style,
|
|
202
|
+
onMouseDown: this.onMouseDown
|
|
203
|
+
}, isShowSelected && /*#__PURE__*/React.createElement("div", {
|
|
203
204
|
className: "editor-list-delete mb-2",
|
|
204
205
|
onClick: e => e.stopPropagation()
|
|
205
|
-
}, value.label || ''), searchable && /*#__PURE__*/
|
|
206
|
+
}, value.label || ''), searchable && /*#__PURE__*/React.createElement("div", {
|
|
206
207
|
className: "option-group-search"
|
|
207
|
-
}, /*#__PURE__*/
|
|
208
|
+
}, /*#__PURE__*/React.createElement(DTableSearchInput, {
|
|
208
209
|
className: "option-search-control",
|
|
209
210
|
placeholder: searchPlaceholder,
|
|
210
211
|
onChange: this.onChangeSearch,
|
|
211
212
|
autoFocus: true
|
|
212
|
-
})), /*#__PURE__*/
|
|
213
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
213
214
|
className: "option-group-content",
|
|
214
215
|
ref: ref => this.optionGroupContentRef = ref
|
|
215
216
|
}, this.renderOptGroup(searchVal))));
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
|
-
|
|
219
|
+
export default SelectOptionGroup;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
class Option extends _react.Component {
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
class Option extends Component {
|
|
10
3
|
constructor() {
|
|
11
4
|
super(...arguments);
|
|
12
5
|
this.onSelectOption = (value, event) => {
|
|
@@ -25,22 +18,14 @@ class Option extends _react.Component {
|
|
|
25
18
|
this.props.changeIndex(-1);
|
|
26
19
|
}
|
|
27
20
|
};
|
|
28
|
-
this.onMouseDown = event => {
|
|
29
|
-
if (this.props.isInModal) {
|
|
30
|
-
// prevent close modal via select option
|
|
31
|
-
event.stopPropagation();
|
|
32
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
21
|
}
|
|
36
22
|
render() {
|
|
37
|
-
return /*#__PURE__*/
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
24
|
className: this.props.isActive ? 'option option-active' : 'option',
|
|
39
25
|
onClick: this.onSelectOption.bind(this, this.props.value),
|
|
40
|
-
onMouseDown: this.onMouseDown,
|
|
41
26
|
onMouseEnter: this.onMouseEnter,
|
|
42
27
|
onMouseLeave: this.onMouseLeave
|
|
43
28
|
}, this.props.children);
|
|
44
29
|
}
|
|
45
30
|
}
|
|
46
|
-
|
|
31
|
+
export default Option;
|
|
@@ -1,51 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _normalizeLongTextValue = _interopRequireDefault(require("./normalize-long-text-value"));
|
|
11
|
-
var _LongTextPreview = _interopRequireDefault(require("./widgets/LongTextPreview"));
|
|
12
|
-
var _ModalPortal = _interopRequireDefault(require("../ModalPortal"));
|
|
13
|
-
require("./index.css");
|
|
14
|
-
class SimpleLongTextFormatter extends _react.default.Component {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import getPreviewContent from './normalize-long-text-value';
|
|
4
|
+
import LongTextPreview from './widgets/LongTextPreview';
|
|
5
|
+
import ModalPortal from '../ModalPortal';
|
|
6
|
+
import './index.css';
|
|
7
|
+
class SimpleLongTextFormatter extends React.Component {
|
|
15
8
|
constructor(props) {
|
|
16
9
|
super(props);
|
|
17
10
|
this.renderLinks = value => {
|
|
18
11
|
const links = value.links;
|
|
19
12
|
if (!Array.isArray(links) || links.length === 0) return null;
|
|
20
|
-
return /*#__PURE__*/
|
|
13
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
21
14
|
className: "long-text-links"
|
|
22
|
-
}, /*#__PURE__*/
|
|
15
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
23
16
|
className: "dtable-font dtable-icon-url"
|
|
24
17
|
}), links.length);
|
|
25
18
|
};
|
|
26
19
|
this.renderCheckList = value => {
|
|
27
20
|
const checkList = value.checklist;
|
|
28
21
|
if (!checkList || checkList.total === 0) return null;
|
|
29
|
-
return /*#__PURE__*/
|
|
22
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
30
23
|
className: "long-text-check-list"
|
|
31
|
-
}, /*#__PURE__*/
|
|
24
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
32
25
|
className: "dtable-font dtable-icon-check-square-solid ".concat(checkList.completed === checkList.total ? 'long-text-check-list-completed' : '')
|
|
33
26
|
}), "".concat(checkList.completed, "/").concat(checkList.total));
|
|
34
27
|
};
|
|
35
28
|
this.renderImages = value => {
|
|
36
29
|
const images = value.images;
|
|
37
30
|
if (!Array.isArray(images) || images.length === 0) return null;
|
|
38
|
-
return /*#__PURE__*/
|
|
31
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
39
32
|
className: "long-text-images"
|
|
40
|
-
}, /*#__PURE__*/
|
|
33
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
41
34
|
src: images[0],
|
|
42
35
|
alt: ""
|
|
43
|
-
}), /*#__PURE__*/
|
|
36
|
+
}), /*#__PURE__*/React.createElement("i", {
|
|
44
37
|
className: "image-number"
|
|
45
38
|
}, images.length > 1 ? '+' + images.length : null));
|
|
46
39
|
};
|
|
47
40
|
this.renderContent = value => {
|
|
48
|
-
return /*#__PURE__*/
|
|
41
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
49
42
|
className: "long-text-content"
|
|
50
43
|
}, value.preview);
|
|
51
44
|
};
|
|
@@ -56,7 +49,7 @@ class SimpleLongTextFormatter extends _react.default.Component {
|
|
|
56
49
|
if (!value) return {};
|
|
57
50
|
const valueType = Object.prototype.toString.call(value);
|
|
58
51
|
if (valueType === '[object String]') {
|
|
59
|
-
return (
|
|
52
|
+
return getPreviewContent(value);
|
|
60
53
|
}
|
|
61
54
|
if (valueType === '[object Object]') {
|
|
62
55
|
return value;
|
|
@@ -108,14 +101,14 @@ class SimpleLongTextFormatter extends _react.default.Component {
|
|
|
108
101
|
const {
|
|
109
102
|
containerClassName
|
|
110
103
|
} = this.props;
|
|
111
|
-
const className = (
|
|
104
|
+
const className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
|
|
112
105
|
const value = this.translateValue();
|
|
113
|
-
return /*#__PURE__*/
|
|
106
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
114
107
|
className: className,
|
|
115
108
|
onMouseEnter: this.onMouseEnter,
|
|
116
109
|
onMouseLeave: this.onMouseLeave,
|
|
117
110
|
ref: ref => this.ref = ref
|
|
118
|
-
}, this.renderLinks(value), this.renderCheckList(value), this.renderImages(value), this.renderContent(value), isPreview && /*#__PURE__*/
|
|
111
|
+
}, this.renderLinks(value), this.renderCheckList(value), this.renderImages(value), this.renderContent(value), isPreview && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(LongTextPreview, {
|
|
119
112
|
value: value,
|
|
120
113
|
formatterStyle: this.formatterStyle
|
|
121
114
|
})));
|
|
@@ -129,4 +122,4 @@ SimpleLongTextFormatter.defaultProps = {
|
|
|
129
122
|
preview: ''
|
|
130
123
|
}
|
|
131
124
|
};
|
|
132
|
-
|
|
125
|
+
export default SimpleLongTextFormatter;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
1
|
const hrefReg = /\[.+\]\(\S+\)|<img( width=[\\|/]?"(\d)+[\\|/|]?")? src="(\S+)" .?\/>|!\[\]\(\S+\)|!\[\]\((\S+)\)|<\S+>/g;
|
|
8
2
|
const imageReg1 = /^<img( width=[\\|/]?"(\d)+[\\|/|]?")? src="(\S+)" .?\/>/;
|
|
9
3
|
const imageReg2 = /^!\[\]\((\S+)\)/;
|
|
@@ -63,4 +57,4 @@ const getPreviewContent = markdownContent => {
|
|
|
63
57
|
text: markdownContent
|
|
64
58
|
};
|
|
65
59
|
};
|
|
66
|
-
|
|
60
|
+
export default getPreviewContent;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _dtableMarkdownViewer = _interopRequireDefault(require("./dtable-markdown-viewer"));
|
|
10
|
-
require("./longTextEditor.css");
|
|
11
|
-
class LongTextPreview extends _react.default.PureComponent {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import DtableMarkdownViewer from './dtable-markdown-viewer';
|
|
3
|
+
import './longTextEditor.css';
|
|
4
|
+
class LongTextPreview extends React.PureComponent {
|
|
12
5
|
constructor(props) {
|
|
13
6
|
super(props);
|
|
14
7
|
this.getStyle = () => {
|
|
@@ -50,16 +43,16 @@ class LongTextPreview extends _react.default.PureComponent {
|
|
|
50
43
|
}
|
|
51
44
|
render() {
|
|
52
45
|
let markdownContent = this.props.value ? this.props.value.text : '';
|
|
53
|
-
return /*#__PURE__*/
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
54
47
|
className: "longtext-modal-dialog longtext-preview",
|
|
55
48
|
style: this.getStyle(),
|
|
56
49
|
ref: ref => this.ref = ref
|
|
57
|
-
}, /*#__PURE__*/
|
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
58
51
|
className: "longtext-container longtext-container-scroll"
|
|
59
|
-
}, /*#__PURE__*/
|
|
52
|
+
}, /*#__PURE__*/React.createElement(DtableMarkdownViewer, {
|
|
60
53
|
markdownContent: markdownContent,
|
|
61
54
|
showTOC: false
|
|
62
55
|
})));
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
|
-
|
|
58
|
+
export default LongTextPreview;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _seafileEditor = require("@seafile/seafile-editor");
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MarkdownViewer, processor } from '@seafile/seafile-editor';
|
|
10
3
|
// Windows old Wechat (3.0 or earlier) inner core is chrome 53 and don't support ECMA6, can't use seafile-editor markdownViewer
|
|
11
4
|
// Windows new Wechat (lastest version 3.3.5) support seafile-editor markdownViewer
|
|
12
5
|
// so use dangerouslySetInnerHTML to preview
|
|
13
|
-
class DtableMarkdownViewer extends
|
|
6
|
+
class DtableMarkdownViewer extends React.PureComponent {
|
|
14
7
|
constructor(props) {
|
|
15
8
|
super(props);
|
|
16
9
|
this.checkBrowser = () => {
|
|
@@ -28,7 +21,7 @@ class DtableMarkdownViewer extends _react.default.PureComponent {
|
|
|
28
21
|
}
|
|
29
22
|
};
|
|
30
23
|
this.convertMarkdown = mdFile => {
|
|
31
|
-
|
|
24
|
+
processor.process(mdFile).then(result => {
|
|
32
25
|
let innerHtml = String(result).replace(/<a /ig, '<a target="_blank" tabindex="-1"');
|
|
33
26
|
this.setState({
|
|
34
27
|
innerHtml
|
|
@@ -43,17 +36,17 @@ class DtableMarkdownViewer extends _react.default.PureComponent {
|
|
|
43
36
|
}
|
|
44
37
|
render() {
|
|
45
38
|
if (this.isWindowsWechat) {
|
|
46
|
-
return /*#__PURE__*/
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
40
|
className: "long-text-container article",
|
|
48
41
|
dangerouslySetInnerHTML: {
|
|
49
42
|
__html: this.state.innerHtml
|
|
50
43
|
}
|
|
51
44
|
});
|
|
52
45
|
}
|
|
53
|
-
return /*#__PURE__*/
|
|
46
|
+
return /*#__PURE__*/React.createElement(MarkdownViewer, {
|
|
54
47
|
markdownContent: this.props.markdownContent,
|
|
55
48
|
showTOC: this.props.showTOC
|
|
56
49
|
});
|
|
57
50
|
}
|
|
58
51
|
}
|
|
59
|
-
|
|
52
|
+
export default DtableMarkdownViewer;
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactResponsive = _interopRequireDefault(require("react-responsive"));
|
|
11
|
-
var _lang = require("../lang");
|
|
12
|
-
var _EditEditorButton = _interopRequireDefault(require("../EditEditorButton"));
|
|
13
|
-
var _selectEditor = require("../select-editor");
|
|
14
|
-
require("./index.css");
|
|
15
|
-
class SingleSelectEditor extends _react.default.Component {
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import MediaQuery from 'react-responsive';
|
|
3
|
+
import { getLocale } from '../lang';
|
|
4
|
+
import EditEditorButton from '../EditEditorButton';
|
|
5
|
+
import { SelectEditorOption, PCSelectEditorPopover, MBSelectEditorPopover } from '../select-editor';
|
|
6
|
+
import './index.css';
|
|
7
|
+
class SingleSelectEditor extends React.Component {
|
|
16
8
|
constructor(props) {
|
|
17
9
|
super(props);
|
|
18
10
|
this.onMouseDown = e => {
|
|
@@ -123,31 +115,31 @@ class SingleSelectEditor extends _react.default.Component {
|
|
|
123
115
|
let option = this.formatOption();
|
|
124
116
|
let options = this.options;
|
|
125
117
|
let selectedOptions = option ? [option] : [];
|
|
126
|
-
return /*#__PURE__*/
|
|
118
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
127
119
|
ref: this.setEditorContainerRef,
|
|
128
120
|
className: "dtable-ui-single-select-editor"
|
|
129
|
-
}, /*#__PURE__*/
|
|
121
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
130
122
|
ref: this.setEditorRef,
|
|
131
123
|
className: option ? '' : 'd-inline-block',
|
|
132
124
|
onClick: this.onAddOptionToggle
|
|
133
|
-
}, option ? /*#__PURE__*/
|
|
125
|
+
}, option ? /*#__PURE__*/React.createElement("div", {
|
|
134
126
|
className: "dtable-ui-single-select-option-container"
|
|
135
|
-
}, /*#__PURE__*/
|
|
127
|
+
}, /*#__PURE__*/React.createElement(SelectEditorOption, {
|
|
136
128
|
option: option
|
|
137
|
-
})) : /*#__PURE__*/
|
|
138
|
-
text:
|
|
139
|
-
})), isPopoverShow && /*#__PURE__*/
|
|
129
|
+
})) : /*#__PURE__*/React.createElement(EditEditorButton, {
|
|
130
|
+
text: getLocale('Add_an_option')
|
|
131
|
+
})), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
|
|
140
132
|
query: "(min-width: 768px)"
|
|
141
|
-
}, /*#__PURE__*/
|
|
133
|
+
}, /*#__PURE__*/React.createElement(PCSelectEditorPopover, {
|
|
142
134
|
popoverPosition: popoverPosition,
|
|
143
135
|
options: options,
|
|
144
136
|
selectedOptions: selectedOptions,
|
|
145
137
|
onOptionItemToggle: this.onOptionItemToggle,
|
|
146
138
|
isSupportNewOption: this.props.isSupportNewOption,
|
|
147
139
|
onAddNewOption: this.onAddNewOption
|
|
148
|
-
})), /*#__PURE__*/
|
|
140
|
+
})), /*#__PURE__*/React.createElement(MediaQuery, {
|
|
149
141
|
query: "(max-width: 767.8px)"
|
|
150
|
-
}, /*#__PURE__*/
|
|
142
|
+
}, /*#__PURE__*/React.createElement(MBSelectEditorPopover, {
|
|
151
143
|
isReadOnly: this.props.isReadOnly,
|
|
152
144
|
value: [this.state.newValue],
|
|
153
145
|
column: this.props.column,
|
|
@@ -164,4 +156,4 @@ SingleSelectEditor.defaultProps = {
|
|
|
164
156
|
isReadOnly: false,
|
|
165
157
|
value: ''
|
|
166
158
|
};
|
|
167
|
-
|
|
159
|
+
export default SingleSelectEditor;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _SelectItem = _interopRequireDefault(require("../SelectItem"));
|
|
11
|
-
require("./index.css");
|
|
12
|
-
class SingleSelectFormatter extends _react.default.PureComponent {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import SelectItem from '../SelectItem';
|
|
4
|
+
import './index.css';
|
|
5
|
+
class SingleSelectFormatter extends React.PureComponent {
|
|
13
6
|
constructor() {
|
|
14
7
|
super(...arguments);
|
|
15
8
|
this.getOption = () => {
|
|
@@ -20,7 +13,7 @@ class SingleSelectFormatter extends _react.default.PureComponent {
|
|
|
20
13
|
} = this.props;
|
|
21
14
|
let option = options.find(item => item.id === value || item.name === value);
|
|
22
15
|
if (option) {
|
|
23
|
-
return /*#__PURE__*/
|
|
16
|
+
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
24
17
|
option: option,
|
|
25
18
|
fontSize: fontSize
|
|
26
19
|
});
|
|
@@ -32,8 +25,8 @@ class SingleSelectFormatter extends _react.default.PureComponent {
|
|
|
32
25
|
containerClassName,
|
|
33
26
|
value
|
|
34
27
|
} = this.props;
|
|
35
|
-
let classname = (
|
|
36
|
-
return /*#__PURE__*/
|
|
28
|
+
let classname = classnames('dtable-ui cell-formatter-container single-select-formatter', containerClassName);
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
37
30
|
className: classname
|
|
38
31
|
}, value ? this.getOption() : '');
|
|
39
32
|
}
|
|
@@ -41,4 +34,4 @@ class SingleSelectFormatter extends _react.default.PureComponent {
|
|
|
41
34
|
SingleSelectFormatter.defaultProps = {
|
|
42
35
|
options: []
|
|
43
36
|
};
|
|
44
|
-
|
|
37
|
+
export default SingleSelectFormatter;
|
package/lib/TextEditor/index.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
10
|
-
var _reactstrap = require("reactstrap");
|
|
11
|
-
class TextEditor extends _react.default.Component {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import isHotkey from 'is-hotkey';
|
|
3
|
+
import { Input } from 'reactstrap';
|
|
4
|
+
class TextEditor extends React.Component {
|
|
12
5
|
constructor(props) {
|
|
13
6
|
super(props);
|
|
14
7
|
this.onCommit = () => {
|
|
@@ -37,7 +30,7 @@ class TextEditor extends _react.default.Component {
|
|
|
37
30
|
selectionEnd,
|
|
38
31
|
value
|
|
39
32
|
} = event.currentTarget;
|
|
40
|
-
if ((
|
|
33
|
+
if (isHotkey('enter', event)) {
|
|
41
34
|
event.preventDefault();
|
|
42
35
|
event.target.blur();
|
|
43
36
|
} else if (event.keyCode === 37 && selectionStart === 0 || event.keyCode === 39 && selectionEnd === value.length) {
|
|
@@ -61,7 +54,7 @@ class TextEditor extends _react.default.Component {
|
|
|
61
54
|
const {
|
|
62
55
|
isReadOnly
|
|
63
56
|
} = this.props;
|
|
64
|
-
return /*#__PURE__*/
|
|
57
|
+
return /*#__PURE__*/React.createElement(Input, {
|
|
65
58
|
ref: this.setInputRef,
|
|
66
59
|
type: "text",
|
|
67
60
|
value: this.state.newValue,
|
|
@@ -78,4 +71,4 @@ TextEditor.defaultProps = {
|
|
|
78
71
|
isReadOnly: false,
|
|
79
72
|
value: ''
|
|
80
73
|
};
|
|
81
|
-
|
|
74
|
+
export default TextEditor;
|