A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: get theme from props
thecodrr4e32c0ace106
diff --git a/packages/editor/dist/index.d.ts b/packages/editor/dist/index.d.tsindex e85a96c93..18fd1b13e 100644--- a/packages/editor/dist/index.d.ts+++ b/packages/editor/dist/index.d.ts@@ -1,7 +1,9 @@/// <reference types="react" />import { EditorOptions } from "@tiptap/react";import Toolbar from "./toolbar";-import { ThemeConfig } from "@notesnook/theme/dist/theme/types";+import { Theme } from "@notesnook/theme";import { AttachmentOptions } from "./extensions/attachment";-declare const useTiptap: (options?: Partial<EditorOptions & ThemeConfig & AttachmentOptions>, deps?: import("react").DependencyList | undefined) => import("@tiptap/react").Editor | null;+declare const useTiptap: (options?: Partial<EditorOptions & AttachmentOptions & {+ theme: Theme;+}>, deps?: import("react").DependencyList | undefined) => import("@tiptap/react").Editor | null;export { useTiptap, Toolbar };diff --git a/packages/editor/dist/index.js b/packages/editor/dist/index.jsindex 94adba884..b578d5556 100644--- a/packages/editor/dist/index.js+++ b/packages/editor/dist/index.js@@ -45,7 +45,6 @@ import TableRow from "@tiptap/extension-table-row";import TableCell from "./extensions/table-cell";import TableHeader from "@tiptap/extension-table-header";import { ImageNode } from "./extensions/image";-import { useTheme } from "@notesnook/theme";import { AttachmentNode } from "./extensions/attachment";import { TaskListNode } from "./extensions/task-list";import { TaskItemNode } from "./extensions/task-item";@@ -59,7 +58,7 @@ EditorView.prototype.updateState = function updateState(state) {};var useTiptap = function (options, deps) {if (options === void 0) { options = {}; }- var theme = options.theme, accent = options.accent, scale = options.scale, onCreate = options.onCreate, onDownloadAttachment = options.onDownloadAttachment, restOptions = __rest(options, ["theme", "accent", "scale", "onCreate", "onDownloadAttachment"]);+ var theme = options.theme, onCreate = options.onCreate, onDownloadAttachment = options.onDownloadAttachment, restOptions = __rest(options, ["theme", "onCreate", "onDownloadAttachment"]);var defaultOptions = useMemo(function () { return ({extensions: [SearchReplace,@@ -109,13 +108,13 @@ var useTiptap = function (options, deps) {],onCreate: function (_a) {var editor = _a.editor;- if (theme && accent && scale) {- editor.storage.theme = useTheme({ theme: theme, accent: accent, scale: scale });+ if (theme) {+ editor.storage.theme = theme;}if (onCreate)onCreate({ editor: editor });},- }); }, [theme, accent, scale, onCreate, onDownloadAttachment]);+ }); }, [theme, onCreate, onDownloadAttachment]);var editor = useEditor(__assign(__assign({}, defaultOptions), restOptions), deps);/*** Add editor to global for use in React Native.diff --git a/packages/editor/dist/toolbar/toolbar.d.ts b/packages/editor/dist/toolbar/toolbar.d.tsindex e871a4cea..3b0a7f532 100644--- a/packages/editor/dist/toolbar/toolbar.d.ts+++ b/packages/editor/dist/toolbar/toolbar.d.ts@@ -1,8 +1,9 @@/// <reference types="react" />-import { ThemeConfig } from "@notesnook/theme/dist/theme/types";+import { Theme } from "@notesnook/theme";import { Editor } from "@tiptap/core";import { ToolbarLocation } from "./stores/toolbar-store";-declare type ToolbarProps = ThemeConfig & {+declare type ToolbarProps = {+ theme: Theme;editor: Editor | null;location: ToolbarLocation;isMobile?: boolean;diff --git a/packages/editor/dist/toolbar/toolbar.js b/packages/editor/dist/toolbar/toolbar.jsindex 073f309d2..46bd88bac 100644--- a/packages/editor/dist/toolbar/toolbar.js+++ b/packages/editor/dist/toolbar/toolbar.js@@ -37,7 +37,6 @@ var __read = (this && this.__read) || function (o, n) {return ar;};import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";-import { useTheme } from "@notesnook/theme";import { Flex } from "rebass";import { findToolById } from "./tools";import { ThemeProvider } from "emotion-theming";@@ -50,8 +49,7 @@ import { Popup } from "./components/popup";import { ToolbarContext, useToolbarContext } from "./hooks/useToolbarContext";import { useToolbarLocation, useToolbarStore, } from "./stores/toolbar-store";export function Toolbar(props) {- var editor = props.editor, theme = props.theme, accent = props.accent, scale = props.scale, location = props.location, isMobile = props.isMobile;- var themeProperties = useTheme({ accent: accent, theme: theme, scale: scale });+ var editor = props.editor, theme = props.theme, location = props.location, isMobile = props.isMobile;var _a = __read(useState(), 2), currentPopup = _a[0], setCurrentPopup = _a[1];var _b = useToolbarStore(), setIsMobile = _b.setIsMobile, setToolbarLocation = _b.setToolbarLocation;useEffect(function () {@@ -82,7 +80,7 @@ export function Toolbar(props) {];if (!editor)return null;- return (_jsxs(ThemeProvider, __assign({ theme: themeProperties }, { children: [_jsx(ToolbarContext.Provider, __assign({ value: {+ return (_jsxs(ThemeProvider, __assign({ theme: theme }, { children: [_jsx(ToolbarContext.Provider, __assign({ value: {setCurrentPopup: setCurrentPopup,currentPopup: currentPopup,} }, { children: _jsx(Flex, __assign({ className: "editor-toolbar", sx: { flexWrap: ["nowrap", "wrap"], overflowX: ["auto", "hidden"] } }, { children: tools.map(function (tools) {diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.tsindex 7fccfea7e..d00b59878 100644--- a/packages/editor/src/index.ts+++ b/packages/editor/src/index.ts@@ -24,7 +24,7 @@ import TableCell from "./extensions/table-cell";import TableHeader from "@tiptap/extension-table-header";import { ImageNode } from "./extensions/image";import { ThemeConfig } from "@notesnook/theme/dist/theme/types";-import { useTheme } from "@notesnook/theme";+import { Theme, useTheme } from "@notesnook/theme";import { AttachmentNode, AttachmentOptions } from "./extensions/attachment";import { TaskListNode } from "./extensions/task-list";import { TaskItemNode } from "./extensions/task-item";@@ -38,17 +38,10 @@ EditorView.prototype.updateState = function updateState(state) {};const useTiptap = (- options: Partial<EditorOptions & ThemeConfig & AttachmentOptions> = {},+ options: Partial<EditorOptions & AttachmentOptions & { theme: Theme }> = {},deps?: React.DependencyList) => {- const {- theme,- accent,- scale,- onCreate,- onDownloadAttachment,- ...restOptions- } = options;+ const { theme, onCreate, onDownloadAttachment, ...restOptions } = options;const defaultOptions = useMemo<Partial<EditorOptions>>(() => ({@@ -100,13 +93,13 @@ const useTiptap = (}),],onCreate: ({ editor }) => {- if (theme && accent && scale) {- editor.storage.theme = useTheme({ theme, accent, scale });+ if (theme) {+ editor.storage.theme = theme;}if (onCreate) onCreate({ editor });},}),- [theme, accent, scale, onCreate, onDownloadAttachment]+ [theme, onCreate, onDownloadAttachment]);const editor = useEditor({ ...defaultOptions, ...restOptions }, deps);diff --git a/packages/editor/src/toolbar/toolbar.tsx b/packages/editor/src/toolbar/toolbar.tsxindex 1411f591c..4c7ebe5ef 100644--- a/packages/editor/src/toolbar/toolbar.tsx+++ b/packages/editor/src/toolbar/toolbar.tsx@@ -1,4 +1,4 @@-import { useTheme } from "@notesnook/theme";+import { Theme, useTheme } from "@notesnook/theme";import { ThemeConfig } from "@notesnook/theme/dist/theme/types";import { Editor } from "@tiptap/core";import { Flex, FlexProps } from "rebass";@@ -30,14 +30,14 @@ import {type ToolbarGroupDefinition = (ToolId | ToolId[])[];type ToolbarDefinition = ToolbarGroupDefinition[];-type ToolbarProps = ThemeConfig & {+type ToolbarProps = {+ theme: Theme;editor: Editor | null;location: ToolbarLocation;isMobile?: boolean;};export function Toolbar(props: ToolbarProps) {- const { editor, theme, accent, scale, location, isMobile } = props;- const themeProperties = useTheme({ accent, theme, scale });+ const { editor, theme, location, isMobile } = props;const [currentPopup, setCurrentPopup] = useState<string | undefined>();const { setIsMobile, setToolbarLocation } = useToolbarStore();@@ -71,7 +71,7 @@ export function Toolbar(props: ToolbarProps) {if (!editor) return null;return (- <ThemeProvider theme={themeProperties}>+ <ThemeProvider theme={theme}><ToolbarContext.Providervalue={{setCurrentPopup,