Skip to content

Commit

Permalink
Pass correct content argument to enter transforms (#54108)
Browse files Browse the repository at this point in the history
* Pass correct content argument to enter transforms

* Revert the change to public API
  • Loading branch information
jsnajdr authored Sep 1, 2023
1 parent 87adc88 commit 2c0aebd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/block-api/block-transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ A transformation of type `enter` is an object that takes the following parameter

- **type** _(string)_: the value `enter`.
- **regExp** _(RegExp)_: the Regular Expression to use as a matcher. If the value matches, the transformation will be applied.
- **transform** _(function)_: a callback that receives the value that has been entered. It should return a block object or an array of block objects.
- **transform** _(function)_: a callback that receives an object with a `content` field containing the value that has been entered. It should return a block object or an array of block objects.
- **priority** _(number, optional)_: controls the priority with which a transform is applied, where a lower value will take precedence over higher values. This behaves much like a [WordPress hook](https://codex.wordpress.org/Plugin_API#Hook_to_WordPress). Like hooks, the default priority is `10` when not otherwise set.

**Example: from --- to Separator block**
Expand Down
7 changes: 1 addition & 6 deletions packages/block-library/src/heading/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@ const transforms = {
...[ 1, 2, 3, 4, 5, 6 ].map( ( level ) => ( {
type: 'enter',
regExp: new RegExp( `^/(h|H)${ level }$` ),
transform( content ) {
return createBlock( 'core/heading', {
level,
content,
} );
},
transform: () => createBlock( 'core/heading', { level } ),
} ) ),
],
to: [
Expand Down

0 comments on commit 2c0aebd

Please sign in to comment.