Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/29: Support for drop positions #30

Merged
merged 5 commits into from
Jul 25, 2017
Merged

T/29: Support for drop positions #30

merged 5 commits into from
Jul 25, 2017

Conversation

Reinmar
Copy link
Member

@Reinmar Reinmar commented Jul 14, 2017

Suggested merge commit message (convention)

Feature: Added dropRange to the drop event and targetRanges to the clipboardInput event. Closes ckeditor/ckeditor5#2668.


Additional information

As you may notice the full d&d support misses just two things now – using the actual drop position (and not the selection) at the end of clipboard input pipeline. Right now the selection is used... so you don't see any changes when d&ding within the editor. The second thing is deleting the dragged content from its original position. But I didn't want to make this PR any bigger now, so this will come some other day.

Also, there's Edge support which I didn't check at all after @Mgsy showed me that Edge doesn't even try supporting dropping files and displays a "no go" icon.

One more thing – I've been thinking about renaming drop's dropRange to dropPosition because it seemed to me that it will always be a position, but it's not necessarily true. E.g. we may want to support dropping on object type elements (like image widgets) in a way that it will be replacing the image and not inserting the content before/after it. This will come up once we'll start working on the magicline stuff.

@Reinmar Reinmar requested a review from pjasiun July 14, 2017 21:57

doc.fire( 'clipboardInput', {
dataTransfer: data.dataTransfer,
targetRanges
Copy link

Choose a reason for hiding this comment

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

Hm... I'm more and more not sure about it. After paste, the position should where the selection.focus is. It means that ranges might be not enough. Also, what is more important, after paste, the selection should be collapsed, after drop not. It means that maybe these events should be handled separately and the common event does not make much sense?

Copy link

Choose a reason for hiding this comment

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

Note that there is still common inputTransformation for the input transformation, so I don't think we need clipboardInput.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm... good points. I'll think on this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I looked into the code and I still think that clipboardInput is quite useful. It's where all the handling should be. Even the image upload feature uses this event. If not for it, you'd need to add 2 listeners. The same in the clipboard feature itself – it'd need two listeners.

The only thing is that we want to select the whole content after drop happened. But this is far down inside inputTransformation which was meant to be that "single pipe" anyway, so getting rid of clipboardInput won't help with that at all.

One thing which I don't like here is that inputTransformation does content insertion which is wrong. So I think that this requires a bigger refactoring anyway so it's not a part of this ticket anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pjasiun
Copy link

pjasiun commented Jul 18, 2017

I tested it manually and it works very well.

* Fired with a `dataTransfer` which comes from the clipboard (was {@link module:engine/view/document~Document#event:paste pasted}
* or {@link module:engine/view/document~Document#event:drop dropped}) and
* should be processed in order to be inserted into the editor.
* Fired as a continuation of {@link #event:paste} amd {@link #event:drop} events.
Copy link
Member Author

Choose a reason for hiding this comment

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

Typo.

@Reinmar
Copy link
Member Author

Reinmar commented Jul 24, 2017

Hm... I'm more and more not sure about it. After paste, the position should where the selection.focus is. It means that ranges might be not enough.

Not exactly – the selection should be after the pasted content. So it's the initial position modified by insertContent(). Ranges should be enough. The only thing which view ranges don't specify and view selection does is whether the selection was fake and its direction. Do you think that anything of this may matter? I think that perhaps the direction in some specific cases, but for now it does not matter in insertContent().

@Reinmar
Copy link
Member Author

Reinmar commented Jul 24, 2017

If we'll agree that we can stay with tragetRanges for now, then this is back on review.

@pjasiun pjasiun merged commit 86daed9 into master Jul 25, 2017
@pjasiun pjasiun deleted the t/29 branch July 25, 2017 12:43
@pjasiun pjasiun added this to the iteration 11 milestone Jul 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants