dtable-ui-component 4.3.6 → 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.css +22 -59
- package/lib/DTableCustomizeSelect/index.js +99 -95
- 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.css +103 -0
- package/lib/SelectOptionGroup/index.js +157 -135
- package/lib/SelectOptionGroup/option.js +31 -38
- 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 +28 -0
- 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,22 +1,14 @@
|
|
|
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 getPreviewContent from './normalize-long-text-value';
|
|
8
4
|
import LongTextPreview from './widgets/LongTextPreview';
|
|
9
5
|
import ModalPortal from '../ModalPortal';
|
|
10
6
|
import './index.css';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_classCallCheck(this, SimpleLongTextFormatter);
|
|
17
|
-
_this = _super.call(this, props);
|
|
18
|
-
_this.renderLinks = function (value) {
|
|
19
|
-
var links = value.links;
|
|
7
|
+
class SimpleLongTextFormatter extends React.Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.renderLinks = value => {
|
|
11
|
+
const links = value.links;
|
|
20
12
|
if (!Array.isArray(links) || links.length === 0) return null;
|
|
21
13
|
return /*#__PURE__*/React.createElement("span", {
|
|
22
14
|
className: "long-text-links"
|
|
@@ -24,8 +16,8 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
24
16
|
className: "dtable-font dtable-icon-url"
|
|
25
17
|
}), links.length);
|
|
26
18
|
};
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
this.renderCheckList = value => {
|
|
20
|
+
const checkList = value.checklist;
|
|
29
21
|
if (!checkList || checkList.total === 0) return null;
|
|
30
22
|
return /*#__PURE__*/React.createElement("span", {
|
|
31
23
|
className: "long-text-check-list"
|
|
@@ -33,8 +25,8 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
33
25
|
className: "dtable-font dtable-icon-check-square-solid ".concat(checkList.completed === checkList.total ? 'long-text-check-list-completed' : '')
|
|
34
26
|
}), "".concat(checkList.completed, "/").concat(checkList.total));
|
|
35
27
|
};
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
this.renderImages = value => {
|
|
29
|
+
const images = value.images;
|
|
38
30
|
if (!Array.isArray(images) || images.length === 0) return null;
|
|
39
31
|
return /*#__PURE__*/React.createElement("span", {
|
|
40
32
|
className: "long-text-images"
|
|
@@ -45,15 +37,17 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
45
37
|
className: "image-number"
|
|
46
38
|
}, images.length > 1 ? '+' + images.length : null));
|
|
47
39
|
};
|
|
48
|
-
|
|
40
|
+
this.renderContent = value => {
|
|
49
41
|
return /*#__PURE__*/React.createElement("span", {
|
|
50
42
|
className: "long-text-content"
|
|
51
43
|
}, value.preview);
|
|
52
44
|
};
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
this.translateValue = () => {
|
|
46
|
+
const {
|
|
47
|
+
value
|
|
48
|
+
} = this.props;
|
|
55
49
|
if (!value) return {};
|
|
56
|
-
|
|
50
|
+
const valueType = Object.prototype.toString.call(value);
|
|
57
51
|
if (valueType === '[object String]') {
|
|
58
52
|
return getPreviewContent(value);
|
|
59
53
|
}
|
|
@@ -62,70 +56,64 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
62
56
|
}
|
|
63
57
|
return {};
|
|
64
58
|
};
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
clearTimeout(
|
|
68
|
-
|
|
59
|
+
this.clearTimer = () => {
|
|
60
|
+
if (this.timer) {
|
|
61
|
+
clearTimeout(this.timer);
|
|
62
|
+
this.timer = null;
|
|
69
63
|
}
|
|
70
64
|
};
|
|
71
|
-
|
|
65
|
+
this.onMouseEnter = () => {
|
|
72
66
|
// in case that there is no `modal-wrapper`
|
|
73
67
|
if (!document.getElementById('modal-wrapper')) {
|
|
74
68
|
return;
|
|
75
69
|
}
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
this.clearTimer();
|
|
71
|
+
if (this.props.value) {
|
|
72
|
+
this.timer = setTimeout(() => {
|
|
73
|
+
const style = this.ref.getBoundingClientRect();
|
|
74
|
+
this.formatterStyle = style;
|
|
75
|
+
this.setState({
|
|
82
76
|
isPreview: true
|
|
83
77
|
});
|
|
84
78
|
}, 2000);
|
|
85
79
|
}
|
|
86
80
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
81
|
+
this.onMouseLeave = () => {
|
|
82
|
+
this.clearTimer();
|
|
83
|
+
if (this.state.isPreview) {
|
|
84
|
+
this.setState({
|
|
91
85
|
isPreview: false
|
|
92
86
|
});
|
|
93
87
|
}
|
|
94
88
|
};
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
this.formatterStyle = null;
|
|
90
|
+
this.state = {
|
|
97
91
|
isPreview: false
|
|
98
92
|
};
|
|
99
|
-
return _this;
|
|
100
93
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})));
|
|
125
|
-
}
|
|
126
|
-
}]);
|
|
127
|
-
return SimpleLongTextFormatter;
|
|
128
|
-
}(React.Component);
|
|
94
|
+
componentWillUnmount() {
|
|
95
|
+
this.clearTimer();
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
const {
|
|
99
|
+
isPreview
|
|
100
|
+
} = this.state;
|
|
101
|
+
const {
|
|
102
|
+
containerClassName
|
|
103
|
+
} = this.props;
|
|
104
|
+
const className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
|
|
105
|
+
const value = this.translateValue();
|
|
106
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: className,
|
|
108
|
+
onMouseEnter: this.onMouseEnter,
|
|
109
|
+
onMouseLeave: this.onMouseLeave,
|
|
110
|
+
ref: ref => this.ref = ref
|
|
111
|
+
}, this.renderLinks(value), this.renderCheckList(value), this.renderImages(value), this.renderContent(value), isPreview && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(LongTextPreview, {
|
|
112
|
+
value: value,
|
|
113
|
+
formatterStyle: this.formatterStyle
|
|
114
|
+
})));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
129
117
|
SimpleLongTextFormatter.defaultProps = {
|
|
130
118
|
value: {
|
|
131
119
|
text: '',
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const hrefReg = /\[.+\]\(\S+\)|<img( width=[\\|/]?"(\d)+[\\|/|]?")? src="(\S+)" .?\/>|!\[\]\(\S+\)|!\[\]\((\S+)\)|<\S+>/g;
|
|
2
|
+
const imageReg1 = /^<img( width=[\\|/]?"(\d)+[\\|/|]?")? src="(\S+)" .?\/>/;
|
|
3
|
+
const imageReg2 = /^!\[\]\((\S+)\)/;
|
|
4
|
+
const linkReg1 = /^\[.+\]\(\S+\)/;
|
|
5
|
+
const linkReg2 = /^<\S+>$/;
|
|
6
|
+
const getLinks = hrefList => {
|
|
7
|
+
const hrefObj = {
|
|
8
8
|
links: [],
|
|
9
9
|
images: []
|
|
10
10
|
};
|
|
11
|
-
hrefList.forEach(
|
|
11
|
+
hrefList.forEach(href => {
|
|
12
12
|
if (href.search(linkReg1) >= 0 || href.search(linkReg2) >= 0) {
|
|
13
13
|
hrefObj.links.push(href);
|
|
14
14
|
} else {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
let imageSrcList = href.match(imageReg1);
|
|
16
|
+
let imageSrcList1 = href.match(imageReg2);
|
|
17
17
|
if (imageSrcList) {
|
|
18
18
|
hrefObj.images.push(imageSrcList[3]);
|
|
19
19
|
} else if (imageSrcList1) {
|
|
@@ -23,10 +23,10 @@ var getLinks = function getLinks(hrefList) {
|
|
|
23
23
|
});
|
|
24
24
|
return hrefObj;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for (
|
|
26
|
+
const getPreviewContent = markdownContent => {
|
|
27
|
+
let preview = '';
|
|
28
|
+
let newMarkdownContent = markdownContent.replace(hrefReg, '');
|
|
29
|
+
for (let index = 0; index < newMarkdownContent.length; index++) {
|
|
30
30
|
if (newMarkdownContent[index] === '#') {
|
|
31
31
|
continue;
|
|
32
32
|
} else if (newMarkdownContent[index] === '\n') {
|
|
@@ -38,19 +38,20 @@ var getPreviewContent = function getPreviewContent(markdownContent) {
|
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
const hrefList = markdownContent.match(hrefReg);
|
|
42
42
|
if (hrefList) {
|
|
43
|
-
|
|
44
|
-
images
|
|
45
|
-
links
|
|
43
|
+
const {
|
|
44
|
+
images,
|
|
45
|
+
links
|
|
46
|
+
} = getLinks(hrefList);
|
|
46
47
|
return {
|
|
47
|
-
preview
|
|
48
|
-
images
|
|
49
|
-
links
|
|
48
|
+
preview,
|
|
49
|
+
images,
|
|
50
|
+
links
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
return {
|
|
53
|
-
preview
|
|
54
|
+
preview,
|
|
54
55
|
images: [],
|
|
55
56
|
links: [],
|
|
56
57
|
text: markdownContent
|
|
@@ -1,73 +1,58 @@
|
|
|
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 DtableMarkdownViewer from './dtable-markdown-viewer';
|
|
7
3
|
import './longTextEditor.css';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
class LongTextPreview extends React.PureComponent {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.getStyle = () => {
|
|
8
|
+
let {
|
|
9
|
+
formatterStyle
|
|
10
|
+
} = this.props;
|
|
11
|
+
let {
|
|
12
|
+
left,
|
|
13
|
+
top
|
|
14
|
+
} = formatterStyle;
|
|
15
|
+
const width = 520;
|
|
16
|
+
const height = this.state.height;
|
|
17
|
+
const padding = 6;
|
|
22
18
|
left = left - width > 0 ? left - width - 12 : 0;
|
|
23
19
|
top = top - padding;
|
|
24
20
|
if (top + height > window.innerHeight) {
|
|
25
21
|
top = top - height > 0 ? top - height : 0;
|
|
26
22
|
}
|
|
27
23
|
return {
|
|
28
|
-
left
|
|
29
|
-
top
|
|
30
|
-
opacity:
|
|
24
|
+
left,
|
|
25
|
+
top,
|
|
26
|
+
opacity: this.state.opacity
|
|
31
27
|
};
|
|
32
28
|
};
|
|
33
|
-
|
|
29
|
+
this.state = {
|
|
34
30
|
height: 450,
|
|
35
31
|
opacity: 0
|
|
36
32
|
};
|
|
37
|
-
return _this;
|
|
38
33
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
64
|
-
className: "longtext-container longtext-container-scroll"
|
|
65
|
-
}, /*#__PURE__*/React.createElement(DtableMarkdownViewer, {
|
|
66
|
-
markdownContent: markdownContent,
|
|
67
|
-
showTOC: false
|
|
68
|
-
})));
|
|
69
|
-
}
|
|
70
|
-
}]);
|
|
71
|
-
return LongTextPreview;
|
|
72
|
-
}(React.PureComponent);
|
|
34
|
+
componentDidMount() {
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
if (!this.ref) return;
|
|
37
|
+
const domHeight = this.ref.offsetHeight;
|
|
38
|
+
this.setState({
|
|
39
|
+
height: domHeight,
|
|
40
|
+
opacity: 1
|
|
41
|
+
});
|
|
42
|
+
}, 0);
|
|
43
|
+
}
|
|
44
|
+
render() {
|
|
45
|
+
let markdownContent = this.props.value ? this.props.value.text : '';
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
className: "longtext-modal-dialog longtext-preview",
|
|
48
|
+
style: this.getStyle(),
|
|
49
|
+
ref: ref => this.ref = ref
|
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "longtext-container longtext-container-scroll"
|
|
52
|
+
}, /*#__PURE__*/React.createElement(DtableMarkdownViewer, {
|
|
53
|
+
markdownContent: markdownContent,
|
|
54
|
+
showTOC: false
|
|
55
|
+
})));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
73
58
|
export default LongTextPreview;
|
|
@@ -1,67 +1,52 @@
|
|
|
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 { MarkdownViewer, processor } from '@seafile/seafile-editor';
|
|
7
3
|
// Windows old Wechat (3.0 or earlier) inner core is chrome 53 and don't support ECMA6, can't use seafile-editor markdownViewer
|
|
8
4
|
// Windows new Wechat (lastest version 3.3.5) support seafile-editor markdownViewer
|
|
9
5
|
// so use dangerouslySetInnerHTML to preview
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _this;
|
|
15
|
-
_classCallCheck(this, DtableMarkdownViewer);
|
|
16
|
-
_this = _super.call(this, props);
|
|
17
|
-
_this.checkBrowser = function () {
|
|
6
|
+
class DtableMarkdownViewer extends React.PureComponent {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.checkBrowser = () => {
|
|
18
10
|
if (window.chrome) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return version.indexOf('Chrome') >= 0;
|
|
23
|
-
});
|
|
11
|
+
const appVersion = navigator.appVersion;
|
|
12
|
+
const appVersionList = appVersion.split(' ');
|
|
13
|
+
const index = appVersionList.findIndex(version => version.indexOf('Chrome') >= 0);
|
|
24
14
|
if (index === -1) return;
|
|
25
|
-
|
|
15
|
+
let chromeVersion = appVersionList[index];
|
|
26
16
|
chromeVersion = parseInt(chromeVersion.slice(chromeVersion.indexOf('/') + 1));
|
|
27
17
|
if (chromeVersion === 53 && navigator.appVersion && navigator.appVersion.includes('WindowsWechat')) {
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
this.convertMarkdown(this.props.markdownContent);
|
|
19
|
+
this.isWindowsWechat = true;
|
|
30
20
|
}
|
|
31
21
|
}
|
|
32
22
|
};
|
|
33
|
-
|
|
34
|
-
processor.process(mdFile).then(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
innerHtml
|
|
23
|
+
this.convertMarkdown = mdFile => {
|
|
24
|
+
processor.process(mdFile).then(result => {
|
|
25
|
+
let innerHtml = String(result).replace(/<a /ig, '<a target="_blank" tabindex="-1"');
|
|
26
|
+
this.setState({
|
|
27
|
+
innerHtml
|
|
38
28
|
});
|
|
39
29
|
});
|
|
40
30
|
};
|
|
41
|
-
|
|
31
|
+
this.state = {
|
|
42
32
|
innerHtml: null
|
|
43
33
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return _this;
|
|
34
|
+
this.isWindowsWechat = false;
|
|
35
|
+
this.checkBrowser();
|
|
47
36
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
__html: this.state.innerHtml
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return /*#__PURE__*/React.createElement(MarkdownViewer, {
|
|
60
|
-
markdownContent: this.props.markdownContent,
|
|
61
|
-
showTOC: this.props.showTOC
|
|
37
|
+
render() {
|
|
38
|
+
if (this.isWindowsWechat) {
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: "long-text-container article",
|
|
41
|
+
dangerouslySetInnerHTML: {
|
|
42
|
+
__html: this.state.innerHtml
|
|
43
|
+
}
|
|
62
44
|
});
|
|
63
45
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
return /*#__PURE__*/React.createElement(MarkdownViewer, {
|
|
47
|
+
markdownContent: this.props.markdownContent,
|
|
48
|
+
showTOC: this.props.showTOC
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
67
52
|
export default DtableMarkdownViewer;
|