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

Fix handling pastes in browsers that don't support ClipboardEvent.clipboardData #162

Merged
merged 2 commits into from Jan 19, 2016

Conversation

javan
Copy link
Contributor

@javan javan commented Jan 19, 2016

Previously when Trix received a paste event with no clipboardData, we'd do nothing and assume the mutation observer would detect the change and cause an HTML re-parse. But because Trix.MutationObserver doesn't deeply traverse nodes, the mutation summary it returns could be empty depending on the pasted HTML. With a little logging, you can see this by inserting HTML into the editor:

$("trix-editor").insertAdjacentHTML("beforeend", "hello")
=> mutationSummary = {"textAdded":"hello"}

$("trix-editor").insertAdjacentHTML("beforeend", "<p>hello</p>")
=> mutationSummary = {}

Instead of doing nothing, we can capture the paste using getPastedHTMLUsingHiddenElement, which a) fixes the problem of nothing pasting at all, and b) allows Trix to format insert the pasted HTML better.

Pasting in IE11 before:
ie11paste

After:
ie11paste-after

javan added a commit that referenced this pull request Jan 19, 2016
Fix handling pastes in browsers that don't support ClipboardEvent.clipboardData
@javan javan merged commit a1ffe00 into master Jan 19, 2016
@javan javan deleted the handle-paste-without-clipboarddata branch January 19, 2016 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant