AboutSupportDeveloper GuideVersion 47.154.100.2
OpenFin JavaScript API
    Preparing search index...

    Class Clipboard

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

    Hierarchy

    • Base
      • Clipboard
    Index
    • get me(): Identity

      Returns Identity

      me should only be accessed from the fin global (FinApi.me); access through entity classes is not guaranteed to behave sensibly in all calling contexts.

    • Reads available formats for the clipboard type

      Parameters

      Returns Promise<string[]>

      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>

      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>

      // 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>

      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>

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

      Parameters

      Returns Promise<void>

      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>

      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>

      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>

      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>

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