I've successfully implemented an "Edit Node" feature for your JSON editor that allows users to select a node in the visualization graph and edit its contents directly. When saved, changes are reflected both in the graph visualization and in the JSON text editor on the left.
A new React modal component that provides a user interface for editing node data with the following features:
- Display Current Value: Shows the current node data before editing
- Edit Key: Allows changing the property key (if applicable)
- Type Selector: Choose between String, Number, and Boolean types
- Value Input: Input field or dropdown selector based on the chosen type
- Error Handling: Displays validation errors with user-friendly messages
- Cancel Button: Discards changes and closes the modal
- Save Button: Validates, saves changes, and updates both the visualization and JSON
The EditNodeModal has been automatically registered in the modal system by adding it to src/features/modals/index.ts, making it available throughout the application.
Added an "Edit" button in the bottom status bar with:
- Visual Icon: Edit icon (pencil) for intuitive UX
- Smart Enable/Disable: Button is disabled when no node is selected
- Tooltip: Shows helpful text when hovering over the button
- Accessibility: Only enabled when a node is selected
- Select a Node: Click on any node in the graph visualization
- Open Edit Modal: Click the "Edit" button in the bottom bar (or use the keyboard shortcut if configured)
- Modify Data:
- Change the property key (if present)
- Select the data type (String, Number, Boolean)
- Enter the new value
- Save or Cancel:
- Click Save: Updates are applied to both graph and JSON
- Click Cancel: Changes are discarded
User clicks Edit Button
↓
EditNodeModal opens with selected node data
↓
User modifies values
↓
User clicks Save
↓
Values are parsed and validated
↓
JSON object is updated at the selected path
↓
Updates propagate to:
- useJson store (JSON state)
- useFile store (text editor contents)
- useGraph store (triggers graph rebuild)
↓
Modal closes
↓
UI reflects all changes
BottomBar (contains Edit button)
↓
ModalController (renders all modals including EditNodeModal)
↓
EditNodeModal (handles editing UI and logic)
↓
useGraph (selected node state)
useJson (JSON data state)
useFile (text editor content state)
parseValue(value: string, type: string): EditValue
- Converts user input to the correct JavaScript type
- Validates input (e.g., numeric strings, boolean values)
- Throws errors for invalid inputs
updateJsonAtPath(jsonObj, path, newValue, newKey?): object
- Navigates to the node location using the JSONPath
- Updates or replaces the key if specified
- Maintains JSON structure integrity
- Returns the updated object
handleSave()
- Validates all inputs
- Parses and type-converts the new value
- Updates the JSON object
- Propagates changes to all stores
- Rebuilds the graph visualization
The feature uses existing Zustand stores for state management:
- useGraph: Manages
selectedNodestate - useJson: Manages overall JSON content
- useFile: Manages text editor contents and tracks changes
- useModal: Controls modal visibility
✅ Edit Button appears in the UI - Visible in the bottom status bar ✅ Edit Mode - Click edit button to enter edit mode ✅ Save button - Saves changes to node visualization and JSON ✅ Cancel button - Discards any unsaved changes ✅ Type Support - String, Number, Boolean types ✅ Validation - Input validation with error messages ✅ Smart Button State - Button disabled when no node selected ✅ Bidirectional Sync - Changes sync between graph and JSON editor
- Array and Object Support: Extend to handle editing arrays and objects
- Keyboard Shortcut: Add a keyboard shortcut (e.g.,
Ctrl+E) to open edit mode - Inline Editing: Add double-click support for inline editing in the graph
- Undo/Redo: Integrate with browser history API for undo/redo functionality
- Search & Replace: Add find/replace functionality for multiple edits
- Data Validation: Support for custom validation rules or JSON schema constraints
- Confirmation Dialog: Add a confirmation before overwriting values
- Select a node in the graph
- Verify "Edit" button becomes enabled
- Click "Edit" to open the modal
- Change the value and click Save
- Verify the node updates in the graph
- Verify the JSON text editor reflects the changes
- Try clicking Cancel to discard changes
- Test with different data types (string, number, boolean)
- Try with invalid input to see error handling
- Created:
src/features/modals/EditNodeModal/index.tsx - Modified:
src/features/modals/index.ts(added export) - Modified:
src/features/editor/BottomBar.tsx(added Edit button)