最近需要用到 WYSIWYG 編輯器,之前都習慣用 tinymce-rails (http://github.com/spohlenz/tinymce-rails) 來和 Rails 做串接。
後來想換另外一套 CKEditor (http://ckeditor.com/) 來試試,開發時沒啥大問題,但上 production 就會遇到 rails asset pipeline 的 compile 問題,當時懶得花時間解就先擱著了。現在又有同樣的需求,不處理不行,於是就認真把目前的 solution 看了一下。
如果在 terminal 下 gem search -r ckeditor
會找到下面這些
artemk-ckeditor (3.5.5)
bcms_fckeditor (1.0.4)
ckeditor (3.6.3)
ckeditor-jess (3.4.3)
ckeditor-rails (0.0.2)
ckeditor_assets (3.6.2)
dust-ckeditor (3.5.0)
fckeditor (0.1.0)
hifi-ckeditor (3.5.2)
iaddict-bcms_fckeditor (1.1.5)
rails-ckeditor (0.0.0)
其中 ckeditor 有整合圖片上傳的功能,是蠻好用的工具,值得看一看,但目前我想要單純一點的 gem。
而ckeditor-rails 和 ckeditor_assets 的 ckeditor 版本是比較新的,拿來試看看,還是有 precompile 的問題,只好放棄,確定要自己打造一顆輪子。
最後就產生了 ckeditor_rails (http://github.com/tsechingho/ckeditor-rails) 這個作品。
但要發布時因為和原本的 ckeditor-rails 撞名,所以只好把破折號 ( - ) 改為底線 ( _ ),這樣才能順利發布在 rubygems.org 上(http://rubygems.org/gems/ckeditor_rails)。
有任何指教,歡迎提供建議。
那跟撞名的那個 gem 有什麼不一樣的嗎?
非常的不喜欢 ckeditor 太重,太慢
是和 ckeditor-rails (http://github.com/fesplugas/rails-ckeditor) 撞名,這個 gem 只有把 ckeditor 解壓縮後,整包放在 vendor/assets 下,所以 vendor/assets/ckeditor 下很雜亂,js 和 css 也不會被 precompile(這當然可以手動加),另外也要手動加上一些設定才能用。
是的,目前 tinymce 和 ckeditor 都還很大一包,連 plugins 加起來,應該有 1 MB 左右,但這也是目前 WYSIWYG 比較好用的。
cool
發現一個 bug,README 上 Gemfile 應該要寫
gem 'ckeditor_rails', :require => 'ckeditor-rails'
才對,都是改名字的錯 ....
XDDD
從我的 iPhone 傳送
若想要 custom toolbar 有什麼方法嗎??
custom toolbar 要去寫 ckeditor config
我也覺得ckeditor太肥,有人推薦更輕量的嗎?
其實只想讓user做很簡單的文字編輯
謝謝
發現你的 document 有一個 bug
在 Include CKEditor javascript assets 這一段落
這一行
Add to your app/assets/stylesheets/application.js after //= require jquery_ujs to work with jQuery
應該是
Add to your app/assets/javascripts/application.js