diff --git a/src/theme/CodeEditor/Actions/DownloadCode.tsx b/src/theme/CodeEditor/Actions/DownloadCode.tsx index d0884da..0694f52 100644 --- a/src/theme/CodeEditor/Actions/DownloadCode.tsx +++ b/src/theme/CodeEditor/Actions/DownloadCode.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { useStore, useScript } from '@theme/CodeEditor/hooks'; -import Button, { Color } from '@theme/CodeEditor/Button'; +import Button from '@theme/CodeEditor/Button'; import { translate } from '@docusaurus/Translate'; const DownloadCode = (props: { title: string }) => { diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index 2b4e5e8..dc79d55 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -40,7 +40,7 @@ const config: Config = { label: 'Demo' }, { - to: 'snippet', + to: 'snippets', position: 'left', label: 'Shareable Snippet' }, diff --git a/website/package.json b/website/package.json index c537fcb..7722148 100644 --- a/website/package.json +++ b/website/package.json @@ -20,6 +20,7 @@ "@mdx-js/react": "3.0.1", "clsx": "^2.1.1", "docusaurus-live-brython": "link:../lib/", + "pako": "^2.1.0", "prism-react-renderer": "^2.3.1", "react": "^18.3.1", "react-dom": "^18.3.1" diff --git a/website/src/components/SnippetComponents/Description/index.tsx b/website/src/components/SnippetComponents/Description/index.tsx index 5305282..424e07d 100644 --- a/website/src/components/SnippetComponents/Description/index.tsx +++ b/website/src/components/SnippetComponents/Description/index.tsx @@ -1,41 +1,25 @@ import React from 'react'; import styles from './styles.module.css'; -import { useLocation, useHistory } from '@docusaurus/router'; import useAutosizeTextArea from './useAutoSizeTextArea'; -const Description = () => { - const location = useLocation(); - const history = useHistory(); - const [textAreaRef, setTextAreaRef] = React.useState(null); - const [description, setDescription] = React.useState(''); - useAutosizeTextArea(textAreaRef, '', 2); - - React.useEffect(() => { - if (location.search) { - const params = new URLSearchParams(location.search); - if (params.has('description')) { - setDescription(params.get('description') || ''); - } - } - }, []); +interface Props { + onChange: (title: string) => void; + description?: string; +} - React.useEffect(() => { - const params = new URLSearchParams(location.search); - if (description) { - params.set('description', description); - } else if (params.has('description')) { - params.delete('description'); - } - history.replace({ - search: params.toString() - }); - }, [description]); +const Description = (props: Props) => { + const [textAreaRef, setTextAreaRef] = React.useState(null); + const [description, setDescription] = React.useState(props.description || ''); + useAutosizeTextArea(textAreaRef, props.description || '', 2); return (