DocumentsManager

How to get DocumentsManager

ES2015+:

import DocumentsManager from 'fontoxml-documents/documentsManager'

ES5:

define([
	'fontoxml-documents/documentsManager'
], function (
	DocumentsManager
) {
});

Type: Class

The documents manager manages the set of loaded documents.

Properties

Name Type Description
documentsCollectionChangedNotifier Notifier

Notifier that can be used to be notified the set of loaded documents has changed.

Methods

Name Description
addDocumentChangeCallback

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.


  Arguments
# Name Type Description
1. documentId DocumentId
2. callback Function
  Returns

Type: Function

call to remove the callback

addDocumentMetadataChangeCallback

Get the metadata on a document. This is the metadata associated to the document by the cms when the document was loaded.


  Arguments
# Name Type Description
1. documentId DocumentId
2. callback Function
  Returns

Type: Function

Call to remove the callback

addDocumentsCollectionChangedCallback

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#documentsCollectionChangeNotifier directly if you don't need to filter on aspects.


  Arguments
# Name Type Description
1. requiredAspects Object
2. callback Function
  Returns

Type: Function

call this to remove the callback

documentMeetsRequiredAspects

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.


  Arguments
# Name Type Description
1. documentId DocumentId
2. requiredAspects Object
  Returns

Type: Boolean

getAllDocumentIds

Returns the documentIds of all loaded documents. If requiredAspects is specified, only documents matching these aspects are returned.


  Arguments
# Name Type Description
1. [requiredAspects] Object
  Returns

Type: Array<DocumentId>

getDocumentIdByNodeId

Returns the documentId of the document containing the node with the given nodeId.


  Arguments
# Name Type Description
1. nodeId NodeId
2. [blueprint] Blueprint
  Returns

Type: DocumentId

getDocumentIdByRemoteDocumentId

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.


  Arguments
# Name Type Description
1. remoteDocumentId RemoteDocumentId
  Returns

Type: DocumentId

getDocumentMetadata

Get the metadata on a document. This is the metadata associated to the document by the cms when the document was loaded.


  Arguments
# Name Type Description
1. documentId DocumentId
  Returns

Type: Object

getDocumentNode

Returns the document node for the document with the given documentId, or null if the specified document is not loaded.


  Arguments
# Name Type Description
1. documentId DocumentId
  Returns

Type: Node

getNodeById

Returns the node with the given nodeId.


  Arguments
# Name Type Description
1. nodeId NodeId
  Returns

Type: Node | Null

getRemoteDocumentId

Get the remote document ID associated with the given document, or null if there is no loaded document with the given ID.


  Arguments
# Name Type Description
1. documentId DocumentId
  Returns

Type: RemoteDocumentId | Null

getSchemaExperience

Returns the schema experience for the document with the given documentId, or null if the specified document is not loaded.


  Arguments
# Name Type Description
1. documentId DocumentId
  Returns

Type: SchemaExperience

hasDocument

Returns whether the document with the given documentId is still loaded.


  Arguments
# Name Type Description
1. documentId DocumentId
  Returns

Type: Boolean

removeAllDocuments

Remove all documents. This should only be used to implement unloadAllDocuments.


  Arguments
# Name Type Description
1. documentId DocumentId
  Related links
  • initialDocumentsManager#setLoadingStrategy

removeDocument

Remove a document. Callers should make sure this document is not referenced anymore before calling this method.


  Arguments
# Name Type Description
1. documentId DocumentId
setDocumentError

Places the document in an error state, unloading it as a result.

Should only be called when an error is unrecoverable for the document.


  Arguments
# Name Type Description
1. documentId DocumentId

The document which has an error

2. error Error

The error which has occured

3. [message] String

The human readable message, if available

  Related links
setDocumentMetadata

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.


  Arguments
# Name Type Description
1. documentId DocumentId
2. metadata Object