Skip to content

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

editor: add more neutral default colors for highlight

Abdullah Attab1a360e445b9
diff --git a/packages/editor/src/toolbar/popups/color-picker.tsx b/packages/editor/src/toolbar/popups/color-picker.tsx
index 16109c7d7..9f31a0310 100644
--- a/packages/editor/src/toolbar/popups/color-picker.tsx
+++ b/packages/editor/src/toolbar/popups/color-picker.tsx
@@ -30,26 +30,10 @@ import { Popup } from "../components/popup";
import { SchemeColors } from "@notesnook/theme";
import { Editor } from "../../types";
-export const DEFAULT_COLORS = [
- "#e91e63",
- "#9c27b0",
- "#673ab7",
- "#3f51b5",
- "#2196f3",
- "#03a9f4",
- "#00bcd4",
- "#009688",
- "#4caf50",
- "#8bc34a",
- "#cddc39",
- "#ffeb3b",
- "#ffc107",
- "#f44336"
-];
-
type ColorPickerProps = {
editor: Editor;
colors?: string[];
+ defaultColors?: string[];
color?: string;
onClear: () => void;
expanded?: boolean;
@@ -71,6 +55,7 @@ export function ColorPicker(props: ColorPickerProps) {
expanded,
onSave,
colors = [],
+ defaultColors = [],
onDelete,
editor
} = props;
@@ -82,7 +67,7 @@ export function ColorPicker(props: ColorPickerProps) {
);
const [deleteMode, setDeleteMode] = useState(false);
const tColor = tinycolor(currentColor);
- const allColors = deleteMode ? colors : [...DEFAULT_COLORS, ...colors];
+ const allColors = deleteMode ? colors : [...defaultColors, ...colors];
useEffect(() => {
if (!ref.current) return;
diff --git a/packages/editor/src/toolbar/tools/colors.tsx b/packages/editor/src/toolbar/tools/colors.tsx
index 92bfb65a4..cf4f8971a 100644
--- a/packages/editor/src/toolbar/tools/colors.tsx
+++ b/packages/editor/src/toolbar/tools/colors.tsx
@@ -22,7 +22,7 @@ import tinycolor from "tinycolor2";
import { PopupWrapper } from "../../components/popup-presenter";
import { config } from "../../utils/config";
import { SplitButton } from "../components/split-button";
-import { ColorPicker, DEFAULT_COLORS } from "../popups/color-picker";
+import { ColorPicker } from "../popups/color-picker";
import { useToolbarLocation } from "../stores/toolbar-store";
import { ToolProps } from "../types";
import { getToolbarElement } from "../utils/dom";
@@ -33,6 +33,7 @@ type ColorToolProps = ToolProps & {
activeColor: string;
title: string;
cacheKey: string;
+ defaultColors: string[];
};
export function ColorTool(props: ColorToolProps) {
@@ -41,6 +42,7 @@ export function ColorTool(props: ColorToolProps) {
activeColor: _activeColor,
title,
cacheKey,
+ defaultColors,
...toolProps
} = props;
const activeColor = _activeColor || config.get(cacheKey);
@@ -91,8 +93,9 @@ export function ColorTool(props: ColorToolProps) {
color={activeColor}
editor={props.editor}
colors={colors}
+ defaultColors={defaultColors}
onDelete={(color) => {
- if (DEFAULT_COLORS.includes(color)) return;
+ if (defaultColors.includes(color)) return;
setColors((colors) => colors.filter((item) => item !== color));
}}
onClear={() => {
@@ -133,6 +136,22 @@ export function Highlight(props: ToolProps) {
cacheKey="highlight"
activeColor={editor.getAttributes("textStyle").backgroundColor}
title={"Background color"}
+ defaultColors={[
+ "#b0bec5", // Neutralized pink
+ "#a1887f", // Neutralized purple
+ "#9575cd", // Neutralized deep purple
+ "#7986cb", // Neutralized indigo
+ "#64b5f6", // Neutralized blue
+ "#4fc3f7", // Neutralized light blue
+ "#4dd0e1", // Neutralized cyan
+ "#4db6ac", // Neutralized teal
+ "#81c784", // Neutralized green
+ "#aed581", // Neutralized light green
+ "#dce775", // Neutralized lime
+ "#fff176", // Neutralized yellow
+ "#ffd54f", // Neutralized amber
+ "#e57373" // Neutralized red
+ ]}
onColorChange={(color) =>
color
? editor.chain().setHighlight(color).run()
@@ -150,6 +169,21 @@ export function TextColor(props: ToolProps) {
cacheKey={"textColor"}
activeColor={editor.getAttributes("textStyle").color}
title="Text color"
+ defaultColors={[
+ "#e91e63",
+ "#9c27b0",
+ "#673ab7",
+ "#3f51b5",
+ "#2196f3",
+ "#03a9f4",
+ "#00bcd4",
+ "#009688",
+ "#4caf50",
+ "#8bc34a",
+ "#cddc39",
+ "#ffc107",
+ "#f44336"
+ ]}
onColorChange={(color) =>
color
? editor.chain().setColor(color).run()