Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: make static toolbar groups actually static

thecodrr82fcb7709bd1
diff --git a/packages/editor/src/toolbar/tool-definitions.ts b/packages/editor/src/toolbar/tool-definitions.ts
index bbf9edc7d..3e2636140 100644
--- a/packages/editor/src/toolbar/tool-definitions.ts
+++ b/packages/editor/src/toolbar/tool-definitions.ts
@@ -302,19 +302,22 @@ export function getDefaultPresets() {
return defaultPresets;
}
+export const STATIC_TOOLBAR_GROUPS: ToolbarDefinition = [
+ [
+ "insertBlock",
+ "tableSettings",
+ "imageSettings",
+ "embedSettings",
+ "attachmentSettings",
+ "linkSettings",
+ "codeRemove",
+ "outdent",
+ "indent",
+ ],
+];
+
const defaultPresets: Record<"default" | "minimal", ToolbarDefinition> = {
default: [
- [
- "insertBlock",
- "tableSettings",
- "imageSettings",
- "embedSettings",
- "attachmentSettings",
- "linkSettings",
- "codeRemove",
- "outdent",
- "indent",
- ],
[
"bold",
"italic",
diff --git a/packages/editor/src/toolbar/toolbar.tsx b/packages/editor/src/toolbar/toolbar.tsx
index 5da3245a9..e7430f1d9 100644
--- a/packages/editor/src/toolbar/toolbar.tsx
+++ b/packages/editor/src/toolbar/toolbar.tsx
@@ -1,23 +1,12 @@
-import { Theme, useTheme } from "@notesnook/theme";
-import { ThemeConfig } from "@notesnook/theme/dist/theme/types";
+import { Theme } from "@notesnook/theme";
import { Editor } from "../types";
import { Flex, FlexProps } from "rebass";
-import { findTool, ToolId } from "./tools";
import { ThemeProvider } from "emotion-theming";
import { EditorFloatingMenus } from "./floating-menus";
-import { getDefaultPresets, getToolDefinition } from "./tool-definitions";
-import { Dropdown } from "./components/dropdown";
-import { ToolButton } from "./components/tool-button";
-import { useContext, useEffect, useRef, useState } from "react";
-// import { MenuPresenter } from "../components/menu";
-import { Popup } from "./components/popup";
-import {
- ToolbarLocation,
- useToolbarLocation,
- useToolbarStore,
-} from "./stores/toolbar-store";
-import { getToolbarElement } from "./utils/dom";
-import { ToolbarDefinition, ToolProps } from "./types";
+import { getDefaultPresets, STATIC_TOOLBAR_GROUPS } from "./tool-definitions";
+import { useEffect, useMemo } from "react";
+import { ToolbarLocation, useToolbarStore } from "./stores/toolbar-store";
+import { ToolbarDefinition } from "./types";
import { ToolbarGroup } from "./components/toolbar-group";
import {
EditorContext,
@@ -40,6 +29,12 @@ export function Toolbar(props: ToolbarProps) {
sx,
...flexProps
} = props;
+
+ const toolbarTools = useMemo(
+ () => [...STATIC_TOOLBAR_GROUPS, ...tools],
+ [tools]
+ );
+
const setToolbarLocation = useToolbarStore(
(store) => store.setToolbarLocation
);
@@ -62,7 +57,7 @@ export function Toolbar(props: ToolbarProps) {
}}
{...flexProps}
>
- {tools.map((tools) => {
+ {toolbarTools.map((tools) => {
return (
<ToolbarGroup
key={tools.join("")}