Browse Source

add web-links xtermjs addon (#290)

pull/311/head
Dmytri Kleiner 4 years ago
committed by GitHub
parent
commit
b2d8b68970
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      package.json
  2. 3
      src/client/wetty/term.ts

1
package.json

@ -120,6 +120,7 @@
"winston": "^3.3.3", "winston": "^3.3.3",
"xterm": "^4.8.1", "xterm": "^4.8.1",
"xterm-addon-fit": "^0.4.0", "xterm-addon-fit": "^0.4.0",
"xterm-addon-web-links": "^0.4.0",
"yargs": "^15.4.1" "yargs": "^15.4.1"
}, },
"devDependencies": { "devDependencies": {

3
src/client/wetty/term.ts

@ -1,5 +1,6 @@
import type { Socket } from 'socket.io-client'; import type { Socket } from 'socket.io-client';
import _ from 'lodash'; import _ from 'lodash';
import { WebLinksAddon } from 'xterm-addon-web-links';
import { FitAddon } from 'xterm-addon-fit'; import { FitAddon } from 'xterm-addon-fit';
import { Terminal } from 'xterm'; import { Terminal } from 'xterm';
@ -10,6 +11,8 @@ import { terminal as termElement } from '../shared/elements.js';
export function terminal(socket: typeof Socket): Term | undefined { export function terminal(socket: typeof Socket): Term | undefined {
const term = new Terminal() as Term; const term = new Terminal() as Term;
if (_.isNull(termElement)) return; if (_.isNull(termElement)) return;
const webLinksAddon = new WebLinksAddon();
term.loadAddon(webLinksAddon);
const fitAddon = new FitAddon(); const fitAddon = new FitAddon();
term.loadAddon(fitAddon); term.loadAddon(fitAddon);
term.open(termElement); term.open(termElement);

Loading…
Cancel
Save