Want to remove the <br type=“_moz”> tag in CKEDITOR 4.2.0

最后都变了- 提交于 2019-12-11 11:55:57

问题


With the inline editor CKEDITOR 4.2.0 and Firefox 23.0.1 the inner html of my editable div tags are enriched with <br type="_moz">. It is not inserted with IE.

I can easily find and replace this tag using javascript.

How can I handle this in the config.js file globally for all my inline editable divs?


回答1:


You should not get data from inline editor by element.innerHTML (or $(element).html()). There's a significant difference between what's really in there and what will CKEditor returns from editor.getData() (which is the correct method to use).

This difference comes from the fact that data (set by editor.setData() - yup - don't set it directly too) needs to be transformed to be better editable inside contenteditable element. Therefore, then that transformation (and other weird things done by/for browsers) need to be reverted and this happens on editor.getData().

PS. If you don't know where to get editor instances check global CKEDITOR.instances object.




回答2:


If using jQuery you can simply search the document for < br type="_moz" > and remove it. Of course you don't need to search whole document, just the DOM element you want.

$(document).find('br').each(function(){
    if($(this).attr('type') === '_moz'){
        $(this).remove();
    }
});



回答3:


Quick easy CSS solution would be to add the following to your stylesheet that gets loaded into CKeditor:

br[type="_moz"]{display: none;}



回答4:


I have used this patch and it worked for me.

http://dev.ckeditor.com/attachment/ticket/5767/5767.patch

Unfortunately, ckeditor team did not use this patch.

So remove appendBogus function from _source/core/dom/element.js and add new appendBogus function to _source/core/dom/walker.js and then combine all the js file as per ckeditor.pack file to recreate ckeditor.js



来源:https://stackoverflow.com/questions/18469969/want-to-remove-the-br-type-moz-tag-in-ckeditor-4-2-0

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