浏览代码

etherpad: refactor to share code with mobile

- simplify initialization procedure
- set user display name as the Etherpad name\
- use SharedDocumentButton
j8
Saúl Ibarra Corretgé 5 年前
父节点
当前提交
98698ba89a

+ 6
- 4
modules/UI/UI.js 查看文件

@@ -15,7 +15,7 @@ import Filmstrip from './videolayout/Filmstrip';
15 15
 
16 16
 import { getLocalParticipant } from '../../react/features/base/participants';
17 17
 import { toggleChat } from '../../react/features/chat';
18
-import { setEtherpadHasInitialzied } from '../../react/features/etherpad';
18
+import { setDocumentUrl } from '../../react/features/etherpad';
19 19
 import { setFilmstripVisible } from '../../react/features/filmstrip';
20 20
 import { setNotificationsEnabled } from '../../react/features/notifications';
21 21
 import {
@@ -240,10 +240,12 @@ UI.initEtherpad = name => {
240 240
         return;
241 241
     }
242 242
     logger.log('Etherpad is enabled');
243
-    etherpadManager
244
-        = new EtherpadManager(config.etherpad_base, name, eventEmitter);
245 243
 
246
-    APP.store.dispatch(setEtherpadHasInitialzied());
244
+    etherpadManager = new EtherpadManager(eventEmitter);
245
+
246
+    const url = new URL(name, config.etherpad_base);
247
+
248
+    APP.store.dispatch(setDocumentUrl(url.toString()));
247 249
 };
248 250
 
249 251
 /**

+ 5
- 21
modules/UI/etherpad/Etherpad.js 查看文件

@@ -1,22 +1,12 @@
1 1
 /* global $, APP, interfaceConfig */
2 2
 
3
-import { setDocumentEditingState } from '../../../react/features/etherpad';
3
+import { getSharedDocumentUrl, setDocumentEditingState } from '../../../react/features/etherpad';
4 4
 import { getToolboxHeight } from '../../../react/features/toolbox';
5 5
 
6 6
 import VideoLayout from '../videolayout/VideoLayout';
7 7
 import LargeContainer from '../videolayout/LargeContainer';
8 8
 import Filmstrip from '../videolayout/Filmstrip';
9 9
 
10
-/**
11
- * Etherpad options.
12
- */
13
-const options = $.param({
14
-    showControls: true,
15
-    showChat: false,
16
-    showLineNumbers: true,
17
-    useMonospaceFont: false
18
-});
19
-
20 10
 /**
21 11
  *
22 12
  */
@@ -70,13 +60,13 @@ class Etherpad extends LargeContainer {
70 60
     /**
71 61
      * Creates new Etherpad object
72 62
      */
73
-    constructor(domain, name) {
63
+    constructor(url) {
74 64
         super();
75 65
 
76 66
         const iframe = document.createElement('iframe');
77 67
 
78 68
         iframe.id = 'etherpadIFrame';
79
-        iframe.src = `${domain + name}?${options}`;
69
+        iframe.src = url;
80 70
         iframe.frameBorder = 0;
81 71
         iframe.scrolling = 'no';
82 72
         iframe.width = DEFAULT_WIDTH;
@@ -199,13 +189,7 @@ export default class EtherpadManager {
199 189
     /**
200 190
      *
201 191
      */
202
-    constructor(domain, name, eventEmitter) {
203
-        if (!domain || !name) {
204
-            throw new Error('missing domain or name');
205
-        }
206
-
207
-        this.domain = domain;
208
-        this.name = name;
192
+    constructor(eventEmitter) {
209 193
         this.eventEmitter = eventEmitter;
210 194
         this.etherpad = null;
211 195
     }
@@ -228,7 +212,7 @@ export default class EtherpadManager {
228 212
      * Create new Etherpad frame.
229 213
      */
230 214
     openEtherpad() {
231
-        this.etherpad = new Etherpad(this.domain, this.name);
215
+        this.etherpad = new Etherpad(getSharedDocumentUrl(APP.store.getState));
232 216
         VideoLayout.addLargeVideoContainer(
233 217
             ETHERPAD_CONTAINER_TYPE,
234 218
             this.etherpad

+ 0
- 10
react/features/etherpad/actionTypes.js 查看文件

@@ -1,13 +1,3 @@
1
-/**
2
- * The type of the action which signals document editing has been enabled.
3
- *
4
- * {
5
- *     type: ETHERPAD_INITIALIZED
6
- * }
7
- */
8
-export const ETHERPAD_INITIALIZED = 'ETHERPAD_INITIALIZED';
9
-
10
-
11 1
 /**
12 2
  * The type of the action which signals document editing has stopped or started.
13 3
  *

+ 0
- 14
react/features/etherpad/actions.js 查看文件

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import {
4
-    ETHERPAD_INITIALIZED,
5 4
     SET_DOCUMENT_EDITING_STATUS,
6 5
     SET_DOCUMENT_URL,
7 6
     TOGGLE_DOCUMENT_EDITING
@@ -40,19 +39,6 @@ export function setDocumentUrl(documentUrl: ?string) {
40 39
     };
41 40
 }
42 41
 
43
-/**
44
- * Dispatches an action to set Etherpad as having been initialized.
45
- *
46
- * @returns {{
47
- *    type: ETHERPAD_INITIALIZED
48
- * }}
49
- */
50
-export function setEtherpadHasInitialzied() {
51
-    return {
52
-        type: ETHERPAD_INITIALIZED
53
-    };
54
-}
55
-
56 42
 /**
57 43
  * Dispatches an action to show or hide Etherpad.
58 44
  *

+ 2
- 20
react/features/etherpad/reducer.js 查看文件

@@ -2,11 +2,7 @@
2 2
 
3 3
 import { ReducerRegistry } from '../base/redux';
4 4
 
5
-import {
6
-    ETHERPAD_INITIALIZED,
7
-    SET_DOCUMENT_EDITING_STATUS,
8
-    SET_DOCUMENT_URL
9
-} from './actionTypes';
5
+import { SET_DOCUMENT_EDITING_STATUS, SET_DOCUMENT_URL } from './actionTypes';
10 6
 
11 7
 const DEFAULT_STATE = {
12 8
 
@@ -21,15 +17,7 @@ const DEFAULT_STATE = {
21 17
      * @public
22 18
      * @type {boolean}
23 19
      */
24
-    editing: false,
25
-
26
-    /**
27
-     * Whether or not Etherpad is ready to use.
28
-     *
29
-     * @public
30
-     * @type {boolean}
31
-     */
32
-    initialized: false
20
+    editing: false
33 21
 };
34 22
 
35 23
 /**
@@ -39,12 +27,6 @@ ReducerRegistry.register(
39 27
     'features/etherpad',
40 28
     (state = DEFAULT_STATE, action) => {
41 29
         switch (action.type) {
42
-        case ETHERPAD_INITIALIZED:
43
-            return {
44
-                ...state,
45
-                initialized: true
46
-            };
47
-
48 30
         case SET_DOCUMENT_EDITING_STATUS:
49 31
             return {
50 32
                 ...state,

+ 3
- 56
react/features/toolbox/components/web/Toolbox.js 查看文件

@@ -21,7 +21,6 @@ import {
21 21
     IconRaisedHand,
22 22
     IconRec,
23 23
     IconShareDesktop,
24
-    IconShareDoc,
25 24
     IconShareVideo
26 25
 } from '../../../base/icons';
27 26
 import {
@@ -34,7 +33,7 @@ import { OverflowMenuItem } from '../../../base/toolbox';
34 33
 import { getLocalVideoTrack, toggleScreensharing } from '../../../base/tracks';
35 34
 import { VideoBlurButton } from '../../../blur';
36 35
 import { ChatCounter, toggleChat } from '../../../chat';
37
-import { toggleDocument } from '../../../etherpad';
36
+import { SharedDocumentButton } from '../../../etherpad';
38 37
 import { openFeedbackDialog } from '../../../feedback';
39 38
 import {
40 39
     beginAddPeople,
@@ -111,16 +110,6 @@ type Props = {
111 110
      */
112 111
     _dialog: boolean,
113 112
 
114
-    /**
115
-     * Whether or not the local participant is currently editing a document.
116
-     */
117
-    _editingDocument: boolean,
118
-
119
-    /**
120
-     * Whether or not collaborative document editing is enabled.
121
-     */
122
-    _etherpadInitialized: boolean,
123
-
124 113
     /**
125 114
      * Whether or not call feedback can be sent.
126 115
      */
@@ -247,8 +236,6 @@ class Toolbox extends Component<Props, State> {
247 236
         this._onToolbarOpenVideoQuality
248 237
             = this._onToolbarOpenVideoQuality.bind(this);
249 238
         this._onToolbarToggleChat = this._onToolbarToggleChat.bind(this);
250
-        this._onToolbarToggleEtherpad
251
-            = this._onToolbarToggleEtherpad.bind(this);
252 239
         this._onToolbarToggleFullScreen
253 240
             = this._onToolbarToggleFullScreen.bind(this);
254 241
         this._onToolbarToggleProfile
@@ -424,16 +411,6 @@ class Toolbox extends Component<Props, State> {
424 411
         this.props.dispatch(toggleChat());
425 412
     }
426 413
 
427
-    /**
428
-     * Dispatches an action to show or hide document editing.
429
-     *
430
-     * @private
431
-     * @returns {void}
432
-     */
433
-    _doToggleEtherpad() {
434
-        this.props.dispatch(toggleDocument());
435
-    }
436
-
437 414
     /**
438 415
      * Dispatches an action to toggle screensharing.
439 416
      *
@@ -749,25 +726,6 @@ class Toolbox extends Component<Props, State> {
749 726
         this._doToggleChat();
750 727
     }
751 728
 
752
-    _onToolbarToggleEtherpad: () => void;
753
-
754
-    /**
755
-     * Creates an analytics toolbar event and dispatches an action for toggling
756
-     * the display of document editing.
757
-     *
758
-     * @private
759
-     * @returns {void}
760
-     */
761
-    _onToolbarToggleEtherpad() {
762
-        sendAnalytics(createToolbarEvent(
763
-            'toggle.etherpad',
764
-            {
765
-                enable: !this.props._editingDocument
766
-            }));
767
-
768
-        this._doToggleEtherpad();
769
-    }
770
-
771 729
     _onToolbarToggleFullScreen: () => void;
772 730
 
773 731
     /**
@@ -960,8 +918,6 @@ class Toolbox extends Component<Props, State> {
960 918
      */
961 919
     _renderOverflowMenuContent() {
962 920
         const {
963
-            _editingDocument,
964
-            _etherpadInitialized,
965 921
             _feedbackConfigured,
966 922
             _fullScreen,
967 923
             _screensharing,
@@ -1007,16 +963,9 @@ class Toolbox extends Component<Props, State> {
1007 963
                         ? t('toolbar.stopSharedVideo')
1008 964
                         : t('toolbar.sharedvideo') } />,
1009 965
             this._shouldShowButton('etherpad')
1010
-                && _etherpadInitialized
1011
-                && <OverflowMenuItem
1012
-                    accessibilityLabel =
1013
-                        { t('toolbar.accessibilityLabel.document') }
1014
-                    icon = { IconShareDoc }
966
+                && <SharedDocumentButton
1015 967
                     key = 'etherpad'
1016
-                    onClick = { this._onToolbarToggleEtherpad }
1017
-                    text = { _editingDocument
1018
-                        ? t('toolbar.documentClose')
1019
-                        : t('toolbar.documentOpen') } />,
968
+                    showLabel = { true } />,
1020 969
             <VideoBlurButton
1021 970
                 key = 'videobackgroundblur'
1022 971
                 showLabel = { true }
@@ -1365,8 +1314,6 @@ function _mapStateToProps(state) {
1365 1314
         _desktopSharingEnabled: desktopSharingEnabled,
1366 1315
         _desktopSharingDisabledTooltipKey: desktopSharingDisabledTooltipKey,
1367 1316
         _dialog: Boolean(state['features/base/dialog'].component),
1368
-        _editingDocument: Boolean(state['features/etherpad'].editing),
1369
-        _etherpadInitialized: Boolean(state['features/etherpad'].initialized),
1370 1317
         _feedbackConfigured: Boolean(callStatsID),
1371 1318
         _hideInviteButton:
1372 1319
             iAmRecorder || (!addPeopleEnabled && !dialOutEnabled),

正在加载...
取消
保存