Class GrapesJsBlock

java.lang.Object
io.jmix.messagetemplatesflowui.kit.component.GrapesJsBlock
All Implemented Interfaces:
Serializable

public class GrapesJsBlock extends Object implements Serializable
A block is an object that allows the end user to reuse components. By default, added blocks are available in the blocks section for adding to the message template using the drag-n-drop action.
See Also:
  • Field Details

    • id

      protected final String id
    • label

      protected String label
    • category

      protected String category
    • content

      protected String content
    • attributes

      protected String attributes
    • icon

      protected String icon
  • Constructor Details

    • GrapesJsBlock

      public GrapesJsBlock(String id)
  • Method Details

    • create

      public static GrapesJsBlock.Builder create(String id)
      Creates GrapesJsBlock.Builder that can be used to create blocks via the Fluent API.
      Parameters:
      id - unique ID of the block
      Returns:
      GrapesJsBlock.Builder for subsequent use via the Fluent API
    • getId

      public String getId()
      Returns:
      unique ID of the block
    • getLabel

      public String getLabel()
      Returns:
      label of the block
    • setLabel

      public void setLabel(String label)
      Sets the label of the block. The label is used to name a block in the blocks section.
      Parameters:
      label - label to set
    • getCategory

      public String getCategory()
      Returns:
      category of the block in the blocks section
    • setCategory

      public void setCategory(String category)
      Sets the category to which the block will be located in the blocks section.
      Parameters:
      category - category to set
    • getContent

      public String getContent()
      Returns:
      HTML content of the block
    • setContent

      public void setContent(String content)
      Sets the HTML content for the block. The content will be rendered in the GrapesJs template when you drag-n-drop a block into the template.
      Parameters:
      content - HTML content to set
    • getAttributes

      public String getAttributes()
      Returns:
      additional attributes of the block
    • setAttributes

      public void setAttributes(String attributes)
      Sets additional attributes of the block as a JSON string. Additional attributes can be used to set additional parameters.
      For example, you can set text that will be displayed as a tooltip when hovering over a block:
      
       grapesJsBlock.setAttributes("""
                           {
                               "title": "Insert another one"
                           }
               """);
       
      Parameters:
      attributes - JSON string attributes to set
    • getIcon

      public String getIcon()
      Returns:
      icon of the block in the block section
    • setIcon

      public void setIcon(String icon)
      Sets icon for the block in the block section. The icon must be from an existing icon set (e.g. vaadin:picture).
      Parameters:
      icon - the icon name with collection prefix