Skip to content

Commit cae5bef

Browse files
committed
Update type definitions, docs
1 parent a50bc0b commit cae5bef

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,14 @@ In addition to the "Copy", "Edit" and "Delete" buttons that appear by each value
254254

255255
```js
256256
{
257-
Element: React.FC,
258-
onClick: (nodeData: NodeData, e: React.MouseEvent) => void
257+
Element: React.FC<{ nodeData: NodeData }>,
258+
onClick?: (nodeData: NodeData, e: React.MouseEvent) => void
259259
}
260260
```
261261
Where `NodeData` is the same data structure received by the previous "Update Functions".
262262

263+
The `onClick` is optional -- don't provide it if you have your own `onClick` handler within your button component.
264+
263265
## Filter functions
264266

265267
You can control which nodes of the data structure can be edited, deleted, or added to, or have their data type changed, by passing Filter functions. These will be called on each property in the data and the attribute will be enforced depending on whether the function returns `true` or `false` (`true` means *cannot* be edited).

src/ButtonPanels.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export const EditButtons: React.FC<EditButtonProps> = ({
126126
</div>
127127
)}
128128
{customButtons?.map(({ Element, onClick }, i) => (
129-
<div key={i} onClick={(e) => onClick(nodeData, e)}>
129+
<div key={i} onClick={(e) => onClick && onClick(nodeData, e)}>
130130
<Element nodeData={nodeData} />
131131
</div>
132132
))}

src/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ export interface CustomNodeDefinition<T = Record<string, unknown>, U = Record<st
284284
export type CustomTextDefinitions = Partial<{ [key in keyof LocalisedStrings]: CustomTextFunction }>
285285

286286
export interface CustomButtonDefinition {
287-
Element: React.FC
288-
onClick: (nodeData: NodeData, e: React.MouseEvent) => void
287+
Element: React.FC<{ nodeData: NodeData }>
288+
onClick?: (nodeData: NodeData, e: React.MouseEvent) => void
289289
}
290290

291291
export interface InputProps {

0 commit comments

Comments
 (0)