Files
Netcatty/lib/customCss.ts
陈大猫 733e19a6f6 perf(settings): reduce Mac settings window input lag (#1347) (#1368)
* perf(settings): reduce Mac settings window input lag (#1347)

Debounce custom CSS commits, memoize heavy tabs, and replace Radix ScrollArea
with native scrolling so typing and navigation stay responsive on macOS.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(settings): flush debounced textarea on unmount

Avoid losing custom CSS edits when the settings window closes before the
debounce timer fires.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 14:45:33 +08:00

15 lines
503 B
TypeScript

const CUSTOM_CSS_STYLE_ID = 'netcatty-custom-css';
/** Inject or update the user custom CSS style block in document.head. */
export function applyCustomCssToDocument(css: string): void {
if (typeof document === 'undefined') return;
let styleEl = document.getElementById(CUSTOM_CSS_STYLE_ID) as HTMLStyleElement | null;
if (!styleEl) {
styleEl = document.createElement('style');
styleEl.id = CUSTOM_CSS_STYLE_ID;
document.head.appendChild(styleEl);
}
styleEl.textContent = css;
}