Rails 3 和富文本编辑器 [英] Rails 3 and Rich text editor

查看:65
本文介绍了Rails 3 和富文本编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个带有博客、评论和其他需要用户输入文本的功能的 Rails 3 应用程序.

I am building a Rails 3 app with blogging, commenting, and other functionality that require the users to input text.

我的问题是使用 Javascript 富文本编辑器是否更好.会有什么好处和坏处.如果这是推荐的方法:

My question is whether it is a better idea to use a Javascript rich text editor or not. What would be the pros and cons. If it is a recommended approach:

  1. 哪些编辑器最好?
  2. 如何在 Rails 表单中使用它们?

提前致谢,

史蒂夫

推荐答案

大多数 Web 富文本编辑器都使用 JavaScript.这些是您可以考虑的一些受欢迎的

Most rich text editors for the web use JavaScript. These are some popular ones you could consider

  1. jwysiwig
  2. markitup
  3. Redactor(这是一个很棒的基于 jQuery 的所见即所得编辑器,它还有一个 Rails 扩展,我在下面链接到了.)
  4. Bootstrap-wysihtml5(如果您正在寻找 Twitter Bootstrap 样式编辑器)
  1. jwysiwig
  2. markitup
  3. Redactor (This is great jQuery based wysiwyg editor that also has a Rails extension I've linked to below.)
  4. Bootstrap-wysihtml5 (If you're looking for a Twitter Bootstrap style editor)

当然,如果您需要,您也可以考虑重量级的替代品,例如 TinyMCE 或 CKEditor.

Of course, you could also consider heavy-weight alternatives like TinyMCE or CKEditor, if your needs are such.

Ruby on Rails 解决方案

如果您需要能够通过 Ruby on Rails 库将图像添加到文本区域,例如 Paperclip或者Carrierwave,你可以考虑其中之一

If you need to able add images to your textarea through a Ruby on Rails library, such as Paperclip or Carrierwave, you may consider one of these

  1. rails-ckeditor
  2. 水银 (Railscast)
  3. rails_tiny_mce
  4. redactor-rails

使用普通 JavaScript 编辑器的问题

当您尝试将图像添加到文本区域时,大多数 javascript 编辑器会提示您输入 URL,因此如果您需要这样做,您可能需要将图像上传到其他地方并向编辑器提供 URL.

Most javascript editors will prompt for a URL when you try to add an image to your textarea, so if you need to do so, you may have to upload the image elsewhere and provide the editor with the URL.

不过我发现有一个 JavaScript 编辑器,http://nicedit.com/,可以进行 AJAX 上传添加图片时http://imageshack.us.当然,提供的图像将完全依赖于 imagehack,这可能对您有用,也可能不适合.这真的取决于你的场景.

There is however one JavaScript editor I found, http://nicedit.com/, that does an AJAX upload to http://imageshack.us when you add an image. Of course, the images that are served will become totally dependent on imageshack which may or may not work for you. It really depends on your scenario.

这篇关于Rails 3 和富文本编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆