-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de615c7
commit 1aca411
Showing
3 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/editor-sample/src/App/TemplatePanel/DownloadJson/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { useMemo } from 'react'; | ||
|
||
import { FileDownloadOutlined } from '@mui/icons-material'; | ||
import { IconButton, Tooltip } from '@mui/material'; | ||
|
||
import { useDocument } from '../../../documents/editor/EditorContext'; | ||
|
||
export default function DownloadJson() { | ||
const doc = useDocument(); | ||
const href = useMemo(() => { | ||
return `data:text/plain,${encodeURIComponent(JSON.stringify(doc, null, ' '))}`; | ||
}, [doc]); | ||
return ( | ||
<Tooltip title="Download JSON file"> | ||
<IconButton href={href} download="emailTemplate.json"> | ||
<FileDownloadOutlined fontSize="small" /> | ||
</IconButton> | ||
</Tooltip> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters