Open masayuki-nakano opened 1 month ago
On the other hand, inputType does not have insertFromPaste for "Paste without format" (Ctrl + V on Firefox/Chrome for Windows). Therefore, web apps cannot distinguish whether the user pasting with or without format.
I meant in the case of contenteditable=true
. E.g., Ctrl
-V
vs. Ctrl
-Shift
-V
.
On linux/Firefox when pasting with ctrl+shift+v I seem to get only plain/text, not text/html https://mozilla.pettay.fi/moztests/paste_contenteditable.html
And Chrome doesn't seem to get access to .dataTransfer ever when inputType is insertFromPaste.
From TPAC 2024 minutes:
Sanket: Sounds fine to give access to HTMl when pasting even in plaintext.
Dan: How about input?
Johannes: We prefixed all the types of inputTypes to make it possible for an old editor to handle new input types with the same prefix.
Sanket/Ryosuke: We could add another attribute that would not cause the same web compat issues. https://w3c.github.io/uievents/#idl-inputeventinit
Dan: Another option is to only deliver plaintext.
Dan: If we can do whatever, we can add new input type. But webcompat is an issue.
Johannes: second best is attribute. Where could that live.
Sanket: we could put it into the init where isComposing lives.
Olli: Maybe put it in the data transfer?
(Olli: what is the order in DataTransferItemList? Could ctrl+shift+v put text/plain first? https://mozilla.pettay.fi/moztests/paste_contenteditable.html Firefox gives only text/plain when doing ctrl+shift+v. text/html is there without ‘shift’. Chrome doesn’t have .dataTransfer with insertFromPaste ? Tested on linux. The test is about normal contenteditable, not plaintext-only)
According to Input Events Level 2,
beforeinput
ofinsertFromPaste
should havedata
asnull
anddataTransfer
when contenteditable. However, it's unclear that whether thedataTransfer
should or should not havetext/html
when the user pasts intocontenteditable=plaintext-only
.From point of view of web apps, if
dataTransfer
hastext/html
as same ascontenteditable=true
, they can serialize the HTML to plaintext by themselves to avoid dependency of browser/OS.On the other hand,
inputType
does not haveinsertFromPaste
for "Paste without format" (Ctrl
+V
on Firefox/Chrome for Windows). Therefore, web apps cannot distinguish whether the user pasting with or without format.Perhaps, there should be new
inputType
value anddataTransfer
may havetext/html
data even when pasting without format.