The clipboard as the controller sees it: drawings in, drawings out, no exceptions escaping. Every failure mode (no clipboard API, refused permission, foreign text, corrupt payload) reduces to false or null.

Constructors

Methods

  • Why the OS clipboard was not used by the last call, or null when it was. Set on a successful copy too, when the payload reached memory but not the system clipboard: that copy works in this tab and will not appear in another, which is exactly what a host wants to be able to tell the user.

    Returns null | string

  • Read drawings back, or null when there is nothing of ours to paste. The system clipboard wins when it holds our payload, so a copy made in another tab beats a stale in-tab one; memory is consulted when the read fails or returns something that is not ours. That last case can paste an older copy after the user has copied unrelated text elsewhere, which is the deliberate trade: losing the copy whenever a browser refuses the read half of the permission would be the worse surprise.

    Returns Promise<null | Omit<Drawing, "id">[]>

  • Turn the in-memory backstop off or on. With it off, a refused system write is a failed copy, which is what a host wants when a cut that cannot reach the OS clipboard must not delete the drawing.

    Parameters

    • enabled: boolean

    Returns void

  • Write drawings out. Resolves true when the payload is retrievable by a later read() (through the system clipboard, or through memory when the fallback is on), false when it is not, so a caller doing a cut knows whether it is safe to delete the original.

    Parameters

    Returns Promise<boolean>