DocumentsHierarchy

How to get DocumentsHierarchy

ES2015+:

import DocumentsHierarchy from 'fontoxml-documents/documentsHierarchy'

ES5:

define([
	'fontoxml-documents/documentsHierarchy'
], function (
	DocumentsHierarchy
) {
});

Type: Class

The DocumentsHierarchy represents the relationships between the documents loaded in the DocumentsManager. It is a tree of DocumentsHierarchyNodes, each of which optionally references a document which can be loaded. The DocumentsHierarchy itself is the root of the tree and can not reference a document.

Properties

Name Type Description
children Array<DocumentsHierarchyNode>

The top-level hierarchy nodes referencing the documents directly loaded in the editor

hierarchyChangedNotifier DebouncedNotifier

Notifier to use for signalling hierarchy changes. Note that this is not called by the hierarchy itself, but should be used by components that mutate the hierarchy. This way, mutations can be batched.

This notifier is debounced internally.

Methods

Name Description
addChild

Append a child to this hierarchy node


  Arguments
# Name Type Description
1. documentsHierarchyNode DocumentsHierarchyNode
clear

Remove all children of the hierarchy

find

Traverses the documents hierarchy in depth-first order looking for a hierarchy node for which the given callback returns true.


  Arguments
# Name Type Description
1. isMatchingHierarchyNode Function

Callback invoked for each node in the hierarchy until true is returned to indicate a match


  Arguments
# Name Type Description
1. DocumentsHierarchyNode
  Returns

Type: Boolean

2. isBackwards Boolean

Whether to traverse the hierarchy in reverse order


  Default value
false
  Returns

Type: DocumentsHierarchyNode | Null

The first node for which the callback returned true

findAll

Find all hierarchy nodes (in hierarchy order) for which the given callback returns true.


  Arguments
# Name Type Description
1. isMatchingHierarchyNode Function
  Arguments
# Name Type Description
1. DocumentsHierarchyNode
  Returns

Type: Boolean

  Returns

Type: Array<DocumentsHierarchyNode>

findAllVisibleHierarchyNodes

Find all visible hierarchy nodes, in hierarchy order.


  Returns

Type: Array<DocumentsHierarchyNode>

findNextVisibleHierarchyNode

Find the visible hierarchy node following (or preceding) the given hierarchy node in hierarchy order.


  Arguments
# Name Type Description
1. currentHierarchyNode DocumentsHierarchyNode
2. isBackwards Boolean
  Default value
true
  Returns

Type: DocumentsHierarchyNode | Null

getFirstVisibleHierarchyNode

Find the first visible hierarchy node.


  Returns

Type: DocumentsHierarchyNode | Null

getLastVisibleHierarchyNode

Find the last visible hierarchy node.


  Returns

Type: DocumentsHierarchyNode | Null

removeChild

Remove a child from this hierarchy node


  Arguments
# Name Type Description
1. documentsHierarchyNode DocumentsHierarchyNode