[MM-32576] Text copied from Microsoft OneNote pastes as an image (v2) (#23530)

* [MM-32576] Text copied from Microsoft OneNote pastes as an image

* [MM-32576] Text copied from Microsoft OneNote pastes as an image (linter and tests fix)

* [MM-32576] Text copied from Microsoft OneNote pastes as an image (E2E tests fix: mock clipboardData.getData())

---------

Co-authored-by: Andrey Karavashkin <akaravashkin@stsoft.ru>
This commit is contained in:
Andrey K 2023-08-18 14:37:58 +03:00 committed by GitHub
parent 7b0b0d8609
commit 56a0becbca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -140,6 +140,7 @@ describe('Upload Files - Settings', () => {
},
}],
types: [],
getData: () => {},
}});
// * An error should be visible saying 'File attachments are disabled'
@ -165,6 +166,7 @@ describe('Upload Files - Settings', () => {
},
}],
types: [],
getData: () => {},
}});
// * An error should be visible saying 'File attachments are disabled'

View File

@ -41,6 +41,7 @@ describe('Paste Image', () => {
},
}],
types: [],
getData: () => {},
}});
cy.uiWaitForFileUploadPreview();

View File

@ -206,7 +206,7 @@ describe('components/FileUpload', () => {
event.preventDefault = jest.fn();
const getAsFile = jest.fn().mockReturnValue(new File(['test'], 'test.png'));
const file = {getAsFile, kind: 'file', name: 'test.png'};
(event as any).clipboardData = {items: [file], types: ['image/png']};
(event as any).clipboardData = {items: [file], types: ['image/png'], getData: () => {}};
const wrapper = shallowWithIntl(
<FileUpload
@ -229,7 +229,7 @@ describe('components/FileUpload', () => {
const event = new Event('paste');
event.preventDefault = jest.fn();
const getAsString = jest.fn();
(event as any).clipboardData = {items: [{getAsString, kind: 'string', type: 'text/plain'}], types: ['text/plain']};
(event as any).clipboardData = {items: [{getAsString, kind: 'string', type: 'text/plain'}], types: ['text/plain'], getData: () => {}};
const wrapper = shallowWithIntl(
<FileUpload

View File

@ -18,7 +18,6 @@ import {
isIosChrome,
isMobileApp,
} from 'utils/user_agent';
import {getHtmlTable} from 'utils/paste';
import {
clearFileInput,
generateId,
@ -451,7 +450,7 @@ export class FileUpload extends PureComponent<Props, State> {
pasteUpload = (e: ClipboardEvent) => {
const {formatMessage} = this.props.intl;
if (!e.clipboardData || !e.clipboardData.items || getHtmlTable(e.clipboardData)) {
if (!e.clipboardData || !e.clipboardData.items || e.clipboardData.getData('text/html')) {
return;
}