Search
Loading...
Skip to content

Disable or Enable Features

Enable Feature#

The following API allows to enable a custom or built-in feature (see the list of built-in features below):

enable(featureId: FeatureId | FeatureId[])

This method enables one or more features using their default predicates. If you need custom predicate logic, use the set() method instead (see below).

Tip: FeatureId can be an arbitrary string, so you can use this mechanism to toggle your own custom features, as well.

Example: Enable Single Feature#

// Enable a feature with its default predicate
cesdk.feature.enable('ly.img.delete');

Example: Enable Multiple Features#

// Enable multiple features at once
cesdk.feature.enable(['ly.img.delete', 'ly.img.duplicate']);

Example: Enable with Glob Pattern#

// Enable all video features
cesdk.feature.enable('ly.img.video.*');
// Enable all crop features
cesdk.feature.enable('ly.img.crop.*');

Disable Feature#

The disable() method provides a convenient way to explicitly disable one or more features:

disable(featureId: FeatureId | FeatureId[])

This method disables features by setting their enable/disable state to false. Note that disable() works best with enable() for simple on/off control. If you’ve used set() with boolean predicates, those will be evaluated first and may override the disable state.

Example: Disable Single Feature#

cesdk.feature.disable('ly.img.delete');

Example: Disable Multiple Features#

cesdk.feature.disable(['ly.img.delete', 'ly.img.duplicate']);

Example: Disable with Glob Pattern#

// Disable all video features
cesdk.feature.disable('ly.img.video.*');
// Disable all crop features
cesdk.feature.disable('ly.img.crop.*');

Set Feature#

The set() method is the unified approach for configuring feature state with custom predicates:

set(featureId: FeatureId, enabled: boolean | FeaturePredicate)

The enabled parameter can be:

  • A boolean (true or false) to enable or disable the feature
  • A function (predicate) that takes a context and returns a boolean

The predicate function receives an EnableFeatureContext with:

  • engine: CreativeEngine - The engine instance
  • isPreviousEnable: () => boolean - Returns the result of any previously registered predicates
  • defaultPredicate: () => boolean - Returns the result of the default predicate

Understanding Predicate Chaining and Evaluation Order#

Multiple predicates can be registered for the same feature, forming a predicate chain. Understanding the evaluation order is crucial:

Evaluation Order:

  1. Most recent set() predicate runs FIRST
  2. Older set() predicates in reverse chronological order (most recent first)
  3. enable()/disable() state runs LAST

This means:

  • set() predicates can override enable() and disable() - They’re evaluated first
  • Boolean predicates are always terminal - They immediately return their value without continuing the chain
  • Function predicates control the chain - The function implementation decides whether to call isPreviousEnable() (continue chain) or return directly (end chain)

Key Principles:

  • Use enable() and disable() for simple on/off control
  • Use set() when you need custom logic or want to override enable/disable
  • Each set() call adds a new predicate to the front of the chain
  • Boolean predicates (true/false) are always terminal - they cannot continue the chain
  • Function predicates decide whether to continue the chain by calling isPreviousEnable(), or end it by returning directly

Example: Enable Feature#

cesdk.feature.set('ly.img.delete', true);

Example: Disable Feature#

cesdk.feature.set('ly.img.delete', false);

Important: Using set() with a boolean creates a terminal predicate. If you later call enable() or disable(), they won’t have an effect because set() predicates are evaluated first:

// This creates a terminal predicate
cesdk.feature.set('ly.img.delete', true);
// This won't disable the feature because set(true) is terminal
cesdk.feature.disable('ly.img.delete');
// Feature is still enabled!
// For simple on/off, use enable() and disable() instead:
cesdk.feature.enable('ly.img.delete'); // Enabled
cesdk.feature.disable('ly.img.delete'); // Now disabled

Example: Custom Predicate#

cesdk.feature.set('ly.img.delete', ({ engine }) => {
const selectedBlocks = engine.block.findAllSelected();
return selectedBlocks.length > 0;
});

Example: Extending Default Predicate#

You can extend the default predicate provided for built-in features:

cesdk.feature.set('ly.img.delete', ({ defaultPredicate }) => {
// Only allow delete after 10 pm
return defaultPredicate() && new Date().getHours() >= 22;
});

Example: Chaining Predicates#

Predicates can access the result of previously registered predicates:

// First, enable with default
cesdk.feature.enable('my.feature');
// Then, add additional logic that chains with previous predicates
cesdk.feature.set('my.feature', ({ isPreviousEnable }) => {
// Disable the feature after 10 pm, otherwise use previous result
return new Date().getHours() >= 22 ? false : isPreviousEnable();
});

Example: Overwriting Defaults for Custom Block Types#

Let’s say you introduced a new kind of block that represents an Avatar. You want to hide the duplicate & delete buttons in the canvas menu for this block:

cesdk.feature.set('ly.img.delete', ({ engine, isPreviousEnable }) => {
const selectedBlock = engine.block.findAllSelected()[0];
const kind = engine.block.getKind(selectedBlock);
if (kind === 'avatar') {
return false;
} else {
return isPreviousEnable();
}
});
cesdk.feature.set('ly.img.duplicate', ({ engine, isPreviousEnable }) => {
const selectedBlock = engine.block.findAllSelected()[0];
const kind = engine.block.getKind(selectedBlock);
if (kind === 'avatar') {
return false;
} else {
return isPreviousEnable();
}
});

Example: Glob Pattern with Predicate#

// Apply custom logic to all video features
cesdk.feature.set('ly.img.video.*', ({ engine }) => {
return engine.scene.getMode() === 'Video';
});

Check Feature#

The following API allows to query if the feature is currently enabled:

isEnabled(featureId: FeatureId): boolean

This method returns true if the feature is currently enabled, false otherwise.

Example#

if (!cesdk.feature.isEnabled('ly.img.navigation.close')) {
return null;
}
// Check multiple features
if (
cesdk.feature.isEnabled('ly.img.delete') &&
cesdk.feature.isEnabled('ly.img.duplicate')
) {
console.log('Both delete and duplicate are enabled');
}
// Check with glob pattern
if (cesdk.feature.isEnabled('ly.img.video.*')) {
console.log('All video features are enabled');
}

List Features#

The list() method returns all registered feature IDs, with optional pattern matching:

list(options?: { matcher?: string }): FeatureId[]

This method is useful for discovering available features and debugging feature configurations.

Example: List All Features#

const allFeatures = cesdk.feature.list();
console.log('All features:', allFeatures);

Example: List with Pattern Matching#

// List all video features
const videoFeatures = cesdk.feature.list({ matcher: 'ly.img.video.*' });
// List all crop features
const cropFeatures = cesdk.feature.list({ matcher: 'ly.img.crop.*' });
// List all navigation features
const navFeatures = cesdk.feature.list({ matcher: 'ly.img.navigation.*' });

Get Feature Predicates#

The get() method allows you to retrieve the predicates associated with a feature:

get(featureId: FeatureId): FeaturePredicate[] | undefined

This is useful for debugging or understanding what predicates have been registered for a feature.

Example#

const predicates = cesdk.feature.get('ly.img.delete');
console.log(`Feature has ${predicates?.length || 0} predicates`);

Glob Pattern Support#

All main Feature API methods support glob pattern matching for batch operations, allowing you to control multiple related features at once.

Supported Methods#

  • enable(pattern) - Enable all matching features
  • disable(pattern) - Disable all matching features
  • set(pattern, predicate) - Set all matching features
  • isEnabled(pattern) - Check if all matching features are enabled
  • list({ matcher: pattern }) - List features matching pattern

Pattern Syntax#

  • * matches any sequence of characters within a segment
  • ly.img.video.* matches all features starting with ly.img.video.
  • ly.img.crop.* matches all features starting with ly.img.crop.

Examples#

// Enable all video features
cesdk.feature.enable('ly.img.video.*');
// Disable all crop features
cesdk.feature.disable('ly.img.crop.*');
// Check if all navigation features are enabled
const allEnabled = cesdk.feature.isEnabled('ly.img.navigation.*');
// Set all filter features with custom predicate
cesdk.feature.set('ly.img.filter.*', ({ engine }) => {
const selectedBlocks = engine.block.findAllSelected();
return selectedBlocks.some((id) => engine.block.hasEffects(id));
});
// List all features in a namespace
const allVideoFeatures = cesdk.feature.list({ matcher: 'ly.img.video.*' });

Best Practices#

  • Use glob patterns to manage related features together
  • Combine with predicates for conditional bulk operations
  • Use list() with matchers to discover available features in a namespace

Built-In Features#

The following features are built-in to CE.SDK:

Feature IDDescription
ly.img.navigation.barControls visibility of the Navigation Bar. Defaults to the value of the configuration option ui.elements.navigation, or true if not set.
ly.img.navigation.backControls visibility of the “Back” button in the Navigation Bar.
ly.img.navigation.closeControls visibility of the “Close” button in the Navigation Bar.
ly.img.navigation.undoRedoControls visibility of the “Undo” and “Redo” button in the Navigation Bar.
ly.img.navigation.zoomControls visibility of the “Zoom” controls in the Navigation Bar.
ly.img.navigation.actionsControls visibility of the “Actions” in the Navigation Bar.
ly.img.inspector.barControls the visibility of the “Inspector Bar” in the Editor. Defaults to the value of the configuration option ui.elements.inspectorBar, or true if not set.
ly.img.inspector.panelControls the visibility of the “Advanced Inspector” in the Editor. Defaults to false if not explicitly enabled.
ly.img.inspector.toggleControls presence of the Inspector Toggle button in the Inspector bar.
ly.img.canvas.barControls the visibility of the “Canvas Bar” in the Editor.
ly.img.canvas.menuControls the visibility of the “Canvas Menu” in the Editor.
ly.img.dockControls the visibility of the “Dock” in the Editor. Defaults to the value of the configuration option ui.elements.dock, or true if not set.
ly.img.library.panelControls the visibility of the “Asset Library” panel in the Editor. Defaults to true if not explicitly disabled.
ly.img.settingsControls the visibility of the “Settings” panel in the Editor. Defaults to false if not explicitly enabled.
ly.img.previewControls existence of the “Preview” button in the Navigation Bar. Returns true when cesdk.engine.editor.getRole() returns Creator, e.g. when editing in the Creator role.
ly.img.deleteControls the ability to delete a block. Changes visibility of the “Delete” button in the Canvas Menu, as well as the ability to delete by pressing the delete key. Will return false when the operation would delete all pages of the document. Will return false when target block is a page and page management features are disabled via Feature API, or during 'Video' scene mode.
ly.img.duplicateControls visibility of the “Duplicate” button in the Canvas Menu. Copy/paste using keyboard shortcuts will be disabled when set to false. Will return false when target block is a page and page management features are disabled via Feature API, or during 'Video' scene mode, or when scene layout is set to 'Free' or 'DepthStack'.
ly.img.replaceControls presence of the “Replace” button in the Canvas Menu, and in the Fill Panel for image and video fills. Returns false by default for stickers.
ly.img.groupControls features for creating and dissolving groups, currently: The existence of “Group” and “Ungroup” buttons in the Inspector Bar. Returns false during 'Video' scene mode.
ly.img.placeholderControls visibility of the “Placeholder” button in the Canvas Menu. Will return true for blocks of type '//ly.img.ubq/text', '//ly.img.ubq/group', '//ly.img.ubq/page', '//ly.img.ubq/audio', or '//ly.img.ubq/graphic'.
ly.img.positionControls presence of the Position dropdown, and can disable the corresponding controls in the Advanced UI Inspector Panel. Returns false if target block is a page.
ly.img.optionsControls presence of the Options button (... button) in the Default UI Inspector Bar. Returns true by default.
ly.img.animationsControls presence of the Animations button. Returns true by default for Graphic and Text blocks in video mode.
ly.img.page.addControls the ability to add pages, by showing the “Add Page” button in the Canvas Bar. Returns false during 'Video' scene mode, or when scene layout is set to 'Free' or 'DepthStack'.
ly.img.page.moveControls the ability to move pages, by showing the “Move Up/Down/Left/Right” buttons in the Canvas Menu. Returns false during 'Video' scene mode, or when scene layout is set to 'Free' or 'DepthStack'. Note that the “Move Up/Left” components will not show up when the target page is already the first page of the document, and “Move Down/Right” will not show up when the target page is already the last page of the document.
ly.img.page.resizeControls the presence of the Resize button in the navigation bar, as well as the page formats button in the document inspector.
ly.img.text.editControls presence of the “Edit” button in the Canvas Menu. Only returns true for text blocks by default.
ly.img.text.typefaceControls presence of the Typeface dropdown, and can disable the corresponding dropdown in the Advanced UI Inspector Panel. Only returns true for text blocks by default.
ly.img.text.fontSizeControls presence of the Font Size input, and can disable the corresponding input in the Advanced UI Inspector Panel. Only returns true for text blocks by default.
ly.img.text.fontStyleControls presence of the Font Style controls (Bold toggle, Italic toggle), in the Canvas Menu, and can disable the corresponding inputs in the Advanced UI Inspector Panel. Only returns true for text blocks by default.
ly.img.text.alignmentControls presence of the Text Horizontal Alignment dropdown, and can disable the corresponding controls in the Advanced UI Inspector Panel. Only returns true for text blocks by default.
ly.img.text.advancedControls the presence of the Advanced text controls in the Editor. Only returns true for text blocks by default.
ly.img.fillControls presence of the Fill button (opening the Fill Panel), and can disable the corresponding button in the Advanced UI Inspector Panel. Returns false for stickers by default.
ly.img.strokeControls presence of the Stroke controls (Color, Width, Stroke), and can disable the corresponding controls in the Advanced UI Inspector Panel. Returns false for stickers by default.
ly.img.adjustmentControls visibility of the “Adjustments” button, and can disable the corresponding button in the Advanced UI Inspector Panel. Returns false for stickers by default.
ly.img.filterControls visibility of the “Filter” button, and can disable the corresponding button in the Advanced UI Inspector Panel. Returns false for stickers by default.
ly.img.filter.lutControls visibility of LUT (Lookup Table) filter controls.
ly.img.filter.duotoneControls visibility of duotone filter controls.
ly.img.effectControls visibility of the “Effect” button, and can disable the corresponding button in the Advanced UI Inspector Panel. Returns false for stickers by default.
ly.img.blurControls visibility of the “Blur” button, and can disable the corresponding button in the Advanced UI Inspector Panel. Returns false for stickers by default.
ly.img.shadowControls visibility of the Shadow button, and can disable the corresponding control in the Advanced UI Inspector Panel. Returns false for pages by default.
ly.img.shape.optionsControls presence of the Shape Options dropdown in the Default UI Inspector Bar, and can disable the corresponding button in the Advanced UI Inspector Panel. Returns true by default, but note that the component itself checks for the target block type and will only render for shape blocks.
ly.img.combineControls presence of the Combine dropdown, and can disable the corresponding button in the Advanced UI Inspector Panel. Returns true by default, but note that the component itself checks for the target block type and will only render if the selection contains only shape blocks and text, or only cutouts.
ly.img.cutoutControls visibility of the Cutout controls (Cutout Type, Cutout Offset, Cutout Smoothing), and can disable the corresponding controls in the Advanced UI Inspector Panel. Only returns true for cutouts by default.
ly.img.transform.positionControls presence of the Transform X and Y Position controls.
ly.img.transform.sizeControls presence of the Transform width and height controls.
ly.img.transform.rotationControls presence of the Transform Rotation controls.
ly.img.transform.flipControls presence of the Transform Flip controls.
ly.img.cropControls presence of the Crop button, and can disable the corresponding button in the Fill Panel. Returns false for stickers by default.
ly.img.crop.sizeControls visibility of crop size controls.
ly.img.crop.positionControls visibility of crop position controls.
ly.img.crop.rotationControls visibility of crop rotation controls.
ly.img.crop.flipControls visibility of crop flip controls.
ly.img.crop.scaleControls visibility of crop scale controls.
ly.img.crop.fillModeControls visibility of crop fill mode controls.
ly.img.crop.panel.autoOpenControls whether the crop panel automatically opens when entering crop mode. Defaults to true. When disabled, integrators can programmatically control panel opening via cesdk.ui.openPanel() or implement custom workflows.
ly.img.trimControls presence of the Trim button, and can disable the corresponding button in the Fill Panel. Only returns true when scene mode is 'Video'.
ly.img.volumeControls presence of the Volume control, and can disable the corresponding button in the Fill Panel. Only returns true when scene mode is 'Video'. Disabled for pages by default.
ly.img.video.timelineControls the visibility of the “Video Timeline” in the Editor.
ly.img.video.clipsControls visibility and behavior of the video clips track in the timeline.
ly.img.video.overlaysControls visibility and behavior of the overlays track in the timeline.
ly.img.video.audioControls visibility and behavior of the audio track in the timeline.
ly.img.video.addClipControls the ability to add new clips to the timeline.
ly.img.video.controlsBase feature for all video control UI elements.
ly.img.video.controls.toggleControls visibility of the video timeline collapse/expand toggle button.
ly.img.video.controls.playbackControls visibility of play/pause button, playback loop, and timestamp controls in video mode.
ly.img.video.controls.loopControls visibility of the loop toggle control.
ly.img.video.controls.splitControls visibility of the split clip control.
ly.img.video.controls.backgroundControls visibility of background color controls in video mode.
ly.img.video.controls.timelineZoomControls visibility of timeline zoom controls.