actiontext 6.0.4 → 6.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -75
- data/MIT-LICENSE +1 -1
- data/app/helpers/action_text/content_helper.rb +2 -1
- data/app/helpers/action_text/tag_helper.rb +9 -1
- data/app/models/action_text/record.rb +9 -0
- data/app/models/action_text/rich_text.rb +1 -1
- data/lib/action_text.rb +2 -0
- data/lib/action_text/attachables/remote_image.rb +1 -1
- data/lib/action_text/attachment.rb +2 -0
- data/lib/action_text/attachment_gallery.rb +1 -1
- data/lib/action_text/attachments/trix_conversion.rb +3 -1
- data/lib/action_text/attribute.rb +5 -0
- data/lib/action_text/content.rb +2 -6
- data/lib/action_text/engine.rb +19 -9
- data/lib/action_text/fixture_set.rb +12 -0
- data/lib/action_text/gem_version.rb +3 -3
- data/lib/action_text/plain_text_conversion.rb +5 -3
- data/lib/action_text/rendering.rb +29 -0
- data/lib/action_text/system_test_helper.rb +55 -0
- data/lib/generators/action_text/install/install_generator.rb +67 -0
- data/lib/{templates → generators/action_text/install/templates}/actiontext.scss +0 -0
- data/lib/rails/generators/test_unit/install_generator.rb +13 -0
- data/lib/{templates → rails/generators/test_unit/templates}/fixtures.yml +0 -0
- data/lib/tasks/actiontext.rake +3 -17
- data/package.json +3 -3
- metadata +24 -19
- data/lib/templates/installer.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92eed23fbd01cae823cfb424bba5361f0905a8378692753474c5afa818f392f3
|
4
|
+
data.tar.gz: 42319d2773752cbaae675f18c0ce924c933b1c655ca528bf832a73e45a472717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89ad4ea25a2889470a0b2951c0bfcac4f46704cba8f2e3fa71e11f243165adea7c73e5db46479644f5296f03ee491980c25e54aa6e7ca6c2d6afeeda3a098551
|
7
|
+
data.tar.gz: b3453106497fb133b26f9995c225718c30932777b04742d9c7b6aad339adb918d0ca73c8a76c88b227de08f258213ed36654a4576e0fd282914c1405fa54662e
|
data/CHANGELOG.md
CHANGED
@@ -1,95 +1,64 @@
|
|
1
|
-
## Rails 6.0.
|
1
|
+
## Rails 6.1.0.rc1 (November 02, 2020) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Declare `ActionText::FixtureSet.attachment` to generate an
|
4
|
+
`<action-text-attachment sgid="..."></action-text-attachment>` element with
|
5
|
+
a valid `sgid` attribute.
|
4
6
|
|
7
|
+
```ruby
|
8
|
+
hello_world_review_content:
|
9
|
+
record: hello_world (Review)
|
10
|
+
name: content
|
11
|
+
body: <p><%= ActionText::FixtureSet.attachment("messages", :hello_world) %> is great!</p>
|
12
|
+
```
|
5
13
|
|
6
|
-
|
14
|
+
*Sean Doyle*
|
7
15
|
|
8
|
-
*
|
16
|
+
* Locate `fill_in_rich_text_area` by `<label>` text
|
9
17
|
|
18
|
+
In addition to searching for `<trix-editor>` elements with the appropriate
|
19
|
+
`aria-label` attribute, also support locating elements that match the
|
20
|
+
corresponding `<label>` element's text.
|
10
21
|
|
11
|
-
|
22
|
+
*Sean Doyle*
|
12
23
|
|
13
|
-
*
|
24
|
+
* Be able to add a default value to `rich_text_area`.
|
14
25
|
|
26
|
+
```ruby
|
27
|
+
form.rich_text_area :content, value: "<h1>Hello world</h1>"
|
28
|
+
#=> <input type="hidden" name="message[content]" id="message_content_trix_input_message_1" value="<h1>Hello world</h1>">
|
29
|
+
```
|
15
30
|
|
16
|
-
|
31
|
+
*Paulo Ancheta*
|
17
32
|
|
18
|
-
*
|
33
|
+
* Add method to confirm rich text content existence by adding `?` after rich
|
34
|
+
text attribute.
|
19
35
|
|
36
|
+
```ruby
|
37
|
+
message = Message.create!(body: "<h1>Funny times!</h1>")
|
38
|
+
message.body? #=> true
|
39
|
+
```
|
20
40
|
|
21
|
-
|
41
|
+
*Kyohei Toyoda*
|
22
42
|
|
23
|
-
*
|
43
|
+
* The `fill_in_rich_text_area` system test helper locates a Trix editor
|
44
|
+
and fills it in with the given HTML.
|
24
45
|
|
46
|
+
```ruby
|
47
|
+
# <trix-editor id="message_content" ...></trix-editor>
|
48
|
+
fill_in_rich_text_area "message_content", with: "Hello <em>world!</em>"
|
25
49
|
|
26
|
-
|
50
|
+
# <trix-editor placeholder="Your message here" ...></trix-editor>
|
51
|
+
fill_in_rich_text_area "Your message here", with: "Hello <em>world!</em>"
|
27
52
|
|
28
|
-
|
53
|
+
# <trix-editor aria-label="Message content" ...></trix-editor>
|
54
|
+
fill_in_rich_text_area "Message content", with: "Hello <em>world!</em>"
|
29
55
|
|
56
|
+
# <input id="trix_input_1" name="message[content]" type="hidden">
|
57
|
+
# <trix-editor input="trix_input_1"></trix-editor>
|
58
|
+
fill_in_rich_text_area "message[content]", with: "Hello <em>world!</em>"
|
59
|
+
```
|
30
60
|
|
31
|
-
|
61
|
+
*George Claghorn*
|
32
62
|
|
33
|
-
* No changes.
|
34
63
|
|
35
|
-
|
36
|
-
## Rails 6.0.3.1 (May 18, 2020) ##
|
37
|
-
|
38
|
-
* No changes.
|
39
|
-
|
40
|
-
|
41
|
-
## Rails 6.0.3 (May 06, 2020) ##
|
42
|
-
|
43
|
-
* No changes.
|
44
|
-
|
45
|
-
|
46
|
-
## Rails 6.0.2.2 (March 19, 2020) ##
|
47
|
-
|
48
|
-
* No changes.
|
49
|
-
|
50
|
-
|
51
|
-
## Rails 6.0.2.1 (December 18, 2019) ##
|
52
|
-
|
53
|
-
* No changes.
|
54
|
-
|
55
|
-
|
56
|
-
## Rails 6.0.2 (December 13, 2019) ##
|
57
|
-
|
58
|
-
* No changes.
|
59
|
-
|
60
|
-
|
61
|
-
## Rails 6.0.1 (November 5, 2019) ##
|
62
|
-
|
63
|
-
* No changes.
|
64
|
-
|
65
|
-
|
66
|
-
## Rails 6.0.0 (August 16, 2019) ##
|
67
|
-
|
68
|
-
* No changes.
|
69
|
-
|
70
|
-
|
71
|
-
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
72
|
-
|
73
|
-
* No changes.
|
74
|
-
|
75
|
-
|
76
|
-
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
77
|
-
|
78
|
-
* No changes.
|
79
|
-
|
80
|
-
|
81
|
-
## Rails 6.0.0.beta3 (March 11, 2019) ##
|
82
|
-
|
83
|
-
* No changes.
|
84
|
-
|
85
|
-
|
86
|
-
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
87
|
-
|
88
|
-
* No changes.
|
89
|
-
|
90
|
-
|
91
|
-
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
92
|
-
|
93
|
-
* Added to Rails.
|
94
|
-
|
95
|
-
*DHH*
|
64
|
+
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actiontext/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
@@ -10,6 +10,7 @@ module ActionText
|
|
10
10
|
mattr_accessor(:scrubber)
|
11
11
|
|
12
12
|
def render_action_text_content(content)
|
13
|
+
self.prefix_partial_path_with_controller_namespace = false
|
13
14
|
sanitize_action_text_content(render_action_text_attachments(content))
|
14
15
|
end
|
15
16
|
|
@@ -29,7 +30,7 @@ module ActionText
|
|
29
30
|
attachment_gallery.attachments.map do |attachment|
|
30
31
|
attachment.node.inner_html = render(attachment, in_gallery: true).chomp
|
31
32
|
attachment.to_html
|
32
|
-
end.join
|
33
|
+
end.join.html_safe
|
33
34
|
end.chomp
|
34
35
|
end
|
35
36
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support/core_ext/object/try"
|
3
4
|
require "action_view/helpers/tags/placeholderable"
|
4
5
|
|
5
6
|
module ActionText
|
@@ -45,7 +46,7 @@ module ActionView::Helpers
|
|
45
46
|
options = @options.stringify_keys
|
46
47
|
add_default_name_and_id(options)
|
47
48
|
options["input"] ||= dom_id(object, [options["id"], :trix_input].compact.join("_")) if object
|
48
|
-
@template_object.rich_text_area_tag(options.delete("name"), editable_value, options)
|
49
|
+
@template_object.rich_text_area_tag(options.delete("name"), options.fetch("value") { editable_value }, options.except("value"))
|
49
50
|
end
|
50
51
|
|
51
52
|
def editable_value
|
@@ -59,6 +60,7 @@ module ActionView::Helpers
|
|
59
60
|
#
|
60
61
|
# ==== Options
|
61
62
|
# * <tt>:class</tt> - Defaults to "trix-content" which ensures default styling is applied.
|
63
|
+
# * <tt>:value</tt> - Adds a default value to the HTML input tag.
|
62
64
|
#
|
63
65
|
# ==== Example
|
64
66
|
# form_with(model: @message) do |form|
|
@@ -66,6 +68,12 @@ module ActionView::Helpers
|
|
66
68
|
# end
|
67
69
|
# # <input type="hidden" name="message[content]" id="message_content_trix_input_message_1">
|
68
70
|
# # <trix-editor id="content" input="message_content_trix_input_message_1" class="trix-content" ...></trix-editor>
|
71
|
+
#
|
72
|
+
# form_with(model: @message) do |form|
|
73
|
+
# form.rich_text_area :content, value: "<h1>Default message</h1>"
|
74
|
+
# end
|
75
|
+
# # <input type="hidden" name="message[content]" id="message_content_trix_input_message_1" value="<h1>Default message</h1>">
|
76
|
+
# # <trix-editor id="content" input="message_content_trix_input_message_1" class="trix-content" ...></trix-editor>
|
69
77
|
def rich_text_area(object_name, method, options = {})
|
70
78
|
Tags::ActionText.new(object_name, method, self, options).render
|
71
79
|
end
|
@@ -5,7 +5,7 @@ module ActionText
|
|
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
7
|
# rich text content using the +has_rich_text+ class method.
|
8
|
-
class RichText <
|
8
|
+
class RichText < Record
|
9
9
|
self.table_name = "action_text_rich_texts"
|
10
10
|
|
11
11
|
serialize :body, ActionText::Content
|
data/lib/action_text.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support/core_ext/object/try"
|
4
|
+
|
3
5
|
module ActionText
|
4
6
|
module Attachments
|
5
7
|
module TrixConversion
|
@@ -26,7 +28,7 @@ module ActionText
|
|
26
28
|
private
|
27
29
|
def trix_attachment_content
|
28
30
|
if partial_path = attachable.try(:to_trix_content_attachment_partial_path)
|
29
|
-
ActionText::Content.
|
31
|
+
ActionText::Content.render(partial: partial_path, object: self, as: model_name.element)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -13,6 +13,7 @@ module ActionText
|
|
13
13
|
# end
|
14
14
|
#
|
15
15
|
# message = Message.create!(content: "<h1>Funny times!</h1>")
|
16
|
+
# message.content? #=> true
|
16
17
|
# message.content.to_s # => "<h1>Funny times!</h1>"
|
17
18
|
# message.content.to_plain_text # => "Funny times!"
|
18
19
|
#
|
@@ -29,6 +30,10 @@ module ActionText
|
|
29
30
|
rich_text_#{name} || build_rich_text_#{name}
|
30
31
|
end
|
31
32
|
|
33
|
+
def #{name}?
|
34
|
+
rich_text_#{name}.present?
|
35
|
+
end
|
36
|
+
|
32
37
|
def #{name}=(body)
|
33
38
|
self.#{name}.body = body
|
34
39
|
end
|
data/lib/action_text/content.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_support/core_ext/module/attribute_accessors_per_thread"
|
4
|
-
|
5
3
|
module ActionText
|
6
4
|
class Content
|
7
|
-
include Serialization
|
8
|
-
|
9
|
-
thread_cattr_accessor :renderer
|
5
|
+
include Rendering, Serialization
|
10
6
|
|
11
7
|
attr_reader :fragment
|
12
8
|
|
@@ -88,7 +84,7 @@ module ActionText
|
|
88
84
|
end
|
89
85
|
|
90
86
|
def to_rendered_html_with_layout
|
91
|
-
|
87
|
+
render partial: "action_text/content/layout", locals: { content: self }
|
92
88
|
end
|
93
89
|
|
94
90
|
def to_s
|
data/lib/action_text/engine.rb
CHANGED
@@ -37,21 +37,31 @@ module ActionText
|
|
37
37
|
end
|
38
38
|
|
39
39
|
initializer "action_text.helper" do
|
40
|
-
|
41
|
-
|
40
|
+
%i[action_controller_base action_mailer].each do |abstract_controller|
|
41
|
+
ActiveSupport.on_load(abstract_controller) do
|
42
|
+
helper ActionText::Engine.helpers
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
initializer "action_text.renderer" do
|
46
|
-
app.executor.to_run { ActionText::Content.renderer = ApplicationController.renderer }
|
47
|
-
app.executor.to_complete { ActionText::Content.renderer = ApplicationController.renderer }
|
48
|
-
|
47
|
+
initializer "action_text.renderer" do
|
49
48
|
ActiveSupport.on_load(:action_text_content) do
|
50
|
-
self.renderer =
|
49
|
+
self.renderer = Class.new(ActionController::Base).renderer
|
50
|
+
end
|
51
|
+
|
52
|
+
%i[action_controller_base action_mailer].each do |abstract_controller|
|
53
|
+
ActiveSupport.on_load(abstract_controller) do
|
54
|
+
around_action do |controller, action|
|
55
|
+
ActionText::Content.with_renderer(controller, &action)
|
56
|
+
end
|
57
|
+
end
|
51
58
|
end
|
59
|
+
end
|
52
60
|
|
53
|
-
|
54
|
-
|
61
|
+
initializer "action_text.system_test_helper" do
|
62
|
+
ActiveSupport.on_load(:action_dispatch_system_test_case) do
|
63
|
+
require "action_text/system_test_helper"
|
64
|
+
include ActionText::SystemTestHelper
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionText
|
4
|
+
class FixtureSet
|
5
|
+
def self.attachment(fixture_set_name, label, column_type: :integer)
|
6
|
+
signed_global_id = ActiveRecord::FixtureSet.signed_global_id fixture_set_name, label,
|
7
|
+
column_type: column_type, for: ActionText::Attachable::LOCATOR_NAME
|
8
|
+
|
9
|
+
%(<action-text-attachment sgid="#{signed_global_id}"></action-text-attachment>)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -18,9 +18,11 @@ module ActionText
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def plain_text_for_node_children(node)
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
texts = []
|
22
|
+
node.children.each_with_index do |child, index|
|
23
|
+
texts << plain_text_for_node(child, index)
|
24
|
+
end
|
25
|
+
texts.join
|
24
26
|
end
|
25
27
|
|
26
28
|
def plain_text_method_for_node(node)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
require "active_support/core_ext/module/attribute_accessors_per_thread"
|
5
|
+
|
6
|
+
module ActionText
|
7
|
+
module Rendering #:nodoc:
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
thread_cattr_accessor :renderer, instance_accessor: false
|
12
|
+
delegate :render, to: :class
|
13
|
+
end
|
14
|
+
|
15
|
+
class_methods do
|
16
|
+
def with_renderer(renderer)
|
17
|
+
previous_renderer = self.renderer
|
18
|
+
self.renderer = renderer
|
19
|
+
yield
|
20
|
+
ensure
|
21
|
+
self.renderer = previous_renderer
|
22
|
+
end
|
23
|
+
|
24
|
+
def render(*args, &block)
|
25
|
+
renderer.render_to_string(*args, &block)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionText
|
4
|
+
module SystemTestHelper
|
5
|
+
# Locates a Trix editor and fills it in with the given HTML.
|
6
|
+
#
|
7
|
+
# The editor can be found by:
|
8
|
+
# * its +id+
|
9
|
+
# * its +placeholder+
|
10
|
+
# * the text from its +label+ element
|
11
|
+
# * its +aria-label+
|
12
|
+
# * the +name+ of its input
|
13
|
+
#
|
14
|
+
# Examples:
|
15
|
+
#
|
16
|
+
# # <trix-editor id="message_content" ...></trix-editor>
|
17
|
+
# fill_in_rich_text_area "message_content", with: "Hello <em>world!</em>"
|
18
|
+
#
|
19
|
+
# # <trix-editor placeholder="Your message here" ...></trix-editor>
|
20
|
+
# fill_in_rich_text_area "Your message here", with: "Hello <em>world!</em>"
|
21
|
+
#
|
22
|
+
# # <label for="message_content">Message content</label>
|
23
|
+
# # <trix-editor id="message_content" ...></trix-editor>
|
24
|
+
# fill_in_rich_text_area "Message content", with: "Hello <em>world!</em>"
|
25
|
+
#
|
26
|
+
# # <trix-editor aria-label="Message content" ...></trix-editor>
|
27
|
+
# fill_in_rich_text_area "Message content", with: "Hello <em>world!</em>"
|
28
|
+
#
|
29
|
+
# # <input id="trix_input_1" name="message[content]" type="hidden">
|
30
|
+
# # <trix-editor input="trix_input_1"></trix-editor>
|
31
|
+
# fill_in_rich_text_area "message[content]", with: "Hello <em>world!</em>"
|
32
|
+
def fill_in_rich_text_area(locator = nil, with:)
|
33
|
+
find(:rich_text_area, locator).execute_script("this.editor.loadHTML(arguments[0])", with.to_s)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Capybara.add_selector :rich_text_area do
|
39
|
+
label "rich-text area"
|
40
|
+
xpath do |locator|
|
41
|
+
if locator.nil?
|
42
|
+
XPath.descendant(:"trix-editor")
|
43
|
+
else
|
44
|
+
input_located_by_name = XPath.anywhere(:input).where(XPath.attr(:name) == locator).attr(:id)
|
45
|
+
input_located_by_label = XPath.anywhere(:label).where(XPath.string.n.is(locator)).attr(:for)
|
46
|
+
|
47
|
+
XPath.descendant(:"trix-editor").where \
|
48
|
+
XPath.attr(:id).equals(locator) |
|
49
|
+
XPath.attr(:placeholder).equals(locator) |
|
50
|
+
XPath.attr(:"aria-label").equals(locator) |
|
51
|
+
XPath.attr(:input).equals(input_located_by_name) |
|
52
|
+
XPath.attr(:id).equals(input_located_by_label)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module ActionText
|
7
|
+
module Generators
|
8
|
+
class InstallGenerator < ::Rails::Generators::Base
|
9
|
+
source_root File.expand_path("templates", __dir__)
|
10
|
+
|
11
|
+
def install_javascript_dependencies
|
12
|
+
rails_command "app:binstub:yarn", inline: true
|
13
|
+
|
14
|
+
say "Installing JavaScript dependencies", :green
|
15
|
+
run "bin/yarn add #{js_dependencies.map { |name, version| "#{name}@#{version}" }.join(" ")}",
|
16
|
+
abort_on_failure: true, capture: true
|
17
|
+
end
|
18
|
+
|
19
|
+
def append_dependencies_to_package_file
|
20
|
+
if (app_javascript_pack_path = Pathname.new("app/javascript/packs/application.js")).exist?
|
21
|
+
js_dependencies.each_key do |dependency|
|
22
|
+
line = %[require("#{dependency}")]
|
23
|
+
|
24
|
+
unless app_javascript_pack_path.read.include? line
|
25
|
+
say "Adding #{dependency} to #{app_javascript_pack_path}", :green
|
26
|
+
append_to_file app_javascript_pack_path, "\n#{line}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
else
|
30
|
+
say <<~WARNING, :red
|
31
|
+
WARNING: Action Text can't locate your JavaScript bundle to add its package dependencies.
|
32
|
+
|
33
|
+
Add these lines to any bundles:
|
34
|
+
|
35
|
+
require("trix")
|
36
|
+
require("@rails/actiontext")
|
37
|
+
|
38
|
+
Alternatively, install and setup the webpacker gem then rerun `bin/rails action_text:install`
|
39
|
+
to have these dependencies added automatically.
|
40
|
+
WARNING
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_actiontext_files
|
45
|
+
template "actiontext.scss", "app/assets/stylesheets/actiontext.scss"
|
46
|
+
|
47
|
+
copy_file "#{GEM_ROOT}/app/views/active_storage/blobs/_blob.html.erb",
|
48
|
+
"app/views/active_storage/blobs/_blob.html.erb"
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_migrations
|
52
|
+
rails_command "railties:install:migrations FROM=active_storage,action_text", inline: true
|
53
|
+
end
|
54
|
+
|
55
|
+
hook_for :test_framework
|
56
|
+
|
57
|
+
private
|
58
|
+
GEM_ROOT = "#{__dir__}/../../../.."
|
59
|
+
|
60
|
+
def js_dependencies
|
61
|
+
js_package = JSON.load(Pathname.new("#{GEM_ROOT}/package.json"))
|
62
|
+
js_package["peerDependencies"].merge \
|
63
|
+
js_package["name"] => "^#{js_package["version"]}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TestUnit
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def create_test_files
|
9
|
+
template "fixtures.yml", "test/fixtures/action_text/rich_texts.yml"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
File without changes
|
data/lib/tasks/actiontext.rake
CHANGED
@@ -1,20 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
desc "Copy over the migration, stylesheet, and JavaScript files"
|
8
|
-
task install: %w( environment run_installer copy_migrations )
|
9
|
-
|
10
|
-
task :run_installer do
|
11
|
-
installer_template = File.expand_path("../templates/installer.rb", __dir__)
|
12
|
-
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{installer_template}"
|
13
|
-
end
|
14
|
-
|
15
|
-
task :copy_migrations do
|
16
|
-
Rake::Task["active_storage:install:migrations"].invoke
|
17
|
-
Rake::Task["railties:install:migrations"].reenable # Otherwise you can't run 2 migration copy tasks in one invocation
|
18
|
-
Rake::Task["action_text:install:migrations"].invoke
|
19
|
-
end
|
3
|
+
desc "Copy over the migration, stylesheet, and JavaScript files"
|
4
|
+
task "action_text:install" do
|
5
|
+
Rails::Command.invoke :generate, ["action_text:install"]
|
20
6
|
end
|
data/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rails/actiontext",
|
3
|
-
"version": "6.0
|
3
|
+
"version": "6.1.0-rc1",
|
4
4
|
"description": "Edit and display rich text in Rails applications",
|
5
5
|
"main": "app/javascript/actiontext/index.js",
|
6
6
|
"files": [
|
7
7
|
"app/javascript/actiontext/*.js"
|
8
8
|
],
|
9
|
-
"homepage": "
|
9
|
+
"homepage": "https://rubyonrails.org/",
|
10
10
|
"repository": {
|
11
11
|
"type": "git",
|
12
12
|
"url": "git+https://github.com/rails/rails.git"
|
@@ -21,7 +21,7 @@
|
|
21
21
|
],
|
22
22
|
"license": "MIT",
|
23
23
|
"dependencies": {
|
24
|
-
"@rails/activestorage": "^6.0.0"
|
24
|
+
"@rails/activestorage": "^6.0.0-alpha"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
27
27
|
"trix": "^1.2.0"
|
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.1.0.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:
|
13
|
+
date: 2020-11-02 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.1.0.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.1.0.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.1.0.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.1.0.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.1.0.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.1.0.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.1.0.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.1.0.rc1
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: nokogiri
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- app/helpers/action_text/tag_helper.rb
|
99
99
|
- app/javascript/actiontext/attachment_upload.js
|
100
100
|
- app/javascript/actiontext/index.js
|
101
|
+
- app/models/action_text/record.rb
|
101
102
|
- app/models/action_text/rich_text.rb
|
102
103
|
- app/views/action_text/attachables/_missing_attachable.html.erb
|
103
104
|
- app/views/action_text/attachables/_remote_image.html.erb
|
@@ -118,27 +119,31 @@ files:
|
|
118
119
|
- lib/action_text/attribute.rb
|
119
120
|
- lib/action_text/content.rb
|
120
121
|
- lib/action_text/engine.rb
|
122
|
+
- lib/action_text/fixture_set.rb
|
121
123
|
- lib/action_text/fragment.rb
|
122
124
|
- lib/action_text/gem_version.rb
|
123
125
|
- lib/action_text/html_conversion.rb
|
124
126
|
- lib/action_text/plain_text_conversion.rb
|
127
|
+
- lib/action_text/rendering.rb
|
125
128
|
- lib/action_text/serialization.rb
|
129
|
+
- lib/action_text/system_test_helper.rb
|
126
130
|
- lib/action_text/trix_attachment.rb
|
127
131
|
- lib/action_text/version.rb
|
132
|
+
- lib/generators/action_text/install/install_generator.rb
|
133
|
+
- lib/generators/action_text/install/templates/actiontext.scss
|
134
|
+
- lib/rails/generators/test_unit/install_generator.rb
|
135
|
+
- lib/rails/generators/test_unit/templates/fixtures.yml
|
128
136
|
- lib/tasks/actiontext.rake
|
129
|
-
- lib/templates/actiontext.scss
|
130
|
-
- lib/templates/fixtures.yml
|
131
|
-
- lib/templates/installer.rb
|
132
137
|
- package.json
|
133
138
|
homepage: https://rubyonrails.org
|
134
139
|
licenses:
|
135
140
|
- MIT
|
136
141
|
metadata:
|
137
142
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
138
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.
|
139
|
-
documentation_uri: https://api.rubyonrails.org/v6.0.
|
143
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.1.0.rc1/actiontext/CHANGELOG.md
|
144
|
+
documentation_uri: https://api.rubyonrails.org/v6.1.0.rc1/
|
140
145
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
141
|
-
source_code_uri: https://github.com/rails/rails/tree/v6.0.
|
146
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.1.0.rc1/actiontext
|
142
147
|
post_install_message:
|
143
148
|
rdoc_options: []
|
144
149
|
require_paths:
|
@@ -150,11 +155,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
155
|
version: 2.5.0
|
151
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
157
|
requirements:
|
153
|
-
- - "
|
158
|
+
- - ">"
|
154
159
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
160
|
+
version: 1.3.1
|
156
161
|
requirements: []
|
157
|
-
rubygems_version: 3.1.
|
162
|
+
rubygems_version: 3.1.4
|
158
163
|
signing_key:
|
159
164
|
specification_version: 4
|
160
165
|
summary: Rich text framework.
|
data/lib/templates/installer.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
require "json"
|
3
|
-
|
4
|
-
APPLICATION_PACK_PATH = Pathname.new("app/javascript/packs/application.js")
|
5
|
-
JS_PACKAGE_PATH = Pathname.new("#{__dir__}/../../package.json")
|
6
|
-
|
7
|
-
JS_PACKAGE = JSON.load(JS_PACKAGE_PATH)
|
8
|
-
JS_DEPENDENCIES = JS_PACKAGE["peerDependencies"].dup.merge \
|
9
|
-
JS_PACKAGE["name"] => "^#{JS_PACKAGE["version"]}"
|
10
|
-
|
11
|
-
say "Copying actiontext.scss to app/assets/stylesheets"
|
12
|
-
copy_file "#{__dir__}/actiontext.scss", "app/assets/stylesheets/actiontext.scss"
|
13
|
-
|
14
|
-
say "Copying fixtures to test/fixtures/action_text/rich_texts.yml"
|
15
|
-
copy_file "#{__dir__}/fixtures.yml", "test/fixtures/action_text/rich_texts.yml"
|
16
|
-
|
17
|
-
say "Copying blob rendering partial to app/views/active_storage/blobs/_blob.html.erb"
|
18
|
-
copy_file "#{__dir__}/../../app/views/active_storage/blobs/_blob.html.erb",
|
19
|
-
"app/views/active_storage/blobs/_blob.html.erb"
|
20
|
-
|
21
|
-
say "Installing JavaScript dependencies"
|
22
|
-
run "yarn add #{JS_DEPENDENCIES.map { |name, version| "#{name}@#{version}" }.join(" ")}"
|
23
|
-
|
24
|
-
if APPLICATION_PACK_PATH.exist?
|
25
|
-
JS_DEPENDENCIES.keys.each do |name|
|
26
|
-
line = %[require("#{name}")]
|
27
|
-
unless APPLICATION_PACK_PATH.read.include? line
|
28
|
-
say "Adding #{name} to #{APPLICATION_PACK_PATH}"
|
29
|
-
append_to_file APPLICATION_PACK_PATH, "\n#{line}"
|
30
|
-
end
|
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
|
45
|
-
end
|