Composer: Don't steal pasted content (#1044)

This commit is contained in:
Alexander Zinchuk 2021-04-22 12:09:15 +03:00
parent 4df0f08365
commit 5b8c34fc9b

View File

@ -2,6 +2,7 @@ import { StateHookSetter, useEffect } from '../../../../lib/teact/teact';
import { ApiAttachment, ApiMessage } from '../../../../api/types';
import buildAttachment from '../helpers/buildAttachment';
import { EDITABLE_INPUT_ID, EDITABLE_INPUT_MODAL_ID } from '../../../../config';
const CLIPBOARD_ACCEPTED_TYPES = ['image/png', 'image/jpeg', 'image/gif'];
const MAX_MESSAGE_LENGTH = 4096;
@ -17,6 +18,11 @@ export default (
return;
}
const input = document.activeElement;
if (input && input.tagName === 'INPUT' && ![EDITABLE_INPUT_ID, EDITABLE_INPUT_MODAL_ID].includes(input.id)) {
return;
}
const { items } = e.clipboardData;
const media = Array.from(items).find((item) => CLIPBOARD_ACCEPTED_TYPES.includes(item.type));
const file = media && media.getAsFile();