dtable-ui-component 0.3.20 → 0.3.21
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 +2 -9
- package/lib/ButtonFormatter/index.js +4 -17
- package/lib/CTimeFormatter/index.js +2 -15
- package/lib/CheckboxEditor/index.js +0 -13
- package/lib/CheckboxFormatter/index.js +2 -11
- package/lib/CollaboratorEditor/index.js +6 -44
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +2 -27
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +2 -20
- package/lib/CollaboratorFormatter/index.js +6 -23
- package/lib/CollaboratorItem/index.js +2 -14
- package/lib/CreatorFormatter/index.js +6 -22
- package/lib/DTableCustomizeCollaboratorSelect/index.js +16 -37
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +6 -5
- package/lib/DTableCustomizeSelect/index.js +14 -37
- package/lib/DTablePopover/index.js +8 -26
- package/lib/DTableRadio/index.js +0 -2
- package/lib/DTableSearchInput/index.js +12 -36
- package/lib/DTableSelect/index.js +13 -27
- package/lib/DTableSwitch/index.js +4 -6
- package/lib/DateEditor/index.js +8 -27
- package/lib/DateEditor/mb-date-editor-popover/index.js +8 -42
- package/lib/DateEditor/pc-date-editor-popover.js +7 -27
- package/lib/DateFormatter/index.js +3 -12
- package/lib/DigitalSignFormatter/index.js +8 -26
- package/lib/DigitalSignFormatter/utils.js +3 -6
- package/lib/DurationFormatter/index.js +3 -10
- package/lib/EditEditorButton/index.js +0 -7
- package/lib/EmailFormatter/index.js +2 -9
- package/lib/FieldDisplaySetting/field-item.js +6 -20
- package/lib/FieldDisplaySetting/index.js +8 -13
- package/lib/FileEditor/index.js +0 -8
- package/lib/FileFormatter/index.js +3 -14
- package/lib/FileItemFormatter/index.js +0 -13
- package/lib/FileItemFormatter/utils.js +0 -6
- package/lib/FileUploader/index.js +0 -16
- package/lib/FormulaFormatter/cell-value-validator.js +0 -10
- package/lib/FormulaFormatter/index.js +8 -38
- package/lib/FormulaFormatter/utils.js +0 -17
- package/lib/GeolocationFormatter/index.js +4 -13
- package/lib/HtmlLongTextFormatter/index.js +0 -21
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -17
- package/lib/HtmlLongTextFormatter/unified/index.js +29 -102
- package/lib/HtmlLongTextFormatter/vfile/core.js +13 -32
- package/lib/HtmlLongTextFormatter/vfile/index.js +4 -11
- package/lib/ImageFormatter/images-lazy-load.js +5 -35
- package/lib/ImageFormatter/index.js +7 -34
- package/lib/ImageFormatter/utils.js +0 -1
- package/lib/ImagePreviewerLightbox/index.js +11 -13
- package/lib/LastModifierFormatter/index.js +6 -22
- package/lib/LinkEditor/index.js +23 -69
- package/lib/LinkEditor/link-editor-option.js +2 -18
- package/lib/LinkEditor/mb-link-editor-popover/index.js +2 -27
- package/lib/LinkEditor/pc-link-editor-popover/index.js +2 -20
- package/lib/LinkFormatter/index.js +12 -35
- package/lib/LongTextFormatter/index.js +2 -6
- package/lib/MBEditorHeader/index.js +6 -13
- package/lib/MTimeFormatter/index.js +2 -15
- package/lib/ModalPortal/index.js +0 -8
- package/lib/MultipleSelectEditor/index.js +4 -42
- package/lib/MultipleSelectFormatter/index.js +4 -17
- package/lib/NotificationPopover/index.js +3 -22
- package/lib/NumberEditor/index.js +7 -35
- package/lib/NumberFormatter/index.js +3 -12
- package/lib/RateFormatter/index.js +10 -25
- package/lib/RowExpandEmailFormatter/index.js +2 -13
- package/lib/RowExpandFileFormatter/index.js +6 -15
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +6 -24
- package/lib/RowExpandFormatter/index.js +10 -60
- package/lib/RowExpandFormulaFormatter/index.js +10 -41
- package/lib/RowExpandImageFormatter/index.js +8 -27
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +11 -27
- package/lib/RowExpandImageFormatter/utils.js +0 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +4 -35
- package/lib/RowExpandLinkFormatter/index.js +6 -28
- package/lib/RowExpandLinkFormatter/utils.js +0 -4
- package/lib/RowExpandLinkFormatter/value-display-utils.js +2 -2
- package/lib/RowExpandRateFormatter/index.js +8 -23
- package/lib/RowExpandUrlFormatter/index.js +2 -14
- package/lib/SelectItem/index.js +2 -13
- package/lib/SelectOptionGroup/index.js +13 -42
- package/lib/SelectOptionGroup/option.js +0 -14
- package/lib/SimpleLongTextFormatter/index.js +0 -26
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +2 -12
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +1 -16
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +0 -17
- package/lib/SingleSelectEditor/index.js +4 -37
- package/lib/SingleSelectFormatter/index.js +5 -17
- package/lib/TextEditor/index.js +3 -22
- package/lib/TextFormatter/index.js +2 -15
- package/lib/UrlFormatter/index.js +2 -9
- package/lib/cellFormatterFactory/index.js +0 -5
- package/lib/common/delete-tip.js +4 -16
- package/lib/common/modal-portal.js +0 -8
- package/lib/formatterConfig/base-formatter-config.js +0 -2
- package/lib/formatterConfig/index.js +0 -4
- package/lib/index.js +12 -6
- package/lib/lang/index.js +0 -7
- package/lib/select-editor/mb-select-editor-popover/index.js +6 -38
- package/lib/select-editor/pc-select-editor-popover/index.js +3 -25
- package/lib/select-editor/select-editor-option.js +2 -17
- package/lib/toaster/alert.js +0 -12
- package/lib/toaster/toast.js +1 -22
- package/lib/toaster/toastManager.js +7 -30
- package/lib/toaster/toaster.js +4 -15
- package/lib/utils/editor-utils.js +0 -20
- package/lib/utils/utils.js +2 -5
- package/package.json +5 -5
|
@@ -7,43 +7,32 @@ import Option from './option';
|
|
|
7
7
|
import DTableSearchInput from '../DTableSearchInput';
|
|
8
8
|
import KeyCodes from './KeyCodes';
|
|
9
9
|
var OPTION_HEIGHT = 32;
|
|
10
|
-
|
|
11
10
|
var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
12
11
|
_inherits(SelectOptionGroup, _Component);
|
|
13
|
-
|
|
14
12
|
var _super = _createSuper(SelectOptionGroup);
|
|
15
|
-
|
|
16
13
|
function SelectOptionGroup(props) {
|
|
17
14
|
var _this;
|
|
18
|
-
|
|
19
15
|
_classCallCheck(this, SelectOptionGroup);
|
|
20
|
-
|
|
21
16
|
_this = _super.call(this, props);
|
|
22
|
-
|
|
23
17
|
_this.resetMenuStyle = function () {
|
|
24
18
|
var _this$optionGroupRef$ = _this.optionGroupRef.getBoundingClientRect(),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
top = _this$optionGroupRef$.top,
|
|
20
|
+
height = _this$optionGroupRef$.height;
|
|
28
21
|
if (height + top > window.innerHeight) {
|
|
29
22
|
var borderWidth = 2;
|
|
30
23
|
_this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';
|
|
31
24
|
}
|
|
32
25
|
};
|
|
33
|
-
|
|
34
26
|
_this.onHotKey = function (event) {
|
|
35
27
|
var keyCode = event.keyCode;
|
|
36
|
-
|
|
37
28
|
if (keyCode === KeyCodes.UpArrow) {
|
|
38
29
|
_this.onPressUp();
|
|
39
30
|
} else if (keyCode === KeyCodes.DownArrow) {
|
|
40
31
|
_this.onPressDown();
|
|
41
32
|
} else if (keyCode === KeyCodes.Enter) {
|
|
42
33
|
var option = _this.filterOptions && _this.filterOptions[_this.state.activeIndex];
|
|
43
|
-
|
|
44
34
|
if (option) {
|
|
45
35
|
_this.props.onSelectOption(option.value);
|
|
46
|
-
|
|
47
36
|
if (!_this.props.supportMultipleSelect) {
|
|
48
37
|
_this.props.closeSelect();
|
|
49
38
|
}
|
|
@@ -52,7 +41,6 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
52
41
|
_this.props.closeSelect();
|
|
53
42
|
}
|
|
54
43
|
};
|
|
55
|
-
|
|
56
44
|
_this.onPressUp = function () {
|
|
57
45
|
if (_this.state.activeIndex > 0) {
|
|
58
46
|
_this.setState({
|
|
@@ -62,7 +50,6 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
62
50
|
});
|
|
63
51
|
}
|
|
64
52
|
};
|
|
65
|
-
|
|
66
53
|
_this.onPressDown = function () {
|
|
67
54
|
if (_this.filterOptions && _this.state.activeIndex < _this.filterOptions.length - 1) {
|
|
68
55
|
_this.setState({
|
|
@@ -72,34 +59,28 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
72
59
|
});
|
|
73
60
|
}
|
|
74
61
|
};
|
|
75
|
-
|
|
76
62
|
_this.onClick = function (e) {
|
|
77
63
|
if (_this.props.stopClickEvent && _this.optionGroupRef.contains(e.target) && !e.target.className.includes('dtable-font')) {
|
|
78
64
|
e.stopPropagation();
|
|
79
65
|
}
|
|
80
66
|
};
|
|
81
|
-
|
|
82
67
|
_this.scrollContent = function () {
|
|
83
68
|
var _this$optionGroupCont = _this.optionGroupContentRef,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
offsetHeight = _this$optionGroupCont.offsetHeight,
|
|
70
|
+
scrollTop = _this$optionGroupCont.scrollTop;
|
|
87
71
|
if (_this.state.activeIndex * OPTION_HEIGHT < scrollTop) {
|
|
88
72
|
_this.optionGroupContentRef.scrollTop = scrollTop - OPTION_HEIGHT;
|
|
89
73
|
} else if (_this.state.activeIndex * OPTION_HEIGHT > offsetHeight + scrollTop) {
|
|
90
74
|
_this.optionGroupContentRef.scrollTop = scrollTop + OPTION_HEIGHT;
|
|
91
75
|
}
|
|
92
76
|
};
|
|
93
|
-
|
|
94
77
|
_this.changeIndex = function (index) {
|
|
95
78
|
_this.setState({
|
|
96
79
|
activeIndex: index
|
|
97
80
|
});
|
|
98
81
|
};
|
|
99
|
-
|
|
100
82
|
_this.onChangeSearch = function (searchVal) {
|
|
101
83
|
var value = searchVal || '';
|
|
102
|
-
|
|
103
84
|
if (value !== _this.state.searchVal) {
|
|
104
85
|
_this.setState({
|
|
105
86
|
searchVal: value,
|
|
@@ -107,19 +88,16 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
107
88
|
});
|
|
108
89
|
}
|
|
109
90
|
};
|
|
110
|
-
|
|
111
91
|
_this.renderOptGroup = function (searchVal) {
|
|
112
92
|
var _this$props = _this.props,
|
|
113
|
-
|
|
114
|
-
|
|
93
|
+
noOptionsPlaceholder = _this$props.noOptionsPlaceholder,
|
|
94
|
+
onSelectOption = _this$props.onSelectOption;
|
|
115
95
|
_this.filterOptions = _this.props.getFilterOptions(searchVal);
|
|
116
|
-
|
|
117
96
|
if (_this.filterOptions === 0) {
|
|
118
97
|
return /*#__PURE__*/React.createElement("div", {
|
|
119
98
|
className: "none-search-result"
|
|
120
99
|
}, noOptionsPlaceholder);
|
|
121
100
|
}
|
|
122
|
-
|
|
123
101
|
return _this.filterOptions.map(function (opt, i) {
|
|
124
102
|
var key = opt.value.column ? opt.value.column.key : i;
|
|
125
103
|
var isActive = _this.state.activeIndex === i;
|
|
@@ -134,7 +112,6 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
134
112
|
}, opt.label);
|
|
135
113
|
});
|
|
136
114
|
};
|
|
137
|
-
|
|
138
115
|
_this.state = {
|
|
139
116
|
searchVal: '',
|
|
140
117
|
activeIndex: -1
|
|
@@ -142,7 +119,6 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
142
119
|
_this.filterOptions = null;
|
|
143
120
|
return _this;
|
|
144
121
|
}
|
|
145
|
-
|
|
146
122
|
_createClass(SelectOptionGroup, [{
|
|
147
123
|
key: "componentDidMount",
|
|
148
124
|
value: function componentDidMount() {
|
|
@@ -161,21 +137,19 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
161
137
|
key: "render",
|
|
162
138
|
value: function render() {
|
|
163
139
|
var _this2 = this;
|
|
164
|
-
|
|
165
140
|
var _this$props2 = this.props,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
141
|
+
searchable = _this$props2.searchable,
|
|
142
|
+
searchPlaceholder = _this$props2.searchPlaceholder,
|
|
143
|
+
top = _this$props2.top,
|
|
144
|
+
left = _this$props2.left,
|
|
145
|
+
minWidth = _this$props2.minWidth,
|
|
146
|
+
value = _this$props2.value,
|
|
147
|
+
isShowSelected = _this$props2.isShowSelected;
|
|
173
148
|
var searchVal = this.state.searchVal;
|
|
174
149
|
var style = {
|
|
175
150
|
top: top || 0,
|
|
176
151
|
left: left || 0
|
|
177
152
|
};
|
|
178
|
-
|
|
179
153
|
if (minWidth) {
|
|
180
154
|
style = {
|
|
181
155
|
top: top || 0,
|
|
@@ -183,7 +157,6 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
183
157
|
minWidth: minWidth
|
|
184
158
|
};
|
|
185
159
|
}
|
|
186
|
-
|
|
187
160
|
return /*#__PURE__*/React.createElement("div", {
|
|
188
161
|
className: "option-group ".concat(isShowSelected ? 'pt-0' : ''),
|
|
189
162
|
ref: function ref(_ref2) {
|
|
@@ -210,8 +183,6 @@ var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
|
210
183
|
}, this.renderOptGroup(searchVal)));
|
|
211
184
|
}
|
|
212
185
|
}]);
|
|
213
|
-
|
|
214
186
|
return SelectOptionGroup;
|
|
215
187
|
}(Component);
|
|
216
|
-
|
|
217
188
|
export default SelectOptionGroup;
|
|
@@ -3,44 +3,32 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React, { Component } from 'react';
|
|
6
|
-
|
|
7
6
|
var Option = /*#__PURE__*/function (_Component) {
|
|
8
7
|
_inherits(Option, _Component);
|
|
9
|
-
|
|
10
8
|
var _super = _createSuper(Option);
|
|
11
|
-
|
|
12
9
|
function Option() {
|
|
13
10
|
var _this;
|
|
14
|
-
|
|
15
11
|
_classCallCheck(this, Option);
|
|
16
|
-
|
|
17
12
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
13
|
args[_key] = arguments[_key];
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
22
|
-
|
|
23
16
|
_this.onSelectOption = function (value, event) {
|
|
24
17
|
_this.props.onSelectOption(value, event);
|
|
25
18
|
};
|
|
26
|
-
|
|
27
19
|
_this.onClick = function (event) {
|
|
28
20
|
if (_this.props.supportMultipleSelect) {
|
|
29
21
|
event.stopPropagation();
|
|
30
22
|
}
|
|
31
23
|
};
|
|
32
|
-
|
|
33
24
|
_this.onMouseEnter = function () {
|
|
34
25
|
_this.props.changeIndex(_this.props.index);
|
|
35
26
|
};
|
|
36
|
-
|
|
37
27
|
_this.onMouseLeave = function () {
|
|
38
28
|
_this.props.changeIndex(-1);
|
|
39
29
|
};
|
|
40
|
-
|
|
41
30
|
return _this;
|
|
42
31
|
}
|
|
43
|
-
|
|
44
32
|
_createClass(Option, [{
|
|
45
33
|
key: "render",
|
|
46
34
|
value: function render() {
|
|
@@ -53,8 +41,6 @@ var Option = /*#__PURE__*/function (_Component) {
|
|
|
53
41
|
}, this.props.children);
|
|
54
42
|
}
|
|
55
43
|
}]);
|
|
56
|
-
|
|
57
44
|
return Option;
|
|
58
45
|
}(Component);
|
|
59
|
-
|
|
60
46
|
export default Option;
|
|
@@ -8,19 +8,13 @@ import getPreviewContent from './normalize-long-text-value';
|
|
|
8
8
|
import LongTextPreview from './widgets/LongTextPreview';
|
|
9
9
|
import ModalPortal from '../ModalPortal';
|
|
10
10
|
import './index.css';
|
|
11
|
-
|
|
12
11
|
var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
13
12
|
_inherits(SimpleLongTextFormatter, _React$Component);
|
|
14
|
-
|
|
15
13
|
var _super = _createSuper(SimpleLongTextFormatter);
|
|
16
|
-
|
|
17
14
|
function SimpleLongTextFormatter(props) {
|
|
18
15
|
var _this;
|
|
19
|
-
|
|
20
16
|
_classCallCheck(this, SimpleLongTextFormatter);
|
|
21
|
-
|
|
22
17
|
_this = _super.call(this, props);
|
|
23
|
-
|
|
24
18
|
_this.renderLinks = function (value) {
|
|
25
19
|
var links = value.links;
|
|
26
20
|
if (!Array.isArray(links) || links.length === 0) return null;
|
|
@@ -30,7 +24,6 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
30
24
|
className: "dtable-font dtable-icon-url"
|
|
31
25
|
}), links.length);
|
|
32
26
|
};
|
|
33
|
-
|
|
34
27
|
_this.renderCheckList = function (value) {
|
|
35
28
|
var checkList = value.checklist;
|
|
36
29
|
if (!checkList || checkList.total === 0) return null;
|
|
@@ -40,7 +33,6 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
40
33
|
className: "dtable-font dtable-icon-check-square-solid ".concat(checkList.completed === checkList.total ? 'long-text-check-list-completed' : '')
|
|
41
34
|
}), "".concat(checkList.completed, "/").concat(checkList.total));
|
|
42
35
|
};
|
|
43
|
-
|
|
44
36
|
_this.renderImages = function (value) {
|
|
45
37
|
var images = value.images;
|
|
46
38
|
if (!Array.isArray(images) || images.length === 0) return null;
|
|
@@ -53,74 +45,59 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
53
45
|
className: "image-number"
|
|
54
46
|
}, images.length > 1 ? '+' + images.length : null));
|
|
55
47
|
};
|
|
56
|
-
|
|
57
48
|
_this.renderContent = function (value) {
|
|
58
49
|
return /*#__PURE__*/React.createElement("span", {
|
|
59
50
|
className: "long-text-content"
|
|
60
51
|
}, value.preview);
|
|
61
52
|
};
|
|
62
|
-
|
|
63
53
|
_this.translateValue = function () {
|
|
64
54
|
var value = _this.props.value;
|
|
65
55
|
if (!value) return {};
|
|
66
56
|
var valueType = Object.prototype.toString.call(value);
|
|
67
|
-
|
|
68
57
|
if (valueType === '[object String]') {
|
|
69
58
|
return getPreviewContent(value);
|
|
70
59
|
}
|
|
71
|
-
|
|
72
60
|
if (valueType === '[object Object]') {
|
|
73
61
|
return value;
|
|
74
62
|
}
|
|
75
|
-
|
|
76
63
|
return {};
|
|
77
64
|
};
|
|
78
|
-
|
|
79
65
|
_this.clearTimer = function () {
|
|
80
66
|
if (_this.timer) {
|
|
81
67
|
clearTimeout(_this.timer);
|
|
82
68
|
_this.timer = null;
|
|
83
69
|
}
|
|
84
70
|
};
|
|
85
|
-
|
|
86
71
|
_this.onMouseEnter = function () {
|
|
87
72
|
// in case that there is no `modal-wrapper`
|
|
88
73
|
if (!document.getElementById('modal-wrapper')) {
|
|
89
74
|
return;
|
|
90
75
|
}
|
|
91
|
-
|
|
92
76
|
_this.clearTimer();
|
|
93
|
-
|
|
94
77
|
if (_this.props.value) {
|
|
95
78
|
_this.timer = setTimeout(function () {
|
|
96
79
|
var style = _this.ref.getBoundingClientRect();
|
|
97
|
-
|
|
98
80
|
_this.formatterStyle = style;
|
|
99
|
-
|
|
100
81
|
_this.setState({
|
|
101
82
|
isPreview: true
|
|
102
83
|
});
|
|
103
84
|
}, 2000);
|
|
104
85
|
}
|
|
105
86
|
};
|
|
106
|
-
|
|
107
87
|
_this.onMouseLeave = function () {
|
|
108
88
|
_this.clearTimer();
|
|
109
|
-
|
|
110
89
|
if (_this.state.isPreview) {
|
|
111
90
|
_this.setState({
|
|
112
91
|
isPreview: false
|
|
113
92
|
});
|
|
114
93
|
}
|
|
115
94
|
};
|
|
116
|
-
|
|
117
95
|
_this.formatterStyle = null;
|
|
118
96
|
_this.state = {
|
|
119
97
|
isPreview: false
|
|
120
98
|
};
|
|
121
99
|
return _this;
|
|
122
100
|
}
|
|
123
|
-
|
|
124
101
|
_createClass(SimpleLongTextFormatter, [{
|
|
125
102
|
key: "componentWillUnmount",
|
|
126
103
|
value: function componentWillUnmount() {
|
|
@@ -130,7 +107,6 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
130
107
|
key: "render",
|
|
131
108
|
value: function render() {
|
|
132
109
|
var _this2 = this;
|
|
133
|
-
|
|
134
110
|
var isPreview = this.state.isPreview;
|
|
135
111
|
var containerClassName = this.props.containerClassName;
|
|
136
112
|
var className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
|
|
@@ -148,10 +124,8 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
148
124
|
})));
|
|
149
125
|
}
|
|
150
126
|
}]);
|
|
151
|
-
|
|
152
127
|
return SimpleLongTextFormatter;
|
|
153
128
|
}(React.Component);
|
|
154
|
-
|
|
155
129
|
SimpleLongTextFormatter.defaultProps = {
|
|
156
130
|
value: {
|
|
157
131
|
text: '',
|
|
@@ -3,7 +3,6 @@ var imageReg1 = /^<img( width=[\\|/]?"(\d)+[\\|/|]?")? src="(\S+)" .?\/>/;
|
|
|
3
3
|
var imageReg2 = /^!\[\]\((\S+)\)/;
|
|
4
4
|
var linkReg1 = /^\[.+\]\(\S+\)/;
|
|
5
5
|
var linkReg2 = /^<\S+>$/;
|
|
6
|
-
|
|
7
6
|
var getLinks = function getLinks(hrefList) {
|
|
8
7
|
var hrefObj = {
|
|
9
8
|
links: [],
|
|
@@ -15,7 +14,6 @@ var getLinks = function getLinks(hrefList) {
|
|
|
15
14
|
} else {
|
|
16
15
|
var imageSrcList = href.match(imageReg1);
|
|
17
16
|
var imageSrcList1 = href.match(imageReg2);
|
|
18
|
-
|
|
19
17
|
if (imageSrcList) {
|
|
20
18
|
hrefObj.images.push(imageSrcList[3]);
|
|
21
19
|
} else if (imageSrcList1) {
|
|
@@ -25,11 +23,9 @@ var getLinks = function getLinks(hrefList) {
|
|
|
25
23
|
});
|
|
26
24
|
return hrefObj;
|
|
27
25
|
};
|
|
28
|
-
|
|
29
26
|
var getPreviewContent = function getPreviewContent(markdownContent) {
|
|
30
27
|
var preview = '';
|
|
31
28
|
var newMarkdownContent = markdownContent.replace(hrefReg, '');
|
|
32
|
-
|
|
33
29
|
for (var index = 0; index < newMarkdownContent.length; index++) {
|
|
34
30
|
if (newMarkdownContent[index] === '#') {
|
|
35
31
|
continue;
|
|
@@ -38,26 +34,21 @@ var getPreviewContent = function getPreviewContent(markdownContent) {
|
|
|
38
34
|
} else {
|
|
39
35
|
preview += newMarkdownContent[index];
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
if (preview.length === 150) {
|
|
43
38
|
break;
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
|
-
|
|
47
41
|
var hrefList = markdownContent.match(hrefReg);
|
|
48
|
-
|
|
49
42
|
if (hrefList) {
|
|
50
43
|
var _getLinks = getLinks(hrefList),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
images = _getLinks.images,
|
|
45
|
+
links = _getLinks.links;
|
|
54
46
|
return {
|
|
55
47
|
preview: preview,
|
|
56
48
|
images: images,
|
|
57
49
|
links: links
|
|
58
50
|
};
|
|
59
51
|
}
|
|
60
|
-
|
|
61
52
|
return {
|
|
62
53
|
preview: preview,
|
|
63
54
|
images: [],
|
|
@@ -65,5 +56,4 @@ var getPreviewContent = function getPreviewContent(markdownContent) {
|
|
|
65
56
|
text: markdownContent
|
|
66
57
|
};
|
|
67
58
|
};
|
|
68
|
-
|
|
69
59
|
export default getPreviewContent;
|
|
@@ -5,56 +5,44 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import DtableMarkdownViewer from './dtable-markdown-viewer';
|
|
7
7
|
import './longTextEditor.css';
|
|
8
|
-
|
|
9
8
|
var LongTextPreview = /*#__PURE__*/function (_React$PureComponent) {
|
|
10
9
|
_inherits(LongTextPreview, _React$PureComponent);
|
|
11
|
-
|
|
12
10
|
var _super = _createSuper(LongTextPreview);
|
|
13
|
-
|
|
14
11
|
function LongTextPreview(props) {
|
|
15
12
|
var _this;
|
|
16
|
-
|
|
17
13
|
_classCallCheck(this, LongTextPreview);
|
|
18
|
-
|
|
19
14
|
_this = _super.call(this, props);
|
|
20
|
-
|
|
21
15
|
_this.getStyle = function () {
|
|
22
16
|
var formatterStyle = _this.props.formatterStyle;
|
|
23
17
|
var left = formatterStyle.left,
|
|
24
|
-
|
|
18
|
+
top = formatterStyle.top;
|
|
25
19
|
var width = 520;
|
|
26
20
|
var height = _this.state.height;
|
|
27
21
|
var padding = 6;
|
|
28
22
|
left = left - width > 0 ? left - width - 12 : 0;
|
|
29
23
|
top = top - padding;
|
|
30
|
-
|
|
31
24
|
if (top + height > window.innerHeight) {
|
|
32
25
|
top = top - height > 0 ? top - height : 0;
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
return {
|
|
36
28
|
left: left,
|
|
37
29
|
top: top,
|
|
38
30
|
opacity: _this.state.opacity
|
|
39
31
|
};
|
|
40
32
|
};
|
|
41
|
-
|
|
42
33
|
_this.state = {
|
|
43
34
|
height: 450,
|
|
44
35
|
opacity: 0
|
|
45
36
|
};
|
|
46
37
|
return _this;
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
_createClass(LongTextPreview, [{
|
|
50
40
|
key: "componentDidMount",
|
|
51
41
|
value: function componentDidMount() {
|
|
52
42
|
var _this2 = this;
|
|
53
|
-
|
|
54
43
|
setTimeout(function () {
|
|
55
44
|
if (!_this2.ref) return;
|
|
56
45
|
var domHeight = _this2.ref.offsetHeight;
|
|
57
|
-
|
|
58
46
|
_this2.setState({
|
|
59
47
|
height: domHeight,
|
|
60
48
|
opacity: 1
|
|
@@ -65,7 +53,6 @@ var LongTextPreview = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
65
53
|
key: "render",
|
|
66
54
|
value: function render() {
|
|
67
55
|
var _this3 = this;
|
|
68
|
-
|
|
69
56
|
var markdownContent = this.props.value ? this.props.value.text : '';
|
|
70
57
|
return /*#__PURE__*/React.createElement("div", {
|
|
71
58
|
className: "longtext-modal-dialog longtext-preview",
|
|
@@ -81,8 +68,6 @@ var LongTextPreview = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
81
68
|
})));
|
|
82
69
|
}
|
|
83
70
|
}]);
|
|
84
|
-
|
|
85
71
|
return LongTextPreview;
|
|
86
72
|
}(React.PureComponent);
|
|
87
|
-
|
|
88
73
|
export default LongTextPreview;
|
|
@@ -4,22 +4,16 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { MarkdownViewer, processor } from '@seafile/seafile-editor';
|
|
7
|
-
|
|
8
7
|
// Windows old Wechat (3.0 or earlier) inner core is chrome 53 and don't support ECMA6, can't use seafile-editor markdownViewer
|
|
9
8
|
// Windows new Wechat (lastest version 3.3.5) support seafile-editor markdownViewer
|
|
10
9
|
// so use dangerouslySetInnerHTML to preview
|
|
11
10
|
var DtableMarkdownViewer = /*#__PURE__*/function (_React$PureComponent) {
|
|
12
11
|
_inherits(DtableMarkdownViewer, _React$PureComponent);
|
|
13
|
-
|
|
14
12
|
var _super = _createSuper(DtableMarkdownViewer);
|
|
15
|
-
|
|
16
13
|
function DtableMarkdownViewer(props) {
|
|
17
14
|
var _this;
|
|
18
|
-
|
|
19
15
|
_classCallCheck(this, DtableMarkdownViewer);
|
|
20
|
-
|
|
21
16
|
_this = _super.call(this, props);
|
|
22
|
-
|
|
23
17
|
_this.checkBrowser = function () {
|
|
24
18
|
if (window.chrome) {
|
|
25
19
|
var appVersion = navigator.appVersion;
|
|
@@ -30,35 +24,27 @@ var DtableMarkdownViewer = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
30
24
|
if (index === -1) return;
|
|
31
25
|
var chromeVersion = appVersionList[index];
|
|
32
26
|
chromeVersion = parseInt(chromeVersion.slice(chromeVersion.indexOf('/') + 1));
|
|
33
|
-
|
|
34
27
|
if (chromeVersion === 53 && navigator.appVersion && navigator.appVersion.includes('WindowsWechat')) {
|
|
35
28
|
_this.convertMarkdown(_this.props.markdownContent);
|
|
36
|
-
|
|
37
29
|
_this.isWindowsWechat = true;
|
|
38
30
|
}
|
|
39
31
|
}
|
|
40
32
|
};
|
|
41
|
-
|
|
42
33
|
_this.convertMarkdown = function (mdFile) {
|
|
43
34
|
processor.process(mdFile).then(function (result) {
|
|
44
35
|
var innerHtml = String(result).replace(/<a /ig, '<a target="_blank" tabindex="-1"');
|
|
45
|
-
|
|
46
36
|
_this.setState({
|
|
47
37
|
innerHtml: innerHtml
|
|
48
38
|
});
|
|
49
39
|
});
|
|
50
40
|
};
|
|
51
|
-
|
|
52
41
|
_this.state = {
|
|
53
42
|
innerHtml: null
|
|
54
43
|
};
|
|
55
44
|
_this.isWindowsWechat = false;
|
|
56
|
-
|
|
57
45
|
_this.checkBrowser();
|
|
58
|
-
|
|
59
46
|
return _this;
|
|
60
47
|
}
|
|
61
|
-
|
|
62
48
|
_createClass(DtableMarkdownViewer, [{
|
|
63
49
|
key: "render",
|
|
64
50
|
value: function render() {
|
|
@@ -70,15 +56,12 @@ var DtableMarkdownViewer = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
70
56
|
}
|
|
71
57
|
});
|
|
72
58
|
}
|
|
73
|
-
|
|
74
59
|
return /*#__PURE__*/React.createElement(MarkdownViewer, {
|
|
75
60
|
markdownContent: this.props.markdownContent,
|
|
76
61
|
showTOC: this.props.showTOC
|
|
77
62
|
});
|
|
78
63
|
}
|
|
79
64
|
}]);
|
|
80
|
-
|
|
81
65
|
return DtableMarkdownViewer;
|
|
82
66
|
}(React.PureComponent);
|
|
83
|
-
|
|
84
67
|
export default DtableMarkdownViewer;
|