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

Line break nodes are (almost) redundant #847

Open
jonnyandrew opened this issue Oct 18, 2023 · 0 comments
Open

Line break nodes are (almost) redundant #847

jonnyandrew opened this issue Oct 18, 2023 · 0 comments
Labels
A-Rich-Text-Editor Rust T-Enhancement Improvement or feature request

Comments

@jonnyandrew
Copy link
Contributor

Problem

If we convert paragraphs to line breaks do we still need LineBreak type internally in the Dom?

Raised in #834 (comment)

The function to add line breaks is deprecated and fell out of use at the point of doing #472, so the Dom shouldn't contain these nodes. However, the LineBreak node is still being used to represent line breaks in the Dom immediately after parsing, before being post-processed into paragraphs.

This is a bit problematic because although we can expect that the Dom should no longer contain LineBreaks, there is a lot of existing code that expects that it might which is effectively dead code and a maintenance burden.

Possible solutions

  • Remove the LineBreak node and parse
    directly to Container. It will be the most effort but, after this PR, we have compatible tests to make this easier. There is also the question of whether this would put too much logic in the HTML parser.
  • Keep the LineBreak node but refactor it to something like Placeholder(LineBreak), adding an invariant assertion that it should not exist in the Dom. We could remove any logic that handles this node type and replace it with an unreachable! error.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Rich-Text-Editor Rust T-Enhancement Improvement or feature request
Projects
None yet
Development

No branches or pull requests

1 participant