From d863c7065f603048925379b3ef580143911892b7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Mar 2026 12:05:50 +0000 Subject: [PATCH] :bug: 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 --- frontend/packages/draft-js/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/packages/draft-js/index.js b/frontend/packages/draft-js/index.js index 23bd20af01..ed8e93932f 100644 --- a/frontend/packages/draft-js/index.js +++ b/frontend/packages/draft-js/index.js @@ -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); }