Controls the availability of features within the Creative Editor SDK.
The FeatureAPI allows you to enable or disable specific functionality within the editor based on custom conditions or user permissions.
Feature Control#
Methods for enabling and checking the status of editor features based on custom predicates.
enable()#
Enables one or more features based on the provided predicate.
The predicate can be either a boolean value that determines if the feature
is enabled or disabled, a function that receives a context object and
returns a boolean, or omitted to get the default behavior. The context contains
the isPreviousEnabled
function
which allows you to check if a feature was previously enabled by other
enable calls, including the CE.SDK editor defaults. This enables you to
further restrict features without reimplementing existing logic.
To use our defaults you can simply omit passing a predicate when enabling a feature.
cesdk.feature.enable('ly.img.delete');cesdk.feature.enable('ly.img.duplicate');
You can also extend the default predicate provided for built-in features.
cesdk.feature.enable('ly.img.delete', ({ defaultPredicate }) => return defaultPredicate() && (new Date().getHours() >= 22););
Parameters#
Parameter | Type | Description |
---|---|---|
featureId | FeatureId | |
predicate? | FeaturePredicate | The condition that determines if the feature is enabled. |
Returns#
void
Signature#
enable(featureId: FeatureId | FeatureId[], predicate?: FeaturePredicate): void
isEnabled()#
Checks if a specific feature is currently enabled.
Parameters#
Parameter | Type | Description |
---|---|---|
featureId | FeatureId | The feature ID to check. |
context | IsEnabledFeatureContext | The context object containing a reference to the underlying engine. |
Returns#
boolean
True if the feature is enabled, false otherwise.
Signature#
isEnabled(featureId: FeatureId, context: IsEnabledFeatureContext): boolean