在 Rails Ruby 中调整 tinymce 编辑器的宽度

Adjust width of tinymce editor in Ruby on Rails

我在 ruby 的 rails 项目中使用 TinyMce gem,我正在尝试调整编辑器的宽度。目前,编辑器的宽度为 100%。

我在某处读到,TinyMce-Editor 采用 area_field 的大小,所以我尝试了这个:

<%= f.text_area :content, :cols =>10, :rows => 50, class: "tinymce" %>

高度根据行值变化,但宽度保持全屏。我通过本教程在 rails 中实现了 tinymce:https://richonrails.com/articles/adding-tinymce-to-your-rails-application

我注意到,在 tinymce.yml 文件中,有两行提到全屏:

theme_advanced_toolbar_location: top
theme_advanced_toolbar_align: left
theme_advanced_statusbar_location: bottom
theme_advanced_buttons3_add:
  - tablecontrols
  - fullscreen
plugins:
  - table
  - fullscreen

但我不知道我需要更改什么,以调整编辑器的宽度。有什么建议吗?提前致谢!

编辑:

我将此添加到我的博文中:

<script>
 tinyMCE.init({
         // General options
         mode: "textareas",
         theme: "advanced",
         width: "300",
         height: "200",

         // Theme options
         theme_advanced_buttons1: "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull",
         theme_advanced_buttons2: "",
         theme_advanced_buttons3: "",
         theme_advanced_buttons4: "",
         theme_advanced_toolbar_location: "top",
         theme_advanced_toolbar_align: "left",
         theme_advanced_resizing: false,

     // Selector
         editor_selector: "tinymce",

 });
</script>

然后,我的编辑不见了。我哪里做错了?

这里是一个示例代码,用于调整宽度并很好地居中 tinymce。只需将宽度(此处 =400px)设置为您想要的大小即可。

<div class="field">
   <%= f.label :content %><br />
   <div style="width: 400px">
      <%= f.text_area :content, :class => "tinymce", :rows => 3 %>
   </div>
</div>