From 7ec469304a222bb08e2a97aafe208f4a2697c7c1 Mon Sep 17 00:00:00 2001 From: Gregory Moskaliuk Date: Fri, 24 Apr 2026 17:36:38 +0200 Subject: [PATCH] refactor(web): centralize - ) : null; - if (parseError) { return ( - - {selectionStyle} -
-
{markdown}
-
-
+
+
{markdown}
+
); } @@ -143,21 +124,18 @@ export const EnrichedMarkdownText = ({ const lastIdx = children.length - 1; return ( - - {selectionStyle} -
- {children.map((child, index) => ( - - ))} -
-
+
+ {children.map((child, index) => ( + + ))} +
); }; diff --git a/src/web/globalStyles.ts b/src/web/globalStyles.ts new file mode 100644 index 00000000..53acfa4c --- /dev/null +++ b/src/web/globalStyles.ts @@ -0,0 +1,15 @@ +import { injectStyleOnce } from './injectStyle'; + +export const ENRM_TEXT_CLASS = 'enrm-text'; +export const ENRM_SELECTION_BG_VAR = '--enrm-selection-bg'; + +const RULES: ReadonlyArray = [ + [ + 'enrm-selection-style', + `.${ENRM_TEXT_CLASS} ::selection { background-color: var(${ENRM_SELECTION_BG_VAR}); }`, + ], +]; + +for (const [id, css] of RULES) { + injectStyleOnce(id, css); +} diff --git a/src/web/injectStyle.ts b/src/web/injectStyle.ts new file mode 100644 index 00000000..063eef35 --- /dev/null +++ b/src/web/injectStyle.ts @@ -0,0 +1,17 @@ +/// + +/** + * Idempotently injects a `