Files
xterm.js/addons/addon-clipboard
Daniel ImmsandCursor 17ad33dc3d Remove TypeScript path mappings in favor of relative imports
Fixes https://github.com/xtermjs/xterm.js/issues/5896

TypeScript path mappings for common/*, browser/*, and headless/*
were not rewritten in emitted JavaScript, which forced webpack resolve
aliases and NODE_PATH workarounds so runtime could resolve modules.
That added build complexity and broke tooling such as ESLint import/no-cycle.

Changes:
- Convert ~750 imports across src/, addons/, and test/ to relative paths
- Remove common/browser/headless paths and src catch-all mappings from tsconfigs
  (keep @xterm/addon-* demo and addon typings paths)
- Remove webpack resolve.alias for common, browser, headless, and vs
- Drop NODE_PATH from unit tests, benchmarks, and VS Code launch config
- Fix addon-image IIPImageStorage to import ./Types after removing catch-all *

Verified: npm run build, esbuild, package, package-headless
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-31 09:16:10 -07:00
..
2024-04-08 02:47:26 +03:00
2024-07-07 09:15:25 -07:00
2023-11-03 11:45:21 -07:00
2026-05-10 16:45:46 +02:00
2024-04-08 04:51:55 +03:00

@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.