Skip to content

Commit

Permalink
Fix: Prevent line breaks when disableLineBreaks is true
Browse files Browse the repository at this point in the history
  • Loading branch information
Infinite-Null committed Nov 29, 2024
1 parent 9a9af21 commit 9aabe20
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default ( props ) => ( element ) => {
__unstableEmbedURLOnPaste,
preserveWhiteSpace,
pastePlainText,
disableLineBreaks,
} = props.current;

// The event listener is attached to the window, so we need to check if
Expand All @@ -37,10 +38,15 @@ export default ( props ) => ( element ) => {
return;
}

const { plainText, html } = getPasteEventData( event );
let { plainText, html } = getPasteEventData( event );

event.preventDefault();

// When line breaks are disabled, convert all line breaks to a single space.
plainText = disableLineBreaks
? plainText.replace( /\r?\n/g, ' ' ).trim()
: plainText;

// Allows us to ask for this information when we get a report.
window.console.log( 'Received HTML:\n\n', html );
window.console.log( 'Received plain text:\n\n', plainText );
Expand Down

0 comments on commit 9aabe20

Please sign in to comment.