1

I'm using/testing django-cms (2.3.5) + bootstrap based templates. Using django-tinymce I add the code:

<a class="carousel-control right" href="#this-carousel-id" data-slide="next">›</a>

But django-tinymce removes "data-slide="next""

<a class="carousel-control right" href="#this-carousel-id">›</a>

And of course nothing works.

Using WYeditor I found no way to modify the options in settings.py. Using tinyMCE I can :

TINYMCE_DEFAULT_CONFIG={
    # General options
    'mode': "textareas",                   
    'theme': "advanced", 
    'remove_linebreaks': "false",

    'convert_urls': "false",
    'relative_urls': "false",
    'theme_advanced_resizing': "true",
    'paste_auto_cleanup_on_paste': "true",
    #'preformatted': "true",

    'valid_elements': "+*[*]",

    'width': "100%",
    'height': "300px",    

    'theme_advanced_buttons1' : "formatselect,separator,bold,italic,hr,separator,link,unlink,separator,bullist,numlist,separator,undo,redo,",
    'theme_advanced_buttons2' : "|,help,code,|",
    'theme_advanced_buttons3' : ""  ,
    'theme_advanced_blockformats' : "p,h1,h2,h3,blockquote",
    'theme_advanced_toolbar_location' : "top",
    # Example content CSS (should be your site CSS)
    #'content_css': 'css/example.css',    
    #'content_css' : "/media/css/tiny_editor.css" 
}

Workflow:

  • I open the HTML popup
  • I copy the code
  • I reopen the popup and the wanted code is there
  • I save the page and I reopen the popup and the code has changed!

How can I avoid this behavior?

I also added the options to keep the spaces/tabs/comments/, to keep the absolute path, but /static/images/path/ is always converted to ../../../../../static/*.

What do I have to check/change?

Thanks!

Daviddd
  • 761
  • 2
  • 12
  • 37
  • https://github.com/divio/django-cms/issues/1529. Ok, hence only solution will be to create my own plugin? – Daviddd Feb 08 '13 at 12:07

3 Answers3

1

You will need to declare data-slide as a valid attribute of a link/a-tag. Have acloser look at the valid_elements setting of tinymce

Thariama
  • 50,002
  • 13
  • 138
  • 166
  • Thanks for replying! Why is it not working using 'valid_elements': "+*[*]",? I already checked valid_elements, but I only specified valid_elements: "a[data-slide]," and it removed other a attributes, except for data-slide. I don't want to specify all attributes. The same with extend_valid_elements – Daviddd Feb 08 '13 at 11:29
  • I'm almost sure it's Django-cms that removes "data-slide" attribute. If open, update the code in the tinymce popup and I reopen it the code is kept. When I save the page, Django "somehow" sanitizes the HTML. – Daviddd Feb 08 '13 at 11:42
  • well, this is possible too – Thariama Feb 08 '13 at 11:42
  • Linked question: http://stackoverflow.com/questions/14774076/django-cms-editors-and-html-data-attribute-cleaned-up – Daviddd Feb 08 '13 at 13:53
1

i belive the removing of the fields is done by html5lib that the cms uses as python package, you'll need to open html5lib folder and open sanitizer.py, in line 184 where the code is:

if name in self.allowed_attributes])

change to:

if name in self.allowed_attributes or re.match( r'data-.*',name)]) 

this will allow all data-(whatever) attributes

for WYMeditor the data-(whatever) attribute is already allowed

elad silver
  • 9,222
  • 4
  • 43
  • 67
-1

"false" and "true" change on False and True

inzem77
  • 129
  • 3