disable dragging in ckeditor

拟墨画扇 提交于 2019-12-11 16:13:33

问题


I am facing an issue with my ckeditor. I am loading an entire page of HTML into the ckeditor. It's loading and showing fine. I want to let users edit only the data (texts), but not its alignment. But in editor each div is draggable (like the textbox in office word). How can I lock these areas.


回答1:


You might consider using Jeditable instead of ckeditor. That way you can individually allow users to edit each text block.




回答2:


I've used the following JS code before to disable text selection. You might be able to use it to bind to the div/whatever holds the ckeditor instance. Note that this would also prevent the user from being able to select text (for instance to copy/cut/etc).

// From http://chris-barr.com/entry/disable_text_selection_with_jquery/
$(function(){
    $.extend($.fn.disableTextSelect = function() {
        return this.each(function(){
            if($.browser.mozilla){//Firefox
                $(this).css('MozUserSelect','none');
            }else if($.browser.msie){//IE
                $(this).bind('selectstart',function(){return false;});
            }else{//Opera, etc.
                $(this).mousedown(function(){return false;});
            }
        });
    });
    $('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'
});



回答3:


Have you added custom styles to the div element? In my case, the problem was that I had some styling - especially overflow: hidden. Removing the overflow, height and min-height rules helped for me: the handles disappeared.

Note that you can still add the rules where you actually display the content.



来源:https://stackoverflow.com/questions/5244626/disable-dragging-in-ckeditor

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