mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 09:46:30 -05:00
fix pasting text (#871)
* fix onPast bug in editor the event was prevented, if event.clipboardData.files was defined. This always the case. Now we check if this filelist object has at least on entry to start the onPaste handler for file uploads. Signed-off-by: Philip Molares <philip.molares@udo.edu> * added e2e test that verifies that pasting text still works Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
e664881f33
commit
1b563f7f89
2 changed files with 13 additions and 1 deletions
|
@ -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}`)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue