w3c / w3c/edit-context

Making it possible to associate the EditContext with multiple Elements

Open
#95 0 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

The rich text editor applications often nests the contenteditable false and true elements to each other.

<div class="root-editable" contenteditable="true">
  editable text
  <div class="nested-context" contenteditable="false">
    <div class="nested-editable" contenteditable="true">
       nested editable text
     </div>
  </div>
</div>
Contenteditable

With the contenteditable element, we can add an event listener to the element that will propagate through all of its descendants, which makes possible for the nested-editable to use the same functionality that was written for the root-editable.
E.g.:

const rootEditable = document.querySelector('.root-editable");
rootEditable.addEventListener("keydown", (e) => {
 // Event fires if the focus was in either the RootEditable or the NestedEditable
});
EditContext

In case of the EditContext, the event listener is attached to its instance that currently prevents to apply the functionality for multiple elements.

const rootEditable = document.querySelector('.root-editable");
const editContext = new EditContext();
rootEditable.editContext = editContext;

editContext.ontextupdate = (event) => {
  // Event fires only if the focus was on the RootEditable (it doesnt fire  if the focus is on the NestedEditable)
}
Solution

If we would be able to apply the EditContext's instance to multiple elements, that would solve this issue.

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

The issue provides nested contenteditable examples and describes the EditContext event behavior, but names no repository files, tests, or entry points. Start by locating the EditContext specification or implementation area, then examine how an instance is associated with an element. Done means one EditContext can support the multiple nested editable elements described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript
Domain
api, frontend
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.