# documentsmanager-f746b3a48442 Source: https://documentation.fontoxml.com/latest/documentsmanager-f746b3a48442 ## DocumentsManager This is the class definition of a singleton. Please do not import or instantiate this class directly, instead use the documentsManager instance directly. The documents manager manages the set of loaded documents. ### `documentsCollectionChangedNotifier` *Notifier* Notifier that can be used to be notified the set of loaded documents has changed. WARNING: This is a platform notifier. Do not trigger the executeCallbacks method on this notifier yourself. ### `addDocumentsCollectionChangedCallback` *function* **Parameters:** - `requiredAspects` - `callback`: `void` **Returns:** call this to remove the callback Registers callback to be invoked whenever the set of documents with the specified aspects changes. Usually, requiredAspects is set to either { 'cap/operable': true } to obtain all documents loaded in the content view, or to { 'cap/editable': true } for documents that are editable. Returns a function which can be called to remove the callback. Use the DocumentsManager#documentsCollectionChangedNotifier directly if you don't need to filter on aspects. ### `addDocumentChangeCallback` *function* **Parameters:** - `documentId` - `callback`: `void` **Returns:** call to remove the callback Registers callback to be invoked whenever any change is made to the XML of the document with ID documentId. If you're interested in specific nodes, consider using an index instead. Returns a function which can be called to remove the callback. ### `hasDocument` *function* **Parameters:** - `documentId` **Returns:** `boolean` Returns whether the document with the given documentId is still loaded. ### `removeDocument` *function* **Parameters:** - `documentId` **Returns:** `void` Remove a document. Callers should make sure this document is not referenced anymore before calling this method. ### `setDocumentError` *function* **Parameters:** - `documentId` - `error` **Returns:** `void` Places the document in an error state, unloading it as a result. Should only be called when an error is unrecoverable for the document. ### `documentMeetsRequiredAspects` *function* **Parameters:** - `documentId` - `requiredAspects` **Returns:** `boolean` Returns whether the document with the given documentId has the aspects specified by requiredAspects. Usually, requiredAspects is set to either { 'cap/operable': true } to check for documents loaded in the content view, or to { 'cap/editable': true } for documents that are editable. ### `addDocumentMetadataChangeCallback` *function* **Parameters:** - `documentId` - `callback`: `void` **Returns:** Call to remove the callback Get the metadata on a document. This is the metadata associated to the document by the cms when the document was loaded. ### `getDocumentMetadata` *function* **Parameters:** - `documentId` Get the metadata on a document. This is the metadata associated to the document by the cms when the document was loaded. This will be null if the cms did not provide any metadata. ### `setDocumentMetadata` *function* **Parameters:** - `documentId` - `metadata` **Returns:** `void` Set the metadata of a document. This is the metadata associated to the document by the cms when the document was loaded. Setting this metadata may trigger a save. ### `getRemoteDocumentId` *function* **Parameters:** - `documentId` Get the remote document ID associated with the given document, or null if there is no loaded document with the given ID or a remote document ID is not available (only possible if the document was detached from the CMS). ### `getDocumentNode` *function* **Parameters:** - `documentId` Returns the document node for the document with the given documentId, or null if the specified document is not loaded. ### `getNodeById` *function* **Parameters:** - `nodeId` Returns the node with the given nodeId. ### `getDocumentIdByNodeId` *function* **Parameters:** - `nodeId` - `blueprint` Returns the documentId of the document containing the node with the given nodeId. ### `getDocumentIdByRemoteDocumentId` *function* **Parameters:** - `remoteDocumentId` Returns the documentId of the document specified by the given remote (i.e., CMS) document identifier, or null if the specified document is not currently loaded. ### `getAllDocumentIds` *function* **Parameters:** - `requiredAspects` Returns the documentIds of all loaded documents. If requiredAspects is specified, only documents matching these aspects are returned. Warning: this may return documents other than those visible in the editor, including templates, documents loaded only for previewing and Document History change logs. If you want to get all documents loaded in the editor, the recommended way is to use the documentsHierarchy instead of this method. For example: Do note that if your hierarchy contains multiple hierarchy nodes pointing at (parts of) the same document, code such as this may see its DocumentId multiple times. ## Related pages - https://documentation.fontoxml.com/latest/documentsmanager-49068070d10f - https://documentation.fontoxml.com/latest/notifier-c862a4a36792 - https://documentation.fontoxml.com/latest/documentid-9bdfc85ab71e - https://documentation.fontoxml.com/latest/documentmetadata-d35a805a40a1 - https://documentation.fontoxml.com/latest/remotedocumentid-7df056df1abc - https://documentation.fontoxml.com/latest/fontodocumentnode-1d5232c2d0e1 - https://documentation.fontoxml.com/latest/nodeid-6f23070e6f8f - https://documentation.fontoxml.com/latest/fontonode-9ce1bcffd645 - https://documentation.fontoxml.com/latest/idomfacade-99cf565f2fe1 - https://documentation.fontoxml.com/latest/documentshierarchy-7d7661ede312 - https://documentation.fontoxml.com/latest/fonto-design-system-ea82ff05749d - https://documentation.fontoxml.com/latest/create-a-popover-fcd4f52edfbc - https://documentation.fontoxml.com/latest/operations-5a5f9ba5c6d8 - https://documentation.fontoxml.com/latest/why-are-my-objects-not-updating-templated-views-and-dependency-tracking-660e27147701 - https://documentation.fontoxml.com/latest/xpath-b79c646b1933