From 3c7187b85713aabf1d3fa1b46227ca0792aeadc6 Mon Sep 17 00:00:00 2001 From: Petyo Ivanov Date: Sat, 22 Jun 2024 07:23:35 +0300 Subject: [PATCH] feat: BoldItalicUnderlineToggles component options resolves #495 Squashed commit of the following: commit 4cac17b0d31fe88731cc6f5275c83e049bec9fef Author: Petyo Ivanov Date: Sat Jun 22 07:21:14 2024 +0300 chore: eslint commit 54bee8223588ac082a2cf58c3a4d342e13745a07 Author: Dharanish V <30527938+dharanish-v@users.noreply.github.com> Date: Fri Jun 14 22:38:47 2024 +0530 fix: add aria-label to CreateLink button (#492) * feat: Add aria-label to CreateLink button * feat: Update CreateLink button aria-label for localization * feat: Update CreateLink button aria-label for localization commit e427be8c39ad8d8ba65274ced95e659b36d6c706 Author: Adriano Scazzola Date: Thu Jun 13 14:28:55 2024 -0300 Add property to display / hidde buttons on BoldItalicUnderlineToggles plugin --- .../components/BoldItalicUnderlineToggles.tsx | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/plugins/toolbar/components/BoldItalicUnderlineToggles.tsx b/src/plugins/toolbar/components/BoldItalicUnderlineToggles.tsx index d30e5b2a..5e960bf4 100644 --- a/src/plugins/toolbar/components/BoldItalicUnderlineToggles.tsx +++ b/src/plugins/toolbar/components/BoldItalicUnderlineToggles.tsx @@ -33,36 +33,49 @@ const FormatButton: React.FC = ({ format, addTitle, removeTit ) } +export interface BoldItalicUnderlineTogglesProps { + options?: ('Bold' | 'Italic' | 'Underline')[] +} + /** * A toolbar component that lets the user toggle bold, italic and underline formatting. * @group Toolbar Components */ -export const BoldItalicUnderlineToggles: React.FC = () => { +export const BoldItalicUnderlineToggles: React.FC = ({ options }: BoldItalicUnderlineTogglesProps) => { const t = useTranslation() return (
- - - + {!options || + (options.includes('Bold') && ( + + ))} + {!options || + (options.includes('Italic') && ( + + ))} + {!options || + (options.includes('Underline') && ( + + ))}
) }