Package Exports
- web-term-ui
- web-term-ui/web-term-ui.es.min.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (web-term-ui) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
WebTerm UI
A Web Terminal UI Lib
Features
- Support block cursor style
- Support inline wrap
- Support Chinese Block style
- Support history record
- Support Custom storageProvider
Usage
npm i web-term-ui
import {WebTerm} from 'web-term-ui';
const term = new WebTerm({
title: [
'This is a Demo. Type "vi" to use vi editor',
'And "ctrl/cmd + s" to Save, "esc" to cancel.\n'
].join('\n'),
container: '#container',
getHeader: () => '/ admin$ '
});
term.on('enter', v => {
if (v === 'vi') term.vi();
else term.write(`Exec "${v}"`);
});
term.on('edit-done', v => {
term.write(`Edit Save: ${v}`);
});
term.on('tab', () => {
term.insertEdit('[test]');
});
CDN
<script src="https://cdn.jsdelivr.net/npm/web-term-ui"></script>
<script>console.log(window.WebTermUi);</script>
Options
export interface IWebTermOptions {
title?: string,
container?: string|HTMLElement,
historyMax?: number,
storageProvider?: {
read: ()=>IPromiseMaybe<string>,
write: (history: string)=>IPromiseMaybe<boolean>
},
getHeader?: IFnMaybe<string>,
}
API
{
clearHistory(): void;
write(content: string | Dom): void;
insertEdit(content: string): void;
replaceEdit(content: string): void;
pushEdit(content: string): void;
vi(v?: string): void;
}
Events
export interface IWebTermEvents {
'enter': [string],
'edit-done': [string],
'edit-cancel': [],
'tab': [];
}