@@ -8,13 +8,8 @@ import type {
8
8
ExcalidrawImperativeAPI ,
9
9
} from '@excalidraw/excalidraw/types/types'
10
10
import type { Delta } from 'jsondiffpatch'
11
- import type { FC } from 'react'
12
11
13
- import {
14
- Excalidraw as Board ,
15
- exportToBlob ,
16
- exportToSvg ,
17
- } from '@excalidraw/excalidraw'
12
+ import { Excalidraw as Board , exportToBlob } from '@excalidraw/excalidraw'
18
13
19
14
import { useIsMobile } from '~/atoms'
20
15
import { API_URL } from '~/constants/env'
@@ -203,47 +198,40 @@ const ExcalidrawImpl = forwardRef<InternelExcalidrawRefObject, ExcalidrawProps>(
203
198
204
199
{ viewModeEnabled && showExtendButton && (
205
200
< MotionButtonBase
206
- onClick = { async ( ) => {
201
+ onClick = { ( ) => {
207
202
if ( ! excalidrawAPIRef . current ) {
208
203
toast . error ( 'Excalidraw API not ready' )
209
204
return
210
205
}
211
206
212
207
const elements = excalidrawAPIRef . current . getSceneElements ( )
213
208
if ( isMobile ) {
214
- const blob = await exportToBlob ( {
209
+ const win = window . open ( )
210
+ const blob = exportToBlob ( {
215
211
elements,
216
212
files : null ,
217
213
} )
218
-
219
- window . open ( window . URL . createObjectURL ( blob ) )
220
- } else {
221
- const windowRect = {
222
- w : window . innerWidth ,
223
- h : window . innerHeight ,
224
- }
225
-
226
- const $svg = await exportToSvg ( {
227
- elements,
228
- files : null ,
229
- maxWidthOrHeight : Math . min (
230
- windowRect . h * 0.7 ,
231
- windowRect . w * 0.9 ,
232
- ) ,
233
- appState : { theme : isDarkMode ? 'dark' : 'light' } ,
234
- exportPadding : 12 ,
214
+ blob . then ( ( blob ) => {
215
+ win ?. location . replace ( URL . createObjectURL ( blob ) )
235
216
} )
236
-
217
+ } else {
237
218
modal . present ( {
238
219
title : 'Preview' ,
239
- content : ( ) => < SvgPreview svgElement = { $svg } /> ,
220
+ content : ( ) => (
221
+ < ExcalidrawImpl
222
+ data = { data }
223
+ className = "h-full"
224
+ showExtendButton = { false }
225
+ />
226
+ ) ,
240
227
clickOutsideToDismiss : true ,
228
+ max : true ,
241
229
} )
242
230
}
243
231
} }
244
232
className = { clsxm (
245
233
'absolute bottom-2 right-2 z-10 box-content flex h-5 w-5 rounded-md border p-2 center' ,
246
- 'border-zinc-200 text-zinc-600' ,
234
+ 'border-zinc-200 bg-base-100 text-zinc-600' ,
247
235
'dark:border-neutral-800 dark:text-zinc-500' ,
248
236
) }
249
237
>
@@ -255,15 +243,3 @@ const ExcalidrawImpl = forwardRef<InternelExcalidrawRefObject, ExcalidrawProps>(
255
243
} ,
256
244
)
257
245
ExcalidrawImpl . displayName = 'ExcalidrawImpl'
258
- const SvgPreview : FC < {
259
- svgElement : SVGSVGElement
260
- } > = ( { svgElement } ) => {
261
- return (
262
- < div
263
- className = "relative w-full overflow-auto [&>svg]:!h-full [&>svg]:!w-full [&>svg]:max-w-full"
264
- dangerouslySetInnerHTML = { {
265
- __html : svgElement . outerHTML ,
266
- } }
267
- />
268
- )
269
- }
0 commit comments