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

Bug fixes for PFW Image with rotation, reflection, alternative text #1158

Merged
merged 8 commits into from
Nov 20, 2017

Conversation

msamsel
Copy link
Contributor

@msamsel msamsel commented Nov 14, 2017

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

yes

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

  • improve way how v:shape are process by PFW filter.
  • remove code which was responsible for returning null in case of shape detection. Currently shapes are filtered out earlier, so this part is not required any longer (this cause one of the errors).

related to: #662

@msamsel msamsel requested a review from f1ames November 15, 2017 11:55
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Looks good, just some details.

@@ -13,6 +13,9 @@
2. [Online_and_offline_image.docx](../generated/_fixtures/Online_and_offline_image/Online_and_offline_image.docx)
3. [Shapes_and_online_and_offline_image.docx](../generated/_fixtures/Shapes_and_online_and_offline_image/Shapes_and_online_and_offline_image.docx)
4. [Wrapped_image.docx](../generated/_fixtures/Wrapped_image/Wrapped_image.docx)
5. [Image_alternative_text.docx](../generated/_fixtures/Image_alternative_text/Image_alternative_text.docx)
6. [Image_reflection.docx](../generated/_fixtures/Image_reflection/Image_reflection.docx)
7. [Image_rotation.docx](../generated/_fixtures/Image_rotation/Image_rotation.docx)
Copy link
Contributor

Choose a reason for hiding this comment

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

When pasting rotated image it is pasted in its original form (not rotated). I'm not sure if it is a proper behaviour or not (as for previous .docx images are pasted exactly as they appear in the document). If this is an intended behaviour it should be explain that rotated images are pasted, but without rotation.

@@ -13,6 +13,9 @@
2. [Online_and_offline_image.docx](../generated/_fixtures/Online_and_offline_image/Online_and_offline_image.docx)
3. [Shapes_and_online_and_offline_image.docx](../generated/_fixtures/Shapes_and_online_and_offline_image/Shapes_and_online_and_offline_image.docx)
4. [Wrapped_image.docx](../generated/_fixtures/Wrapped_image/Wrapped_image.docx)
5. [Image_alternative_text.docx](../generated/_fixtures/Image_alternative_text/Image_alternative_text.docx)
6. [Image_reflection.docx](../generated/_fixtures/Image_reflection/Image_reflection.docx)
7. [Image_rotation.docx](../generated/_fixtures/Image_rotation/Image_rotation.docx)

**Expected:** Images are pasted to the editor.<br>
Note: Keep in mind that shapes (like last object in `Shapes_and_online_and_offline_image.docx`) will not be pasted.
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest I cannot recall what was the status of handling shapes. Now I see that for shapes (e.g. in Shapes_and_online_and_offline_image.docx), img element with invalid path (pointing to some local/temporary resources) is inserted. Shouldn't it just be skipped? Same happens for canvas elements.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this PR is about images, but as a whole implementation of v:shape filter changed it influences shapes also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good point. Honestly I don't know. I remain them untouched. I'll talk with @mlewand what to do with it.

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 so img which earlier appear after pasting shapes are now removed. More details how it works is below in main line comment.

… to have no img tags belong to shapes in expected file. Little description update for manual test.
@msamsel
Copy link
Contributor Author

msamsel commented Nov 16, 2017

Ok so shapes, or more specific img tags belong to shapes, are now removed from PFW output. I change line which tag them with data-cke-is-shape="true" to remove them instead.
I also decide to remain shape related tests. Might be useful in the future if we decide to process shapes with a better way. Currently those test shows that img tags are removed from the output. So check if there is not shapes which leaks out as unhandled img tags.
Currently we also don't want to replace those img tags with notification such as "Not supported image" or anything like that.

@msamsel msamsel requested a review from f1ames November 16, 2017 16:47
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Looks good 👍 Just one manual tests needs updating after shapes handling change was introduced - /tests/plugins/pastefromword/manual/shapesaretagged, because current behaviour doesn't match the description.


I found one edge case with canvases: if you copy image together with canvas (empty or containing other shapes), the image is pasted properly and canvas removed. However, if canvas contains other image, the canvas element itself is removed, but image (the one outside canvas) is pasted without being converted to base64:

nov-17-2017 13-52-09

I would ask you to extract it to separate issue as it is not directly related with this fix.

@msamsel
Copy link
Contributor Author

msamsel commented Nov 20, 2017

Extracted issue here: #1183

@msamsel msamsel requested a review from f1ames November 20, 2017 10:26
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Looking at this now, I think we should simply remove shapesaretagged test, see my comment below.

**Expected:**
* For browsers with good `text/html` clipboard processing (Firefox, Chrome, Safari): First image tag had additional attribute `data-cke-is-shape="true"`. Second image is pasted without this attribute.
* For other browsers (Edge, IE, Mobile): There won't be `data-cke-is-shape="true"`. Browser will behave in an old way: display blank place or embed image by it's own.
**Expected:** Single image is pasted to the editor. Shape present in word document is removed during paste process.
Copy link
Contributor

Choose a reason for hiding this comment

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

You simplified it too much IMHO. It works as described in Chrome, FF, Safari. On IE11 both shape and image are pasted and on older IEs again only second image.

Additionally AFAIR or Safari and IEs < 11, the image is pasted, but it has invalid src, so basically the broken image is pasted (hard to tell if it is valid behaviour based on description).

TBH, I haven't thought about this earlier, but this test (shapesaretagged) was created to check if shapes are tagged with special attribute. Now shapes are removed so there is no purpose in keeping it and it could be simply removed, WDYT @msamsel? The case with removing shapes is already covered in other manual tests.

Sorry for the confusion, but I think it will be the best way, no sense in duplicating similar test.

@msamsel msamsel requested a review from f1ames November 20, 2017 12:23
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@f1ames f1ames merged commit 47ae8e2 into t/662 Nov 20, 2017
@f1ames f1ames deleted the t/662-3173 branch November 20, 2017 14:57
@msamsel msamsel restored the t/662-3173 branch December 15, 2017 11:54
@msamsel msamsel deleted the t/662-3173 branch December 15, 2017 12:03
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