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

Remove format button should work with collapsed selection #4049

Merged
merged 8 commits into from
Jun 4, 2020
Merged

Conversation

jacekbogdanski
Copy link
Member

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

  • Unit tests
  • Manual tests

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.

  • PR is consistent with the code style guide

What is the proposed changelog entry for this pull request?

*[#4008](https://github.com/ckeditor/ckeditor4/issues/4008): Fixed: [Remove format](https://ckeditor.com/cke4/addon/removeformat) doesn't work with collapsed selection.

What changes did you make?

I reverted changes introduced in #2625 as they seem not necessary and adds this regression. Remove format operates only on inline elements, which is nicely documented here: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-removeFormatTags
Also, it seems like remove format indeed only breaks inline elements:

if ( pathElement.equals( path.block ) || pathElement.equals( path.blockLimit ) )
break;

so, enlarging range only for inline elements may be a good approach. I didn't note any special issues with skipping block elements and the issue #2451 is still covered.

Which issues does your PR resolve?

Closes #4008

@Comandeer Comandeer self-requested a review May 21, 2020 14:18
@Comandeer Comandeer self-assigned this May 21, 2020
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

Fix looks and works good.

However there's a small issue with a manual test in IE11: putting the selection at the end of the text puts it already outside of strong tag. Probably the text needs to be inputed by the user for the test to start working.

'test remove format with collapsed selection': function() {
this.editorBot.setHtmlWithSelection( '<p><strong>Hello,^</strong></p>' );

this.editor.execCommand( 'removeFormat' );
Copy link
Member

Choose a reason for hiding this comment

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

this.editor is used several times in the test – maybe extract it to a variable?

@jacekbogdanski
Copy link
Member Author

Weird, it seems to work correctly for me (on IE11):

removeformat

Nevertheless, changing this test to always request full input should cover some edge cases 👍

Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

LGTM! I've just made some small adjustments in tests.

@Comandeer Comandeer merged commit 4538808 into master Jun 4, 2020
@Comandeer Comandeer deleted the t/4008 branch June 4, 2020 14:40
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