How to replace <b> with <strong> in TinyMCE for Plone

ぐ巨炮叔叔 提交于 2019-12-23 17:11:17

问题


I would like to replace bold tag, , with strong tag, in TinyMCE. How to do it in Plone using Products.TinyMCE?

I read TinyMCE document, http://www.tinymce.com/wiki.php/Configuration:valid_elements. Below is how to do it in TinyMCE:

tinyMCE.init({
    ...
    valid_elements : "strong/b"
});

Thanks.


回答1:


I never tested this change, however you can try what you learned patching "tiny_mce_init.js".

To do this I suggest to use z3c.jbot (see also http://blog.keul.it/2011/06/z3cjbot-magical-with-your-skins.html).




回答2:


You may do this using the tinymce configuration:

tinyMCE.init({
    ...
    extended_valid_elements : "strong/b",
    ....
    // Override internal formats  
    formats: {
    bold : {inline : 'strong' }
    },
    ...
});

In case you have editor content already saved in the database with b-tags it might be needed to replace those tags on serverside with strong-tags.




回答3:


Both keul and Thariama answers are correct. I have to combine both answers in order for TinyMCE working in Plone.

Here is how I do it, - patching/overriding "tiny_mce_init.js" with the name "Products.TinyMCE.skins.tinymce.tiny_mce_init.js" using z3c.jbot.

function TinyMCEConfig(id) {
  ...
  this.init = function() {
    ...
    var init_dict = {
      ...
      fix_list_elements : false,

      extended_valid_elements : "strong/b",
      // Override internal formats  
      formats: {
        bold : {inline : 'strong' }
      }
    };
    ...
  };    
  ...      
}


来源:https://stackoverflow.com/questions/10394205/how-to-replace-b-with-strong-in-tinymce-for-plone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!