Skip to content

InMemoryClipboard

An in-memory clipboard installed by Lib.useInMemoryClipboard.

It replaces the clipboard of one window until InMemoryClipboard.restore runs. [Symbol.dispose] does the same. It is set only where the renderer has Symbol.dispose (Chromium 134 and later, so Electron 35 and later), and a bundler that lowers using puts its helper outside the serialized callback, so prefer try/finally inside an evalInObsidian callback.

Import:

import type { InMemoryClipboard } from 'obsidian-integration-testing';

Signature:

export interface InMemoryClipboard extends Disposable

Extends: Disposable

Properties

PropertyTypeDescription
htmlstringThe HTML the clipboard holds now: the seed, or the last HTML written. Writing plain text alone clears it, as a real clipboard does.
isElectronClipboardReplacedbooleanWhether Electron's clipboard module was replaced too. It is false where the window has no require (mobile), or where the module's methods could not be overwritten.
restore(this: void) => voidPuts the window's own clipboard back. Calling it again does nothing.
textstringThe text the clipboard holds now: the seed, or the last text written.
writtenTextsreadonly string[]Every text written while the clipboard was installed, oldest first. A write through navigator.clipboard.write counts when its item carries text/plain.

Links to this page: