-
Notifications
You must be signed in to change notification settings - Fork 811
Rich Text Editor Blocks v16 Documentation #7305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eshanrnh
merged 21 commits into
umbraco:main
from
Newnab:feature/rte-blocks-documentation
Sep 23, 2025
Merged
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0dccd0c
WIP: Add new Blocks page for Rich Text Editor with view location docuβ¦
AdamBurtEtch 3b6a328
WIP: Edits to Blocks page for Rich Text Editor
AdamBurtEtch ad98bc1
Adding screenshots to RTE Blocks documentation
AdamBurtEtch 88bc50f
Add Blocks page to Summary
AdamBurtEtch c288647
Formatting fixes
AdamBurtEtch 0eda20b
Undo unnecessary whitespace change
AdamBurtEtch 75b28bc
Address PR feedback around acronym usage
AdamBurtEtch 1a492c0
Merge branch 'main' into feature/rte-blocks-documentation
iOvergaard 0646c6d
Restore reference to custom backoffice view
AdamBurtEtch e098108
Fix reference to RTE Blocks in Macros docs
AdamBurtEtch c4bdfa4
Remove double word "using"
AdamBurtEtch 4f2a22e
Fix for missing parenthesis in Summary
AdamBurtEtch b7e927a
Remove unnecessary bullet point spacing
AdamBurtEtch 06aae55
Ensure use of action words at start of list items
AdamBurtEtch 9d06059
Position images within instruction list
AdamBurtEtch e8e2e81
End list items with full stop
AdamBurtEtch 02b87f0
Fix broken link
AdamBurtEtch 6c11f31
Remove unnecessary link paths
AdamBurtEtch 94cb712
Update 16/umbraco-cms/fundamentals/backoffice/property-editors/built-β¦
eshanrnh 687852b
Update 16/umbraco-cms/fundamentals/backoffice/property-editors/built-β¦
eshanrnh 244aca1
Update 16/umbraco-cms/fundamentals/backoffice/property-editors/built-β¦
eshanrnh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
212 changes: 212 additions & 0 deletions
212
...e/property-editors/built-in-umbraco-property-editors/rich-text-editor/blocks.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| # Blocks | ||
|
|
||
| Blocks enable editors to insert structured content elements directly into the Rich Text Editor (RTE). Blocks are [Element Types](../../../../../../data/defining-content/#element-types) and can be configured with custom properties, styling, and behavior. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Blocks can be added to the Rich Text Editor when: | ||
|
|
||
| * Available Blocks are specified as part of the Rich Text Editor Data Type configuration | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * The **Insert Block** toolbar option is enabled in the Rich Text Editor | ||
|
|
||
|  | ||
|
|
||
| ## Configure Blocks | ||
|
|
||
| Blocks are Element Types that must be created before configuring them as blocks in the Rich Text Editor. You can create Element Types in the **Settings** > **Document Types** section | ||
|
|
||
| Blocks functionality can then be configured through the Rich Text Editor Data Type configuration as follows. | ||
|
|
||
| 1. Navigate to **Settings** > **Data Types**. | ||
| 2. Select your Rich Text Editor Data Type or create a new one. | ||
| 3. In the **Available Blocks** section, add the Element Types you want to make available as blocks. | ||
| 4. Configure each Block Type with the options described below. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|  | ||
|
|
||
| ### Editor Appearance | ||
|
|
||
| Configure how blocks appear and behave in the Content section: | ||
|
|
||
| * **Label** - Define how the block appears in the editor. Umbraco 16 uses [Umbraco Flavoured Markdown](../../../../../reference/umbraco-flavored-markdown.md) (UFM) syntax for dynamic labels. Use `{=propertyAlias}` to display property values (e.g., `{=author}` for a text property containing the name of an author, or `Written by: {=author}` for a label with static text and dynamic content) | ||
| * **Display Inline** - When enabled, blocks remain inline with surrounding text. When disabled, blocks appear on separate lines | ||
| * **Overlay size** - Set the size of the editing overlay when editors work with the block content | ||
|
|
||
|  | ||
|
|
||
| ### Data Models | ||
|
|
||
| Configure the content structure for your blocks: | ||
|
|
||
| * **Content model** - The Element Type that defines the main content properties for the block (required) | ||
| * **Settings model** - Optional Element Type that defines additional settings or configuration options for the block | ||
|
|
||
|  | ||
|
|
||
| ### Catalogue Appearance | ||
|
|
||
| Control how blocks appear in the block picker: | ||
|
|
||
| * **Background color** - Background color displayed behind the block icon or thumbnail | ||
| * **Icon Color** - Color of the Element Type icon | ||
| * **Thumbnail** - Custom image to replace the default Element Type icon | ||
|
|
||
| ## Working with Blocks | ||
|
|
||
| ### Adding Blocks to Content | ||
|
|
||
| Editors can add blocks to rich text content using the **Insert Block** toolbar button: | ||
|
|
||
| 1. Position the cursor where you want to insert the block | ||
| 2. Click the **Insert Block** button in the Rich Text Editor toolbar | ||
| 3. Select the desired Block from the available options | ||
| 4. Configure the block content (and settings, if provided) | ||
| 5. The block appears in the editor as a structured element | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|  | ||
|
|
||
|  | ||
|
|
||
|  | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Rendering Blocks | ||
|
|
||
| To display blocks on the frontend, create Partial Views for each Block. | ||
|
|
||
| {% hint style="info" %} | ||
| Rich Text Editor blocks use a different view location than Block List blocks. RTE blocks are placed in `Views/Partials/RichText/Components/`, while Block List blocks use `Views/Partials/BlockList/Components/`. | ||
| {% endhint %} | ||
|
|
||
| ### File Structure | ||
|
|
||
| * **Location**: `Views/Partials/RichText/Components/` | ||
| * **Naming**: Use the exact Element Type alias as the filename (e.g., `quoteBlock.cshtml` for alias `quoteBlock`) | ||
| * **Model**: `Umbraco.Cms.Core.Models.Blocks.RichTextBlockItem` | ||
|
|
||
| The different folder structure ensures that RTE blocks and Block List blocks can have separate rendering implementations, even when using the same Element Types. | ||
|
|
||
| {% hint style="warning" %} | ||
| The view filename must match the Element Type alias exactly. If you see the error `ArgumentException: ~/Views/Partials/richtext/Components/[filename].cshtml does not match any available view`, verify that your view filename matches your Element Type alias precisely. | ||
| {% endhint %} | ||
|
|
||
| ### Example Partial View | ||
|
|
||
| For a Block Type with Element Type alias `quoteBlock`: | ||
|
|
||
| ```csharp | ||
| @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.RichTextBlockItem> | ||
|
|
||
| @{ | ||
| var quoteText = Model.Content.Value("quoteText")?.ToString(); | ||
| var citation = Model.Content.Value("citation")?.ToString(); | ||
| } | ||
|
|
||
| <blockquote class="quote-block"> | ||
| @if (!string.IsNullOrEmpty(quoteText)) | ||
| { | ||
| <p class="quote-text">@Html.Raw(quoteText)</p> | ||
| } | ||
|
|
||
| @if (!string.IsNullOrEmpty(citation)) | ||
| { | ||
| <cite class="quote-citation">@citation</cite> | ||
| } | ||
| </blockquote> | ||
| ``` | ||
|
|
||
| ### Example with Settings Model | ||
|
|
||
| For a Call To Action block with Element Type alias `callToActionBlock` and settings model `callToActionBlockSettings`: | ||
|
|
||
| ```csharp | ||
| @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.RichTextBlockItem> | ||
| @using Umbraco.Cms.Core.Models | ||
|
|
||
| @{ | ||
| // Get link from Multi URL Picker | ||
| var linkPicker = Model.Content.Value<IEnumerable<Link>>("link"); | ||
| var link = linkPicker?.FirstOrDefault(); | ||
|
|
||
| // Get style from settings (if settings model exists) | ||
| var style = "primary"; // Default style | ||
| if (Model.Settings != null) | ||
| { | ||
| var settingsStyle = Model.Settings.Value("style")?.ToString(); | ||
| if (!string.IsNullOrEmpty(settingsStyle)) | ||
| { | ||
| style = settingsStyle.ToLower(); | ||
| } | ||
| } | ||
|
|
||
| // CSS class based on style setting | ||
| var cssClass = $"cta-button cta-button--{style}"; | ||
| } | ||
|
|
||
| @if (link != null && !string.IsNullOrEmpty(link.Url)) | ||
| { | ||
| <div class="cta-block"> | ||
| <a href="@link.Url" | ||
| class="@cssClass" | ||
| @(link.Target == "_blank" ? Html.Raw("target=\"_blank\" rel=\"noopener noreferrer\"") : Html.Raw(""))> | ||
| @(!string.IsNullOrEmpty(link.Name) ? link.Name : "Learn More") | ||
| </a> | ||
| </div> | ||
| } | ||
| ``` | ||
|
|
||
| ### Type-Safe Rendering with Models Builder | ||
|
|
||
| When using Models Builder, specify the Content and Settings models for type-safe access: | ||
|
|
||
| ```csharp | ||
| @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.RichTextBlockItem<QuoteBlock, QuoteBlockSettings>> | ||
| @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels; | ||
|
|
||
| @{ | ||
| var style = ""; | ||
| if (Model.Settings?.Color != null) | ||
| { | ||
| style = $"style=\"border-left-color: {Model.Settings.Color};\""; | ||
| } | ||
| } | ||
|
|
||
| <blockquote class="quote-block" @Html.Raw(style)> | ||
| @if (!string.IsNullOrEmpty(Model.Content.QuoteText)) | ||
| { | ||
| <p class="quote-text">@Html.Raw(Model.Content.QuoteText)</p> | ||
| } | ||
|
|
||
| @if (!string.IsNullOrEmpty(Model.Content.Citation)) | ||
| { | ||
| <cite class="quote-citation">@Model.Content.Citation</cite> | ||
| } | ||
| </blockquote> | ||
| ``` | ||
|
|
||
| ## Build a Custom Backoffice View | ||
|
|
||
| Building Custom Views for Block representations in Backoffice is the same for all Block Editors. [Read about building a Custom View for Blocks here](../../../../../tutorials/creating-custom-views-for-blocklist.md). | ||
|
|
||
| ## Best Practices | ||
|
|
||
| ### Content Design | ||
|
|
||
| * Design blocks for reusable content patterns | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * Keep block content focused on a single purpose | ||
| * Use descriptive labels that help editors understand the block's function | ||
|
|
||
| ### Performance | ||
|
|
||
| * Avoid creating too many Blocks - this can overwhelm content editors | ||
| * Use appropriate caching strategies for block rendering | ||
| * Consider the impact of complex blocks on editor performance | ||
|
|
||
| ### Accessibility | ||
|
|
||
| * Ensure block markup follows accessibility guidelines | ||
| * Provide meaningful labels and descriptions | ||
| * Test block rendering with screen readers | ||
|
|
||
| ## Related Articles | ||
|
|
||
| * [Element Types](../../../../../../data/defining-content/#element-types) | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * [Rich Text Editor Configuration](../configuration.md) | ||
| * [Rich Text Editor Extensions](../extensions.md) | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+185 KB
...aco-property-editors/rich-text-editor/images/rte-blocks-adding-to-content-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+174 KB
...aco-property-editors/rich-text-editor/images/rte-blocks-adding-to-content-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+106 KB
...aco-property-editors/rich-text-editor/images/rte-blocks-adding-to-content-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+143 KB
...co-property-editors/rich-text-editor/images/rte-blocks-data-models-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+247 KB
...-property-editors/rich-text-editor/images/rte-blocks-datatype-configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+141 KB
...perty-editors/rich-text-editor/images/rte-blocks-editor-appearance-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+310 KB
...o-property-editors/rich-text-editor/images/rte-blocks-toolbar-insert-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.