diff --git a/cypress/integration/upload.spec.ts b/cypress/integration/upload.spec.ts index 40dd70b25..c5d0ccdbc 100644 --- a/cypress/integration/upload.spec.ts +++ b/cypress/integration/upload.spec.ts @@ -95,4 +95,16 @@ describe('Upload', () => { cy.get('.CodeMirror-activeline > .CodeMirror-line > span') .should('have.text', 'not empty') }) + + it('text paste still works', () => { + const testText = 'a long test text' + const pasteEvent = { + clipboardData: { + getData: (type = 'text') => testText + } + } + cy.get('.CodeMirror-scroll').trigger('paste', pasteEvent) + cy.get('.CodeMirror-activeline > .CodeMirror-line > span') + .should('have.text', `${testText}`) + }) }) diff --git a/src/components/editor/editor-pane/editor-pane.tsx b/src/components/editor/editor-pane/editor-pane.tsx index 65ccf4787..a90e74c76 100644 --- a/src/components/editor/editor-pane/editor-pane.tsx +++ b/src/components/editor/editor-pane/editor-pane.tsx @@ -70,7 +70,7 @@ interface PasteEvent { } const onPaste = (pasteEditor: Editor, event: PasteEvent) => { - if (event && event.clipboardData && event.clipboardData.files) { + if (event && event.clipboardData && event.clipboardData.files && event.clipboardData.files.length > 0) { event.preventDefault() const files: FileList = event.clipboardData.files if (files && files.length >= 1) {