2013-07-23 84 views
1

我使用了以下内容:如何设置tinymce文本区域的高度?

<textarea 
    data-ui-tinymce="tinymceOptions" 
    data-ng-disabled="modal.action=='delete'" 
    data-ng-model="modal.formData.text" 
    id="inputText" 
    rows="20" 
    required></textarea> 

当TinyMCE的出现高度只有几厘米。首次出现时,如何更改默认的高度?

下面是我使用的选项列表:

selector: "textarea",   
plugins: [ 
         "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker", 
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking", 
         "table contextmenu template textcolor paste fullpage textcolor" 
       ], 

       toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect fontselect fontsizeselect", 
       toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | code | inserttime preview | forecolor backcolor", 
       toolbar3: "table | hr removeformat | subscript superscript | charmap | print fullscreen | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft", 

       menubar: false, 
       toolbar_items_size: 'small', 

       templates: [ 
         {title: 'Test template 1', content: 'Test 1'}, 
         {title: 'Test template 2', content: 'Test 2'} 

]

+0

可以模拟上的jsfiddle相同(http://jsfiddle.net)或添加屏幕截图,使其易于理解:) – dreamweiver

回答

4

应设置容器对象的高度在CSS:

#inputText { 
    height : 10000000px; 
} 
0

这对我的作品(见setTimeout part)

$(function() { 
 
    window.init_tinymce = function (id, custom_config) { 
 
     var textarea = $('#' + id); 
 

 
     // Default TinyMCE configuration 
 
     var basic_config = { 
 
      mode: 'none', 
 
      plugins: "link", 
 
      menu: 'none', 
 
      toolbar: 'bold | formatselect | link' 
 
     }; 
 

 
     tinymce.init($.extend(basic_config, custom_config)); 
 
     ... 
 

 
     setTimeout(function(){ //wait for tinymce to load 
 
      console.log('timeout'); 
 
      $(tinymce.editors[0].iframeElement).contents().find('body') 
 
       .css('min-height', $(tinymce.editors[0].contentAreaContainer).height() * .9); 
 
     }, 1000); 
 
    }; 
 
});

0

从JavaScript

tinymce.init({ 
    selector: 'textarea', 
    height: 200 
}); 

或从HTML

<textarea style="height: 200px;"> 
0

为TinyMCE的版本以前 4.X那么这个代码工作

tinyMCE.init({ 
    ..., 
    setup: function(editor) { 
     editor.onInit.add(function() { 
      var width = editor.getWin().clientWidth; 
      var height = 50; 

      editor.theme.resizeTo(width, height); 
     }); 
    } 
}); 

为TinyMCE的版本4.x和再经过这个代码工作

tinyMCE.init({ 
    setup: function (ed) { 
     ed.on('init', function(args) { 
     var id = ed.id; 
     var height = 25; 

     document.getElementById(id + '_ifr').style.height = height + 'px'; 
     }); 
    } 
}); 
相关问题