mirror of
https://github.com/tsl0922/ttyd.git
synced 2026-01-03 09:24:22 +01:00
html: add xterm clipboard addon
This commit is contained in:
@@ -2,6 +2,7 @@ import { bind } from 'decko';
|
||||
import type { IDisposable, ITerminalOptions } from '@xterm/xterm';
|
||||
import { Terminal } from '@xterm/xterm';
|
||||
import { CanvasAddon } from '@xterm/addon-canvas';
|
||||
import { ClipboardAddon } from '@xterm/addon-clipboard';
|
||||
import { WebglAddon } from '@xterm/addon-webgl';
|
||||
import { FitAddon } from '@xterm/addon-fit';
|
||||
import { WebLinksAddon } from '@xterm/addon-web-links';
|
||||
@@ -84,6 +85,8 @@ export class Xterm {
|
||||
private terminal: Terminal;
|
||||
private fitAddon = new FitAddon();
|
||||
private overlayAddon = new OverlayAddon();
|
||||
private clipboardAddon = new ClipboardAddon();
|
||||
private webLinksAddon = new WebLinksAddon();
|
||||
private webglAddon?: WebglAddon;
|
||||
private canvasAddon?: CanvasAddon;
|
||||
private zmodemAddon?: ZmodemAddon;
|
||||
@@ -149,7 +152,7 @@ export class Xterm {
|
||||
@bind
|
||||
public open(parent: HTMLElement) {
|
||||
this.terminal = new Terminal(this.options.termOptions);
|
||||
const { terminal, fitAddon, overlayAddon } = this;
|
||||
const { terminal, fitAddon, overlayAddon, clipboardAddon, webLinksAddon } = this;
|
||||
window.term = terminal as TtydTerminal;
|
||||
window.term.fit = () => {
|
||||
this.fitAddon.fit();
|
||||
@@ -157,7 +160,8 @@ export class Xterm {
|
||||
|
||||
terminal.loadAddon(fitAddon);
|
||||
terminal.loadAddon(overlayAddon);
|
||||
terminal.loadAddon(new WebLinksAddon());
|
||||
terminal.loadAddon(clipboardAddon);
|
||||
terminal.loadAddon(webLinksAddon);
|
||||
|
||||
terminal.open(parent);
|
||||
fitAddon.fit();
|
||||
|
||||
Reference in New Issue
Block a user