<Editor> component provides a form-based UI for editing task properties. It connects to the Gantt through a shared API instance, reads the currently selected task from the store, and dispatches update-task and delete-task actions when the user makes changes.
Wiring up the Editor
The minimum setup requires two things: exposing the Gantt API via theinit prop and passing that API to <Editor>.
GanttWithEditor.jsx
Render
<Editor> conditionally ({api && <Editor api={api} />}) so it only mounts after the Gantt has initialised and the API is available.add-task action (so newly created tasks are immediately editable), listen to the event inside init:
Sidebar vs modal placement
Theplacement prop on <Editor> controls where the form appears. The default is 'sidebar', which renders it as a panel alongside the chart. Use 'modal' to display it as an overlay dialog.
- Modal
Configuring editor fields
By default the editor shows all standard fields (name, type, start, end, duration, progress, details, links). UsegetEditorItems() to retrieve those defaults and customise them.
Selecting a subset of fields
Adding a custom field
Each item in theitems array is a field descriptor with at least a key, a comp (the registered editor control type), and a label.
comp types are: text, date, counter, slider, twostate, select, links.
Registering custom editor controls
registerEditorItem(name, Component) maps a string key to any React component, making it available as a comp type in field descriptors. Call it once at module level (or inside a useEffect with an empty dependency array).
@svar-ui/react-core is automatically installed as a dependency of @svar-ui/react-gantt. You do not need to add it to your package.json separately.Validation
Addrequired and validation / validationMessage to any field descriptor. Validation runs on every change when autoSave is true, and on save when autoSave is false.
Read-only mode
You can make either the whole Gantt or just the Editor read-only.- Read-only Gantt
- Read-only Editor
Hotkeys
The Gantt chart registers keyboard shortcuts globally while the chart is in focus. None of the hotkeys fire when the cursor is inside an<input> or <textarea>.
| Hotkey | Action |
|---|---|
Delete | Delete the selected task(s) |
Tab | Indent the selected task (make it a child of the task above) |
Shift+Tab | Outdent the selected task |
Ctrl+Z | Undo (requires undo={true} on <Gantt>) |
Ctrl+Y | Redo (requires undo={true} on <Gantt>) |
Ctrl+Z / Ctrl+Y for undo/redo when the undo prop is enabled on <Gantt>. These are registered via the hotkeys prop on <Editor>:
Hotkeys are processed in last-registered-first order. Returning early from a handler prevents lower-priority handlers from firing. Hotkeys do not fire while focus is inside an
<input> or <textarea>.Editor props reference
| Prop | Type | Default | Description |
|---|---|---|---|
api | IApi | — | Required. The API instance obtained from <Gantt init={...}>. |
items | array | [] | Custom field list. Falls back to getEditorItems() defaults when empty. |
placement | 'sidebar' | 'modal' | 'sidebar' | Where the editor renders. |
layout | string | 'default' | Layout variant for the editor panel. |
autoSave | boolean | true | When true, saves each field change immediately. |
readonly | boolean | false | Renders field values as plain text; hides the Delete button. |
topBar | boolean | object | true | Top bar config. false hides it; an object overrides buttons. |
bottomBar | boolean | object | true | Bottom bar config. |
focus | boolean | false | Auto-focuses the first editable field on open. |
hotkeys | object | {} | Additional hotkey handlers merged with the built-in undo/redo bindings. |