From cb0b9b909567933e5007e1245906b1943c3a2ca6 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Thu, 18 Aug 2016 09:40:18 -0700 Subject: [PATCH] update keydown handler signature (#254) * update keydown handler signature * Update applying-custom-formatting.md * Update defining-custom-block-nodes.md * Update saving-to-a-database.md * Update using-plugins.md --- docs/walkthroughs/adding-event-handlers.md | 8 ++++---- docs/walkthroughs/applying-custom-formatting.md | 12 ++++++------ docs/walkthroughs/defining-custom-block-nodes.md | 16 ++++++++-------- docs/walkthroughs/saving-to-a-database.md | 4 ++-- docs/walkthroughs/using-plugins.md | 8 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/walkthroughs/adding-event-handlers.md b/docs/walkthroughs/adding-event-handlers.md index 9f6e00137..4935898b5 100644 --- a/docs/walkthroughs/adding-event-handlers.md +++ b/docs/walkthroughs/adding-event-handlers.md @@ -46,13 +46,13 @@ class App extends React.Component { this.setState({ state })} - onKeyDown={(e, state) => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } // Define a new handler which prints the key code that was pressed. - onKeyDown(event, state) { + onKeyDown(event, data, state) { console.log(event.which) } @@ -77,12 +77,12 @@ class App extends React.Component { this.setState({ state })} - onKeyDown={(e, state) => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { // Return with no changes if it's not the "7" key with shift pressed. if (event.which != 55 || !event.shiftKey) return diff --git a/docs/walkthroughs/applying-custom-formatting.md b/docs/walkthroughs/applying-custom-formatting.md index 293f25778..a2ce6ea58 100644 --- a/docs/walkthroughs/applying-custom-formatting.md +++ b/docs/walkthroughs/applying-custom-formatting.md @@ -29,12 +29,12 @@ class App extends React.Component { state={this.state.state} state={this.state.state} onChange={state => this.setState({ state })} - onKeyDown={e, state => this.onKeyDown(e, state)} + onKeyDown={e, data, state => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { if (event.which != 192 || !event.metaKey) return const isCode = state.blocks.some(block => block.type == 'code') @@ -68,12 +68,12 @@ class App extends React.Component { schema={this.state.schema} state={this.state.state} onChange={state => this.setState({ state })} - onKeyDown={(e, state) => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { if (!event.metaKey) return // Decide what to do based on the key code... @@ -141,12 +141,12 @@ class App extends React.Component { schema={this.state.schema} state={this.state.state} onChange={state => this.setState({ state })} - onKeyDown={(e, state) => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { if (!event.metaKey) return switch (event.which) { diff --git a/docs/walkthroughs/defining-custom-block-nodes.md b/docs/walkthroughs/defining-custom-block-nodes.md index ab7af673a..687f8c25e 100644 --- a/docs/walkthroughs/defining-custom-block-nodes.md +++ b/docs/walkthroughs/defining-custom-block-nodes.md @@ -23,12 +23,12 @@ class App extends React.Component { this.setState({ state })} - onKeyDown={(e, state) => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { if (event.which != 55 || !event.shiftKey) return const newState = state @@ -87,12 +87,12 @@ class App extends React.Component { schema={this.state.schema} state={this.state.state} onChange={state => this.setState({ state })} - onKeyDown={e, state => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { if (event.which != 55 || !event.shiftKey) return const newState = state @@ -130,12 +130,12 @@ class App extends React.Component { schema={this.state.schema} state={this.state.state} onChange={state => this.setState({ state })} - onKeyDown={e, state => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { // Return with no changes if it's not the "`" key with cmd/ctrl pressed. if (event.which != 192 || !event.metaKey) return @@ -176,12 +176,12 @@ class App extends React.Component { schema={this.state.schema} state={this.state.state} onChange={state => this.setState({ state })} - onKeyDown={e, state => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { if (event.which != 192 || !event.metaKey) return // Determine whether any of the currently selected blocks are code blocks. diff --git a/docs/walkthroughs/saving-to-a-database.md b/docs/walkthroughs/saving-to-a-database.md index ad9bb6205..32e00b682 100644 --- a/docs/walkthroughs/saving-to-a-database.md +++ b/docs/walkthroughs/saving-to-a-database.md @@ -135,7 +135,7 @@ class App extends React.Component { this.onChange(state)} - onDocumentChange={state => this.onDocumentChange(document, state)} + onDocumentChange={(document, state) => this.onDocumentChange(document, state)} /> ) } @@ -182,7 +182,7 @@ class App extends React.Component { this.onChange(state)} - onDocumentChange={state => this.onDocumentChange(document, state)} + onDocumentChange={(document, state) => this.onDocumentChange(document, state)} /> ) } diff --git a/docs/walkthroughs/using-plugins.md b/docs/walkthroughs/using-plugins.md index 3cd9bbdd3..1b8644fbd 100644 --- a/docs/walkthroughs/using-plugins.md +++ b/docs/walkthroughs/using-plugins.md @@ -31,12 +31,12 @@ class App extends React.Component { schema={this.state.schema} state={this.state.state} onChange={state => this.setState({ state })} - onKeyDown={(e, state) => this.onKeyDown(e, state)} + onKeyDown={(e, data, state) => this.onKeyDown(e, data, state)} /> ) } - onKeyDown(event, state) { + onKeyDown(event, data, state) { if (!event.metaKey || event.which != 66) return return state .transform() @@ -68,7 +68,7 @@ function MarkHotkey(options) { // Return our "plugin" object, containing the `onKeyDown` handler. return { - onKeyDown(event, state) { + onKeyDown(event, data, state) { // Check that the key pressed matches our `code` option. if (!event.metaKey || event.which != code) return @@ -199,7 +199,7 @@ function MarkHotkey(options) { const { type, key } = options return { - onKeyDown(event, state) { + onKeyDown(event, data, state) { // Change the comparison to use the key name. if (!event.metaKey || keycode(event.which) != key) return return state