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.
Files changed (120) hide show
  1. package/lib/AutoNumberFormatter/index.js +11 -24
  2. package/lib/ButtonFormatter/index.js +29 -45
  3. package/lib/CTimeFormatter/index.js +17 -32
  4. package/lib/CheckboxEditor/index.js +42 -49
  5. package/lib/CheckboxFormatter/index.js +17 -30
  6. package/lib/CollaboratorEditor/index.js +118 -135
  7. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
  8. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
  9. package/lib/CollaboratorFormatter/index.js +26 -42
  10. package/lib/CollaboratorItem/index.js +31 -44
  11. package/lib/CreatorFormatter/index.js +24 -40
  12. package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
  13. package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
  14. package/lib/DTableCustomizeSelect/index.js +92 -103
  15. package/lib/DTablePopover/index.js +52 -71
  16. package/lib/DTablePopover/utils.js +1 -1
  17. package/lib/DTableRadio/index.js +9 -7
  18. package/lib/DTableSearchInput/index.js +89 -99
  19. package/lib/DTableSearchInput/utils.js +2 -2
  20. package/lib/DTableSelect/dtable-select-label.js +5 -3
  21. package/lib/DTableSelect/index.js +50 -64
  22. package/lib/DTableSelect/utils.js +36 -41
  23. package/lib/DTableSwitch/index.js +7 -5
  24. package/lib/DateEditor/index.js +88 -94
  25. package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
  26. package/lib/DateEditor/pc-date-editor-popover.js +70 -77
  27. package/lib/DateFormatter/index.js +15 -28
  28. package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
  29. package/lib/DigitalSignFormatter/index.js +55 -65
  30. package/lib/DigitalSignFormatter/utils.js +9 -8
  31. package/lib/DurationFormatter/index.js +14 -27
  32. package/lib/EditEditorButton/index.js +10 -22
  33. package/lib/EmailFormatter/index.js +11 -24
  34. package/lib/FieldDisplaySetting/field-item.js +18 -20
  35. package/lib/FieldDisplaySetting/index.js +41 -43
  36. package/lib/FileEditor/index.js +18 -29
  37. package/lib/FileFormatter/index.js +29 -43
  38. package/lib/FileItemFormatter/index.js +17 -32
  39. package/lib/FileItemFormatter/utils.js +5 -5
  40. package/lib/FileUploader/index.js +20 -33
  41. package/lib/FormulaFormatter/cell-value-validator.js +23 -8
  42. package/lib/FormulaFormatter/index.js +77 -83
  43. package/lib/FormulaFormatter/utils.js +27 -21
  44. package/lib/GeolocationFormatter/index.js +19 -32
  45. package/lib/HtmlLongTextFormatter/index.js +43 -52
  46. package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
  47. package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
  48. package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
  49. package/lib/ImageFormatter/images-lazy-load.js +71 -79
  50. package/lib/ImageFormatter/index.js +86 -97
  51. package/lib/ImageFormatter/utils.js +1 -1
  52. package/lib/ImagePreviewerLightbox/index.js +20 -18
  53. package/lib/ImagePreviewerLightbox/utils.js +3 -3
  54. package/lib/LastModifierFormatter/index.js +24 -40
  55. package/lib/LinkEditor/index.js +163 -167
  56. package/lib/LinkEditor/link-editor-option.js +41 -56
  57. package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
  58. package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
  59. package/lib/LinkFormatter/index.js +75 -77
  60. package/lib/LongTextFormatter/index.js +5 -3
  61. package/lib/MBEditorHeader/index.js +25 -38
  62. package/lib/MTimeFormatter/index.js +17 -32
  63. package/lib/ModalPortal/index.js +15 -32
  64. package/lib/MultipleSelectEditor/index.js +118 -136
  65. package/lib/MultipleSelectFormatter/index.js +24 -40
  66. package/lib/NotificationPopover/index.js +68 -95
  67. package/lib/NumberEditor/index.js +75 -82
  68. package/lib/NumberFormatter/index.js +15 -28
  69. package/lib/RateFormatter/index.js +29 -45
  70. package/lib/RoleStatusEditor/index.js +20 -22
  71. package/lib/RowExpandEmailFormatter/index.js +24 -37
  72. package/lib/RowExpandFileFormatter/index.js +28 -42
  73. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
  74. package/lib/RowExpandFormatter/index.js +92 -96
  75. package/lib/RowExpandFormulaFormatter/index.js +85 -91
  76. package/lib/RowExpandImageFormatter/index.js +65 -82
  77. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
  78. package/lib/RowExpandImageFormatter/utils.js +1 -1
  79. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
  80. package/lib/RowExpandLinkFormatter/index.js +131 -137
  81. package/lib/RowExpandLinkFormatter/utils.js +23 -17
  82. package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
  83. package/lib/RowExpandRateFormatter/index.js +27 -42
  84. package/lib/RowExpandUrlFormatter/index.js +27 -40
  85. package/lib/SelectItem/index.js +17 -33
  86. package/lib/SelectOptionGroup/index.js +141 -159
  87. package/lib/SelectOptionGroup/option.js +24 -40
  88. package/lib/SimpleLongTextFormatter/index.js +55 -67
  89. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
  90. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
  91. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
  92. package/lib/SingleSelectEditor/index.js +108 -119
  93. package/lib/SingleSelectFormatter/index.js +21 -37
  94. package/lib/TextEditor/index.js +45 -51
  95. package/lib/TextFormatter/index.js +17 -32
  96. package/lib/UrlFormatter/index.js +11 -24
  97. package/lib/cellFormatterFactory/index.js +8 -17
  98. package/lib/common/ClickOutside.js +22 -43
  99. package/lib/common/delete-tip.js +40 -65
  100. package/lib/common/modal-portal.js +15 -33
  101. package/lib/constants/index.js +5 -5
  102. package/lib/data/dtable-value.js +4 -4
  103. package/lib/formatterConfig/base-formatter-config.js +24 -3
  104. package/lib/formatterConfig/index.js +5 -4
  105. package/lib/lang/index.js +6 -6
  106. package/lib/locals/de.js +1 -1
  107. package/lib/locals/en.js +1 -1
  108. package/lib/locals/fr.js +1 -1
  109. package/lib/locals/zh-CN.js +1 -1
  110. package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
  111. package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
  112. package/lib/select-editor/select-editor-option.js +41 -56
  113. package/lib/toaster/alert.js +73 -88
  114. package/lib/toaster/index.js +1 -1
  115. package/lib/toaster/toast.js +75 -102
  116. package/lib/toaster/toastManager.js +55 -91
  117. package/lib/toaster/toaster.js +58 -57
  118. package/lib/utils/editor-utils.js +17 -19
  119. package/lib/utils/utils.js +14 -14
  120. 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
- var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
12
- _inherits(SimpleLongTextFormatter, _React$Component);
13
- var _super = _createSuper(SimpleLongTextFormatter);
14
- function SimpleLongTextFormatter(props) {
15
- var _this;
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
- _this.renderCheckList = function (value) {
28
- var checkList = value.checklist;
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
- _this.renderImages = function (value) {
37
- var images = value.images;
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
- _this.renderContent = function (value) {
40
+ this.renderContent = value => {
49
41
  return /*#__PURE__*/React.createElement("span", {
50
42
  className: "long-text-content"
51
43
  }, value.preview);
52
44
  };
53
- _this.translateValue = function () {
54
- var value = _this.props.value;
45
+ this.translateValue = () => {
46
+ const {
47
+ value
48
+ } = this.props;
55
49
  if (!value) return {};
56
- var valueType = Object.prototype.toString.call(value);
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
- _this.clearTimer = function () {
66
- if (_this.timer) {
67
- clearTimeout(_this.timer);
68
- _this.timer = null;
59
+ this.clearTimer = () => {
60
+ if (this.timer) {
61
+ clearTimeout(this.timer);
62
+ this.timer = null;
69
63
  }
70
64
  };
71
- _this.onMouseEnter = function () {
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
- _this.clearTimer();
77
- if (_this.props.value) {
78
- _this.timer = setTimeout(function () {
79
- var style = _this.ref.getBoundingClientRect();
80
- _this.formatterStyle = style;
81
- _this.setState({
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
- _this.onMouseLeave = function () {
88
- _this.clearTimer();
89
- if (_this.state.isPreview) {
90
- _this.setState({
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
- _this.formatterStyle = null;
96
- _this.state = {
89
+ this.formatterStyle = null;
90
+ this.state = {
97
91
  isPreview: false
98
92
  };
99
- return _this;
100
93
  }
101
- _createClass(SimpleLongTextFormatter, [{
102
- key: "componentWillUnmount",
103
- value: function componentWillUnmount() {
104
- this.clearTimer();
105
- }
106
- }, {
107
- key: "render",
108
- value: function render() {
109
- var _this2 = this;
110
- var isPreview = this.state.isPreview;
111
- var containerClassName = this.props.containerClassName;
112
- var className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
113
- var value = this.translateValue();
114
- return /*#__PURE__*/React.createElement("div", {
115
- className: className,
116
- onMouseEnter: this.onMouseEnter,
117
- onMouseLeave: this.onMouseLeave,
118
- ref: function ref(_ref) {
119
- return _this2.ref = _ref;
120
- }
121
- }, this.renderLinks(value), this.renderCheckList(value), this.renderImages(value), this.renderContent(value), isPreview && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(LongTextPreview, {
122
- value: value,
123
- formatterStyle: this.formatterStyle
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
- var hrefReg = /\[.+\]\(\S+\)|<img( width=[\\|/]?"(\d)+[\\|/|]?")? src="(\S+)" .?\/>|!\[\]\(\S+\)|!\[\]\((\S+)\)|<\S+>/g;
2
- var imageReg1 = /^<img( width=[\\|/]?"(\d)+[\\|/|]?")? src="(\S+)" .?\/>/;
3
- var imageReg2 = /^!\[\]\((\S+)\)/;
4
- var linkReg1 = /^\[.+\]\(\S+\)/;
5
- var linkReg2 = /^<\S+>$/;
6
- var getLinks = function getLinks(hrefList) {
7
- var hrefObj = {
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(function (href) {
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
- var imageSrcList = href.match(imageReg1);
16
- var imageSrcList1 = href.match(imageReg2);
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
- var getPreviewContent = function getPreviewContent(markdownContent) {
27
- var preview = '';
28
- var newMarkdownContent = markdownContent.replace(hrefReg, '');
29
- for (var index = 0; index < newMarkdownContent.length; index++) {
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
- var hrefList = markdownContent.match(hrefReg);
41
+ const hrefList = markdownContent.match(hrefReg);
42
42
  if (hrefList) {
43
- var _getLinks = getLinks(hrefList),
44
- images = _getLinks.images,
45
- links = _getLinks.links;
43
+ const {
44
+ images,
45
+ links
46
+ } = getLinks(hrefList);
46
47
  return {
47
- preview: preview,
48
- images: images,
49
- links: links
48
+ preview,
49
+ images,
50
+ links
50
51
  };
51
52
  }
52
53
  return {
53
- preview: 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
- var LongTextPreview = /*#__PURE__*/function (_React$PureComponent) {
9
- _inherits(LongTextPreview, _React$PureComponent);
10
- var _super = _createSuper(LongTextPreview);
11
- function LongTextPreview(props) {
12
- var _this;
13
- _classCallCheck(this, LongTextPreview);
14
- _this = _super.call(this, props);
15
- _this.getStyle = function () {
16
- var formatterStyle = _this.props.formatterStyle;
17
- var left = formatterStyle.left,
18
- top = formatterStyle.top;
19
- var width = 520;
20
- var height = _this.state.height;
21
- var padding = 6;
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: left,
29
- top: top,
30
- opacity: _this.state.opacity
24
+ left,
25
+ top,
26
+ opacity: this.state.opacity
31
27
  };
32
28
  };
33
- _this.state = {
29
+ this.state = {
34
30
  height: 450,
35
31
  opacity: 0
36
32
  };
37
- return _this;
38
33
  }
39
- _createClass(LongTextPreview, [{
40
- key: "componentDidMount",
41
- value: function componentDidMount() {
42
- var _this2 = this;
43
- setTimeout(function () {
44
- if (!_this2.ref) return;
45
- var domHeight = _this2.ref.offsetHeight;
46
- _this2.setState({
47
- height: domHeight,
48
- opacity: 1
49
- });
50
- }, 0);
51
- }
52
- }, {
53
- key: "render",
54
- value: function render() {
55
- var _this3 = this;
56
- var markdownContent = this.props.value ? this.props.value.text : '';
57
- return /*#__PURE__*/React.createElement("div", {
58
- className: "longtext-modal-dialog longtext-preview",
59
- style: this.getStyle(),
60
- ref: function ref(_ref) {
61
- return _this3.ref = _ref;
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
- var DtableMarkdownViewer = /*#__PURE__*/function (_React$PureComponent) {
11
- _inherits(DtableMarkdownViewer, _React$PureComponent);
12
- var _super = _createSuper(DtableMarkdownViewer);
13
- function DtableMarkdownViewer(props) {
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
- var appVersion = navigator.appVersion;
20
- var appVersionList = appVersion.split(' ');
21
- var index = appVersionList.findIndex(function (version) {
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
- var chromeVersion = appVersionList[index];
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
- _this.convertMarkdown(_this.props.markdownContent);
29
- _this.isWindowsWechat = true;
18
+ this.convertMarkdown(this.props.markdownContent);
19
+ this.isWindowsWechat = true;
30
20
  }
31
21
  }
32
22
  };
33
- _this.convertMarkdown = function (mdFile) {
34
- processor.process(mdFile).then(function (result) {
35
- var innerHtml = String(result).replace(/<a /ig, '<a target="_blank" tabindex="-1"');
36
- _this.setState({
37
- innerHtml: 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
- _this.state = {
31
+ this.state = {
42
32
  innerHtml: null
43
33
  };
44
- _this.isWindowsWechat = false;
45
- _this.checkBrowser();
46
- return _this;
34
+ this.isWindowsWechat = false;
35
+ this.checkBrowser();
47
36
  }
48
- _createClass(DtableMarkdownViewer, [{
49
- key: "render",
50
- value: function render() {
51
- if (this.isWindowsWechat) {
52
- return /*#__PURE__*/React.createElement("div", {
53
- className: "long-text-container article",
54
- dangerouslySetInnerHTML: {
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
- return DtableMarkdownViewer;
66
- }(React.PureComponent);
46
+ return /*#__PURE__*/React.createElement(MarkdownViewer, {
47
+ markdownContent: this.props.markdownContent,
48
+ showTOC: this.props.showTOC
49
+ });
50
+ }
51
+ }
67
52
  export default DtableMarkdownViewer;