actiontext 6.0.3.1 → 6.1.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of actiontext might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -36
- 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 +2 -2
- 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: '09f9c1559c51bd7a3b87f84438fddbae872987e8d6221a5a65d8430268aa4d17'
         | 
| 4 | 
            +
              data.tar.gz: c1cf34d3cf17502d181d9c01dbfd32ca9b222ff4356c89e394f3c12ce115985f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 845cbf0cd6a49d76c9e4454cfa11953ee028474d07869fe5a36ea5f772a3cd3873d7eb1b442393f77ebef2d229e13db9b9dbcaad6f346dfde249c356e2fc4934
         | 
| 7 | 
            +
              data.tar.gz: b27dc1f63a7b533b44bb57351480e7d9b0864ab7690bfb2d3a6ed2818f2ed8b448751276f79c64878a5894d75bf34b72712f5653d40c92048ad1e290c4069101
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,60 +1,69 @@ | |
| 1 | 
            -
            ## Rails 6.0. | 
| 1 | 
            +
            ## Rails 6.1.0.rc2 (December 01, 2020) ##
         | 
| 2 2 |  | 
| 3 3 | 
             
            *   No changes.
         | 
| 4 4 |  | 
| 5 5 |  | 
| 6 | 
            -
            ## Rails 6.0. | 
| 6 | 
            +
            ## Rails 6.1.0.rc1 (November 02, 2020) ##
         | 
| 7 7 |  | 
| 8 | 
            -
            *    | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
            ## Rails 6.0.2.2 (March 19, 2020) ##
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            *   No changes.
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
            ## Rails 6.0.2.1 (December 18, 2019) ##
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            *   No changes.
         | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
            ## Rails 6.0.2 (December 13, 2019) ##
         | 
| 22 | 
            -
             | 
| 23 | 
            -
            *   No changes.
         | 
| 8 | 
            +
            *   Declare `ActionText::FixtureSet.attachment` to generate an
         | 
| 9 | 
            +
                `<action-text-attachment sgid="..."></action-text-attachment>` element with
         | 
| 10 | 
            +
                a valid `sgid` attribute.
         | 
| 24 11 |  | 
| 12 | 
            +
                ```ruby
         | 
| 13 | 
            +
                hello_world_review_content:
         | 
| 14 | 
            +
                  record: hello_world (Review)
         | 
| 15 | 
            +
                  name: content
         | 
| 16 | 
            +
                  body: <p><%= ActionText::FixtureSet.attachment("messages", :hello_world) %> is great!</p>
         | 
| 17 | 
            +
                ```
         | 
| 25 18 |  | 
| 26 | 
            -
             | 
| 19 | 
            +
                *Sean Doyle*
         | 
| 27 20 |  | 
| 28 | 
            -
            *    | 
| 21 | 
            +
            *   Locate `fill_in_rich_text_area` by `<label>` text
         | 
| 29 22 |  | 
| 23 | 
            +
                In addition to searching for `<trix-editor>` elements with the appropriate
         | 
| 24 | 
            +
                `aria-label` attribute, also support locating elements that match the
         | 
| 25 | 
            +
                corresponding `<label>` element's text.
         | 
| 30 26 |  | 
| 31 | 
            -
             | 
| 27 | 
            +
                *Sean Doyle*
         | 
| 32 28 |  | 
| 33 | 
            -
            *    | 
| 29 | 
            +
            *   Be able to add a default value to `rich_text_area`.
         | 
| 34 30 |  | 
| 31 | 
            +
                ```ruby
         | 
| 32 | 
            +
                form.rich_text_area :content, value: "<h1>Hello world</h1>"
         | 
| 33 | 
            +
                #=> <input type="hidden" name="message[content]" id="message_content_trix_input_message_1" value="<h1>Hello world</h1>">
         | 
| 34 | 
            +
                ```
         | 
| 35 35 |  | 
| 36 | 
            -
             | 
| 36 | 
            +
                *Paulo Ancheta*
         | 
| 37 37 |  | 
| 38 | 
            -
            *    | 
| 38 | 
            +
            *   Add method to confirm rich text content existence by adding `?` after rich
         | 
| 39 | 
            +
                text attribute.
         | 
| 39 40 |  | 
| 41 | 
            +
                ```ruby
         | 
| 42 | 
            +
                message = Message.create!(body: "<h1>Funny times!</h1>")
         | 
| 43 | 
            +
                message.body? #=> true
         | 
| 44 | 
            +
                ```
         | 
| 40 45 |  | 
| 41 | 
            -
             | 
| 46 | 
            +
                *Kyohei Toyoda*
         | 
| 42 47 |  | 
| 43 | 
            -
            *    | 
| 48 | 
            +
            *   The `fill_in_rich_text_area` system test helper locates a Trix editor
         | 
| 49 | 
            +
                and fills it in with the given HTML.
         | 
| 44 50 |  | 
| 51 | 
            +
                ```ruby
         | 
| 52 | 
            +
                # <trix-editor id="message_content" ...></trix-editor>
         | 
| 53 | 
            +
                fill_in_rich_text_area "message_content", with: "Hello <em>world!</em>"
         | 
| 45 54 |  | 
| 46 | 
            -
             | 
| 55 | 
            +
                # <trix-editor placeholder="Your message here" ...></trix-editor>
         | 
| 56 | 
            +
                fill_in_rich_text_area "Your message here", with: "Hello <em>world!</em>"
         | 
| 47 57 |  | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
            ## Rails 6.0.0.beta2 (February 25, 2019) ##
         | 
| 52 | 
            -
             | 
| 53 | 
            -
            *   No changes.
         | 
| 58 | 
            +
                # <trix-editor aria-label="Message content" ...></trix-editor>
         | 
| 59 | 
            +
                fill_in_rich_text_area "Message content", with: "Hello <em>world!</em>"
         | 
| 54 60 |  | 
| 61 | 
            +
                # <input id="trix_input_1" name="message[content]" type="hidden">
         | 
| 62 | 
            +
                # <trix-editor input="trix_input_1"></trix-editor>
         | 
| 63 | 
            +
                fill_in_rich_text_area "message[content]", with: "Hello <em>world!</em>"
         | 
| 64 | 
            +
                ```
         | 
| 55 65 |  | 
| 56 | 
            -
             | 
| 66 | 
            +
                *George Claghorn*
         | 
| 57 67 |  | 
| 58 | 
            -
            *   Added to Rails.
         | 
| 59 68 |  | 
| 60 | 
            -
             | 
| 69 | 
            +
            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", formats: :html, 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-rc2",
         | 
| 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"
         | 
    
        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.rc2
         | 
| 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: 2020- | 
| 13 | 
            +
            date: 2020-12-01 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.rc2
         | 
| 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.rc2
         | 
| 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.rc2
         | 
| 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.rc2
         | 
| 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.rc2
         | 
| 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.rc2
         | 
| 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.rc2
         | 
| 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.rc2
         | 
| 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.rc2/actiontext/CHANGELOG.md
         | 
| 144 | 
            +
              documentation_uri: https://api.rubyonrails.org/v6.1.0.rc2/
         | 
| 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.rc2/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
         |