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

Block autoformat could work in all kind of blocks #6170

Closed
Reinmar opened this issue Jan 30, 2020 · 9 comments · Fixed by #7576
Closed

Block autoformat could work in all kind of blocks #6170

Reinmar opened this issue Jan 30, 2020 · 9 comments · Fixed by #7576
Assignees
Labels
domain:ui/ux This issue reports a problem related to UI or UX. intro Good first ticket. package:autoformat type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@Reinmar
Copy link
Member

Reinmar commented Jan 30, 2020

📝 Provide a description of the improvement

So, right now when you're in at the beginning of a heading 2 and type ### it is not going to change it to a heading 3. It's only possible to turn a paragraph into other types of blocks.

This means that you can't easily toggle between block types. Also, if you made a mistake, you need to get back to a paragraph (e.g. by undoing) and only then you can use autoformatting.

One example of an application where you can always switch between block types is Notion and I use this quite a lot. Especially when I'm changing heading levels (cause I'm reorganizing a document).

Another aspect is that currently you can only apply autoformatting to an empty block. We'd also like to apply formatting for blocks that have some content in it, as long as your cursor is at the beginning of the line.

Related issue:

cc @jodator @panr @oleq


If you'd like to see this improvement implemented, add a 👍 reaction to this post.

@Reinmar Reinmar added type:improvement This issue reports a possible enhancement of an existing feature. domain:ui/ux This issue reports a problem related to UI or UX. intro Good first ticket. package:autoformat labels Jan 30, 2020
@Reinmar Reinmar added this to the nice-to-have milestone Jan 30, 2020
@jodator
Copy link
Contributor

jodator commented Jan 30, 2020

One example of an application where you can always switch between block types is Notion and I use this quite a lot. Especially when I'm changing heading levels (cause I'm reorganizing a document).

After using this app for some time I feel that this is the expected way of doing things. IIRC I just used this app this way (might be a hint from a tutorial). It feels natural. Even so, then when testing our implementation of block autoformat it felt weird in that regard.

ps.: This change shouldn't be a time consuming one.

@ma2ciek

This comment has been minimized.

@Reinmar

This comment has been minimized.

@Reinmar
Copy link
Member Author

Reinmar commented May 12, 2020

We did a quick review of the block autoformat code and there are a couple of things that might be worth at least considering when working on this:

@Reinmar Reinmar modified the milestones: nice-to-have, iteration 33 May 26, 2020
@Reinmar
Copy link
Member Author

Reinmar commented May 26, 2020

One thing I noticed in Notion is that `1. ` will work in a paragraph but not in a heading. While `# ` will work everywhere. That even makes some sense, so we should be careful to not "overdo" here.

@mlewand
Copy link
Contributor

mlewand commented Jun 30, 2020

Cleaned up the issue a bit (extracted #7517).

Also we need more elaboration on that:

  • Reading model element names from the schema.
  • Naming.
  • isTyping.

Related issue:

@Reinmar
Copy link
Member Author

Reinmar commented Jun 30, 2020

  • Reading model element names from the schema.

It's about https://github.com/ckeditor/ckeditor5/blob/b80c677/packages/ckeditor5-autoformat/src/autoformat.js#L120-L139. It'd be cleaner if we read the heading* element names from the schema. But it's a completely minor issue.

Naming

It's most likely about https://github.com/ckeditor/ckeditor5/blob/b80c677/packages/ckeditor5-autoformat/src/autoformat.js#L126. It's not a command value. Since we planned to review this code, it might be a good moment to clean up such issues. But it's again a minor issue.

isTyping

It's about using the isInput property (it was renamed from isTyping -> isInput) to check whether a current change should be treated as typing. That property was added quite recently so the autoformat feature which was implemented very early is using some other heuristic (probably, worse).

@mlewand
Copy link
Contributor

mlewand commented Jun 30, 2020

We had a quick discussion regarding these changes today, and we made several minor adjustments.

One thing I noticed in Notion is that `1. ` will work in a paragraph but not in a heading. While `# ` will work everywhere. That even makes some sense, so we should be careful to not "overdo" here.

Wile mentioned Notion doesn't allow turning a list to a header, we decided to simplify things and not impose such limitations for now. Which means there is not going to be any map telling what block can be turned into what.

While doing this issue we could also do some refactoring here and there (e.g. #7366, there are also some misused variable names in the code).

However for now the refactoring should be limited, so we're not going to utilize text watcher / perform a full rewrite.

@Reinmar
Copy link
Member Author

Reinmar commented Jul 1, 2020

I noticed that you can't turn a heading into a list by typing `1. `. You can, however, by typung `* `. That makes a lot of sense. I was just trying to number the headings (as steps) and I was positively surprised that Notion devs predicted this case. It makes a lot of sense to me. (edit: extracted to #7569)

mlewand added a commit that referenced this issue Jul 22, 2020
Feature (autoformat): Block autoformat can also be triggered in blocks other than paragraph. Closes #6170.

Feature (autoformat): Enabled autoformat feature also for blocks that are not empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:ui/ux This issue reports a problem related to UI or UX. intro Good first ticket. package:autoformat type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants