Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Pass eventTimeStamp to 'handleKeyPress' to allow tracking
Browse files Browse the repository at this point in the history
Summary:
For purposes of logging, so that we can get the exact timestamp from the event
object for this event.

Reviewed By: dwwoelfel

Differential Revision: D7955262

fbshipit-source-id: b905088a28abc0b1c18ce55cf7d1651674e3fa64
  • Loading branch information
flarnie authored and facebook-github-bot committed May 10, 2018
1 parent b86b5ce commit 0ecf9a6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/APIReference-Editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ rendered list of results to trigger applying the mention entity to your content.

#### handleKeyCommand
```
handleKeyCommand?: (command: string, editorState: EditorState) => DraftHandleValue
handleKeyCommand?: (command: string, editorState: EditorState, eventTimeStamp: number) => DraftHandleValue
```
Handle the named editor command. See
[Advanced Topics: Key Bindings](/docs/advanced-topics-key-bindings.html)
Expand Down
1 change: 1 addition & 0 deletions src/component/base/DraftEditorProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export type DraftEditorProps = {
handleKeyCommand?: (
command: DraftEditorCommand | string,
editorState: EditorState,
eventTimeStamp: number,
) => DraftHandleValue,

// Handle intended text insertion before the insertion occurs. This may be
Expand Down
4 changes: 3 additions & 1 deletion src/component/handlers/edit/editOnKeyDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ function editOnKeyDown(editor: DraftEditor, e: SyntheticKeyboardEvent<>): void {
// Allow components higher up the tree to handle the command first.
if (
editor.props.handleKeyCommand &&
isEventHandled(editor.props.handleKeyCommand(command, editorState))
isEventHandled(
editor.props.handleKeyCommand(command, editorState, e.timeStamp),
)
) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/model/modifier/RichTextEditorUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const RichTextEditorUtil = {
handleKeyCommand: function(
editorState: EditorState,
command: DraftEditorCommand | string,
eventTimeStamp: ?number,
): ?EditorState {
switch (command) {
case 'bold':
Expand Down

0 comments on commit 0ecf9a6

Please sign in to comment.