How to get DocumentReference?
import DocumentReference from 'fontoxml-documents/src/DocumentReference.js'
A DocumentReference represents a reference to a document. The precise identity of the target document may not be known. This allows it to represent references to external content or those which reference content for which the identity is only known after loading (e.g., documents referenced by their relative path).
A document can either be referenced directly by its remote document ID, or indirectly using a potentially relative URL and the remote document ID of the referrer.
If the document this reference refers to is loaded, this is set to the corresponding document ID.
Type: Error | NULL
A DocumentReference can be in an error state in a number of ways:
An error may have been encountered after the document was loaded, in which case the documentId property is set but the document is no longer available.
An error may have been encountered during loading, in which case only the remoteDocumentId or relativeUrl and referrerId properties have been set.
The reference itself may be erroneous, in which case this error property will be set.
The getLoadingStateForDocumentReference function can be used to obtain the error that may have occurred in any of these cases.
Can be used to hide referenced documents from the editor.
This may be set to false, for instance, to include resource documents that are part of a project but are not editable directly.
In case the reference refers to a potentially relative ID with respect to a referrer document, this is the remote document ID of the referrer document.
Type: RemoteDocumentId | String | NULL
In case the reference refers to a potentially relative ID with respect to a referrer document, this is the ID or URL being targeted.
In case the reference refers to an absolute remote document ID, this is that ID.
If the reference originates from another loaded document, this is set to the document ID of that document.
If the reference originates from another loaded document, this is set to the node ID of the node representing the reference in that document.
Root Node Id
If the document this reference refers to is loaded and this reference references a part of the document, this is set to the corresponding node ID. If set to null, the document is either not loaded or the reference references the root of the document.
Returns the source node, that is, the node that represents the reference itself, or null if there is no such node.
Traversal Root Node
Returns the traversal root node, representing the target of the reference.
If the reference refers to the root of the document, its Document node is returned. If the target document is not loaded, this returns null.
Returns whether the target document is currently loaded.
Mark the reference as erroneous. This will clear any instance set, so the targeted document will no longer be visualized under this reference.
Should be called with the document instance ID when the document targeted by the reference is loaded in the DocumentsManager, and with null as soon as it is unloaded.
Related Document Target
Set the target of the document reference to a related document. The setTarget method should be called to make the reference absolute once its ID is known.
Should be called when the absolute remote ID of the document targeted by the reference is known. It does not need to have an instance currently loaded in the documents manager.