Skip to content

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

editor: add support for toggling highlight/background color (#4330)

Muhammad Ali7e7a1aeecb6d
diff --git a/packages/editor/src/toolbar/tools/colors.tsx b/packages/editor/src/toolbar/tools/colors.tsx
index ef8e9b9a7..055f9a2ad 100644
--- a/packages/editor/src/toolbar/tools/colors.tsx
+++ b/packages/editor/src/toolbar/tools/colors.tsx
@@ -105,8 +105,14 @@ export function ColorTool(props: ColorToolProps) {
}}
cacheKey={`custom_${cacheKey}`}
onChange={(color) => {
- onColorChange(color);
- config.set(cacheKey, color);
+ const currentColor = config.get(cacheKey);
+ if (currentColor && currentColor === color) {
+ onColorChange();
+ config.set(cacheKey, null);
+ } else {
+ onColorChange(color);
+ config.set(cacheKey, color);
+ }
}}
onClose={() => setIsOpen(false)}
title={title}