Skip to content

Commit

Permalink
[v16] Add xterm/image-addon to web terminal
Browse files Browse the repository at this point in the history
Backport #48780
  • Loading branch information
avatus committed Nov 12, 2024
1 parent bc334f1 commit d93a7ae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion web/packages/teleport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
"@opentelemetry/sdk-trace-base": "1.25.1",
"@opentelemetry/sdk-trace-web": "1.25.1",
"@opentelemetry/semantic-conventions": "1.25.1",
"@xterm/xterm": "^5.5.0",
"@xterm/addon-canvas": "^0.7.0",
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-image": "^0.8.0",
"@xterm/addon-web-links": "^0.11.0",
"@xterm/addon-webgl": "^0.18.0",
"@xterm/xterm": "^5.5.0",
"create-react-class": "^15.6.3",
"events": "3.3.0"
},
Expand Down
4 changes: 4 additions & 0 deletions web/packages/teleport/src/lib/term/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import '@xterm/xterm/css/xterm.css';
import { ITheme, Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
import { ImageAddon } from '@xterm/addon-image';
import { WebglAddon } from '@xterm/addon-webgl';
import { WebLinksAddon } from '@xterm/addon-web-links';
import { CanvasAddon } from '@xterm/addon-canvas';
Expand Down Expand Up @@ -50,6 +51,7 @@ export default class TtyTerminal {
_convertEol: boolean;
_debouncedResize: DebouncedFunc<() => void>;
_fitAddon = new FitAddon();
_imageAddon = new ImageAddon();
_webLinksAddon = new WebLinksAddon();
_webglAddon: WebglAddon;
_canvasAddon = new CanvasAddon();
Expand Down Expand Up @@ -88,6 +90,7 @@ export default class TtyTerminal {

this.term.loadAddon(this._fitAddon);
this.term.loadAddon(this._webLinksAddon);
this.term.loadAddon(this._imageAddon);
// handle context loss and load webgl addon
try {
// try to create a new WebglAddon. If webgl is not supported, this
Expand Down Expand Up @@ -155,6 +158,7 @@ export default class TtyTerminal {
this._disconnect();
this._debouncedResize.cancel();
this._fitAddon.dispose();
this._imageAddon.dispose();
this._webglAddon?.dispose();
this._canvasAddon?.dispose();
this._el.innerHTML = null;
Expand Down

0 comments on commit d93a7ae

Please sign in to comment.