Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichText API: Limit "prefix" transformations to Paragraph blocks #19727

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -445,6 +445,7 @@ class RichText extends Component {
const {
__unstableInputRule: inputRule,
__unstableMarkAutomaticChange: markAutomaticChange,
__unstableAllowPrefixTransformations: allowPrefixTransformations,
formatTypes,
setTimeout,
clearTimeout,
Expand All @@ -454,6 +455,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