Layout Manager

Associates React components with layouts.

You can access a global instance of this class via inkdrop.layouts.

Registering and unregistering a React component

You can register your React component classes to the component registry. Then, the registered components can be added to layouts. Below example registers MyDialog class to the component registry and adds it to modal layout so that you can show it as a modal view.

module.exports = {
  activate() {
    inkdrop.components.registerClass(MyDialog)
    inkdrop.layouts.addComponentToLayout(
      'modal',
      'MyDialog'
    )
  },

  deactivate() {
    inkdrop.layouts.removeComponentFromLayout(
      'modal',
      'MyDialog'
    )
    inkdrop.components.deleteClass(MyDialog)
  }
}

This is described in detail in the Word Count plugin walkthrough.

Available layouts can be found here.

Event Subscription

onLayoutChange(name, callback)

Invoke the given callback when the layout with given name is changed.

Argument Description
callback(components) Function to be called when keystrokes match a binding.
‚ÄÉcomponents An array of component class names that was changed

Return values

Returns a Disposable on which .dispose() can be called to unsubscribe.

Methods

addComponentToLayout(layoutName, componentClassName)

Adds a component to specified layout

Argument Description
layoutName String, a layout name
componentClassName A React class name which is registered in the component registry.

insertComponentToLayoutBefore(layoutName, referenceComponentClassName, componentClassNameToInsert)

Inserts a component before the reference component to specified layout

Argument Description
layoutName String, a layout name
referenceComponentClassName A React class name before which componentClassName is inserted.
componentClassName A React class name which is registered in the component registry.

insertComponentToLayoutAfter(layoutName, referenceComponentClassName, componentClassNameToInsert)

Inserts a component after the reference component to specified layout

Argument Description
layoutName String, a layout name
referenceComponentClassName A React class name after which componentClassName is inserted.
componentClassName A React class name which is registered in the component registry.

getLayout(name)

Returns a set of components of the specified layout

Argument Description
name A name of the layout to get

Return values

An array of component class names

getLayoutComponents(name)

Returns a set of React component classes of the specified layout

Argument Description
name A name of the layout to get

Return values

An array of React component classes

indexOfComponentInLayout(layoutName, componentClassName)

Returns the first index at which a given component can be found in the specified layout, or -1 if cannot found.

Argument Description
layoutName String, a layout name
componentClassName A React class name to search.

Return values

Number

removeComponentFromLayout(layoutName, componentClassName)

Removes a component from specified layout

Argument Description
layoutName String, a layout name
componentClassName A React class name which is registered in the component registry.

setLayout(name, components)

Sets a set of components to the specified layout

Argument Description
name A name of the layout to be set
components An array of component class names

Can you help us improve these docs?

The source of these docs is here on GitHub. If you see a way these docs can be improved, please fork us!