@seafile/sdoc-editor 0.4.32 → 0.4.34
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/comment/components/comment-delete-popover.js +47 -0
- package/dist/basic-sdk/comment/components/comment-item-content.js +3 -1
- package/dist/basic-sdk/comment/components/comment-item-reply.js +11 -5
- package/dist/basic-sdk/comment/components/comment-item-wrapper.js +10 -5
- package/dist/basic-sdk/comment/components/comment-list.css +8 -14
- package/dist/basic-sdk/extension/plugins/callout/render-elem/index.css +3 -0
- package/package.json +1 -1
- package/dist/basic-sdk/comment/components/comment-delete-shadow.js +0 -39
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { PopoverBody, UncontrolledPopover } from 'reactstrap';
|
|
4
|
+
import './comment-list.css';
|
|
5
|
+
const CommentDeletePopover = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
type,
|
|
8
|
+
setIsShowDeleteModal,
|
|
9
|
+
deleteConfirm,
|
|
10
|
+
targetId,
|
|
11
|
+
parentDom
|
|
12
|
+
} = _ref;
|
|
13
|
+
const {
|
|
14
|
+
t
|
|
15
|
+
} = useTranslation();
|
|
16
|
+
const onDeleteCancel = useCallback(event => {
|
|
17
|
+
event.stopPropagation();
|
|
18
|
+
setIsShowDeleteModal(false);
|
|
19
|
+
}, [setIsShowDeleteModal]);
|
|
20
|
+
const handleConfirm = useCallback(event => {
|
|
21
|
+
event.stopPropagation();
|
|
22
|
+
deleteConfirm();
|
|
23
|
+
}, [deleteConfirm]);
|
|
24
|
+
const message = type === 'comment' ? 'comment' : 'reply';
|
|
25
|
+
const content = t("Are_you_sure_to_delete_this_".concat(message));
|
|
26
|
+
return /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
27
|
+
container: parentDom,
|
|
28
|
+
target: targetId,
|
|
29
|
+
onClick: event => event.stopPropagation(),
|
|
30
|
+
placement: "bottom",
|
|
31
|
+
className: "comment-delete-popover",
|
|
32
|
+
isOpen: true
|
|
33
|
+
}, /*#__PURE__*/React.createElement(PopoverBody, {
|
|
34
|
+
className: "comment-delete-popover-container"
|
|
35
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "delete-tip"
|
|
37
|
+
}, content), /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: "delete-control mt-5"
|
|
39
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
40
|
+
className: "btn btn-secondary mr-2",
|
|
41
|
+
onClick: onDeleteCancel
|
|
42
|
+
}, t('Cancel')), /*#__PURE__*/React.createElement("button", {
|
|
43
|
+
className: "btn btn-primary",
|
|
44
|
+
onClick: handleConfirm
|
|
45
|
+
}, t('Confirm')))));
|
|
46
|
+
};
|
|
47
|
+
export default CommentDeletePopover;
|
|
@@ -15,7 +15,8 @@ const CommentItem = _ref => {
|
|
|
15
15
|
updateComment,
|
|
16
16
|
updateCommentState,
|
|
17
17
|
onDeleteComment,
|
|
18
|
-
t
|
|
18
|
+
t,
|
|
19
|
+
targetId
|
|
19
20
|
} = _ref;
|
|
20
21
|
const [isDropdownOpen, setDropdownOpen] = useState(false);
|
|
21
22
|
const [isEditing, setIsEditing] = useState(false);
|
|
@@ -94,6 +95,7 @@ const CommentItem = _ref => {
|
|
|
94
95
|
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
95
96
|
target: "tooltip_".concat(menuId)
|
|
96
97
|
}, t('Resolved_tip'))), /*#__PURE__*/React.createElement(Dropdown, {
|
|
98
|
+
id: targetId,
|
|
97
99
|
isOpen: isDropdownOpen,
|
|
98
100
|
toggle: () => setDropdownOpen(!isDropdownOpen)
|
|
99
101
|
}, /*#__PURE__*/React.createElement(DropdownToggle, {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useState, useRef } from 'react';
|
|
2
2
|
import { withTranslation } from 'react-i18next';
|
|
3
3
|
import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import context from '../../../context';
|
|
6
6
|
import CommentEditor from './comment-editor';
|
|
7
|
-
import CommentDeleteShadow from './comment-delete-shadow';
|
|
8
7
|
import { textToHtml } from '../utils';
|
|
9
8
|
import { useNotificationContext } from '../hooks/notification-hooks';
|
|
9
|
+
import CommentDeletePopover from './comment-delete-popover';
|
|
10
10
|
const CommentItemReply = _ref => {
|
|
11
11
|
let {
|
|
12
12
|
isActive,
|
|
@@ -20,8 +20,10 @@ const CommentItemReply = _ref => {
|
|
|
20
20
|
const {
|
|
21
21
|
notificationsInfo
|
|
22
22
|
} = useNotificationContext();
|
|
23
|
+
const liRef = useRef(null);
|
|
23
24
|
const isUnseen = notificationsInfo.notifications_map["sdoc_notification_".concat(reply.comment_id, "_").concat(reply.id)] ? true : false;
|
|
24
25
|
const [isEditing, setIsEditing] = useState(false);
|
|
26
|
+
const replyOpToolsId = "replyOpTools_".concat(reply.id);
|
|
25
27
|
const onEditToggle = useCallback(event => {
|
|
26
28
|
event.stopPropagation();
|
|
27
29
|
setIsEditing(true);
|
|
@@ -48,7 +50,8 @@ const CommentItemReply = _ref => {
|
|
|
48
50
|
}, [reply, updateReply]);
|
|
49
51
|
const user = context.getUserInfo();
|
|
50
52
|
return /*#__PURE__*/React.createElement("li", {
|
|
51
|
-
className: "comment-item"
|
|
53
|
+
className: "comment-item",
|
|
54
|
+
ref: liRef
|
|
52
55
|
}, /*#__PURE__*/React.createElement("div", {
|
|
53
56
|
className: "comment-header"
|
|
54
57
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -69,6 +72,7 @@ const CommentItemReply = _ref => {
|
|
|
69
72
|
}), /*#__PURE__*/React.createElement("span", {
|
|
70
73
|
className: "sdoc-unread-message-text-tip"
|
|
71
74
|
}, t('New')))))), isActive && user.username === reply.author && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Dropdown, {
|
|
75
|
+
id: replyOpToolsId,
|
|
72
76
|
isOpen: isDropdownOpen,
|
|
73
77
|
toggle: () => setDropdownOpen(!isDropdownOpen)
|
|
74
78
|
}, /*#__PURE__*/React.createElement(DropdownToggle, {
|
|
@@ -99,10 +103,12 @@ const CommentItemReply = _ref => {
|
|
|
99
103
|
content: reply.reply,
|
|
100
104
|
updateContent: updateContent,
|
|
101
105
|
setIsEditing: setIsEditing
|
|
102
|
-
}), isShowDeleteDialog && isActive && /*#__PURE__*/React.createElement(
|
|
106
|
+
}), isShowDeleteDialog && isActive && /*#__PURE__*/React.createElement(CommentDeletePopover, {
|
|
107
|
+
parentDom: liRef.current,
|
|
103
108
|
type: "reply",
|
|
104
109
|
deleteConfirm: _deleteReply,
|
|
105
|
-
setIsShowDeleteModal: setIsShowDeleteDialog
|
|
110
|
+
setIsShowDeleteModal: setIsShowDeleteDialog,
|
|
111
|
+
targetId: replyOpToolsId
|
|
106
112
|
}));
|
|
107
113
|
};
|
|
108
114
|
export default withTranslation('sdoc-editor')(CommentItemReply);
|
|
@@ -9,8 +9,8 @@ import CommentItemContent from './comment-item-content';
|
|
|
9
9
|
import CommentItemReply from './comment-item-reply';
|
|
10
10
|
import CommentEditor from './comment-editor';
|
|
11
11
|
import CommentItemResolvedReply from './comment-item-resolved-reply';
|
|
12
|
-
import CommentDeleteShadow from './comment-delete-shadow';
|
|
13
12
|
import { COMMENT_URL_CLASSNAME } from '../constants';
|
|
13
|
+
import CommentDeletePopover from './comment-delete-popover';
|
|
14
14
|
const CommentItemWrapper = _ref => {
|
|
15
15
|
let {
|
|
16
16
|
container,
|
|
@@ -25,6 +25,7 @@ const CommentItemWrapper = _ref => {
|
|
|
25
25
|
const {
|
|
26
26
|
dispatch
|
|
27
27
|
} = useCommentContext();
|
|
28
|
+
const commentOpToolsId = "commentOpTools_".concat(comment.id);
|
|
28
29
|
const deleteComment = useCallback(async commentId => {
|
|
29
30
|
await context.deleteComment(commentId);
|
|
30
31
|
const {
|
|
@@ -253,7 +254,8 @@ const CommentItemWrapper = _ref => {
|
|
|
253
254
|
comment: comment,
|
|
254
255
|
updateComment: updateComment,
|
|
255
256
|
updateCommentState: updateCommentState,
|
|
256
|
-
onDeleteComment: onDeleteComment
|
|
257
|
+
onDeleteComment: onDeleteComment,
|
|
258
|
+
targetId: commentOpToolsId
|
|
257
259
|
}), comment.replies && comment.replies.length > 0 && comment.replies.map(reply => {
|
|
258
260
|
const {
|
|
259
261
|
type
|
|
@@ -281,10 +283,13 @@ const CommentItemWrapper = _ref => {
|
|
|
281
283
|
placeholder: tip,
|
|
282
284
|
insertContent: insertContent,
|
|
283
285
|
hiddenComment: hiddenComment
|
|
284
|
-
}), isShowDeleteDialog && isActive && /*#__PURE__*/React.createElement(
|
|
285
|
-
type:
|
|
286
|
+
}), isShowDeleteDialog && isActive && /*#__PURE__*/React.createElement(CommentDeletePopover, {
|
|
287
|
+
type: "comment",
|
|
288
|
+
setIsShowDeleteDialog: setIsShowDeleteDialog,
|
|
289
|
+
targetId: commentOpToolsId,
|
|
286
290
|
deleteConfirm: _deleteComment,
|
|
287
|
-
setIsShowDeleteModal: setIsShowDeleteDialog
|
|
291
|
+
setIsShowDeleteModal: setIsShowDeleteDialog,
|
|
292
|
+
parentDom: listRef.current
|
|
288
293
|
}));
|
|
289
294
|
};
|
|
290
295
|
CommentItemWrapper.defaultProps = {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
.sdoc-comment-list-container .comment-ui-container {
|
|
6
6
|
background-color: #edf2fa;
|
|
7
7
|
border-radius: 8px;
|
|
8
|
-
box-shadow: 0 0 2px rgba(0,0,0
|
|
8
|
+
box-shadow: 0 0 2px rgba(0, 0, 0, .04);
|
|
9
9
|
padding: 16px 0;
|
|
10
10
|
margin-bottom: 10px;
|
|
11
11
|
cursor: pointer;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
position: relative;
|
|
16
16
|
left: -24px;
|
|
17
17
|
background: rgba(255, 255, 255, .92);
|
|
18
|
-
box-shadow: 0 1px 3px rgba(0,0,0
|
|
18
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 8px 3px rgba(0, 0, 0, .15);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.sdoc-comment-list-container .comment-item-selected-text-container {
|
|
@@ -55,20 +55,14 @@
|
|
|
55
55
|
cursor: pointer;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
inset: 0;
|
|
61
|
-
background-color: rgba(0, 0, 0, .7);
|
|
62
|
-
display: flex;
|
|
63
|
-
flex-direction: column;
|
|
64
|
-
align-items: center;
|
|
65
|
-
padding-top: 10px;
|
|
66
|
-
color: #fff;
|
|
67
|
-
z-index: 1;
|
|
58
|
+
.comment-delete-popover .comment-delete-popover-container {
|
|
59
|
+
padding: 16px;
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
.
|
|
71
|
-
|
|
62
|
+
.comment-delete-popover-container .delete-control {
|
|
63
|
+
display: flex;
|
|
64
|
+
justify-content: end;
|
|
65
|
+
width: 100%;
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
.sdoc-comment-list-container .comment-ui-container.active .comment-item:hover {
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { withTranslation } from 'react-i18next';
|
|
3
|
-
import { Button } from 'reactstrap';
|
|
4
|
-
const CommentDeleteShadow = _ref => {
|
|
5
|
-
let {
|
|
6
|
-
type,
|
|
7
|
-
setIsShowDeleteModal,
|
|
8
|
-
deleteConfirm,
|
|
9
|
-
t
|
|
10
|
-
} = _ref;
|
|
11
|
-
const onDeleteCancel = useCallback(event => {
|
|
12
|
-
event.stopPropagation();
|
|
13
|
-
setIsShowDeleteModal(false);
|
|
14
|
-
}, [setIsShowDeleteModal]);
|
|
15
|
-
const onDeleteConfirm = useCallback(event => {
|
|
16
|
-
event.stopPropagation();
|
|
17
|
-
deleteConfirm();
|
|
18
|
-
}, [deleteConfirm]);
|
|
19
|
-
const message = type === 'comment' ? 'comment' : 'reply';
|
|
20
|
-
const content = t("Are_you_sure_to_delete_this_".concat(message));
|
|
21
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
-
className: "comment-delete-shadow"
|
|
23
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
24
|
-
className: "delete-tip"
|
|
25
|
-
}, content), /*#__PURE__*/React.createElement("div", {
|
|
26
|
-
className: "delete-control"
|
|
27
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
28
|
-
color: "secondary",
|
|
29
|
-
className: "mr-2",
|
|
30
|
-
onClick: onDeleteCancel
|
|
31
|
-
}, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
32
|
-
color: "primary",
|
|
33
|
-
onClick: onDeleteConfirm
|
|
34
|
-
}, t('Confirm'))));
|
|
35
|
-
};
|
|
36
|
-
CommentDeleteShadow.defaultProps = {
|
|
37
|
-
type: 'comment'
|
|
38
|
-
};
|
|
39
|
-
export default withTranslation('sdoc-editor')(CommentDeleteShadow);
|