Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
25 lines
1.5 KiB
JavaScript
25 lines
1.5 KiB
JavaScript
// Type-to-search is intentionally limited to the home page. Never capture typing
|
|
// in another editor, a modal, an open menu, or an OS/browser keyboard shortcut.
|
|
(() => {
|
|
const input = document.querySelector('[data-home-type-search]');
|
|
if (!input) return;
|
|
document.addEventListener('keydown', event => {
|
|
if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || event.isComposing) return;
|
|
if (event.target.closest?.('input,textarea,select,button,a,summary,[contenteditable]:not([contenteditable="false"]),[role="textbox"]')) return;
|
|
if ([...document.querySelectorAll('dialog[open],details[open],[role="dialog"]:not(dialog),[aria-modal="true"]:not(dialog)')]
|
|
.some(surface => !surface.hidden && surface.getClientRects().length)) return;
|
|
if (window.getSelection()?.toString()) return;
|
|
const composing = event.key === 'Process' || event.keyCode === 229;
|
|
if (!composing && ([...event.key].length !== 1 || event.key.trim() === '')) return;
|
|
document.dispatchEvent(new Event('home:search'));
|
|
if (input.closest('[inert]') || !input.getClientRects().length) return;
|
|
input.focus({preventScroll: true});
|
|
// Redirect IME's native composition to the input without synthesizing text.
|
|
if (composing) return;
|
|
event.preventDefault();
|
|
// Search inputs do not support setRangeText/selectionStart in all browsers.
|
|
input.value += event.key;
|
|
input.dispatchEvent(new Event('input', {bubbles: true}));
|
|
});
|
|
})();
|