add new button
This commit is contained in:
@@ -33,7 +33,7 @@ export default function Editor({ content, setContent, contentType }) {
|
|||||||
|
|
||||||
return <>
|
return <>
|
||||||
<ThemeProvider theme={themes[theme]}>
|
<ThemeProvider theme={themes[theme]}>
|
||||||
<EditorControls code={content} language={language} setLanguage={setLanguage} theme={theme} setTheme={setTheme} />
|
<EditorControls code={content} setCode={setContent} language={language} setLanguage={setLanguage} theme={theme} setTheme={setTheme} />
|
||||||
<EditorTextArea code={content} setCode={setContent} language={language} />
|
<EditorTextArea code={content} setCode={setContent} language={language} />
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import copy from 'copy-to-clipboard';
|
|||||||
import { languageIds } from '../highlighting';
|
import { languageIds } from '../highlighting';
|
||||||
import themes from '../style/themes';
|
import themes from '../style/themes';
|
||||||
|
|
||||||
export default function EditorControls({ code, language, setLanguage, theme, setTheme }) {
|
export default function EditorControls({ code, setCode, language, setLanguage, theme, setTheme }) {
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [recentlySaved, setRecentlySaved] = useState(false);
|
const [recentlySaved, setRecentlySaved] = useState(false);
|
||||||
|
|
||||||
@@ -24,17 +24,26 @@ export default function EditorControls({ code, language, setLanguage, theme, set
|
|||||||
setSaving(false);
|
setSaving(false);
|
||||||
setRecentlySaved(true);
|
setRecentlySaved(true);
|
||||||
history.replace({
|
history.replace({
|
||||||
pathname: pasteId,
|
pathname: pasteId
|
||||||
hash: ''
|
|
||||||
});
|
});
|
||||||
copy(window.location.href);
|
copy(window.location.href);
|
||||||
document.title = 'paste | ' + pasteId;
|
document.title = 'paste | ' + pasteId;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
setCode('');
|
||||||
|
setLanguage('plain');
|
||||||
|
history.replace({
|
||||||
|
pathname: '/'
|
||||||
|
});
|
||||||
|
document.title = 'paste';
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Header>
|
<Header>
|
||||||
<Section>
|
<Section>
|
||||||
|
<Button onClick={reset}>[new]</Button>
|
||||||
<Button onClick={save}>
|
<Button onClick={save}>
|
||||||
{recentlySaved
|
{recentlySaved
|
||||||
? '[link copied!]'
|
? '[link copied!]'
|
||||||
@@ -44,6 +53,7 @@ export default function EditorControls({ code, language, setLanguage, theme, set
|
|||||||
<MenuButton label="language" value={language} setValue={setLanguage} ids={languageIds} />
|
<MenuButton label="language" value={language} setValue={setLanguage} ids={languageIds} />
|
||||||
</Section>
|
</Section>
|
||||||
<Section>
|
<Section>
|
||||||
|
|
||||||
<MenuButton label="theme" value={theme} setValue={setTheme} ids={Object.keys(themes)} />
|
<MenuButton label="theme" value={theme} setValue={setTheme} ids={Object.keys(themes)} />
|
||||||
<Button as="a" href="https://github.com/lucko/paste" target="_blank" rel="noreferrer">[about]</Button>
|
<Button as="a" href="https://github.com/lucko/paste" target="_blank" rel="noreferrer">[about]</Button>
|
||||||
</Section>
|
</Section>
|
||||||
|
|||||||
Reference in New Issue
Block a user