Skip to content

Commit

Permalink
Allow adding a header by typing /h1, /h2 etc (#26597)
Browse files Browse the repository at this point in the history
* Allow adding a header by typing /hX where X is int(1-6)

* Accept both lowercase and uppercase
  • Loading branch information
aristath authored Nov 3, 2020
1 parent 1fbe105 commit 125c2ed
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/block-library/src/heading/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ const transforms = {
} );
},
} ) ),
...[ 1, 2, 3, 4, 5, 6 ].map( ( level ) => ( {
type: 'enter',
regExp: new RegExp( `^/(h|H)${ level }$` ),
transform( content ) {
return createBlock( name, {
level,
content,
} );
},
} ) ),
],
to: [
{
Expand Down

0 comments on commit 125c2ed

Please sign in to comment.