w3c / w3c/edit-context

Extending the list of supported elements

Open
#103 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
48
Forks
13
PR merge metrics
No merged PRs in 30d

Description

We started to experiment with EditContext API in CKEditor 5 and encountered an issue. There are so-called "nested editables" inside the editor – smaller editable regions inside the main editable region of the editor, e.g. image captions or table cells. We want to use the EditContext API also in these nested editables but it can't be used directly due to limiting the list of supported elements only to shadow hosts + <canvas>. This limitation forces us to dynamically inject a <div> element into a nested editable to enable the EditContext API when the user starts interacting with it:

<figure class="image" contenteditable="false">
	<img src="[…]" alt="[…]">
	<figcaption contenteditable="true">Some caption</figcaption>
</figure>
<!-- beomes -->
<figure class="image" contenteditable="false">
	<img src="[…]" alt="[…]">
	<figcaption contenteditable="true">
		<div class="edit-context-host">Some caption</div>
	</figcaption>
</figure>

It works but introduces some drawbacks, especially when it comes to the styling, e.g. it breaks selectors like td > p:first-child.

It was decided in #19 to limit the list to "boring elements" (shadow hosts) but I feel that this list could be too limited. CKEditor 5 is not the only editor that uses nested editables, e.g. Tiny also uses them with the <figcaption> element for image captions so does Lexical. Due to that, I propose extending the current list of supported elements, e.g. to all elements supporting the contenteditable attribute.

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.

Research direction

Start with the supported-elements decision in issue #19 and compare it with this issue's nested-editable examples, especially

and table cells. Evaluate whether the EditContext API should support all elements with the contenteditable attribute, then document the proposed element list and rationale for review.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.