1
1
import "@netless/window-manager/dist/style.css" ;
2
2
import "./Whiteboard.less" ;
3
3
4
- import RedoUndo from "@netless/redo-undo" ;
5
- import ToolBox from "@netless/tool-box" ;
6
- import { WindowManager } from "@netless/window-manager" ;
4
+ import { Fastboard , Language } from "@netless/fastboard-react" ;
7
5
import classNames from "classnames" ;
8
- import { RaiseHand , ScenesController } from "flat-components" ;
6
+ import { RaiseHand } from "flat-components" ;
9
7
import { observer } from "mobx-react-lite" ;
10
8
import React , { useCallback , useEffect , useState } from "react" ;
11
9
import { message } from "antd" ;
@@ -32,7 +30,7 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
32
30
disableHandRaising,
33
31
} ) {
34
32
const { i18n, t } = useTranslation ( ) ;
35
- const { room, phase } = whiteboardStore ;
33
+ const { room, phase, fastboardAPP } = whiteboardStore ;
36
34
37
35
const [ whiteboardEl , setWhiteboardEl ] = useState < HTMLElement | null > ( null ) ;
38
36
const [ collectorEl , setCollectorEl ] = useState < HTMLElement | null > ( null ) ;
@@ -44,40 +42,10 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
44
42
} , [ isReconnecting , t ] ) ;
45
43
46
44
useEffect ( ( ) => {
47
- const mountWindowManager = async ( ) : Promise < void > => {
48
- if ( whiteboardEl && collectorEl && room ) {
49
- const windowManager = await WindowManager . mount ( {
50
- room,
51
- container : whiteboardEl ,
52
- collectorContainer : collectorEl ,
53
- cursor : true ,
54
- /* the containerSizeRatio config limit width and height ratio of windowManager
55
- for make sure windowManager sync in whiteboard. */
56
- containerSizeRatio : whiteboardStore . getWhiteboardRatio ( ) ,
57
- collectorStyles : {
58
- position : "absolute" ,
59
- bottom : "8px" ,
60
- } ,
61
- chessboard : false ,
62
- } ) ;
63
-
64
- whiteboardStore . updateWindowManager ( windowManager ) ;
65
- whiteboardStore . onMainViewSceneChange ( ) ;
66
- whiteboardStore . onMainViewSceneLengthChange ( ) ;
67
- whiteboardStore . onMainViewRedoUndoStepsChange ( ) ;
68
- whiteboardStore . onWindowManagerBoxStateChange (
69
- whiteboardStore . windowManager ?. boxState ,
70
- ) ;
71
- }
72
- } ;
73
-
74
- void mountWindowManager ( ) ;
75
-
76
- return ( ) => {
77
- whiteboardStore . destroyWindowManager ( ) ;
78
- } ;
79
- // eslint-disable-next-line react-hooks/exhaustive-deps
80
- } , [ whiteboardEl , collectorEl , room ] ) ;
45
+ if ( fastboardAPP && collectorEl ) {
46
+ fastboardAPP . bindCollector ( collectorEl ) ;
47
+ }
48
+ } , [ collectorEl , fastboardAPP ] ) ;
81
49
82
50
const whiteboardOnResize = useCallback ( ( ) => {
83
51
if ( whiteboardEl ) {
@@ -200,54 +168,6 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
200
168
onDragOver = { onDragOver }
201
169
onDrop = { onDrop }
202
170
>
203
- < div className = "whiteboard-writable-area" >
204
- < div className = "tool-box-out" >
205
- < ToolBox
206
- hotkeys = { {
207
- arrow : "A" ,
208
- clear : "" ,
209
- clicker : "" ,
210
- ellipse : "C" ,
211
- eraser : "E" ,
212
- hand : "H" ,
213
- laserPointer : "Z" ,
214
- pencil : "P" ,
215
- rectangle : "R" ,
216
- selector : "S" ,
217
- shape : "" ,
218
- straight : "L" ,
219
- text : "T" ,
220
- } }
221
- i18nLanguage = { i18n . language }
222
- room = { room }
223
- />
224
- </ div >
225
- < div
226
- className = { classNames ( "redo-undo-box" , {
227
- "is-disabled" : whiteboardStore . isWindowMaximization ,
228
- } ) }
229
- >
230
- < RedoUndo
231
- redoSteps = { whiteboardStore . redoSteps }
232
- room = { room }
233
- undoSteps = { whiteboardStore . undoSteps }
234
- />
235
- </ div >
236
- < div
237
- className = { classNames ( "page-controller-box" , {
238
- "is-disabled" : whiteboardStore . isWindowMaximization ,
239
- } ) }
240
- >
241
- < ScenesController
242
- addScene = { whiteboardStore . addMainViewScene }
243
- currentSceneIndex = { whiteboardStore . currentSceneIndex }
244
- disabled = { false }
245
- nextScene = { whiteboardStore . nextMainViewScene }
246
- preScene = { whiteboardStore . preMainViewScene }
247
- scenesCount = { whiteboardStore . scenesCount }
248
- />
249
- </ div >
250
- </ div >
251
171
{ ! whiteboardStore . isCreator && ! whiteboardStore . isWritable && (
252
172
< div className = "raise-hand-container" >
253
173
< RaiseHand
@@ -257,14 +177,13 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
257
177
/>
258
178
</ div >
259
179
) }
260
- < div
261
- ref = { bindCollector }
262
- className = { classNames ( "collector-container" , {
263
- "collector-container-not-writable" : ! whiteboardStore . isWritable ,
264
- } ) }
180
+ < div ref = { bindCollector } />
181
+ < Fastboard
182
+ ref = { bindWhiteboard }
183
+ app = { fastboardAPP }
184
+ language = { i18n . language as Language }
185
+ theme = "light"
265
186
/>
266
-
267
- < div ref = { bindWhiteboard } className = "whiteboard-box" />
268
187
</ div >
269
188
)
270
189
) ;
0 commit comments