简体   繁体   English

禁用在ckeditor中拖动

[英]disable dragging in ckeditor

I am facing an issue with my ckeditor. 我的ckeditor面临问题。 I am loading an entire page of HTML into the ckeditor. 我正在将整个HTML页面加载到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). 但是在编辑器中,每个div都是可拖动的(就像Office Word中的文本框一样)。 How can I lock these areas. 如何锁定这些区域。

You might consider using Jeditable instead of ckeditor. 您可以考虑使用Jeditable而不是ckeditor。 That way you can individually allow users to edit each text block. 这样,您可以单独允许用户编辑每个文本块。

I've used the following JS code before to disable text selection. 在禁用文本选择之前,我已经使用以下JS代码。 You might be able to use it to bind to the div/whatever holds the ckeditor instance. 您可能可以使用它绑定到div /包含ckeditor实例的任何对象。 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'
});

Have you added custom styles to the div element? 您是否已将自定义样式添加到div元素? In my case, the problem was that I had some styling - especially overflow: hidden . 就我而言,问题是我有一些样式,尤其是overflow: hidden Removing the overflow , height and min-height rules helped for me: the handles disappeared. 删除overflowheightmin-height规则对我有所帮助:手柄消失了。

Note that you can still add the rules where you actually display the content. 请注意,您仍然可以在实际显示内容的位置添加规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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