Dockable
API reference

Actions

Every model change is an action. The creators, their type constants and their data.

"Action creators for FlexLayout model mutations." Each static method of Actions (from @fragiola/dockable) returns an Action. Dispatch it with engine.doAction(action) (through onAction); see The model and actions.

import { Actions, DockLocation } from "@fragiola/dockable";

engine.doAction(Actions.addTab({ type: "tab", name: "Log", component: "log" }, "ts1", DockLocation.BOTTOM, -1));
engine.doAction(Actions.group([Actions.deleteTab("a"), Actions.deleteTab("b")]));

In onAction, compare action.type with the constants (Actions.DELETE_TAB, …). Their values are FlexLayout's ("FlexLayout_DeleteTab", …). action.data holds the creator's arguments under the names listed below; location is stored as its name ("center", "top", …), read it back with DockLocation.getByName(action.data.location).

DockLocation values: DockLocation.CENTER, TOP, BOTTOM, LEFT, RIGHT. For addTab and moveNode, CENTER adds to the target tabset at index (-1 appends); the others split the target and create a new tabset on that side (or, with a row as the target, dock along its edge).

Tabs

creatortype constantaction.datadescription
addTab(json: IJsonTabNode, toNodeId: string, location: DockLocation, index: number, select?: boolean)ADD_TABjson, toNode, location, index, selectAdds a tab node to the given tabset node
deleteTab(tabNodeId: string)DELETE_TABnodeDeletes a tab node from the layout
renameTab(tabNodeId: string, text: string)RENAME_TABnode, textChange the given nodes tab text
selectTab(tabNodeId: string)SELECT_TABtabNodeSelects the given tab in its parent tabset
setTabPinned(tabNodeId: string, pinned: boolean)SET_TAB_PINNEDnode, pinnedPins or unpins the given tab; pinning moves it to the end of the pinned group at the start of its tabset's tabstrip, unpinning moves it to the start of the unpinned tabs. Only applies to tabs in tabsets (ignored for border tabs).
moveNode(fromNodeId: string, toNodeId: string, location: DockLocation, index: number, select?: boolean)MOVE_NODEfromNode, toNode, location, index, selectMoves a node (tab or tabset) from one location to another
addNode(json: IJsonTabNode, toNodeId: string, location: DockLocation, index: number, select?: boolean)ADD_TABsame as addTabDeprecated: use addTab instead.

Tabsets and rows

creatortype constantaction.datadescription
setActiveTabset(tabsetNodeId: string | undefined, layoutId?: string | undefined)SET_ACTIVE_TABSETtabsetNode, layoutIdSet the given tabset node as the active tabset
deleteTabset(tabsetNodeId: string)DELETE_TABSETnodeDeletes a tabset node and all it's child tab nodes from the layout
maximizeToggle(tabsetNodeId: string, layoutId?: string | undefined)MAXIMIZE_TOGGLEnode, layoutIdMaximizes the given tabset
adjustWeights(nodeId: string, weights: number[])ADJUST_WEIGHTSnodeId, weightsAdjust the weights of a row, used when the splitter is moved

Attributes

creatortype constantaction.datadescription
updateModelAttributes(attributes: IGlobalAttributes)UPDATE_MODEL_ATTRIBUTESjsonUpdates the global model jsone attributes
updateNodeAttributes(nodeId: string, attributes: | IRowAttributes | ITabSetAttributes | ITabAttributes | ITabGroupAttributes | IBorderAttributes)UPDATE_NODE_ATTRIBUTESnode, jsonUpdates the given nodes json attributes
updateSubLayoutAttributes(layoutId: string, attributes: ISubLayoutAttributes)UPDATE_SUBLAYOUT_ATTRIBUTESlayoutId, jsonUpdates the given sublayout's json attributes

Popout windows

Use type "window" (the default). "float" layouts are kept in the model but not rendered yet.

creatortype constantaction.datadescription
popoutTab(nodeId: string, type: ILayoutType = "window")POPOUT_TABnode, typePops out the given tab node into a new browser window or floating panel
popoutTabset(nodeId: string, type: ILayoutType = "window")POPOUT_TABSETnode, typePops out the given tabset node into a new browser window or floating panel
closePopout(layoutId: string)CLOSE_POPOUTlayoutIdCloses the popout. For a window layout this is FlexLayout's conversion into a float, which is not rendered yet; see Popouts
createPopout(layout: IJsonRowNode, rect: IJsonRect, type: ILayoutType)CREATE_SUBLAYOUTsame as createSubLayoutCreates a new empty popout window with the given layout (alias for createSubLayout)
createSubLayout(layout: IJsonRowNode, rect: IJsonRect, type: ILayoutType)CREATE_SUBLAYOUTlayout, rect, typeCreates a new sublayout with the given layout

Batches

creatortype constantaction.datadescription
group(actions: Action[])GROUPthe actions (as data) and actionsGroups multiple actions into a single GroupAction. When performed, the model applies the contained actions in sequence between a single onBeforeAction/onAfterAction listener pair, so the batch is a single undo step and a single entry in an action log.

Borders, floats and tab groups

setBorderType and adjustBorderSplit act on borders, which Dockable.Borders renders (see Borders). The float and tab group actions are applied by the model (they are ported from FlexLayout and unit-tested), but no primitive renders floats or tab groups yet, so their effect is not visible. See Limitations.

creatortype constantaction.datadescription
setBorderType(borderNodeId: string, borderType: "split" | "overlay")SET_BORDER_TYPEnode, borderTypeSets the display type of the given border. In 'overlay' mode the selected tab's panel overlays the main layout area instead of insetting it (Visual Studio style auto hide), and is deselected by a pointer-down in the main layout area.
adjustBorderSplit(nodeId: string, size: number)ADJUST_BORDER_SPLITnode, sizeAdjust the size of the border
movePopoutToFront(layoutId: string)MOVE_FLOAT_TO_FRONTlayoutIdMoves a floating panel popout to the front of the display
moveFloat(layoutId: string, rect: Rect)MOVE_FLOATlayoutId, rectMoves a floating panel
popoutFloat(layoutId: string, rect?: IJsonRect)POPOUT_FLOATlayoutId, rectConverts a floating panel into a native popout window (the reverse of closePopout). The layout keeps its id and content; the given rect should be in screen coordinates.
dockFloatToLayout(layoutId: string, toNodeId: string, location: DockLocation, index: number)DOCK_FLOAT_TO_LAYOUTlayoutId, toNode, location, indexDocks a floating panel's whole layout into another layout.
addTabToNewGroup(tabNodeId: string, name?: string, color?: string)ADD_TAB_TO_NEW_GROUPnode, name, colorCreates a new group in the tab's parent tabset/border and moves the tab into it. The group is inserted at the tab's position, so the tab becomes the first (and initially only) member.
ungroup(groupNodeId: string)UNGROUPnodeMoves every tab of the given group back into the group's parent tabset/border (at the group's position) and deletes the now-empty group. The group's color/name is lost.
removeTabFromGroup(tabNodeId: string)REMOVE_TAB_FROM_GROUPnodeMoves a tab out of its group into the group's parent tabset/border, directly after the group. The group is deleted if it becomes empty.

The Action object

memberdescription
typethe type constant
datathe creator's arguments
isAdjusting()true for the intermediate adjustWeights of a live splitter drag (the gesture ends with a non-adjusting action)
setAdjusting(adjusting)marks an action as adjusting
userData / setUserData(data)any value you attach (for example to mark an action you re-dispatch after a confirmation)
toJSON()a plain { type, data } object (with userData when set), for logs

GroupAction (from Actions.group) has actions: the contained actions, applied in order between a single onBeforeAction/onAfterAction pair: one undo step, one log entry.

Type constants

ADD_TAB, DELETE_TAB, RENAME_TAB, SET_TAB_PINNED, SET_BORDER_TYPE, SELECT_TAB, MOVE_NODE, DELETE_TABSET, SET_ACTIVE_TABSET, ADJUST_WEIGHTS, ADJUST_BORDER_SPLIT, MAXIMIZE_TOGGLE, UPDATE_MODEL_ATTRIBUTES, UPDATE_NODE_ATTRIBUTES, UPDATE_SUBLAYOUT_ATTRIBUTES, POPOUT_TAB, POPOUT_TABSET, CLOSE_POPOUT, MOVE_FLOAT_TO_FRONT, MOVE_FLOAT, DOCK_FLOAT_TO_LAYOUT, POPOUT_FLOAT, CREATE_SUBLAYOUT, ADD_TAB_TO_NEW_GROUP, UNGROUP, REMOVE_TAB_FROM_GROUP, GROUP.

On this page