editor: load theme from local storage on init

This commit is contained in:
ammarahm-ed
2023-08-04 20:58:24 +05:00
committed by Ammar Ahmed
parent 985ae848d3
commit 3831b9409e
3 changed files with 28 additions and 2 deletions

View File

@@ -18,6 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Editor } from "@notesnook/editor";
import {
ThemeDefinition,
useThemeColors,
useThemeEngineStore
} from "@notesnook/theme";
import {
MutableRefObject,
useCallback,
@@ -25,8 +30,7 @@ import {
useRef,
useState
} from "react";
import { EventTypes, isReactNative, post } from "../utils";
import { useThemeColors, useThemeEngineStore } from "@notesnook/theme";
import { EventTypes, isReactNative, post, saveTheme } from "../utils";
import { injectCss, transform } from "../utils/css";
type Attachment = {
@@ -190,6 +194,9 @@ export function useEditorController(update: () => void): EditorController {
break;
case "native:theme":
setTheme(message.value);
setTimeout(() => {
saveTheme(message.value as ThemeDefinition);
});
break;
case "native:title":
setTitle(value);