copy-text: load the toast store only when copying, so the Markdown renderer still renders without a browser
This commit is contained in:
1 parent
5faf357b49
commit
13a4153be4
1 file changed
+2
-2
@@ -1,5 +1,3 @@
|
||||
import { pushToast } from './store';
|
||||
|
||||
/**
|
||||
* Put text on the clipboard. The browser clipboard call can be refused inside the app window (WebView2 asks no one and says no),
|
||||
* so a hidden text field and the older copy command are the second try. Resolves true when one of them worked.
|
||||
@@ -30,6 +28,8 @@ export async function copyText(value: string): Promise<boolean> {
|
||||
|
||||
/** Copy and say so: "Copied", or "Couldn't copy" with what to do instead. */
|
||||
export async function copyAndTell(value: string, label: string): Promise<void> {
|
||||
// loaded here, not at the top: the store needs a browser, and the Markdown renderer (which copies code) is also rendered without one
|
||||
const { pushToast } = await import('./store');
|
||||
if (await copyText(value))
|
||||
pushToast('success', 'Copied', label);
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user