| 1 |
import { |
| 2 |
RichTextShortcut, |
| 3 |
RichTextToolbarButton, |
| 4 |
} from '@wordpress/block-editor'; |
| 5 |
import { __ } from '@wordpress/i18n'; |
| 6 |
import { toggleFormat } from '@wordpress/rich-text'; |
| 7 |
|
| 8 |
import getIcon from '../../utils/get-icon'; |
| 9 |
|
| 10 |
export const name = 'ghostkit/uppercase'; |
| 11 |
|
| 12 |
export const settings = { |
| 13 |
title: __('Uppercase', 'ghostkit'), |
| 14 |
tagName: 'span', |
| 15 |
className: 'ghostkit-text-uppercase', |
| 16 |
edit: function BadgeFormat(props) { |
| 17 |
const { value, onChange, isActive } = props; |
| 18 |
|
| 19 |
function toggleUppercase() { |
| 20 |
onChange( |
| 21 |
toggleFormat(value, { |
| 22 |
type: name, |
| 23 |
}) |
| 24 |
); |
| 25 |
} |
| 26 |
|
| 27 |
return ( |
| 28 |
<> |
| 29 |
<RichTextShortcut |
| 30 |
type="access" |
| 31 |
character="u" |
| 32 |
onUse={() => toggleUppercase()} |
| 33 |
/> |
| 34 |
<RichTextToolbarButton |
| 35 |
shortcutCharacter="u" |
| 36 |
shortcutType="access" |
| 37 |
title={__('Uppercase', 'ghostkit')} |
| 38 |
icon={getIcon('icon-text-uppercase')} |
| 39 |
onClick={() => toggleUppercase()} |
| 40 |
isActive={isActive} |
| 41 |
/> |
| 42 |
</> |
| 43 |
); |
| 44 |
}, |
| 45 |
}; |
| 46 |
|