Skip to content

The OSINT investigator's workbench. One case, one folder, every tool. Local-first: your media and your investigations never leave your machine.

JavaScript
635 B
Raw Blame
import { toast } from './state.svelte.js';

/** Said when the browser keeps the clipboard shut: the page lost focus, or a
 *  permission was refused. */
export const REFUSED = 'The browser refused the clipboard';

/**
 * Put text on the clipboard and say so, or say the browser refused. Returns whether
 * it landed, so a caller with more to do (Publish) carries on either way.
 */
export async function copyText(text, { said = 'Copied', quiet = false } = {}) {
  try {
    await navigator.clipboard.writeText(text);
  } catch {
    toast(REFUSED, 'warn');
    return false;
  }
  if (!quiet) toast(said, 'ok', 1600);
  return true;
}