使用 NicEditor 调整大小 window

Resizing window with NicEditor

我正在使用 NicEditor (http://nicedit.com)。

首先,我将文本区域的宽度设置为 100%,但是当我调整 window 大小时,编辑器保持不变,不会调整到 [=24= 的新 100% 宽度].

<textarea style="width: 100%;"> something .. </textarea>

<script>
    //<![CDATA[
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
//]]>

</script> 

我该如何解决这个问题?

编辑: 我找到了一个有效的解决方案:

  $(function () {
      editor = new nicEditor({fullPanel : false}).panelInstance('text');
  })

  $(window).resize(function() {
     editor.removeInstance('text'); 
     editor = new nicEditor({fullPanel : false}).panelInstance('text');
  });

默认情况下,Nice Editor 或 CK Editor 没有响应功能。

试试下面的方法。通过父元素控制宽度和高度。

    <textarea id="comments" style="width:100%; height:100%;"></textarea>

每次 window 调整大小时,调用 NiceEdit

JS:

  var editor;
  function reLoadEditor() {
      editor.removeInstance('comments'); 
      editor = new nicEditor({fullPanel : false}).panelInstance('comments');
  }();

  $(window).resize( function() {
     reLoadEditor();
  } );

参考 - 演示 3:Add/Remove NicEditors:
http://nicedit.com/demos.php?demo=3

我找到了另一个简单的方法。在 nicEdit.js 文件更改中,您只需更改 2 行:

453线附近变化"width".

原文:

var panelElm = new bkElement('DIV').setStyle({
  width: (parseInt(e.getStyle('width')) || e.clientWidth) + 'px'
}).appendBefore(e);

新:

var panelElm = new bkElement('DIV').setStyle({
  width: '100%'
}).appendBefore(e);

在第 554 行附近,您还必须更改 "width"。

原文:

newX = parseInt(e.getStyle('width')) || e.clientWidth;

新:

newX = '100%';

就这些了。