fix: theme toggle

This commit is contained in:
ghost2023
2026-08-10 11:52:03 +03:00
parent 84081156f6
commit 10af12bfc6
18 changed files with 47 additions and 341 deletions

View File

@@ -1,4 +1,4 @@
import React, { useMemo, useState, useEffect } from "react";
import React, { useMemo } from "react";
import { Editor as TinyMCEEditor } from "@/record-management/common/editor/rte";
import type { Editor as TinyMCEEditorType } from "tinymce";
@@ -21,18 +21,11 @@ export const TemplateEditor: React.FC<TemplateEditorProps> = ({
placeholders,
}) => {
const hasPlaceholders = placeholders && placeholders.length > 0;
const [isDarkMode, setIsDarkMode] = useState(() =>
typeof window !== "undefined" && document.documentElement.classList.contains("dark")
);
useEffect(() => {
const observer = new MutationObserver(() => {
setIsDarkMode(document.documentElement.classList.contains("dark"));
});
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
return () => observer.disconnect();
}, []);
// The app is light-only — nothing sets the `dark` class on <html>, so this is
// a constant rather than observed state. Kept as a named flag so the TinyMCE
// skin/content-style branches below stay readable.
const isDarkMode = false;
const init = useMemo(() => {
return {
height: 600,