diff --git a/packages/editor-sample/src/App/TemplatePanel/DownloadJson/index.tsx b/packages/editor-sample/src/App/TemplatePanel/DownloadJson/index.tsx new file mode 100644 index 0000000..f891f79 --- /dev/null +++ b/packages/editor-sample/src/App/TemplatePanel/DownloadJson/index.tsx @@ -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 ( + + + + + + ); +} diff --git a/packages/editor-sample/src/App/TemplatePanel/ImportJson/index.tsx b/packages/editor-sample/src/App/TemplatePanel/ImportJson/index.tsx index 25f21c8..afc5f1e 100644 --- a/packages/editor-sample/src/App/TemplatePanel/ImportJson/index.tsx +++ b/packages/editor-sample/src/App/TemplatePanel/ImportJson/index.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import { UploadFileOutlined } from '@mui/icons-material'; +import { FileUploadOutlined } from '@mui/icons-material'; import { IconButton, Tooltip } from '@mui/material'; import ImportJsonDialog from './ImportJsonDialog'; @@ -17,7 +17,7 @@ export default function ImportJson() { <> setOpen(true)}> - + {dialog} diff --git a/packages/editor-sample/src/App/TemplatePanel/index.tsx b/packages/editor-sample/src/App/TemplatePanel/index.tsx index c0cfb1b..0340cad 100644 --- a/packages/editor-sample/src/App/TemplatePanel/index.tsx +++ b/packages/editor-sample/src/App/TemplatePanel/index.tsx @@ -14,6 +14,7 @@ import { import ToggleInspectorPanelButton from '../InspectorDrawer/ToggleInspectorPanelButton'; import ToggleSamplesPanelButton from '../SamplesDrawer/ToggleSamplesPanelButton'; +import DownloadJson from './DownloadJson'; import HtmlPanel from './HtmlPanel'; import ImportJson from './ImportJson'; import JsonPanel from './JsonPanel'; @@ -94,6 +95,7 @@ export default function TemplatePanel() { +