DocumentCapabilitiesManager

How to get DocumentCapabilitiesManager

ES2015+:

import DocumentCapabilitiesManager from 'fontoxml-documents/documentCapabilitiesManager'

ES5:

define([
	'fontoxml-documents/documentCapabilitiesManager'
], function (
	DocumentCapabilitiesManager
) {
});

Type: Class

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. Changes in capability level are generally managed automatically.

Methods

Name Description
addCapabilityLostCallback

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.


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

Type: Function

Stops further invocations of the callback when called. This may be used to cancel this callback.

addNewDocumentCallback

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.


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

Type: Function

stops further invocations of the callback when called

ensureCapabilityLevel

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.


  Arguments
# Name Type Description
1. documentId DocumentId
2. level String
  Returns

Type: Promise<String>

resolves to the actual level reached after transitions complete.

hasCapability

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

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


  Arguments
# Name Type Description
1. documentId DocumentId
2. capability String
  Returns

Type: Boolean

setCapabilityLevel

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.


  Arguments
# Name Type Description
1. documentId DocumentId
2. level String
  Returns

Type: Promise<String>

resolves to the actual level reached after transitions complete.