dtable-ui-component 4.4.29 → 4.4.30-beta1
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.
|
|
67
|
-
if (this.
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
76
|
-
}
|
|
77
|
-
this.clearTimer();
|
|
78
|
+
if (!document.getElementById('modal-wrapper')) return;
|
|
79
|
+
this.clearOpenPreviewTimer();
|
|
78
80
|
if (this.props.value) {
|
|
79
|
-
this.
|
|
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.
|
|
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
|
|
@@ -99,14 +117,16 @@ class SimpleLongTextFormatter extends _react.default.Component {
|
|
|
99
117
|
};
|
|
100
118
|
}
|
|
101
119
|
componentWillUnmount() {
|
|
102
|
-
this.
|
|
120
|
+
this.clearOpenPreviewTimer();
|
|
121
|
+
this.clearClosePreviewTimer();
|
|
103
122
|
}
|
|
104
123
|
render() {
|
|
105
124
|
const {
|
|
106
125
|
isPreview
|
|
107
126
|
} = this.state;
|
|
108
127
|
const {
|
|
109
|
-
containerClassName
|
|
128
|
+
containerClassName,
|
|
129
|
+
previewClassName
|
|
110
130
|
} = this.props;
|
|
111
131
|
const className = (0, _classnames.default)('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
|
|
112
132
|
const value = this.translateValue();
|
|
@@ -116,8 +136,11 @@ class SimpleLongTextFormatter extends _react.default.Component {
|
|
|
116
136
|
onMouseLeave: this.onMouseLeave,
|
|
117
137
|
ref: ref => this.ref = ref
|
|
118
138
|
}, 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, {
|
|
139
|
+
className: previewClassName,
|
|
119
140
|
value: value,
|
|
120
|
-
formatterStyle: this.formatterStyle
|
|
141
|
+
formatterStyle: this.formatterStyle,
|
|
142
|
+
onMouseEnter: this.onPreviewMouseEnter,
|
|
143
|
+
onMouseLeave: this.onPreviewMouseLeave
|
|
121
144
|
})));
|
|
122
145
|
}
|
|
123
146
|
}
|
|
@@ -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
|
-
|
|
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:
|
|
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:
|
|
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
|
}
|