简体   繁体   English

(CKEDITOR) Internet Explorer 删除调整大小处理程序

[英](CKEDITOR) Internet Explorer remove resize handler

I have the problem that on internet explorer for each div in the editor a resize box is shown.. This box isn´t shown for Mozilla Firefox.我遇到的问题是,在 Internet Explorer 上,对于编辑器中的每个 div,都会显示一个调整大小框。Mozilla Firefox 不显示此框。 How can i remove this resize box/resize handler and focus the element directly on typing or selecting it?如何删除此调整大小框/调整大小处理程序并将元素直接集中在键入或选择它上?

Actually i need this: http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-disableObjectResizing but it also needs to remove the weird box.其实我需要这个: http : //docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-disableObjectResizing但它也需要删除奇怪的框。 If it isn't remove i need to click twice and the Ckeditor right click menu fails...如果它没有被删除,我需要单击两次并且 Ckeditor 右键单击​​菜单失败...

调整框大小?

PArtial solution部分解决方案

This url provided a partial anwser http://chris.photobooks.com/tests/rte/IE_resizing/IE_resizing.html此网址提供了部分答案http://chris.photobooks.com/tests/rte/IE_resizing/IE_resizing.html

It is not something from CKEDITOR but from html5/javascript/ie This is a temp fix for the right click menu to work ok, again.它不是来自 CKEDITOR 而是来自 html5/javascript/ie 这是一个临时修复程序,可以让右键菜单再次正常工作。

    $("iframe")[0].contentDocument.attachEvent( 'oncontrolselect', function( event )
    {
            event.srcElement.focus();
            return false;
    }); 

To Test/reproduce the bug/problem:要测试/重现错误/问题:

<script src="http://ckeditor.com/apps/ckeditor/4.0.1/ckeditor.js"></script> 
<div id="testEditor">test text<div style="min-height:200px;"> test div</div></div> 
<script>CKEDITOR.replace("testEditor");</script>

Note: You need to click the div element to see the box.注意:您需要单击 div 元素才能看到该框。

IE doesn't show the boxes when the editable element is contained in a not editable element:当可编辑元素包含在不可编辑元素中时,IE 不会显示这些框:

<div contenteditable="false">
    <div contenteditable="true">
       . . .
    </div>
</div>

The ckeditor content is edited in an HTML document. ckeditor 内容在 HTML 文档中进行编辑。 The contenteditable flag is set by ckeditor on the body tag of that document. contenteditable 标志由 ckeditor 在该文档的正文标签上设置。 It seems not possible to set a contenteditable=false attribute to its parent, the HTML tag.似乎不可能为其父级 HTML 标记设置 contenteditable=false 属性。

My (jQuery) workaround is to set the iframe body contenteditable attribute to false, and wrap the body content in a div that has contenteditable=true.我的 (jQuery) 解决方法是将 iframe 正文 contenteditable 属性设置为 false,并将正文内容包装在具有 contenteditable=true 的 div 中。 You will have to do that on every mode change, but the mode event is also thrown on instanceReady:您必须在每次模式更改时都这样做,但模式事件也会在 instanceReady 上抛出:

editor.on('mode', function (evt) {
   //-- in system mode return, editor has no document here
   if (!evt.editor.document) return false;

   //-- get the body of the document in the cdeditor iframe
   var $editorDocumentBody = $(evt.editor.document.getBody().$);

   //-- if ie hasLayout property, wrapper needed to avoid resize borders
   var documentStyle = $editorDocumentBody[0].currentStyle;
   if (typeof documentStyle.hasLayout != 'undefined' && documentStyle.hasLayout){

      //-- check if wrapper div already exists
      var $insertedElement = $editorDocumentBody.find('div[contenteditable="true"]');

      //-- if not, create wrapper, append body content to it, append to body
      if (!$insertedElement.length) {
         $insertedElement = $('<div/>', {
            contenteditable: 'true'
         }).append($editorDocumentBody.contents()).appendTo($editorDocumentBody);
      };

      //-- set the contenteditable attributes
      $editorDocumentBody.attr('contenteditable', 'false');
      $insertedElement.attr('contenteditable', 'true');
   };
}

You might need to allow elements with the contenteditable attribute.您可能需要允许具有 contenteditable 属性的元素。 You can edit config.js and add something like this:您可以编辑 config.js 并添加如下内容:

config.allowedContent = 
   'span p a img hr h6 h5 h4 h3 h2 h1 th td tr div;*[contenteditable]';

Please note that this workaround wraps a div around the user content, what might not be preferable.请注意,此解决方法在用户内容周围包裹了一个 div,这可能并不可取。 You can see the div with the contenteditable attribute in HTML mode.您可以在 HTML 模式下看到带有 contenteditable 属性的 div。

It looks like IE automatically adds resize handles on editable elements with defined dimensions.看起来 IE 会自动在具有定义尺寸的可编辑元素上添加调整大小的句柄。 If you get rid of the min-height, the handles will go away.如果你摆脱了最小高度,手柄就会消失。

<div contenteditable="true">
    <!-- IE9 displays resize handles around this div because
         its height is defined. -->
    <div style="height: 100px">test</div>
</div>

<div contenteditable="true">
    <!-- No resize handles here because size is auto. -->
    <div>test</div>
</div>

<div>
    <!-- Obviously no handles here either because content is
         not editable. -->
    <div style="height: 100px">test</div>
</div>

In my case, I had a problem removing the resize handler in IE11 in the Summernote WYSIWYG-editor.就我而言,我在Summernote所见即所得编辑器中删除 IE11 中的调整大小处理程序时遇到问题。 I also reviewed many topics on Stackoverflow .我还回顾了Stackoverflow上的许多主题。 The reason was that I had the property width: 705px in the styles for paragraph p.原因是我在段落 p 的样式中有属性width: 705px When I removed this property, then the damn resize handler disappeared!当我删除此属性时,该死的调整大小处理程序消失了!

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

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