Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(editor3): prefer superdesk media on drop
Browse files Browse the repository at this point in the history
over using links

SDANSA-209
petrjasek committed Nov 20, 2018
1 parent 02f9124 commit 1da273f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions scripts/core/editor3/components/BaseUnstyledComponent.tsx
Original file line number Diff line number Diff line change
@@ -49,7 +49,9 @@ class BaseUnstyledComponent extends React.Component<any, any> {
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<any, any> {
});
} 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);
}
}

0 comments on commit 1da273f

Please sign in to comment.