@seafile/comment-editor 0.0.1-alpha.1 → 0.0.1-alpha.3
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/global-comment/global-comment-header.js +4 -3
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +1 -2
- package/dist/basic-sdk/hooks/use-comment.js +8 -4
- package/dist/basic-sdk/layout/comment-layout/index.js +13 -1
- package/dist/pages/seafile-comment-editor.js +7 -5
- package/package.json +1 -1
- package/dist/basic-sdk/comment/components/comment-context-menu/index.css +0 -16
- package/dist/basic-sdk/comment/components/comment-context-menu/index.js +0 -43
- package/dist/basic-sdk/comment/components/comment-context-menu/menu-item.js +0 -57
- package/dist/basic-sdk/comment/components/comment-operation/index.css +0 -26
- package/dist/basic-sdk/comment/components/comment-operation/index.js +0 -31
|
@@ -25,7 +25,8 @@ const GlobalCommentHeader = _ref => {
|
|
|
25
25
|
const panelHeaderRef = (0, _react.useRef)(null);
|
|
26
26
|
const [isMounted, setIsMounted] = (0, _react.useState)(false);
|
|
27
27
|
const {
|
|
28
|
-
api
|
|
28
|
+
api,
|
|
29
|
+
pluginEvent
|
|
29
30
|
} = (0, _useComment.useComment)();
|
|
30
31
|
const {
|
|
31
32
|
readAllNotifications,
|
|
@@ -47,13 +48,13 @@ const GlobalCommentHeader = _ref => {
|
|
|
47
48
|
const res = await listUnseenNotifications();
|
|
48
49
|
const notifications = res.data.notifications;
|
|
49
50
|
const eventBus = _eventBus.default.getInstance();
|
|
50
|
-
eventBus.dispatch(
|
|
51
|
+
eventBus.dispatch(pluginEvent.UNSEEN_NOTIFICATIONS_COUNT, notifications === null || notifications === void 0 ? void 0 : notifications.length);
|
|
51
52
|
eventBus.dispatch(_constants.INTERNAL_EVENT.NEW_NOTIFICATION);
|
|
52
53
|
eventBus.dispatch(_constants.INTERNAL_EVENT.CLEAR_NOTIFICATION);
|
|
53
54
|
} catch (error) {
|
|
54
55
|
//
|
|
55
56
|
}
|
|
56
|
-
}, [listUnseenNotifications, readAllNotifications]);
|
|
57
|
+
}, [listUnseenNotifications, pluginEvent.UNSEEN_NOTIFICATIONS_COUNT, readAllNotifications]);
|
|
57
58
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
58
59
|
className: "comments-panel-header"
|
|
59
60
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -9,7 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _reactI18next = require("react-i18next");
|
|
11
11
|
var _slate = require("@seafile/slate");
|
|
12
|
-
var _commentContextMenu = _interopRequireDefault(require("../../../../comment/components/comment-context-menu"));
|
|
13
12
|
var _constants = require("../../../../constants");
|
|
14
13
|
var _context = _interopRequireDefault(require("../../../../context"));
|
|
15
14
|
var _useColorContext = require("../../../../hooks/use-color-context");
|
|
@@ -156,7 +155,7 @@ const TextStyleMenuList = _ref => {
|
|
|
156
155
|
tipMessage: t('Reduce_font_size')
|
|
157
156
|
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
158
157
|
className: "sdocfont sdoc-reduce-font-size"
|
|
159
|
-
}))), idPrefix &&
|
|
158
|
+
}))), idPrefix && enableSeafileAI && /*#__PURE__*/_react.default.createElement(_aiMenu.AIContextMenu, {
|
|
160
159
|
isRichEditor: isRichEditor
|
|
161
160
|
}));
|
|
162
161
|
};
|
|
@@ -22,12 +22,14 @@ var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
|
22
22
|
const CommentContext = /*#__PURE__*/_react.default.createContext(null);
|
|
23
23
|
const CommentProvider = _ref => {
|
|
24
24
|
let {
|
|
25
|
-
editor,
|
|
26
25
|
children,
|
|
27
|
-
|
|
26
|
+
editor,
|
|
27
|
+
pluginName = '',
|
|
28
|
+
className = '',
|
|
29
|
+
pluginEventBus,
|
|
30
|
+
pluginEvent,
|
|
28
31
|
api,
|
|
29
|
-
|
|
30
|
-
className
|
|
32
|
+
onCloseCommentPanel
|
|
31
33
|
} = _ref;
|
|
32
34
|
const {
|
|
33
35
|
t
|
|
@@ -186,6 +188,8 @@ const CommentProvider = _ref => {
|
|
|
186
188
|
pluginName,
|
|
187
189
|
className,
|
|
188
190
|
api,
|
|
191
|
+
pluginEventBus,
|
|
192
|
+
pluginEvent,
|
|
189
193
|
commentsInfo,
|
|
190
194
|
commentType,
|
|
191
195
|
commentList,
|
|
@@ -22,7 +22,9 @@ const CommentLayout = _ref => {
|
|
|
22
22
|
} = _ref;
|
|
23
23
|
const {
|
|
24
24
|
className,
|
|
25
|
-
pluginName
|
|
25
|
+
pluginName,
|
|
26
|
+
pluginEventBus,
|
|
27
|
+
pluginEvent
|
|
26
28
|
} = (0, _useComment.useComment)();
|
|
27
29
|
const [width, setWidth] = (0, _react.useState)(MIN_PANEL_WIDTH);
|
|
28
30
|
const panelWrapperStyle = (0, _react.useMemo)(() => {
|
|
@@ -50,6 +52,16 @@ const CommentLayout = _ref => {
|
|
|
50
52
|
const eventBus = _eventBus.default.getInstance();
|
|
51
53
|
eventBus.dispatch(_constants.INTERNAL_EVENT.RESIZE_ARTICLE);
|
|
52
54
|
}, []);
|
|
55
|
+
(0, _react.useEffect)(() => {
|
|
56
|
+
const isShowGlobalComments = pluginName === 'sdoc' ? true : false;
|
|
57
|
+
const settings = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
58
|
+
_localStorageUtils.default.setItem(_constants.SDOC_STORAGE, {
|
|
59
|
+
...settings,
|
|
60
|
+
isShowGlobalComments
|
|
61
|
+
});
|
|
62
|
+
const eventBus = pluginEventBus.getInstance();
|
|
63
|
+
eventBus.dispatch(pluginEvent.RESIZE_ARTICLE);
|
|
64
|
+
}, [pluginEvent.RESIZE_ARTICLE, pluginEventBus, pluginName]);
|
|
53
65
|
(0, _react.useEffect)(() => {
|
|
54
66
|
const settings = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
|
|
55
67
|
const {
|
|
@@ -13,22 +13,24 @@ var _errorBoundary = _interopRequireDefault(require("../components/error-boundar
|
|
|
13
13
|
const SeafileCommentEditor = _ref => {
|
|
14
14
|
let {
|
|
15
15
|
editor,
|
|
16
|
-
className = '',
|
|
17
16
|
pluginName = '',
|
|
17
|
+
className = '',
|
|
18
|
+
pluginEventBus,
|
|
19
|
+
pluginEvent,
|
|
18
20
|
api,
|
|
19
21
|
onCloseCommentPanel
|
|
20
22
|
} = _ref;
|
|
21
23
|
_basicSdk.context.init();
|
|
22
24
|
return /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentProvider, {
|
|
25
|
+
editor: editor,
|
|
23
26
|
pluginName: pluginName,
|
|
24
27
|
className: className,
|
|
25
|
-
|
|
28
|
+
pluginEventBus: pluginEventBus,
|
|
29
|
+
pluginEvent: pluginEvent,
|
|
26
30
|
api: api,
|
|
27
31
|
onCloseCommentPanel: onCloseCommentPanel
|
|
28
32
|
}, /*#__PURE__*/_react.default.createElement(_basicSdk.CommentLayout, {
|
|
29
|
-
editor: editor
|
|
30
|
-
className: className,
|
|
31
|
-
pluginName: pluginName
|
|
33
|
+
editor: editor
|
|
32
34
|
})));
|
|
33
35
|
};
|
|
34
36
|
var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(SeafileCommentEditor);
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
.menu-group-item.sdoc-comment-menu-container {
|
|
2
|
-
width: auto;
|
|
3
|
-
color: #212529;
|
|
4
|
-
font-size: 14px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.sdoc-comment-menu-item .sdoc-comments {
|
|
8
|
-
margin-right: 4px;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.sdoc-context-menu-divider {
|
|
12
|
-
margin-right: 8px;
|
|
13
|
-
border-left: 1px solid #e5e5e5;
|
|
14
|
-
width: 1px;
|
|
15
|
-
height: 24px;
|
|
16
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _constants = require("../../../constants");
|
|
11
|
-
var _eventBus = _interopRequireDefault(require("../../../utils/event-bus"));
|
|
12
|
-
var _menuItem = _interopRequireDefault(require("./menu-item"));
|
|
13
|
-
require("./index.css");
|
|
14
|
-
const CommentContextMenu = _ref => {
|
|
15
|
-
let {
|
|
16
|
-
isRichEditor
|
|
17
|
-
} = _ref;
|
|
18
|
-
const onCommentClick = (0, _react.useCallback)(event => {
|
|
19
|
-
// Make context toolbar disappear
|
|
20
|
-
const contextToolBarDom = document.querySelector('.sdoc-context-toolbar');
|
|
21
|
-
if (contextToolBarDom) {
|
|
22
|
-
contextToolBarDom.removeAttribute('style');
|
|
23
|
-
}
|
|
24
|
-
const eventBus = _eventBus.default.getInstance();
|
|
25
|
-
eventBus.dispatch(_constants.INTERNAL_EVENT.ADD_CONTEXT_COMMENT);
|
|
26
|
-
}, []);
|
|
27
|
-
const commentProps = {
|
|
28
|
-
id: 'context-toolbar-comment',
|
|
29
|
-
isRichEditor,
|
|
30
|
-
className: 'menu-group-item sdoc-comment-menu-container',
|
|
31
|
-
disabled: false,
|
|
32
|
-
isActive: false,
|
|
33
|
-
onMouseDown: onCommentClick,
|
|
34
|
-
iconClass: 'sdocfont sdoc-comments',
|
|
35
|
-
text: 'Comment',
|
|
36
|
-
ariaLabel: 'Add_Comment',
|
|
37
|
-
type: 'sdoc-add-comment'
|
|
38
|
-
};
|
|
39
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
40
|
-
className: "sdoc-context-menu-divider"
|
|
41
|
-
}), /*#__PURE__*/_react.default.createElement(_menuItem.default, commentProps));
|
|
42
|
-
};
|
|
43
|
-
var _default = exports.default = CommentContextMenu;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactI18next = require("react-i18next");
|
|
11
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
-
var _tooltip = _interopRequireDefault(require("../../../components/tooltip"));
|
|
13
|
-
const MenuItem = _ref => {
|
|
14
|
-
let {
|
|
15
|
-
isRichEditor = true,
|
|
16
|
-
className = 'menu-group-item',
|
|
17
|
-
disabled,
|
|
18
|
-
isActive,
|
|
19
|
-
type,
|
|
20
|
-
onMouseDown,
|
|
21
|
-
id,
|
|
22
|
-
text,
|
|
23
|
-
ariaLabel,
|
|
24
|
-
iconClass
|
|
25
|
-
} = _ref;
|
|
26
|
-
const {
|
|
27
|
-
t
|
|
28
|
-
} = (0, _reactI18next.useTranslation)('sdoc-editor');
|
|
29
|
-
const onClick = (0, _react.useCallback)(event => {
|
|
30
|
-
if (disabled) return;
|
|
31
|
-
onMouseDown(event, type);
|
|
32
|
-
|
|
33
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
-
}, [disabled, type]);
|
|
35
|
-
const validClassName = (0, _classnames.default)('', className, {
|
|
36
|
-
'btn btn-icon btn-secondary btn-active': !isRichEditor,
|
|
37
|
-
'rich-icon-btn': isRichEditor,
|
|
38
|
-
'rich-icon-btn-disabled': isRichEditor && disabled,
|
|
39
|
-
'rich-icon-btn-hover': isRichEditor && !disabled
|
|
40
|
-
});
|
|
41
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
42
|
-
id: id,
|
|
43
|
-
type: "button",
|
|
44
|
-
"aria-label": ariaLabel,
|
|
45
|
-
className: validClassName,
|
|
46
|
-
disabled: disabled,
|
|
47
|
-
"data-active": isActive,
|
|
48
|
-
onClick: onClick
|
|
49
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
50
|
-
className: "sdoc-comment-menu-item"
|
|
51
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
52
|
-
className: iconClass
|
|
53
|
-
}), /*#__PURE__*/_react.default.createElement("span", null, t(text)))), /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
54
|
-
target: id
|
|
55
|
-
}, t(ariaLabel)));
|
|
56
|
-
};
|
|
57
|
-
var _default = exports.default = MenuItem;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
.sdoc-notification-count {
|
|
2
|
-
position: absolute;
|
|
3
|
-
color: #fff;
|
|
4
|
-
font-size: 12px;
|
|
5
|
-
top: -7px;
|
|
6
|
-
right: -10px;
|
|
7
|
-
padding: 2px;
|
|
8
|
-
background: #fc6440;
|
|
9
|
-
border-radius: 50%;
|
|
10
|
-
min-width: 20px;
|
|
11
|
-
min-height: 20px;
|
|
12
|
-
transform: scale(.7);
|
|
13
|
-
text-align: center;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.sdoc-plugin-operation-btn-container .sdoc-unread-message-tip {
|
|
17
|
-
position: absolute;
|
|
18
|
-
left: 12px;
|
|
19
|
-
top: 4px;
|
|
20
|
-
display: inline-block;
|
|
21
|
-
height: 6px;
|
|
22
|
-
width: 6px;
|
|
23
|
-
border-radius: 50%;
|
|
24
|
-
background-color: #fc6440;
|
|
25
|
-
margin-left: 6px;
|
|
26
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = CommentsOperation;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _constants = require("../../../constants");
|
|
11
|
-
var _eventBus = _interopRequireDefault(require("../../../utils/event-bus"));
|
|
12
|
-
require("./index.css");
|
|
13
|
-
function CommentsOperation() {
|
|
14
|
-
const [unseenNotificationsCount, setUnseenNotificationsCount] = (0, _react.useState)(0);
|
|
15
|
-
const updateUnseenNotificationsCount = (0, _react.useCallback)(count => {
|
|
16
|
-
setUnseenNotificationsCount(count);
|
|
17
|
-
}, []);
|
|
18
|
-
(0, _react.useEffect)(() => {
|
|
19
|
-
const eventBus = _eventBus.default.getInstance();
|
|
20
|
-
const unsubscribeUnseenNotificationsCount = eventBus.subscribe(_constants.INTERNAL_EVENT.UNSEEN_NOTIFICATIONS_COUNT, updateUnseenNotificationsCount);
|
|
21
|
-
return () => {
|
|
22
|
-
unsubscribeUnseenNotificationsCount();
|
|
23
|
-
};
|
|
24
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
|
-
}, []);
|
|
26
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("i", {
|
|
27
|
-
className: "sdocfont sdoc-comments"
|
|
28
|
-
}), unseenNotificationsCount > 0 && /*#__PURE__*/_react.default.createElement("span", {
|
|
29
|
-
className: "sdoc-unread-message-tip"
|
|
30
|
-
}));
|
|
31
|
-
}
|