Merge pull request #2876 from javierm/ckeditor4_update

Ckeditor4 update
This commit is contained in:
Raimond Garcia
2018-09-17 23:02:50 +02:00
committed by GitHub
16 changed files with 126 additions and 27 deletions

View File

@@ -5,33 +5,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
/* Filebrowser routes */
// The location of an external file browser, that should be launched when "Browse Server" button is pressed.
config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
// The location of a script that handles file uploads in the Flash dialog.
config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
// The location of a script that handles file uploads in the Image dialog.
config.filebrowserImageUploadUrl = "/ckeditor/pictures";
// The location of a script that handles file uploads.
config.filebrowserUploadUrl = "/ckeditor/attachment_files";
config.allowedContent = true;
config.format_tags = "p;h2;h3";
// Rails CSRF token
config.filebrowserParams = function(){
@@ -109,7 +92,14 @@ CKEDITOR.editorConfig = function( config )
config.toolbar_mini = [
{ name: 'paragraph', groups: [ 'list' ], items: [ 'NumberedList', 'BulletedList' ] },
{ name: 'links', items: [ 'Link', 'Unlink' ] },
{ name: 'styles', items: [ 'Format' ] },
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike' ] }
];
config.toolbar_admin = config.toolbar_mini.concat([
{ name: 'insert', items: [ 'Image' ] }
]);
config.toolbar = "mini";
};

View File

@@ -79,6 +79,9 @@ module Abilities
can :manage, SiteCustomization::Image
can :manage, SiteCustomization::ContentBlock
can :access, :ckeditor
can :manage, Ckeditor::Picture
can [:manage], ::Legislation::Process
can [:manage], ::Legislation::DraftVersion
can [:manage], ::Legislation::Question

View File

@@ -0,0 +1,4 @@
class Ckeditor::Asset < ActiveRecord::Base
include Ckeditor::Orm::ActiveRecord::AssetBase
include Ckeditor::Backend::Paperclip
end

View File

@@ -0,0 +1,14 @@
class Ckeditor::Picture < Ckeditor::Asset
has_attached_file :data,
url: '/ckeditor_assets/pictures/:id/:style_:basename.:extension',
path: ':rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension',
styles: { content: '800>', thumb: '118x100#' }
validates_attachment_presence :data
validates_attachment_size :data, less_than: 2.megabytes
validates_attachment_content_type :data, content_type: /\Aimage/
def url_content
url(:content)
end
end

View File

@@ -50,7 +50,8 @@
<div class="ckeditor margin-top">
<%= f.label :content %>
<%= f.cktext_area :content, label: false, cols: 80, rows: 10, ckeditor: { language: I18n.locale } %>
<%= f.cktext_area :content, label: false, cols: 80, rows: 10,
ckeditor: { language: I18n.locale, toolbar: "admin" } %>
</div>
<div class="small-12 medium-6 large-3">

View File

@@ -8,7 +8,7 @@
<h2><%= @custom_page.subtitle%></h2>
<% end %>
<%= text_with_links @custom_page.content %>
<%= safe_html_with_links AdminWYSIWYGSanitizer.new.sanitize(@custom_page.content) %>
</div>
<% if @custom_page.print_content_flag %>