Copied to clipboard

Flag this post as spam?

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


  • Adam Hearn 16 posts 127 karma points
    Aug 08, 2024 @ 16:58
    Adam Hearn
    0

    How to allow additional elements in U14 RTE

    Been away from Umbraco for quite a while and I see there's been lots of change... I'm trying to allow a couple of additional elements in the RTE (Umbraco 14.1.1).

    Problem - the RTE is dropping custom elements on save.

    Way of old (v8 IIRC) was to update validElements within config\tinyMceConfig.config

    I've found references (here and in Github Issues) to add a config section to the appsettings.json file so that [at least?] the following are present (really, the global section is at is was and the ValidElements list may/not be fully correct as was a copy found on the forum):

    "Umbraco": {
        "CMS": {
          "Global": {
            "SanitizeTinyMce": true
          },
          "RichTextEditor": {
            "ValidElements": "+a[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],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|reversed|start|style|type],-ul[class|style],-li[class|style],br[class],img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align|umbracoorgwidth|umbracoorgheight|onresize|onresizestart|onresizeend|rel|data-id],-sub[style|class],-sup[style|class],-blockquote[dir|style|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],#td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align|style],address[class|align|style],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|style|dir|class|align|style],hr[class|style],small[class|style],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang],object[class|id|width|height|codebase|*],param[name|value|_value|class],embed[type|width|height|src|class|*],map[name|class],area[shape|coords|href|alt|target|class],bdo[class],button[class],iframe[*],figure,figcaption,i[*]"
          }
        }
    

    The documentation page for the config is there for v13 but v14 it's ominously missing.

    Would anyone have a working example of how to add an element to the valid elements list of the RTE for Umbraco 14? TIA!

  • Adam Hearn 16 posts 127 karma points
    Aug 09, 2024 @ 07:59
    Adam Hearn
    0

    A solution should anyone else have the same question - a TinyMCE plugin can be used to manipulate the settings:

    Create an Umbraco manifest file:

    "[site-root]\App_Plugins\[name]\umbraco-package.json"
    

    The content of the file:

    {
      "name": "My TinyMCE Plugin",
      "version": "1.0.0",
      "extensions": [
        {
          "type": "tinyMcePlugin",
          "alias": "mytinymceplugin",
          "name": "My TinyMCE Plugin",
          "meta": {
            "SanitizeTinyMce": false,
    
            "config": {
              "plugins": [ "[name]" ],
              "valid_elements": "+a[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],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|reversed|start|style|type],-ul[class|style],-li[class|style],br[class],img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align|umbracoorgwidth|umbracoorgheight|onresize|onresizestart|onresizeend|rel|data-id],-sub[style|class],-sup[style|class],-blockquote[dir|style|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],#td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align|style],address[class|align|style],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|style|dir|class|align|style],hr[class|style],small[class|style],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang],object[class|id|width|height|codebase|*],param[name|value|_value|class],embed[type|width|height|src|class|*],map[name|class],area[shape|coords|href|alt|target|class],bdo[class],button[class],iframe[*],figure,figcaption,i[*]"
            }
          }
        }
      ]
    }
    
  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 09, 2024 @ 10:01
Please Sign in or register to post replies

Write your reply to:

Draft