dtable-ui-component 0.1.90 → 0.1.91

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.
@@ -68,7 +68,8 @@ var LinkFormatter = /*#__PURE__*/function (_React$Component) {
68
68
  className: "link-item",
69
69
  onClick: _this.expandLinkedTableRow.bind(_assertThisInitialized(_this), row)
70
70
  }, /*#__PURE__*/React.createElement("div", {
71
- className: "link-name"
71
+ className: "link-name",
72
+ title: displayValue
72
73
  }, displayValue));
73
74
  });
74
75
  return result;
@@ -5,6 +5,8 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import cn from 'astro-classname';
7
7
  import getPreviewContent from './normalize-long-text-value';
8
+ import LongTextPreview from './widgets/LongTextPreview';
9
+ import ModalPortal from '../ModalPortal';
8
10
  import './index.css';
9
11
 
10
12
  var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
@@ -12,16 +14,12 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
12
14
 
13
15
  var _super = _createSuper(SimpleLongTextFormatter);
14
16
 
15
- function SimpleLongTextFormatter() {
17
+ function SimpleLongTextFormatter(props) {
16
18
  var _this;
17
19
 
18
20
  _classCallCheck(this, SimpleLongTextFormatter);
19
21
 
20
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
21
- args[_key] = arguments[_key];
22
- }
23
-
24
- _this = _super.call.apply(_super, [this].concat(args));
22
+ _this = _super.call(this, props);
25
23
 
26
24
  _this.renderLinks = function (value) {
27
25
  var links = value.links;
@@ -78,18 +76,71 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
78
76
  return {};
79
77
  };
80
78
 
79
+ _this.clearTimer = function () {
80
+ if (_this.timer) {
81
+ clearTimeout(_this.timer);
82
+ _this.timer = null;
83
+ }
84
+ };
85
+
86
+ _this.onMouseEnter = function () {
87
+ // in case that there is no `modal-wrapper`
88
+ if (!document.getElementById('modal-wrapper')) {
89
+ return;
90
+ }
91
+
92
+ _this.clearTimer();
93
+
94
+ if (_this.props.value) {
95
+ _this.timer = setTimeout(function () {
96
+ var style = _this.ref.getBoundingClientRect();
97
+
98
+ _this.formatterStyle = style;
99
+
100
+ _this.setState({
101
+ isPreview: true
102
+ });
103
+ }, 2000);
104
+ }
105
+ };
106
+
107
+ _this.onMouseLeave = function () {
108
+ _this.clearTimer();
109
+
110
+ if (_this.state.isPreview) {
111
+ _this.setState({
112
+ isPreview: false
113
+ });
114
+ }
115
+ };
116
+
117
+ _this.formatterStyle = null;
118
+ _this.state = {
119
+ isPreview: false
120
+ };
81
121
  return _this;
82
122
  }
83
123
 
84
124
  _createClass(SimpleLongTextFormatter, [{
85
125
  key: "render",
86
126
  value: function render() {
127
+ var _this2 = this;
128
+
129
+ var isPreview = this.state.isPreview;
87
130
  var containerClassName = this.props.containerClassName;
88
131
  var className = cn('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
89
132
  var value = this.translateValue();
90
133
  return /*#__PURE__*/React.createElement("div", {
91
- className: className
92
- }, this.renderLinks(value), this.renderCheckList(value), this.renderImages(value), this.renderContent(value));
134
+ className: className,
135
+ onMouseEnter: this.onMouseEnter,
136
+ onMouseLeave: this.onMouseLeave,
137
+ ref: function ref(_ref) {
138
+ return _this2.ref = _ref;
139
+ }
140
+ }, this.renderLinks(value), this.renderCheckList(value), this.renderImages(value), this.renderContent(value), isPreview && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(LongTextPreview, {
141
+ value: value,
142
+ formatterStyle: this.formatterStyle
143
+ })));
93
144
  }
94
145
  }]);
95
146
 
@@ -0,0 +1,88 @@
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
+ import React from 'react';
6
+ import DtableMarkdownViewer from './dtable-markdown-viewer';
7
+ import './longTextEditor.css';
8
+
9
+ var LongTextPreview = /*#__PURE__*/function (_React$PureComponent) {
10
+ _inherits(LongTextPreview, _React$PureComponent);
11
+
12
+ var _super = _createSuper(LongTextPreview);
13
+
14
+ function LongTextPreview(props) {
15
+ var _this;
16
+
17
+ _classCallCheck(this, LongTextPreview);
18
+
19
+ _this = _super.call(this, props);
20
+
21
+ _this.getStyle = function () {
22
+ var formatterStyle = _this.props.formatterStyle;
23
+ var left = formatterStyle.left,
24
+ top = formatterStyle.top;
25
+ var width = 520;
26
+ var height = _this.state.height;
27
+ var padding = 6;
28
+ left = left - width > 0 ? left - width - 12 : 0;
29
+ top = top - padding;
30
+
31
+ if (top + height > window.innerHeight) {
32
+ top = top - height > 0 ? top - height : 0;
33
+ }
34
+
35
+ return {
36
+ left: left,
37
+ top: top,
38
+ opacity: _this.state.opacity
39
+ };
40
+ };
41
+
42
+ _this.state = {
43
+ height: 450,
44
+ opacity: 0
45
+ };
46
+ return _this;
47
+ }
48
+
49
+ _createClass(LongTextPreview, [{
50
+ key: "componentDidMount",
51
+ value: function componentDidMount() {
52
+ var _this2 = this;
53
+
54
+ setTimeout(function () {
55
+ if (!_this2.ref) return;
56
+ var domHeight = _this2.ref.offsetHeight;
57
+
58
+ _this2.setState({
59
+ height: domHeight,
60
+ opacity: 1
61
+ });
62
+ }, 0);
63
+ }
64
+ }, {
65
+ key: "render",
66
+ value: function render() {
67
+ var _this3 = this;
68
+
69
+ var markdownContent = this.props.value ? this.props.value.text : '';
70
+ return /*#__PURE__*/React.createElement("div", {
71
+ className: "longtext-modal-dialog longtext-preview",
72
+ style: this.getStyle(),
73
+ ref: function ref(_ref) {
74
+ return _this3.ref = _ref;
75
+ }
76
+ }, /*#__PURE__*/React.createElement("div", {
77
+ className: "longtext-container longtext-container-scroll"
78
+ }, /*#__PURE__*/React.createElement(DtableMarkdownViewer, {
79
+ markdownContent: markdownContent,
80
+ showTOC: false
81
+ })));
82
+ }
83
+ }]);
84
+
85
+ return LongTextPreview;
86
+ }(React.PureComponent);
87
+
88
+ export default LongTextPreview;
@@ -0,0 +1,83 @@
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
+ import React from 'react';
6
+ import { MarkdownViewer, processor } from '@seafile/seafile-editor';
7
+
8
+ // Windows old Wechat (3.0 or earlier) inner core is chrome 53 and don't support ECMA6, can't use seafile-editor markdownViewer
9
+ // Windows new Wechat (lastest version 3.3.5) support seafile-editor markdownViewer
10
+ // so use dangerouslySetInnerHTML to preview
11
+ var DtableMarkdownViewer = /*#__PURE__*/function (_React$PureComponent) {
12
+ _inherits(DtableMarkdownViewer, _React$PureComponent);
13
+
14
+ var _super = _createSuper(DtableMarkdownViewer);
15
+
16
+ function DtableMarkdownViewer(props) {
17
+ var _this;
18
+
19
+ _classCallCheck(this, DtableMarkdownViewer);
20
+
21
+ _this = _super.call(this, props);
22
+
23
+ _this.checkBrowser = function () {
24
+ if (window.chrome) {
25
+ var appVersion = navigator.appVersion;
26
+ var appVersionList = appVersion.split(' ');
27
+ var index = appVersionList.findIndex(function (version) {
28
+ return version.indexOf('Chrome') >= 0;
29
+ });
30
+ var chromeVersion = appVersionList[index];
31
+ chromeVersion = parseInt(chromeVersion.slice(chromeVersion.indexOf('/') + 1));
32
+
33
+ if (chromeVersion === 53 && navigator.appVersion && navigator.appVersion.includes('WindowsWechat')) {
34
+ _this.convertMarkdown(_this.props.markdownContent);
35
+
36
+ _this.isWindowsWechat = true;
37
+ }
38
+ }
39
+ };
40
+
41
+ _this.convertMarkdown = function (mdFile) {
42
+ processor.process(mdFile).then(function (result) {
43
+ var innerHtml = String(result).replace(/<a /ig, '<a target="_blank" tabindex="-1"');
44
+
45
+ _this.setState({
46
+ innerHtml: innerHtml
47
+ });
48
+ });
49
+ };
50
+
51
+ _this.state = {
52
+ innerHtml: null
53
+ };
54
+ _this.isWindowsWechat = false;
55
+
56
+ _this.checkBrowser();
57
+
58
+ return _this;
59
+ }
60
+
61
+ _createClass(DtableMarkdownViewer, [{
62
+ key: "render",
63
+ value: function render() {
64
+ if (this.isWindowsWechat) {
65
+ return /*#__PURE__*/React.createElement("div", {
66
+ className: "long-text-container article",
67
+ dangerouslySetInnerHTML: {
68
+ __html: this.state.innerHtml
69
+ }
70
+ });
71
+ }
72
+
73
+ return /*#__PURE__*/React.createElement(MarkdownViewer, {
74
+ markdownContent: this.props.markdownContent,
75
+ showTOC: this.props.showTOC
76
+ });
77
+ }
78
+ }]);
79
+
80
+ return DtableMarkdownViewer;
81
+ }(React.PureComponent);
82
+
83
+ export default DtableMarkdownViewer;
@@ -0,0 +1,352 @@
1
+
2
+ .longtext-editor-dialog .longtext-editor-wrapper {
3
+ height: 600px;
4
+ overflow: hidden;
5
+ }
6
+
7
+ .longtext-formatter {
8
+ width: 100%;
9
+ max-width: 100%;
10
+ overflow: hidden;
11
+ text-overflow: ellipsis;
12
+ white-space: nowrap;
13
+ }
14
+
15
+ .longtext-detail {
16
+ width: 100%;
17
+ }
18
+
19
+ .operation-longtext-formatter .longtext-detail:hover {
20
+ background-color: #f5f5f5;
21
+ cursor: pointer;
22
+ }
23
+
24
+ .operation-longtext-formatter .row-expand-view {
25
+ position: fixed;
26
+ left: 0;
27
+ top: 0;
28
+ }
29
+
30
+ .row-height-56 .longtext-formatter,
31
+ .row-height-88 .longtext-formatter,
32
+ .row-height-128 .longtext-formatter {
33
+ overflow: hidden;
34
+ display: -webkit-box;
35
+ -webkit-box-orient: vertical;
36
+ text-overflow: -o-ellipsis-lastline;
37
+ white-space: pre-wrap;
38
+ word-wrap: break-word;
39
+ }
40
+
41
+ .row-height-56 .longtext-formatter {
42
+ max-height: 42px;
43
+ line-height: 1.5;
44
+ -webkit-line-clamp: 2;
45
+ }
46
+
47
+ .row-height-88 .longtext-formatter {
48
+ max-height: 78px;
49
+ line-height: 1.4;
50
+ -webkit-line-clamp: 4;
51
+ }
52
+
53
+ .row-height-128 .longtext-formatter {
54
+ max-height: 117px;
55
+ line-height: 1.4;
56
+ -webkit-line-clamp: 6;
57
+ }
58
+
59
+ .longtext-icon-container {
60
+ border-radius: 3px;
61
+ display: inline-block;
62
+ }
63
+
64
+ .longtext-formatter-links-container, .longtext-formatter-check-list-container {
65
+ background-color: #f0f0f0;
66
+ color: #9c9c9c;
67
+ padding: 0 3px;
68
+ height: 20px;
69
+ line-height: 20px;
70
+ margin: 0 4px;
71
+ }
72
+
73
+ .longtext-formatter-links-container:hover {
74
+ background-color: #dbdbdd;
75
+ }
76
+
77
+ .longtext-formatter-link-list-open {
78
+ background-color: #dbdbdd;
79
+ }
80
+
81
+ .longtext-links-list-container {
82
+ position: absolute;
83
+ background-color: #fff;
84
+ z-index: 3;
85
+ box-shadow: 0 0 5px #ccc;
86
+ padding: 10px;
87
+ border-radius: 4px;
88
+ width: 294px;
89
+ overflow: hidden;
90
+ max-height: 320px;
91
+ overflow-y: auto;
92
+ }
93
+
94
+ .longtext-links-list-container .longtext-formatter-link-item {
95
+ width: 100%;
96
+ overflow: hidden;
97
+ text-overflow: ellipsis;
98
+ white-space: nowrap;
99
+ display: block;
100
+ font-size: 14px;
101
+ line-height: 16px;
102
+ margin-bottom: 14px;
103
+ }
104
+
105
+ .longtext-links-list-container .longtext-formatter-link-item:hover {
106
+ text-decoration: underline;
107
+ }
108
+
109
+ .longtext-links-list-container .longtext-formatter-link-item:last-child {
110
+ margin-bottom: 0;
111
+ }
112
+
113
+ .longtext-formatter-image-container {
114
+ margin-right: -10px;
115
+ }
116
+
117
+ .row-height-32 .longtext-formatter-image-container {
118
+ line-height: 30px;
119
+ }
120
+
121
+ .longtext-formatter-image-container img {
122
+ max-width: 28px;
123
+ border: 1px solid #f0f0f0;
124
+ max-height: 28px;
125
+ box-sizing: border-box;
126
+ border-radius: 3px;
127
+ margin-top: -3px;
128
+ }
129
+
130
+ .longtext-formatter-image-container .image-number {
131
+ font-style: normal;
132
+ display: inline-block;
133
+ font-size: 12px;
134
+ border-radius: 6px;
135
+ background-color: #999;
136
+ color: #fff;
137
+ transform: translate(-50%, 6px) scale(0.8);
138
+ min-width: 14px;
139
+ line-height: 14px;
140
+ padding: 0 3px;
141
+ }
142
+
143
+ .row-height-56 .longtext-formatter-image-container .image-number {
144
+ transform: translate(-50%, 3px) scale(0.8);
145
+ }
146
+
147
+ .row-height-88 .longtext-formatter-image-container .image-number,
148
+ .row-height-128 .longtext-formatter-image-container .image-number {
149
+ transform: translate(-50%, 6px) scale(0.8);
150
+ }
151
+
152
+ .longtext-formatter-links-container .dtable-font, .longtext-formatter-check-list-container .dtable-font {
153
+ margin-right: 4px;
154
+ font-size: 12px;
155
+ }
156
+
157
+ .longtext-formatter-checklist-completed {
158
+ color: #61BD4F;
159
+ }
160
+
161
+ .longtext-modal {
162
+ position: fixed;
163
+ background-color:rgba(0, 0, 0, 0.5);
164
+ left: 0;
165
+ top: 0;
166
+ bottom: 0;
167
+ right: 0;
168
+ z-index: 1049;
169
+ }
170
+
171
+ .longtext-modal-dialog {
172
+ width: 800px;
173
+ border-radius: 3px;
174
+ position: absolute;
175
+ display: flex;
176
+ flex-direction: column;
177
+ margin-left: 50%;
178
+ transform: translateX(-50%);
179
+ top: 20px;
180
+ overflow: hidden;
181
+ bottom: 20px;
182
+ border: 1px solid rgba(0, 0, 0, 0.2);
183
+ background-color: #ffffff;
184
+ background-clip: padding-box;
185
+ }
186
+
187
+ .longtext-modal-dialog-header {
188
+ box-sizing: border-box;
189
+ padding: 0 8px 0 20px;
190
+ }
191
+
192
+ .longtext-modal-dialog-header .longtext-header {
193
+ height: 36px;
194
+ line-height: 36px;
195
+ display: flex;
196
+ justify-content: space-between;
197
+ }
198
+
199
+ .longtext-modal-dialog-header .longtext-header-name {
200
+ font-weight: 700;
201
+ }
202
+
203
+ .longtext-modal-dialog-header-border {
204
+ border-bottom: 1px solid #e9ecef;
205
+ }
206
+
207
+ .longtext-modal-dialog-header .longtext-compat-info {
208
+ margin-bottom: 8px;
209
+ height: 12px;
210
+ display: flex;
211
+ }
212
+
213
+ .longtext-modal-dialog-header .longtext-browser-warning {
214
+ margin-right: 4px;
215
+ display: inline-block;
216
+ line-height: 12px;
217
+ transform: scale(0.8);
218
+ }
219
+
220
+ .longtext-modal-dialog-header .browser-warning-content {
221
+ line-height: 12px;
222
+ }
223
+
224
+ .longtext-header-tool {
225
+ display: flex;
226
+ align-items: center;
227
+ flex-direction: row;
228
+ }
229
+
230
+ .longtext-header-tool-item {
231
+ font-size: 16px;
232
+ font-weight: 700;
233
+ color: #000;
234
+ cursor: pointer;
235
+ opacity: .5;
236
+ width: 24px;
237
+ height: 24px;
238
+ text-align: center;
239
+ display: block;
240
+ line-height: 24px;
241
+ border-radius: 3px;
242
+ }
243
+
244
+ .longtext-header-tool-item:not(.long-text-full-screen):hover {
245
+ opacity: 1;
246
+ }
247
+
248
+ .longtext-container {
249
+ overflow: hidden;
250
+ flex: 1 1 auto;
251
+ height: fit-content;
252
+ }
253
+
254
+ .long-text-full-screen {
255
+ background-color: #e0e0e0;
256
+ }
257
+
258
+ .longtext-container-scroll {
259
+ overflow-y: auto;
260
+ height: fit-content;
261
+ }
262
+
263
+ .longtext-modal-dialog .btn {
264
+ margin-right: 15px;
265
+ }
266
+
267
+ .longtext-container .seafile-simple-editor {
268
+ border: none;
269
+ }
270
+
271
+ .longtext-container .article{
272
+ padding: 10px 30px 10px 30px;
273
+ height: auto;
274
+ }
275
+
276
+ .longtext-container .seafile-editor-topbar {
277
+ height: 34px;
278
+ padding-left: 10px;
279
+ border-top: 1px solid #e9ecef;
280
+ border-bottom: 1px solid #e9ecef;
281
+ box-shadow: none;
282
+ }
283
+
284
+ .longtext-container .sf-editor-toolbar {
285
+ height: 32px;
286
+ }
287
+
288
+ .longtext-container .rich-icon-btn {
289
+ line-height: 24px;
290
+ }
291
+
292
+ .longtext-container .header-list-container {
293
+ height: 32px;
294
+ padding: 4px 5px;
295
+ border-right: 1px solid #e9ecef;
296
+ }
297
+
298
+ .longtext-container .list-body div {
299
+ line-height: 24px;
300
+ }
301
+
302
+ .longtext-container .seafile-editor-topbar .editor-btn-group {
303
+ padding: 3px 0 3px 5px;
304
+ border-right: 1px solid #e9ecef;
305
+ }
306
+
307
+ .longtext-container .upload-localimg {
308
+ height: 26px;
309
+ }
310
+
311
+ .upload-localimg .btn {
312
+ height: 26px;
313
+ }
314
+
315
+ .longtext-container .custom-dropdown-list .dropdown-list-toggle {
316
+ height: 24px;
317
+ }
318
+
319
+ .longtext-container h2 {
320
+ border-bottom: none;
321
+ }
322
+
323
+ .longtext-preview {
324
+ width: 520px;
325
+ height: fit-content;
326
+ max-height: 450px;
327
+ margin-left: 0;
328
+ z-index: 100;
329
+ top: 0;
330
+ box-shadow: 0 0 5px #ccc;
331
+ border: 1px solid rgba(0, 40, 100, 0.12);
332
+ transform: none;
333
+ }
334
+
335
+ .longtext-preview .longtext-container .article {
336
+ padding: 10px 16px;
337
+ }
338
+
339
+ .row-height-128 .longtext-formatter .article {
340
+ white-space: nowrap;
341
+ }
342
+
343
+ .row-height-128 .longtext-formatter .article li,
344
+ .row-height-128 .longtext-formatter .article p {
345
+ white-space: pre-wrap;
346
+ margin: 0;
347
+ }
348
+
349
+ .row-height-128 .longtext-formatter .article pre {
350
+ margin: 0;
351
+ padding: 8px;
352
+ }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "0.1.90",
3
+ "version": "0.1.91",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "0.0.9",
7
7
  "@seafile/seafile-calendar": "^0.0.21",
8
+ "@seafile/seafile-editor": "^0.3.103",
8
9
  "antd-mobile": "^2.3.3",
9
10
  "astro-classname": "^2.1.0",
10
11
  "bail": "1.0.5",
@@ -20,9 +21,9 @@
20
21
  "react-app-polyfill": "^1.0.6",
21
22
  "react-dom": "16.14.0",
22
23
  "react-responsive": "^8.0.3",
24
+ "react-select": "4.3.0",
23
25
  "react-transition-group": "^4.4.1",
24
26
  "reactstrap": "^8.4.1",
25
- "react-select": "4.3.0",
26
27
  "rehype-format": "^2.2.0",
27
28
  "rehype-mathjax": "^2.0.0",
28
29
  "rehype-raw": "^2.0.0",