ckeditor / editor-recommendations

A set of recommendations for modern editing solutions.
https://ckeditor.github.io/editor-recommendations/
47 stars 12 forks source link

Enter key behaviour #36

Closed Comandeer closed 7 years ago

Comandeer commented 8 years ago

As it is widely known, Enter key is used to create new line in "classic" text editors (MS Word, LibreOffice Writer, etc.):

Therefore users are expecting similar behaviour from online WYSIWYG editors:

The use-case for Enter is obvious.

For Shift + Enter I could think of poems or address blocks (so texts where line break doesn't indicate change of topic, but it's purely a typographic convention):

<p>Comandeer<br>
Test Street 56<br>
GhostTown</p>

Use-case for Ctrl + Enter is dependent of the context, e.g. unprintable texts (blog article, e-mail…) does not need that sort of features, but online book creator – needs it badly.


To sum up: by default editor should:

Am I missing something or it sounds reasonable?

I've also made a small research how online WYSIWYG handle that keys now: https://gist.github.com/Comandeer/5f47231c7683a09c7374

fredck commented 8 years ago

That's a good start and it sums up well the basics of it. The only point of debate on those aspects is whether Enter should produce br.

I agree with the proposal that Enter should care about the semantical value of its behavior in undoubtedly break text into p elements.

This issue is much broader though. We need to come to an agreement on how Enter will behave on non plain paragraph contexts, like titles, lists, tables, pre-formatted text, etc.

Reinmar commented 8 years ago

I would be very strict about one thing – if the current selection position supports block content, the Enter must work on the block level (e.g. split the <p>). If the selection position doesn't allow blocks, the Enter would work like Shift + Enter. If <br> isn't allowed, then Enter should be disabled.

In other words, there are 3 modes: block, soft, disabled. The Enter tries to execute 1st or 2nd mode (in this order). The Shift + Enter tries only the 2nd mode.

I'm also trying to express here that this behaviour should not be configurable. The enter key behaviour should only depend on the data model (its schema) and the current selection position. Otherwise developers tend to break the editor.

And the last requirement in my opinion is that lists, headings and other blocks are special types of blocks. No type (or default type) == paragraph. Hence, paragraph must be enabled for other types to be enabled as well. For instance, you shouldn't be able to have lists when paragraphs are forbidden, because that leads to ridiculous situations and makes enter key (and other features) implementation a nightmare.

Comandeer commented 8 years ago

Ok, I've created the first version of draft.

Only the general behavior is included, so creating new block context and inserting a line break. There is also a note that the default block context is a paragraph, but it could be changed by a certain feature.

Comandeer commented 7 years ago

Ok, it seems like a stable feature. I propose moving it from draft to the recommendation status. I'll wait 3 days for objections and then do what should be done ;)