diff --git a/frontend/packages/draft-js/index.js b/frontend/packages/draft-js/index.js index ed8e93932f..84b7190537 100644 --- a/frontend/packages/draft-js/index.js +++ b/frontend/packages/draft-js/index.js @@ -375,6 +375,10 @@ function splitTextIntoTextBlocks(text) { export function insertText(state, text, attrs, inlineStyles) { const blocks = splitTextIntoTextBlocks(text); + if (blocks.length === 0) { + return state; + } + const character = CharacterMetadata.create({style: OrderedSet(inlineStyles)}); let blockArray = DraftPasteProcessor.processText( diff --git a/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs b/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs index 135df9ecb3..616cd17b98 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs @@ -221,12 +221,13 @@ handle-pasted-text (fn [text _ _] - (let [current-block-styles (ted/get-editor-current-block-data state) - inline-styles (ted/get-editor-current-inline-styles state) - style (merge current-block-styles inline-styles) - state (-> (ted/insert-text state text style) - (handle-change))] - (st/emit! (dwt/update-editor-state shape state))) + (when (seq text) + (let [current-block-styles (ted/get-editor-current-block-data state) + inline-styles (ted/get-editor-current-inline-styles state) + style (merge current-block-styles inline-styles) + state (-> (ted/insert-text state text style) + (handle-change))] + (st/emit! (dwt/update-editor-state shape state)))) "handled")] (mf/use-layout-effect on-mount)