Skip to content

V16: Removes TinyMCE (server-side) #18913

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
merged 18 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/Umbraco.Core/Constants-PropertyEditors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,6 @@ public static class Aliases
/// </summary>
public const string RichText = "Umbraco.RichText";

/// <summary>
/// TinyMCE
/// </summary>
[Obsolete("Please use RichText constant instead, scheduled for removal in v16")]
public const string TinyMce = "Umbraco.TinyMCE";

/// <summary>
/// Boolean.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions src/Umbraco.Core/Models/Blocks/RichTextBlockValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,4 @@ public RichTextBlockValue(IEnumerable<RichTextBlockLayoutItem> layouts)
/// <inheritdoc />
[JsonIgnore]
public override string PropertyEditorAlias => Constants.PropertyEditors.Aliases.RichText;

// RTE block layouts uses "Umbraco.TinyMCE" in V14 and below, but should use "Umbraco.RichText" for V15+
[Obsolete("Will be removed in V18.")]
public override bool SupportsBlockLayoutAlias(string alias)
=> base.SupportsBlockLayoutAlias(alias) || alias.Equals(Constants.PropertyEditors.Aliases.TinyMce);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// Value converter for the RTE so that it always returns IHtmlString so that Html.Raw doesn't have to be used.
/// </summary>
[DefaultPropertyValueConverter]
public class SimpleTinyMceValueConverter : PropertyValueConverterBase
public class SimpleRichTextValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(IPublishedPropertyType propertyType)
=> propertyType.EditorAlias == Constants.PropertyEditors.Aliases.RichText;
Expand All @@ -26,8 +26,8 @@
// default value is: null
source;

public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview) =>

// source should come from ConvertSource and be a string (or null) already
new HtmlEncodedString(inter == null ? string.Empty : (string)inter);

Check warning on line 32 in src/Umbraco.Core/PropertyEditors/ValueConverters/SimpleRichtextValueConverter.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v16/dev)

❌ New issue: Excess Number of Function Arguments

ConvertIntermediateToObject has 5 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static IUmbracoBuilder AddCoreInitialServices(this IUmbracoBuilder builde
// discovered when CoreBootManager configures the converters. We will remove the basic one defined
// in core so that the more enhanced version is active.
builder.PropertyValueConverters()
.Remove<SimpleTinyMceValueConverter>();
.Remove<SimpleRichTextValueConverter>();

// register *all* checks, except those marked [HideFromTypeFinder] of course
builder.Services.AddSingleton<IMarkdownToHtmlConverter, MarkdownToHtmlConverter>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected override void Migrate()
Constants.PropertyEditors.Aliases.TextBox => "Umb.PropertyEditorUi.TextBox",
Constants.PropertyEditors.Aliases.TextArea => "Umb.PropertyEditorUi.TextArea",
Constants.PropertyEditors.Aliases.RichText => "Umb.PropertyEditorUi.TinyMCE",
Constants.PropertyEditors.Aliases.TinyMce => "Umb.PropertyEditorUi.TinyMCE",
"Umbraco.TinyMCE" => "Umb.PropertyEditorUi.TinyMCE",
Constants.PropertyEditors.Aliases.Boolean => "Umb.PropertyEditorUi.Toggle",
Constants.PropertyEditors.Aliases.MarkdownEditor => "Umb.PropertyEditorUi.MarkdownEditor",
Constants.PropertyEditors.Aliases.UserPicker => "Umb.PropertyEditorUi.UserPicker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected override void Migrate()
PropertyEditorAliases.RichText => HandleRichText(ref configurationData),
PropertyEditorAliases.TextBox => HandleTextBoxAndTextArea(ref configurationData),
PropertyEditorAliases.TextArea => HandleTextBoxAndTextArea(ref configurationData),
PropertyEditorAliases.TinyMce => HandleRichText(ref configurationData),
"Umbraco.TinyMCE" => HandleRichText(ref configurationData),
PropertyEditorAliases.UploadField => HandleUploadField(ref configurationData),
_ => false
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ConvertRichTextEditorProperties(
}

protected override IEnumerable<string> PropertyEditorAliases
=> new[] { Constants.PropertyEditors.Aliases.TinyMce, Constants.PropertyEditors.Aliases.RichText };
=> new[] { "Umbraco.TinyMCE", Constants.PropertyEditors.Aliases.RichText };

protected override EditorValueHandling DetermineEditorValueHandling(object editorValue)
=> editorValue is RichTextEditorValue richTextEditorValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LocalLinkRteProcessor : ITypedLocalLinkProcessor

public IEnumerable<string> PropertyEditorAliases =>
[
Constants.PropertyEditors.Aliases.TinyMce, Constants.PropertyEditors.Aliases.RichText
"Umbraco.TinyMCE", Constants.PropertyEditors.Aliases.RichText
];

public Func<object?, Func<object?, bool>, Func<string, string>, bool> Process => ProcessRichText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Umbraco.Cms.Core.PropertyEditors.ValueConverters;
/// used dynamically.
/// </summary>
[DefaultPropertyValueConverter]
public class RteBlockRenderingValueConverter : SimpleTinyMceValueConverter, IDeliveryApiPropertyValueConverter
public class RteBlockRenderingValueConverter : SimpleRichTextValueConverter, IDeliveryApiPropertyValueConverter
{
private readonly HtmlImageSourceParser _imageSourceParser;
private readonly HtmlLocalLinkParser _linkParser;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NUnit.Framework;

Check notice on line 1 in tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/BlockEditorBackwardsCompatibilityTests.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v16/dev)

✅ Getting better: Code Duplication

reduced similar code in: BlockListIsBackwardsCompatible,RichTextIsBackwardsCompatible. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check notice on line 1 in tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/BlockEditorBackwardsCompatibilityTests.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v16/dev)

✅ Getting better: Large Assertion Blocks

The number of large assertion blocks decreases from 5 to 4, threshold = 4. This test file has several blocks of large, consecutive assert statements. Avoid adding more.
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Blocks;
Expand Down Expand Up @@ -276,115 +276,7 @@
Assert.AreEqual("264536b65b0f4641aa43d4bfb515831d", toEditor.Expose[3].ContentKey.ToString("N"));
});
}

Check notice on line 279 in tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/BlockEditorBackwardsCompatibilityTests.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v16/dev)

✅ No longer an issue: Large Method

RichTextIsBackwardsCompatible is no longer above the threshold for lines of code. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
[TestCase]
public async Task RichTextIsBackwardsCompatible()
{
var elementType = await CreateElementType();
var richTextDataType = await CreateRichTextDataType(elementType);
var contentType = await CreateContentType(richTextDataType);

var json = $$"""
{
"markup": "<p>huh?</p>",
"blocks": {
"layout": {
"{{Constants.PropertyEditors.Aliases.TinyMce}}": [
{
"contentUdi": "umb://element/1304e1ddac87439684fe8a399231cb3d",
"settingsUdi": "umb://element/1f613e26ce274898908a561437af5100"
},
{
"contentUdi": "umb://element/0a4a416e547d464fabcc6f345c17809a",
"settingsUdi": "umb://element/63027539b0db45e7b70459762d4e83dd"
}
]
},
"contentData": [
{
"contentTypeKey": "{{elementType.Key}}",
"udi": "umb://element/1304e1ddac87439684fe8a399231cb3d",
"title": "Content Title One",
"text": "Content Text One"
},
{
"contentTypeKey": "{{elementType.Key}}",
"udi": "umb://element/0a4a416e547d464fabcc6f345c17809a",
"title": "Content Title Two",
"text": "Content Text Two"
}
],
"settingsData": [
{
"contentTypeKey": "{{elementType.Key}}",
"udi": "umb://element/1f613e26ce274898908a561437af5100",
"title": "Settings Title One",
"text": "Settings Text One"
},
{
"contentTypeKey": "{{elementType.Key}}",
"udi": "umb://element/63027539b0db45e7b70459762d4e83dd",
"title": "Settings Title Two",
"text": "Settings Text Two"
}
]
}
}
""";

var contentBuilder = new ContentBuilder()
.WithContentType(contentType)
.WithName("Home");

var content = contentBuilder.Build();
content.Properties["blocks"]!.SetValue(json);
ContentService.Save(content);

var toEditor = richTextDataType.Editor!.GetValueEditor().ToEditor(content.Properties["blocks"]!) as RichTextEditorValue;
Assert.IsNotNull(toEditor);
Assert.IsNotNull(toEditor.Blocks);

Assert.Multiple(() =>
{
Assert.AreEqual(2, toEditor.Blocks.ContentData.Count);

Assert.AreEqual("1304e1ddac87439684fe8a399231cb3d", toEditor.Blocks.ContentData[0].Key.ToString("N"));
Assert.AreEqual("0a4a416e547d464fabcc6f345c17809a", toEditor.Blocks.ContentData[1].Key.ToString("N"));

AssertValueEquals(toEditor.Blocks.ContentData[0], "title", "Content Title One");
AssertValueEquals(toEditor.Blocks.ContentData[0], "text", "Content Text One");
AssertValueEquals(toEditor.Blocks.ContentData[1], "title", "Content Title Two");
AssertValueEquals(toEditor.Blocks.ContentData[1], "text", "Content Text Two");

Assert.IsFalse(toEditor.Blocks.ContentData[0].RawPropertyValues.Any());
Assert.IsFalse(toEditor.Blocks.ContentData[1].RawPropertyValues.Any());
});

Assert.Multiple(() =>
{
Assert.AreEqual(2, toEditor.Blocks.SettingsData.Count);

Assert.AreEqual("1f613e26ce274898908a561437af5100", toEditor.Blocks.SettingsData[0].Key.ToString("N"));
Assert.AreEqual("63027539b0db45e7b70459762d4e83dd", toEditor.Blocks.SettingsData[1].Key.ToString("N"));

AssertValueEquals(toEditor.Blocks.SettingsData[0], "title", "Settings Title One");
AssertValueEquals(toEditor.Blocks.SettingsData[0], "text", "Settings Text One");
AssertValueEquals(toEditor.Blocks.SettingsData[1], "title", "Settings Title Two");
AssertValueEquals(toEditor.Blocks.SettingsData[1], "text", "Settings Text Two");

Assert.IsFalse(toEditor.Blocks.SettingsData[0].RawPropertyValues.Any());
Assert.IsFalse(toEditor.Blocks.SettingsData[1].RawPropertyValues.Any());
});

Assert.Multiple(() =>
{
Assert.AreEqual(2, toEditor.Blocks.Expose.Count);

Assert.AreEqual("1304e1ddac87439684fe8a399231cb3d", toEditor.Blocks.Expose[0].ContentKey.ToString("N"));
Assert.AreEqual("0a4a416e547d464fabcc6f345c17809a", toEditor.Blocks.Expose[1].ContentKey.ToString("N"));
});
}

private static void AssertValueEquals(BlockItemData blockItemData, string propertyAlias, string expectedValue)
{
var blockPropertyValue = blockItemData.Values.FirstOrDefault(v => v.Alias == propertyAlias);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NUnit.Framework;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Blocks;
Expand Down Expand Up @@ -50,7 +50,7 @@ public void Can_Get_Index_Values_From_RichText_With_Blocks()
Blocks = JsonSerializer.Deserialize<RichTextBlockValue>($$"""
{
"layout": {
"Umbraco.TinyMCE": [{
"Umbraco.RichText": [{
"contentKey": "{{elementId:D}}"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void Can_Track_Block_References()
Blocks = JsonSerializer.Deserialize<RichTextBlockValue>($$"""
{
"layout": {
"Umbraco.TinyMCE": [{
"{{Constants.PropertyEditors.Aliases.RichText}}": [{
"contentKey": "{{elementId:D}}"
}
]
Expand Down Expand Up @@ -151,7 +151,7 @@ public void Can_Track_Block_Tags()
Blocks = JsonSerializer.Deserialize<RichTextBlockValue>($$"""
{
"layout": {
"Umbraco.TinyMCE": [{
"{{Constants.PropertyEditors.Aliases.RichText}}": [{
"contentKey": "{{elementId:D}}"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Can_Parse_JObject()
"markup": "<p>this is some markup</p><umb-rte-block data-content-key=\"36cc710a-d8a6-45d0-a07f-7bbd8742cf02\"><!--Umbraco-Block--></umb-rte-block>",
"blocks": {
"layout": {
"Umbraco.TinyMCE": [{
"Umbraco.RichText": [{
"contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf02",
"settingsKey": "d2eeef66-4111-42f4-a164-7a523eaffbc2"
}
Expand Down Expand Up @@ -118,7 +118,7 @@ public void Can_Parse_Blocks_With_Both_Content_And_Settings()
"markup": "<p>this is some markup</p><umb-rte-block data-content-key=\"36cc710a-d8a6-45d0-a07f-7bbd8742cf02\"><!--Umbraco-Block--></umb-rte-block>",
"blocks": {
"layout": {
"Umbraco.TinyMCE": [{
"Umbraco.RichText": [{
"contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf02",
"settingsKey": "d2eeef66-4111-42f4-a164-7a523eaffbc2"
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public void Can_Parse_Blocks_With_Content_Only()
"markup": "<p>this is some markup</p><umb-rte-block data-content-key=\"36cc710a-d8a6-45d0-a07f-7bbd8742cf02\"></umb-rte-block>",
"blocks": {
"layout": {
"Umbraco.TinyMCE": [{
"Umbraco.RichText": [{
"contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf02"
}
]
Expand Down Expand Up @@ -241,7 +241,7 @@ public void Can_Parse_Mixed_Blocks_And_Inline_Blocks()
"markup": "<p>this is <umb-rte-block-inline data-content-key=\"36cc710a-d8a6-45d0-a07f-7bbd8742cf03\"></umb-rte-block-inline> some markup</p><umb-rte-block data-content-key=\"36cc710a-d8a6-45d0-a07f-7bbd8742cf02\"></umb-rte-block>",
"blocks": {
"layout": {
"Umbraco.TinyMCE": [{
"Umbraco.RichText": [{
"contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf02"
}, {
"contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf03"
Expand Down