什么所见即所得与 jQuery 和 Ruby on Rails 3.1 (Sprockets) 配合得很好?

发布于 2024-12-02 20:30:50 字数 323 浏览 2 评论 0原文

我在使用 Rails 进行任何“常见”所见即所得工作时遇到困难。我们甚至不得不暂时用 RedCloth 自己做一个。

我尝试使用 tinymce-rails 但无法使其工作。还尝试了 nicEdit ,它有效,但仅当您调用在线图书馆时(并且看起来也被遗弃)。

有人使用过对 jQuery 和 Rails 3.1(Sprockets)友好的所见即所得吗?

I am having trouble making any "common" WYSIWYG work with Rails. We even had to do one ourselves with RedCloth for the moment.

I tried to use tinymce-rails but couldn't make it work. Also tried nicEdit which worked but only when you called the online library (and also looks abandoned).

Has anyone worked with a good WYSIWYG that is jQuery and Rails 3.1 (Sprockets) friendly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

_蜘蛛 2024-12-09 20:30:50

我在 Rails 3.1 应用程序中使用 ckeditor

只需将文件夹放入 lib/assets/javascripts 中,每当需要时就可以像这样引用它:

= javascript_include_tag "ckeditor/ckeditor.js"

在 javascript 中:

:javascript
  $(function(){
    CKEDITOR.replace( 'input',
      {
        // Optional params:
        skin : 'office2003',
        height: '700px'
      });
  })

I use ckeditor in my Rails 3.1 app.

Just throw the folder into you lib/assets/javascripts and whenever you need it reference it like this:

= javascript_include_tag "ckeditor/ckeditor.js"

And in javascript:

:javascript
  $(function(){
    CKEDITOR.replace( 'input',
      {
        // Optional params:
        skin : 'office2003',
        height: '700px'
      });
  })
怪我闹别瞎闹 2024-12-09 20:30:50

在解决这个问题一段时间后,我想出了一个将标准tinyMCE与Rails 3.1和资产管道结合使用的解决方案。

  1. 我从tinyMCE jQuery 包开始。
  2. 在供应商中为tinyMCE创建一个目录:/vendor/assets/javascripts/tiny_mce
  3. 仅将jquery.tinymce.js放在/vendor/assets/javascripts/tiny_mce内
  4. 将剩余的 tinyMCE 文件放入 /public/javascripts 文件夹中名为 tiny_mce 的目录内
  5. 将tinyMCE添加到您的application.js中,如下所示:

    //=需要jquery
    ...
    //=需要tiny_mce/jquery.tinymce.js
    
  6. 我也在我的application.js 中初始化tinyMCE,并设置< code>script_url 路径告诉tinyMCE它的支持文件现在位于我的public/javascripts/tiny_mce目录中:

    $('.tinymce').each(function(i){
    $(这个).tinymce({
      script_url : '/javascripts/tiny_mce/tiny_mce.js',
       ...
    

应该可以。现在,您正在使用资产管道加载tinyMCE,并从公共目录提供支持资产和javascript。

After struggling with this issue for quite awhile, I came up with a solution for using the standard tinyMCE with Rails 3.1 and the asset pipeline.

  1. I started with the tinyMCE jQuery package.
  2. Create a directory in vendor for tinyMCE: /vendor/assets/javascripts/tiny_mce
  3. Place only jquery.tinymce.js inside of /vendor/assets/javascripts/tiny_mce
  4. Place the remaining tinyMCE files in a directory in your /public/javascripts folder, inside of a directory called tiny_mce
  5. Add tinyMCE to your application.js like so:

    //=require jquery
    ...
    //=require tiny_mce/jquery.tinymce.js
    
  6. I initialize tinyMCE in my application.js as well, and set a script_url path to tell tinyMCE that it's supporting files now live in my public/javascripts/tiny_mce directory:

    $('.tinymce').each(function(i){
    $(this).tinymce({
      script_url : '/javascripts/tiny_mce/tiny_mce.js',
       ...
    

That should work. Now you are using the asset pipeline to load tinyMCE, and serving the supporting assets and javascripts from the public directory.

三寸金莲 2024-12-09 20:30:50

Mercury Editor 看起来很有前途。我打算在下一个 Rails 项目中尝试一下。

http://jejacks0n.github.com/mercury/

The Mercury Editor looks promising. I'm planning to try it on my next rails project.

http://jejacks0n.github.com/mercury/

花伊自在美 2024-12-09 20:30:50

Luuf 已经提到了 Aloha-Editor。尽管它仍在大力开发中,但看起来很有希望。

只需将 aloha-config.js 文件放在资产路径中的任何位置,aloha 文件就会转到(即)供应商/资产。

示例配置:

    (function(window, undefined) {
        if (window.Aloha === undefined || window.Aloha === null) {
        var Aloha = window.Aloha = {};
            }

    Aloha.settings = {
      logLevels: {'error': true, 'warn': true, 'info': true, 'debug': false,    'deprecated': true},
      baseUrl: "/assets/lib",
      errorhandling: false,
      plugins: false
    };
    })(window);

“baseUrl”行是最重要的。将其设置为 /assets/lib 似乎可以确保与资产管道的兼容性。

还没有尝试过串联,当我知道它的行为方式时会发表评论。

问候!

Luuf already mentioned Aloha-Editor. Though it's still under heavy development it looks quite promising.

Just put a aloha-config.js file anywhere in your asset path, the aloha-files goes to (i.e.) vendor/assets.

Example config:

    (function(window, undefined) {
        if (window.Aloha === undefined || window.Aloha === null) {
        var Aloha = window.Aloha = {};
            }

    Aloha.settings = {
      logLevels: {'error': true, 'warn': true, 'info': true, 'debug': false,    'deprecated': true},
      baseUrl: "/assets/lib",
      errorhandling: false,
      plugins: false
    };
    })(window);

The line "baseUrl" is most important. Setting it to /assets/lib seems to ensure compability with the asset pipeline.

Haven't tried concatenation yet, will post a comment when I know how it behaves.

Regards!

寄风 2024-12-09 20:30:50

Aloha Editor

http://aloha-editor.org/

It's tough between that & Mercery - but Aloha has a nicer "feel" and it has wider browser support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文