Phenomenon
When using the Clipboard API (navigator.clipboard.readText/writeText) with contenteditable elements, the behavior may be inconsistent. Reading clipboard content may not work during paste events, and writing to clipboard may not preserve formatting.
Reproduction example
- Create a contenteditable div.
- Listen for paste events.
- Try to read clipboard content using Clipboard API.
- Try to write formatted content to clipboard.
- Observe any errors or inconsistencies.
Observed behavior
- In Firefox on Windows, Clipboard API may not work correctly with contenteditable.
- Reading clipboard during paste may require user gesture.
- Writing formatted content may not preserve HTML.
- Permissions may be required inconsistently.
Expected behavior
- Clipboard API should work seamlessly with contenteditable.
- Reading should work during paste events.
- Writing should preserve formatting when appropriate.