Implement contenteditable="plaintext-only"
Categories
(Core :: DOM: Editor, enhancement, P3)
Tracking
()
People
(Reporter: noms, Assigned: masayuki)
References
(Blocks 7 open bugs, )
Details
(4 keywords, Whiteboard: [h2review-noted] webcompat:risk-high )
User Story
platform-scheduled:2025-06-30
Attachments
(1 file)
Comment 1•9 years ago
|
||
Assignee | ||
Comment 2•9 years ago
|
||
Assignee | ||
Comment 3•9 years ago
|
||
Assignee | ||
Comment 5•9 years ago
|
||
Assignee | ||
Comment 6•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Assignee | ||
Updated•9 years ago
|
Comment 7•9 years ago
|
||
Updated•8 years ago
|
Updated•8 years ago
|
Assignee | ||
Comment 8•8 years ago
|
||
Comment 9•7 years ago
|
||
![]() |
||
Updated•6 years ago
|
![]() |
||
Updated•6 years ago
|
Updated•6 years ago
|
Comment 10•6 years ago
|
||
See bug 1547409. Moving webcompat whiteboard tags to project flags.
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 11•5 years ago
|
||
Note that plaintext-only
is removed from the spec:
Comment 12•5 years ago
|
||
(In reply to Kagami :saschanaz from comment #11)
Note that
plaintext-only
is removed from the spec:
Does it mean this bug can be closed with WONTFIX?
Since beforeinput is standardised, the same effect of plaintext-only can be achieved via beforeinput.
Assignee | ||
Comment 13•5 years ago
|
||
(In reply to 張俊芝(ZHANG Junzhi) from comment #12)
Does it mean this bug can be closed with WONTFIX?
Depends on existing web apps. If web apps won't stop using the non-standardized API, we would need to implement it for Firefox users.
(The main issue of plaintext-only
is, there are no agreement of what can be called as "plaintext" from point of innerHTML
view.)
Since beforeinput is standardised, the same effect of plaintext-only can be achieved via beforeinput.
Well, sorry for the delay to implement beforeinput
. I'm still struggling with setting proper target ranges at deletion. You can test our beforeinput
event behavior on your own apps with setting dom.input_events.beforeinput.enabled
to true in about:config
.
Updated•5 years ago
|
![]() |
||
Updated•3 years ago
|
![]() |
||
Updated•3 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 14•2 years ago
|
||
The following spec PRs specify the contenteditable="plaintext-only" which is supported in WebKit and Chromium:
Assignee | ||
Comment 15•2 years ago
|
||
(In reply to Howard Edwards [:howard-e] from comment #14)
The following spec PRs specify the contenteditable="plaintext-only" which is supported in WebKit and Chromium:
Unfortunately, the PRs do not standardize the behavior enough...
Comment 16•2 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #15)
Unfortunately, the PRs do not standardize the behavior enough...
Other than line breaks (LF vs <br>), what should the spec for plaintext-only cover?
Assignee | ||
Comment 17•2 years ago
|
||
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 pressingEnter
) - 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 causesinsertParagraph
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
).
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 19•2 years ago
|
||
Bumping the priority a bit higher because we've now found more implementations that break (see the see-also's)
Comment 20•2 years ago
|
||
Am I right in thinking that the open spec issue https://github.com/w3c/editing/issues/419 still blocks the implementation of this bug?
Assignee | ||
Comment 21•2 years ago
|
||
Yes and no. No standardized spec blocks us to implement this, and there are too few tests. Additionally, the examples in the issue may not all of what should be standardized.
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Updated•2 years ago
|
Comment 22•2 years ago
|
||
Yeah I think we can plan to implement. The spec issue should be fixed but it seems relatively easy.
Assignee | ||
Updated•11 months ago
|
Assignee | ||
Updated•11 months ago
|
Updated•9 months ago
|
Comment 23•9 months ago
|
||
Verified this issue and still reproduces on Firefox Nightly for http://jsbin.com/kaladi/edit?html,output as the first input field does not accept input at all
Tested with:
Browser / Version: Firefox Nightly 128.0a1 (2024-05-29) (64-bit)
Operating System: Windows 10 PRO x64
Assignee | ||
Comment 24•7 months ago
•
|
||
Hmm, I found ugly hack of Chrome. They use line feeds as line breakers in the plaintext-only
mode. However, it requires some white-space
property valuses to make them visible. Therefore, they forcibly replace the white-space
value with corresponding value which makes line feeds visible.
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/css/resolver/style_adjuster.cc;l=343;drc=99d1b90e58c0aeaf0693f0652bfe1569c8663f95
It's hard to align to Chrome and it does not conform to any standards. So I think that we should use <br>
s at least when line feeds are not visible.
Updated•5 months ago
|
Assignee | ||
Comment 25•5 months ago
|
||
Emilio, I found user-modify: read-write-plaintext-only
. Should we support this? And can we implement it only when a pref is enabled?
Assignee | ||
Comment 26•5 months ago
|
||
Hmm, we need to add new pseudo-class here. https://searchfox.org/mozilla-central/rev/f2c181a7ab3bfea4d2266521e6eac713630479b3/dom/html/nsGenericHTMLElement.cpp#1318-1319
Comment 27•5 months ago
|
||
Why would you need a new pseudo-class? Other browsers don't (afaict) have a new pseudo-class for plaintext-only
, they'd just match :read-write
wouldn't they?
You'd map the read_only
state of the contenteditable
attribute to ReadWritePlaintextOnly
here.
As for whether you can parse a value only when a pref is set, of course, though we'd need to move this code out of simple_keyword
, then you'd be able to do something like this.
I can do the refactor for you, then you can add the new value and pref :)
Assignee | ||
Comment 28•5 months ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #27)
Why would you need a new pseudo-class?
Oh, I just thought that it's required for the consistency. If it's enough that contenteditable=plaintext-only
causes :read-write
, I don't think we should add the pseudo-class since adding it must make the contenteditable.css
have complicated selectors.
Other browsers don't (afaict) have a new pseudo-class for
plaintext-only
, they'd just match:read-write
wouldn't they?
I've not checked the other browsers' behavior. Indeed, it's important that whether they make the pseudo-class active or not.
You'd map the
read_only
state of thecontenteditable
attribute toReadWritePlaintextOnly
here.
Thanks. That's where I found.
As for whether you can parse a value only when a pref is set, of course, though we'd need to move this code out of
simple_keyword
, then you'd be able to do something like this.I can do the refactor for you, then you can add the new value and pref :)
Thank you. If you think that it's required, I'll request you to do that. However, honestly, I'm not sure whether we really need to change the style system.
Comment 29•5 months ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #28)
Thank you. If you think that it's required, I'll request you to do that. However, honestly, I'm not sure whether we really need to change the style system.
I think it might be useful for consistency with other browsers perhaps, but only if you think it's useful. I'm not sure what the behavior should be when switching from / to the plaintext mode from style. Seems weird.
Actually looking at -moz-user-modify
, it might be worth removing that property altogether. In WebKit, it does cause the text to be editable (it is the thing that actually triggers "contenteditable" behavior. But we only check it in one caret-painting code-path?
Assignee | ||
Comment 30•5 months ago
|
||
As far as I've tested, Chrome does not work with :read-write-plaintext-only { color: red; }
(querySelector
too). So I think it's fine not to support it at least for now. So, let's keep current implementation as-is about the layout module.
Assignee | ||
Updated•5 months ago
|
Assignee | ||
Updated•5 months ago
|
Assignee | ||
Updated•5 months ago
|
Assignee | ||
Updated•5 months ago
|
Assignee | ||
Updated•5 months ago
|
Assignee | ||
Updated•5 months ago
|
Updated•2 months ago
|
Comment 31•2 months ago
|
||
Link to jira https://mozilla-hub.atlassian.net/browse/FFXP-2459
Updated•1 month ago
|
Assignee | ||
Updated•23 days ago
|
Assignee | ||
Updated•23 days ago
|
Assignee | ||
Comment 32•22 days ago
|
||
Comment 33•22 days ago
|
||
Release Note Request (optional, but appreciated)
[Why is this notable]: Allows authors to make elements editable but only allows to enter plain text.
[Affects Firefox for Android]: yes
[Suggested wording]: The value plaintext-only
can now be specified for the contenteditable
attribute, making the raw text of an element editable but without supporting rich text formatting.
[Links (documentation, blog post, etc)]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable
Comment 34•19 days ago
|
||
Comment 35•18 days ago
|
||
bugherder |
Comment 36•18 days ago
|
||
Added to the Fx136 nightly release notes, please allow 30 minutes for the site to update.
Keeping the relnote-firefox flag as ? to keep it on the radar for inclusion in the final Fx136 release notes.
Updated•16 days ago
|
Comment 37•6 days ago
|
||
Description
•