-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathregister.js
More file actions
37 lines (37 loc) · 875 Bytes
/
register.js
File metadata and controls
37 lines (37 loc) · 875 Bytes
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
window.wp.blocks.registerBlock( {
name: 'list',
displayName: 'List',
elements: [ 'ul', 'ol' ],
type: 'text',
icon: 'gridicons-list-unordered',
controls: [
{
icon: 'gridicons-list-unordered',
stateSelector: 'ul',
onClick: function( editor ) {
editor.execCommand( 'InsertUnorderedList' );
}
},
{
icon: 'gridicons-list-ordered',
stateSelector: 'ol',
onClick: function( editor ) {
editor.execCommand( 'InsertOrderedList' );
}
},
{
classes: 'remove-formatting',
icon: 'gridicons-list-unordered',
onClick: function( block, editor ) {
if ( block.nodeName === 'UL' ) {
editor.execCommand( 'InsertUnorderedList' );
} else if ( block.nodeName === 'OL' ) {
editor.execCommand( 'InsertOrderedList' );
}
}
}
],
insert: function( block, editor ) {
editor.execCommand( 'InsertUnorderedList' );
}
} );