| 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/mark'; |
| 11 |
|
| 12 |
export const settings = { |
| 13 |
title: __('Highlight', 'ghostkit'), |
| 14 |
tagName: 'mark', |
| 15 |
className: 'ghostkit-highlight', |
| 16 |
edit: function HighlightFormat(props) { |
| 17 |
const { value, onChange, isActive } = props; |
| 18 |
|
| 19 |
function toggleMark() { |
| 20 |
onChange( |
| 21 |
toggleFormat(value, { |
| 22 |
type: name, |
| 23 |
}) |
| 24 |
); |
| 25 |
} |
| 26 |
|
| 27 |
// Since this format is deprecated, we don't need to display it in UI. |
| 28 |
if (!isActive) { |
| 29 |
return null; |
| 30 |
} |
| 31 |
|
| 32 |
return ( |
| 33 |
<> |
| 34 |
<RichTextShortcut |
| 35 |
type="access" |
| 36 |
character="m" |
| 37 |
onUse={() => toggleMark()} |
| 38 |
/> |
| 39 |
<RichTextToolbarButton |
| 40 |
shortcutCharacter="m" |
| 41 |
shortcutType="access" |
| 42 |
title={__('Highlight', 'ghostkit')} |
| 43 |
icon={getIcon('icon-felt-pen')} |
| 44 |
onClick={() => toggleMark()} |
| 45 |
isActive={isActive} |
| 46 |
/> |
| 47 |
</> |
| 48 |
); |
| 49 |
}, |
| 50 |
}; |
| 51 |
|