-
Notifications
You must be signed in to change notification settings - Fork 0
Components Definition
Sébastien Bouez edited this page Aug 22, 2025
·
1 revision
This guide explains how to create XML component definition files for the ExpressiveWeb framework. These files allow you to define reusable components in the visual editor by specifying their structure, behavior, and features.
Each XML component file follows this basic structure:
<?xml version="1.0" encoding="utf-8" ?>
<Component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/sebbouez/ExpressiveWeb/refs/heads/main/Schemas/schema_components.xsd">
<!-- Component definition -->
</Component><UID>bootstrap.Card</UID>- Description: Unique identifier for the component within the kit
-
Recommended format:
[kit_name].[component_name] - Usage: Reference the component in other components or actions
<Name>Card</Name>- Description: Name displayed in the editor's user interface
- Usage: User-friendly name in the component palette
<Template>
<![CDATA[
<div class="card">
<slot/>
</div>
]]>
</Template>- Description: HTML code generated by the component
-
<slot/>: Indicates where child elements will be inserted - CDATA: Encapsulates HTML to avoid XML conflicts
<Allows>*</Allows>
<!-- or -->
<Allows>bootstrap.Button;bootstrap.Text</Allows>
<!-- or -->
<Allows>text</Allows>-
*: Allows all types of children -
UID List: Separate with
;to allow only these components -
Predefined values:
-
text: Text content only -
paragraphs: Paragraph elements -
headings: Heading elements
-
<Denies>bootstrap.Card</Denies>-
Description: Forbids certain components even if
Allowsis set to* - Usage: Prevent problematic nesting (e.g., card within card)
<Family>Layout</Family>- Description: Logical group to which the component belongs
- Usage: Organization in the editor's palette
<Slots>.card-body</Slots>- Description: Defines precisely where child elements will be inserted
- Format: Valid CSS selectors
- Usage: Complex templates with specific insertion zones
<Variants>
<Variant name="Card model 1" className="card1"/>
<Variant name="Card model 2" className="card2"/>
</Variants>- Description: Offers different visual variations of the component
-
Attributes:
-
name: Name displayed in the interface -
className: CSS class applied
-
Use the correct Xml Schema Description to get the list of supported features.
<Features>
<InlineEdit/>
</Features>- Description: Enables inline editing of text content
- Usage: Text components, headings, paragraphs
Use the correct Xml Schema Description to get the list of supported actions.
<Actions>
<Action Header="Add card" Command="AppendChild" Params="bootstrap.Card"/>
<Action Header="Add button" Command="AppendChild" Params="bootstrap.Button"/>
</Actions>- Description: Defines actions available in the context menu
-
Attributes:
-
Header: Text displayed in the context menu -
Command: Command to execute -
Params: Command parameters
-
-
Consistent UIDs: Use a prefix for your kit (e.g.,
bootstrap.,mykit.) - Explicit names: Choose clear and descriptive names
- Convention: Use PascalCase for component names
-
Logical relationships: Clearly define parent-child relationships with
Allows/Denies - Modularity: Create reusable and composable components
- Granularity: Balance between overly generic and overly specific components
- Valid HTML: Ensure generated HTML is valid
- CSS Classes: Use classes consistent with your CSS framework
- Accessibility: Include appropriate ARIA attributes
- XML Comments: Document complex components
- Testing: Validate your components in the editor
- Versioning: Manage versions of your component kits
- XSD Schema: Always use schema reference for validation
- Tools: Use an XML editor with real-time validation
<?xml version="1.0" encoding="utf-8" ?>
<Component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/sebbouez/ExpressiveWeb/refs/heads/main/Schemas/schema_components.xsd">
<UID>bootstrap.Card</UID>
<Name>Card</Name>
<Family>Layout</Family>
<Slots>.card-body</Slots>
<Variants>
<Variant name="Standard card" className="card"/>
<Variant name="Card with border" className="card border"/>
</Variants>
<Features>
<ContextualBoxStyle EnableBorderSettings="true" EnableBackgroundSettings="true" />
</Features>
<Actions>
<Action Header="Add title" Command="AppendChild" Params="bootstrap.CardTitle"/>
<Action Header="Add text" Command="AppendChild" Params="bootstrap.CardText"/>
</Actions>
<Allows>bootstrap.CardTitle;bootstrap.CardText;bootstrap.Button</Allows>
<Denies>bootstrap.Card</Denies>
<Template>
<![CDATA[
<div class="card">
<div class="card-body">
<slot/>
</div>
</div>
]]>
</Template>
</Component>This structure enables the creation of rich and interactive component kits for the ExpressiveWeb visual editor, providing an intuitive and powerful development experience.