Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xterm/addon-clipboard

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xterm/addon-clipboard

An addon for [xterm.js](https://github.com/xtermjs/xterm.js) that enables accessing the system clipboard. This addon requires xterm.js v4+.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-16.44%
Maintainers
1
Weekly downloads
 
Created
Source

@xterm/addon-clipboard

An addon for xterm.js that enables accessing the system clipboard. This addon requires xterm.js v4+.

Install

npm install --save @xterm/addon-clipboard

Usage

import { Terminal } from 'xterm';
import { ClipboardAddon } from '@xterm/addon-clipboard';

const terminal = new Terminal();
const clipboardAddon = new ClipboardAddon();
terminal.loadAddon(clipboardAddon);

To use a custom clipboard provider

import { Terminal } from '@xterm/xterm';
import { ClipboardAddon, IClipboardProvider, ClipboardSelectionType } from '@xterm/addon-clipboard';

function b64Encode(data: string): string {
  // Base64 encode impl
}

function b64Decode(data: string): string {
  // Base64 decode impl
}

class MyCustomClipboardProvider implements IClipboardProvider {
  private _data: string
  public readText(selection: ClipboardSelectionType): Promise<string> {
    return Promise.resolve(b64Encode(this._data));
  }
  public writeText(selection: ClipboardSelectionType, data: string): Promise<void> {
    this._data = b64Decode(data);
    return Promise.resolve();
  }
}

const terminal = new Terminal();
const clipboardAddon = new ClipboardAddon(new MyCustomClipboardProvider());
terminal.loadAddon(clipboardAddon);

See the full API for more advanced usage.

Keywords

FAQs

Package last updated on 22 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc