diff --git a/addons/xterm-addon-web-links/src/WebLinksAddon.ts b/addons/xterm-addon-web-links/src/WebLinksAddon.ts index 26d5904b..3290a59c 100644 --- a/addons/xterm-addon-web-links/src/WebLinksAddon.ts +++ b/addons/xterm-addon-web-links/src/WebLinksAddon.ts @@ -26,7 +26,13 @@ const end = ')($|' + negatedPathCharacterSet + ')'; const strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end); function handleLink(event: MouseEvent, uri: string): void { - window.open(uri, '_blank'); + const newWindow = window.open(); + if (newWindow) { + newWindow.opener = null; + newWindow.location.href = uri; + } else { + console.warn('Opening link blocked as opener could not be cleared'); + } } export class WebLinksAddon implements ITerminalAddon { diff --git a/src/browser/Linkifier.ts b/src/browser/Linkifier.ts index 30c76e8a..971501b7 100644 --- a/src/browser/Linkifier.ts +++ b/src/browser/Linkifier.ts @@ -298,7 +298,13 @@ export class Linkifier implements ILinkifier { if (matcher.handler) { return matcher.handler(e, uri); } - window.open(uri, '_blank'); + const newWindow = window.open(); + if (newWindow) { + newWindow.opener = null; + newWindow.location.href = uri; + } else { + console.warn('Opening link blocked as opener could not be cleared'); + } }, () => { this._onLinkHover.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg)); diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 16e32110..fc2549bc 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -1170,7 +1170,7 @@ declare module 'xterm' { } /** - * (EXPERIMENTAL) Data type to register a CSI, DCS or ESC callback in the parser + * Data type to register a CSI, DCS or ESC callback in the parser * in the form: * ESC I..I F * CSI Prefix P..P I..I F @@ -1214,7 +1214,7 @@ declare module 'xterm' { } /** - * (EXPERIMENTAL) Parser interface. + * Allows hooking into the parser for custom handling of escape sequences. */ export interface IParser { /** @@ -1231,11 +1231,6 @@ declare module 'xterm' { */ registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; - /** - * @deprecated use `registerMarker` instead. - */ - addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable; - /** * Adds a handler for DCS escape sequences. * @param id Specifies the function identifier under which the callback @@ -1255,11 +1250,6 @@ declare module 'xterm' { */ registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; - /** - * @deprecated use `registerMarker` instead. - */ - addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable; - /** * Adds a handler for ESC escape sequences. * @param id Specifies the function identifier under which the callback @@ -1273,11 +1263,6 @@ declare module 'xterm' { */ registerEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; - /** - * @deprecated use `registerMarker` instead. - */ - addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable; - /** * Adds a handler for OSC escape sequences. * @param ident The number (first parameter) of the sequence. @@ -1295,11 +1280,6 @@ declare module 'xterm' { * @return An IDisposable you can call to remove this handler. */ registerOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; - - /** - * @deprecated use `registerMarker` instead. - */ - addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; } /**