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 2 commits into from Jan 19, 2016


Copy link

@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:


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
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
@javan javan deleted the handle-paste-without-clipboarddata branch Jan 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant