mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-30 07:08:47 +00:00
fix: add clipboard addon to docker container terminal
The docker container terminal did not load xterm's ClipboardAddon, so pasting into it (e.g. a MariaDB shell) broke the cursor and left the pasted text uneditable. The web server terminal already loads this addon; this brings the container terminal in line with it. Also dispose the terminal on cleanup so its addons don't leak on remount. Fixes #5065
This commit is contained in:
@@ -3,6 +3,7 @@ import React, { useEffect, useRef } from "react";
|
|||||||
import { FitAddon } from "xterm-addon-fit";
|
import { FitAddon } from "xterm-addon-fit";
|
||||||
import "@xterm/xterm/css/xterm.css";
|
import "@xterm/xterm/css/xterm.css";
|
||||||
import { AttachAddon } from "@xterm/addon-attach";
|
import { AttachAddon } from "@xterm/addon-attach";
|
||||||
|
import { ClipboardAddon } from "@xterm/addon-clipboard";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { fixMacOsAltKeys } from "@/lib/terminal-keyboard";
|
import { fixMacOsAltKeys } from "@/lib/terminal-keyboard";
|
||||||
@@ -46,6 +47,8 @@ export const DockerTerminal: React.FC<Props> = ({
|
|||||||
const ws = new WebSocket(wsUrl);
|
const ws = new WebSocket(wsUrl);
|
||||||
|
|
||||||
const addonAttach = new AttachAddon(ws);
|
const addonAttach = new AttachAddon(ws);
|
||||||
|
const clipboardAddon = new ClipboardAddon();
|
||||||
|
term.loadAddon(clipboardAddon);
|
||||||
fixMacOsAltKeys(term);
|
fixMacOsAltKeys(term);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
term.open(termRef.current);
|
term.open(termRef.current);
|
||||||
@@ -55,6 +58,7 @@ export const DockerTerminal: React.FC<Props> = ({
|
|||||||
addonFit.fit();
|
addonFit.fit();
|
||||||
return () => {
|
return () => {
|
||||||
ws.readyState === WebSocket.OPEN && ws.close();
|
ws.readyState === WebSocket.OPEN && ws.close();
|
||||||
|
term.dispose();
|
||||||
};
|
};
|
||||||
}, [containerId, activeWay, id]);
|
}, [containerId, activeWay, id]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user