@seafile/sdoc-editor 2.0.60 → 2.0.61
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/dist/basic-sdk/extension/plugins/seatable-column/model.js +2 -1
- package/dist/basic-sdk/extension/plugins/seatable-column/render-elem.css +36 -0
- package/dist/basic-sdk/extension/plugins/seatable-column/render-elem.js +76 -12
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/index.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.sdoc-seatable-column-label-container {
|
|
2
|
+
position: absolute;
|
|
3
|
+
height: 42px;
|
|
4
|
+
z-index: 101;
|
|
5
|
+
width: fit-content;
|
|
6
|
+
max-width: 250px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sdoc-seatable-column-label-container .label-container {
|
|
10
|
+
height: 36px;
|
|
11
|
+
width: 100%;
|
|
12
|
+
padding: 7px 8px;
|
|
13
|
+
background-color: #fff;
|
|
14
|
+
display: flex;
|
|
15
|
+
justify-content: space-around;
|
|
16
|
+
align-items: center;
|
|
17
|
+
border-radius: 3px;
|
|
18
|
+
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
|
|
19
|
+
border: 1px solid #e8e8e8;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sdoc-seatable-column-label-container .label-container .control-icon {
|
|
23
|
+
cursor: default;
|
|
24
|
+
margin-right: 5px;
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
font-size: 12px;
|
|
27
|
+
color: #444;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.sdoc-seatable-column-label-container .label-container .control-label {
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
text-overflow: ellipsis;
|
|
34
|
+
flex-grow: 1;
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
}
|
|
@@ -9,6 +9,10 @@ exports.default = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _slateReact = require("@seafile/slate-react");
|
|
11
11
|
var _mdToHtml = _interopRequireDefault(require("../../../../slate-convert/md-to-html"));
|
|
12
|
+
var _useScrollContext = require("../../../hooks/use-scroll-context");
|
|
13
|
+
var _utils = require("../../utils");
|
|
14
|
+
var _commons = require("../../commons");
|
|
15
|
+
require("./render-elem.css");
|
|
12
16
|
const Column = _ref => {
|
|
13
17
|
let {
|
|
14
18
|
props,
|
|
@@ -20,7 +24,13 @@ const Column = _ref => {
|
|
|
20
24
|
children
|
|
21
25
|
} = props;
|
|
22
26
|
const isReadOnly = (0, _slateReact.useReadOnly)();
|
|
23
|
-
const
|
|
27
|
+
const scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
28
|
+
const seaTableColumnRef = (0, _react.useRef)(null);
|
|
29
|
+
const [menuPosition, setMenuPosition] = (0, _react.useState)({
|
|
30
|
+
top: '',
|
|
31
|
+
left: ''
|
|
32
|
+
});
|
|
33
|
+
const [isShowLabel, setIsShowLabel] = (0, _react.useState)(false);
|
|
24
34
|
const [columnValue, setColumnValue] = (0, _react.useState)('');
|
|
25
35
|
const data = element.data || {};
|
|
26
36
|
const {
|
|
@@ -49,14 +59,24 @@ const Column = _ref => {
|
|
|
49
59
|
});
|
|
50
60
|
}
|
|
51
61
|
}, [editor, element.data, isLongTextColumn, editor.currentRowIdx]);
|
|
52
|
-
const
|
|
62
|
+
const handleScroll = (0, _react.useCallback)(e => {
|
|
63
|
+
if (isReadOnly) return;
|
|
64
|
+
if (e.currentTarget.scrollTop) {
|
|
65
|
+
const menuPosition = (0, _utils.getMenuPosition)(seaTableColumnRef.current, editor);
|
|
66
|
+
setMenuPosition(menuPosition);
|
|
67
|
+
}
|
|
68
|
+
}, [editor, isReadOnly]);
|
|
53
69
|
(0, _react.useEffect)(() => {
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
if (isReadOnly) return;
|
|
71
|
+
let observerRefValue = null;
|
|
72
|
+
if (scrollRef.current) {
|
|
73
|
+
scrollRef.current.addEventListener('scroll', handleScroll);
|
|
74
|
+
observerRefValue = scrollRef.current;
|
|
58
75
|
}
|
|
59
|
-
|
|
76
|
+
return () => {
|
|
77
|
+
observerRefValue.removeEventListener('scroll', handleScroll);
|
|
78
|
+
};
|
|
79
|
+
}, [handleScroll, isReadOnly, scrollRef]);
|
|
60
80
|
const {
|
|
61
81
|
font_size = null,
|
|
62
82
|
font = null,
|
|
@@ -72,8 +92,8 @@ const Column = _ref => {
|
|
|
72
92
|
border: '1px solid transparent',
|
|
73
93
|
userSelect: 'none',
|
|
74
94
|
display: 'inline-block',
|
|
75
|
-
...(
|
|
76
|
-
border: '1px solid
|
|
95
|
+
...(isShowLabel && {
|
|
96
|
+
border: '1px solid #007bff'
|
|
77
97
|
}),
|
|
78
98
|
...(font_size && {
|
|
79
99
|
fontSize: font_size
|
|
@@ -100,16 +120,60 @@ const Column = _ref => {
|
|
|
100
120
|
textDecoration: 'line-through'
|
|
101
121
|
})
|
|
102
122
|
};
|
|
123
|
+
const onColumnClick = (0, _react.useCallback)(event => {
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
if (isReadOnly || isShowLabel) return;
|
|
126
|
+
const {
|
|
127
|
+
top,
|
|
128
|
+
left
|
|
129
|
+
} = seaTableColumnRef.current.getBoundingClientRect();
|
|
130
|
+
const menuTop = top - 42; // top = top distance - menu height
|
|
131
|
+
const newMenuPosition = {
|
|
132
|
+
top: menuTop,
|
|
133
|
+
left: left // left = callout left distance
|
|
134
|
+
};
|
|
135
|
+
// 201 is distance with browser top
|
|
136
|
+
if (menuTop <= 201) {
|
|
137
|
+
newMenuPosition['display'] = 'none';
|
|
138
|
+
}
|
|
139
|
+
setMenuPosition(newMenuPosition);
|
|
140
|
+
setIsShowLabel(true);
|
|
141
|
+
}, [isReadOnly, isShowLabel]);
|
|
142
|
+
(0, _react.useEffect)(() => {
|
|
143
|
+
const onHideColumnLabel = event => {
|
|
144
|
+
if (seaTableColumnRef.current && !seaTableColumnRef.current.contains(event.target)) {
|
|
145
|
+
setIsShowLabel(false);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
document.addEventListener('click', onHideColumnLabel, true);
|
|
149
|
+
return () => {
|
|
150
|
+
document.removeEventListener('click', onHideColumnLabel, true);
|
|
151
|
+
};
|
|
152
|
+
}, []);
|
|
103
153
|
return /*#__PURE__*/_react.default.createElement("span", Object.assign({}, attributes, {
|
|
104
|
-
style: style
|
|
105
|
-
|
|
154
|
+
style: style,
|
|
155
|
+
ref: seaTableColumnRef,
|
|
156
|
+
onClick: onColumnClick
|
|
157
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, !isLongTextColumn && columnValue, isLongTextColumn && /*#__PURE__*/_react.default.createElement("div", {
|
|
106
158
|
style: {
|
|
107
159
|
padding: '10px'
|
|
108
160
|
},
|
|
109
161
|
dangerouslySetInnerHTML: {
|
|
110
162
|
__html: columnValue
|
|
111
163
|
}
|
|
112
|
-
}), children)
|
|
164
|
+
}), children), isShowLabel && /*#__PURE__*/_react.default.createElement(_commons.ElementPopover, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
165
|
+
className: "sdoc-seatable-column-label-container",
|
|
166
|
+
style: menuPosition,
|
|
167
|
+
contentEditable: false,
|
|
168
|
+
"data-slate-node": null,
|
|
169
|
+
"data-slate-editor": false
|
|
170
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
171
|
+
className: "label-container"
|
|
172
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
173
|
+
className: `control-icon ${data.icon_class}`
|
|
174
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
175
|
+
className: "control-label"
|
|
176
|
+
}, data.name)))));
|
|
113
177
|
};
|
|
114
178
|
const renderColumn = (props, editor) => {
|
|
115
179
|
return /*#__PURE__*/_react.default.createElement(Column, {
|