editing([index])

Class: Tree.

Description:

Starts editing a specified item, stops editing all items when null is passed, or returns an item currently being edited with its index property.

If no parameters are passed, it returns currently editing item's index or null if no item is being edited at the moment.

Editing state is when a user can type a new text into the item. Only one item can be editing at a time.

Parameters:

Name Type Description

[index]

Array.<number> | null

Index of the item to start editing. Pass null to stop editing currently editing item (if any).

Returns:

If index argument is passed, this Tree component is returned. When no arguments are provided, returns an item being edited at the moment (if any), or null if no item is being edited.

Type: ListItem | null | Tree

Examples:

Starting to edit a specified item:

tree.editing([0, 2]);

Stop editing all items:

tree.editing(null);

Check which item is editing now:

let editedItem = tree.editing(); // -> ListItem or false.
console.log(editedItem.index); // prints the index of the item