[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>
Этот коммит содержится в:
@@ -140,6 +140,7 @@ describe('Upload Files - Settings', () => {
|
|||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
types: [],
|
types: [],
|
||||||
|
getData: () => {},
|
||||||
}});
|
}});
|
||||||
|
|
||||||
// * An error should be visible saying 'File attachments are disabled'
|
// * An error should be visible saying 'File attachments are disabled'
|
||||||
@@ -165,6 +166,7 @@ describe('Upload Files - Settings', () => {
|
|||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
types: [],
|
types: [],
|
||||||
|
getData: () => {},
|
||||||
}});
|
}});
|
||||||
|
|
||||||
// * An error should be visible saying 'File attachments are disabled'
|
// * An error should be visible saying 'File attachments are disabled'
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ describe('Paste Image', () => {
|
|||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
types: [],
|
types: [],
|
||||||
|
getData: () => {},
|
||||||
}});
|
}});
|
||||||
|
|
||||||
cy.uiWaitForFileUploadPreview();
|
cy.uiWaitForFileUploadPreview();
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ describe('components/FileUpload', () => {
|
|||||||
event.preventDefault = jest.fn();
|
event.preventDefault = jest.fn();
|
||||||
const getAsFile = jest.fn().mockReturnValue(new File(['test'], 'test.png'));
|
const getAsFile = jest.fn().mockReturnValue(new File(['test'], 'test.png'));
|
||||||
const file = {getAsFile, kind: 'file', name: '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(
|
const wrapper = shallowWithIntl(
|
||||||
<FileUpload
|
<FileUpload
|
||||||
@@ -229,7 +229,7 @@ describe('components/FileUpload', () => {
|
|||||||
const event = new Event('paste');
|
const event = new Event('paste');
|
||||||
event.preventDefault = jest.fn();
|
event.preventDefault = jest.fn();
|
||||||
const getAsString = 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(
|
const wrapper = shallowWithIntl(
|
||||||
<FileUpload
|
<FileUpload
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
isIosChrome,
|
isIosChrome,
|
||||||
isMobileApp,
|
isMobileApp,
|
||||||
} from 'utils/user_agent';
|
} from 'utils/user_agent';
|
||||||
import {getHtmlTable} from 'utils/paste';
|
|
||||||
import {
|
import {
|
||||||
clearFileInput,
|
clearFileInput,
|
||||||
generateId,
|
generateId,
|
||||||
@@ -451,7 +450,7 @@ export class FileUpload extends PureComponent<Props, State> {
|
|||||||
pasteUpload = (e: ClipboardEvent) => {
|
pasteUpload = (e: ClipboardEvent) => {
|
||||||
const {formatMessage} = this.props.intl;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user