Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Use of <p> to represent line breaks in message output #832

Closed
jonnyandrew opened this issue Sep 29, 2023 · 2 comments · Fixed by #834
Closed

Use of <p> to represent line breaks in message output #832

jonnyandrew opened this issue Sep 29, 2023 · 2 comments · Fixed by #834
Assignees
Labels
A-Rich-Text-Editor T-Enhancement Improvement or feature request

Comments

@jonnyandrew
Copy link
Contributor

jonnyandrew commented Sep 29, 2023

Problem

When a user types multiple lines of text in the editor, it is represented as multiple HTML paragraphs in the message output.

The default and correct way to display an HTML paragraph is to add a significant padding to visually separate it from the surrounding elements. Hence it's reasonable to expect that any client may render the message in this way. The problem is then that the user may compose a message that looks one way in the editor (compact spacing at line breaks) only for it to be displayed completely differently when rendered by a client.

Proposed solution

For context,<p> tags were only added to help manage the state of the editor internally but there shouldn't be any reason that this implementation detail needs to leak into the message output.

Historically, some clients have adjusted the default style of paragraph tags to reduce the padding. However this shouldn't be necessary when we can use <br> tags to represent a line break as it appears in the editor.

So my proposed solution would be to

  • continue using paragraphs for the internal representation of new lines;
  • consider renaming the internal node type from paragraph to something more abstract (to avoid any confusion);
  • strip paragraphs and replace with line breaks during the rendering of HTML message output;
  • ensure any input containing line breaks is parsed into paragraphs.
@ara4n
Copy link
Member

ara4n commented Sep 30, 2023

A slightly hacky but pragmatic alternative to backing out #472 (which looks fairly complex) might be to postprocess the output of the RTE to turn <p>foo</p> into foo<br/> and <p>foo</p><p> </p> into <p>foo</p>. I vaguely remember doing this in Element Web in the very original Draft.js based RTE to fix the same bug.

@aringenbach
Copy link
Contributor

An additional point for the proposed solution is that it's also needed to replace line breaks back with paragraphs on edit/quote use case.

@jonnyandrew jonnyandrew added the bug label Oct 4, 2023
@jonnyandrew jonnyandrew self-assigned this Oct 5, 2023
@jonnyandrew jonnyandrew added T-Enhancement Improvement or feature request and removed bug labels Oct 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Rich-Text-Editor T-Enhancement Improvement or feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants