Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial drop event, and transform for images in HTML mode #3748

Closed
wants to merge 1 commit into from

Conversation

ephox-mogran
Copy link
Contributor

Description

Exploring #3744

There are two parts of this PR.

  1. Exploring defining a transform type html that transform HTML passed via dataTransfer
  2. Supporting thehtml source transform for image blocks.

It's currently hooking into onDrop in BlockDropZone. It only does something if it detects there are no files being transferred, but that's not exactly an elegant way of deciding which drop handler to execute. They probably need to be orchestrated properly.

How Has This Been Tested?

Screenshots (jpeg or gifs if applicable):

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows has proper inline documentation.

@ephox-mogran ephox-mogran requested a review from ellatrix December 1, 2017 05:43
isMatch( html ) {
const wrapper = document.createElement( 'div' );
wrapper.innerHTML = html;
return wrapper.childNodes.length === 1 && wrapper.childNodes[ 0 ].nodeName.toLowerCase() === 'img';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fragile. How exact would the HTML match need to be to create an image?

return (
<DropZone
onFilesDrop={ dropFiles }
onDrop={ drop }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if these are going to be separate, then there needs to be some better logic to communicate which one should fire. Here I'm essentially checking if numFiles is zero, but that requires some idea of the implementation of onFilesDrop. I think there would be a better way.

@ellatrix
Copy link
Member

Superseded by #4577. Thanks for the work on this @ephox-mogran!

@ellatrix ellatrix closed this Jan 19, 2018
@ellatrix ellatrix deleted the try/html-drag-and-drop branch January 19, 2018 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants