Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a documentOverride setting #4844

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/browser/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ export class Terminal extends CoreTerminal implements ITerminal {
}

this._document = parent.ownerDocument!;
if (this.options.documentOverride && this.options.documentOverride instanceof Document) {
this._document = this.optionsService.rawOptions.documentOverride as Document;
}

// Create main element container
this.element = this._document.createElement('div');
Expand Down
1 change: 1 addition & 0 deletions src/common/services/OptionsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
cursorInactiveStyle: 'outline',
customGlyphs: true,
drawBoldTextInBrightColors: true,
documentOverride: null,
fastScrollModifier: 'alt',
fastScrollSensitivity: 5,
fontFamily: 'courier-new, courier, monospace',
Expand Down
1 change: 1 addition & 0 deletions src/common/services/Services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export interface ITerminalOptions {
cursorInactiveStyle?: CursorInactiveStyle;
customGlyphs?: boolean;
disableStdin?: boolean;
documentOverride?: any | null;
drawBoldTextInBrightColors?: boolean;
fastScrollModifier?: 'none' | 'alt' | 'ctrl' | 'shift';
fastScrollSensitivity?: number;
Expand Down
11 changes: 11 additions & 0 deletions typings/xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ declare module 'xterm' {
*/
disableStdin?: boolean;

/**
* A {@link Document} to use instead of the one that xterm.js was attached
* to. The purpose of this is to improve support in multi-window
* applications where HTML elements may be references across multiple
* windows which can cause problems with `instanceof`.
*
* The type is `any` because using `Document` can cause TS to have
* performance/compiler problems.
*/
documentOverride?: any | null;

/**
* Whether to draw bold text in bright colors. The default is true.
*/
Expand Down