@@ -6,6 +6,7 @@ import React, { useCallback, useContext, useEffect, useState } from "react";
6
6
import { Fastboard , Language } from "@netless/fastboard-react" ;
7
7
import {
8
8
DarkModeContext ,
9
+ PresetsModal ,
9
10
RaiseHand ,
10
11
SaveAnnotationModal ,
11
12
SaveAnnotationModalProps ,
@@ -20,6 +21,7 @@ import { isSupportedFileExt } from "../utils/drag-and-drop";
20
21
import { isSupportedImageType , onDropImage } from "../utils/drag-and-drop/image" ;
21
22
import { ClassRoomStore } from "../stores/class-room-store" ;
22
23
import { refreshApps } from "../utils/toolbar-apps" ;
24
+ import { PRESETS } from "../constants/presets" ;
23
25
24
26
export interface WhiteboardProps {
25
27
whiteboardStore : WhiteboardStore ;
@@ -46,6 +48,7 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
46
48
const [ saveAnnotationImages , setSaveAnnotationImages ] = useState <
47
49
SaveAnnotationModalProps [ "images" ]
48
50
> ( [ ] ) ;
51
+ const [ presetsVisible , showPresets ] = useState ( false ) ;
49
52
50
53
const isReconnecting = phase === RoomPhase . Reconnecting ;
51
54
@@ -135,6 +138,9 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
135
138
onSaveAnnotation : ( ) => {
136
139
showSaveAnnotation ( true ) ;
137
140
} ,
141
+ onPresets : ( ) => {
142
+ showPresets ( true ) ;
143
+ } ,
138
144
} ) ;
139
145
} , [ t ] ) ;
140
146
@@ -156,6 +162,14 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
156
162
}
157
163
} , [ ] ) ;
158
164
165
+ const insertPresetImage = useCallback (
166
+ ( fileURL : string ) => {
167
+ whiteboardStore . insertImage ( { fileURL } ) ;
168
+ showPresets ( false ) ;
169
+ } ,
170
+ [ whiteboardStore ] ,
171
+ ) ;
172
+
159
173
const onDragOver = useCallback (
160
174
( event : React . DragEvent < HTMLDivElement > ) => {
161
175
event . preventDefault ( ) ;
@@ -219,6 +233,12 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
219
233
visible = { saveAnnotationVisible }
220
234
onClose = { ( ) => showSaveAnnotation ( false ) }
221
235
/>
236
+ < PresetsModal
237
+ images = { PRESETS }
238
+ visible = { presetsVisible }
239
+ onClick = { insertPresetImage }
240
+ onClose = { ( ) => showPresets ( false ) }
241
+ />
222
242
</ >
223
243
) ;
224
244
} ) ;
0 commit comments