-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.js
54 lines (50 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { toggleFormat } from '@wordpress/rich-text';
import {
RichTextToolbarButton,
RichTextShortcut,
__unstableRichTextInputEvent,
} from '@wordpress/block-editor';
import { formatBold } from '@wordpress/icons';
const name = 'core/bold';
const title = __( 'Bold' );
export const bold = {
name,
title,
tagName: 'strong',
className: null,
edit( { isActive, value, onChange, onFocus } ) {
function onToggle() {
onChange( toggleFormat( value, { type: name } ) );
}
function onClick() {
onToggle();
onFocus();
}
return (
<>
<RichTextShortcut
type="primary"
character="b"
onUse={ onToggle }
/>
<RichTextToolbarButton
name="bold"
icon={ formatBold }
title={ title }
onClick={ onClick }
isActive={ isActive }
shortcutType="primary"
shortcutCharacter="b"
/>
<__unstableRichTextInputEvent
inputType="formatBold"
onInput={ onToggle }
/>
</>
);
},
};