getCurrentSelectedBlock

Retrieves the JSON structure of a selected component on the canvas of a marketing content item. Use this wire adapter when building a CMS extension for Marketing Cloud Next that interacts with components on the canvas.

Syntax 

1import { LightningElement, wire, api } from "lwc";
2import { getCurrentSelectedBlock } from "experience/blockBuilderApi";
3
4export default class Example extends LightningElement {
5  @api paragraphText;
6
7  @wire(getCurrentSelectedBlock, {})
8  onCurrentSelectedBlock({ data }) {
9    if (data) {
10      const selectedBlockInUEMFormat = data;
11
12      // check the type of the block
13      const blockDefinition = selectedBlockInUEMFormat.definition;
14
15      // handle a paragraph block
16      if (blockDefinition === "lightning/paragraph") {
17        const paragraphBlock = selectedBlockInUEMFormat;
18
19        // extract the text attribute from the paragraph block
20        this.paragraphText = paragraphBlock.attributes.text;
21      }
22
23      // do other things with the block...
24    } else {
25      // no block is currently selected
26      this.paragraphText = "";
27    }
28  }
29}

Returns 

  • data—the JSON structure of the selected component. Undefined if the user hasn’t selected a component.

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.