-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Deprecated the coarse onArrowUp
et al key handler props on DraftEditor.react
to make it possible to produce editor commands from these keys
#1637
Conversation
…itor.react` to make it possible to produce editor commands from these keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steveluscher has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update RichTextEditorUtil.onTab and the rich
examples in examples/
? Sounds great otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steveluscher has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
I updated the examples and the homepage, but I wasn't really sure how to update |
…itor.react` to make it possible to produce editor commands from these keys Summary: Previously, it was impossible to do this: ``` function mapKeysToEditorCommands(e) { if (mentionsAutocompleteIsOpen) { switch (e.keyCode) { case Keys.UP: return 'MentionsAutocomplete/select-previous'; case Keys.DOWN: return 'MentionsAutocomplete/select-next'; } } return getDefaultKeyBinding(e); } <DraftEditor keyBindingFn={mapKeysToEditorCommands} ... /> ``` …because we didn't give TAB, ESCAPE, LEFT, UP, RIGHT, or DOWN a chance to produce a command name. This pull request: 1. deprecates the prop-based key handlers (`onUpArrow` et al.) and encourages people to move their custom key logic into a `keyBindingFn`, and 2. lets the named keypresses fall through to the `keyBindingFn` whenever a prop-based key handler isn't supplied. 3. Updates the homepage and the rich text example.  Closes facebookarchive#1637 Differential Revision: D6864155 fbshipit-source-id: 23efb4caac25b1bc867350a1212f142b5b3ce7ab
It's weird that @steveluscher it looks like you did land this, but the PR was not closed by facebook-github-bot. I'm closing this, if I'm missing something then please open a new PR and we can land it separately. I also opened an internal task to look into why the PR wasn't closed when the imported change landed on master. T25937659 |
…itor.react` to make it possible to produce editor commands from these keys Summary: Previously, it was impossible to do this: ``` function mapKeysToEditorCommands(e) { if (mentionsAutocompleteIsOpen) { switch (e.keyCode) { case Keys.UP: return 'MentionsAutocomplete/select-previous'; case Keys.DOWN: return 'MentionsAutocomplete/select-next'; } } return getDefaultKeyBinding(e); } <DraftEditor keyBindingFn={mapKeysToEditorCommands} ... /> ``` …because we didn't give TAB, ESCAPE, LEFT, UP, RIGHT, or DOWN a chance to produce a command name. This pull request: 1. deprecates the prop-based key handlers (`onUpArrow` et al.) and encourages people to move their custom key logic into a `keyBindingFn`, and 2. lets the named keypresses fall through to the `keyBindingFn` whenever a prop-based key handler isn't supplied. 3. Updates the homepage and the rich text example.  Closes facebookarchive/draft-js#1637 Differential Revision: D6864155 fbshipit-source-id: 23efb4caac25b1bc867350a1212f142b5b3ce7ab
…itor.react` to make it possible to produce editor commands from these keys Summary: Previously, it was impossible to do this: ``` function mapKeysToEditorCommands(e) { if (mentionsAutocompleteIsOpen) { switch (e.keyCode) { case Keys.UP: return 'MentionsAutocomplete/select-previous'; case Keys.DOWN: return 'MentionsAutocomplete/select-next'; } } return getDefaultKeyBinding(e); } <DraftEditor keyBindingFn={mapKeysToEditorCommands} ... /> ``` …because we didn't give TAB, ESCAPE, LEFT, UP, RIGHT, or DOWN a chance to produce a command name. This pull request: 1. deprecates the prop-based key handlers (`onUpArrow` et al.) and encourages people to move their custom key logic into a `keyBindingFn`, and 2. lets the named keypresses fall through to the `keyBindingFn` whenever a prop-based key handler isn't supplied. 3. Updates the homepage and the rich text example.  Closes facebookarchive/draft-js#1637 Differential Revision: D6864155 fbshipit-source-id: 23efb4caac25b1bc867350a1212f142b5b3ce7ab
Previously, it was impossible to do this:
…because we didn't give TAB, ESCAPE, LEFT, UP, RIGHT, or DOWN a chance to produce a command name.
This pull request:
onUpArrow
et al.) and encourages people to move their custom key logic into akeyBindingFn
, andkeyBindingFn
whenever a prop-based key handler isn't supplied.