actiontext 6.0.0.beta1 → 6.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actiontext might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/app/helpers/action_text/content_helper.rb +16 -9
- data/app/helpers/action_text/tag_helper.rb +6 -2
- data/app/models/action_text/rich_text.rb +3 -3
- data/app/views/active_storage/blobs/_blob.html.erb +1 -1
- data/db/migrate/{201805281641_create_action_text_tables.rb → 20180528164100_create_action_text_tables.rb} +2 -3
- data/lib/action_text/attachable.rb +4 -0
- data/lib/action_text/attribute.rb +3 -6
- data/lib/action_text/engine.rb +4 -0
- data/lib/action_text/gem_version.rb +2 -2
- data/lib/templates/installer.rb +14 -1
- data/package.json +1 -1
- metadata +17 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e027d8fcc05b12d8c897d7445f540e3f5df0e7ca3f992c4c409c95cd6b2475b9
|
4
|
+
data.tar.gz: 4c19e71d52d6920814b6d78f902329166ad261e96132f975d91a965b1ee5e174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9889a9d71eeea85e8edf10f08cd36549991cfc620d29f323a2ebed84ccd0aa622c94015a240a51dbc84bf5528dd83bb9b9e2c95efff111f7eae7fe6f234446d
|
7
|
+
data.tar.gz: fc5f807c6eb51a74507909d784abf574a2d7cf227ae1913cbd93b01356553e3d1dfec6b3cc9a6eb5215a6d40926b36c95add9ddc0d3e25067477ad2a271f7e9c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
## Rails 6.0.1.rc1 (October 31, 2019) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 6.0.0 (August 16, 2019) ##
|
7
|
+
|
8
|
+
* No changes.
|
9
|
+
|
10
|
+
|
11
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
12
|
+
|
13
|
+
* No changes.
|
14
|
+
|
15
|
+
|
16
|
+
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
17
|
+
|
18
|
+
* No changes.
|
19
|
+
|
20
|
+
|
21
|
+
## Rails 6.0.0.beta3 (March 11, 2019) ##
|
22
|
+
|
23
|
+
* No changes.
|
24
|
+
|
25
|
+
|
26
|
+
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
27
|
+
|
28
|
+
* No changes.
|
29
|
+
|
30
|
+
|
1
31
|
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
2
32
|
|
3
33
|
* Added to Rails.
|
@@ -1,21 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "rails-html-sanitizer"
|
4
|
+
|
3
5
|
module ActionText
|
4
6
|
module ContentHelper
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
mattr_accessor(:sanitizer) { Rails::Html::Sanitizer.safe_list_sanitizer.new }
|
8
|
+
mattr_accessor(:allowed_tags) { sanitizer.class.allowed_tags + [ ActionText::Attachment::TAG_NAME, "figure", "figcaption" ] }
|
9
|
+
mattr_accessor(:allowed_attributes) { sanitizer.class.allowed_attributes + ActionText::Attachment::ATTRIBUTES }
|
10
|
+
mattr_accessor(:scrubber)
|
8
11
|
|
9
12
|
def render_action_text_content(content)
|
10
|
-
content
|
13
|
+
sanitize_action_text_content(render_action_text_attachments(content))
|
14
|
+
end
|
15
|
+
|
16
|
+
def sanitize_action_text_content(content)
|
17
|
+
sanitizer.sanitize(content.to_html, tags: allowed_tags, attributes: allowed_attributes, scrubber: scrubber).html_safe
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_action_text_attachments(content)
|
21
|
+
content.render_attachments do |attachment|
|
11
22
|
unless attachment.in?(content.gallery_attachments)
|
12
23
|
attachment.node.tap do |node|
|
13
24
|
node.inner_html = render(attachment, in_gallery: false).chomp
|
14
25
|
end
|
15
26
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
content = content.render_attachment_galleries do |attachment_gallery|
|
27
|
+
end.render_attachment_galleries do |attachment_gallery|
|
19
28
|
render(layout: attachment_gallery, object: attachment_gallery) do
|
20
29
|
attachment_gallery.attachments.map do |attachment|
|
21
30
|
attachment.node.inner_html = render(attachment, in_gallery: true).chomp
|
@@ -23,8 +32,6 @@ module ActionText
|
|
23
32
|
end.join("").html_safe
|
24
33
|
end.chomp
|
25
34
|
end
|
26
|
-
|
27
|
-
sanitize content.to_html, tags: ALLOWED_TAGS, attributes: ALLOWED_ATTRIBUTES
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "action_view/helpers/tags/placeholderable"
|
4
|
+
|
3
5
|
module ActionText
|
4
6
|
module TagHelper
|
5
7
|
cattr_accessor(:id, instance_accessor: false) { 0 }
|
6
8
|
|
7
|
-
# Returns a
|
9
|
+
# Returns a +trix-editor+ tag that instantiates the Trix JavaScript editor as well as a hidden field
|
8
10
|
# that Trix will write to on changes, so the content will be sent on form submissions.
|
9
11
|
#
|
10
12
|
# ==== Options
|
@@ -35,6 +37,8 @@ end
|
|
35
37
|
|
36
38
|
module ActionView::Helpers
|
37
39
|
class Tags::ActionText < Tags::Base
|
40
|
+
include Tags::Placeholderable
|
41
|
+
|
38
42
|
delegate :dom_id, to: ActionView::RecordIdentifier
|
39
43
|
|
40
44
|
def render
|
@@ -50,7 +54,7 @@ module ActionView::Helpers
|
|
50
54
|
end
|
51
55
|
|
52
56
|
module FormHelper
|
53
|
-
# Returns a
|
57
|
+
# Returns a +trix-editor+ tag that instantiates the Trix JavaScript editor as well as a hidden field
|
54
58
|
# that Trix will write to on changes, so the content will be sent on form submissions.
|
55
59
|
#
|
56
60
|
# ==== Options
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActionText
|
4
|
-
# The RichText record holds the content produced by the Trix editor in a serialized
|
4
|
+
# The RichText record holds the content produced by the Trix editor in a serialized +body+ attribute.
|
5
5
|
# It also holds all the references to the embedded files, which are stored using Active Storage.
|
6
6
|
# This record is then associated with the Active Record model the application desires to have
|
7
|
-
# rich text content using the
|
7
|
+
# rich text content using the +has_rich_text+ class method.
|
8
8
|
class RichText < ActiveRecord::Base
|
9
9
|
self.table_name = "action_text_rich_texts"
|
10
10
|
|
@@ -15,7 +15,7 @@ module ActionText
|
|
15
15
|
has_many_attached :embeds
|
16
16
|
|
17
17
|
before_save do
|
18
|
-
self.embeds = body.
|
18
|
+
self.embeds = body.attachables.grep(ActiveStorage::Blob).uniq if body.present?
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_plain_text
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
|
2
2
|
<% if blob.representable? %>
|
3
|
-
<%= image_tag blob.representation(
|
3
|
+
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
|
4
4
|
<% end %>
|
5
5
|
|
6
6
|
<figcaption class="attachment__caption">
|
@@ -2,11 +2,10 @@ class CreateActionTextTables < ActiveRecord::Migration[6.0]
|
|
2
2
|
def change
|
3
3
|
create_table :action_text_rich_texts do |t|
|
4
4
|
t.string :name, null: false
|
5
|
-
t.text :body,
|
5
|
+
t.text :body, size: :long
|
6
6
|
t.references :record, null: false, polymorphic: true, index: false
|
7
7
|
|
8
|
-
t.
|
9
|
-
t.datetime :updated_at, null: false
|
8
|
+
t.timestamps
|
10
9
|
|
11
10
|
t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
|
12
11
|
end
|
@@ -67,6 +67,10 @@ module ActionText
|
|
67
67
|
super.merge(attachable_sgid: attachable_sgid)
|
68
68
|
end
|
69
69
|
|
70
|
+
def to_trix_content_attachment_partial_path
|
71
|
+
to_partial_path
|
72
|
+
end
|
73
|
+
|
70
74
|
def to_rich_text_attributes(attributes = {})
|
71
75
|
attributes.dup.tap do |attrs|
|
72
76
|
attrs[:sgid] = attachable_sgid
|
@@ -26,7 +26,7 @@ module ActionText
|
|
26
26
|
def has_rich_text(name)
|
27
27
|
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
28
28
|
def #{name}
|
29
|
-
|
29
|
+
rich_text_#{name} || build_rich_text_#{name}
|
30
30
|
end
|
31
31
|
|
32
32
|
def #{name}=(body)
|
@@ -34,14 +34,11 @@ module ActionText
|
|
34
34
|
end
|
35
35
|
CODE
|
36
36
|
|
37
|
-
has_one :"rich_text_#{name}", -> { where(name: name) },
|
37
|
+
has_one :"rich_text_#{name}", -> { where(name: name) },
|
38
|
+
class_name: "ActionText::RichText", as: :record, inverse_of: :record, autosave: true, dependent: :destroy
|
38
39
|
|
39
40
|
scope :"with_rich_text_#{name}", -> { includes("rich_text_#{name}") }
|
40
41
|
scope :"with_rich_text_#{name}_and_embeds", -> { includes("rich_text_#{name}": { embeds_attachments: :blob }) }
|
41
|
-
|
42
|
-
after_save do
|
43
|
-
public_send(name).save if public_send(name).changed?
|
44
|
-
end
|
45
42
|
end
|
46
43
|
end
|
47
44
|
end
|
data/lib/action_text/engine.rb
CHANGED
data/lib/templates/installer.rb
CHANGED
@@ -26,7 +26,20 @@ if APPLICATION_PACK_PATH.exist?
|
|
26
26
|
line = %[require("#{name}")]
|
27
27
|
unless APPLICATION_PACK_PATH.read.include? line
|
28
28
|
say "Adding #{name} to #{APPLICATION_PACK_PATH}"
|
29
|
-
append_to_file APPLICATION_PACK_PATH, "#{line}
|
29
|
+
append_to_file APPLICATION_PACK_PATH, "\n#{line}"
|
30
30
|
end
|
31
31
|
end
|
32
|
+
else
|
33
|
+
warn <<~WARNING
|
34
|
+
WARNING: Action Text can't locate your JavaScript bundle to add its package dependencies.
|
35
|
+
|
36
|
+
Add these lines to any bundles:
|
37
|
+
|
38
|
+
require("trix")
|
39
|
+
require("@rails/actiontext")
|
40
|
+
|
41
|
+
Alternatively, install and setup the webpacker gem then rerun `bin/rails action_text:install`
|
42
|
+
to have these dependencies added automatically.
|
43
|
+
|
44
|
+
WARNING
|
32
45
|
end
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actiontext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.1.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javan Makhmali
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -18,56 +18,56 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 6.0.
|
21
|
+
version: 6.0.1.rc1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 6.0.
|
28
|
+
version: 6.0.1.rc1
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: activerecord
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 6.0.
|
35
|
+
version: 6.0.1.rc1
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 6.0.
|
42
|
+
version: 6.0.1.rc1
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: activestorage
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - '='
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 6.0.
|
49
|
+
version: 6.0.1.rc1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - '='
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 6.0.
|
56
|
+
version: 6.0.1.rc1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: actionpack
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - '='
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 6.0.
|
63
|
+
version: 6.0.1.rc1
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - '='
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 6.0.
|
70
|
+
version: 6.0.1.rc1
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: nokogiri
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
- app/views/action_text/attachment_galleries/_attachment_gallery.html.erb
|
105
105
|
- app/views/action_text/content/_layout.html.erb
|
106
106
|
- app/views/active_storage/blobs/_blob.html.erb
|
107
|
-
- db/migrate/
|
107
|
+
- db/migrate/20180528164100_create_action_text_tables.rb
|
108
108
|
- lib/action_text.rb
|
109
109
|
- lib/action_text/attachable.rb
|
110
110
|
- lib/action_text/attachables/content_attachment.rb
|
@@ -134,8 +134,11 @@ homepage: https://rubyonrails.org
|
|
134
134
|
licenses:
|
135
135
|
- MIT
|
136
136
|
metadata:
|
137
|
-
|
138
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.
|
137
|
+
bug_tracker_uri: https://github.com/rails/rails/issues
|
138
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.0.1.rc1/actiontext/CHANGELOG.md
|
139
|
+
documentation_uri: https://api.rubyonrails.org/v6.0.1.rc1/
|
140
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
|
141
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.0.1.rc1/actiontext
|
139
142
|
post_install_message:
|
140
143
|
rdoc_options: []
|
141
144
|
require_paths:
|
@@ -151,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
154
|
- !ruby/object:Gem::Version
|
152
155
|
version: 1.3.1
|
153
156
|
requirements: []
|
154
|
-
rubygems_version: 3.0.
|
157
|
+
rubygems_version: 3.0.3
|
155
158
|
signing_key:
|
156
159
|
specification_version: 4
|
157
160
|
summary: Rich text framework.
|