File action interface
See Defining custom actions page for usage instructions.
FileAction
Interface
Source code on GitHub: src/types/action.types.ts
Unique file action ID. If you set the action ID to one of the built-in Chonky action action IDs, you custom action definition will override the built-in definition.
When set to true
, the action will only be active (dispatchable) when user
selects one or more files. If fileFilter
is defined, it will be applied to
selection before checking if its empty.
A predicate that determines whether a file should be included in the selection for this action.
List of hotkeys that should trigger this action, defined using hotkey-js
notation.
When button is defined and toolbar
or contextMenu
is set to true
, a
button will be added to the relevant UI component. Clicking on this button
will active this action. The appearance of the button will change based on
the action definition and the current Chonky state.
When sortKeySelector
is specified, the action becomes a sorting toggle. When
this action is activated, it will sort files using the key selector, toggling
between Ascending and Descending orders.
When fileViewConfig
is specified, triggering this action will apply the
provided config to Chonky's file view.
When option
is specified, the action becomes an option toggle. When the action
is activated, the boolean value of the option will be toggled.
When selection transform is defined, activating this action will update the file
selection. If the transform function returns null
, selection will be left
untouched.
When effect is defined, it will be called right before dispatching the action to
the user defined action handler. If the effect function returns a promise, Chonky
will wait for the promise to resolve or fail before dispatching the action to the
handler. If this function returns true
, the file action will NOT be dispatched
the the handler.
Field used to infer the type of action payload. It is used solely for Typescript type inference and action validation.
Field used to infer the type of extra state for this action. It is used solely for Typescript type inference and action validation.