Skip to content

Commit

Permalink
RichText API: Limit prefix transformations to Paragraph
Browse files Browse the repository at this point in the history
… and any consumer of RichText that provides experimental prop
`__unstableAllowPrefixTransformations.`
  • Loading branch information
mcsf committed Jan 27, 2020
1 parent 31ce117 commit 1537c31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function ParagraphBlock( {
aria-label={ content ? __( 'Paragraph block' ) : __( 'Empty block; start writing or type forward slash to choose a block' ) }
placeholder={ placeholder || __( 'Start writing or type / to choose a block' ) }
__unstableEmbedURLOnPaste
__unstableAllowPrefixTransformations
/>
</TextColor>
</BackgroundColor>
Expand Down
5 changes: 5 additions & 0 deletions packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ class RichText extends Component {
const {
__unstableInputRule: inputRule,
__unstableMarkAutomaticChange: markAutomaticChange,
__unstableAllowPrefixTransformations: allowPrefixTransformations,
formatTypes,
setTimeout,
clearTimeout,
Expand All @@ -455,6 +456,10 @@ class RichText extends Component {
clearTimeout( this.onInput.timeout );
this.onInput.timeout = setTimeout( this.onCreateUndoLevel, 1000 );

if ( ! allowPrefixTransformations ) {
return;
}

// Only run input rules when inserting text.
if ( inputType !== 'insertText' ) {
return;
Expand Down

0 comments on commit 1537c31

Please sign in to comment.