dtdckeditor4.x

CKEDITOR 4 - dtd: If i change b element values, others also change like p elements


I'm working with CKEDITOR 4 and I have added a new element to dtd. My custom element can be contained in a 'p' element but I don't want that it can be contained in a 'b' element. Then, now I have this:

alert( !!CKEDITOR.dtd[ 'p' ][ 'mycustomtag' ] ); // **true**

alert( !!CKEDITOR.dtd[ 'b' ][ 'mycustomtag' ] ); // **true**

So I do the following:

CKEDITOR.dtd.[ 'b' ][ 'mycustomtag' ] = 0;

but after this I check it again and:

alert( !!CKEDITOR.dtd[ 'p' ][ 'mycustomtag' ] ); // **false**

alert( !!CKEDITOR.dtd[ 'b' ][ 'mycustomtag' ] ); // **false**

It seems like b and p element are grouped in some way... but I want to get this:

alert( !!CKEDITOR.dtd[ 'p' ][ 'mycustomtag' ] ); // **true**

alert( !!CKEDITOR.dtd[ 'b' ][ 'mycustomtag' ] ); // **false**

I can't find a way to change only element b... Anyone know how to get it?

Thanks.


Solution

  • I have finally found a solution.

    Consists in redefining the dtd elements (b and p) in whole and not in part, like this:

    CKEDITOR.dtd.b = { '#': 1, a: 1, abbr: 1, *mycustomtag: 0*, acronym: 1, applet: 1, 
    area: 1, audio: 1, font: 1, i: 1, iframe: 1, ... }
    
    CKEDITOR.dtd.p = { '#': 1, a: 1, abbr: 1, *mycustomtag: 1*, acronym: 1, applet: 1, 
    area: 1, audio: 1, font: 1, i: 1, iframe: 1, ... }
    

    I don't know if it is the most elegant solution, but it worked out well.

    kind regards.