I have this line:

'paste_remove_spans': True,

that I want to use to stop TineMCE from automatically adding <span>'s to text that is pasted into the editor.

I know how to change the layout/buttons of the editor for wordpress like so:

function change_mce_options( $init ) {
 $init['theme_advanced_blockformats'] = 'p,address,pre,code,h3,h4,h5,h6';
 $init['theme_advanced_disable'] = 'forecolor';
 return $init;
}
add_filter('tiny_mce_before_init', 'change_mce_options');

But I can't seem to figure out how to add this new rule. Do I need to make a filter for that aswell?

有帮助吗?

解决方案

You should only have to modify your code to this:

function change_mce_options( $init ) {
  $init['theme_advanced_blockformats'] = 'p,address,pre,code,h3,h4,h5,h6';
  $init['theme_advanced_disable'] = 'forecolor';
  $init['paste_remove_spans'] = true;
  return $init;
}
add_filter('tiny_mce_before_init', 'change_mce_options');

Also, make sure so your cache is cleared by disabling/re-enabling your theme or plugin.

其他提示

It's not working anymore...

But I've found out solution that works:

change tinyMCEPreInit variable : for example, when I want to show just H3 and <p>:

<script type="text/javascript">
    jQuery(document).ready(function($) {
        tinyMCEPreInit.mceInit.post_editor.block_formats = "Paragraph=p;Heading 3=h3";
    });
</script>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top