Skip to content

Commit

Permalink
feat: passing path to Editor for better customizability
Browse files Browse the repository at this point in the history
  • Loading branch information
pionxzh committed Aug 13, 2024
1 parent 48c1a13 commit f03ab10
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/pages/how-to/data-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ For advanced use cases, you can provide `PreComponent` and `PostComponent` to re
#### `Editor`

To enable editing for a data type, you need to provide `serialize` and `deserialize` functions to convert the value to and from a string representation. You can then use the `Editor` component to provide a custom editor for the stringified value. When the user edits the value, it will be parsed using `deserialize`, and the result will be passed to the `onChange` callback.

- `props.path` - The path to the value.
- `props.value` - The value to edit.
- `props.setValue` - A function that can be used to update the value.
- `props.abortEditing` - A function that can be used to abort editing.
Expand Down
1 change: 1 addition & 0 deletions src/components/DataKeyPair.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ export const DataKeyPair: FC<DataKeyPairProps> = (props) => {
(editing && editable)
? (Editor && (
<Editor
path={path}
value={tempValue}
setValue={setTempValue}
abortEditing={abortEditing}
Expand Down
1 change: 1 addition & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface DataItemProps<ValueType = unknown> {
}

export type EditorProps<ValueType = unknown> = {
path: Path
value: ValueType
setValue: Dispatch<ValueType>
abortEditing: () => void
Expand Down

0 comments on commit f03ab10

Please sign in to comment.