Rich online editor for Ruby on Rails - tinyMCE

[url]http://www.aidanf.net/adding-a-rich-text-editor-to-your-rails-application[/url] 推薦兩款for rails的rich editor.
今日嘗試了一下以前在java裏使用過的TinyMCE。

[quote]ruby script/plugin install hxxp://secure.near-time.com/svn/plugins/trunk/tiny_mce/
[/quote]
[quote]rake tiny_mce:scripts:install[/quote]
在controller裏配置editor的屬性:

class UsersController < ApplicationController
uses_tiny_mce(:options => {:theme => 'advanced',
:browsers => %w{msie gecko},
:theme_advanced_toolbar_location => "top",
:theme_advanced_toolbar_align => "left",
:theme_advanced_resizing => true,
:theme_advanced_resize_horizontal => false,
:paste_auto_cleanup_on_paste => true,
:theme_advanced_buttons1 => %w{formatselect fontselect fontsizeselect bold italic underline strikethrough separator justifyleft justifycenter justifyright indent outdent separator bullist numlist forecolor backcolor separator link unlink image undo redo},
:theme_advanced_buttons2 => [],
:theme_advanced_buttons3 => [],
:plugins => %w{contextmenu paste}},
:only => [:new, :edit, :show, :index])

而後在view中任意使用textarea的屬性,都會出現一個Rich editor.

<% # Include TinyMCE before other JS to avoid problems -%>
<%= javascript_include_tiny_mce_if_used %>
<%= tiny_mce if using_tiny_mce? %>

<%= f.text_area :user_name %>

似乎不能只針對一個屬性。
更多請看:
[url]http://tinymce.moxiecode.com/index.php[/url]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章