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

Default Editable enter behavior to newline #374

Closed
aduth opened this issue Apr 6, 2017 · 10 comments
Closed

Default Editable enter behavior to newline #374

aduth opened this issue Apr 6, 2017 · 10 comments
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Type] Question Questions about the design or development of the editor. [Type] Task Issues or PRs that have been broken down into an individual action to take
Milestone

Comments

@aduth
Copy link
Member

aduth commented Apr 6, 2017

This is related to how we want to handle block splitting, e.g. pressing enter in the middle of a paragraph. But more specifically to changes introduced in #347, nothing occurs when pressing enter in a text block. We could consider defaulting this to a newline via TinyMCE settings.

https://www.tinymce.com/docs/configure/content-filtering/#forced_root_block

We should also consider how this impacts inline editables (quote citation, image caption). We can control this via Editable prop if need be.

@aduth aduth added Framework Issues related to broader framework topics, especially as it relates to javascript [Type] Task Issues or PRs that have been broken down into an individual action to take [Type] Question Questions about the design or development of the editor. labels Apr 6, 2017
@aduth aduth added Good First Issue An issue that's suitable for someone looking to contribute for the first time TinyMCE labels Apr 6, 2017
@mtias mtias added [Feature] Blocks Overall functionality of blocks and removed Framework Issues related to broader framework topics, especially as it relates to javascript labels May 3, 2017
@jasmussen
Copy link
Contributor

It seems like this change would be good to try out sooner rather than later.

@jasmussen jasmussen added this to the May Week 3 (Alpha) milestone May 16, 2017
@ellatrix
Copy link
Member

What needs to happen here? All blocks add BR on enter, P on double?

@aduth
Copy link
Member Author

aduth commented May 16, 2017

I'm wondering if the current behavior is sufficient for what we want. It doesn't default to newlines, but at least handles the multiple consecutive paragraphs as a block split intent.

@jasmussen jasmussen modified the milestones: May Week 3 (Alpha), Beta May 22, 2017
@ellatrix
Copy link
Member

@mtias @jasmussen Do you agree with this? Does anything need to change?

@jasmussen
Copy link
Contributor

It seems like the two approaches we're looking at:

  1. Single linebreak creates paragraph, double linebreak splits (current behavior)
  2. Single linebreak creates linebreaks, double linebreak creates paragraph, triple linebreak could split

I think the current behavior works well, and is a nice callback to the current wp-admin. I'm okay with making a decision that we keep this.

However the arguments in favor of option 2 are strong, in my book. It's the standard behavior for most other text editors. It fixes the mystery meat that is inherent in having to create single linebreaks using shift enter. And it allows mobile users to create single linebreaks without entering HTML mode.

Option 2 also feels like a big change, which is why it'd be good to do it soon.

To help us make a decision (and I'd like @mtias thoughts too), how much work would it be to switch to option 2? It sounds like a lot, which would make me lean towards option 1.

@ellatrix ellatrix added [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable and removed Good First Issue An issue that's suitable for someone looking to contribute for the first time labels May 22, 2017
@aduth
Copy link
Member Author

aduth commented May 22, 2017

The behavior hinges on TinyMCE's forced_root_block configuration. What you describe in the second option sounds more like a hybrid between 'p' and false options. This doesn't exist out-of-the-box, but maybe there's a solution where we leave the option to its default value of creating paragraphs, but intercept the new block event to assign as a br at the first linebreak.

@ellatrix
Copy link
Member

I wast wondering if we could otherwise have the inline config for all blocks and the text block be one paragraph. Then break on multiple line breaks.

@nylen
Copy link
Member

nylen commented May 22, 2017

I think that option (2) here should be a separate block type, and the default text block should keep the current behavior of "enter = new paragraph".

@spocke
Copy link

spocke commented May 23, 2017

We recommend using paragraphs as the default since paragraph has semantic meaning and this is the default line break behavior of common word processors like Word, LibreOffice, Google docs etc except that the paragraph margin is 0 in some of them.

Also knowing that you have a fixed format of producing paragraphs means that you can know what to do when converting say a list to paragraphs if you have some form of mixed style with br:s and paragraphs you can't reverse that process since that information has been lost.

Having some mixed mode would become very complex fast since there is no strict rules sometimes it would do one thing sometimes it would do something else and the end user wouldn't be able to tell when since they can't even see the br:s.

However there are situations where we need to produce BR elements by default in tinymce even if the forced_root_block is set to 'p', that is inside elements that can't semantically have a paragraph. Could be things like nested spans as the editable host etc.

@ellatrix
Copy link
Member

I think we addressed all this in the form of a prop now. Some editables like text and heading can split on double enter, others like captions will never split. See also #1078. Feel free to reopen or create a new ticket if there are remaining concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Type] Question Questions about the design or development of the editor. [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

No branches or pull requests

6 participants