In this example, we will demonstrate how to use the CreativeEditor SDK’s CreativeEngine to manage placeholder behavior and controls through the block Api.
Placeholder Behavior and Controls
fun supportsPlaceholderBehavior(block: DesignBlock): Boolean
Query whether the block supports placeholder behavior.
-
block
: the block to query. -
Returns whether the block supports placeholder behavior.
fun setPlaceholderBehaviorEnabled( block: DesignBlock, enabled: Boolean,)
Enable or disable the placeholder behavior for a block.
-
block
: the block whose placeholder behavior should be enabled or disabled. -
enabled
: Whether the placeholder behavior should be enabled or disabled.
fun isPlaceholderBehaviorEnabled(block: DesignBlock): Boolean
Query whether the placeholder behavior for a block is enabled.
-
block
: the block whose placeholder behavior state should be queried. -
Returns the enabled state of the block’s placeholder behavior.
fun setPlaceholderEnabled( block: DesignBlock, enabled: Boolean,)
Enable or disable the placeholder function for a block.
-
block
: the block whose placeholder function should be enabled or disabled. -
enabled
: whether the function should be enabled or disabled.
fun isPlaceholderEnabled(block: DesignBlock): Boolean
Query whether the placeholder function for a block is enabled.
-
block
: the block whose placeholder function state should be queried. -
Returns the enabled state of the placeholder function.
fun supportsPlaceholderControls(block: DesignBlock): Boolean
Checks whether the block supports placeholder controls.
-
block
: The block to query. -
Returns whether the block supports placeholder controls.
fun setPlaceholderControlsOverlayEnabled( block: DesignBlock, enabled: Boolean,)
Enable or disable the visibility of the placeholder overlay pattern for a block.
-
block
: The block whose placeholder overlay should be enabled or disabled. -
enabled
: Whether the placeholder overlay should be shown or not.
fun isPlaceholderControlsOverlayEnabled(block: DesignBlock): Boolean
Query whether the placeholder overlay pattern for a block is shown.
-
block
: The block whose placeholder overlay visibility state should be queried. -
Returns the visibility state of the block’s placeholder overlay pattern.
fun setPlaceholderControlsButtonEnabled( block: DesignBlock, enabled: Boolean,)
Enable or disable the visibility of the placeholder button for a block.
-
block
: The block whose placeholder button should be shown or not. -
enabled
: Whether the placeholder button should be shown or not.
fun isPlaceholderControlsButtonEnabled(block: DesignBlock): Boolean
Query whether the placeholder button for a block is shown.
-
block
: The block whose placeholder button visibility state should be queried. -
Returns the visibility state of the block’s placeholder button.
Full Code
Here’s the full code:
// Check if block supports placeholder behaviorif (engine.block.supportsPlaceholderBehavior(block)) { // Enable the placeholder behavior engine.block.setPlaceholderBehaviorEnabled(block, enabled = true) val placeholderBehaviorIsEnabled = engine.block.isPlaceholderBehaviorEnabled(block)
// Enable the placeholder capabilities (interaction in Adopter mode) engine.block.setPlaceholderEnabled(block, enabled = true) val placeholderIsEnabled = engine.block.isPlaceholderEnabled(block)
// Check if block supports placeholder controls if (engine.block.supportsPlaceholderControls(block)) { // Enable the visibility of the placeholder overlay pattern engine.block.setPlaceholderControlsOverlayEnabled(block, enabled = true) val overlayEnabled = engine.block.isPlaceholderControlsOverlayEnabled(block)
// Enable the visibility of the placeholder button engine.block.setPlaceholderControlsButtonEnabled(block, enabled = true) val buttonEnabled = engine.block.isPlaceholderControlsButtonEnabled(block) }}