// Share an outline: a read-only link anyone can open (no account), or the plain text. import { useState } from 'react'; import Sheet from './reader/Sheet.jsx'; import { useToast } from './Toasts.jsx'; import { useOutlineShareLink } from '../hooks/useOutlineShareLink.js'; import { shareOutline } from '../utils/outlineExport.js'; const btn = 'rounded-xl border border-[var(--r-line)] px-3.5 py-2 text-sm hover:bg-black/5 disabled:opacity-50'; export default function ShareOutlineSheet({ open, onClose, projectId, outline }) { const { toast } = useToast(); const link = useOutlineShareLink(projectId, open); const [copied, setCopied] = useState(false); const copyLink = async () => { try { await navigator.clipboard.writeText(link.url); setCopied(true); window.setTimeout(() => setCopied(false), 2000); } catch { toast('Couldn’t copy. Select the link and copy it.', { tone: 'error' }); } }; // The phone/computer share sheet, with the link (falls back to copying it) const shareLink = async () => { if (navigator.share) { try { await navigator.share({ title: `${outline.title} — Outline`, url: link.url }); return; } catch (err) { if (err?.name === 'AbortError') return; } } copyLink(); }; const shareText = async () => { const result = await shareOutline(outline); if (result === 'copied') toast('Outline copied. Paste it into a message or email.'); else if (result === 'failed') toast('Couldn’t share or copy the outline.', { tone: 'error' }); }; return (

Read-only link

Anyone with the link can read this study’s outlines (the whole-study one and each chunk’s), and print them. They can’t edit anything, and they can’t see your notes or scripts. No account needed.

{link.state === 'loading' &&

Checking…

} {link.state === 'unavailable' && (

Links need your account and a connection to the server. You can still share the text below.

)} {link.state === 'ready' && (link.token ? (
e.target.select()} className="min-w-0 flex-1 truncate rounded-lg border border-[var(--r-line)] bg-[var(--r-bg)] px-3 py-2 text-xs text-[var(--r-sub)]" />

People see the version that last synced to your account, and it updates as you edit. Turning the link off stops it working right away.

) : ( ))} {link.error &&

{link.error}

}

Or send the text

The outline you’re looking at, as plain text, to paste into a message or email.

); }