Editor component renders a side panel (or modal) that lets users view and edit task properties. It connects to the Gantt chart through the shared api object.
Basic setup
1
Import the components
Import both
Gantt and Editor from the package.2
Create a shared api reference
Declare a reactive
api variable and pass it to both components using bind:this on Gantt or the init callback.Editor must receive the same api instance as Gantt. Using bind:this={api} on Gantt is the simplest way to achieve this.Editor props
IApi
The Gantt API object. Connects the editor to the chart so it can read and write task data.
TEditorItem[]
Array of editor field descriptors. Overrides the default set of fields rendered in the panel.
'sidebar' | 'modal'
default:"sidebar"
Controls where the editor appears. Use
"modal" to open it as a centred dialog.boolean
default:"true"
When
true, changes are saved automatically as the user edits fields. Set to false to require an explicit save action.boolean | object
default:"true"
Show or hide the title bar at the top of the editor. Pass
false to remove it entirely.object
Configuration for the button bar at the bottom of the editor. Accepts an
items array of toolbar-style button descriptors.Default editor items
ThedefaultEditorItems array defines the built-in fields shown in the editor. You can import it directly or call getEditorItems() to get a fresh copy that has task-type options populated from the current config.
Editor item fields
Each item in theitems array is an object with the following properties:
string
required
The control type. Built-in values:
"text", "textarea", "date", "counter", "slider", "combo", "select", "multiselect", "radio", "checkbox", "links", "twostate".string
required
The task property this field reads from and writes to.
string
Display label shown above the field.
(value: any) => string
Function that returns a dynamic label based on the current field value.
Record<string, any>
Control-specific configuration options (e.g.
{ format: "%d-%m-%Y" } for date fields, { min: 1, max: 100 } for sliders).Function that returns
true to hide the field for a particular task.(task: Partial<ITask>, state: IData) => boolean
Function that returns
true to disable the field for a particular task and state.Customising the field list
UsegetEditorItems() to start from the defaults, then filter, reorder, or extend the array:
Custom controls
You can register your own Svelte components as editor controls withregisterEditorItem. The registered name is then used as the comp value in an item descriptor.
Field validation
Addrequired to make a field mandatory, or provide a validation function and an optional validationMessage for custom rules:
Readonly mode
To open the editor in a non-editable view, passreadonly to the Gantt component. You can also selectively disable individual fields using the isDisabled callback on each item: