Skip to content

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

feat: add minimal toolbar preset

thecodrrca508303fb8a
diff --git a/packages/editor/dist/cjs/toolbar/toolbar.js b/packages/editor/dist/cjs/toolbar/toolbar.js
index 43bd8c505..0de4b0012 100644
--- a/packages/editor/dist/cjs/toolbar/toolbar.js
+++ b/packages/editor/dist/cjs/toolbar/toolbar.js
@@ -11,7 +11,7 @@ const toolbarstore_1 = require("./stores/toolbarstore");
const toolbargroup_1 = require("./components/toolbargroup");
const popuprenderer_1 = require("../components/popup-presenter/popuprenderer");
function Toolbar(props) {
- const { editor, theme, location, tools = tooldefinitions_1.DEFAULT_TOOLS } = props;
+ const { editor, theme, location, tools = (0, tooldefinitions_1.getDefaultPresets)().default, } = props;
const setToolbarLocation = (0, toolbarstore_1.useToolbarStore)((store) => store.setToolbarLocation);
(0, react_1.useEffect)(() => {
setToolbarLocation(location);
diff --git a/packages/editor/dist/cjs/toolbar/tooldefinitions.d.ts b/packages/editor/dist/cjs/toolbar/tooldefinitions.d.ts
index 576ba91b9..224e00ff4 100644
--- a/packages/editor/dist/cjs/toolbar/tooldefinitions.d.ts
+++ b/packages/editor/dist/cjs/toolbar/tooldefinitions.d.ts
@@ -2,4 +2,4 @@ import { ToolbarDefinition, ToolDefinition } from "./types";
import { ToolId } from "./tools";
export declare function getToolDefinition(id: ToolId): ToolDefinition;
export declare function getAllTools(): Record<"fontSize" | "underline" | "bold" | "bulletList" | "code" | "italic" | "subscript" | "superscript" | "textDirection" | "fontFamily" | "highlight" | "removeAttachment" | "downloadAttachment" | "deleteColumn" | "deleteRow" | "deleteTable" | "mergeCells" | "strikethrough" | "codeRemove" | "numberedList" | "textColor" | "openLink" | "linkSettings" | "imageSettings" | "rowProperties" | "insertRowBelow" | "insertRowAbove" | "moveRowDown" | "moveRowUp" | "columnProperties" | "insertColumnRight" | "insertColumnLeft" | "moveColumnRight" | "moveColumnLeft" | "cellProperties" | "cellBorderColor" | "splitCells" | "attachmentSettings" | "embedSettings" | "tableSettings" | "math" | "clearformatting" | "addLink" | "editLink" | "removeLink" | "insertBlock" | "headings" | "alignment" | "imageAlignCenter" | "imageAlignLeft" | "imageAlignRight" | "imageProperties" | "embedAlignCenter" | "embedAlignLeft" | "embedAlignRight" | "embedProperties" | "cellBackgroundColor" | "cellTextColor" | "cellBorderWidth", ToolDefinition>;
-export declare const DEFAULT_TOOLS: ToolbarDefinition;
+export declare function getDefaultPresets(): Record<"default" | "minimal", ToolbarDefinition>;
diff --git a/packages/editor/dist/cjs/toolbar/tooldefinitions.js b/packages/editor/dist/cjs/toolbar/tooldefinitions.js
index c6458168a..490c86ec4 100644
--- a/packages/editor/dist/cjs/toolbar/tooldefinitions.js
+++ b/packages/editor/dist/cjs/toolbar/tooldefinitions.js
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.DEFAULT_TOOLS = exports.getAllTools = exports.getToolDefinition = void 0;
+exports.getDefaultPresets = exports.getAllTools = exports.getToolDefinition = void 0;
const tools = {
bold: {
icon: "bold",
@@ -287,34 +287,45 @@ function getAllTools() {
return tools;
}
exports.getAllTools = getAllTools;
-exports.DEFAULT_TOOLS = [
- [
- "insertBlock",
- "tableSettings",
- "imageSettings",
- "embedSettings",
- "attachmentSettings",
- "linkSettings",
- "codeRemove",
- ],
- [
- "bold",
- "italic",
- "underline",
+function getDefaultPresets() {
+ return defaultPresets;
+}
+exports.getDefaultPresets = getDefaultPresets;
+const defaultPresets = {
+ default: [
+ [
+ "insertBlock",
+ "tableSettings",
+ "imageSettings",
+ "embedSettings",
+ "attachmentSettings",
+ "linkSettings",
+ "codeRemove",
+ ],
[
- "strikethrough",
- "code",
- "subscript",
- "superscript",
- "highlight",
- "textColor",
- "math",
+ "bold",
+ "italic",
+ "underline",
+ [
+ "strikethrough",
+ "code",
+ "subscript",
+ "superscript",
+ "highlight",
+ "textColor",
+ "math",
+ ],
],
+ ["fontSize"],
+ ["headings", "fontFamily"],
+ ["numberedList", "bulletList"],
+ ["addLink"],
+ ["alignment", "textDirection"],
+ ["clearformatting"],
+ ],
+ minimal: [
+ ["bold", "italic", "underline", "strikethrough", "code"],
+ ["headings", "addLink"],
+ ["clearformatting"],
],
- ["fontSize"],
- ["headings", "fontFamily"],
- ["numberedList", "bulletList"],
- ["addLink"],
- ["alignment", "textDirection"],
- ["clearformatting"],
-];
+};
diff --git a/packages/editor/dist/es/toolbar/toolbar.js b/packages/editor/dist/es/toolbar/toolbar.js
index 90250891f..d5c77e9fc 100644
--- a/packages/editor/dist/es/toolbar/toolbar.js
+++ b/packages/editor/dist/es/toolbar/toolbar.js
@@ -2,13 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Flex } from "rebass";
import { ThemeProvider } from "emotion-theming";
import { EditorFloatingMenus } from "./floating-menus";
-import { DEFAULT_TOOLS } from "./tool-definitions";
+import { getDefaultPresets } from "./tool-definitions";
import { useEffect } from "react";
import { useToolbarStore, } from "./stores/toolbar-store";
import { ToolbarGroup } from "./components/toolbar-group";
import { EditorContext, PopupRenderer, } from "../components/popup-presenter/popuprenderer";
export function Toolbar(props) {
- const { editor, theme, location, tools = DEFAULT_TOOLS } = props;
+ const { editor, theme, location, tools = getDefaultPresets().default, } = props;
const setToolbarLocation = useToolbarStore((store) => store.setToolbarLocation);
useEffect(() => {
setToolbarLocation(location);
diff --git a/packages/editor/dist/es/toolbar/tooldefinitions.d.ts b/packages/editor/dist/es/toolbar/tooldefinitions.d.ts
index 576ba91b9..224e00ff4 100644
--- a/packages/editor/dist/es/toolbar/tooldefinitions.d.ts
+++ b/packages/editor/dist/es/toolbar/tooldefinitions.d.ts
@@ -2,4 +2,4 @@ import { ToolbarDefinition, ToolDefinition } from "./types";
import { ToolId } from "./tools";
export declare function getToolDefinition(id: ToolId): ToolDefinition;
export declare function getAllTools(): Record<"fontSize" | "underline" | "bold" | "bulletList" | "code" | "italic" | "subscript" | "superscript" | "textDirection" | "fontFamily" | "highlight" | "removeAttachment" | "downloadAttachment" | "deleteColumn" | "deleteRow" | "deleteTable" | "mergeCells" | "strikethrough" | "codeRemove" | "numberedList" | "textColor" | "openLink" | "linkSettings" | "imageSettings" | "rowProperties" | "insertRowBelow" | "insertRowAbove" | "moveRowDown" | "moveRowUp" | "columnProperties" | "insertColumnRight" | "insertColumnLeft" | "moveColumnRight" | "moveColumnLeft" | "cellProperties" | "cellBorderColor" | "splitCells" | "attachmentSettings" | "embedSettings" | "tableSettings" | "math" | "clearformatting" | "addLink" | "editLink" | "removeLink" | "insertBlock" | "headings" | "alignment" | "imageAlignCenter" | "imageAlignLeft" | "imageAlignRight" | "imageProperties" | "embedAlignCenter" | "embedAlignLeft" | "embedAlignRight" | "embedProperties" | "cellBackgroundColor" | "cellTextColor" | "cellBorderWidth", ToolDefinition>;
-export declare const DEFAULT_TOOLS: ToolbarDefinition;
+export declare function getDefaultPresets(): Record<"default" | "minimal", ToolbarDefinition>;
diff --git a/packages/editor/dist/es/toolbar/tooldefinitions.js b/packages/editor/dist/es/toolbar/tooldefinitions.js
index e027167ce..5e2a7bb17 100644
--- a/packages/editor/dist/es/toolbar/tooldefinitions.js
+++ b/packages/editor/dist/es/toolbar/tooldefinitions.js
@@ -282,34 +282,44 @@ export function getToolDefinition(id) {
export function getAllTools() {
return tools;
}
-export const DEFAULT_TOOLS = [
- [
- "insertBlock",
- "tableSettings",
- "imageSettings",
- "embedSettings",
- "attachmentSettings",
- "linkSettings",
- "codeRemove",
- ],
- [
- "bold",
- "italic",
- "underline",
+export function getDefaultPresets() {
+ return defaultPresets;
+}
+const defaultPresets = {
+ default: [
+ [
+ "insertBlock",
+ "tableSettings",
+ "imageSettings",
+ "embedSettings",
+ "attachmentSettings",
+ "linkSettings",
+ "codeRemove",
+ ],
[
- "strikethrough",
- "code",
- "subscript",
- "superscript",
- "highlight",
- "textColor",
- "math",
+ "bold",
+ "italic",
+ "underline",
+ [
+ "strikethrough",
+ "code",
+ "subscript",
+ "superscript",
+ "highlight",
+ "textColor",
+ "math",
+ ],
],
+ ["fontSize"],
+ ["headings", "fontFamily"],
+ ["numberedList", "bulletList"],
+ ["addLink"],
+ ["alignment", "textDirection"],
+ ["clearformatting"],
+ ],
+ minimal: [
+ ["bold", "italic", "underline", "strikethrough", "code"],
+ ["headings", "addLink"],
+ ["clearformatting"],
],
- ["fontSize"],
- ["headings", "fontFamily"],
- ["numberedList", "bulletList"],
- ["addLink"],
- ["alignment", "textDirection"],
- ["clearformatting"],
-];
+};
diff --git a/packages/editor/src/toolbar/tool-definitions.ts b/packages/editor/src/toolbar/tool-definitions.ts
index 8980549f7..dface5983 100644
--- a/packages/editor/src/toolbar/tool-definitions.ts
+++ b/packages/editor/src/toolbar/tool-definitions.ts
@@ -290,34 +290,45 @@ export function getAllTools() {
return tools;
}
-export const DEFAULT_TOOLS: ToolbarDefinition = [
- [
- "insertBlock",
- "tableSettings",
- "imageSettings",
- "embedSettings",
- "attachmentSettings",
- "linkSettings",
- "codeRemove",
- ],
- [
- "bold",
- "italic",
- "underline",
+export function getDefaultPresets() {
+ return defaultPresets;
+}
+
+const defaultPresets: Record<"default" | "minimal", ToolbarDefinition> = {
+ default: [
[
- "strikethrough",
- "code",
- "subscript",
- "superscript",
- "highlight",
- "textColor",
- "math",
+ "insertBlock",
+ "tableSettings",
+ "imageSettings",
+ "embedSettings",
+ "attachmentSettings",
+ "linkSettings",
+ "codeRemove",
],
+ [
+ "bold",
+ "italic",
+ "underline",
+ [
+ "strikethrough",
+ "code",
+ "subscript",
+ "superscript",
+ "highlight",
+ "textColor",
+ "math",
+ ],
+ ],
+ ["fontSize"],
+ ["headings", "fontFamily"],
+ ["numberedList", "bulletList"],
+ ["addLink"],
+ ["alignment", "textDirection"],
+ ["clearformatting"],
+ ],
+ minimal: [
+ ["bold", "italic", "underline", "strikethrough", "code"],
+ ["headings", "addLink"],
+ ["clearformatting"],
],
- ["fontSize"],
- ["headings", "fontFamily"],
- ["numberedList", "bulletList"],
- ["addLink"],
- ["alignment", "textDirection"],
- ["clearformatting"],
-];
+};
diff --git a/packages/editor/src/toolbar/toolbar.tsx b/packages/editor/src/toolbar/toolbar.tsx
index a8ceb4b50..50653f5a3 100644
--- a/packages/editor/src/toolbar/toolbar.tsx
+++ b/packages/editor/src/toolbar/toolbar.tsx
@@ -5,7 +5,7 @@ import { Flex, FlexProps } from "rebass";
import { findTool, ToolId } from "./tools";
import { ThemeProvider } from "emotion-theming";
import { EditorFloatingMenus } from "./floating-menus";
-import { DEFAULT_TOOLS, getToolDefinition } from "./tool-definitions";
+import { getDefaultPresets, getToolDefinition } from "./tool-definitions";
import { Dropdown } from "./components/dropdown";
import { ToolButton } from "./components/tool-button";
import { useContext, useEffect, useRef, useState } from "react";
@@ -32,7 +32,12 @@ type ToolbarProps = {
};
export function Toolbar(props: ToolbarProps) {
- const { editor, theme, location, tools = DEFAULT_TOOLS } = props;
+ const {
+ editor,
+ theme,
+ location,
+ tools = getDefaultPresets().default,
+ } = props;
const setToolbarLocation = useToolbarStore(
(store) => store.setToolbarLocation
);