/** * Putting two flavours of the same thing on the clipboard at once. * * A clipboard holds one *content* in several representations, and the pasting * application picks the richest it understands. That is the whole mechanism * behind a paste into Word keeping its headings while the same paste into a * terminal arrives as text. `copyToClipboard` writes one flavour — plain text — * so a transcript pasted into Word arrived as a wall of markdown with the * asterisks still in it. * * So: markdown on `text/plain`, HTML on the platform's rich flavour, both from * one call. Nothing about the copy changes for a plain-text target. * * ## What each platform can carry * * - **macOS** takes both onto the general pasteboard in one clearing, so a * paste into Word is rich and a paste into a terminal is the markdown. * - **Windows** takes both through a `DataObject`, with the HTML wrapped in the * CF_HTML envelope the format requires (and PowerShell run `-STA`, because * the clipboard APIs are apartment-threaded). * - **Linux** cannot: X11 and Wayland clipboards are owned by one process * advertising one set of targets, and `xclip`/`wl-copy` advertise the single * type they were given. Offering HTML there would mean *replacing* the plain * text with HTML source for every other paste target, which is a worse * clipboard than the one we started with. So Linux gets the markdown, and the * caller is told which flavour landed rather than left to guess. * * Every path falls back to `copyToClipboard`: a rich copy that fails is still a * copy, and the user finds out from the status line what they got. */ /** What actually reached the clipboard. */ export type CopyFlavour = "rich" | "text"; export interface RichPayload { /** The `text/plain` flavour — markdown, for anything that takes text. */ text: string; /** The rich flavour — an HTML *fragment*, no `` or ``. */ html: string; } /** * The CF_HTML envelope Windows requires. * * The header carries byte offsets into the string that contains it, which makes * it self-referential: the offsets are only correct once they are the width * they will be when written. Fixed-width zero-padded fields are how the format * solves that, and why these are padded to ten digits rather than printed * plainly. * * Exported for its own test: the arithmetic is invisible until a paste lands in * Word with its first tag missing, which is a long way from here. */ export declare function wrapCfHtml(fragment: string): string; /** * Copy `payload`, richly where the platform allows it. * * @returns which flavour reached the clipboard: `"rich"` when the receiving * application can paste structure, `"text"` when it will get the markdown. * The caller reports this, because "copied" meaning two different things * depending on the machine is how a feature gets reported as broken. */ export declare function copyRichToClipboard(payload: RichPayload): Promise; //# sourceMappingURL=rich-clipboard.d.ts.map