Namespace: editables

Granite.author. editables

The Editable Store (array based) that contains all the Editables available on the page.
The store is sorted based on the content resource structure.

Initialized by Document#event:cq-editables-loaded; available on Document#event:cq-editor-loaded

Source:
storage/editables.js

Methods


add(editables, config)

Adds the passed Editables to the store

Parameters:
Name Type Description
editables Array.<Granite.author.Editable>

Editables to be added to the store (replaces if already existing)

config Object

Configuration object that specifies the position where the editables should be added

Properties
Name Type Description
insertBehavior string

Order in which the component must be inserted {@see Granite.author.persistence.PARAGRAPH_ORDER}

editableNeighbor Granite.author.Editable

The targeted Granite.author.Editable neighbor

Source:
storage/editables.js
Fires:

clean()

Destroys all Editables from the store, and empties the store

Source:
storage/editables.js
Fires:

find(search)

Returns the stored Editables according to the search parameter

Parameters:
Name Type Description
search Object | String

Either a complex search or the path as a string

Source:
storage/editables.js
Returns:

Returns an array of found Editables

Type
Array.<Granite.author.Editable>

getChildren(editable, all)

Returns the children of the passed Editable

Parameters:
Name Type Description
editable Granite.author.Editable

The Editable parent

all Boolean

All the children or only the direct descendant

Source:
storage/editables.js
Returns:

Returns all the children of the Editable

Type
Array.<Granite.author.Editable>

getParent(editable [, all])

Returns the parent of the passed Editable

Parameters:
Name Type Argument Description
editable Granite.author.Editable

The Editable child

all Boolean <optional>

Indicates if we want to receive an array of all parents

Source:
storage/editables.js
Returns:

Returns the parent(s) of the given Editable or null

Type
Granite.author.Editable | Array.<Granite.author.Editable>

getRoot()

Returns the root of the tree of Editables

Source:
storage/editables.js
Returns:

Returns the root of the tree of Editables

Type
Granite.author.Editable

getSelectableParents(editable)

Returns the selectable parents (= those with actions available on them) of the passed Editable

Parameters:
Name Type Description
editable Granite.author.Editable

The Editable child

Source:
storage/editables.js
Returns:

Returns all the selectable parents of the Editable or null

Type
Array.<Granite.author.Editable>

move(editable, config)

Move the passed Editable to another position in the store

Parameters:
Name Type Description
editable Granite.author.Editable

Editable to be moved

config Object

Configuration object that specifies the new position where the editable should be moved

Properties
Name Type Description
insertBehavior string

Order in which the component must be inserted {@see Granite.author.persistence.PARAGRAPH_ORDER}

editableNeighbor Granite.author.Editable

The targeted Granite.author.Editable neighbor

Source:
storage/editables.js
Fires:

onReady(path, listener)

Registers a listener that would be executed when the Editable (at the given path) is ready

Parameters:
Name Type Description
path String

The path of the Editable

listener function

The listener function

Source:
storage/editables.js

onTypeReady(type, listener)

Registers a listener that would be executed when the Editable (of the given type) is ready

Parameters:
Name Type Description
type String

The type (sling resource type) of the Editable

listener function

The listener function

Source:
storage/editables.js

remove(editable, removeChildren)

Removes the passed Editables from the store

Parameters:
Name Type Description
editable Array.<Granite.author.Editable> | Granite.author.Editable

The Editables to remove

removeChildren Boolean

Indicates if it should remove the children of the Editables too

Source:
storage/editables.js
Fires:

set(editables)

Initializes the store with the passed Editables (cleans the store first)

Parameters:
Name Type Description
editables Array.<Granite.author.Editable>

The ordered (parent to children) Editables to be added in the store.

Source:
storage/editables.js
Fires: