Skip to content

Commit e297e6c

Browse files
authored
fix: add contenteditable attribute to prevent extension conflicts (#78)
1 parent 1d03ec8 commit e297e6c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/terminal.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,17 @@ export class Terminal implements ITerminalCore {
325325
parent.setAttribute('tabindex', '0');
326326
}
327327

328+
// Mark as contenteditable so browser extensions (Vimium, etc.) recognize
329+
// this as an input element and don't intercept keyboard events.
330+
parent.setAttribute('contenteditable', 'true');
331+
// Prevent actual content editing - we handle input ourselves
332+
parent.addEventListener('beforeinput', (e) => e.preventDefault());
333+
334+
// Add accessibility attributes for screen readers and extensions
335+
parent.setAttribute('role', 'textbox');
336+
parent.setAttribute('aria-label', 'Terminal input');
337+
parent.setAttribute('aria-multiline', 'true');
338+
328339
// Create WASM terminal with current dimensions and theme config
329340
const wasmConfig = this.buildWasmConfig();
330341
this.wasmTerm = this.ghostty!.createTerminal(this.cols, this.rows, wasmConfig);
@@ -1113,6 +1124,12 @@ export class Terminal implements ITerminalCore {
11131124
this.element.removeEventListener('mousemove', this.handleMouseMove);
11141125
this.element.removeEventListener('mouseleave', this.handleMouseLeave);
11151126
this.element.removeEventListener('click', this.handleClick);
1127+
1128+
// Remove contenteditable and accessibility attributes added in open()
1129+
this.element.removeAttribute('contenteditable');
1130+
this.element.removeAttribute('role');
1131+
this.element.removeAttribute('aria-label');
1132+
this.element.removeAttribute('aria-multiline');
11161133
}
11171134

11181135
// Remove document-level listeners (only if opened)

0 commit comments

Comments
 (0)