CKEditor unwanted   characters

后端 未结 10 865
误落风尘
误落风尘 2020-12-02 08:13

How can I disable CKEditor to get me every time  , when i don\'t want them? I\'m using CKEditor with jQuery adapter.

I don\'t want to have any

相关标签:
10条回答
  • 2020-12-02 08:22

    I had the same problems creating some tables. What I saw was that if i created the tables with the css rule align="left" the <p>&nbsp;</p> are added, but if i changed the css rule to align="center" i could edit the paragraphs out and they were not added again.

    0 讨论(0)
  • 2020-12-02 08:25

    I noticed some text editing operations, like deleting a character (by hitting Backspace button) are spliting edited text node into two. Hitting Space Bar at the end of such newly created text node is always resulting into &nbsp; instead of normal space. I am calling normalize() http://www.w3schools.com/jsref/met_node_normalize.asp to changed element after change:

    CKEDITOR.on('instanceReady', function (ck) {
        ck.editor.on("change", function (e) {
            var sel = ck.editor.getSelection();
            if (sel) {
                var selected = sel.getStartElement();
                if (selected && selected.$)
                    sel.getStartElement().$.normalize();
            }
        });
     });
    
    0 讨论(0)
  • 2020-12-02 08:32

    I had already had to play around with config.js, so in order to fix '?' showing up in safari I ended up with 3 lines in config.js

    config.fillEmptyBlocks = function (element) {
    return true; // DON'T DO ANYTHING!!!!!};
    config.entities = false;
    config.basicEntities = false;
    
    0 讨论(0)
  • 2020-12-02 08:33

    There is another way that a non breaking space character can occur. By simply entering a space at the end of a sentence.

    CKEditor escapes basic HTML entities along with latin and greek entities.

    Add these config options to prevent this (you can also add them in your config file):

    CKEDITOR.on( 'instanceCreated', function( event ) {
     editor.on( 'configLoaded', function() {
    
      editor.config.basicEntities = false;
      editor.config.entities_greek = false; 
      editor.config.entities_latin = false; 
      editor.config.entities_additional = '';
    
     });
    });
    

    These options will prevent CKEditor from escaping nbsp gt lt amp ' " an other latin and greek characters.

    Sources: http://docs.ckeditor.com/#!/api/CKEDITOR.config http://docs.ckeditor.com/source/plugin48.html#CKEDITOR-config-cfg-basicEntities

    0 讨论(0)
  • 2020-12-02 08:35

    If you're using PHP you can use the following :

    preg_replace("/[\<]p[\>][\s]+&nbsp;[\<][\/]p[\>]/" , " " , $pre_comment);
    

    This will remove : "<p> &nbsp;</p>"

    Enjoy :)

    Maxwell

    0 讨论(0)
  • 2020-12-02 08:37

    Try:

    config.basicEntities = false;

    for me fixed the problem.

    0 讨论(0)
提交回复
热议问题