-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve importing images from Microsoft Word #4291
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Fix
I see it still doesn't work with some of the samples added in initial issue (tested on Chrome 85 on Windows 10):
- Images not imported from word #2800 (comment) - still no images at all
- Images not imported from word #2800 (comment) - works fine 👍
- Images not imported from word #2800 (comment) - works almost fine (some images are missing, see below).
- Images not imported from word #2800 (comment) - first image doesn't show up.
Related to 3rd point above - page 20 and 21 results in broken images. I suspect this are .emz
because there were some related errors in the console, but it will be good to check what is the exact cause
Code
I would be for making this RTF parser more generic thing (moving to pastetools
maybe?) and reworking removeHeadersAndFooters()
and removeMatchedGroup()
methods (see comments in the code).
Manual Tests
It might be good to add another manual test which covers all formats, so shapes, WMF, EMF, png, jpg, gif and also some unsupported ones (bmp
or something?) to see how it works with complex content with multiple different formats. Or just add original .docx
files from issue itself (mentioned on the beginning of this review).
Others
From what I see you can paste header/footer content explicitly, but I assume it is intended as it doesn't happen during regular copy/paste?
Could you also review other related tickets mentioned in #2800 to see if it solves other issues too?
Other issues which mention Paste From MS Word and images problems: #3972, #3937, #3782, #3781, #2675, #2516, #1345, #1134
I'm wondering if we can't introduce new error that will be displayed when some image can't be inserted because it's unsupported. WDYT? |
It would be more descriptive than some random errors for sure. I wonder how many information this error may provide to guide user and by descriptive enough... Probably file extension? File names are just some random strings generated by Word and no related to original file names AFAIR? |
I've rebased onto latest |
Yes, it just works this way, I didn't change anything here.
Done 👍 |
Fixed. It seems that if image is inserted more than once, it has the same unique id. There is only one image not rendered correctly in this document, according to our newly introduced error message. Probably it is the list marker, because i don't see any other incorrectly rendered image 🤔
Yup, these two images are in EMF format, currently unsupported. Covered by our new error message.
The first image is also in EMF format. |
OK, I've updated the PR's description to sum up the major changes here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature
Haven't found any issues 👏 Also the error message is pretty descriptive and should help users to understand better what's going on 👍
- Images not imported from word #2800 (comment) - works fine, first image is WMF (error shows correctly) 👍
- Images not imported from word #2800 (comment) - works fine 👍
- Images not imported from word #2800 (comment) - works fine (apart from IE11, see below), two EMF images 👍
- Images not imported from word #2800 (comment) - works fine, error for the first images is shown 👍
As for 3. and IE11, for me there are no images. Since changes in this PR touches only browsers with Clipboard API I assume it worked the same before, but will be good to confirm that.
The code
Haven't looked at pastetools/filter/*.js
closely yet, but since the rest looks good I expect some minor polishing only.
Manual tests
Since changes touches paste tools (which are used by PfLO too - mentioned here also) maybe we could add new or tag existing PfLO manual tests so we will be sure to check it during testing phase too?
It would be good if we could add resize
plugin (or just increase editor height), because now testing is pretty painful with longer content.
Unit tests
One test fails in IE11 and IE10 (probably IE9 and IE8 too, but haven't checked):
Again regarding Libre Office, I guess handling images is mainly covered in tests/plugins/pastetools/filter/image.js
test, but maybe some dedicated PfLO test could be useful here? Unless, we have all cases already covered in existing PfLO test? 🤔
Docs
I see documentation builds fine and API docs are generated correctly. I have one doubt regarding @removed
annotation (see review comments).
Others
I think we don't need this file - https://github.com/ckeditor/ckeditor4/blob/afc87ba0463c74ec76ec5b0f4a64fc60c0c0cd43/tests/plugins/pastefromword/generated/_fixtures/ImagesExtraction/DuplicatedImage/~%24plicatedImage.docx
The images in your review comment were not linked correctly, but I've just checked all the linked docs in the issue and they seem to work correctly. In case of IE11 it works the same as on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ckeditor/qa-team could you take a look and test this PR too to check if everything works fine without any regressions? |
Ok, I've added examples to API docs and added some unit tests for RTF helpers. |
Steps:
[CKEDITOR] Error code: pastetools-unsupported-image. {type: "image/wmf", index: 0} Notes:
|
Ok, I didn't find anything new apart from this issue mentioned above. The rest seems to be ok 👍 |
Word treats images with changed wrapped options as shapes, adding additional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 👏 🎉
@FilipTokarski could you also verify on your side that everything works fine? |
@Comandeer Could you check if you can |
@FilipTokarski, it works for me. From what I see on the recording, it seems that you test it on some old version 🤔 Even if images weren't rendered correctly, there should be more specific errors (e.g. about unsupported image formats or incorrect image extraction). |
Works for me too. We have checked with @FilipTokarski if this is the issue with e.g. different software/OS versions but seems to be insignificant here. @FilipTokarski also did fresh checkout but it still doesn't work for him. I asked @FilipTokarski to use our |
I used Results:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After talking to @f1ames we concluded that this is most probably some edge case related to my environment and not caused directly by the changes in this PR. In the future we should however closely monitor any bug reports concerning pasting from Word, as I suspect sooner or later someone might stumble upon similar problem.
What is the purpose of this pull request?
Bug fix
Does your PR contain necessary tests?
All patches that change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
Did you follow the CKEditor 4 code style guide?
Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.
What is the proposed changelog entry for this pull request?
What changes did you make?
Ok, this was a really tough one:
img
tags. Fortunately they are easily filtered by using\defshp
.CKEDITOR.plugins.pastetools.filters.word.images
withCKEDITOR.plugins.pastetools.filters.image
. It's potentially breaking change – however it touches only private members of API.CKEDITOR.pasteFilters
the real alias ofCKEDITOR.plugins.pastetools.filters
.Which issues does your PR resolve?
Closes #2800.
Closes #3782.
Closes #4297.