From 6d3c89645d4868b8a72e7d88b62e60c426d4f542 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Wed, 24 Jun 2026 19:06:06 -0400 Subject: [PATCH] add CodeMirror editor theme inheritance --- translate/src/context/Theme.tsx | 6 ++++++ .../src/modules/translationform/components/EditField.tsx | 9 ++------- .../modules/translationform/utils/editFieldExtensions.ts | 9 ++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/translate/src/context/Theme.tsx b/translate/src/context/Theme.tsx index 1fca9857ce..16d22767a1 100644 --- a/translate/src/context/Theme.tsx +++ b/translate/src/context/Theme.tsx @@ -8,6 +8,12 @@ type ThemeContextType = { setEditorTheme: (editorTheme: string) => void; }; +export function editorThemeClass(editorTheme: string | null): string { + return editorTheme === 'dark' || editorTheme === 'light' + ? `${editorTheme}-theme` + : ''; +} + export const ThemeContext = createContext({ theme: 'dark', editorTheme: 'match', diff --git a/translate/src/modules/translationform/components/EditField.tsx b/translate/src/modules/translationform/components/EditField.tsx index 311ca5c709..525ab2046f 100644 --- a/translate/src/modules/translationform/components/EditField.tsx +++ b/translate/src/modules/translationform/components/EditField.tsx @@ -14,7 +14,7 @@ import React, { import { EditFieldHandle, EditorActions } from '~/context/Editor'; import { Locale } from '~/context/Locale'; -import { ThemeContext } from '~/context/Theme'; +import { editorThemeClass, ThemeContext } from '~/context/Theme'; import { useReadonlyEditor } from '~/hooks/useReadonlyEditor'; import { getExtensions, useKeyHandlers } from '../utils/editFieldExtensions'; @@ -127,15 +127,10 @@ export const EditField = memo( [view], ); - const editorThemeClass = - editorTheme === 'dark' || editorTheme === 'light' - ? `${editorTheme}-theme` - : ''; - return (
+ editorThemeClass(document.body.getAttribute('data-editor-theme')), + }) + : null; } function completePlaceholder(