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

Blockquote should be split on backspace key press. Empty block element at the beginning of the limit element should be converted to a paragraph on backspace key press. #8569

Merged
merged 5 commits into from
Dec 22, 2020

Conversation

niegowski
Copy link
Contributor

@niegowski niegowski commented Dec 2, 2020

Suggested merge commit message (convention)

Feature (typing): Empty block element at the beginning of the limit element should be converted to a paragraph on backspace key press. Closes #8137.

Feature (block-quote): Block-quote should be split on backspace key press at the beginning of the block-quote. Closes #7636.

Fix (list): The delete event handler listening on a higher priority to avoid intercepting by the block-quote and widget handler. Closes #8706.


Additional information

…nt at the beginning of the limit element should be converted to a paragraph on backspace key press.
@niegowski
Copy link
Contributor Author

@ckeditor/qa-team could you please test it?

@FilipTokarski
Copy link
Member

Checked in various browsers, I didn't find any bugs. Seems to work fine 👍

The only thing that caught my attention, is that changing heading -> paragraph is not recognized by Track Changes ( block quote works ok ), but I guess this is a case for a follow-up.

@niegowski
Copy link
Contributor Author

The only thing that caught my attention, is that changing heading -> paragraph is not recognized by Track Changes ( block quote works ok ), but I guess this is a case for a follow-up.

I changed a bit the way it's handled, now it should properly integrate with TC.

@FilipTokarski
Copy link
Member

Yes, now it shows a proper suggestion 👍

@@ -168,7 +169,7 @@ export default class ListEditing extends Plugin {

data.preventDefault();
evt.stop();
}, { priority: 'high' } );
Copy link
Member

Choose a reason for hiding this comment

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

Why? It's useful if such quirks are documented in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a code comment.

// If Backspace key is pressed with selection collapsed in first empty block inside a quote, break the quote.
//
// Priority high + 5 to override widget's feature listener but not list's feature listener.
this.listenTo( viewDocument, 'delete', ( evt, data ) => {
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this applies to blockQuotes only? Maybe it'd be simpler if this was generalized a bit and put directly in the delete handler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, it's a different case for list items (that are not wrapped) and blockQuotes (that are wrapped).

const positionParent = doc.selection.getLastPosition().parent;
//
// Priority normal - 10 to override default handler but not list's feature listener.
this.listenTo( viewDocument, 'enter', ( evt, data ) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why did you need to change anything in the Enter key support in this PR? This PR from its history and description was all about the Backspace key, so this is confusing.

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 seems more reasonable to use -10 instead of using afterInit just to order listeners.

@Reinmar
Copy link
Member

Reinmar commented Dec 10, 2020

I left a couple of questions and suggestions.

I'm mostly worried about:

  • why some things were changed/needed,
  • whether we couldn't make them simpler (these priorities thing is best to avoid).

Copy link
Member

@Reinmar Reinmar left a comment

Choose a reason for hiding this comment

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

As commented.

@niegowski
Copy link
Contributor Author

As we discussed F2F I created a followup: #8640

@niegowski niegowski requested a review from Reinmar December 11, 2020 09:06

editor.editing.view.document.fire( 'delete', domEvtDataStub );

sinon.assert.calledWithExactly( editor.execute, 'outdentList' );
Copy link
Member

Choose a reason for hiding this comment

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

I know you were consistent with all the other tests here, but just to clarify – I think all of them should be checking the actual content of the model too, not only whether the command was executed. We don't know if some other handler didn't react or the command didn't do something unexpected (quite probable when changing its behavior).

@Reinmar Reinmar merged commit 2d9954c into master Dec 22, 2020
@Reinmar Reinmar deleted the i/8137 branch December 22, 2020 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants