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

Undo by pressing backspace: AutoFormat #10508

Merged
merged 4 commits into from
Sep 15, 2021

Conversation

arkflpc
Copy link
Contributor

@arkflpc arkflpc commented Sep 10, 2021

Suggested merge commit message (convention)

Feature (autoformat): Allowed undoing automatic Markdown-like formatting by pressing Backspace. See #10413.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

Base automatically changed from ck/10413-backspace-reverting-text-transformation to master September 10, 2021 11:31
Copy link
Member

@oleq oleq left a comment

Choose a reason for hiding this comment

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

Some remarks:

  • The feature works fine on the technical level.
  • I'm not sure applying this behavior to headings, blockquotes, code blocks, or horizontal lines is very useful, though. It's very unlikely anyone begins their block with ###, >, ``` or --- and they really want this sequence to be preserved because this is how they start the sentence. It's more likely they'll create headings/blockquotes/code blocks/etc. and want to press backspace and get rid of the whole block because they changed their mind.
    • OTOH, it makes sense for numbered lists because I can imagine starting a sentence with 1. and not wanting to create a list. Same with ordered lists, for instance, if they write footnotes they might want their sentence to start with * so they can superscript it later.
    • Maybe we could disable it for certain formattings then?
  • Come to think of it, I'm not sure how this feature could be useful for basic style formattings either (those that do not start with ^ in their regexps). I mean, it works fine but how is **abc** a useful sequence anyone would like to have in their content? Backspacing to remove "c" seems more logical than undoing the autoformatting.
    • Unlike the case with lists, I see no strong reason against enabling it for basic styles, though. It's a nice gimmick, I guess.
  • I couldn't find any other UX issues with this new behavior. I thought composition will break but I failed to find any scenario that would prove it.
  • No other text editor act like this. I'm curious why?

TL;DR

I'd enable this feature for ordered, numbered lists, and maybe for basic styles (because it looks cool). Then I'd wait for feedback from the community.

This behavior could be an argument of blockAutoformatEditing() and inlineAutoformatEditing() so 3rd-party integrators can decide what they want.

@@ -203,4 +186,88 @@ describe( 'Autoformat undo integration', () => {
expect( getData( model ) ).to.equal( '<paragraph>> []</paragraph>' );
} );
} );

describe( 'should undo by pressing backspace', () => {
Copy link
Member

Choose a reason for hiding this comment

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

We'll need a paranoid-integration-check-test here to make sure this does not happen when the selection changed in the meanwhile. It does not mean we have to double all requestUndoOnBackspace() tests here, just a single assertion will do.

@Reinmar
Copy link
Member

Reinmar commented Sep 15, 2021

I'd enable this feature for ordered, numbered lists,

Sounds good. The reasoning (that you often need to revert the autoformat in these cases) works for me.

and maybe for basic styles (because it looks cool)

You wrote yourself that "I'm not sure how this feature could be useful for basic style formatting". I agree that it looks cool there, though.

My big worry here, if we start to choose arbitrarily in which cases backspace works would be, though, that it will be a constant surprise to the user.

So, I think that viable options are:

  • Make it work in all cases
  • Make it work in block cases only (because of lists)
  • Do nothing.

@Reinmar
Copy link
Member

Reinmar commented Sep 15, 2021

  • Make it work in all cases

Let's go this way. We'll be consistent and have feedback (if anyone is annoyed by that).

@Reinmar Reinmar marked this pull request as ready for review September 15, 2021 09:17
@Reinmar Reinmar requested a review from oleq September 15, 2021 09:17
@oleq oleq merged commit b46ae90 into master Sep 15, 2021
@oleq oleq deleted the ck/10413-backspace-reverting-autoformat branch September 15, 2021 11:36
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.

3 participants