Chonky v2.1.0 Docs
IntroductionInstallation & usageFile Browser demosMigrating from 1.xFAQ
Basics

File action interface

See Defining custom actions page for usage instructions.

FileAction Interface

Source code on GitHub: src/types/action.types.ts

id:string
PropertyRequired

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.

requiresSelection:boolean
PropertyOptional

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.

fileFilter:FileFilter
PropertyOptional

A predicate that determines whether a file should be included in the selection for this action.

hotkeys:string[] | readonly string[]
PropertyOptional

List of hotkeys that should trigger this action, defined using hotkey-js notation.

button:FileActionButton
PropertyOptional

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.

sortKeySelector:FileSortKeySelector
PropertyOptional

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.

fileViewConfig:FileViewConfig
PropertyOptional

When fileViewConfig is specified, triggering this action will apply the provided config to Chonky's file view.

option:FileActionOption
PropertyOptional

When option is specified, the action becomes an option toggle. When the action is activated, the boolean value of the option will be toggled.

selectionTransform:FileSelectionTransform
PropertyOptional

When selection transform is defined, activating this action will update the file selection. If the transform function returns null, selection will be left untouched.

effect:FileActionEffect
PropertyOptional

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.

__payloadType:any
PropertyOptional

Field used to infer the type of action payload. It is used solely for Typescript type inference and action validation.

__extraStateType:any
PropertyOptional

Field used to infer the type of extra state for this action. It is used solely for Typescript type inference and action validation.

If you have a question, want to request a feature or report a bug, please create an issue on GitHub. You can also report inaccurate or unclear documentation on Chonky's Discord server.