Add paste button on mobile + update copy icon (#610)

This commit is contained in:
Misode
2024-10-04 17:40:02 +02:00
committed by GitHub
parent fab3088799
commit f1b60b8b40
6 changed files with 19 additions and 7 deletions

View File

@@ -202,8 +202,18 @@ export function SourcePanel({ name, model, blockStates, doCopy, doDownload, doIm
setHighlighting(value)
}
const importFromClipboard = useCallback(async () => {
if (editor.current) {
const text = await navigator.clipboard.readText()
editor.current.setValue(text)
}
}, [])
return <>
<div class="controls source-controls">
{window.matchMedia('(pointer: coarse)').matches && <>
<Btn icon="paste" onClick={importFromClipboard} />
</>}
<BtnMenu icon="gear" tooltip={locale('output_settings')} data-cy="source-controls">
{getSourceIndents().map(key =>
<Btn label={locale(`indentation.${key}`)} active={indent === key}