From d399ffa9f87ea55f3ed863900b7e266b4591a428 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 21 Aug 2024 22:55:57 -0400 Subject: [PATCH] Add clear option to remove highlight in formatting menu closes #7436 --- app/editor/menus/formatting.tsx | 35 +++++++++++++++++----- app/hooks/useDictionary.ts | 1 + shared/i18n/locales/en_US/translation.json | 1 + 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/editor/menus/formatting.tsx b/app/editor/menus/formatting.tsx index fe6551d9c4..66a6e1c317 100644 --- a/app/editor/menus/formatting.tsx +++ b/app/editor/menus/formatting.tsx @@ -20,6 +20,7 @@ import { } from "outline-icons"; import { EditorState } from "prosemirror-state"; import * as React from "react"; +import styled from "styled-components"; import Highlight from "@shared/editor/marks/Highlight"; import { getMarksBetween } from "@shared/editor/queries/getMarksBetween"; import { isInCode } from "@shared/editor/queries/isInCode"; @@ -89,13 +90,26 @@ export default function formattingMenuItems( ), active: () => !!highlight, visible: !isCode && (!isMobile || !isEmpty), - children: Highlight.colors.map((color, index) => ({ - name: "highlight", - label: Highlight.colorNames[index], - icon: , - active: isMarkActive(schema.marks.highlight, { color }), - attrs: { color }, - })), + children: [ + ...(highlight + ? [ + { + name: "highlight", + label: dictionary.none, + icon: , + active: () => false, + attrs: { color: highlight.mark.attrs.color }, + }, + ] + : []), + ...Highlight.colors.map((color, index) => ({ + name: "highlight", + label: Highlight.colorNames[index], + icon: , + active: isMarkActive(schema.marks.highlight, { color }), + attrs: { color }, + })), + ], }, { name: "code_inline", @@ -224,3 +238,10 @@ export default function formattingMenuItems( }, ]; } + +const DottedCircleIcon = styled(CircleIcon)` + circle { + stroke: ${(props) => props.theme.textSecondary}; + stroke-dasharray: 2, 2; + } +`; diff --git a/app/hooks/useDictionary.ts b/app/hooks/useDictionary.ts index 8b5a5c4136..e8178b11db 100644 --- a/app/hooks/useDictionary.ts +++ b/app/hooks/useDictionary.ts @@ -92,6 +92,7 @@ export default function useDictionary() { outdent: t("Outdent"), video: t("Video"), untitled: t("Untitled"), + none: t("None"), }), [t] ); diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index bfba038f57..1730b9b50f 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -451,6 +451,7 @@ "Indent": "Indent", "Outdent": "Outdent", "Video": "Video", + "None": "None", "Could not import file": "Could not import file", "Unsubscribed from document": "Unsubscribed from document", "Account": "Account",