AboutSupportDeveloper GuideVersion 33

The Clipboard API allows reading and writing to the clipboard in multiple formats.

Hierarchy

  • Base
    • Clipboard

Accessors

  • get me(): Identity
  • Provides access to the OpenFin representation of the current code context (usually a document such as a View or Window), as well as to the current Interop context.

    Useful for debugging in the devtools console, where this will intelligently type itself based on the context in which the devtools panel was opened.

    Returns Identity

Methods

  • Reads available formats for the clipboard type

    Parameters

    Returns Promise<string[]>

    Example

    fin.Clipboard.getAvailableFormats().then(formats => console.log(formats)).catch(err => console.log(err));
    
  • Read the content of the clipboard as Html

    Parameters

    Returns Promise<string>

    Example

    fin.Clipboard.readHtml().then(html => console.log(html)).catch(err => console.log(err));
    
  • Read the content of the clipboard as a base64 string or a dataURL based on the input parameter 'format', defaults to 'dataURL'

    Parameters

    Returns Promise<string>

    Example

    // see TS type: OpenFin.ImageFormatOptions

    const pngOrDataURLOrBmpOptions = {
    format: 'png', // can be: 'png' | 'dataURL' | 'bmp'
    };

    const jpgOptions = {
    format: 'jpg',
    quality: 80 // optional, if omitted defaults to 100
    };

    fin.Clipboard.readImage(pngOrDataURLOrBmpOptions)
    .then(image => console.log('Image read from clipboard as PNG, DataURL or BMP', image))
    .catch(err => console.log(err));

    fin.Clipboard.readImage(jpgOptions)
    .then(image => console.log('Image read from clipboard as JPG', image))
    .catch(err => console.log(err));

    // defaults to {format: 'dataURL'}
    fin.Clipboard.readImage()
    .then(image => console.log('Image read from clipboard as DataURL', image))
    .catch(err => console.log(err));
  • Read the content of the clipboard as Rtf

    Parameters

    Returns Promise<string>

    Example

    const writeObj = {
    data: 'some text goes here'
    };
    async function readRtf() {
    await fin.Clipboard.writeRtf(writeObj);
    return await fin.Clipboard.readRtf();
    }
    readRtf().then(rtf => console.log(rtf)).catch(err => console.log(err));
  • Read the content of the clipboard as plain text

    Parameters

    Returns Promise<string>

    Example

    fin.Clipboard.readText().then(text => console.log(text)).catch(err => console.log(err));
    
  • Writes data into the clipboard

    Parameters

    Returns Promise<void>

    Example

    fin.Clipboard.write({
    data: {
    text: 'a',
    html: 'b',
    rtf: 'c',
    // Can be either a base64 string, or a DataURL string. If using DataURL, the
    // supported formats are `data:image/png[;base64],` and `data:image/jpeg[;base64],`.
    // Using other image/<format> DataURLs will throw an Error.
    image: '...'
    }
    }).then(() => console.log('write data into clipboard')).catch(err => console.log(err));
  • Writes data into the clipboard as Html

    Parameters

    Returns Promise<void>

    Example

    fin.Clipboard.writeHtml({
    data: '<h1>Hello, World!</h1>'
    }).then(() => console.log('HTML On clipboard')).catch(err => console.log(err));
  • Writes data into the clipboard as an Image

    Parameters

    Returns Promise<void>

    Example

    fin.Clipboard.writeImage({
    // raw base64 string, or dataURL of either data:image/png or data:image/jpeg type
    image: '...'
    }).then(() => console.log('Image written to clipboard')).catch(err => console.log(err));
  • Writes data into the clipboard as Rtf

    Parameters

    Returns Promise<void>

    Example

    fin.Clipboard.writeRtf({
    data: 'some text goes here'
    }).then(() => console.log('RTF On clipboard')).catch(err => console.log(err));
  • Writes data into the clipboard as plain text

    Parameters

    Returns Promise<void>

    Example

    fin.Clipboard.writeText({
    data: 'hello, world'
    }).then(() => console.log('Text On clipboard')).catch(err => console.log(err));