Skip to content

Commit b1eaaee

Browse files
committed
html: add xterm clipboard addon
1 parent d0134c8 commit b1eaaee

File tree

4 files changed

+14134
-13944
lines changed

4 files changed

+14134
-13944
lines changed

html/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
},
5454
"dependencies": {
5555
"@xterm/addon-canvas": "^0.7.0",
56+
"@xterm/addon-clipboard": "^0.1.0",
5657
"@xterm/addon-fit": "^0.10.0",
5758
"@xterm/addon-image": "^0.8.0",
5859
"@xterm/addon-unicode11": "^0.8.0",

html/src/components/terminal/xterm/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { bind } from 'decko';
22
import type { IDisposable, ITerminalOptions } from '@xterm/xterm';
33
import { Terminal } from '@xterm/xterm';
44
import { CanvasAddon } from '@xterm/addon-canvas';
5+
import { ClipboardAddon } from '@xterm/addon-clipboard';
56
import { WebglAddon } from '@xterm/addon-webgl';
67
import { FitAddon } from '@xterm/addon-fit';
78
import { WebLinksAddon } from '@xterm/addon-web-links';
@@ -84,6 +85,8 @@ export class Xterm {
8485
private terminal: Terminal;
8586
private fitAddon = new FitAddon();
8687
private overlayAddon = new OverlayAddon();
88+
private clipboardAddon = new ClipboardAddon();
89+
private webLinksAddon = new WebLinksAddon();
8790
private webglAddon?: WebglAddon;
8891
private canvasAddon?: CanvasAddon;
8992
private zmodemAddon?: ZmodemAddon;
@@ -149,15 +152,16 @@ export class Xterm {
149152
@bind
150153
public open(parent: HTMLElement) {
151154
this.terminal = new Terminal(this.options.termOptions);
152-
const { terminal, fitAddon, overlayAddon } = this;
155+
const { terminal, fitAddon, overlayAddon, clipboardAddon, webLinksAddon } = this;
153156
window.term = terminal as TtydTerminal;
154157
window.term.fit = () => {
155158
this.fitAddon.fit();
156159
};
157160

158161
terminal.loadAddon(fitAddon);
159162
terminal.loadAddon(overlayAddon);
160-
terminal.loadAddon(new WebLinksAddon());
163+
terminal.loadAddon(clipboardAddon);
164+
terminal.loadAddon(webLinksAddon);
161165

162166
terminal.open(parent);
163167
fitAddon.fit();

html/yarn.lock

+19
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,17 @@ __metadata:
12671267
languageName: node
12681268
linkType: hard
12691269

1270+
"@xterm/addon-clipboard@npm:^0.1.0":
1271+
version: 0.1.0
1272+
resolution: "@xterm/addon-clipboard@npm:0.1.0"
1273+
dependencies:
1274+
js-base64: ^3.7.5
1275+
peerDependencies:
1276+
"@xterm/xterm": ^5.4.0
1277+
checksum: fe33d28223ae7f9965653c6c946a68e06f1d884fba1d11e8bcb52dcc608dbb2240caf48573d6297daefa56696e88f963148a1035ccf034cb6fb4f88f506a2ec7
1278+
languageName: node
1279+
linkType: hard
1280+
12701281
"@xterm/addon-fit@npm:^0.10.0":
12711282
version: 0.10.0
12721283
resolution: "@xterm/addon-fit@npm:0.10.0"
@@ -6431,6 +6442,13 @@ __metadata:
64316442
languageName: node
64326443
linkType: hard
64336444

6445+
"js-base64@npm:^3.7.5":
6446+
version: 3.7.7
6447+
resolution: "js-base64@npm:3.7.7"
6448+
checksum: d1b02971db9dc0fd35baecfaf6ba499731fb44fe3373e7e1d6681fbd3ba665f29e8d9d17910254ef8104e2cb8b44117fe4202d3dc54c7cafe9ba300fe5433358
6449+
languageName: node
6450+
linkType: hard
6451+
64346452
"js-tokens@npm:^4.0.0":
64356453
version: 4.0.0
64366454
resolution: "js-tokens@npm:4.0.0"
@@ -10475,6 +10493,7 @@ __metadata:
1047510493
dependencies:
1047610494
"@typescript-eslint/eslint-plugin": ^7.1.1
1047710495
"@xterm/addon-canvas": ^0.7.0
10496+
"@xterm/addon-clipboard": ^0.1.0
1047810497
"@xterm/addon-fit": ^0.10.0
1047910498
"@xterm/addon-image": ^0.8.0
1048010499
"@xterm/addon-unicode11": ^0.8.0

0 commit comments

Comments
 (0)