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: make toolbar configurable
thecodrr82be67613255
diff --git a/packages/editor/dist/index.d.ts b/packages/editor/dist/index.d.tsindex 93faa0581..204080ab2 100644--- a/packages/editor/dist/index.d.ts+++ b/packages/editor/dist/index.d.ts@@ -1,3 +1,4 @@+/// <reference types="react" />import "./extensions";import { EditorOptions } from "@tiptap/react";import Toolbar from "./toolbar";diff --git a/packages/editor/dist/toolbar/toolbar.d.ts b/packages/editor/dist/toolbar/toolbar.d.tsindex 3b0a7f532..29e9038aa 100644--- a/packages/editor/dist/toolbar/toolbar.d.ts+++ b/packages/editor/dist/toolbar/toolbar.d.ts@@ -2,11 +2,13 @@import { Theme } from "@notesnook/theme";import { Editor } from "@tiptap/core";import { ToolbarLocation } from "./stores/toolbar-store";+import { ToolbarDefinition } from "./types";declare type ToolbarProps = {theme: Theme;editor: Editor | null;location: ToolbarLocation;isMobile?: boolean;+ tools?: ToolbarDefinition;};export declare function Toolbar(props: ToolbarProps): JSX.Element | null;export {};diff --git a/packages/editor/dist/toolbar/toolbar.js b/packages/editor/dist/toolbar/toolbar.jsindex 8f2313852..6b7d13b98 100644--- a/packages/editor/dist/toolbar/toolbar.js+++ b/packages/editor/dist/toolbar/toolbar.js@@ -17,44 +17,44 @@ import { useEffect } from "react";import { useToolbarStore, } from "./stores/toolbar-store";import { ToolbarGroup } from "./components/toolbar-group";import { EditorContext, PopupRenderer, } from "../components/popup-presenter/popuprenderer";+var DEFAULT_TOOLS = [+ [+ "insertBlock",+ "tableSettings",+ "imageSettings",+ "embedSettings",+ "attachmentSettings",+ "linkSettings",+ "codeRemove",+ ],+ [+ "bold",+ "italic",+ "underline",+ [+ "strikethrough",+ "code",+ "subscript",+ "superscript",+ "highlight",+ "textColor",+ ],+ ],+ ["fontSize"],+ ["headings", "fontFamily"],+ ["numberedList", "bulletList"],+ ["addLink"],+ ["alignCenter", ["alignLeft", "alignRight", "alignJustify", "ltr", "rtl"]],+ ["clearformatting"],+];export function Toolbar(props) {- var editor = props.editor, theme = props.theme, location = props.location, isMobile = props.isMobile;+ var editor = props.editor, theme = props.theme, location = props.location, isMobile = props.isMobile, _a = props.tools, tools = _a === void 0 ? DEFAULT_TOOLS : _a;var setIsMobile = useToolbarStore(function (store) { return store.setIsMobile; });var setToolbarLocation = useToolbarStore(function (store) { return store.setToolbarLocation; });useEffect(function () {setIsMobile(isMobile || false);setToolbarLocation(location);}, [isMobile, location]);- var tools = [- [- "insertBlock",- "tableSettings",- "imageSettings",- "embedSettings",- "attachmentSettings",- "linkSettings",- "codeRemove",- ],- [- "bold",- "italic",- "underline",- [- "strikethrough",- "code",- "subscript",- "superscript",- "highlight",- "textColor",- ],- ],- ["fontSize"],- ["headings", "fontFamily"],- ["numberedList", "bulletList"],- ["addLink"],- ["alignCenter", ["alignLeft", "alignRight", "alignJustify", "ltr", "rtl"]],- ["clearformatting"],- ];if (!editor)return null;return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(EditorContext.Provider, __assign({ value: editor }, { children: _jsxs(PopupRenderer, __assign({ editor: editor }, { 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/toolbar/toolbar.tsx b/packages/editor/src/toolbar/toolbar.tsxindex 3e9cedf5b..53e924c98 100644--- a/packages/editor/src/toolbar/toolbar.tsx+++ b/packages/editor/src/toolbar/toolbar.tsx@@ -23,23 +23,48 @@ import {EditorContext,PopupRenderer,} from "../components/popup-presenter/popuprenderer";-// type Colors = {-// text: string;-// background: string;-// bgSecondary: string;-// primary: string;-// hover: string;-// border: string;-// };type ToolbarProps = {theme: Theme;editor: Editor | null;location: ToolbarLocation;isMobile?: boolean;+ tools?: ToolbarDefinition;};++const DEFAULT_TOOLS: ToolbarDefinition = [+ [+ "insertBlock",+ "tableSettings",+ "imageSettings",+ "embedSettings",+ "attachmentSettings",+ "linkSettings",+ "codeRemove",+ ],+ [+ "bold",+ "italic",+ "underline",+ [+ "strikethrough",+ "code",+ "subscript",+ "superscript",+ "highlight",+ "textColor",+ ],+ ],+ ["fontSize"],+ ["headings", "fontFamily"],+ ["numberedList", "bulletList"],+ ["addLink"],+ ["alignCenter", ["alignLeft", "alignRight", "alignJustify", "ltr", "rtl"]],+ ["clearformatting"],+];+export function Toolbar(props: ToolbarProps) {- const { editor, theme, location, isMobile } = props;+ const { editor, theme, location, isMobile, tools = DEFAULT_TOOLS } = props;const setIsMobile = useToolbarStore((store) => store.setIsMobile);const setToolbarLocation = useToolbarStore((store) => store.setToolbarLocation@@ -50,37 +75,6 @@ export function Toolbar(props: ToolbarProps) {setToolbarLocation(location);}, [isMobile, location]);- const tools: ToolbarDefinition = [- [- "insertBlock",- "tableSettings",- "imageSettings",- "embedSettings",- "attachmentSettings",- "linkSettings",- "codeRemove",- ],- [- "bold",- "italic",- "underline",- [- "strikethrough",- "code",- "subscript",- "superscript",- "highlight",- "textColor",- ],- ],- ["fontSize"],- ["headings", "fontFamily"],- ["numberedList", "bulletList"],- ["addLink"],- ["alignCenter", ["alignLeft", "alignRight", "alignJustify", "ltr", "rtl"]],- ["clearformatting"],- ];-if (!editor) return null;return (<ThemeProvider theme={theme}>