Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle paste event in contenteditable element with HTML and plain text fallback #36277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ashish-CodeJourney
Copy link
Contributor

@Ashish-CodeJourney Ashish-CodeJourney commented Oct 9, 2024

Description

  • Added paste event listener to the contenteditable paragraph
  • Prevent default paste behavior to handle pasted content manually
  • Retrieve pasted content as HTML, and fallback to plain text if no HTML is available
  • Display the pasted content in a separate result div

Motivation

The changes enhance the behavior of the contenteditable element when handling pasted content. By preventing the default paste action and manually handling the content, we ensure that both HTML and plain text are processed correctly. This allows better control over pasted data, providing a more predictable experience for users and developers working with editable content.

Additional details

This change improves the handling of clipboard events, addressing cases where pasted content (HTML or plain text) is not handled correctly by default.

Related issues and pull requests

Fixes #36276, where pasted content inside a contenteditable div was not handled correctly due to the improper use of the dataTransfer object.

…in text fallback

- Added `paste` event listener to the contenteditable paragraph
- Prevent default paste behavior to handle pasted content manually
- Retrieve pasted content as HTML, and fallback to plain text if no HTML is available
- Display the pasted content in a separate result div
@Ashish-CodeJourney Ashish-CodeJourney requested a review from a team as a code owner October 9, 2024 05:32
@Ashish-CodeJourney Ashish-CodeJourney requested review from Elchi3 and removed request for a team October 9, 2024 05:32
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Oct 9, 2024
Copy link
Contributor

github-actions bot commented Oct 9, 2024

Preview URLs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dataTransfer is null
1 participant