w3c / w3c/editing

Behavior of insert* commands for contenteditable=plaintext-only

Open
#419 12 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

See https://bugzilla.mozilla.org/show_bug.cgi?id=1291467#c17 by @masayuki-nakano

I checked the behavior in Chrome roughly now, then, I see only the following commands work, so their definitions are required:

  • Handling steps of Document.execCommand("insertParagraph") (Chrome/Safari handle this command differently from pressing Enter)
  • Handling steps of Document.execCommand("insertLineBreak") (LF vs <br> (Chrome vs. Safari)
  • Handling steps of the commands when caret is in special elements such as <li>
  • Handling steps of Document.execCommand("insertText") (including line breaks causes insertParagraph in both, but I'm not sure it's intended since the behavior looks odd)
  • Handling steps of Document.execCommand("insertHTML") (especially which elements need to be handled as line breaks)

And the other commands (except undo, redo and clipboard commands) should be defined as NOOP (including not deleting Selection).

cc @howard-e

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 linked Bugzilla discussion and compare the listed execCommand cases for plaintext-only editing. The work is complete when the handling steps are defined for insertParagraph, insertLineBreak, insertText, insertHTML, and special elements, while the other commands are explicitly treated as no-ops as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
documentation, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.