DocumentCapabilitiesManager

Type: Class

How to get documentCapabilitiesManager?

JavaScript

import documentCapabilitiesManager from 'fontoxml-documents/src/documentCapabilitiesManager.js'

Provides methods related to the current capability level for loaded documents.

Documents are loaded with 'previewable' capability level, and may increase this level through 'operable', 'editable' and 'saveable' depending on their current state. Each level is considered to include all preceding levels, so an 'editable' document automatically has the 'operable' and 'previewable' capability levels as well.

  • previewable - the document has been loaded; documents loaded for previews (such as in the CMS browser) remain at this level.

  • operable - the document is being used in the editor and can be the target of operations.

  • editable - the document may be modified by operations.

  • saveable - changes to the document can be saved to the CMS.

Changes in capability level are generally managed automatically. The exception is when writing a loading strategy (see initialDocumentsManager), where ensureCapabilityLevel should be used to raise the level for loaded documents to operable so they may be used in the editor. This will then be increased automatically to editable or saveable based on the document's lock status.

For compatibility with older APIs, capability levels are also automatically reflected as document aspects with names like cap/operable, and a value of true if the document has that capability level.

Methods

addCapabilityLostCallback

Type: Function

Registers a callback to be invoked once when the given document loses the given capability level. This includes unloading the document

This callback is invoked after the document completes a transition that removes the requested capability.

In contrast to most callback related code, this callback will fire only once. The removal function may be used to cancel it.

Valid values for level are:

  • previewable

  • operable

  • editable

  • saveable

Arguments

Returns

addNewDocumentCallback

Type: Function

Registers a callback to be invoked for any document that reaches a certain capability level.

This callback is invoked after the document completes a transition that grants the requested capability. If you want to perform processing before this happens, use addUpgradeTransitionCallback instead.

Valid values for level are:

  • previewable

  • operable

  • editable

  • saveable

Arguments

Returns

ensureCapabilityLevel

Type: Function

Sets the document's capability level if the current level is lower than the specified level. Use DocumentCapabilitiesManager#setCapabilityLevel if you want to downgrade a document's capabilities.

Valid values for level are:

  • previewable

  • operable

  • editable

  • saveable

Arguments

Returns

hasCapability

Type: Function

Check whether the given document has the given capability level (or higher).

Valid values for capability are:

  • previewable

  • operable

  • editable

  • saveable

Arguments

Returns

setCapabilityLevel

Type: Function

Sets the document's capability level. Note that this will downgrade capabilities if the current level is higher. Use DocumentCapabilitiesManager#ensureCapabilityLevel to only set the level if it is lower.

Valid values for level are:

  • previewable

  • operable

  • editable

  • saveable

Arguments

Returns