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

Add Key, test for printable character on keydown when selection #77

Merged
merged 1 commit into from Aug 17, 2015

Conversation

bantic
Copy link
Collaborator

@bantic bantic commented Aug 13, 2015

Uses a whitelist of keycodes to determine if a character is printable.
There will probably need to be additions to that heuristic in the future,
but this feels pretty reasonable for a first approach.

This fixes the issue of content editable adding garbage HTML when you select two text nodes
that have different styling (e.g., part of a heading and part of a plain-text section) and
hit a character. Chrome inserts a span to try to preserve the styling of the plain-text
when it removes the selection and joins the plain-text to the heading.

Fixes #50

cc @mixonic

mixonic added a commit that referenced this pull request Aug 17, 2015
Add `Key`, test for printable character on keydown when selection
@mixonic mixonic merged commit 5c4ffa6 into master Aug 17, 2015
@mixonic mixonic deleted the handle-keystroke-50 branch August 17, 2015 16:24
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.

handle keystrokes when there is a selection
2 participants