UNPKG

react-terminal-viewer

Version:

<h1 align="center"> react-terminal-viewer </h1>

88 lines (87 loc) 2.84 kB
import React from 'react'; import { Terminal, ITerminalOptions } from 'xterm'; import 'xterm/css/xterm.css'; import { FitAddon } from 'xterm-addon-fit'; import { WebLinksAddon } from 'xterm-addon-web-links'; import { CanvasAddon } from 'xterm-addon-canvas'; import { SearchAddon } from '../Addon/SearchAddon'; import { HighlightAddon } from '../Addon/HighlightAddon'; import type { AddonType } from '../Addon/useAddon'; import type { IRemoteOptions } from '../Hooks/useRemote'; import type { ICacheOptions } from '../Hooks/useCache'; import type { IHighlightOptions } from '../Addon/HighlightAddon'; import { TerminalRef } from '../types'; import './index.less'; export interface TerminalExposedRef { terminal?: Terminal | undefined; addons?: { search?: SearchAddon | undefined; fit?: FitAddon | undefined; webLinks?: WebLinksAddon | undefined; highlight?: HighlightAddon | undefined; canvas?: CanvasAddon | undefined; }; refresh?: (() => void) | undefined; } export interface TerminalViewerBodyProps { /** * @description.zh-CN 是否自动拉伸填充容器宽高 * @default true */ fit?: boolean; /** *@description.zh-CN 是否开启自动滚动到底部 *@default true */ autoScroll?: boolean; /** * @description.zh-CN 外层样式类名 */ className?: string; /** * @description.zh-CN 自定义空文本显示 */ empty?: React.ReactNode; /** * @description.zh-CN 是否支持渲染超链接 * @default true */ webLinksSupport?: boolean; /** * @description.zh-CN 是否使用 canvas 渲染 * @default false */ canvasSupport?: boolean; /** * @description.zh-CN 远程搜索选配置 * */ remoteOptions?: IRemoteOptions; /** * @description.zh-CN 缓存配置,仅在配置远程加载后有效,如 `expires: 60 * 1000` 表示自动清理已过期一分钟的缓存 */ cacheOptions?: ICacheOptions; /** * @description.zh-CN 高亮选项 */ highlightOptions?: IHighlightOptions[]; /** * @description.zh-CN xtem.js 配置, https://github.com/xtermjs/xterm.js */ terminalOptions?: ITerminalOptions; /** * @description.zh-CN 用于渲染日志的默认数据,如 "echo 1\r\necho2" * @default ''' */ defaultData?: string; /** * @description.zh-CN 插件加载成功后的回调 */ onAddonReady?: (instance: Terminal, addon: AddonType) => void; /** * @description.zh-CN 加载状态变更后的回调 */ onLoading?: (loading: boolean) => void; } declare const TerminalViewerBody: React.ForwardRefExoticComponent<TerminalViewerBodyProps & React.RefAttributes<TerminalRef | undefined>>; export default TerminalViewerBody;