Skip to content

Commit

Permalink
show toast on copy
Browse files Browse the repository at this point in the history
  • Loading branch information
duranb committed Dec 4, 2024
1 parent f473eae commit 1661ade
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { createEventDispatcher } from 'svelte';
import { isFswCommand, isFswCommandArgumentEnum } from '../../../utilities/codemirror/codemirror-utils';
import { getTarget } from '../../../utilities/generic';
import { showFailureToast, showSuccessToast } from '../../../utilities/toast';
import { tooltip } from '../../../utilities/tooltip';
import Input from '../../form/Input.svelte';
import CommandArgument from './CommandArg.svelte';
Expand Down Expand Up @@ -75,7 +76,12 @@
async function onCopy() {
if (selectedCommandDefinition) {
await navigator.clipboard.writeText(`${selectedCommandDefinition.stem}`);
try {
await navigator.clipboard.writeText(`${selectedCommandDefinition.stem}`);
showSuccessToast(`"${selectedCommandDefinition.stem}" copied to clipboard`);
} catch {
showFailureToast(`Error copying "${selectedCommandDefinition.stem}" to clipboard`);
}
}
}
Expand Down

0 comments on commit 1661ade

Please sign in to comment.