@seafile/sdoc-editor 1.0.138 → 1.0.139
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/assets/css/sdoc-editor-article.css +1 -1
- package/dist/basic-sdk/comment/components/comment-item-collapse-wrapper.js +1 -0
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +2 -1
- package/dist/basic-sdk/comment/components/comment-list.css +80 -41
- package/dist/basic-sdk/comment/components/comment-list.js +40 -45
- package/dist/basic-sdk/comment/components/editor-comment.js +54 -39
- package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +4 -4
- package/dist/basic-sdk/comment/components/elements-comment-count/index.js +4 -2
- package/dist/basic-sdk/comment/components/global-comment/index.css +10 -16
- package/dist/basic-sdk/comment/components/style.css +2 -2
- package/dist/basic-sdk/comment/utils/index.js +15 -2
- package/dist/basic-sdk/constants/index.js +12 -3
- package/dist/basic-sdk/extension/plugins/code-block/helpers.js +2 -2
- package/dist/basic-sdk/hooks/use-selection-position.js +4 -9
- package/dist/basic-sdk/layout/article-container.js +37 -21
- package/dist/basic-sdk/outline/style.css +2 -0
- package/dist/basic-sdk/right-panel/index.css +2 -1
- package/dist/basic-sdk/utils/full-width-mode.js +49 -0
- package/dist/components/doc-operations/more-operations.js +32 -7
- package/dist/components/doc-operations/style.css +36 -0
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +2 -1
- package/public/locales/de/sdoc-editor.json +2 -1
- package/public/locales/en/sdoc-editor.json +2 -1
- package/public/locales/es/sdoc-editor.json +2 -1
- package/public/locales/es_AR/sdoc-editor.json +2 -1
- package/public/locales/es_MX/sdoc-editor.json +2 -1
- package/public/locales/fr/sdoc-editor.json +2 -1
- package/public/locales/it/sdoc-editor.json +2 -1
- package/public/locales/ru/sdoc-editor.json +2 -1
- package/public/locales/zh_CN/sdoc-editor.json +2 -1
|
@@ -71,6 +71,7 @@ const CommentItemCollapseWrapper = _ref => {
|
|
|
71
71
|
});
|
|
72
72
|
}, [editor, element, scrollRef]);
|
|
73
73
|
const onItemClick = (0, _react.useCallback)(event => {
|
|
74
|
+
event.stopPropagation();
|
|
74
75
|
if (event.target.className === _constants.COMMENT_URL_CLASSNAME) return;
|
|
75
76
|
setCurrentCommentGroup(topLevelComment.id);
|
|
76
77
|
}, [setCurrentCommentGroup, topLevelComment.id]);
|
|
@@ -251,7 +251,8 @@ const CommentItemWrapper = _ref => {
|
|
|
251
251
|
'active': isActive,
|
|
252
252
|
'sdoc-resolved': comment.resolved,
|
|
253
253
|
'd-flex flex-column': element,
|
|
254
|
-
'comment-item-detail-wrapper': isGlobalComment
|
|
254
|
+
'global-comment-item-detail-wrapper': isGlobalComment,
|
|
255
|
+
'comment-item-detail-wrapper': !isGlobalComment
|
|
255
256
|
});
|
|
256
257
|
const tip = comment.resolved ? 'Reopen_discussion' : 'Enter_reply_shift_Enter_for_new_line_Enter_to_send';
|
|
257
258
|
const handleScrollToArticle = (0, _react.useCallback)(e => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
.sdoc-comment-list-container {
|
|
2
2
|
position: absolute;
|
|
3
3
|
margin-top: 5px;
|
|
4
|
+
left: 14px;
|
|
4
5
|
}
|
|
5
6
|
|
|
6
7
|
.sdoc-comment-list-container .article.sdoc-comment-editor {
|
|
@@ -8,14 +9,31 @@
|
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
.sdoc-comment-list-container .comment-ui-container {
|
|
11
|
-
background-color: #
|
|
12
|
-
|
|
13
|
-
box-shadow:
|
|
14
|
-
padding: 16px
|
|
15
|
-
|
|
12
|
+
background-color: #FFF;
|
|
13
|
+
margin-bottom: 0px;
|
|
14
|
+
box-shadow: none;
|
|
15
|
+
padding: 16px;
|
|
16
|
+
border-radius: 0px;
|
|
16
17
|
cursor: pointer;
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
/* comment detail list */
|
|
21
|
+
.sdoc-comment-list-container .comment-item-detail-wrapper .comment-item-list {
|
|
22
|
+
margin-bottom: 16px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.sdoc-comment-list-container .comment-item-detail-wrapper .comment-item-list .comment-item .comment-content {
|
|
26
|
+
margin-bottom: 0px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.sdoc-comment-list-container .comment-item-detail-wrapper .comment-item {
|
|
30
|
+
padding: 16px 16px 0px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sdoc-comment-list-container .comment-ui-container.sdoc-resolved {
|
|
34
|
+
background: #f5f5f5;
|
|
35
|
+
}
|
|
36
|
+
|
|
19
37
|
.sdoc-comment-list-container .comment-ui-container.active {
|
|
20
38
|
position: relative;
|
|
21
39
|
left: -5px;
|
|
@@ -52,12 +70,12 @@
|
|
|
52
70
|
overflow-y: auto;
|
|
53
71
|
margin: 0;
|
|
54
72
|
padding: 0;
|
|
55
|
-
padding-bottom:
|
|
73
|
+
padding-bottom: 0px;
|
|
56
74
|
}
|
|
57
75
|
|
|
58
76
|
.sdoc-comment-list-container .comment-item {
|
|
59
77
|
position: relative;
|
|
60
|
-
padding:
|
|
78
|
+
padding: 0px;
|
|
61
79
|
cursor: pointer;
|
|
62
80
|
}
|
|
63
81
|
|
|
@@ -82,14 +100,11 @@
|
|
|
82
100
|
align-items: center;
|
|
83
101
|
}
|
|
84
102
|
|
|
85
|
-
|
|
103
|
+
/* content */
|
|
104
|
+
.comment-item .comment-content {
|
|
86
105
|
margin-top: 10px;
|
|
87
|
-
margin-left:
|
|
88
|
-
word-break: keep-all;
|
|
106
|
+
margin-left: 35px;
|
|
89
107
|
word-wrap: break-word;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.comment-item .comment-content {
|
|
93
108
|
font-size: 14px;
|
|
94
109
|
}
|
|
95
110
|
|
|
@@ -104,17 +119,65 @@
|
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
.comment-item .comment-content p {
|
|
107
|
-
margin: 0
|
|
122
|
+
margin: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* footer */
|
|
126
|
+
.comment-item .comment-footer {
|
|
127
|
+
display: flex;
|
|
128
|
+
color: #666666;
|
|
129
|
+
font-size: 14px;
|
|
130
|
+
margin-left: 35px;
|
|
131
|
+
margin-top: 16px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.comment-item .comment-footer .comments-count {
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
position: relative;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.comment-item .comment-footer .comments-count .comments-count-number {
|
|
141
|
+
margin-left: 8px;
|
|
142
|
+
margin-top: -2px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.comment-item .comment-footer .comment-author {
|
|
146
|
+
margin-left: 20px;
|
|
147
|
+
align-items: initial;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.comment-item .comment-footer .comment-author__avatar {
|
|
151
|
+
width: 16px;
|
|
152
|
+
height: 16px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.comment-item .comment-footer .comment-author__avatar img {
|
|
156
|
+
border-radius: 50%;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.comment-item .comment-footer .comment-author__latest-reply {
|
|
160
|
+
margin-left: 8px;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.comment-item .comment-footer .comment-author__latest-reply p {
|
|
164
|
+
margin: 0px;
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
text-overflow: ellipsis;
|
|
167
|
+
white-space: nowrap;
|
|
168
|
+
width: 220px;
|
|
108
169
|
}
|
|
109
170
|
|
|
171
|
+
/* header */
|
|
110
172
|
.sdoc-comment-list-container .comment-header .comment-author__avatar {
|
|
111
173
|
display: flex;
|
|
112
174
|
align-items: center;
|
|
113
175
|
}
|
|
114
176
|
|
|
115
|
-
.sdoc-comment-list-container .comment-header .comment-author__avatar img {
|
|
116
|
-
|
|
117
|
-
|
|
177
|
+
.sdoc-article-container .sdoc-comment-list-container .comment-item .comment-header .comment-author__avatar img {
|
|
178
|
+
margin-top: 3px;
|
|
179
|
+
width: 24px;
|
|
180
|
+
height: 24px;
|
|
118
181
|
border-radius: 50%;
|
|
119
182
|
}
|
|
120
183
|
|
|
@@ -299,20 +362,6 @@
|
|
|
299
362
|
}
|
|
300
363
|
|
|
301
364
|
/* editor Side comment preview */
|
|
302
|
-
.sdoc-article-container .sdoc-comment-list-container {
|
|
303
|
-
width: 312px;
|
|
304
|
-
/* font-size: 14px !important; */
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.sdoc-article-container .comment-ui-container {
|
|
308
|
-
padding: 0;
|
|
309
|
-
margin: 0;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
.sdoc-article-container .sdoc-comment-list-container .comment-item {
|
|
313
|
-
padding: 16px 16px 0px 16px;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
365
|
.sdoc-article-container .sdoc-comment-list-container .comment-item .comment-editor-wrapper.pb-3 {
|
|
317
366
|
padding-bottom: 0 !important;
|
|
318
367
|
}
|
|
@@ -321,16 +370,6 @@
|
|
|
321
370
|
align-items: flex-start;
|
|
322
371
|
}
|
|
323
372
|
|
|
324
|
-
.sdoc-article-container .sdoc-comment-list-container .comment-item .comment-content {
|
|
325
|
-
margin-left: 33px;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.sdoc-article-container .sdoc-comment-list-container .comment-item .comment-author__avatar img {
|
|
329
|
-
margin-top: 3px;
|
|
330
|
-
width: 24px;
|
|
331
|
-
height: 24px;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
373
|
.sdoc-article-container .sdoc-comment-list-container .comment-item .comment-author__info {
|
|
335
374
|
padding-left: 8px;
|
|
336
375
|
}
|
|
@@ -13,40 +13,23 @@ var _useSelectionPosition = require("../../hooks/use-selection-position");
|
|
|
13
13
|
var _useCommentContext = require("../hooks/comment-hooks/use-comment-context");
|
|
14
14
|
var _commentEditor = _interopRequireDefault(require("./comment-editor"));
|
|
15
15
|
var _commentItemWrapper = _interopRequireDefault(require("./comment-item-wrapper"));
|
|
16
|
-
var
|
|
17
|
-
var _constants = require("../../constants");
|
|
16
|
+
var _commentItemCollapseWrapper = _interopRequireDefault(require("./comment-item-collapse-wrapper"));
|
|
18
17
|
require("./comment-list.css");
|
|
19
18
|
const CommentList = _ref => {
|
|
19
|
+
var _topLevelComment$repl, _topLevelComment$repl2;
|
|
20
20
|
let {
|
|
21
|
+
editor,
|
|
21
22
|
comments,
|
|
22
|
-
|
|
23
|
+
activeElement,
|
|
23
24
|
hiddenComment,
|
|
24
25
|
deleteUnseenNotifications
|
|
25
26
|
} = _ref;
|
|
26
27
|
const commentRef = (0, _react.useRef)(null);
|
|
27
|
-
const position = (0, _useSelectionPosition.useCommentListPosition)();
|
|
28
|
-
const [activeComment, setActiveComment] = (0, _react.useState)(false);
|
|
29
|
-
const handelArticleClick = (0, _react.useCallback)(event => {
|
|
30
|
-
if (event.target.className !== 'article') return;
|
|
31
|
-
hiddenComment();
|
|
32
|
-
}, [hiddenComment]);
|
|
33
|
-
// onMount: hidden comment
|
|
34
|
-
(0, _react.useEffect)(() => {
|
|
35
|
-
const eventBus = _eventBus.default.getInstance();
|
|
36
|
-
const unsubscribe = eventBus.subscribe(_constants.INTERNAL_EVENT.ARTICLE_CLICK, handelArticleClick);
|
|
37
|
-
return () => {
|
|
38
|
-
unsubscribe();
|
|
39
|
-
};
|
|
40
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
-
}, []);
|
|
42
|
-
const onCommentClick = (0, _react.useCallback)(comment => {
|
|
43
|
-
if (activeComment && activeComment.id === comment.id) return;
|
|
44
|
-
setActiveComment(comment);
|
|
45
|
-
deleteUnseenNotifications && deleteUnseenNotifications(comment);
|
|
46
|
-
}, [activeComment, deleteUnseenNotifications]);
|
|
28
|
+
const position = (0, _useSelectionPosition.useCommentListPosition)(activeElement);
|
|
47
29
|
const {
|
|
48
30
|
dispatch
|
|
49
31
|
} = (0, _useCommentContext.useCommentContext)();
|
|
32
|
+
const [isShowCommentDetail, setIsShowCommentDetail] = (0, _react.useState)(false);
|
|
50
33
|
const insertComment = (0, _react.useCallback)(async (elementId, comment) => {
|
|
51
34
|
const res = await _context.default.insertComment(comment);
|
|
52
35
|
const {
|
|
@@ -69,7 +52,7 @@ const CommentList = _ref => {
|
|
|
69
52
|
}, [dispatch]);
|
|
70
53
|
const insertContent = (0, _react.useCallback)(content => {
|
|
71
54
|
const user = _context.default.getUserInfo();
|
|
72
|
-
const elementId =
|
|
55
|
+
const elementId = activeElement === null || activeElement === void 0 ? void 0 : activeElement.id;
|
|
73
56
|
const time = (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss');
|
|
74
57
|
const comment = {
|
|
75
58
|
comment: content,
|
|
@@ -81,51 +64,63 @@ const CommentList = _ref => {
|
|
|
81
64
|
updated_at: time
|
|
82
65
|
};
|
|
83
66
|
insertComment(elementId, comment);
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
setIsShowCommentDetail(true);
|
|
68
|
+
}, [insertComment, activeElement === null || activeElement === void 0 ? void 0 : activeElement.id]);
|
|
69
|
+
const onClickOutSide = (0, _react.useCallback)(e => {
|
|
86
70
|
const commentWrapper = commentRef.current;
|
|
87
71
|
const clickIsInComment = commentWrapper && commentWrapper.contains(e.target) && commentWrapper !== e.target;
|
|
88
72
|
if (clickIsInComment) return;
|
|
89
|
-
|
|
90
|
-
}, []);
|
|
73
|
+
hiddenComment();
|
|
74
|
+
}, [hiddenComment]);
|
|
91
75
|
(0, _react.useEffect)(() => {
|
|
92
|
-
document.addEventListener('click',
|
|
76
|
+
document.addEventListener('click', onClickOutSide);
|
|
93
77
|
commentRef.current.scrollIntoView({
|
|
94
78
|
behavior: 'smooth',
|
|
95
79
|
block: 'nearest'
|
|
96
80
|
});
|
|
97
81
|
return () => {
|
|
98
|
-
document.removeEventListener('click',
|
|
82
|
+
document.removeEventListener('click', onClickOutSide);
|
|
99
83
|
};
|
|
100
|
-
}, [
|
|
84
|
+
}, [onClickOutSide]);
|
|
85
|
+
const setCurrentCommentGroup = (0, _react.useCallback)(() => {
|
|
86
|
+
setIsShowCommentDetail(true);
|
|
87
|
+
}, []);
|
|
88
|
+
const topLevelComment = (comments === null || comments === void 0 ? void 0 : comments.length) > 0 ? comments[0] : {};
|
|
89
|
+
const replyCount = topLevelComment === null || topLevelComment === void 0 ? void 0 : (_topLevelComment$repl = topLevelComment.replies) === null || _topLevelComment$repl === void 0 ? void 0 : _topLevelComment$repl.length;
|
|
90
|
+
const latestReply = ((_topLevelComment$repl2 = topLevelComment.replies) === null || _topLevelComment$repl2 === void 0 ? void 0 : _topLevelComment$repl2.length) > 0 ? topLevelComment.replies[topLevelComment.replies.length - 1] : null;
|
|
101
91
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
102
92
|
ref: commentRef,
|
|
103
93
|
id: "sdoc-comment-list-container",
|
|
104
94
|
className: "sdoc-comment-list-container",
|
|
105
95
|
style: {
|
|
106
|
-
top: position.y
|
|
96
|
+
top: position.y,
|
|
97
|
+
width: '300px'
|
|
107
98
|
}
|
|
108
|
-
},
|
|
99
|
+
}, !isShowCommentDetail && Object.keys(topLevelComment).length > 0 && /*#__PURE__*/_react.default.createElement(_commentItemCollapseWrapper.default, {
|
|
100
|
+
key: comments.id,
|
|
101
|
+
editor: editor,
|
|
102
|
+
topLevelComment: topLevelComment,
|
|
103
|
+
replyCount: replyCount,
|
|
104
|
+
latestReply: latestReply,
|
|
105
|
+
setCurrentCommentGroup: setCurrentCommentGroup
|
|
106
|
+
}), !isShowCommentDetail && comments.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
107
|
+
className: "comment-ui-container active"
|
|
108
|
+
}, /*#__PURE__*/_react.default.createElement(_commentEditor.default, {
|
|
109
|
+
type: "comment",
|
|
110
|
+
globalComment: true,
|
|
111
|
+
insertContent: insertContent,
|
|
112
|
+
hiddenComment: hiddenComment,
|
|
113
|
+
commentRef: commentRef
|
|
114
|
+
})), isShowCommentDetail && comments.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
109
115
|
className: "comment-list"
|
|
110
116
|
}, comments.map(comment => {
|
|
111
117
|
if (comment.resolved) return null;
|
|
112
|
-
const isActive = activeComment && activeComment.id === comment.id;
|
|
113
118
|
const props = {
|
|
114
119
|
key: comment.id,
|
|
115
120
|
comment: comment,
|
|
116
|
-
isActive:
|
|
117
|
-
onCommentClick: onCommentClick,
|
|
118
|
-
hiddenComment: () => setActiveComment(null)
|
|
121
|
+
isActive: true
|
|
119
122
|
};
|
|
120
123
|
return /*#__PURE__*/_react.default.createElement(_commentItemWrapper.default, props);
|
|
121
|
-
})), comments.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
122
|
-
className: "comment-ui-container active"
|
|
123
|
-
}, /*#__PURE__*/_react.default.createElement(_commentEditor.default, {
|
|
124
|
-
type: "comment",
|
|
125
|
-
globalComment: true,
|
|
126
|
-
insertContent: insertContent,
|
|
127
|
-
hiddenComment: hiddenComment,
|
|
128
|
-
commentRef: commentRef
|
|
129
124
|
})));
|
|
130
125
|
};
|
|
131
126
|
var _default = exports.default = CommentList;
|
|
@@ -14,56 +14,74 @@ var _commentList = _interopRequireDefault(require("./comment-list"));
|
|
|
14
14
|
var _useSelectionElement = require("../../hooks/use-selection-element");
|
|
15
15
|
var _useCommentContext = require("../hooks/comment-hooks/use-comment-context");
|
|
16
16
|
var _elementsCommentCount = _interopRequireDefault(require("./elements-comment-count"));
|
|
17
|
+
var _eventBus = _interopRequireDefault(require("../../../basic-sdk/utils/event-bus"));
|
|
18
|
+
var _index = require("../utils/index");
|
|
17
19
|
var _constants = require("../../extension/constants");
|
|
18
20
|
var _constants2 = require("../../constants");
|
|
21
|
+
var _constants3 = require("../../../basic-sdk/constants");
|
|
19
22
|
const EditorComment = _ref => {
|
|
20
23
|
let {
|
|
21
24
|
deleteUnseenNotifications,
|
|
22
25
|
editor
|
|
23
26
|
} = _ref;
|
|
24
27
|
(0, _useSelectionUpdate.default)();
|
|
25
|
-
const selectionElement = (0, _useSelectionElement.useSelectionElement)({
|
|
26
|
-
editor
|
|
27
|
-
});
|
|
28
|
-
const [isShowComments, setIsShowComments] = (0, _react.useState)(false);
|
|
29
|
-
const onAddCommentToggle = (0, _react.useCallback)(() => {
|
|
30
|
-
setIsShowComments(true);
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
// When selectionElement update, recalculate comment's panel state
|
|
34
|
-
const [comments, setComments] = (0, _react.useState)([]);
|
|
35
28
|
const {
|
|
36
29
|
element_comments_map
|
|
37
30
|
} = (0, _useCommentContext.useCommentContext)().commentsInfo;
|
|
38
|
-
(0,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
const currentSelectionElement = (0, _useSelectionElement.useSelectionElement)({
|
|
32
|
+
editor
|
|
33
|
+
}); // The slate node of the current cursor line
|
|
34
|
+
const [activeElement, setActiveElement] = (0, _react.useState)(null); // The slate node currently activated by clicking
|
|
35
|
+
const [comments, setComments] = (0, _react.useState)([]);
|
|
36
|
+
const [isShowComments, setIsShowComments] = (0, _react.useState)(false);
|
|
37
|
+
const onAddCommentToggle = (0, _react.useCallback)(event => {
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
let activeElement = currentSelectionElement;
|
|
40
|
+
// Add comments to image elements in the image block
|
|
41
|
+
if (currentSelectionElement.type === _constants.ELEMENT_TYPE.IMAGE_BLOCK) {
|
|
42
|
+
activeElement = currentSelectionElement.children.find(item => (item === null || item === void 0 ? void 0 : item.type) === _constants.ELEMENT_TYPE.IMAGE);
|
|
50
43
|
}
|
|
51
|
-
|
|
52
|
-
setIsShowComments(
|
|
53
|
-
}, [
|
|
44
|
+
setActiveElement(activeElement);
|
|
45
|
+
setIsShowComments(true);
|
|
46
|
+
}, [currentSelectionElement]);
|
|
47
|
+
const onSelectElement = (0, _react.useCallback)(elementId => {
|
|
48
|
+
const activeElement = (0, _index.getCommentElementById)(elementId, editor);
|
|
49
|
+
setActiveElement(activeElement);
|
|
50
|
+
const unresolvedComments = element_comments_map[elementId].filter(item => !item.resolved);
|
|
51
|
+
setComments(unresolvedComments);
|
|
52
|
+
setIsShowComments(true);
|
|
53
|
+
}, [editor, element_comments_map]);
|
|
54
54
|
const hiddenComment = (0, _react.useCallback)(() => {
|
|
55
55
|
setComments([]);
|
|
56
56
|
setIsShowComments(false);
|
|
57
57
|
}, []);
|
|
58
|
+
|
|
59
|
+
// Comments are updated to modify the current comment
|
|
60
|
+
(0, _react.useEffect)(() => {
|
|
61
|
+
if (activeElement) {
|
|
62
|
+
const unresolvedComments = element_comments_map[activeElement.id].filter(item => !item.resolved);
|
|
63
|
+
setComments(unresolvedComments);
|
|
64
|
+
if (unresolvedComments.length === 0) {
|
|
65
|
+
setIsShowComments(false);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
|
+
}, [element_comments_map]);
|
|
70
|
+
(0, _react.useEffect)(() => {
|
|
71
|
+
const eventBus = _eventBus.default.getInstance();
|
|
72
|
+
eventBus.dispatch(_constants3.INTERNAL_EVENT.RESIZE_ARTICLE, {
|
|
73
|
+
isHasComments: isShowComments
|
|
74
|
+
});
|
|
75
|
+
}, [isShowComments]);
|
|
58
76
|
const cursor = (0, _helper.useCursorPosition)();
|
|
59
77
|
const style = (0, _react.useMemo)(() => {
|
|
60
78
|
var _Node$string;
|
|
61
|
-
if (
|
|
79
|
+
if (currentSelectionElement && ((_Node$string = _slate.Node.string(currentSelectionElement)) === null || _Node$string === void 0 ? void 0 : _Node$string.length) === 0 && !currentSelectionElement.children.find(n => n.type === _constants.ELEMENT_TYPE.IMAGE)) {
|
|
62
80
|
return {
|
|
63
81
|
top: '-99999px'
|
|
64
82
|
};
|
|
65
83
|
}
|
|
66
|
-
const comments = element_comments_map[
|
|
84
|
+
const comments = element_comments_map[currentSelectionElement === null || currentSelectionElement === void 0 ? void 0 : currentSelectionElement.id];
|
|
67
85
|
const unresolvedComments = comments && comments.filter(item => !item.resolved);
|
|
68
86
|
const hasComments = unresolvedComments && unresolvedComments.length > 0;
|
|
69
87
|
if (hasComments) return {
|
|
@@ -76,8 +94,7 @@ const EditorComment = _ref => {
|
|
|
76
94
|
top: cursor.y,
|
|
77
95
|
zIndex: _constants2.Z_INDEX.COMMENT_ADD
|
|
78
96
|
};
|
|
79
|
-
}, [
|
|
80
|
-
if (!selectionElement) return null;
|
|
97
|
+
}, [currentSelectionElement, element_comments_map, cursor.y, isShowComments]);
|
|
81
98
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
82
99
|
className: "sdoc-comment-container"
|
|
83
100
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -94,18 +111,16 @@ const EditorComment = _ref => {
|
|
|
94
111
|
className: "sdocfont sdoc-add-comment mr-1"
|
|
95
112
|
}))), /*#__PURE__*/_react.default.createElement(_elementsCommentCount.default, {
|
|
96
113
|
elementCommentsMap: element_comments_map,
|
|
97
|
-
|
|
98
|
-
editor: editor
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
width: '294px'
|
|
103
|
-
} : null
|
|
104
|
-
}, isShowComments && /*#__PURE__*/_react.default.createElement(_commentList.default, {
|
|
114
|
+
activeElement: activeElement,
|
|
115
|
+
editor: editor,
|
|
116
|
+
onSelectElement: onSelectElement
|
|
117
|
+
}), isShowComments && /*#__PURE__*/_react.default.createElement(_commentList.default, {
|
|
118
|
+
editor: editor,
|
|
105
119
|
comments: comments,
|
|
106
|
-
|
|
120
|
+
activeElement: activeElement,
|
|
121
|
+
onSelectElement: onSelectElement,
|
|
107
122
|
hiddenComment: hiddenComment,
|
|
108
123
|
deleteUnseenNotifications: deleteUnseenNotifications
|
|
109
|
-
})))
|
|
124
|
+
})));
|
|
110
125
|
};
|
|
111
126
|
var _default = exports.default = EditorComment;
|
|
@@ -9,7 +9,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _core = require("../../../extension/core");
|
|
10
10
|
var _helper = require("../../helper");
|
|
11
11
|
var _mouseEvent = require("../../../utils/mouse-event");
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
12
|
var _constants = require("../../../constants");
|
|
14
13
|
var _useScrollContext = require("../../../hooks/use-scroll-context");
|
|
15
14
|
const ElementCommentCount = _ref => {
|
|
@@ -17,15 +16,16 @@ const ElementCommentCount = _ref => {
|
|
|
17
16
|
elementId,
|
|
18
17
|
isElementSelected,
|
|
19
18
|
commentsCount,
|
|
20
|
-
editor
|
|
19
|
+
editor,
|
|
20
|
+
onSelectElement
|
|
21
21
|
} = _ref;
|
|
22
22
|
const element = (0, _core.getNodeById)(editor.children, elementId);
|
|
23
23
|
const [top, setTop] = (0, _react.useState)(-9999);
|
|
24
24
|
const scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
25
25
|
const onClick = (0, _react.useCallback)(event => {
|
|
26
26
|
(0, _mouseEvent.eventStopPropagation)(event);
|
|
27
|
-
(
|
|
28
|
-
}, [
|
|
27
|
+
onSelectElement(elementId);
|
|
28
|
+
}, [elementId, onSelectElement]);
|
|
29
29
|
const updatePosition = (0, _react.useCallback)(() => {
|
|
30
30
|
if (!element) return;
|
|
31
31
|
const scrollTop = scrollRef.current.scrollTop || 0;
|
|
@@ -12,7 +12,8 @@ const ElementsCommentCount = _ref => {
|
|
|
12
12
|
let {
|
|
13
13
|
elementCommentsMap,
|
|
14
14
|
selectionElement,
|
|
15
|
-
editor
|
|
15
|
+
editor,
|
|
16
|
+
onSelectElement
|
|
16
17
|
} = _ref;
|
|
17
18
|
if (!elementCommentsMap) return null;
|
|
18
19
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -29,7 +30,8 @@ const ElementsCommentCount = _ref => {
|
|
|
29
30
|
elementId: elementId,
|
|
30
31
|
isElementSelected: isSelected,
|
|
31
32
|
commentsCount: unresolvedCommentCount,
|
|
32
|
-
editor: editor
|
|
33
|
+
editor: editor,
|
|
34
|
+
onSelectElement: onSelectElement
|
|
33
35
|
});
|
|
34
36
|
}));
|
|
35
37
|
};
|
|
@@ -193,6 +193,7 @@
|
|
|
193
193
|
/* custom */
|
|
194
194
|
.sdoc-comment-drawer .sdoc-comment-list-container {
|
|
195
195
|
margin-top: 0px;
|
|
196
|
+
left: 0;
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
.sdoc-comment-drawer .sdoc-comment-list-container .comment-ui-container {
|
|
@@ -211,10 +212,6 @@
|
|
|
211
212
|
padding-bottom: 0px;
|
|
212
213
|
}
|
|
213
214
|
|
|
214
|
-
.sdoc-comment-drawer .sdoc-comment-list-container .comment-ui-container .comment-item {
|
|
215
|
-
padding: 0px
|
|
216
|
-
}
|
|
217
|
-
|
|
218
215
|
.sdoc-comment-drawer .sdoc-comment-list-container .comment-ui-container.active .comment-item:hover {
|
|
219
216
|
background-color: unset;
|
|
220
217
|
}
|
|
@@ -225,9 +222,8 @@
|
|
|
225
222
|
margin-top: -5px;
|
|
226
223
|
}
|
|
227
224
|
|
|
228
|
-
.sdoc-comment-drawer .sdoc-comment-list-container .comment-item .comment-content{
|
|
225
|
+
.sdoc-comment-drawer .sdoc-comment-list-container .comment-item .comment-content {
|
|
229
226
|
margin-left: 35px;
|
|
230
|
-
margin-bottom: 16px;
|
|
231
227
|
display: flex;
|
|
232
228
|
align-items: center;
|
|
233
229
|
}
|
|
@@ -237,13 +233,6 @@
|
|
|
237
233
|
margin-right: 6px;
|
|
238
234
|
}
|
|
239
235
|
|
|
240
|
-
.sdoc-comment-drawer .sdoc-comment-list-container .comment-item .comment-footer {
|
|
241
|
-
display: flex;
|
|
242
|
-
color: #666666;
|
|
243
|
-
font-size: 14px;
|
|
244
|
-
margin-left: 35px;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
236
|
.sdoc-comment-drawer .sdoc-comment-list-container .comment-item .comment-footer .comments-count {
|
|
248
237
|
display: flex;
|
|
249
238
|
align-items: center;
|
|
@@ -296,15 +285,20 @@
|
|
|
296
285
|
border: 1px solid #dee3eb;
|
|
297
286
|
}
|
|
298
287
|
|
|
299
|
-
|
|
288
|
+
/* global detail */
|
|
289
|
+
.sdoc-comment-drawer .sdoc-comment-list-container .global-comment-item-detail-wrapper {
|
|
300
290
|
border-bottom: 0px
|
|
301
291
|
}
|
|
302
292
|
|
|
303
|
-
.sdoc-comment-drawer .sdoc-comment-list-container .comment-item-detail-wrapper:hover {
|
|
293
|
+
.sdoc-comment-drawer .sdoc-comment-list-container .global-comment-item-detail-wrapper:hover {
|
|
304
294
|
background-color: #FFF;
|
|
305
295
|
}
|
|
306
296
|
|
|
307
|
-
.sdoc-comment-drawer .sdoc-comment-list-container .comment-item-detail-wrapper .comment-operation .sdoc-confirm {
|
|
297
|
+
.sdoc-comment-drawer .sdoc-comment-list-container .global-comment-item-detail-wrapper .comment-operation .sdoc-confirm {
|
|
308
298
|
color: rgb(70, 77, 90);
|
|
309
299
|
font-weight: unset;
|
|
310
300
|
}
|
|
301
|
+
|
|
302
|
+
.sdoc-comment-drawer .sdoc-comment-list-container .global-comment-item-detail-wrapper .comment-item:not(:last-child){
|
|
303
|
+
margin-bottom: 16px;
|
|
304
|
+
}
|
|
@@ -18,9 +18,10 @@ Object.defineProperty(exports, "generatorNotificationKey", {
|
|
|
18
18
|
return _notificationUtils.generatorNotificationKey;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
exports.searchCollaborators = void 0;
|
|
21
|
+
exports.searchCollaborators = exports.getCommentElementById = void 0;
|
|
22
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
23
23
|
var _slate = require("@seafile/slate");
|
|
24
|
+
var _slateReact = require("@seafile/slate-react");
|
|
24
25
|
var _utils = require("../../../utils");
|
|
25
26
|
var _constants = require("../../../constants");
|
|
26
27
|
var _notificationUtils = require("./notification-utils");
|
|
@@ -251,4 +252,16 @@ const focusToCommentElement = (editor, element) => {
|
|
|
251
252
|
};
|
|
252
253
|
(0, _core.focusEditor)(editor, range);
|
|
253
254
|
};
|
|
254
|
-
exports.focusToCommentElement = focusToCommentElement;
|
|
255
|
+
exports.focusToCommentElement = focusToCommentElement;
|
|
256
|
+
const getCommentElementById = (elementId, editor) => {
|
|
257
|
+
let element = null;
|
|
258
|
+
const dom = document.querySelectorAll(`[data-id="${elementId}"]`)[0];
|
|
259
|
+
if (dom) {
|
|
260
|
+
const slateNode = _slateReact.ReactEditor.toSlateNode(editor, dom);
|
|
261
|
+
if (slateNode) {
|
|
262
|
+
element = slateNode;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return element;
|
|
266
|
+
};
|
|
267
|
+
exports.getCommentElementById = getCommentElementById;
|
|
@@ -4,7 +4,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.PAGE_EDIT_AREA_WIDTH = exports.MODIFY_TYPE = exports.INTERNAL_EVENT = exports.HEADER_OUTLINE_WIDTH_MAPPING = exports.DOCUMENT_PLUGIN_EDITOR = exports.DIFF_VIEWER = exports.COMMENT_EDITOR_EDIT_AREA_WIDTH = exports.COMMENT_EDITOR = void 0;
|
|
7
|
+
exports.PAGE_EDIT_AREA_WIDTH = exports.MODIFY_TYPE = exports.LEFT_OUTLINE_WIDTH = exports.INTERNAL_EVENT = exports.HEADER_OUTLINE_WIDTH_MAPPING = exports.FULL_WIDTH_MODE = exports.DOCUMENT_PLUGIN_EDITOR = exports.DIFF_VIEWER = exports.COMMENT_EDITOR_EDIT_AREA_WIDTH = exports.COMMENT_EDITOR = exports.ARTICLE_MIN_WIDTH = exports.ARTICLE_FULL_WIDTH = void 0;
|
|
8
8
|
Object.defineProperty(exports, "PLUGIN_BTN_POSITION", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function () {
|
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "PLUGIN_DISPLAY_TYPE", {
|
|
|
17
17
|
return _plugin.PLUGIN_DISPLAY_TYPE;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
exports.Z_INDEX = exports.WIKI_OUTLINE = exports.WIKI_EDITOR = exports.REVISION_DIFF_VALUE = exports.REVISION_DIFF_KEY = exports.REBASE_TYPES = exports.REBASE_TYPE = exports.REBASE_ORIGIN = exports.REBASE_MARK_KEY = exports.REBASE_MARKS = void 0;
|
|
20
|
+
exports.Z_INDEX = exports.WIKI_OUTLINE = exports.WIKI_EDITOR = exports.RIGHT_COMMENT_WIDTH = exports.REVISION_DIFF_VALUE = exports.REVISION_DIFF_KEY = exports.REBASE_TYPES = exports.REBASE_TYPE = exports.REBASE_ORIGIN = exports.REBASE_MARK_KEY = exports.REBASE_MARKS = void 0;
|
|
21
21
|
var Z_INDEX = _interopRequireWildcard(require("./z-index"));
|
|
22
22
|
exports.Z_INDEX = Z_INDEX;
|
|
23
23
|
var _plugin = require("./plugin");
|
|
@@ -84,4 +84,13 @@ const REBASE_ORIGIN = exports.REBASE_ORIGIN = {
|
|
|
84
84
|
MY: 'my'
|
|
85
85
|
};
|
|
86
86
|
const REBASE_MARKS = exports.REBASE_MARKS = [REBASE_MARK_KEY.ORIGIN, REBASE_MARK_KEY.REBASE_TYPE, REBASE_MARK_KEY.MODIFY_TYPE, REBASE_MARK_KEY.OLD_ELEMENT];
|
|
87
|
-
const DIFF_VIEWER = exports.DIFF_VIEWER = 'diff_viewer';
|
|
87
|
+
const DIFF_VIEWER = exports.DIFF_VIEWER = 'diff_viewer';
|
|
88
|
+
const FULL_WIDTH_MODE = exports.FULL_WIDTH_MODE = 'full-width-mode';
|
|
89
|
+
|
|
90
|
+
// left outline and right comment width
|
|
91
|
+
const LEFT_OUTLINE_WIDTH = exports.LEFT_OUTLINE_WIDTH = 280;
|
|
92
|
+
const RIGHT_COMMENT_WIDTH = exports.RIGHT_COMMENT_WIDTH = 314;
|
|
93
|
+
|
|
94
|
+
// min width and full width
|
|
95
|
+
const ARTICLE_MIN_WIDTH = exports.ARTICLE_MIN_WIDTH = '794px';
|
|
96
|
+
const ARTICLE_FULL_WIDTH = exports.ARTICLE_FULL_WIDTH = 'calc(100% - 50px - 50px)'; // The left and right sides are 50
|
|
@@ -17,12 +17,12 @@ const isMenuDisabled = (editor, readonly) => {
|
|
|
17
17
|
const {
|
|
18
18
|
selection
|
|
19
19
|
} = editor;
|
|
20
|
-
if (selection
|
|
20
|
+
if (selection === null) return true;
|
|
21
21
|
if ((0, _helper.getCalloutEntry)(editor)) return true;
|
|
22
22
|
const selectedElems = (0, _core.getSelectedElems)(editor);
|
|
23
23
|
const hasVoid = selectedElems.some(elem => editor.isVoid(elem));
|
|
24
24
|
if (hasVoid) return true;
|
|
25
|
-
const isMatch = selectedElems.
|
|
25
|
+
const isMatch = selectedElems.every(elem => {
|
|
26
26
|
const type = (0, _core.getNodeType)(elem);
|
|
27
27
|
if (type === _constants.PARAGRAPH) return true;
|
|
28
28
|
return false;
|
|
@@ -5,24 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useSelectionPosition = exports.useCommentListPosition = void 0;
|
|
7
7
|
var _slateReact = require("@seafile/slate-react");
|
|
8
|
-
var _slate = require("@seafile/slate");
|
|
9
8
|
var _useScrollContext = require("./use-scroll-context");
|
|
10
|
-
const useSelectionPosition =
|
|
9
|
+
const useSelectionPosition = node => {
|
|
11
10
|
const editor = (0, _slateReact.useSlateStatic)();
|
|
12
11
|
if (!editor.selection) return {
|
|
13
12
|
x: 0,
|
|
14
13
|
y: 0
|
|
15
14
|
};
|
|
16
|
-
const node = _slate.Editor.above(editor, {
|
|
17
|
-
mode: 'lowest',
|
|
18
|
-
match: n => _slate.Element.isElement(n) && _slate.Editor.isBlock(editor, n)
|
|
19
|
-
});
|
|
20
15
|
if (!node) return {
|
|
21
16
|
x: 0,
|
|
22
17
|
y: 0
|
|
23
18
|
};
|
|
24
19
|
try {
|
|
25
|
-
const domNode = _slateReact.ReactEditor.toDOMNode(editor, node
|
|
20
|
+
const domNode = _slateReact.ReactEditor.toDOMNode(editor, node);
|
|
26
21
|
const rect = domNode.getBoundingClientRect();
|
|
27
22
|
return rect;
|
|
28
23
|
} catch (error) {
|
|
@@ -34,8 +29,8 @@ const useSelectionPosition = () => {
|
|
|
34
29
|
}
|
|
35
30
|
};
|
|
36
31
|
exports.useSelectionPosition = useSelectionPosition;
|
|
37
|
-
const useCommentListPosition =
|
|
38
|
-
const selectionPosition = useSelectionPosition();
|
|
32
|
+
const useCommentListPosition = selectionElement => {
|
|
33
|
+
const selectionPosition = useSelectionPosition(selectionElement);
|
|
39
34
|
const headerHeight = 100;
|
|
40
35
|
const scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
41
36
|
const {
|
|
@@ -7,49 +7,67 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = ArticleContainer;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _constants = require("../constants");
|
|
11
|
-
var _useScrollContext = require("../hooks/use-scroll-context");
|
|
12
|
-
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
13
10
|
var _outline = require("../outline");
|
|
11
|
+
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
12
|
+
var _useScrollContext = require("../hooks/use-scroll-context");
|
|
13
|
+
var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
|
|
14
|
+
var _fullWidthMode = require("../utils/full-width-mode");
|
|
15
|
+
var _constants = require("../constants");
|
|
14
16
|
function ArticleContainer(_ref) {
|
|
15
17
|
let {
|
|
16
18
|
editor,
|
|
17
19
|
children
|
|
18
20
|
} = _ref;
|
|
21
|
+
const scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
19
22
|
const articleRef = (0, _react.useRef)(null);
|
|
23
|
+
const articleFullWidthModeRef = (0, _react.useRef)({});
|
|
24
|
+
const [containerStyle, setContainerStyle] = (0, _react.useState)({});
|
|
20
25
|
(0, _react.useEffect)(() => {
|
|
21
26
|
editor.width = articleRef.current.children[0].clientWidth;
|
|
22
27
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
28
|
}, []);
|
|
24
|
-
const
|
|
25
|
-
|
|
29
|
+
const handleWidthModeSize = (0, _react.useCallback)(() => {
|
|
30
|
+
const isFullWidth = _localStorageUtils.default.getItem(_constants.FULL_WIDTH_MODE);
|
|
31
|
+
if (!isFullWidth) return;
|
|
32
|
+
const containerStyle = (0, _fullWidthMode.getStyleByFullWidthMode)(articleFullWidthModeRef, scrollRef, editor);
|
|
33
|
+
setContainerStyle(containerStyle);
|
|
34
|
+
}, [editor, scrollRef]);
|
|
26
35
|
const handleWindowResize = (0, _react.useCallback)(function () {
|
|
27
36
|
let {
|
|
28
|
-
scrollIntoArticle = false
|
|
37
|
+
scrollIntoArticle = false,
|
|
38
|
+
isFullWidth = _localStorageUtils.default.getItem(_constants.FULL_WIDTH_MODE),
|
|
39
|
+
isHasComments
|
|
29
40
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
41
|
+
const isShowOutline = (0, _outline.getOutlineSetting)();
|
|
42
|
+
|
|
43
|
+
// Full width mode
|
|
44
|
+
if (isFullWidth) {
|
|
45
|
+
articleFullWidthModeRef.current['isShowOutline'] = isShowOutline;
|
|
46
|
+
articleFullWidthModeRef.current['isHasComments'] = isHasComments;
|
|
47
|
+
handleWidthModeSize();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// get state from local storage
|
|
52
|
+
const containerStyle = {
|
|
53
|
+
width: _constants.ARTICLE_MIN_WIDTH
|
|
54
|
+
};
|
|
30
55
|
const rect = scrollRef.current.getBoundingClientRect();
|
|
31
56
|
const articleRect = articleRef.current.getBoundingClientRect();
|
|
32
|
-
// get state from local storage
|
|
33
|
-
const isShowOutline = (0, _outline.getOutlineSetting)();
|
|
34
57
|
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR && (rect.width - articleRect.width) / 2 < 280) {
|
|
35
|
-
|
|
36
|
-
marginLeft: '280px'
|
|
37
|
-
});
|
|
58
|
+
containerStyle['marginLeft'] = '280px';
|
|
38
59
|
} else {
|
|
39
|
-
|
|
60
|
+
containerStyle['marginLeft'] = 'auto';
|
|
40
61
|
}
|
|
62
|
+
setContainerStyle(containerStyle);
|
|
41
63
|
if (scrollIntoArticle) {
|
|
42
64
|
articleRef.current.scrollIntoView({
|
|
43
65
|
inline: 'start',
|
|
44
66
|
block: 'nearest'
|
|
45
67
|
});
|
|
46
68
|
}
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
70
|
}, [editor.editorType, scrollRef]);
|
|
48
|
-
const handelArticleClick = (0, _react.useCallback)(event => {
|
|
49
|
-
if (!articleRef.current.contains(event.target)) return;
|
|
50
|
-
const eventBus = _eventBus.default.getInstance();
|
|
51
|
-
eventBus.dispatch(_constants.INTERNAL_EVENT.ARTICLE_CLICK, event);
|
|
52
|
-
}, []);
|
|
53
71
|
(0, _react.useEffect)(() => {
|
|
54
72
|
const eventBus = _eventBus.default.getInstance();
|
|
55
73
|
const unsubscribeOutline = eventBus.subscribe(_constants.INTERNAL_EVENT.OUTLINE_STATE_CHANGED, handleWindowResize);
|
|
@@ -77,13 +95,11 @@ function ArticleContainer(_ref) {
|
|
|
77
95
|
className: "article sdoc-editor__article",
|
|
78
96
|
style: articleStyle,
|
|
79
97
|
id: "sdoc-editor-print-wrapper",
|
|
80
|
-
ref: articleRef
|
|
81
|
-
onClick: handelArticleClick
|
|
98
|
+
ref: articleRef
|
|
82
99
|
}, children), _react.default.Children.count(children) > 1 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
83
100
|
className: "article sdoc-editor__article",
|
|
84
101
|
style: articleStyle,
|
|
85
102
|
id: "sdoc-editor-print-wrapper",
|
|
86
|
-
ref: articleRef
|
|
87
|
-
onClick: handelArticleClick
|
|
103
|
+
ref: articleRef
|
|
88
104
|
}, children[0]), [...children.slice(1)]));
|
|
89
105
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
.sdoc-outline-wrapper {
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 100px;
|
|
4
|
+
left: 0;
|
|
4
5
|
bottom: 0;
|
|
5
6
|
display: flex;
|
|
6
7
|
margin: 20px 30px 20px 16px;
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
.wiki-outline-wrapper {
|
|
17
18
|
position: fixed;
|
|
18
19
|
right: 0;
|
|
20
|
+
left: unset;
|
|
19
21
|
margin: 0;
|
|
20
22
|
pointer-events: unset !important;
|
|
21
23
|
flex: none;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getStyleByFullWidthMode = void 0;
|
|
8
|
+
var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
|
|
9
|
+
var _constants = require("../constants");
|
|
10
|
+
const getStyleByFullWidthMode = (articleFullWidthModeRef, scrollRef, editor) => {
|
|
11
|
+
const {
|
|
12
|
+
isShowOutline,
|
|
13
|
+
isHasComments
|
|
14
|
+
} = (articleFullWidthModeRef === null || articleFullWidthModeRef === void 0 ? void 0 : articleFullWidthModeRef.current) || {};
|
|
15
|
+
const containerStyle = {};
|
|
16
|
+
containerStyle['width'] = _constants.ARTICLE_FULL_WIDTH;
|
|
17
|
+
|
|
18
|
+
// Has outline and comments
|
|
19
|
+
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR && isHasComments) {
|
|
20
|
+
const rect = scrollRef.current.getBoundingClientRect();
|
|
21
|
+
const currentMaxWidth = rect.width - 100;
|
|
22
|
+
const leftWidth = _constants.LEFT_OUTLINE_WIDTH - 50;
|
|
23
|
+
const rightWidth = _constants.RIGHT_COMMENT_WIDTH - 50;
|
|
24
|
+
// Enough width to enable widescreen mode
|
|
25
|
+
if (currentMaxWidth - leftWidth - rightWidth > _constants.ARTICLE_MIN_WIDTH.slice(0, -2)) {
|
|
26
|
+
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
27
|
+
containerStyle['width'] = containerStyle['width'].slice(0, -1) + ` - ${leftWidth + rightWidth}px`;
|
|
28
|
+
} else {
|
|
29
|
+
containerStyle['width'] = _constants.ARTICLE_MIN_WIDTH;
|
|
30
|
+
_localStorageUtils.default.setItem(_constants.FULL_WIDTH_MODE, false);
|
|
31
|
+
}
|
|
32
|
+
return containerStyle;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Has outline
|
|
36
|
+
if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR) {
|
|
37
|
+
containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
|
|
38
|
+
const adjustWidth = ` - ${_constants.LEFT_OUTLINE_WIDTH - 50}px`; // One side is 50
|
|
39
|
+
containerStyle['width'] = containerStyle['width'].slice(0, -1) + adjustWidth;
|
|
40
|
+
}
|
|
41
|
+
// Has comments
|
|
42
|
+
if (isHasComments) {
|
|
43
|
+
containerStyle['marginRight'] = `${_constants.RIGHT_COMMENT_WIDTH}px`;
|
|
44
|
+
const adjustWidth = ` - ${_constants.RIGHT_COMMENT_WIDTH - 50}px`; // One side is 50
|
|
45
|
+
containerStyle['width'] = containerStyle['width'].slice(0, -1) + adjustWidth;
|
|
46
|
+
}
|
|
47
|
+
return containerStyle;
|
|
48
|
+
};
|
|
49
|
+
exports.getStyleByFullWidthMode = getStyleByFullWidthMode;
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
+
var _DTableSwitch2 = _interopRequireDefault(require("dtable-ui-component/lib/DTableSwitch"));
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _reactI18next = require("react-i18next");
|
|
11
12
|
var _reactstrap = require("reactstrap");
|
|
12
13
|
var _printJs = _interopRequireDefault(require("@seafile/print-js"));
|
|
14
|
+
var _menuShortcutIndicator = _interopRequireDefault(require("../../basic-sdk/extension/commons/menu-shortcut-indicator"));
|
|
15
|
+
var _context = _interopRequireDefault(require("../../context"));
|
|
13
16
|
var _basicSdk = require("../../basic-sdk");
|
|
17
|
+
var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
|
|
18
|
+
var _utils = require("../../utils");
|
|
14
19
|
var _constants = require("../../constants");
|
|
15
|
-
var _context = _interopRequireDefault(require("../../context"));
|
|
16
20
|
var _constants2 = require("../../basic-sdk/constants");
|
|
17
|
-
var _menuShortcutIndicator = _interopRequireDefault(require("../../basic-sdk/extension/commons/menu-shortcut-indicator"));
|
|
18
|
-
var _utils = require("../../utils");
|
|
19
21
|
const MoreOperations = _ref => {
|
|
20
22
|
let {
|
|
21
23
|
t
|
|
22
24
|
} = _ref;
|
|
23
25
|
const [isDropdownOpen, setIsDropdownOpen] = (0, _react.useState)(false);
|
|
26
|
+
const [isFullWidthMode, setIsFullWidthMode] = (0, _react.useState)(_localStorageUtils.default.getItem(_constants2.FULL_WIDTH_MODE));
|
|
24
27
|
const parentFolderURL = _context.default.getSetting('parentFolderURL');
|
|
25
28
|
const isPro = _context.default.getSetting('isPro');
|
|
26
29
|
const isFreezed = _context.default.getSetting('isFreezed');
|
|
@@ -36,7 +39,12 @@ const MoreOperations = _ref => {
|
|
|
36
39
|
};
|
|
37
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
41
|
}, []);
|
|
39
|
-
const toggleDropdown = (0, _react.useCallback)(isDropdownOpen => {
|
|
42
|
+
const toggleDropdown = (0, _react.useCallback)((event, isDropdownOpen) => {
|
|
43
|
+
if (isDropdownOpen) {
|
|
44
|
+
// Clicking the fullscreen menu does not close the collapsed menu
|
|
45
|
+
const el = document.getElementById('sdoc-full-width-mode-wrapper');
|
|
46
|
+
if (el && el.contains(event.target)) return;
|
|
47
|
+
}
|
|
40
48
|
setIsDropdownOpen(!isDropdownOpen);
|
|
41
49
|
}, []);
|
|
42
50
|
const handlePrint = (0, _react.useCallback)(() => {
|
|
@@ -68,10 +76,19 @@ const MoreOperations = _ref => {
|
|
|
68
76
|
const printTexts = (0, _utils.isMac)() ? ['⌘', 'P'] : ['Ctrl', 'P'];
|
|
69
77
|
return printTexts;
|
|
70
78
|
}, []);
|
|
79
|
+
const onSwitchMode = (0, _react.useCallback)(() => {
|
|
80
|
+
const newMode = !isFullWidthMode;
|
|
81
|
+
_localStorageUtils.default.setItem(_constants2.FULL_WIDTH_MODE, newMode);
|
|
82
|
+
const eventBus = _basicSdk.EventBus.getInstance();
|
|
83
|
+
eventBus.dispatch(_constants2.INTERNAL_EVENT.RESIZE_ARTICLE, {
|
|
84
|
+
isFullWidth: newMode
|
|
85
|
+
});
|
|
86
|
+
setIsFullWidthMode(newMode);
|
|
87
|
+
}, [isFullWidthMode]);
|
|
71
88
|
return /*#__PURE__*/_react.default.createElement(_reactstrap.Dropdown, {
|
|
72
89
|
className: "sdoc-operator-folder",
|
|
73
90
|
isOpen: isDropdownOpen,
|
|
74
|
-
toggle:
|
|
91
|
+
toggle: event => toggleDropdown(event, isDropdownOpen)
|
|
75
92
|
}, /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownToggle, {
|
|
76
93
|
className: "op-item",
|
|
77
94
|
tag: "span"
|
|
@@ -96,7 +113,15 @@ const MoreOperations = _ref => {
|
|
|
96
113
|
}, t('Freeze_document')), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
97
114
|
className: "sdoc-dropdown-menu-item",
|
|
98
115
|
onClick: handleClickHistory
|
|
99
|
-
}, t('Document_history')),
|
|
116
|
+
}, t('Document_history')), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
117
|
+
id: "sdoc-full-width-mode-wrapper",
|
|
118
|
+
className: "sdoc-dropdown-menu-item"
|
|
119
|
+
}, /*#__PURE__*/_react.default.createElement(_DTableSwitch2.default, {
|
|
120
|
+
checked: isFullWidthMode,
|
|
121
|
+
placeholder: t('Full_width_mode'),
|
|
122
|
+
switchClassName: "sdoc-full-width-mode-wrapper w-100",
|
|
123
|
+
onChange: onSwitchMode
|
|
124
|
+
})), parentFolderURL && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
100
125
|
className: "sdoc-operator-folder-divider"
|
|
101
126
|
}), /*#__PURE__*/_react.default.createElement(_reactstrap.DropdownItem, {
|
|
102
127
|
className: "sdoc-dropdown-menu-item",
|
|
@@ -55,3 +55,39 @@
|
|
|
55
55
|
height: 1px;
|
|
56
56
|
width: 100%;
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
.sdoc-operator-folder .sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdoc-full-width-mode-wrapper .custom-switch {
|
|
60
|
+
padding-left: 0px;
|
|
61
|
+
width: 100%;
|
|
62
|
+
justify-content: space-between;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.sdoc-operator-folder .sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdoc-full-width-mode-wrapper .custom-switch .custom-switch-description {
|
|
67
|
+
margin-left: 0px;
|
|
68
|
+
color: unset;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.sdoc-operator-folder .sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdoc-full-width-mode-wrapper .custom-switch .custom-switch-indicator {
|
|
72
|
+
width: 22px;
|
|
73
|
+
height: 12px;
|
|
74
|
+
border-radius: 6px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.sdoc-operator-folder .sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdoc-full-width-mode-wrapper .custom-switch .custom-switch-indicator:before {
|
|
78
|
+
height: 8px;
|
|
79
|
+
width: 8px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.sdoc-operator-folder .sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdoc-full-width-mode-wrapper .custom-switch .custom-switch-input:checked ~ .custom-switch-indicator:before {
|
|
83
|
+
left: 12px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.sdoc-operator-folder .sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdoc-full-width-mode-wrapper .custom-switch .custom-switch-input:checked~.custom-switch-indicator {
|
|
87
|
+
background: #ff8000;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.sdoc-operator-folder .sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdoc-full-width-mode-wrapper .custom-switch .custom-switch-input:focus~.custom-switch-indicator {
|
|
91
|
+
box-shadow: 0 0 0 2px rgba(255, 128, 0, .25);
|
|
92
|
+
border-color: #ff8000;
|
|
93
|
+
}
|
package/package.json
CHANGED