From 1da273f4a7a082c6da3cc3f8e084115dfc862ebc Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Tue, 20 Nov 2018 14:06:58 +0100 Subject: [PATCH] fix(editor3): prefer superdesk media on drop over using links SDANSA-209 --- .../editor3/components/BaseUnstyledComponent.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/core/editor3/components/BaseUnstyledComponent.tsx b/scripts/core/editor3/components/BaseUnstyledComponent.tsx index 57a092193a..0b9b0c6be6 100644 --- a/scripts/core/editor3/components/BaseUnstyledComponent.tsx +++ b/scripts/core/editor3/components/BaseUnstyledComponent.tsx @@ -49,7 +49,9 @@ class BaseUnstyledComponent extends React.Component { const blockKey = this.getDropBlockKey(); const link = event.originalEvent.dataTransfer.getData('URL'); - if ( + if (canDropMedia(event, this.props.editorProps) && mediaType.includes('application/superdesk')) { + this.props.dispatch(dragDrop(dataTransfer, mediaType, blockKey)); + } else if ( typeof link === 'string' && link.startsWith('http') && this.props.editorProps.editorFormat.includes('embed') @@ -60,12 +62,8 @@ class BaseUnstyledComponent extends React.Component { }); } else if (mediaType === 'text/html' && this.props.editorProps.editorFormat.includes('embed')) { this.props.dispatch(embed(event.originalEvent.dataTransfer.getData(mediaType), blockKey)); - } else if (canDropMedia(event, this.props.editorProps)) { // Dropping new media - const {dataTransfer} = event.originalEvent; - const mediaType = getValidMediaType(event.originalEvent); - const blockKey = this.getDropBlockKey(); - - this.props.dispatch(dragDrop(dataTransfer, mediaType, blockKey)); + } else { + console.warn('unsupported media type on drop', mediaType); } }