Copied to clipboard

Flag this post as spam?

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


  • Liam 22 posts 158 karma points
    Sep 12, 2013 @ 13:37
    Liam
    0

    TinyMce Schema

    Hi all,

    I've been trying to figure out the best/quickest way to restrict tinyMce so that it only allows valid html5 elements.

    I see here (snippet below) that this can be done in tinymce.init function

    tinymce.init({
       
    ...
       schema
    : "html5"
    });

    There is also a customConfig section in tinyMceConfig.config

    <!-- this area is for custom config settings that should be added during TinyMCE initialization -->

      <customConfig>

        <config key="entity_encoding">raw</config>

    <config key="schema">html5-strict</config>

    ...

    I realise that I can specify any valid elements just above this section in the this config file but shouldn't this setting save me from doing this?

    Anyone else been able to get this working?

    Thanks in advance.

    Liam

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Sep 16, 2013 @ 22:50
    Jan Skovgaard
    0

    Hi Liam and welcome to our :)

    You can see a list of the allowed elements in the /config/tinyMceConfig.config file - sounds like it's what you're looking for?

    Otherwise please let us know.

    Cheers, Jan

  • Liam 22 posts 158 karma points
    Sep 17, 2013 @ 15:58
    Liam
    0

    Hi Jan,

    Thanks for your reply.

    Yes, I did see the "valid elements" section/list in the config file where you add valid elements from this works perfectly (if you have a complete and updated list).

    I eventually ended up going down this route to get my site to pass accessibility test but the list in the config is incomplete meaning there is a potential for valid elements to be missed and therefore tidied out incorrectly. 

    My thought was that the custom settings section could be used to specify schema which would instruct TinyMce to control valid elements based on what this is set to. I am assuming somewhere in TinyMce source there are lists of valid elements depending on schema targetted. 

    I realise that I could create and test a full config section which has every valid HTML5 element then use that in future, remembering to update it for any new elements introduced etc but that seems like a lot of work especially when tinyMce have got this facility already......perhaps I am just being lazy :)  

    Thanks Again,

    Liam

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Sep 17, 2013 @ 21:27
    Jan Skovgaard
    0

    Hi Liam

    Yes it's indeed hard to keep up with what's a go and a no-go with elements and attributes in the HTML5 spec since it's a living spec that can be changed quickly.

    I'm not sure what the best approach for keeping the list updated would be, but I think it's worth considering WHAT elements makes sense in a rich text editor. It does not make sense to allow

    and
    for instance...

    But it would actually be a good idea to update the config file - perhaps one should do a core pull request adding some of the elements that have proven themselves good enough to stay in the spec? :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft