File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { Flex , IconButton , Input } from 'theme-ui'
2
2
import { useState } from 'react'
3
3
import { DownloadIcon , LogoIcon , GithubIcon } from './NavbarIcons'
4
+ import context from "../../uibox/editor" ;
5
+ import { useEditorContext , useHandlers } from '@/uibox'
4
6
5
7
function Navbar ( ) {
6
- // const { canvas } = useCanvasContext ()
8
+ const { canvas } = useEditorContext ( )
7
9
const [ templateName , setTemplateName ] = useState ( 'My First Design' )
8
10
const downloadImage = ( ) => {
9
11
//@ts -ignore
@@ -21,6 +23,20 @@ function Navbar() {
21
23
// a.download = 'drawing.png'
22
24
// a.click()
23
25
// }
26
+ const data = canvas ?. toDataURL ( {
27
+ multiplier : 3 ,
28
+ top : 0 ,
29
+ left : 0 ,
30
+ height : canvas . height ,
31
+ width : canvas . width ,
32
+ } ) ;
33
+ // const data= canvas?.toDataURL("image/png");
34
+ if ( data ) {
35
+ const a = document . createElement ( 'a' )
36
+ a . href = data
37
+ a . download = 'drawing.png'
38
+ a . click ( )
39
+ }
24
40
}
25
41
26
42
return (
You can’t perform that action at this time.
0 commit comments