DocumentLoader

How to get DocumentLoader

ES2015+:

import DocumentLoader from 'fontoxml-remote-documents/documentLoader'

ES5:

define([
	'fontoxml-remote-documents/documentLoader'
], function (
	DocumentLoader
) {
});

Type: Class

The DocumentLoader manages and de-duplicates load requests for documents and adds corresponding instances of DocumentController to the DocumentsManager.

Documents can be referred to either by their documentId or by an URL relative to some other document. In the latter case, resolving occurs in the CMS, but we can deduplicate requests by checking the documentId returned from such requests.

Methods

Name Description
loadDocument

Request the document with the given ID to be loaded


  Arguments
# Name Type Description
1. remoteDocumentId RemoteDocumentId
2. [options] Object
  Members

Members

Name Type Description
detachFromCms Boolean

If set to true, the local document will be a copy that is no longer linked to its remote counterpart and will not participate in locking and saving. Use this for documents that function like templates used to create new documents.


  Default value
false
onlyFromCache Boolean

If set to true, no request will be sent. The return value will resemble the last actual attempt to load this document, or resolve to undefined if the document has never been loaded.


  Default value
false
  Returns

Type: Promise<DocumentId>

Promise resolving to the document ID once it is available in the DocumentsManager

loadRelatedDocument

Request the document referred to by the given URL and referrer document ID to be loaded


  Arguments
# Name Type Description
1. relativeUrl String
2. referrerId RemoteDocumentId
3. [options] Object
  Members

Members

Name Type Description
detachFromCms Boolean

If set to true, the local document will be a copy that is no longer linked to its remote counterpart and will not participate in locking and saving. Use this for documents that function like templates used to create new documents.


  Default value
false
onlyFromCache Boolean

If set to true, no request will be sent. The return value will resemble the last actual attempt to load this document, or resolve to undefined if the document has never been loaded.


  Default value
false
  Returns

Type: Promise<DocumentId>

Promise resolving to the document ID once it is available in the DocumentsManager