dtable-ui-component 4.4.28 → 4.4.30-beta

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.
@@ -63,20 +63,22 @@ class SimpleLongTextFormatter extends _react.default.Component {
63
63
  }
64
64
  return {};
65
65
  };
66
- this.clearTimer = () => {
67
- if (this.timer) {
68
- clearTimeout(this.timer);
69
- this.timer = null;
70
- }
66
+ this.clearOpenPreviewTimer = () => {
67
+ if (!this.openPreviewTimer) return;
68
+ clearTimeout(this.openPreviewTimer);
69
+ this.openPreviewTimer = null;
70
+ };
71
+ this.clearClosePreviewTimer = () => {
72
+ if (!this.closePreviewTimer) return;
73
+ clearTimeout(this.closePreviewTimer);
74
+ this.closePreviewTimer = null;
71
75
  };
72
76
  this.onMouseEnter = () => {
73
77
  // in case that there is no `modal-wrapper`
74
- if (!document.getElementById('modal-wrapper')) {
75
- return;
76
- }
77
- this.clearTimer();
78
- if (this.props.value) {
79
- this.timer = setTimeout(() => {
78
+ if (!document.getElementById('modal-wrapper')) return;
79
+ this.clearOpenPreviewTimer();
80
+ if (this.props.value && this.props.value.text) {
81
+ this.openPreviewTimer = setTimeout(() => {
80
82
  const style = this.ref.getBoundingClientRect();
81
83
  this.formatterStyle = style;
82
84
  this.setState({
@@ -86,7 +88,23 @@ class SimpleLongTextFormatter extends _react.default.Component {
86
88
  }
87
89
  };
88
90
  this.onMouseLeave = () => {
89
- this.clearTimer();
91
+ this.clearOpenPreviewTimer();
92
+
93
+ // Case 1: The mouse moves out of the cell and is not in the preview component, close the preview component after 2S
94
+ this.closePreviewTimer = setTimeout(() => {
95
+ if (this.state.isPreview) {
96
+ this.setState({
97
+ isPreview: false
98
+ });
99
+ }
100
+ }, 2000);
101
+ };
102
+ // Case 2: The mouse moves out of the cell and into the preview component, do not close the preview component
103
+ this.onPreviewMouseEnter = () => {
104
+ this.clearClosePreviewTimer();
105
+ };
106
+ // Case 2: The mouse move out of the preview component, close the preview component
107
+ this.onPreviewMouseLeave = () => {
90
108
  if (this.state.isPreview) {
91
109
  this.setState({
92
110
  isPreview: false
@@ -106,7 +124,8 @@ class SimpleLongTextFormatter extends _react.default.Component {
106
124
  isPreview
107
125
  } = this.state;
108
126
  const {
109
- containerClassName
127
+ containerClassName,
128
+ previewClassName
110
129
  } = this.props;
111
130
  const className = (0, _classnames.default)('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
112
131
  const value = this.translateValue();
@@ -116,8 +135,11 @@ class SimpleLongTextFormatter extends _react.default.Component {
116
135
  onMouseLeave: this.onMouseLeave,
117
136
  ref: ref => this.ref = ref
118
137
  }, this.renderLinks(value), this.renderCheckList(value), this.renderImages(value), this.renderContent(value), isPreview && /*#__PURE__*/_react.default.createElement(_ModalPortal.default, null, /*#__PURE__*/_react.default.createElement(_LongTextPreview.default, {
138
+ className: previewClassName,
119
139
  value: value,
120
- formatterStyle: this.formatterStyle
140
+ formatterStyle: this.formatterStyle,
141
+ onMouseEnter: this.onPreviewMouseEnter,
142
+ onMouseLeave: this.onPreviewMouseLeave
121
143
  })));
122
144
  }
123
145
  }
@@ -53,7 +53,8 @@ const getPreviewContent = markdownContent => {
53
53
  return {
54
54
  preview,
55
55
  images,
56
- links
56
+ links,
57
+ text: markdownContent
57
58
  };
58
59
  }
59
60
  return {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _classnames = _interopRequireDefault(require("classnames"));
9
10
  var _dtableMarkdownViewer = _interopRequireDefault(require("./dtable-markdown-viewer"));
10
11
  require("./longTextEditor.css");
11
12
  class LongTextPreview extends _react.default.PureComponent {
@@ -33,6 +34,12 @@ class LongTextPreview extends _react.default.PureComponent {
33
34
  opacity: this.state.opacity
34
35
  };
35
36
  };
37
+ this.onMouseEnter = e => {
38
+ this.props.onMouseEnter && this.props.onMouseEnter(e);
39
+ };
40
+ this.onMouseLeave = e => {
41
+ this.props.onMouseLeave && this.props.onMouseLeave(e);
42
+ };
36
43
  this.state = {
37
44
  height: 450,
38
45
  opacity: 0
@@ -49,11 +56,17 @@ class LongTextPreview extends _react.default.PureComponent {
49
56
  }, 0);
50
57
  }
51
58
  render() {
52
- let markdownContent = this.props.value ? this.props.value.text : '';
59
+ const {
60
+ className,
61
+ value
62
+ } = this.props;
63
+ const markdownContent = value ? value.text : '';
53
64
  return /*#__PURE__*/_react.default.createElement("div", {
54
- className: "longtext-modal-dialog longtext-preview",
65
+ className: (0, _classnames.default)('longtext-modal-dialog longtext-preview', className),
55
66
  style: this.getStyle(),
56
- ref: ref => this.ref = ref
67
+ ref: ref => this.ref = ref,
68
+ onMouseEnter: this.onMouseEnter,
69
+ onMouseLeave: this.onMouseLeave
57
70
  }, /*#__PURE__*/_react.default.createElement("div", {
58
71
  className: "longtext-container longtext-container-scroll"
59
72
  }, /*#__PURE__*/_react.default.createElement(_dtableMarkdownViewer.default, {
@@ -325,13 +325,22 @@
325
325
  height: fit-content;
326
326
  max-height: 450px;
327
327
  margin-left: 0;
328
- z-index: 100;
328
+ z-index: 10000;
329
329
  top: 0;
330
330
  box-shadow: 0 0 5px #ccc;
331
331
  border: 1px solid rgba(0, 40, 100, 0.12);
332
332
  transform: none;
333
333
  }
334
334
 
335
+ .longtext-preview .sf-slate-viewer-scroll-container {
336
+ padding: 0;
337
+ overflow-x: hidden;
338
+ }
339
+
340
+ .longtext-preview .sf-slate-viewer-scroll-container .sf-slate-viewer-article-container {
341
+ width: 100%;
342
+ }
343
+
335
344
  .longtext-preview .longtext-container .article {
336
345
  padding: 10px 16px;
337
346
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "4.4.28",
3
+ "version": "4.4.30beta",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "2.0.5",
7
7
  "@seafile/seafile-calendar": "0.0.24",
8
- "@seafile/seafile-editor": "~1.0.71",
8
+ "@seafile/seafile-editor": "~1.0.72",
9
9
  "antd-mobile": "2.3.1",
10
10
  "classnames": "2.3.2",
11
11
  "dayjs": "1.10.7",