@seafile/sdoc-editor 0.3.7 → 0.3.9
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/hooks/use-participants.js +17 -0
- package/dist/basic-sdk/socket/socket-client.js +12 -0
- package/dist/basic-sdk/socket/socket-manager.js +6 -0
- package/dist/components/toast/alert.js +7 -5
- package/dist/components/toast/toast.js +3 -3
- package/dist/components/toast/toastManager.js +2 -2
- package/dist/constants/index.js +3 -1
- package/package.json +3 -3
|
@@ -4,6 +4,8 @@ import context from '../../../context';
|
|
|
4
4
|
import { User } from '../../../model';
|
|
5
5
|
import toaster from '../../../components/toast';
|
|
6
6
|
import { getErrorMsg } from '../../../utils';
|
|
7
|
+
import { EventBus } from '../../../basic-sdk';
|
|
8
|
+
import { EXTERNAL_EVENT } from '../../../constants';
|
|
7
9
|
const ParticipantsContext = React.createContext(null);
|
|
8
10
|
export const ParticipantsProvider = props => {
|
|
9
11
|
const isSdocRevision = context.getSetting('isSdocRevision');
|
|
@@ -37,6 +39,12 @@ export const ParticipantsProvider = props => {
|
|
|
37
39
|
});
|
|
38
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
41
|
}, [updateLocalParticipants, participants]);
|
|
42
|
+
const deleteLocalParticipant = useCallback(email => {
|
|
43
|
+
if (!participants.find(participant => participant.username === email)) return;
|
|
44
|
+
let newParticipants = participants.slice(0);
|
|
45
|
+
newParticipants = newParticipants.filter(participant => participant.username !== email);
|
|
46
|
+
setParticipants(newParticipants);
|
|
47
|
+
}, [participants]);
|
|
40
48
|
const deleteParticipant = useCallback(email => {
|
|
41
49
|
if (!participants.find(participant => participant.username === email)) return;
|
|
42
50
|
context.deleteParticipants(email).then(res => {
|
|
@@ -57,6 +65,15 @@ export const ParticipantsProvider = props => {
|
|
|
57
65
|
}).catch(error => {});
|
|
58
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
67
|
}, []);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const eventBus = EventBus.getInstance();
|
|
70
|
+
const unsubscribeParticipantAdded = eventBus.subscribe(EXTERNAL_EVENT.PARTICIPANT_ADDED, updateLocalParticipants);
|
|
71
|
+
const unsubscribeParticipantRemoved = eventBus.subscribe(EXTERNAL_EVENT.PARTICIPANT_REMOVED, deleteLocalParticipant);
|
|
72
|
+
return () => {
|
|
73
|
+
unsubscribeParticipantAdded();
|
|
74
|
+
unsubscribeParticipantRemoved();
|
|
75
|
+
};
|
|
76
|
+
}, [updateLocalParticipants, deleteLocalParticipant]);
|
|
60
77
|
return /*#__PURE__*/React.createElement(ParticipantsContext.Provider, {
|
|
61
78
|
value: {
|
|
62
79
|
participants,
|
|
@@ -150,6 +150,14 @@ class SocketClient {
|
|
|
150
150
|
const socketManager = SocketManager.getInstance();
|
|
151
151
|
socketManager.receiveNewNotification(notification);
|
|
152
152
|
};
|
|
153
|
+
this.receiveParticipantAdded = uses => {
|
|
154
|
+
const socketManager = SocketManager.getInstance();
|
|
155
|
+
socketManager.receiveParticipantAdded(uses);
|
|
156
|
+
};
|
|
157
|
+
this.receiveParticipantRemoved = email => {
|
|
158
|
+
const socketManager = SocketManager.getInstance();
|
|
159
|
+
socketManager.receiveParticipantRemoved(email);
|
|
160
|
+
};
|
|
153
161
|
this.config = config;
|
|
154
162
|
this.isReconnect = false;
|
|
155
163
|
this.socket = io(config.sdocServer, {
|
|
@@ -180,6 +188,10 @@ class SocketClient {
|
|
|
180
188
|
|
|
181
189
|
// notification
|
|
182
190
|
this.socket.on('new-notification', this.receiveNewNotification);
|
|
191
|
+
|
|
192
|
+
// participant
|
|
193
|
+
this.socket.on('participant-added', this.receiveParticipantAdded);
|
|
194
|
+
this.socket.on('participant-removed', this.receiveParticipantRemoved);
|
|
183
195
|
this.socket.io.on('reconnect', this.onReconnect);
|
|
184
196
|
this.socket.io.on('reconnect_attempt', this.onReconnectAttempt);
|
|
185
197
|
this.socket.io.on('reconnect_error', this.onReconnectError);
|
|
@@ -339,6 +339,12 @@ class SocketManager {
|
|
|
339
339
|
this.closeSocketConnect = () => {
|
|
340
340
|
this.socketClient.disconnectWithServer();
|
|
341
341
|
};
|
|
342
|
+
this.receiveParticipantAdded = uses => {
|
|
343
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.PARTICIPANT_ADDED, uses);
|
|
344
|
+
};
|
|
345
|
+
this.receiveParticipantRemoved = email => {
|
|
346
|
+
this.eventBus.dispatch(EXTERNAL_EVENT.PARTICIPANT_REMOVED, email);
|
|
347
|
+
};
|
|
342
348
|
this.editor = editor;
|
|
343
349
|
this.document = _document;
|
|
344
350
|
this.socketClient = new SocketClient(config);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { css } from '
|
|
2
|
+
import { css } from 'goober';
|
|
3
3
|
class Alert extends React.PureComponent {
|
|
4
4
|
constructor(props) {
|
|
5
5
|
super(props);
|
|
@@ -104,11 +104,13 @@ class Alert extends React.PureComponent {
|
|
|
104
104
|
}
|
|
105
105
|
render() {
|
|
106
106
|
const toastStyle = this.getContainerStyle(this.props.intent);
|
|
107
|
-
return /*#__PURE__*/React.createElement("div",
|
|
107
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: "".concat(toastStyle.borderStyle, " ").concat(this.containerStyle)
|
|
109
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
108
110
|
className: this.toastIcon
|
|
109
|
-
}, /*#__PURE__*/React.createElement("i",
|
|
110
|
-
className: toastStyle.iconClass
|
|
111
|
-
}
|
|
111
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
112
|
+
className: "".concat(toastStyle.iconColor, " ").concat(toastStyle.iconClass)
|
|
113
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
112
114
|
className: this.toastTextContainer
|
|
113
115
|
}, /*#__PURE__*/React.createElement("p", {
|
|
114
116
|
className: this.toastTextTitle
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { css } from '
|
|
2
|
+
import { css, keyframes } from 'goober';
|
|
3
3
|
import Transition from 'react-transition-group/Transition';
|
|
4
4
|
import Alert from './alert';
|
|
5
5
|
const animationEasing = {
|
|
@@ -8,7 +8,7 @@ const animationEasing = {
|
|
|
8
8
|
spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
|
|
9
9
|
};
|
|
10
10
|
const ANIMATION_DURATION = 240;
|
|
11
|
-
const openAnimation =
|
|
11
|
+
const openAnimation = keyframes('openAnimation', {
|
|
12
12
|
from: {
|
|
13
13
|
opacity: 0,
|
|
14
14
|
transform: 'translateY(-120%)'
|
|
@@ -17,7 +17,7 @@ const openAnimation = css.keyframes('openAnimation', {
|
|
|
17
17
|
transform: 'translateY(0)'
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const closeAnimation =
|
|
20
|
+
const closeAnimation = keyframes('closeAnimation', {
|
|
21
21
|
from: {
|
|
22
22
|
transform: 'scale(1)',
|
|
23
23
|
opacity: 1
|
|
@@ -2,10 +2,10 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
const _excluded = ["id", "description"];
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { css } from '
|
|
5
|
+
import { css } from 'goober';
|
|
6
6
|
import Toast from './toast';
|
|
7
7
|
const wrapperClass = css({
|
|
8
|
-
maxWidth:
|
|
8
|
+
maxWidth: '560px',
|
|
9
9
|
margin: '0 auto',
|
|
10
10
|
top: 0,
|
|
11
11
|
left: 0,
|
package/dist/constants/index.js
CHANGED
|
@@ -11,7 +11,9 @@ export const EXTERNAL_EVENT = {
|
|
|
11
11
|
DOCUMENT_REPLACED_ERROR: 'document_replaced_error',
|
|
12
12
|
REMOVE_DOCUMENT: 'remove_document',
|
|
13
13
|
REMOVE_DOCUMENT_ERROR: 'remove_document_error',
|
|
14
|
-
NEW_NOTIFICATION: 'new_notification'
|
|
14
|
+
NEW_NOTIFICATION: 'new_notification',
|
|
15
|
+
PARTICIPANT_ADDED: 'participant-added',
|
|
16
|
+
PARTICIPANT_REMOVED: 'participant-removed'
|
|
15
17
|
};
|
|
16
18
|
export const TIP_TYPE = {
|
|
17
19
|
DELETE_NO_CHANGES_REVISION: 'delete_no_changes_revision',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a sdoc editor",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"copy-to-clipboard": "^3.3.3",
|
|
16
16
|
"dayjs": "1.11.2",
|
|
17
17
|
"deep-copy": "1.4.2",
|
|
18
|
+
"goober": "2.1.13",
|
|
18
19
|
"is-hotkey": "0.2.0",
|
|
19
20
|
"is-url": "^1.2.4",
|
|
20
21
|
"lodash.throttle": "4.1.1",
|
|
@@ -91,7 +92,6 @@
|
|
|
91
92
|
"eslint-plugin-react-hooks": "^1.6.1",
|
|
92
93
|
"file-loader": "6.2.0",
|
|
93
94
|
"fs-extra": "7.0.1",
|
|
94
|
-
"glamor": "2.20.40",
|
|
95
95
|
"html-webpack-plugin": "^4.0.0-beta.5",
|
|
96
96
|
"husky": "8.0.3",
|
|
97
97
|
"i18next": "22.4.9",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"postcss-loader": "^6.2.1",
|
|
114
114
|
"postcss-normalize": "^10.0.1",
|
|
115
115
|
"postcss-preset-env": "^7.0.1",
|
|
116
|
-
"postcss-safe-parser": "^
|
|
116
|
+
"postcss-safe-parser": "^6.0.0",
|
|
117
117
|
"prettier": "3.1.0",
|
|
118
118
|
"prop-types": "15.8.1",
|
|
119
119
|
"raf": "3.4.0",
|