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

Pasting image widget into table cell #694

Merged
merged 45 commits into from
Aug 10, 2017
Merged

Pasting image widget into table cell #694

merged 45 commits into from
Aug 10, 2017

Conversation

Comandeer
Copy link
Member

@Comandeer Comandeer commented Jul 28, 2017

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

All patches which 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

  • Unit tests
  • Manual tests

What changes did you make?

  • Now all non-table/mixed content is passed to other paste handlers and is no longer handled by table paste handler.
  • Selecting cells after paste was moved to afterPaste handler.
  • Logic of empting cells before real paste is also updated.
  • However there is still one issue, which I don't have a good idea how to solve: after selecting more than one cell, pasting into them and clicking "Undo" button, only the first cell is selected. It's caused by the change introduced while passing mixed content to other paste handlers.

closes #520, #460.

@f1ames f1ames self-requested a review July 31, 2017 10:44
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.

The code looks good, however there are some failing tests (checked on Chrome and FF):
screen shot 2017-08-01 at 08 18 25

@Comandeer
Copy link
Member Author

I've pushed fixes for failing tests (simple change from paste to afterPaste listener). I've also prepared additional test for testing paste flow when pasting non-tabular content.

@mlewand mlewand self-requested a review August 4, 2017 09:31
Copy link
Contributor

@mlewand mlewand left a comment

Choose a reason for hiding this comment

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

Here are few notes I made during the review. I went with adding my proposals in a PR based on, and targeted at this PR.

if ( tmpContainer.getChildCount() > 1 || !pastedTable ) {
selectedCells[ 0 ].setHtml( tmpContainer.getHtml() );
evt.data.dataValue = tmpContainer.getHtml();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a reason for using tmpContainer.getHtml() since evt.data.dataValue is already set, and actually we don't want to mess up evt.data.dataValue if possible, since it's about to be pasted into the table cell.


// Handle mixed content (if the table is not the only child in the tmpContainer, we
// are probably dealing with mixed content). We handle also non-table content here.
// We just collapse selection to the first selected cell and pass non-table/mixed
// content to other paste handlers (#520).
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to me that this comment is pretty much oudated. How about:

// In case of mixed content or non table content just insert it to a first cell, erasing the others.

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually this paste handler does not perform paste in such case. It just selects the first cell and ends its job – so I don't see my comment as outdated. Maybe it could be a little bit more detailed.

// content (#520).
editor.once( 'afterPaste', function() {
var toSelect = cellToPaste ?
getCellsBetween( new CKEDITOR.dom.element( pastedTableMap[ 0 ][ 0 ] ), cellToPaste ) :
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a critical thing but pastedTableMap is used before it's defined, we should avoid this kind of code.

@Comandeer
Copy link
Member Author

Ok, I've merged t/520_fix branch and newest master. I've also fixed failing tests in IE11.

@Comandeer Comandeer requested a review from mlewand August 10, 2017 09:58
@mlewand
Copy link
Contributor

mlewand commented Aug 10, 2017

@f1ames please check whether your issues have been addressed.

@f1ames f1ames self-requested a review August 10, 2017 11:17
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.

As for my requests, I see all tests are green now.

@f1ames
Copy link
Contributor

f1ames commented Aug 10, 2017

@mlewand should I merge it, or you will do the honors?

@f1ames
Copy link
Contributor

f1ames commented Aug 10, 2017

Merging now :)

mlewand and others added 21 commits August 10, 2017 14:01
This caused a bug that if pasted table was bigger than the current selection, the output would be missing some cells. Covered the change with unit test.
…tomized by tableselection.

That caused user to be unable to paste a nested table into an existing table.
…n was present table would not be pasted and merged correctly.
@mlewand
Copy link
Contributor

mlewand commented Aug 10, 2017

Sry I was out, please do the honors 🙂

@mlewand
Copy link
Contributor

mlewand commented Aug 25, 2017

Looks like this PR also fixed #460 🎉.

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.

None yet

4 participants