fix: do not reload editor on theme change

This commit is contained in:
thecodrr
2022-07-09 09:00:05 +05:00
parent e6b365cca1
commit 39bc1d58cf
12 changed files with 52 additions and 29 deletions

View File

@@ -18,8 +18,8 @@ import {
import { ReactNodeView } from "./react-node-view";
import { NodeViewRendererProps } from "@tiptap/core";
import { Theme } from "@notesnook/theme";
import { ThemeProvider } from "emotion-theming";
import { Editor } from "../../types";
import { ThemeProvider } from "../../components/theme-provider";
/**
* A ReactNodeView that handles React components sensitive
@@ -76,13 +76,12 @@ export class SelectionBasedNodeView<
forwardRef?: ForwardRef
): React.ReactElement<any> | null {
if (!this.options.component) return null;
const theme = this.editor.storage.theme as Theme;
const isSelected =
this.editor.isEditable &&
(this.insideSelection() || this.nodeInsideSelection());
return (
<ThemeProvider theme={theme}>
<ThemeProvider>
<this.options.component
{...props}
editor={this.editor}