mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Fix tsconfigs, IDisposable, and add comments
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"main": "lib/xterm-addon-clipboard.js",
|
||||
"types": "typings/xterm-addon-clipboard.d.ts",
|
||||
"repository": "https://github.com/xtermjs/xterm.js",
|
||||
"repository": "https://github.com/xtermjs/xterm.js/tree/master/addons/xterm-addon-clipboard",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"terminal",
|
||||
|
||||
@@ -4,18 +4,17 @@
|
||||
*/
|
||||
|
||||
import { ClipboardProvider } from './ClipboardProvider';
|
||||
import { IClipboardProvider, ITerminalAddon, Terminal } from 'xterm';
|
||||
import { IClipboardProvider, IDisposable, ITerminalAddon, Terminal } from 'xterm';
|
||||
|
||||
export class ClipboardAddon implements ITerminalAddon {
|
||||
private _terminal: Terminal | undefined;
|
||||
private _disposable: IDisposable | undefined;
|
||||
constructor(private _provider: IClipboardProvider = new ClipboardProvider()) {}
|
||||
|
||||
public activate(terminal: Terminal): void {
|
||||
this._terminal = terminal;
|
||||
terminal.registerClipboardProvider(this._provider);
|
||||
this._disposable = terminal.registerClipboardProvider(this._provider);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._terminal?.deregisterClipboardProvider();
|
||||
return this._disposable?.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2017",
|
||||
"target": "es2021",
|
||||
"sourceMap": true,
|
||||
"outDir": "../out",
|
||||
"rootDir": ".",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2015",
|
||||
"target": "es2021",
|
||||
"lib": [
|
||||
"es2015"
|
||||
"es2021"
|
||||
],
|
||||
"rootDir": ".",
|
||||
"outDir": "../out-test",
|
||||
@@ -19,4 +19,4 @@
|
||||
"./**/*",
|
||||
"../../../typings/xterm.d.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,12 +883,13 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
||||
return this.linkifier2.registerLinkProvider(linkProvider);
|
||||
}
|
||||
|
||||
public registerClipboardProvider(provider: IClipboardProvider): void {
|
||||
public registerClipboardProvider(provider: IClipboardProvider): IDisposable {
|
||||
this._clipboardProvider = provider;
|
||||
}
|
||||
|
||||
public deregisterClipboardProvider(): void {
|
||||
this._clipboardProvider = undefined;
|
||||
return {
|
||||
dispose: () => {
|
||||
this._clipboardProvider = undefined;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public registerCharacterJoiner(handler: CharacterJoinerHandler): number {
|
||||
|
||||
@@ -104,10 +104,7 @@ export class MockTerminal implements ITerminal {
|
||||
public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
public registerClipboardProvider(provider: IClipboardProvider): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
public deregisterClipboardProvider(): void {
|
||||
public registerClipboardProvider(provider: IClipboardProvider): IDisposable {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
public hasSelection(): boolean {
|
||||
|
||||
@@ -168,11 +168,8 @@ export class Terminal extends Disposable implements ITerminalApi {
|
||||
this._verifyPositiveIntegers(decorationOptions.x ?? 0, decorationOptions.width ?? 0, decorationOptions.height ?? 0);
|
||||
return this._core.registerDecoration(decorationOptions);
|
||||
}
|
||||
public registerClipboardProvider(provider: IClipboardProvider): void {
|
||||
this._core.registerClipboardProvider(provider);
|
||||
}
|
||||
public deregisterClipboardProvider(): void {
|
||||
this._core.deregisterClipboardProvider();
|
||||
public registerClipboardProvider(provider: IClipboardProvider): IDisposable {
|
||||
return this._core.registerClipboardProvider(provider);
|
||||
}
|
||||
public hasSelection(): boolean {
|
||||
return this._core.hasSelection();
|
||||
|
||||
@@ -78,7 +78,6 @@ type TerminalProxyCustomOverrides = 'buffer' | (
|
||||
'registerLinkProvider' |
|
||||
'registerCharacterJoiner' |
|
||||
'registerClipboardProvider' |
|
||||
'deregisterClipboardProvider' |
|
||||
'deregisterCharacterJoiner' |
|
||||
'loadAddon'
|
||||
);
|
||||
|
||||
Vendored
+8
-9
@@ -1073,12 +1073,7 @@ declare module 'xterm' {
|
||||
* clipboard to read/write clipboard data.
|
||||
* @param provider The provider to register.
|
||||
*/
|
||||
registerClipboardProvider(provider: IClipboardProvider): void;
|
||||
|
||||
/**
|
||||
* Deregisters the active clipboard provider.
|
||||
*/
|
||||
deregisterClipboardProvider(): void;
|
||||
registerClipboardProvider(provider: IClipboardProvider): IDisposable;
|
||||
|
||||
/**
|
||||
* Gets whether the terminal has an active selection.
|
||||
@@ -1873,14 +1868,18 @@ declare module 'xterm' {
|
||||
/**
|
||||
* Sets the clipboard content.
|
||||
* @param selection The clipboard selection to set.
|
||||
* @param data The base64 encoded data to set. If the data is invalid base64, the clipboard is
|
||||
* cleared.
|
||||
* @param data The base64 encoded data to set. If the data is invalid
|
||||
* base64, the clipboard is cleared.
|
||||
*/
|
||||
writeText(selection: ClipboardSelection, data: string): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clipboard selection type.
|
||||
* Clipboard selection type. This is used to specify which selection buffer to
|
||||
* read or write to.
|
||||
* - SYSTEM `c`: The system clipboard.
|
||||
* - PRIMARY `p`: The primary clipboard. This is provided for compatibility
|
||||
* with Linux X11.
|
||||
*/
|
||||
export const enum ClipboardSelection {
|
||||
SYSTEM = 'c',
|
||||
|
||||
Reference in New Issue
Block a user