Skip to content

ElementNode format #5708

@zurfyx

Description

@zurfyx

There is a case that works well in three major editors: Word, GDoc and Pages that Lexical still doesn't do quite right. Preserving the format when there's no text.

While #5707 addresses part of the issue (retention of selection) it doesn't fix the retention while moving away.

There's a key ingredient that's missing here: persistance.

In HTML, browsers do this with:

<p>
  <b>
  </b>
</p>

In Lexical we never wanted to introduce this DOM structure because of redundancy, a11y (and the fact that we don't support nested HTML).

But we can do better, we can persist this format in the ElementNode. In the Lexical case, ElementNode would only store and use this in particular cases when the selection touches on the entirety of the Element. These are:

  1. Collapsed selection on an empty block ElementNode
  2. Entire block ElementNode selected (i.e. triple click)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions