You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -148,6 +149,7 @@ The only *required* value is `data` (although you will need to provide a `setDat
148
149
|`jsonParse`|`(input: string) => JsonData`|`JSON.parse`| When editing a block of JSON directly, you may wish to allow some "looser" input -- e.g. 'single quotes', trailing commas, or unquoted field names. In this case, you can provide a third-party JSON parsing method. I recommend [JSON5](https://json5.org/), which is what is used in the [Demo](https://carlosnz.github.io/json-edit-react/)|
149
150
|`jsonStringify`|`(data: JsonData) => string`|`(data) => JSON.stringify(data, null, 2)`| Similarly, you can override the default presentation of the JSON string when starting editing JSON. You can supply different formatting parameters to the native `JSON.stringify()`, or provide a third-party option, like the aforementioned JSON5. |
150
151
|`errorMessageTimeout`|`number`|`2500`| Time (in milliseconds) to display the error message in the UI. ||
152
+
|`keyboardControls`|`KeyboardControls`| As explained [above](#usage)| Override some or all of the keyboard controls. See [Keyboard customisation](#keyboard-customisation) for details. ||
151
153
152
154
## Managing state
153
155
@@ -655,6 +657,44 @@ customText = {
655
657
}
656
658
```
657
659
660
+
## Keyboard customisation
661
+
662
+
The default keyboard controls are [outlined above](#usage), but it's possible to customise/override these. Just pass in a `keyboardControls` prop with the actions you wish to override defined. The default config object is:
663
+
```ts
664
+
{
665
+
confirm: 'Enter', // default for all Value nodes, and key entry
If (for example), you just wish to change the general "confirmation" action to "Cmd-Enter" (on Mac), or "Ctrl-Enter", you'd just pass in:
681
+
```ts
682
+
keyboardControls = {
683
+
confirm: {
684
+
key: "Enter",
685
+
modifier: [ "Meta", "Control" ]
686
+
}
687
+
}
688
+
```
689
+
690
+
**Considerations**:
691
+
692
+
- Key names come from [this list](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values)
693
+
- Accepted modifiers are "Meta", "Control", "Alt", "Shift"
694
+
- On Mac, "Meta" refers to the "Cmd" key, and "Alt" refers to "Option"
695
+
- If multiple modifiers are specified (in an array), *any* of them will be accepted (multi-modifier commands not currently supported)
696
+
- You only need to specify values for `stringConfirm`, `numberConfirm`, and `booleanConfirm` if they should *differ* from your `confirm` value.
697
+
- You won't be able to override system or browser behaviours: for example, on Mac "Ctrl-click" will perform a right-click, so using it as a click modifier won't work (hence we also accept "Meta"/"Cmd" as the default `clipboardModifier`).
658
698
659
699
## Undo functionality
660
700
@@ -691,6 +731,7 @@ A few helper functions, components and types that might be useful in your own im
691
731
- `ValueNodeProps`: all props passed internally to "value" nodes (i.e. *not* objects/arrays)
692
732
- `CustomNodeProps`: all props passed internally to [Custom nodes](#custom-nodes); basically the same as `CollectionNodeProps` with an extra `customNodeProps` field for passing props unique to your component`
0 commit comments