🐛 Fix null text crash on paste in text editor

The splitTextIntoTextBlocks function in @penpot/draft-js called
.split() on the text parameter without a null check. When pasting
content without text data (e.g., images only), Draft.js passes null
to handlePastedText, causing a TypeError.

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Andrey Antukh
2026-03-23 12:05:50 +00:00
parent 8729fed724
commit d863c7065f

View File

@@ -366,6 +366,9 @@ export function getInlineStyle(state, blockKey, offset) {
const NEWLINE_REGEX = /\r\n?|\n/g;
function splitTextIntoTextBlocks(text) {
if (text == null) {
return [];
}
return text.split(NEWLINE_REGEX);
}