Copied to clipboard

Flag this post as spam?

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


  • ninjajs 4 posts 24 karma points
    Jul 31, 2024 @ 22:34
    ninjajs
    0

    how to allow all elements and attributes in RTE in umbraco 13.3?

    I have tried editing appsetting.json:

    "RichTextEditor": { "ValidElements": "*[*]" }

    But it keeps stripping out attributes like

    <div role="img">Img</div>
    

    Also tried setting SanitizeTinyMce to false

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 01, 2024 @ 12:53
    Huw Reddick
    0

    my guess would be because role is not a valid attribute for a div.

    If you add a class/id/title attribute, are they removed? If you add role to a anchor tag <a href="#" role="button">Button Link</a>, does that get removed?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 01, 2024 @ 13:01
    Huw Reddick
    0

    looks like it just removes it from div or span tags, might be worth checking TinyMCE docs

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 01, 2024 @ 13:14
    Huw Reddick
    0

    looks to be something Umbraco is doing.

    using a native tinymce plugin outside of umbraco does not remove the role attribute

  • ninjajs 4 posts 24 karma points
    Aug 01, 2024 @ 23:29
    ninjajs
    0

    I have read both umbraco and tinymce documentation. All I could find was text saying to use "ValidElements" which does not work.

    In previous versions of umbraco there was the ability to use "extendedvalidelements" but this does not seem to exist in umbraco 13.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 02, 2024 @ 07:14
    Huw Reddick
    0

    Hi ninjajs,

    I have done some playing around and worked out that you can add @[role] to extended_valid_elements and it should then work.

  • ninjajs 4 posts 24 karma points
    Aug 03, 2024 @ 00:23
    ninjajs
    0

    Than you. I used that and it worked for the role attribute but it stripped other attributes like class. I ended up adding those back in and now its working fine.

    Here is the final solution:

    "Umbraco": {
    "CMS": {
      "Global": {
        "SanitizeTinyMce": true
      },
      "RichTextEditor": {
        "ValidElements": "*[*]",
        "CustomConfig": {
          "extended_valid_elements": "@[id|style|rel|data-id|data-udi|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup|role]"
        }
      }
    }
    

    }

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 03, 2024 @ 13:01
    Huw Reddick
    0

    yes that would be correct, you just need to add @[role] to your existing validelements string (which would overwrite the standard umbraco validelements)

    So it is probably better to remove ValidElements completely from your appsettings and just put @[role] in the extendedvalidelements

  • girish 15 posts 88 karma points
    Aug 02, 2024 @ 06:45
    girish
    0

    To allow all elements and attributes in the Rich Text Editor (RTE) in Umbraco 13.3, you can configure it through the appsettings.json file as you've mentioned. However, the configuration needs to be done correctly, and there might be additional steps to ensure that the TinyMCE settings are applied correctly.

    Here are the steps you can follow to allow all elements and attributes in the RTE:

    Edit appsettings.json: Ensure that you have the correct settings in your appsettings.json file.

    {
      "Umbraco": {
        "CMS": {
          "Content": {
            "SanitizeTinyMce": false,
            "RichTextEditor": {
              "ValidElements": "*[*]"
            }
          }
        }
      }
    }
    

    Clear the Cache: Sometimes, Umbraco caches the settings. Clear the cache to make sure the new settings are applied. You can do this by restarting the application or manually clearing the cache.

    Configure TinyMCE in the Backoffice: Ensure that the TinyMCE configuration in the backoffice is also set to allow all elements and attributes. You can do this by modifying the TinyMCE configuration in the Umbraco backoffice.

    Go to Settings > Data Types. Find your Rich Text Editor Data Type. Edit the TinyMCE configuration and make sure to include the extendedvalidelements configuration. Here's an example of how you can configure it:

    {
      "toolbar": [
        "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
      ],
      "menubar": "file edit view insert format tools table help",
      "extended_valid_elements": "*[*]"
    }
    

    Custom TinyMCE Configuration (Optional): If the above steps do not work, you can customize the TinyMCE configuration further by creating a custom TinyMCE configuration file and loading it in your Umbraco setup.

    Check Permissions and Security Settings: Ensure there are no additional security settings or permissions that might be stripping out attributes. This can include server-side security configurations or additional sanitization logic in your code.

    By following these steps, you should be able to configure the Rich Text Editor to allow all elements and attributes in Umbraco 13.3.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 02, 2024 @ 07:12
    Huw Reddick
    0

    Hi girish,

    Your examples are incorrect "RichTextEditor": does not sit under "Content" it goes directly under "Umbraco" at the same level as "CMS"

    setting ValidElements or extendedvalidelements to [] does not fix this, Umbrac always removes the role attribute from div and span tags.

    Clear the Cache: Sometimes, Umbraco caches the settings. Clear the cache to make sure the new settings are applied. You can do this by restarting the application or manually clearing the cache.

    Any change to appsettings requires a restart since they are only loaded on startup, manually clearing the cache won't make any difference.

Please Sign in or register to post replies

Write your reply to:

Draft