* Switch to a single controller option for choosing JavaScript approach
* Remove remnants of webpacker specific work within Rails
* No longer used
* Missing space
* Raise if unknown option is passed
* Style
* Use latest versions
* Make channels setup generic to all node setups
* Make Action Text installer work with any node package manager
* Explaining variables are not useless
* Rubocop pleasing
* Don't rely on Rails.root
Tests don't like it!
* Rubocopping
* Assume importmap
* No longer relevant
* Another cop
* Style
* Correct installation notice
* Add dependencies for action cable when adding a channel
* Fix paths to be relative to generator
* Just go straight to yarn, forget about binstub
* Fix tests
* Fixup installer, only yarn once
* Test generically with run
* Style
* Fix reference and reversibility
* Style
* Fix test
* Test pinning dependencies
* Remove extra space
* Add more tests
* Use latest dependencies
* Relegated this to controllers
* Refactor ChannelGenerator + more tests
Use a uniform level of abstraction
* No benefit to having actiontext css as scss
* Update test
* Update docs
* No more css assets to be generated
New world, new CSS frameworks, new needs.
* SCSS is becoming optional
* Remove Sass as a default-on setting
But continue to make it easy to add.
* Update docs
* No longer used
* Update tests
* Update docs
* Update docs
* No longer used
* No longer by default
* Fix tests
* Promote Tailwind CSS as an alternative to Sass
* Fix test and copy task
* Update railties/lib/rails/generators/rails/app/templates/Gemfile.tt
Co-authored-by: Kevin Newton <kddnewton@gmail.com>
Co-authored-by: Kevin Newton <kddnewton@gmail.com>
* Turbolinks is being replaced with Hotwire
* Make --webpack opt-in
* Don't use specific webpacker installers any more in preparation for next Webpacker
* Update railties/lib/rails/app_updater.rb
Co-authored-by: Alex Ghiculescu <alex@tanda.co>
* Trailing whitespace
* Convert to Turbo data attribute for tracking
* Default is no webpack, no hotwire
* Swap out turbolinks references for hotwire
* Drop explicit return
* Only generate package.json if using webpack
* Only create package.json in webpack mode
* Only create app/javascript in webpack mode
* Generate correct style/js links based on js mode
* Fix tests from changed output format
Not sure why these are showing up in this PR, though.
* Rubocopping
* Stick with webpack for the test app for now
* Adjust tests
* Replace minitest-reporters with minitest-ci (#43016)
minitest-reporters is used to create junit xml reports on CI.
But when it loads before rails minitest plugin makes
`Rails::TestUnitReporter` not being added as a reporter.
minitest-ci is now only loaded at ci and does not interferes with
rails minitest plugins. And keeps junit reports workings
* Too heavy handed to actually run bundle
Just like we don't auto-migrate
* Pin js frameworks in importmap
Instead of having importmap preconfigure it.
* Match updated app/javascript path
* No need for the explaining comment
* Fixes test cases for replace webpack with importmapped Hotwire as default js (#42999)
* Fix rubocop issues
* Fix more railities test cases
* Fix plugin generator railties shared test cases
* Fix Action Text install generator asset pipeline spec
* They're modules, not files
* Let dev use the latest release as well
So we don't have to replace unexisting dev releases with latest release
* Make Webpack responsible for generating all the JS files it needs
Webpacker 6 has already moved from app/javascript to app/packs.
* Don't add rails/ujs by default any longer
All the ajax/form functionality has been superseded by Turbo. The rest lives in a weird inbetween land we need to address through other means.
* Use new importmap location
* Switch to using turbo-rails and stimulus-rails directly
The hotwire-rails gem does not offer enough value for its indirection
* Use latest Webpacker
* Prevent version resolution requests from getting swallowed
* Use ESM syntax for imports
* Move management of yarn, package.json, etc to Webpacker 6
* Update for Webpacker 6
* Move bin/setup addition to Webpacker as well
* Remove dead tests
* Bump to Webpacker 6.0.0.rc.2
* No longer relevant given the new default is no webpacker
* Rely on Webpacker 6
* No longer relevant
* No longer relevant
* Make cable channel generator work for both webpacker and importmap setups
* Fix tests
* For tests testing importmap way
* Use Webpacker 6 dummy
* RuboCopping
* One more bump to fix webpack-dev-server
* Another bump. Hopefully the last one!
* Also enough to not want turbo tracking on
* Fix tests
* Latest
* Fix tests
* Fix more tests
* Fix tests
Co-authored-by: Alex Ghiculescu <alex@tanda.co>
Co-authored-by: André Luis Leal Cardoso Junior <andrehjr@gmail.com>
Co-authored-by: Abhay Nikam <nikam.abhay1@gmail.com>
Co-authored-by: Guillermo Iguaran <guilleiguaran@gmail.com>
* Stop trying to configure listen by default on compatible platforms
Modern computers with SSDs don't see much/any benefit from having an evented file update watcher. Remove complexity by taking this spinning-drive concession out.
* Actually need listen for testing the opt-in
* Test no longer relevant
* Move to ESM and drop Babel transpiling
* Make the activestorage JS directly available through the asset pipeline as a precompiled asset
* Use example with direct attachment
* Explain that direct reference is possible
* Active Storage JS is a module
* Retain umd asset for backwards compatibility, add ESM file in addition
* Explain how to use activestorage.esm with importmap
* Use untranspiled activestorage inclusion
* Don't repeat terser options
* Action Text JS should be available via the asset pipeline too
* Main was a module anyway, no need to reference that twice
* Fix rollup references
* Precompile action text JS for asset pipeline
* No JavaScript dependencies needed with the asset pipeline
* Stub Webpacker::Engine to trigger webpack path for testing
* Extract asset paths
* Exercise asset pipeline path
* Terser doesn't do anything useful on this small package
* Make trix directly available to the asset pipeline
* Indirect doesn't carry its worth
* Reminder for development about keeping things in sync for the asset pipeline
* Ensure this isn't turned into undefined while mirroring
* Mirror Trix CSS for asset pipeline
* Add the needed JS include tag automatically under the asset pipeline
* Please RuboCop
* Keep the peer dependency
Even though we also need it explicitly as a dev dependency in order to generate the mirror output for trix.
* Fix test
* Add CHANGELOG entry
Similar to: #42378
Tried adding test cases for the changes but
migration file would always use id as primary_key_type
and reference type as foreign_key_type. Did not find
any good way to assert the changes.
Tested locally and following is the schema
generated for Action Text migration if
`primary_key_type: :uuid`
```
create_table "action_text_rich_texts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "name", null: false
t.text "body"
t.string "record_type", null: false
t.uuid "record_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
end
```
Terser is more up to date with modern javascript features, and the
uglifier gem repository recommends using it for minifying ES6+.
Followup for 955041b
Affected gems:
* actionmailbox
* activestorage
* actiontext
This fixes the following warning:
DEPRECATION WARNING: Using legacy connection handling is deprecated. Please set
`legacy_connection_handling` to `false` in your application.
The new connection handling does not support `connection_handlers`
getter and setter.
Read more about how to migrate at: https://guides.rubyonrails.org/active_record_multiple_databases.html#migrate-to-the-new-connection-handling
(called from require at ~/.gem/ruby/3.1.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34)
Currently when you make a new Rails app, we generate a lot of initializers. For new users, I think we should try and include as few as possible - the less files, the less daunting a new app is. And for upgrades I'd like to [continue to simplify the update process](https://github.com/rails/rails/pull/41083), in this case by not bringing back initializers you have probably already dismissed or modified.
In this PR I'm proposing we remove two initializers: `application_controller_renderer.rb` and `cookies_serializer.rb`:
**`application_controller_renderer.rb`**. This configures [`ActionController::Renderer`](https://api.rubyonrails.org/classes/ActionController/Renderer.html), for rendering views outside of controller actions. I don't think this is something most Rails apps will need (certainly not on day 1); users can configure this feature when they need it.
**`cookies_serializer.rb`**. This was added for [Rails 4.1](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#cookies-serializer). The behaviour is:
- For new apps, the initializer says `:json`.
- For upgraded apps that don't have the initializer, it is added with value `:marshal`.
- If there's no initializer, the [default value](c9a89a4067/actionpack/lib/action_dispatch/middleware/cookies.rb (L589)) is `:marshal`.
Since nobody should be upgrading direct from Rails 4.0 to Rails 7.0, we can simplify this by using new framework defaults. So the behavior will now be:
- For new apps, `config.load_defaults("7.0")` sets the value to `:json`.
- The `new_framework_defaults_7_0.rb` file explains this, and suggests using `:hybrid` to be upgrade to JSON cookies.
- No changes to [the code](c9a89a4067/actionpack/lib/action_dispatch/middleware/cookies.rb (L589)); the default value is `:marshal` if you don't set one.
So if you were not setting a `cookies_serializer` previously and you want to keep using `:marshal`, you'll need to explicitly set this before using `config.load_defaults("7.0")`, otherwise it will switch to `:json`. The upside of this is you won't get the `cookies_serializer.rb` file created for you every time you upgrade.
Both methods are defined in multiple parts of the framework. It would
be useful to put them in a proper place, so that repetition is
avoided.
I chose the implementation from `ActiveRecord` because it's a bit more
complete with the `SQLCounter` class, and also because other parts
depend on it.
Trix's `<trix-editor>` doesn't support the [form][] property like
`<textarea>` or other form fields.
For example, consider the following HTML and event listener:
```html
<form action="/articles" method="post">
<textarea name="content"></textarea>
<button type="submit">Save</button>
</form>
<script>
addEventListener("keydown", ({ key, metaKey, target }) => {
if (target.form && key == "Enter" && (metaKey || ctrlKey)) {
form.requestSubmit()
}
})
</script>
```
The `target` (an instance of `HTMLTextAreaElement` relies on the
[HTMLTextAreaElement.form][] property for access to its associated
`<form>`. While it's usually equivalent to `target.closest("form")`,
that isn't always the case. Declaring a `[form]` attribute with another
`<form>` element's `[id]` value can associate a field to a `<form>` that
is _not an ancestor_. That means that the event listener from above
would continue to work with this HTML:
```html
<textarea name="content" form="new_article"></textarea>
<!-- elsewhere -->
<form id="new_article" action="/articles" method="post">
<button type="submit">Save</button>
</form>
```
Unfortunately, if the `<textarea>` element were replaced with a
`<trix-editor>`, the event listener's reliance on accessing the form as
a property would break, since the `<trix-editor>` custom element doesn't
declare that property. There is currently a pull request
([basecamp/trix#899][]) to add support for accessing the `form` as a
property of the `<trix-editor>` element.
The [feedback][] provided on that pull request suggests that we
implement the `form` property by delegating to the `<input
type="hidden">` element. Currently, `<input type="hidden">` elements
constructed by Action Text helpers cannot declare the `[form]`
attribute.
This commit adds support by special-casing the `options[:form]` key
within `ActionText::TagHelper#rich_text_area_tag`.
[form]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement#properties
[basecamp/trix#899]: https://github.com/basecamp/trix/pull/899#discussion_r618543357
[feedback]: https://github.com/basecamp/trix/pull/899#discussion_r618543357
The test cases where failing because the test
`test_converts_Trix-formatted_attachments_with_custom_tag_name` set a
custom tag_name to `arbitrary-tag`. This test would also set the
ActionText::AttachmentGallery::ATTACHMENT_SELECTOR private constant
to `arbitrary-tag`.
Other test cases had proper ActionText::Attachment.tag_name set to
`action-text-attachment` but the constant once defined would not
reset.
This PR attempts to fix the issue by converting the
ActionText::AttachmentGallery::{ATTACHMENT_}SELECTOR to class methods
Fixes#41782
The helpers of Action Text are added to a couple of non-reloadable
base classes:
initializer "action_text.helper" do
%i[action_controller_base action_mailer].each do |abstract_controller|
ActiveSupport.on_load(abstract_controller) do
helper ActionText::Engine.helpers
end
end
end
Therefore, it does not make sense that they are reloadable themselves.
For the same price, we can also make the models non-reloadable, thus
saving parent applications from the unnecessary work of reloading this
engine.
We did this for turbo-rails as well.