ckeditor gem custom config.js не загружается в производство - PullRequest
0 голосов
/ 20 марта 2019

Я следовал инструкциям в gem readme, чтобы использовать ckeditor в моем приложении rails, но как только я пытаюсь использовать его в рабочей среде вместе с heroku, файл config.js, который используется по ссылке CDN, а не из моих ресурсов/javascripts/ckeditor/config.js файл.Пользовательский конфиг работает в среде разработки.

ckeditor.rb initializers / assets / application.rb

Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.precompile += %w( ckeditor/*)
Rails.application.config.assets.precompile += %w( custom_styling.css )

initializers / assets / ckeditor.rb

    Ckeditor.setup do |config|
      require 'ckeditor/orm/active_record'

       config.image_file_types = %w(jpg jpeg png gif tiff)

       config.attachment_file_types = %w(mp4 doc docx xls odt ods pdf rar zip tar tar.gz swf)

       config.cdn_url = "//cdn.ckeditor.com/4.11.3/standard/ckeditor.js"

       config.js_config_url = 'ckeditor/config.js'
    end

assets / javascripts / ckeditor / config.js

    CKEDITOR.editorConfig = function( config ) {
      config.language = 'en';
      config.uiColor = '#ffffff';

      config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
      config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
      config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
      config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
      config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
      config.filebrowserImageUploadUrl = "/ckeditor/pictures?";
      config.filebrowserUploadUrl = "/ckeditor/attachment_files";
      config.allowedContent = true;

      config.toolbar = [
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source'] },
        { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
        { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
        { name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'SpecialChar' ] },

      ];
    };

config / initializers / assets.rb

Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.precompile += %w( ckeditor/config.js)
Rails.application.config.assets.precompile += %w( custom_styling.css )

views / article_templates / edit_form.html.erb

<%= javascript_include_tag Ckeditor.cdn_url %>
<textarea id="content" name="content" class="ckeditor"><%= raw @article.content %></textarea>

1 Ответ

0 голосов
/ 20 марта 2019

Прежде всего вы должны установить правильный путь для config.js в ckeditor.rb:

config.js_config_url = "/assets/ckeditor/config.js"

Но бесполезно, потому что это путь по умолчанию

  # JS config url
  # Used when CKEditor CDN enabled
  # By default: "/assets/ckeditor/config.js"
  # config.js_config_url = "/assets/ckeditor/config.js"

Также вам следует изменить прекомпиляцию активов следующим образом:

Rails.application.config.assets.precompile += %w(ckeditor/config.js)

...