Search code examples
jqueryhtmlcssautoresize

Resizing window with NicEditor


I'm using NicEditor (http://nicedit.com).

First, I set the width of the textarea 100%, but when I resize the window, the editor stays the same and won't resize to the new 100% width of the window.

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

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

</script> 

How can I fix this?

EDIT: I found a solution that works:

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

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

Solution

  • By Default, Nice Editor or CK Editor don't have responsive feature.

    Try something like below. control the width and height by parent element.

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

    On every window resize, invoke the NiceEdit

    JS:

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

    Reference - Demo 3 : Add/Remove NicEditors:
    http://nicedit.com/demos.php?demo=3