简体   繁体   中英

Tiny MCE content formatting is not putting styles into the spans it creates

I am using TinyMCE Version 4.3.12 to edit html for an intranet Knowledge Base. When I try to change formatting on some of the text, ie changing font size with the font size dropdown, the editor shows the text as it should be. However, after posting, the output only shows the span tags that the styling should be in, with no styling in these tags. Even the view source option in the editor is showing span tags around the text with no styling at all. Is there any way to correct this?

EDIT: here is the code that calls TinyMCE. There is no special code being used to convert the output. The code within the editor is showing span tags around text, but no styling in these span tags.

    $('#editmodal-diag-text').tinymce({
                                    selector: "textarea"
                                    , content_css: 'style.css'
                                    , theme: "modern"
                                    , visual: false
                                    , selector: "textarea:not(.discussionPostBox)"
                                    , plugins: [
                                        "advlist autolink lists link image charmap print preview hr anchor pagebreak adjustlineheight",
                                        "searchreplace wordcount visualblocks visualchars code fullscreen",
                                        "insertdatetime media nonbreaking save table contextmenu directionality",
                                        "emoticons template paste textcolor colorpicker textpattern toggleparent frameset"
                                    ]
                                    , toolbar1: "undo redo | styleselect | bold italic underline strikethrough | link image | alignleft aligncenter alignright | anchor link | lineheight"
                                    , toolbar2: " bullist numlist outdent indent | preview html | forecolor backcolor | removeformat | toggleparent | fontsizeselect | frameset | adjustlineheight"
                                    , inline_styles: true
                                    , verify_html: false
                                    , fix_list_elements: true
                                    , valid_styles: {
                                        '*': '*'
                                    }
                                    , valid_elements: '*[*]'
                                    , forced_root_block: false
                                    }

                                });

Your use of valid_styles in your configuration is what is causing your issues. Please see this TinyMCE Fiddle: http://fiddle.tinymce.com/q2faab/1

If you just comment out your valid_styles portion of the configuration things seem to work.

I would note that a few plugins you have in your configuration ( adjustlineheight , toggleparent , and frameset ) don't seem to be part of standard TinyMCE so they are not part of the fiddle. If things work in the fiddle but not with those plugins loaded its possible they could be causing an issue as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM