Skip to content

Commit

Permalink
Merge branch 'strikeThroughSupSubTogglesOptionProps'
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi committed Jul 2, 2024
2 parents 40a6be9 + a3b0a16 commit 29feb8d
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions src/plugins/toolbar/components/BoldItalicUnderlineToggles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface BoldItalicUnderlineTogglesProps {
* A toolbar component that lets the user toggle bold, italic and underline formatting.
* @group Toolbar Components
*/
export const BoldItalicUnderlineToggles: React.FC = ({ options }: BoldItalicUnderlineTogglesProps) => {
export const BoldItalicUnderlineToggles: React.FC<BoldItalicUnderlineTogglesProps> = ({ options }) => {
const t = useTranslation()

const showAllButtons = typeof options === 'undefined'
Expand Down Expand Up @@ -78,35 +78,47 @@ export const BoldItalicUnderlineToggles: React.FC = ({ options }: BoldItalicUnde
)
}

export interface StrikeThroughSupSubTogglesProps {
options?: ('Strikethrough' | 'Sub' | 'Sup')[]
}

/**
* A toolbar component that lets the user toggle strikeThrough, superscript and subscript formatting.
* @group Toolbar Components
*/
export const StrikeThroughSupSubToggles: React.FC = () => {
export const StrikeThroughSupSubToggles: React.FC<StrikeThroughSupSubTogglesProps> = ({ options }) => {
const t = useTranslation()
const showAllButtons = typeof options === 'undefined'

return (
<div className={styles.toolbarGroupOfGroups}>
<FormatButton
format={IS_STRIKETHROUGH}
addTitle={t('toolbar.strikethrough', 'Strikethrough')}
removeTitle={t('toolbar.removeStrikethrough', 'Remove strikethrough')}
icon="strikeThrough"
formatName="strikethrough"
/>
<FormatButton
format={IS_SUPERSCRIPT}
addTitle={t('toolbar.superscript', 'Superscript')}
removeTitle={t('toolbar.removeSuperscript', 'Remove superscript')}
icon="superscript"
formatName="superscript"
/>
<FormatButton
format={IS_SUBSCRIPT}
addTitle={t('toolbar.subscript', 'Subscript')}
removeTitle={t('toolbar.removeSubscript', 'Remove subscript')}
icon="subscript"
formatName="subscript"
/>
{showAllButtons || options.includes('Strikethrough') ? (
<FormatButton
format={IS_STRIKETHROUGH}
addTitle={t('toolbar.strikethrough', 'Strikethrough')}
removeTitle={t('toolbar.removeStrikethrough', 'Remove strikethrough')}
icon="strikeThrough"
formatName="strikethrough"
/>
) : null}
{showAllButtons || options.includes('Sup') ? (
<FormatButton
format={IS_SUPERSCRIPT}
addTitle={t('toolbar.superscript', 'Superscript')}
removeTitle={t('toolbar.removeSuperscript', 'Remove superscript')}
icon="superscript"
formatName="superscript"
/>
) : null}
{showAllButtons || options.includes('Sub') ? (
<FormatButton
format={IS_SUBSCRIPT}
addTitle={t('toolbar.subscript', 'Subscript')}
removeTitle={t('toolbar.removeSubscript', 'Remove subscript')}
icon="subscript"
formatName="subscript"
/>
) : null}
</div>
)
}

0 comments on commit 29feb8d

Please sign in to comment.