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

The image uploading listener for handling base64/blob images no longer stops inputTransformation event #264

Merged
merged 12 commits into from
Jan 22, 2019

Conversation

f1ames
Copy link
Contributor

@f1ames f1ames commented Dec 17, 2018

Suggested merge commit message (convention)

Other: The image uploading listener for handling base64/blob images no longer stops inputTransformation event. Closes ckeditor/ckeditor5#5177. Closes ckeditor/ckeditor5#2530.


Additional information

This PR aligns the way base64/blob images uploading works to https://github.com/ckeditor/ckeditor5-upload/issues/87 issue in which the FileLoader accepts Promise instead of File instance.

It's nice to see how much inputTransformation listener got simplified. However, tests got a little more complex.

This PR is based on #258 PR and will not work without ckeditor/ckeditor5-upload#88 so should be closed after closing this mentioned PRs. The CI will be red unless ckeditor/ckeditor5-upload#88 is merged.

@coveralls
Copy link

coveralls commented Dec 17, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling f5a52f3 on t/258 into 699d586 on master.

@jodator jodator self-requested a review January 4, 2019 11:26
@jodator
Copy link
Contributor

jodator commented Jan 11, 2019

@f1ames I've forgot about this one after checking the images upload. It is still valid right?
If so could you check conflicts with master? I'll review it first thing next business day :) ☕

@f1ames
Copy link
Contributor Author

f1ames commented Jan 14, 2019

Still failing on Edge, due to some reason 🤔 I will look into it.

Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

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

Cosmetics to change really.


if ( !fetchableImages.length ) {
return;
}

evt.stop();
const writer = new UpcastWriter();
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I'm worried about that construct. I think that we could expose those methods on the view if they're need. Tahen we could write it as:

const view = editor.editing.view; // ps.: also used for crateRangeIn()

/// the code as now

view.setAttribute( 'src', '', fetchableImage.imageElement );

This unfortunately will require small changes in the engine.

Edit: I've just found this construct in the Clipboard docs. I'll report an issue there. So do not change this ATM.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll leave it as is for now. Btw. one may use change block here:

editor.editing.view.change( writer => {
    // code...
} );

to obtain the writer. However, it uses DowncastWriter not UpcastWriter (still their setAttribute() methods uses exactly same API).

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking abut it and while it looks safe we probably ought to fix it globally as in referenced ticket.

src/imageupload/utils.js Outdated Show resolved Hide resolved
src/imageupload/utils.js Outdated Show resolved Hide resolved
@jodator
Copy link
Contributor

jodator commented Jan 14, 2019

As the code is ready: @Mgsy could you check this one?

Co-Authored-By: f1ames <dr.odpowiedz@gmail.com>
@Mgsy Mgsy self-requested a review January 15, 2019 15:09
@f1ames f1ames requested a review from jodator January 15, 2019 15:22
@Mgsy
Copy link
Member

Mgsy commented Jan 16, 2019

I'm not able to paste an image from Word to the editor in Edge (other browsers work fine and the sample has PFO plugin activated). Tested on VM.

bug_cke5

@f1ames
Copy link
Contributor Author

f1ames commented Jan 16, 2019

I'm not able to paste an image from Word to the editor in Edge (other browsers work fine and the sample has PFO plugin activated). Tested on VM.

That's probably caused by the lack of support for File constructor in Edge. However, in this case the image should be pasted (as blob) and no error should be shown (I guess it is not handled correctly ATM).

@jodator
Copy link
Contributor

jodator commented Jan 16, 2019

That's probably caused by the lack of support for File constructor in Edge. However, in this case the image should be pasted (as blob) and no error should be shown (I guess it is not handled correctly ATM).

So should this be fixed here or in PFO plugin?

@f1ames
Copy link
Contributor Author

f1ames commented Jan 16, 2019

☝️ Sorry, didn't make it clear in the previous comment. It should be fixed in this PR from what I can see and I'm working on the fix ATM.

@f1ames
Copy link
Contributor Author

f1ames commented Jan 16, 2019

However, in this case the image should be pasted (as blob) and no error should be shown (I guess it is not handled correctly ATM).

Mixed up a little bit, we cannot use blob here due to collaboration features (it may break it). So the image simply will not be pasted. However, undefined alert is unnecessary. I think we should skip any messages here.

@f1ames
Copy link
Contributor Author

f1ames commented Jan 16, 2019

Funny that there is no error in Edge in the case @Mgsy found. In Chrome (when file promise is rejected) there is - so I have added a fix there too - ckeditor/ckeditor5-upload#90. Please review and merge it together with this PR.

@Mgsy
Copy link
Member

Mgsy commented Jan 16, 2019

I have added a fix there too - ckeditor/ckeditor5-upload#90. Please review and merge it together with this PR.

After switching to this branch, indeed, the image isn't pasted in Edge, but unfortunately, the undefined alert is still displayed.

@f1ames
Copy link
Contributor Author

f1ames commented Jan 16, 2019

@Mgsy I have pushed a fix. In Edge image should not be pasted, no errors in the console and no alert displayed.

After switching to this branch, indeed, the image isn't pasted in Edge, but unfortunately, the undefined alert is still displayed.

Sorry, it was part of the fix, the second part was pushed in the latest commit (f5a52f3).

Copy link
Member

@Mgsy Mgsy left a comment

Choose a reason for hiding this comment

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

👌

@jodator jodator merged commit 8c5b4fc into master Jan 22, 2019
@jodator jodator deleted the t/258 branch January 22, 2019 14:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants