-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Binding left & right arrow keys? #219
Comments
What is your use case? |
I'm trying to listen if the cursor is currently in an inline that has an Entity type of LINK to fire off a popover component to edit the href. This will do a bit more, but for now baby steps. Currently I can achieve this in the onChange event and a little tweak to the 'currentBlockContainsLink' helper. |
If you don't mind positioning the flyout absolutely, outside the
render() {
return (
<div>
<Editor ... />
<LinkMenu editorState={this.state.editorState} />
</div>
);
}
class LinkMenu extends React.Component {
render() {
const isWithinLink = ...;
if (isWithinLink) {
const targetRect = getVisibleSelectionRect(...);
return <div style={/* use targetRect to position */}>...</div>;
}
return <div />;
}
} |
Yup, thats pretty much what I'm doing. :) We can close this issue if you think that binding to the left / right arrow keys is unnecessary or dangerous. Thanks! |
I think they could be exposed the same way as the up and down arrow keys, especially if it allows better keyboard navigation for flyouts. For instance, I could imagine a mentions result dropdown that allows two dimensions of navigation. I haven't seen a need for it yet, so I'm fine with holding off for now. But if anyone should see this issue and want to offer up a PR to solve a need, I'm open to it. :) |
Summary: Exposes right and left keyboard events, as suggested in [this issue](#219) by hellendag. This will greatly simplify some of our arrow handling at [Artsy](https://github.com/artsy/positron/blob/master/client/apps/edit/components/content2/sections/text/index.coffee#L121). The test suite is passing locally. Closes #1384 Differential Revision: D5954003 fbshipit-source-id: 90c3a7d6bb5070c455f56d60ccd64c5ad136fe59
Summary: Exposes right and left keyboard events, as suggested in [this issue](facebookarchive/draft-js#219) by hellendag. This will greatly simplify some of our arrow handling at [Artsy](https://github.com/artsy/positron/blob/master/client/apps/edit/components/content2/sections/text/index.coffee#L121). The test suite is passing locally. Closes facebookarchive/draft-js#1384 Differential Revision: D5954003 fbshipit-source-id: 90c3a7d6bb5070c455f56d60ccd64c5ad136fe59
Doesn't fall through to the default behavior when returning false from a custom key handler. Crawled the source code but couldn't find anywhere this is being handled. I guess I could manually reset the selection every time after Im done listening in. Perhaps theres an easier way?
The text was updated successfully, but these errors were encountered: