formaui-net.Blazor.Composer
1.0.0-preview.27
Prefix Reserved
dotnet add package formaui-net.Blazor.Composer --version 1.0.0-preview.27
NuGet\Install-Package formaui-net.Blazor.Composer -Version 1.0.0-preview.27
<PackageReference Include="formaui-net.Blazor.Composer" Version="1.0.0-preview.27" />
<PackageVersion Include="formaui-net.Blazor.Composer" Version="1.0.0-preview.27" />
<PackageReference Include="formaui-net.Blazor.Composer" />
paket add formaui-net.Blazor.Composer --version 1.0.0-preview.27
#r "nuget: formaui-net.Blazor.Composer, 1.0.0-preview.27"
#:package formaui-net.Blazor.Composer@1.0.0-preview.27
#addin nuget:?package=formaui-net.Blazor.Composer&version=1.0.0-preview.27&prerelease
#tool nuget:?package=formaui-net.Blazor.Composer&version=1.0.0-preview.27&prerelease
Forma.Blazor.Composer
FormaComposer, a rich text authoring surface for Blazor: an editor with the toolbar, dialogs,
views and attachments an article or a page body needs, assembled from plugins the host picks. It is
a Forma input bound to a ComposerDocument, the content together with the format it is written
in, and it holds every HTML document to the library's sanitizer on the way in and on the way out.
.NET 11 · Blazor components.
Install
dotnet add package formaui-net.Blazor.Composer --prerelease
The package depends on formaui-net.Blazor,
the library it is built on, and on
formaui-net.Framework.Composer.Extensibility,
the contracts a plugin is written against.
Register
using Forma.Blazor;
using Forma.Blazor.Components.Composer;
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.AddFormaServerIntegration();
builder.Services.AddFormaComposer(composer => composer
.AddRichTextEditor(editor => editor.TryAddDefaultFeatures())
.TryAddDefaultPlugins());
AddFormaServerIntegration() registers what the composer needs from the library, the HTML sanitizer among it.
AddFormaComposer describes, once, the plugins every composer in the application is built from.
Use
@using Forma.Blazor.Components.Composer
@using Forma.Framework.Composer.Documents
<FormaComposer @bind-Value="_body" />
@code {
private ComposerDocument _body = new(ComposerDocumentFormat.Html, "<p>Draft.</p>");
}
FormaComposer binds with @bind-Value, inside an EditForm or on its own. The HTML the host
reads back is what the sanitizer allowed; a host persisting it still sanitizes on the server,
because the endpoint receiving the document cannot trust what the browser sent.
Two presets carry a fixed set of plugins of their own and need no AddFormaComposer:
@using Forma.Blazor.Components.Composer.RichTextEditor
<FormaStandardRichTextEditor @bind-Value="_body" />
<FormaCompactRichTextEditor @bind-Value="_summary" />
| Component | What it is |
|---|---|
FormaComposer |
The composer: the editors it is given, each with its own toolbar, a switcher between editors and views, the attachments list and the status strip. |
FormaStandardRichTextEditor |
Rich text with paragraph formats, typography, basic formatting, lists, alignment and direction, links, images, tables and horizontal rules. |
FormaCompactRichTextEditor |
Rich text with typography, basic formatting, alignment and direction, and links, for a blurb or a summary. |
All three take Disabled, ReadOnly and Options, and a read-only composer shows no toolbar.
FormaComposer also takes Plugins, a ComposerDefinition of its own in place of the
application's, ActiveEditorId with ActiveEditorIdChanged to bind the active editor, and
History for an undo stack the host holds; SwitchEditorAsync switches the editor from code.
ComposerOptions sets ShowToolbar, ShowEditorSwitcher, DefaultEditorId for the editor that
opens when the document's format alone does not decide it, IsResizable for the grip that drags
the composer taller, HistoryCapacity for the undo stack, and PlainTextUpdateOn for when text
typed into the plain text editor reaches the composer: as each character is typed, or, set to
TextUpdate.Change, as the editor commits its edit, as it loses the focus or before a shortcut runs.
Choosing the plugins
Every editor and every capability is a plugin, and where a plugin is registered is where it applies: on the composer it reaches every editor and view, under an editor that editor's surface, under a view that view's bar. A plugin with an options record is configured where it is registered.
using Forma.Blazor.Components.Composer;
using Forma.Blazor.Components.Composer.Plugins;
using Forma.Blazor.Components.Composer.RichTextEditor.Plugins;
using Forma.Blazor.Components.Composer.RichTextEditor.Views;
builder.Services.AddFormaComposer(composer => composer
.AddRichTextEditor(editor => editor
.AddFeaturePlugin<ParagraphFormatPlugin>()
.AddFeaturePlugin<BasicFormattingPlugin>()
.AddFeaturePlugin<ListPlugin>()
.AddFeaturePlugin<LinkPlugin>()
.AddFeaturePlugin<ImagePlugin>()
.AddFeaturePlugin<TablePlugin, TablePluginOptions>(options => options.MaxRowCount = 12)
.AddFeaturePlugin<FileUploadPlugin>()
.AddViewPlugin<RichTextPreviewViewPlugin>())
.AddFeaturePlugin<MaximizePlugin>());
Each composer builds its own instance of every plugin from the description. A composer with no editor registered uses the plain text editor.
TryAddDefaultFeatures() on the rich text editor registers every rich text plugin, attaching,
the selection bar and both views; on the plain text editor it registers attaching.
TryAddDefaultPlugins() on the composer registers maximizing and the shortcuts reference. Each
adds only what that scope has not registered itself, so a host changes one plugin's options by
registering it with them beside the defaults.
Editors
| Plugin | Format | What it authors |
|---|---|---|
RichTextEditorPlugin |
Html |
A visual canvas, hosting the rich text plugins, the selection bar and the two views. |
PlainTextEditorPlugin |
PlainText |
A text area. |
Switching editor is an undoable step.
Rich text plugins
In Forma.Blazor.Components.Composer.RichTextEditor.Plugins, each registered under the rich text
editor.
| Plugin | Contributes | Options |
|---|---|---|
BasicFormattingPlugin |
Bold, italic, underline, strikethrough, inline code, clear formatting, and subscript and superscript where its options include them | BasicFormattingPluginOptions: IncludeSubscriptAndSuperscript |
ParagraphFormatPlugin |
Paragraph, headings 1 to 6, blockquote, lead paragraph | |
TypographyPlugin |
Font family, font size, line height, text color, highlight color | TypographyPluginOptions: the choices offered, each color a TypographyColor with the English name readers know it by, and FontSizeUnit, Rem or Points |
ListPlugin |
Bulleted and numbered lists, indent, outdent | |
AlignmentBidiPlugin |
Alignment and paragraph direction | |
LinkPlugin |
Links and anchors | |
ImagePlugin |
An image by address, with alt text and caption | |
VideoPlugin |
A video placeholder carrying the address, title and autoplay | |
TablePlugin |
Tables, their rows, columns and header row | TablePluginOptions: default and maximum rows and columns, and IncludeHeader |
HorizontalRulePlugin |
A thematic break | |
EmojiPlugin |
An emoji picker | EmojiPluginOptions: the picker's EmojiPickerOptions |
SpecialCharacterPlugin |
A palette of typographic and mathematical symbols | SpecialCharacterPluginOptions: the Characters offered |
ClipboardPlugin |
Paste as plain text, paste from Word, select all | |
TemplatePlugin |
Document templates, inserted at the caret or replacing the document | TemplatePluginOptions: the ComposerTemplate list, and ReplaceContent |
EmbedPlugin |
An embed placeholder the host resolves |
Double-clicking a link, image, video or embed reopens its dialog. Pasted markup passes through the
sanitizer as typed content does, and so does a template, markup a plugin writes into the canvas, a
document a converter produces and a document the host's History holds. A stored file a plugin
inserts at an address its element doesn't allow goes in as its name alone.
The link and image dialogs refuse an address the sanitizer wouldn't keep on their element: a link takes a web, mail or telephone address or a path within the site, and an image a web address, a path within the site or an inline picture.
Plugins for any editor
In Forma.Blazor.Components.Composer.Plugins.
| Plugin | Contributes |
|---|---|
FileUploadPlugin |
Attaching files from the author's device to ComposerDocument.Attachments, listed beneath the canvas; FileUploadPluginOptions.Picker sets the files accepted, a file larger than its MaxFileSize, or than 10 MiB where it sets none, refused as it is picked. |
MaximizePlugin |
A toggle filling the viewport with the composer. |
SelectionBarPlugin |
A toggle for the formatting bar that follows a selection. |
ShortcutsPlugin |
A reference of every shortcut the surface answers, opened from the toolbar or with Ctrl+/. |
An attachment opens in a new tab from its name in the list. One whose address a link doesn't allow,
javascript: among them, is listed by its name alone, as
Forma.Framework.Sanitization
sets out.
Views
In Forma.Blazor.Components.Composer.RichTextEditor.Views, each registered under the rich text
editor and reached from the switcher.
| Plugin | Shows |
|---|---|
RichTextPreviewViewPlugin |
The document as a reader sees it, at the width on offer, on a paper size or at a device width, turned to landscape or zoomed; printed, or exported as an HTML file. |
RichTextSourceViewPlugin |
The document's HTML one block per numbered line; copied, or downloaded. |
What a host supplies
Each registration is optional and enables one thing.
| Registration | What it enables |
|---|---|
IFileStore (Forma.Framework.Resources) |
Uploading attachments through FileUploadPlugin, into the store. |
IComposerDocumentConverter (Forma.Framework.Composer.Documents) |
Switching between editors whose formats differ, for the pair of formats it converts. |
IHtmlSanitizer or IMarkupPolicy (Forma.Framework.Sanitization) |
A sanitizer of the host's own, or the library's with rules of the host's own, registered before AddFormaServerIntegration(), and in a WebAssembly client before AddFormaWebAssemblyIntegration(). |
using Forma.Framework.Resources;
builder.Services.AddScoped<IFileStore, UploadFolderStore>();
Forma.Framework.Resources
documents the store, and
Forma.Framework.Sanitization
the sanitizer and its policy.
Saving what authors write
The sanitizer's policy decides what markup a document may hold, not the plugins chosen. A composer
without TypographyPlugin or ImagePlugin offers no button for a font or a picture, yet pasted or
submitted HTML still carries whatever the policy allows; a host that must refuse a construct
narrows the policy.
The composer sanitizes as the author writes, and the endpoint saving the document sanitizes again,
because it cannot trust what the browser sent. Both apply one policy when the host registers it,
as an IMarkupPolicy or an IHtmlSanitizer, ahead of Forma's registrars on the server and in a
WebAssembly client alike, and resolves IHtmlSanitizer where it saves:
using Forma.Framework.Sanitization;
builder.Services.AddSingleton<IMarkupPolicy, ArticleMarkupPolicy>();
app.MapPost("/articles/{id}", async (string id, ArticleBody body, IHtmlSanitizer sanitizer, ArticleStore store) =>
await store.SaveAsync(id, sanitizer.Sanitize(body.Html)));
What the composer kept passes that second pass unchanged, so a document saved and loaded again opens as the author left it.
Rendering the document to readers
The library's forma-prose.css, which FormaPageHead links, styles an authored document:
headings, quotes, code, lists, tables, figures and links. A host renders a document inside an
element carrying the forma-prose class, so readers see it as the canvas and the preview showed
it.
The video and embed plugins write placeholders, which a host replaces with the player, form or widget each stands for:
<div class="forma-composer-video" data-video-url="…" data-video-title="…" data-autoplay="true">…</div>
<div class="forma-composer-embed" data-embed-type="…" data-embed-id="…" data-settings="…">…</div>
A placeholder is a div its class names, whose attributes carry what it stands for, so a website
and a native application render one stored document alike. A renderer replaces the whole div,
reading its attributes rather than its content:
| Placeholder | Attribute | Holds |
|---|---|---|
forma-composer-video |
data-video-url |
The video's address, always present |
data-video-title |
Its title, where the author gave one | |
data-autoplay |
true where it plays as it is shown, and absent otherwise |
|
forma-composer-embed |
data-embed-type |
The kind of thing the host embeds |
data-embed-id |
Which one of that kind | |
data-settings |
The settings the author gave it, where there are any |
The video placeholder holds a paragraph linking to its address, named by its title or by the
address, so it reads as a link where it is left as is; the embed placeholder holds [Embed: …]
with its type, or its id where it has no type.
Localization
The composer's strings localize through the library's localization, with AddJsonLocalization() from
formaui-net.Framework.Localization.Json.
Each language is a locale pack the application references, such as
formaui-net.Blazor.Locales.Hebrew or formaui-net.Blazor.Locales.Spanish.
Extending
A class implementing IComposerFeaturePlugin adds a capability, one implementing
IComposerEditorPlugin an editor with a canvas of its own, and one implementing
IComposerViewPlugin a view; each is registered like the package's own. A format is a value a host
makes with new ComposerDocumentFormat("…"), and an IComposerDocumentConverter carries a document
between two formats.
Forma.Framework.Composer.Extensibility
documents the contracts, with an example plugin.
License
Apache License 2.0, under the repository's LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- formaui-net.Blazor (= 1.0.0-preview.27)
- formaui-net.Framework.Browser (= 1.0.0-preview.27)
- formaui-net.Framework.Browser.Interop (= 1.0.0-preview.27)
- formaui-net.Framework.Composer (= 1.0.0-preview.27)
- formaui-net.Framework.Composer.Extensibility (= 1.0.0-preview.27)
- formaui-net.Framework.Css (= 1.0.0-preview.27)
- formaui-net.Framework.Emojis (= 1.0.0-preview.27)
- formaui-net.Framework.Files (= 1.0.0-preview.27)
- formaui-net.Framework.Icons (= 1.0.0-preview.27)
- formaui-net.Framework.Input (= 1.0.0-preview.27)
- formaui-net.Framework.Input.Interop (= 1.0.0-preview.27)
- formaui-net.Framework.JavaScript.Interop (= 1.0.0-preview.27)
- formaui-net.Framework.Localization (= 1.0.0-preview.27)
- formaui-net.Framework.Media (= 1.0.0-preview.27)
- formaui-net.Framework.Resources (= 1.0.0-preview.27)
- formaui-net.Framework.Sanitization (= 1.0.0-preview.27)
- formaui-net.Framework.Share (= 1.0.0-preview.27)
- formaui-net.Framework.Toolbar (= 1.0.0-preview.27)
- Microsoft.AspNetCore.Components (>= 11.0.0)
- Microsoft.AspNetCore.Components.Forms (>= 11.0.0)
- Microsoft.AspNetCore.Components.Web (>= 11.0.0)
- Microsoft.JSInterop (>= 11.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.27 | 40 | 12/3/2026 |
| 1.0.0-preview.26 | 51 | 12/3/2026 |
| 1.0.0-preview.25 | 49 | 12/2/2026 |
| 1.0.0-preview.24 | 55 | 12/1/2026 |
| 1.0.0-preview.23 | 63 | 11/30/2026 |
| 1.0.0-preview.22 | 58 | 11/30/2026 |
| 1.0.0-preview.21 | 64 | 11/29/2026 |
| 1.0.0-preview.20 | 73 | 11/26/2026 |
| 1.0.0-preview.19 | 63 | 11/26/2026 |
| 1.0.0-preview.18 | 62 | 11/26/2026 |
| 1.0.0-preview.17 | 59 | 11/26/2026 |
| 1.0.0-preview.16 | 56 | 11/24/2026 |
| 1.0.0-preview.15 | 61 | 11/23/2026 |
| 1.0.0-preview.14 | 54 | 11/23/2026 |
| 1.0.0-preview.13 | 58 | 11/21/2026 |
| 1.0.0-preview.12 | 58 | 11/20/2026 |
| 1.0.0-preview.11 | 57 | 11/18/2026 |
| 1.0.0-preview.10 | 67 | 11/17/2026 |
| 1.0.0-preview.9 | 93 | 11/17/2026 |
| 1.0.0-preview.8 | 67 | 11/17/2026 |
What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.27/CHANGELOG.md