From 10e56a52f3a521a2fe15ae18940366c707e6f1fb Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:00:59 +0100 Subject: [PATCH] V16: Removes TinyMCE (server-side) (#18913) * Create new migration * Migrate UI to tiptap * remember to overwrite toolbar * Add setting to disable migration * Add default extensions when migrating * Remove places where editorUI alias is used * Remove more tinyMCE stuff * Make sure that blocks also works * Reverted files from bad merge * bring back value converters * Class name casing --------- Co-authored-by: leekelleher --- src/Umbraco.Core/Constants-PropertyEditors.cs | 6 - .../Models/Blocks/RichTextBlockValue.cs | 5 - ...ter.cs => SimpleRichtextValueConverter.cs} | 2 +- .../UmbracoBuilder.CoreServices.cs | 2 +- .../Upgrade/V_14_0_0/AddEditorUiToDataType.cs | 2 +- .../V_14_0_0/MigrateDataTypeConfigurations.cs | 2 +- .../ConvertRichTextEditorProperties.cs | 2 +- .../LocalLinks/LocalLinkRteProcessor.cs | 2 +- .../RteBlockRenderingValueConverter.cs | 2 +- .../BlockEditorBackwardsCompatibilityTests.cs | 108 ------------------ .../PropertyIndexValueFactoryTests.cs | 4 +- .../RichTextPropertyEditorTests.cs | 4 +- .../RichTextPropertyEditorHelperTests.cs | 8 +- 13 files changed, 15 insertions(+), 134 deletions(-) rename src/Umbraco.Core/PropertyEditors/ValueConverters/{SimpleTinyMceValueConverter.cs => SimpleRichtextValueConverter.cs} (95%) diff --git a/src/Umbraco.Core/Constants-PropertyEditors.cs b/src/Umbraco.Core/Constants-PropertyEditors.cs index 9466a51b88..0d0b5d9767 100644 --- a/src/Umbraco.Core/Constants-PropertyEditors.cs +++ b/src/Umbraco.Core/Constants-PropertyEditors.cs @@ -170,12 +170,6 @@ public static partial class Constants /// public const string RichText = "Umbraco.RichText"; - /// - /// TinyMCE - /// - [Obsolete("Please use RichText constant instead, scheduled for removal in v16")] - public const string TinyMce = "Umbraco.TinyMCE"; - /// /// Boolean. /// diff --git a/src/Umbraco.Core/Models/Blocks/RichTextBlockValue.cs b/src/Umbraco.Core/Models/Blocks/RichTextBlockValue.cs index efae15d0a1..6cbab55693 100644 --- a/src/Umbraco.Core/Models/Blocks/RichTextBlockValue.cs +++ b/src/Umbraco.Core/Models/Blocks/RichTextBlockValue.cs @@ -23,9 +23,4 @@ public class RichTextBlockValue : BlockValue /// [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); } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/SimpleTinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/SimpleRichtextValueConverter.cs similarity index 95% rename from src/Umbraco.Core/PropertyEditors/ValueConverters/SimpleTinyMceValueConverter.cs rename to src/Umbraco.Core/PropertyEditors/ValueConverters/SimpleRichtextValueConverter.cs index 7f4e37483e..abf4c5b1eb 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/SimpleTinyMceValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/SimpleRichtextValueConverter.cs @@ -7,7 +7,7 @@ namespace Umbraco.Cms.Core.PropertyEditors.ValueConverters; /// Value converter for the RTE so that it always returns IHtmlString so that Html.Raw doesn't have to be used. /// [DefaultPropertyValueConverter] -public class SimpleTinyMceValueConverter : PropertyValueConverterBase +public class SimpleRichTextValueConverter : PropertyValueConverterBase { public override bool IsConverter(IPublishedPropertyType propertyType) => propertyType.EditorAlias == Constants.PropertyEditors.Aliases.RichText; diff --git a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs index 13b2679b2c..bc01e0474c 100644 --- a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs +++ b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs @@ -164,7 +164,7 @@ public static partial class UmbracoBuilderExtensions // 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(); + .Remove(); // register *all* checks, except those marked [HideFromTypeFinder] of course builder.Services.AddSingleton(); diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddEditorUiToDataType.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddEditorUiToDataType.cs index 8e3028c44a..71326b56f3 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddEditorUiToDataType.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddEditorUiToDataType.cs @@ -68,7 +68,7 @@ public class AddEditorUiToDataType : MigrationBase 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", diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateDataTypeConfigurations.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateDataTypeConfigurations.cs index c0113ee9db..cd2149ec90 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateDataTypeConfigurations.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateDataTypeConfigurations.cs @@ -102,7 +102,7 @@ public class MigrateDataTypeConfigurations : MigrationBase 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 }; diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertRichTextEditorProperties.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertRichTextEditorProperties.cs index 3df45e4e8c..77b8707ca0 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertRichTextEditorProperties.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/ConvertRichTextEditorProperties.cs @@ -31,7 +31,7 @@ public partial class ConvertRichTextEditorProperties : ConvertBlockEditorPropert } protected override IEnumerable 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 diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/LocalLinks/LocalLinkRteProcessor.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/LocalLinks/LocalLinkRteProcessor.cs index 84bdcc7ff1..6f32b19c9b 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/LocalLinks/LocalLinkRteProcessor.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_15_0_0/LocalLinks/LocalLinkRteProcessor.cs @@ -11,7 +11,7 @@ public class LocalLinkRteProcessor : ITypedLocalLinkProcessor public IEnumerable PropertyEditorAliases => [ - Constants.PropertyEditors.Aliases.TinyMce, Constants.PropertyEditors.Aliases.RichText + "Umbraco.TinyMCE", Constants.PropertyEditors.Aliases.RichText ]; public Func, Func, bool> Process => ProcessRichText; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteBlockRenderingValueConverter.cs b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteBlockRenderingValueConverter.cs index c6b38cb35c..2c3f061b80 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteBlockRenderingValueConverter.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteBlockRenderingValueConverter.cs @@ -26,7 +26,7 @@ namespace Umbraco.Cms.Core.PropertyEditors.ValueConverters; /// used dynamically. /// [DefaultPropertyValueConverter] -public class RteBlockRenderingValueConverter : SimpleTinyMceValueConverter, IDeliveryApiPropertyValueConverter +public class RteBlockRenderingValueConverter : SimpleRichTextValueConverter, IDeliveryApiPropertyValueConverter { private readonly HtmlImageSourceParser _imageSourceParser; private readonly HtmlLocalLinkParser _linkParser; diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/BlockEditorBackwardsCompatibilityTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/BlockEditorBackwardsCompatibilityTests.cs index 601c8d4ebe..ea8d586f34 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/BlockEditorBackwardsCompatibilityTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/BlockEditorBackwardsCompatibilityTests.cs @@ -277,114 +277,6 @@ internal sealed class BlockEditorBackwardsCompatibilityTests : UmbracoIntegratio }); } - [TestCase] - public async Task RichTextIsBackwardsCompatible() - { - var elementType = await CreateElementType(); - var richTextDataType = await CreateRichTextDataType(elementType); - var contentType = await CreateContentType(richTextDataType); - - var json = $$""" - { - "markup": "

huh?

", - "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); diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/PropertyIndexValueFactoryTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/PropertyIndexValueFactoryTests.cs index bc0e43f3e5..2b21ba032a 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/PropertyIndexValueFactoryTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/PropertyIndexValueFactoryTests.cs @@ -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; @@ -50,7 +50,7 @@ internal sealed class PropertyIndexValueFactoryTests : UmbracoIntegrationTest Blocks = JsonSerializer.Deserialize($$""" { "layout": { - "Umbraco.TinyMCE": [{ + "Umbraco.RichText": [{ "contentKey": "{{elementId:D}}" } ] diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditorTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditorTests.cs index 5bffee22aa..b1f908d852 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditorTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditorTests.cs @@ -98,7 +98,7 @@ internal sealed class RichTextPropertyEditorTests : UmbracoIntegrationTest Blocks = JsonSerializer.Deserialize($$""" { "layout": { - "Umbraco.TinyMCE": [{ + "{{Constants.PropertyEditors.Aliases.RichText}}": [{ "contentKey": "{{elementId:D}}" } ] @@ -151,7 +151,7 @@ internal sealed class RichTextPropertyEditorTests : UmbracoIntegrationTest Blocks = JsonSerializer.Deserialize($$""" { "layout": { - "Umbraco.TinyMCE": [{ + "{{Constants.PropertyEditors.Aliases.RichText}}": [{ "contentKey": "{{elementId:D}}" } ] diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs index ab68db550f..daeed11a52 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs @@ -30,7 +30,7 @@ public class RichTextPropertyEditorHelperTests "markup": "

this is some markup

", "blocks": { "layout": { - "Umbraco.TinyMCE": [{ + "Umbraco.RichText": [{ "contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf02", "settingsKey": "d2eeef66-4111-42f4-a164-7a523eaffbc2" } @@ -118,7 +118,7 @@ public class RichTextPropertyEditorHelperTests "markup": "

this is some markup

", "blocks": { "layout": { - "Umbraco.TinyMCE": [{ + "Umbraco.RichText": [{ "contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf02", "settingsKey": "d2eeef66-4111-42f4-a164-7a523eaffbc2" } @@ -190,7 +190,7 @@ public class RichTextPropertyEditorHelperTests "markup": "

this is some markup

", "blocks": { "layout": { - "Umbraco.TinyMCE": [{ + "Umbraco.RichText": [{ "contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf02" } ] @@ -241,7 +241,7 @@ public class RichTextPropertyEditorHelperTests "markup": "

this is some markup

", "blocks": { "layout": { - "Umbraco.TinyMCE": [{ + "Umbraco.RichText": [{ "contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf02" }, { "contentKey": "36cc710a-d8a6-45d0-a07f-7bbd8742cf03"