-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attachment support is not included here, since it requires webpack-built javascripts. Closes #3144
- Loading branch information
Showing
11 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
:ruby | ||
js_data = { | ||
csspath: field.css_location, | ||
jspath: field.js_location | ||
} | ||
|
||
= form.rich_text_area field.method_name, field.html_attributes.reverse_merge(data: { options: js_data.to_json }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'rails_admin/config/fields' | ||
require 'rails_admin/config/fields/types' | ||
|
||
RailsAdmin::Config::Fields.register_factory do |parent, properties, fields| | ||
if defined?(::ActionText) && properties.try(:association?) && (match = /\Arich_text_(.+)\Z/.match properties.name) && properties.klass.to_s == 'ActionText::RichText' | ||
field = RailsAdmin::Config::Fields::Types.load(:action_text).new(parent, match[1], properties) | ||
fields << field | ||
true | ||
else | ||
false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'rails_admin/config/fields/base' | ||
require 'rails_admin/config/fields/types/text' | ||
|
||
module RailsAdmin | ||
module Config | ||
module Fields | ||
module Types | ||
class ActionText < RailsAdmin::Config::Fields::Types::Text | ||
# Register field type for the type loader | ||
RailsAdmin::Config::Fields::Types.register(self) | ||
|
||
register_instance_option :version do | ||
'1.1.1' | ||
end | ||
|
||
register_instance_option :css_location do | ||
"https://cdnjs.cloudflare.com/ajax/libs/trix/#{version}/trix.css" | ||
end | ||
|
||
register_instance_option :js_location do | ||
"https://cdnjs.cloudflare.com/ajax/libs/trix/#{version}/trix.js" | ||
end | ||
|
||
register_instance_option :partial do | ||
:form_action_text | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
spec/dummy_app/db/migrate/20190531065324_create_action_text_tables.action_text.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateActionTextTables < ActiveRecord::Migration[5.0] | ||
def change | ||
create_table :action_text_rich_texts do |t| | ||
t.string :name, null: false | ||
t.text :body, size: :long | ||
t.references :record, null: false, polymorphic: true, index: false | ||
|
||
t.timestamps | ||
|
||
t.index [:record_type, :record_id, :name], name: "index_action_text_rich_texts_uniqueness", unique: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::ActionText do | ||
it_behaves_like 'a generic field type', :action_text_field | ||
end if defined?(ActionText) |