-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathregister.js
More file actions
40 lines (34 loc) · 862 Bytes
/
register.js
File metadata and controls
40 lines (34 loc) · 862 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
38
39
40
( function( wp ) {
function getControls() {
var controls = [];
'123456'.split( '' ).forEach( function( level ) {
controls.push( {
icon: 'gridicons-heading',
text: level,
stateSelector: 'h' + level,
onClick: function( block, editor ) {
editor.formatter.apply( 'h' + level, block );
}
} );
} );
controls.push( {
classes: 'remove-formatting',
icon: 'gridicons-heading',
onClick: function( block, editor ) {
editor.formatter.apply( 'p', block );
}
} );
controls.push( 'text-align-left', 'text-align-center', 'text-align-right' );
return controls;
}
wp.blocks.registerBlock( {
name: 'heading',
displayName: 'Heading',
elements: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ],
type: 'text',
icon: 'gridicons-heading',
controls: getControls(),
insert: function() {
}
} );
} )( window.wp );