Rails 3.1 ckeditor: Adding fontsize in toolbar?

廉价感情. 提交于 2020-01-06 09:31:14

问题


I have ckeditor in my rails 3.1 app but I am not able to add fontsize and font dropdowns to my toolbar.

My edit view code:

<%= javascript_include_tag "ckeditor/ckeditor.js" %>
...
<%= form_for @page, :html => { :class => 'edit_page', :id => "page_form" } do |page| %>
...
<%= page.cktext_area :content, {:height => "350px", :width => "920px"}%>
...
<% end %>

I am able to adjust the height and width but not add any other parameters?


回答1:


Could be late but in rails 3.1 app you can go to /vendor/bundle/ruby/1.8/gems/ckeditor-3.7.0/vendor/assets/javascripts/ckeditor/config.js this is where configuration for the toolbars takes place.

Here is an exemple of my configuration

    ..
    ...
     /* Toolbars */
      config.toolbar = 'Easy';

      config.toolbar_Easy =
        [
            ['Source','-','Preview'],
            ['Cut','Copy','Paste','PasteText','PasteFromWord',],
            ['Undo','Redo','-','SelectAll','RemoveFormat'],
            ['Styles','Format','FontSize'],['Maximize','-','About'],
            ['Subscript', 'Superscript', 'TextColor'],
            ['Bold','Italic','Underline','Strike'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
            ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
            ['Link','Unlink','Anchor'],
          /*   ['Image', 'Attachment', 'Flash', 'Embed'], */
            ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
        ];
    ...
    ..

and there is an image of how this configuration looks in a form




回答2:


I never used this gem or ckeditor before, but looking at their documentation it seems pretty straight forward.

Looks like you just modify public/javascripts/ckeditor/config.js

config.fontSize_sizes = '16/16px;24/24px;48/48px;';

Ref.

https://github.com/galetahub/ckeditor

http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.fontSize_sizes




回答3:


You can install this plugin http://ckeditor.com/addon/font

Extract and copy the "font" folder to ckeditor/plugins directory then inside your code call the plugin.

CKEDITOR.replace(this.id, {
    extraPlugins: 'font',
});

Now your toolbar will show up with font family and size option as below




回答4:


rmagnum2002, Is it possible to change the width and height of the toolbar button. ex: changing width of size drop down box.

I have added some plugins and but dont' know how to change width of the plugin?



来源:https://stackoverflow.com/questions/9425318/rails-3-1-ckeditor-adding-fontsize-in-toolbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!