w3c / w3c/editing

Nested editing hosts do not need to be wrapped in insertParagraph

Open
#490 5 comments 0 reactions 1 assignee View on GitHub

@zcorpan is already working on this.

Since Oct 20, 2025.

execCommand
Dominant language
HTML
Stars
202
Forks
43
PR merge metrics
No merged PRs in 30d

Description

When performing the action for insertParagraph, step 11 asks to check if the container is not editable:

https://github.com/w3c/editing/blob/b9fbe88d2319c5667a008804c2364023ce4ccec0/docs/execCommand/index.html#L13580-L13584

This is not how it currently works in both Chrome and Firefox for the following case:

<div contenteditable>foo <div contenteditable>bar</div></div>

If insertParagraph is run while a selection exists inside the inner editing host, a new container is created to wrap the contents in. This should not be necessary, and Chrome and Firefox both use the existing inner editing host as the container.

The behavior seems to be more accurately reflected by:

If the container is not editable and the container is either not an editing host, or its parent is neither editable nor an editing host, ...

An alternative approach could be to change the "is editing host" logic to exclude elements with contenteditable set to true or plaintextonly that are children of an editable node or an editing host, which is the approach I took for Ladybird.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.