From 708524ada6672822dc4b35055cfd4e6ac48a2679 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:52:40 +0200 Subject: [PATCH 1/3] fix(composer): show menu values as written and name the colors ToolbarOption.IsTitleVerbatim marks a title that is a value, and the composer leaves it as written: the font families, sizes, line heights, special characters and zoom levels, each of which it looked up as a key, so the rich text editor's toolbar threw under RequireMatchingLocalization outside English. The color menus offer TypographyColors, labeled by names Hebrew and Spanish localize, in place of hex codes. --- CHANGELOG.md | 13 +++++ docs/composer-design.md | 3 +- src/Blazor/Forma.Blazor.Composer/README.md | 2 +- .../Plugins/SpecialCharacterPlugin.cs | 1 + .../RichTextEditor/Plugins/TypographyColor.cs | 8 +++ .../Plugins/TypographyPlugin.cs | 28 +++++++---- .../Plugins/TypographyPluginOptions.cs | 25 ++++++++-- .../Views/RichTextPreviewViewPlugin.cs | 1 + .../Editing/ComposerToolbarLayout.cs | 5 +- .../Forma.Framework.Toolbar/README.md | 3 +- .../Forma.Framework.Toolbar/ToolbarOption.cs | 3 ++ .../Forma.Blazor.Composer/he.json | 8 +++ .../Forma.Blazor.Composer/es.json | 8 +++ .../Forma.Blazor.Composer.BUnit.Tests.csproj | 1 + .../FormaComposerTests.razor | 28 +++++++++++ .../Forma.Blazor.Composer.Tests.csproj | 1 + .../RichTextEditor/RichTextPluginTests.cs | 49 +++++++++++++++++++ .../Editing/ComposerToolbarLayoutTests.cs | 25 ++++++++++ 18 files changed, 193 insertions(+), 19 deletions(-) create mode 100644 src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyColor.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 252a8e906..579c8141a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ release is cut, and reads *Unreleased* until then. It lists every change a consu breaks what the release before it allowed says how to migrate, as [Versioning's rules](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.5/docs/releases.md#the-release-record) set out. What Forma gained before its first release, month by month, is in [the feature history](FEATURE-HISTORY.md). +## `1.0.0-preview.11` + +*Unreleased* + +- `ToolbarOption.IsTitleVerbatim` marks a title that is a value shown as written, such as a font's name or a size, and + the composer leaves such a title as it is. Its font families, font sizes, line heights, special characters and zoom + levels are verbatim. It looked each of them up as a key, so the rich text editor's toolbar threw under + `RequireMatchingLocalization` in a language other than English, and `Diagnostics` reported every one missing. +- `TypographyPluginOptions.TextColors` and `HighlightColors` are `TypographyColor`s, each a color's English name and + its `CssColor`, and the color menus label each color by its name, which Hebrew and Spanish localize. They labeled + each by its hex code, which a screen reader reads out character by character. To migrate, name each color: + `new TypographyColor("Red", CssColor.FromHex(0xd32f2f))`. + ## `1.0.0-preview.10` *November 17, 2026* diff --git a/docs/composer-design.md b/docs/composer-design.md index b5e0e8e7a..f9bbf7f8f 100644 --- a/docs/composer-design.md +++ b/docs/composer-design.md @@ -80,7 +80,7 @@ Key bindings come through `IComposerKeyBindingSource`, which every plugin is and A **view** has the shape of an editor — its own component, rows, items and assets, maximizable like any surface — but shows one editor's document read-only rather than editing it. An editor offers a view by registering it as a child, and a feature registered under that view contributes to its rows exactly as one registered under an editor contributes to the editor's; the layout for a view takes the built-in row, the rows the view declared, and what is registered under the view or at the composer root, and nothing else — so neither an editor's formatting nor a command acting on the document, such as attaching a file, lands on its preview. The switcher lists the active editor's views as trailing tabs after the editors, and those tabs are the only way in: a view is its own surface, not a toolbar toggle. A plugin reports which of its own toggles and options are active through `ActiveStates`, which is how a view's paper size and zoom show in its bar without going through the selection. -`Title` is the **English source string**, not a resolved localized string, and so is every title and row label a plugin contributes; the composer localizes them when it draws them. A plugin never resolves a localizer of its own — one that did would capture whichever culture it was built under, and would have to carry the composer's words for every group it joins. What a plugin does name is **where its localization lives**, through `LocaleSourceType`, the way a component part names its composite's: the composer reads a plugin's titles from that type's locale, so a plugin shipped from another package brings its own strings, and reads those of a plugin naming none from its own. A group the composer provides, named in `ComposerGroups`, takes the composer's title whichever plugin declares it, as a row named in `ComposerRows` takes the composer's label, so a plugin joining one never carries the composer's word for it. Every title is read from one locale, so a title missing from it is a miss the localization's checks report. Localization happens before contributions are merged, since a merged group no longer says which plugin declared each item in it. +`Title` is the **English source string**, not a resolved localized string, and so is every title and row label a plugin contributes; the composer localizes them when it draws them. A menu option whose title is a value rather than words, a font's name, a size, a line height, a character, a zoom level, is marked `IsTitleVerbatim`, and the composer shows it as written; a color is offered by its name. A plugin never resolves a localizer of its own — one that did would capture whichever culture it was built under, and would have to carry the composer's words for every group it joins. What a plugin does name is **where its localization lives**, through `LocaleSourceType`, the way a component part names its composite's: the composer reads a plugin's titles from that type's locale, so a plugin shipped from another package brings its own strings, and reads those of a plugin naming none from its own. A group the composer provides, named in `ComposerGroups`, takes the composer's title whichever plugin declares it, as a row named in `ComposerRows` takes the composer's label, so a plugin joining one never carries the composer's word for it. Every title is read from one locale, so a title missing from it is a miss the localization's checks report. Localization happens before contributions are merged, since a merged group no longer says which plugin declared each item in it. ### 3.1a Composing a composer @@ -556,3 +556,4 @@ These are correctness requirements for every Forma component, and the composer i | C19 | Whose defaults does an editor get? | Its own. The editor builder is typed by its editor, so each editor's package extends it with defaults of its own and one editor's defaults cannot be called on another. The composer's defaults are what belongs on every surface, which is maximizing and the shortcut reference; attaching is each editor's, since a view never edits the document (§4.3a). | | C20 | How does a capability that joins the composer to another component ship? | As an AddOn of its own, `Forma.AddOns.Composer.Plugins.{Component}` (§9), so neither component's package depends on the other and a host wanting both adds the one package that joins them. | | C21 | Where does a plugin from another package keep its labels' localization? | With itself. A plugin names the type whose locale files hold its labels through `LocaleSourceType`, and the composer reads its titles from that type's locale alone. A group the composer provides, named in `ComposerGroups`, takes the composer's own title, as a standard row does, so a plugin joining one carries only its own commands' words, and a title read from one locale makes a missing one a miss the localization's checks report (§3.1). | +| C22 | How does a menu option that is a value, a font's name, a size, a character, stay unlocalized? | The plugin marks it `ToolbarOption.IsTitleVerbatim`, false unless set, and the composer shows its title as written, so the plugin that knows it is listing values says so and every title the composer looks up is text a pack can carry. A color is offered by its name, a `TypographyColor`, which localizes and gives a screen reader a word in place of a hex code. A template keeps its `Title`: it is the host's own words, which the host localizes through its own files (§3.1). | diff --git a/src/Blazor/Forma.Blazor.Composer/README.md b/src/Blazor/Forma.Blazor.Composer/README.md index 9bf416885..3dfc262fe 100644 --- a/src/Blazor/Forma.Blazor.Composer/README.md +++ b/src/Blazor/Forma.Blazor.Composer/README.md @@ -131,7 +131,7 @@ editor. | --- | --- | --- | | `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, and `FontSizeUnit`, `Rem` or `Points` | +| `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 | | diff --git a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/SpecialCharacterPlugin.cs b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/SpecialCharacterPlugin.cs index 0cb02dea6..019a1e621 100644 --- a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/SpecialCharacterPlugin.cs +++ b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/SpecialCharacterPlugin.cs @@ -45,6 +45,7 @@ public sealed class SpecialCharacterPlugin( { Id = $"char-{c}", Title = c, + IsTitleVerbatim = true, Command = $"{InsertCharacterPrefix}{c}", })], }, diff --git a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyColor.cs b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyColor.cs new file mode 100644 index 000000000..85213b96a --- /dev/null +++ b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyColor.cs @@ -0,0 +1,8 @@ +namespace Forma.Blazor.Components.Composer.RichTextEditor.Plugins; + +using Forma.Framework.Css; + +/// A color offers, with the name a reader knows it by. +/// The color's English name, which the composer localizes as its option's label and accessible name. +/// The color the text or its highlight takes. +public sealed record TypographyColor(string Name, CssColor Color); diff --git a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyPlugin.cs b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyPlugin.cs index c08bded77..181fe6a41 100644 --- a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyPlugin.cs +++ b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyPlugin.cs @@ -57,6 +57,7 @@ public sealed class TypographyPlugin( { Id = $"font-family:{family}", Title = family, + IsTitleVerbatim = true, Command = $"{FontFamilyCommand}:{family}", PreviewStyle = $"font-family:{family}", })], @@ -70,6 +71,7 @@ public sealed class TypographyPlugin( { Id = $"font-size:{ToCssSize(size)}", Title = size, + IsTitleVerbatim = true, Command = $"{FontSizeCommand}:{ToCssSize(size)}", })], }, @@ -82,6 +84,7 @@ public sealed class TypographyPlugin( { Id = $"line-height:{height}", Title = height, + IsTitleVerbatim = true, Command = $"{LineHeightCommand}:{height}", })], }, @@ -100,10 +103,10 @@ public sealed class TypographyPlugin( Icon = Glyph.FontColor, Options = [.. Options.TextColors.Select(color => new ToolbarOption { - Id = $"text-color:{color}", - Title = color, - Command = $"{TextColorCommand}:{color}", - Swatch = color, + Id = $"text-color:{color.Color}", + Title = color.Name, + Command = $"{TextColorCommand}:{color.Color}", + Swatch = color.Color.ToString(), })], }, new ToolbarMenu @@ -113,10 +116,10 @@ public sealed class TypographyPlugin( Icon = Glyph.Highlight, Options = [.. Options.HighlightColors.Select(color => new ToolbarOption { - Id = $"highlight-color:{color}", - Title = color, - Command = $"{HighlightColorCommand}:{color}", - Swatch = color, + Id = $"highlight-color:{color.Color}", + Title = color.Name, + Command = $"{HighlightColorCommand}:{color.Color}", + Swatch = color.Color.ToString(), })], }, ], @@ -143,8 +146,8 @@ public ValueTask ExecuteAsync(string command, ComposerContext context, IComposer { FontFamilyCommand => ("fontName", GetFirst(Options.FontFamilies)), FontSizeCommand => ("fontSize", GetFirst(Options.FontSizes) is { } size ? ToCssSize(size) : null), - TextColorCommand => ("foreColor", GetFirst(Options.TextColors)), - HighlightColorCommand => ("hiliteColor", GetFirst(Options.HighlightColors)), + TextColorCommand => ("foreColor", GetFirstColor(Options.TextColors)), + HighlightColorCommand => ("hiliteColor", GetFirstColor(Options.HighlightColors)), LineHeightCommand => ("lineHeight", GetFirst(Options.LineHeights)), _ => (null, null), }; @@ -160,6 +163,11 @@ public ValueTask ExecuteAsync(string command, ComposerContext context, IComposer { return values.Count > 0 ? values[0] : null; } + + static string? GetFirstColor(IReadOnlyList colors) + { + return colors.Count > 0 ? colors[0].Color.ToString() : null; + } } // A label is a pixel size at the default 16px root, so its rem is the label divided by 16. diff --git a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyPluginOptions.cs b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyPluginOptions.cs index bff2248f6..dce9dce46 100644 --- a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyPluginOptions.cs +++ b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Plugins/TypographyPluginOptions.cs @@ -1,5 +1,7 @@ namespace Forma.Blazor.Components.Composer.RichTextEditor.Plugins; +using Forma.Framework.Css; + /// Options configuring font families, sizes, colors, and line heights offered by . public sealed record TypographyPluginOptions { @@ -26,10 +28,25 @@ public sealed record TypographyPluginOptions ["1.0", "1.15", "1.5", "1.6", "2.0"]; /// The text colors offered in the color picker. - public IReadOnlyList TextColors { get; set; } = - ["#000000", "#d32f2f", "#1976d2", "#388e3c", "#f57c00", "#7b1fa2", "#616161"]; + public IReadOnlyList TextColors { get; set; } = + [ + new("Black", CssColor.FromHex(0x000000)), + new("Red", CssColor.FromHex(0xd32f2f)), + new("Blue", CssColor.FromHex(0x1976d2)), + new("Green", CssColor.FromHex(0x388e3c)), + new("Orange", CssColor.FromHex(0xf57c00)), + new("Purple", CssColor.FromHex(0x7b1fa2)), + new("Gray", CssColor.FromHex(0x616161)), + ]; /// The highlight background colors offered in the highlight picker. - public IReadOnlyList HighlightColors { get; set; } = - ["#ffff00", "#a5d6a7", "#90caf9", "#ffcc80", "#ce93d8", "#e0e0e0"]; + public IReadOnlyList HighlightColors { get; set; } = + [ + new("Yellow", CssColor.FromHex(0xffff00)), + new("Green", CssColor.FromHex(0xa5d6a7)), + new("Blue", CssColor.FromHex(0x90caf9)), + new("Orange", CssColor.FromHex(0xffcc80)), + new("Purple", CssColor.FromHex(0xce93d8)), + new("Gray", CssColor.FromHex(0xe0e0e0)), + ]; } diff --git a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Views/RichTextPreviewViewPlugin.cs b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Views/RichTextPreviewViewPlugin.cs index 4ca70626f..654e4aa44 100644 --- a/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Views/RichTextPreviewViewPlugin.cs +++ b/src/Blazor/Forma.Blazor.Composer/RichTextEditor/Views/RichTextPreviewViewPlugin.cs @@ -114,6 +114,7 @@ public sealed class RichTextPreviewViewPlugin : IComposerViewPlugin { Id = $"zoom:{zoom}", Title = zoom.ToString(CultureInfo.InvariantCulture) + "%", + IsTitleVerbatim = true, Command = ZoomCommandPrefix + zoom.ToString(CultureInfo.InvariantCulture), })], }, diff --git a/src/Framework/Forma.Framework.Composer/Editing/ComposerToolbarLayout.cs b/src/Framework/Forma.Framework.Composer/Editing/ComposerToolbarLayout.cs index 9c60d3e22..aecbe3bae 100644 --- a/src/Framework/Forma.Framework.Composer/Editing/ComposerToolbarLayout.cs +++ b/src/Framework/Forma.Framework.Composer/Editing/ComposerToolbarLayout.cs @@ -20,7 +20,8 @@ public sealed record ComposerToolbarRowLayout( /// editor's surface, the rows its feature plugins declare. A row holding no items is left out, the built-in row excepted, /// and an item naming a row the layout does not hold lands on the plugins row where the layout has one. A standard row /// and a standard group take the composer's own title, localized for the composer, whichever plugin declares them; every -/// other title is localized for the plugin that declared it. +/// other title is localized for the plugin that declared it, an option's title excepted where +/// leaves it as written. /// public sealed class ComposerToolbarLayout { @@ -142,7 +143,7 @@ private static ToolbarItem Localize(ToolbarItem item, IComposerPlugin contributo ToolbarMenu menu => menu with { Title = localize(contributor, menu.Title), - Options = [.. menu.Options.Select(option => option with { Title = localize(contributor, option.Title) })], + Options = [.. menu.Options.Select(option => option.IsTitleVerbatim ? option : option with { Title = localize(contributor, option.Title) })], }, _ => item with { Title = localize(contributor, item.Title) }, }; diff --git a/src/Framework/Forma.Framework.Toolbar/README.md b/src/Framework/Forma.Framework.Toolbar/README.md index cb4571f9e..bec09de6e 100644 --- a/src/Framework/Forma.Framework.Toolbar/README.md +++ b/src/Framework/Forma.Framework.Toolbar/README.md @@ -162,7 +162,8 @@ Every item, through `ToolbarItem`: `ToolbarToggle` adds `IsActive`, `AlternateTitle` and `AlternateIcon`. `ToolbarMenu` has `Options`, each a `ToolbarOption` with its own `Id`, `Title`, `Icon` and `Command`, plus -`IsActive` for the option matching the current state, `PreviewStyle`, inline CSS previewing the +`IsActive` for the option matching the current state, `IsTitleVerbatim` for a title that is a value +shown as written, such as a font's name or a size, `PreviewStyle`, inline CSS previewing the option on its own label, and `Swatch`, a CSS color drawn beside it. `ToolbarReadout` has `Value` and `IsAnnounced`. `ToolbarCustomItem` has `Component`, the component type, and `Parameters`, handed to it as given. `ToolbarGroup` has `Items`. diff --git a/src/Framework/Forma.Framework.Toolbar/ToolbarOption.cs b/src/Framework/Forma.Framework.Toolbar/ToolbarOption.cs index 7e279b519..bc5ea8641 100644 --- a/src/Framework/Forma.Framework.Toolbar/ToolbarOption.cs +++ b/src/Framework/Forma.Framework.Toolbar/ToolbarOption.cs @@ -11,6 +11,9 @@ public sealed record ToolbarOption /// The option's label and accessible name, localized by the host. public required string Title { get; init; } + /// Whether is a value shown as written, such as a font's name or a size, which a host localizing the titles it is handed leaves as it is. + public bool IsTitleVerbatim { get; init; } + /// The icon shown beside the option. public Icon? Icon { get; init; } diff --git a/src/Locales/Forma.Blazor.Locales.Hebrew/Forma.Blazor.Composer/he.json b/src/Locales/Forma.Blazor.Locales.Hebrew/Forma.Blazor.Composer/he.json index b20dd6834..291dd92de 100644 --- a/src/Locales/Forma.Blazor.Locales.Hebrew/Forma.Blazor.Composer/he.json +++ b/src/Locales/Forma.Blazor.Locales.Hebrew/Forma.Blazor.Composer/he.json @@ -63,6 +63,14 @@ "Paragraph Style": "סגנון פסקה", "Typography": "טיפוגרפיה", "Color": "צבע", + "Black": "שחור", + "Red": "אדום", + "Blue": "כחול", + "Green": "ירוק", + "Orange": "כתום", + "Purple": "סגול", + "Gray": "אפור", + "Yellow": "צהוב", "History": "היסטוריה", "Document Status": "מצב המסמך", "Grouped Commands": "פקודות מקובצות", diff --git a/src/Locales/Forma.Blazor.Locales.Spanish/Forma.Blazor.Composer/es.json b/src/Locales/Forma.Blazor.Locales.Spanish/Forma.Blazor.Composer/es.json index 38d551492..154ed2666 100644 --- a/src/Locales/Forma.Blazor.Locales.Spanish/Forma.Blazor.Composer/es.json +++ b/src/Locales/Forma.Blazor.Locales.Spanish/Forma.Blazor.Composer/es.json @@ -63,6 +63,14 @@ "Paragraph Style": "Estilo de Párrafo", "Typography": "Tipografía", "Color": "Color", + "Black": "Negro", + "Red": "Rojo", + "Blue": "Azul", + "Green": "Verde", + "Orange": "Naranja", + "Purple": "Morado", + "Gray": "Gris", + "Yellow": "Amarillo", "History": "Historial", "Document Status": "Estado del Documento", "Grouped Commands": "Comandos Agrupados", diff --git a/tests/bunit/Blazor/Forma.Blazor.Composer.BUnit.Tests/Forma.Blazor.Composer.BUnit.Tests.csproj b/tests/bunit/Blazor/Forma.Blazor.Composer.BUnit.Tests/Forma.Blazor.Composer.BUnit.Tests.csproj index b378e3c9f..4fe930d42 100644 --- a/tests/bunit/Blazor/Forma.Blazor.Composer.BUnit.Tests/Forma.Blazor.Composer.BUnit.Tests.csproj +++ b/tests/bunit/Blazor/Forma.Blazor.Composer.BUnit.Tests/Forma.Blazor.Composer.BUnit.Tests.csproj @@ -25,6 +25,7 @@ + diff --git a/tests/bunit/Blazor/Forma.Blazor.Composer.BUnit.Tests/FormaComposerTests.razor b/tests/bunit/Blazor/Forma.Blazor.Composer.BUnit.Tests/FormaComposerTests.razor index 54cea7edf..89c1854fd 100644 --- a/tests/bunit/Blazor/Forma.Blazor.Composer.BUnit.Tests/FormaComposerTests.razor +++ b/tests/bunit/Blazor/Forma.Blazor.Composer.BUnit.Tests/FormaComposerTests.razor @@ -13,6 +13,7 @@ @using Microsoft.Extensions.Time.Testing @using Forma.Blazor.Components.Composer.Dialogs @using Forma.Framework.Localization +@using Forma.Framework.Localization.Json @using Forma.Tests.Interop @using Forma.Tests.Localization @using Microsoft.AspNetCore.Components.Web @@ -595,6 +596,33 @@ Assert.Equal(["/check/eager.js", "/check/view.css"], GetLoadedUrls(assets)); } + [Theory] + [InlineData("es")] + [InlineData("he")] + public void Should_find_a_localization_for_every_title_of_its_default_plugins(string language) + { + // Arrange — a host that requires every lookup to find its localization, with every default plugin and feature. + using var culture = new CultureScope(language); + using var ctx = new FormaComposerTests(); + ctx.Services.AddSingleton(new JsonStringLocaleFactory(new LocalizationOptions { LocalePacks = LocalePacks, RequireMatchingLocalization = true })); + var model = new HtmlModel(); + var plugins = ComposerDefinition.Create(composer => composer + .AddRichTextEditor(editor => editor.TryAddDefaultFeatures()) + .TryAddDefaultPlugins()); + var cut = ctx.Render(@); + cut.WaitForAssertion(() => Assert.True(cut.FindAll("[role=tab]").Count > 1)); + var viewCount = cut.FindAll("[role=tab]").Count - 1; + + // Act — each view in turn, the preview's bar offering the zoom levels + for (var index = 1; index <= viewCount; index++) + { + cut.FindAll("[role=tab]")[index].Click(); + } + + // Assert + Assert.Equal("true", cut.FindAll("[role=tab]")[viewCount].GetAttribute("aria-selected")); + } + [Fact] public void Should_route_the_shortcuts_of_the_view_shown_through_its_own_scope() { diff --git a/tests/unit/Blazor/Forma.Blazor.Composer.Tests/Forma.Blazor.Composer.Tests.csproj b/tests/unit/Blazor/Forma.Blazor.Composer.Tests/Forma.Blazor.Composer.Tests.csproj index a31fc996e..1fa2801db 100644 --- a/tests/unit/Blazor/Forma.Blazor.Composer.Tests/Forma.Blazor.Composer.Tests.csproj +++ b/tests/unit/Blazor/Forma.Blazor.Composer.Tests/Forma.Blazor.Composer.Tests.csproj @@ -10,6 +10,7 @@ + diff --git a/tests/unit/Blazor/Forma.Blazor.Composer.Tests/RichTextEditor/RichTextPluginTests.cs b/tests/unit/Blazor/Forma.Blazor.Composer.Tests/RichTextEditor/RichTextPluginTests.cs index c7f3a0b13..c9639a4af 100644 --- a/tests/unit/Blazor/Forma.Blazor.Composer.Tests/RichTextEditor/RichTextPluginTests.cs +++ b/tests/unit/Blazor/Forma.Blazor.Composer.Tests/RichTextEditor/RichTextPluginTests.cs @@ -8,6 +8,7 @@ namespace Forma.Blazor.Composer.Tests.RichTextEditor; using Forma.Framework.Composer.Documents; using Forma.Framework.Composer.Editing; using Forma.Framework.Composer.Plugins; +using Forma.Framework.Css; using Forma.Framework.Sanitization; using Forma.Framework.Toolbar; using Forma.Tests.Composer; @@ -247,6 +248,7 @@ public void Should_write_a_font_size_in_the_configured_unit( // Assert Assert.Multiple( () => Assert.Equal(label, option.Title), + () => Assert.True(option.IsTitleVerbatim), () => Assert.Equal($"font-size:{expected}", option.Id), () => Assert.Equal($"{TypographyPlugin.FontSizeCommand}:{expected}", option.Command)); } @@ -263,6 +265,40 @@ public void Should_scale_authored_sizes_with_the_reader_by_default() // Assert Assert.All(options, option => Assert.EndsWith("rem", option.Command, StringComparison.Ordinal)); } + + [Fact] + public void Should_label_a_color_by_its_name_and_apply_its_value() + { + // Arrange + var plugin = new TypographyPlugin( + new RichTextEditorPlugin(), + new TypographyPluginOptions { TextColors = [new TypographyColor("Red", CssColor.FromHex(0xd32f2f))] }); + + // Act + var option = FindMenu(plugin.Items, "text-color").Options.Single(); + + // Assert + Assert.Multiple( + () => Assert.Equal("Red", option.Title), + () => Assert.False(option.IsTitleVerbatim), + () => Assert.Equal("#d32f2f", option.Swatch), + () => Assert.Equal($"{TypographyPlugin.TextColorCommand}:#d32f2f", option.Command)); + } + + [Theory] + [InlineData("font-family")] + [InlineData("line-height")] + public void Should_offer_each_value_with_its_title_verbatim(string menuId) + { + // Arrange + var plugin = new TypographyPlugin(new RichTextEditorPlugin()); + + // Act + var options = FindMenu(plugin.Items, menuId).Options; + + // Assert + Assert.All(options, option => Assert.True(option.IsTitleVerbatim)); + } } public sealed class Link @@ -399,6 +435,19 @@ public async Task Should_dispatch_character_insert() Assert.Equal("©", requestedValue); Assert.Equal("special-character", plugin.Id); } + + [Fact] + public void Should_offer_each_character_with_its_title_verbatim() + { + // Arrange + var plugin = new SpecialCharacterPlugin(new RichTextEditorPlugin()); + + // Act + var options = FindMenu(plugin.Items, "special-character").Options; + + // Assert + Assert.All(options, option => Assert.True(option.IsTitleVerbatim)); + } } public sealed class Emoji diff --git a/tests/unit/Framework/Forma.Framework.Composer.Tests/Editing/ComposerToolbarLayoutTests.cs b/tests/unit/Framework/Forma.Framework.Composer.Tests/Editing/ComposerToolbarLayoutTests.cs index 674a62ba3..37386f24c 100644 --- a/tests/unit/Framework/Forma.Framework.Composer.Tests/Editing/ComposerToolbarLayoutTests.cs +++ b/tests/unit/Framework/Forma.Framework.Composer.Tests/Editing/ComposerToolbarLayoutTests.cs @@ -277,6 +277,31 @@ public void Should_localize_each_contribution_in_the_language_of_the_plugin_that () => Assert.Equal(["first:rule", "second:table"], insert.Items.Select(item => item.Title))); } + [Fact] + public void Should_leave_a_verbatim_option_title_as_written_and_localize_the_rest() + { + // Arrange + var editor = new Editor(); + var menu = new ToolbarMenu + { + Id = "font", + Title = "Font Family", + Options = + [ + new() { Id = "default", Title = "Default", Command = "font.default" }, + new() { Id = "arial", Title = "Arial", IsTitleVerbatim = true, Command = "font.arial" }, + ], + }; + var plugin = new Plugin { Id = "typography", Items = [CreateRow(ComposerRows.Formatting, menu)] }; + + // Act + var layout = ComposerToolbarLayout.Create(editor, [plugin], (contributor, title) => $"{contributor?.Id ?? "composer"}:{title}"); + + // Assert + var options = Assert.IsType(Assert.Single(layout.Rows.Single(row => row.Id == ComposerRows.Formatting).Items)).Options; + Assert.Equal(["typography:Default", "Arial"], options.Select(option => option.Title)); + } + [Fact] public void Should_title_a_standard_group_in_the_composer_s_words_whichever_plugin_declares_it() { From 4a8dc9d1f3eea1324f14a20911d33118290bf3e5 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:52:52 +0200 Subject: [PATCH 2/3] test(explorer): await the remaining clicks that open an actions menu --- .../FormaExplorerTests.razor | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/bunit/Blazor/Forma.Blazor.Explorer.BUnit.Tests/FormaExplorerTests.razor b/tests/bunit/Blazor/Forma.Blazor.Explorer.BUnit.Tests/FormaExplorerTests.razor index c3780a56c..4f81339be 100644 --- a/tests/bunit/Blazor/Forma.Blazor.Explorer.BUnit.Tests/FormaExplorerTests.razor +++ b/tests/bunit/Blazor/Forma.Blazor.Explorer.BUnit.Tests/FormaExplorerTests.razor @@ -1102,19 +1102,19 @@ OnDelete="@(req => { deleteReq = req; return Task.CompletedTask; })" />); // Act - cut.Find(".forma-explorer-new-folder-tool").Click(); + await cut.Find(".forma-explorer-new-folder-tool").ClickAsync(new()); await fields.TypeAsync(cut.Find("#forma-explorer-folder-input"), "New Album"); - cut.Find(".forma-dialog-footer .forma-button-primary").Click(); + await cut.Find(".forma-dialog-footer .forma-button-primary").ClickAsync(new()); // Assert Assert.NotNull(createReq); Assert.Equal("New Album", createReq.Name); // Act - cut.Find("button[aria-label='Actions for Races']").Click(); - cut.Find("[data-action='folder-rename']").Click(); + await cut.Find("button[aria-label='Actions for Races']").ClickAsync(new()); + await cut.Find("[data-action='folder-rename']").ClickAsync(new()); await fields.TypeAsync(cut.Find("#forma-explorer-rename-input"), "Updated Races"); - cut.Find(".forma-dialog-footer .forma-button-primary").Click(); + await cut.Find(".forma-dialog-footer .forma-button-primary").ClickAsync(new()); // Assert Assert.NotNull(renameReq); @@ -1122,8 +1122,8 @@ Assert.Equal("Updated Races", renameReq.NewName); // Act - cut.Find("button[aria-label='Actions for Races']").Click(); - cut.Find("[data-action='folder-delete']").Click(); + await cut.Find("button[aria-label='Actions for Races']").ClickAsync(new()); + await cut.Find("[data-action='folder-delete']").ClickAsync(new()); await cut.Find(".forma-dialog-footer .forma-button-danger").ClickAsync(new MouseEventArgs()); // Assert @@ -1145,10 +1145,10 @@ OnFolderCreate="@(req => { createReq = req; return Task.CompletedTask; })" />); // Act - cut.Find("button[aria-label='Actions for Races']").Click(); - cut.Find("[data-action='folder-create']").Click(); + await cut.Find("button[aria-label='Actions for Races']").ClickAsync(new()); + await cut.Find("[data-action='folder-create']").ClickAsync(new()); await fields.TypeAsync(cut.Find("#forma-explorer-folder-input"), "2027"); - cut.Find(".forma-dialog-footer .forma-button-primary").Click(); + await cut.Find(".forma-dialog-footer .forma-button-primary").ClickAsync(new()); // Assert Assert.NotNull(createReq); @@ -1666,7 +1666,7 @@ public sealed class Commands { [Fact] - public void Should_render_every_action_when_options_are_default() + public async Task Should_render_every_action_when_options_are_default() { // Arrange using var ctx = new FormaExplorerTests(); @@ -1677,13 +1677,13 @@ var cut = ctx.Render(@); // Assert - ItemNamed(cut, "cover.jpg").QuerySelector(".forma-explorer-action-bar .forma-dropdown-menu-trigger")!.Click(); + await ItemNamed(cut, "cover.jpg").QuerySelector(".forma-explorer-action-bar .forma-dropdown-menu-trigger")!.ClickAsync(new()); var labels = cut.FindAll(".forma-dropdown-menu-item").Select(i => i.TextContent.Trim()).ToList(); Assert.Equal(["Preview", "Rename", "Delete"], labels); Assert.Single(cut.FindAll(".forma-explorer-new-folder-tool")); Assert.Empty(cut.FindAll(".forma-explorer-new-folder-button")); Assert.Single(cut.FindAll(".forma-explorer-upload-button")); - cut.Find("button[aria-label='Actions for Races']").Click(); + await cut.Find("button[aria-label='Actions for Races']").ClickAsync(new()); Assert.Equal("Races", cut.Find(".forma-explorer-folder-actions .forma-dropdown-menu-header").TextContent.Trim()); Assert.Equal( ["folder-create", "folder-rename", "folder-delete"], From fd73fdd8eed327a416bf446493b064f4440d2f63 Mon Sep 17 00:00:00 2001 From: Eyal Alon <3756641+soyeyalon@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:00:35 +0200 Subject: [PATCH 3/3] chore: release 1.0.0-preview.11 --- CHANGELOG.md | 2 +- Directory.Build.props | 2 +- docs/features-status.md | 2 +- src/Framework/Forma.Framework.Localization/README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 579c8141a..5548f3298 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ set out. What Forma gained before its first release, month by month, is in [the ## `1.0.0-preview.11` -*Unreleased* +*November 18, 2026* - `ToolbarOption.IsTitleVerbatim` marks a title that is a value shown as written, such as a font's name or a size, and the composer leaves such a title as it is. Its font families, font sizes, line heights, special characters and zoom diff --git a/Directory.Build.props b/Directory.Build.props index 488f1b24c..4a79036f0 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -27,7 +27,7 @@ 1.0.0 - preview.10 + preview.11 diff --git a/docs/features-status.md b/docs/features-status.md index 14f19e65d..6ba814047 100644 --- a/docs/features-status.md +++ b/docs/features-status.md @@ -7,7 +7,7 @@ | Measure | Now | | --- | --- | | Components | 67 implemented and 7 in progress, as [the catalog](component-catalog.md) lists them, and 21 planned, as [the roadmap](component-roadmap.md) orders them | -| Packages | Every project under `src/` but the Showcase, released from `main` by `release.yml` to nuget.org and the organization's GitHub feed, the latest published release `1.0.0-preview.10` | +| Packages | Every project under `src/` but the Showcase, released from `main` by `release.yml` to nuget.org and the organization's GitHub feed, the latest published release `1.0.0-preview.11` | | Render modes | Interactive Server, WebAssembly and Auto implemented: every call a component makes to a script and every call back checked in each, and on the Server in WebKit, the engine of Safari and of Apple's web views, every runtime on a page following its culture coordinator, a client reading its host's own strings, and a host setting either arrangement up as the README says; static rendering implemented, every check page rendered statically with no enabled control that needs interactivity; Blazor Hybrid implemented on WPF, Windows Forms and MAUI on Windows, every component checked in a web view and each host's application set up as the README says; an inventory holds every component to a check page in every render mode | The gate runs every check [the verification design](verification-design.md#gates) sets out, each platform's where the machine can run it. It passes locally on Windows and in CI on Linux, on Windows and on an Android emulator. diff --git a/src/Framework/Forma.Framework.Localization/README.md b/src/Framework/Forma.Framework.Localization/README.md index a3ab6d37b..eb66d8de4 100644 --- a/src/Framework/Forma.Framework.Localization/README.md +++ b/src/Framework/Forma.Framework.Localization/README.md @@ -335,7 +335,7 @@ and referencing this package, whose build does the rest: - +