Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gihan Perera 3 posts 72 karma points
    Dec 08, 2022 @ 16:01
    Gihan Perera
    0

    Tiny MCE Rich Editor - Extended Valid Elements

    Hi,

    I need to add some custom attributes to the div tag on the Rich Editor source code. but there are no options to use Extended Valid Elements in the Umbraco core.

    Is there any alternative solution for it?

    FYI I'm using Umbraco 11

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Dec 08, 2022 @ 17:52
    Søren Gregersen
    0

    Hi,

    In the startup you can extend the configuration. The configruation is described here https://docs.umbraco.com/umbraco-cms/reference/configuration/richtexteditorsettings

    You can add something like this, in the ConfigureServices methods

        services.Configure<RichTextEditorConfiguration>(opts =>
        {
            opts.ValidElements += "video,audio";
        });
    

    The .Net documentation for the configure method is found here

    https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.optionsconfigurationservicecollectionextensions.configure?view=dotnet-plat-ext-7.0

  • Gihan Perera 3 posts 72 karma points
    Dec 08, 2022 @ 23:42
    Gihan Perera
    0

    Thanks for the quick reply.

    As per instruction, I've added the below code but not working yet.

    public void ConfigureServices(IServiceCollection services)
        {
            services.AddUmbraco(_env, _config)
                .AddBackOffice()
                .AddWebsite()
                .AddComposers()
                .Build();
            services.Configure<RichTextEditorConfiguration>(opts =>
            {
                opts.ValidElements += "div[*]";
            });
        }
    

    It will automatically remove any custom attributes.

    Eg : <div uk-grid="margin:uk-margin-large-top">{html}</div> Result : <div>{html}</div>

    Is there any way to use the Extended Valid Elements Umbraco core?

    Based on the document, it seems to be out of control

    https://our.umbraco.com/documentation/Reference/Configuration-for-Umbraco-7-and-8/tinyMceConfig/#extended-valid-elements

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies