Coder Social home page Coder Social logo

actiontext's Introduction

Action Text has been merged into Rails!

You can find the latest version of the source code inside the Rails repository, where we’ll continue to work on it.

Please report any bugs to the Rails issue tracker.

An archive of the source code before the merge is available here.

actiontext's People

Contributors

albertoalmagro avatar bogdanvlviv avatar dhh avatar georgeclaghorn avatar guilleiguaran avatar hakusaro avatar huacnlee avatar ikepon avatar javan avatar kaspth avatar liroyleshed avatar lucascaton avatar noma4i avatar rafaelfranca avatar rikkipitt avatar sstephenson avatar swamp09 avatar vendethiel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

actiontext's Issues

ActionView::MissingTemplate

Hey guys,

I did a test on rails 5.2.0 and I had a partial result using:

gem 'webpacker', '~> 3.5'

gem "actiontext", github: "rails/actiontext", require: "action_text"

gem "image_processing", "~> 1.2" # for Active Storage variants

gem 'trix

And the ActionText complain:
Missing partial action_text/attachables/_remote_image with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :vtt, :png, :jpeg, :gif, :bmp, :tiff, :svg, :mpeg, :mp3, :ogg, :m4a, :webm, :mp4, :otf, :ttf, :woff, :woff2, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :gzip], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:

Add "insert image" button to default setup

Our user base is not used to drag and drop as an action to add images to RTE-areas.

Therefore, we have a toolbar button to "add image".

I suggest adding such a button to the default setup in action text so there is a clear affordance that shows me how to add a picture.

Have to use custom validations

Along the same lines as rails/rails#33741 (feel free to close if too similar)
However I'm thinking there will be some actiontext specific changes required as well.

Expected Behavior

class Note < ApplicationRecord
  has_rich_text :content
end

With a model like this, I should be able to use a simple validation like

validates_presence_of :content

Actual Behavior

Need to write a custom validation. Here's what I came up with:

validate :has_content

def has_content
  unless content&.body&.present?
    errors.add(:content, "Can't be blank")
  end
end

System Configuration

Rails 5.2.1
Ruby 2.5.1

couldn't update when image attached

When I try to updating content of ActionText without attachment, it works properly.
But if the content have an image, I can't add text or image to content of ActionText.
After remove attached image, it updated correctly.

Below is information for more detailed.

Thank you.

When updating without attachment

(0.5ms) begin transaction
↳ app/controllers/articles_controller.rb:26
ActionText::RichText Load (0.6ms) SELECT "action_text_rich_texts".* FROM "action_text_rich_texts" WHERE "action_text_rich_texts"."record_id" = ? AND "action_text_rich_texts"."record_type" = ? AND "action_text_rich_texts"."name" = ? LIMIT ? [["record_id", 8], ["record_type", "Article"], ["name", "content"], ["LIMIT", 1]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attribute.rb:29
User Load (14.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
↳ app/controllers/articles_controller.rb:26
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (24.5ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (7.1ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (29.6ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (2.5ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (6.5ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (2.0ms)
ActionText::RichText Update (5.6ms) UPDATE "action_text_rich_texts" SET "body" = ?, "updated_at" = ? WHERE "action_text_rich_texts"."id" = ? [["body", "

TESTTESTTEST
"], ["updated_at", "2018-11-29 08:09:49.961947"], ["id", 2]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attribute.rb:43
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (6.0ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (2.9ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (4.6ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (3.5ms)
Article Update (0.3ms) UPDATE "articles" SET "updated_at" = ? WHERE "articles"."id" = ? [["updated_at", "2018-11-29 08:09:50.760540"], ["id", 8]]
↳ app/controllers/articles_controller.rb:26
(2.0ms) commit transaction

When containing image

posted parameter

"content"=>"<div><figure data-trix-attachment=\"{&quot;contentType&quot;:&quot;image&quot;,&quot;height&quot;:705,&quot;url&quot;:&quot;http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--f86e2d4ddbecd7cc3594c6b288e860405343f302/image.png&quot;,&quot;width&quot;:1253}\" data-trix-content-type=\"image\" class=\"attachment attachment--preview\"><img src=\"http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--f86e2d4ddbecd7cc3594c6b288e860405343f302/image.png\" width=\"1253\" height=\"705\"><figcaption class=\"attachment__caption\"></figcaption></figure><br><br>TESTTESTTEST</div>"

SQL transaction

(0.7ms) begin transaction
↳ app/controllers/articles_controller.rb:26
ActionText::RichText Load (0.8ms) SELECT "action_text_rich_texts".* FROM "action_text_rich_texts" WHERE "action_text_rich_texts"."record_id" = ? AND "action_text_rich_texts"."record_type" = ? AND "action_text_rich_texts"."name" = ? LIMIT ? [["record_id", 11], ["record_type", "Article"], ["name", "content"], ["LIMIT", 1]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attribute.rb:29
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
↳ app/controllers/articles_controller.rb:26
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/attachables/_remote_image.html.erb (3.9ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (154.5ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/attachables/_remote_image.html.erb (0.2ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (147.0ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/attachables/_remote_image.html.erb (0.2ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (141.5ms)
(0.1ms) commit transaction

When deleting image

(0.2ms) begin transaction
↳ app/controllers/articles_controller.rb:26
ActionText::RichText Load (0.4ms) SELECT "action_text_rich_texts".* FROM "action_text_rich_texts" WHERE "action_text_rich_texts"."record_id" = ? AND "action_text_rich_texts"."record_type" = ? AND "action_text_rich_texts"."name" = ? LIMIT ? [["record_id", 10], ["record_type", "Article"], ["name", "content"], ["LIMIT", 1]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attribute.rb:29
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
↳ app/controllers/articles_controller.rb:26
ActiveStorage::Blob Load (0.3ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 9], ["LIMIT", 1]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attachable.rb:24
Rendered active_storage/blobs/_blob.html.erb (2.0ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (73.9ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (0.1ms)
CACHE ActiveStorage::Blob Load (0.0ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 9], ["LIMIT", 1]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attachable.rb:24
Rendered active_storage/blobs/_blob.html.erb (0.8ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (66.7ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (0.2ms)
CACHE ActiveStorage::Blob Load (0.0ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 9], ["LIMIT", 1]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attachable.rb:24
Rendered active_storage/blobs/_blob.html.erb (0.7ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (65.0ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (0.2ms)
ActionText::RichText Update (1.0ms) UPDATE "action_text_rich_texts" SET "body" = ?, "updated_at" = ? WHERE "action_text_rich_texts"."id" = ? [["body", ""], ["updated_at", "2018-11-29 08:17:38.915927"], ["id", 5]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attribute.rb:43
ActiveStorage::Blob Load (0.2ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 9], ["LIMIT", 1]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attachable.rb:24
Rendered active_storage/blobs/_blob.html.erb (0.7ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (68.4ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (0.1ms)
CACHE ActiveStorage::Blob Load (0.0ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 9], ["LIMIT", 1]]
↳ /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/lib/action_text/attachable.rb:24
Rendered active_storage/blobs/_blob.html.erb (0.8ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (62.0ms)
Rendered /Users/hyunkiahn/.rvm/gems/ruby-2.5.1/bundler/gems/actiontext-18974137be2c/app/views/action_text/content/_layout.html.erb (0.1ms)
Article Update (0.3ms) UPDATE "articles" SET "updated_at" = ? WHERE "articles"."id" = ? [["updated_at", "2018-11-29 08:17:39.857448"], ["id", 10]]
↳ app/controllers/articles_controller.rb:26
(1.0ms) commit transaction

ActionText::Content#to_s triggers unnecessary queries

When rendering the content - each of the embedded blobs is individually loaded via the GlobalID::Locator - ignoring an preloaded values from with_rich_text_#{name}_and_embeds.

If the attachments are inside a gallery they seem to be loaded multiple time.

Failing test (requires some query assertions copied from ActiveRecord).

  test "with preloaded embeds it doesn't N+1 query" do
    ActiveStorage::Current.host = "http://localhost:3000"
    attachables = [create_file_blob(filename: "racecar.jpg", content_type: "image/jpg"), create_file_blob(filename: "racecar.jpg", content_type: "image/jpg")]
    html = attachables.map{ |attachable|
      <<~HTML
      <action-text-attachment sgid="#{attachable.attachable_sgid}" content-type="image/jpg" previewable="true" presentation="gallery" filename="racecar.jpg" url=#{attachable.service_url} filesize="418099" width="649" height="647" ></action-text-attachment>
      HTML
    }.join
    message = Message.create!(subject: "Greetings", content: "<div>#{html}</div>")
    message = Message.with_rich_text_content_and_embeds.find(message.id)
    sleep 1 # Wait for background processing
    assert_no_queries do
      message.content.to_s
    end
  end
Failure:
ActionText::ModelTest#test_with_preloaded_embeds_it_doesn't_N+1_query [/Users/lsylvester/Rails/actiontext/test/unit/model_test.rb:46]:
6 instead of 0 queries were executed.
Queries:
SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ?
SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ?
SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ?
SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ?
SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ?
SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ?.
Expected: 0
  Actual: 6

Code for this test is at https://github.com/lsylvester/actiontext/tree/unnecessary-queries-test but it is not ready for a PR.

Security / Input Validation

Many users will at some point render the saved content outside of the editor itself. In this case it becomes crucial that the saved HTML does not contain any scripts or other security vulnerabilities. Does ActionText do any form of validation on the saved html? If not, malicious users could take advantage of the exposed API and inject <script> tags.

The sanitize gem may be of use here!

UseCase video embedding

Hi, I love the idea of actiontext.
I looked into our own RTE implementation and found a use case that is not supported yet:

Embedding of external videos.

UseCase: I want to write a blog post and add a youtube or vimeo video.
Ideally, I would want to see a preview of the video in my editor - same as with images.

The way we do it right now: Authors can paste a video URL in the editor. Once we save the content we use oembed to change the URL to the preview-snipped. We then save both, the original text and the output-text which includes the youtube (…) video-snipped. We then display the output-text.

This process would still work with actiontext/trix, but it's not on the same level as working with images.

Are there other ways to handle this within actiontext?
Native support for embedding of external videos?
Or an api that allows to handle the trix-ui-part (paste, display a preview) and rendering part?

Thanks

UniqueViolation: Error in Gallery edits (Rails 5.2.1)

I know action_text doesn't support Rails 5.2.1 (and depends on Rails 6.0.x).

That said, with minimal work, it's working 99% in Rails 5.2.1 and now the only issue I'm running into is in a very specific scenario (below), and I was wondering if anyone here knows whether it's related to reliance on a specific update in Rails 6 (related to ActiveStorage or ActiveRecord) that I could patch in to make it work in Rails 5.2.1:

Environment

  • New Rails 5.2.1 app
  • Add latest actiontext and webpacker versions from Github to Gemfile and bundle install
  • Install webpacker
  • Make sure javascript_pack_tag 'application' is in application layout
  • Install actiontext
  • Run migrations
  • Add Post scaffold with title:string and run migrations
  • Add rich_text_field :content to Post.rb, then update _form.erb, show.erb, and posts_controller post_params
  • The only Rails 5.2.1 specific change (relevant to this) is to simply remove the image transforms from _blob.html.erb: <%= image_tag blob.representation({})

Issue

  • Go to posts#new and add a title and some content
  • Upload 2 images to the rich_text_field (by drag-and-dropping)
  • Save (which works fine and displays correctly on posts#show)
  • Then try to edit the post, and specifically edit rich_text_field so that 1 or 2 of original 2 images are still present (but something about the content is different than before)
  • Save
  • PG::UniqueViolation Error

PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_active_storage_attachments_uniqueness" DETAIL: Key (record_type, record_id, name, blob_id)=(ActionText::RichText, 349d05dd-cc7c-4e51-973d-24ff9e382e10, embeds, 1e794d34-6a14-4a80-9aeb-d31e6e1a1494) already exists. : INSERT INTO "active_storage_attachments" ("name", "record_id", "record_type", "blob_id", "created_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"

This does NOT happen in Rails 6.0.0.alpha. This DOES happen in Rails 5.2.1 without uuid's and without postgres.

It looks like it's trying to re-upload the image, even though it's already been uploaded.

I realize this is not a bug, so I'm sorry to clog up issues, but if anyone knows off the top of their head why this might be happening in Rails 5.2.1 (and not with Rails 6.0.0.alpha), I would deeply appreciate some help!

Thanks!!

UseCase: Delete a picture

This might be solved in a way I did not understand yet.
But just in case it is not, here is my use case:

In my mind, using actiontext in an app that is behind a login (eg basecamp) is different from using it publicly, eg to create a public blog post or edit a public profile description.
The main difference is the importance of "truly" deleting an image.

UseCase

  • I create a public blogpost with actiontext and publish it. The post has a few images that are now saved in the cloud.
  • For some reason, I need to delete one or more of those images. Because of copy right. Or privacy reasons. Or …
  • Fist step is to remove it from the body of the blogpost in actiontext and update the post.

However, I assume this does not trigger the deletion of the image itself in the cloud. Which in this use case is required to really comply with eg privacy laws.

A sub-case for this would be to upload images in trix but then abandon the post (not click save). I am not sure if the image is already in the cloud, but if it is, its a similar problem: How do I get rid of it. However, in this case its less urgent since the image was not public yet; its just an image I want deleted that is on someones cloud storage, somewhere.

Based on this, I wonder …

  • … should the recommended use of actiontext include a list of files associated with the text-block, so I have a place where I can click the "delete this image"-button?
  • … should/can this list be synced to the content of the text?
    • as in: remove or warn if I delete an image that is in use
    • or: the editor notices the fact that I removed an image from my blogpost and asks me if I want to delete it from the "harddrive" as well
  • … should this list be part of the trix-UI or something somewhere outside the editor-box?
  • … is there a way to create a backoffice view that lists images that are associated with a text-block but not used inside the text (and similar cases, like the sub-case above). Eg: does actiontext save the associated image ids or just the public url as part of the blogpost?

Thanks

Add image gallery support

Image galleries display…

  1. correctly in an editor
  2. incorrectly after saving/viewing
  3. incorrectly when loaded back into an editor

undefined method `url_expires_in` for nil:NilClass:

Hello,

I am having troubles when I want to add pictures.
There is no issue when I copy paste a picture directly in the text editor. However when I try to drag and drop a picture from a folder, it raises an error in ActiveStorage::DirectUploadsController line 19 with the error NoMethodError - undefined method 'url_expires_in' for nil:NilClass:
Any idea of where it can come from?

Thanks

Make it configurable just for backend development

I found this new feature really interesting for chat feature developing as it also make use of ActiveStorage.
I tried to make it work on a API case but I founded the problem that the :content received at the controller is too specific to be generated by a frontend:

<div>
 <figure data-trix-attachment=\“{&quot;contentType&quot;:&quot;image/jpeg&quot;,&quot;filename&quot;:&quot;happy_frog.jpg&quot;,&quot;filesize&quot;:91211,&quot;height&quot;:386,&quot;sgid&quot;:&quot;BAh7CEkiCGdpZAY6BkVUSSI3Z2lkOi8vYWN0aW9uLXRleHQvQWN0aXZlU3RvcmFnZTo6QmxvYi83P2V4cGlyZXNfaW4GOwBUSSIMcHVycG9zZQY7AFRJIg9hdHRhY2hhYmxlBjsAVEkiD2V4cGlyZXNfYXQGOwBUMA==--0861859ff592952a0f7d81387e24246d5816b26f&quot;,&quot;url&quot;:&quot;http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--9ece563b8519d50276db4cf816538a712315615c/happy_frog.jpg&quot;,&quot;width&quot;:620}\” data-trix-content-type=\“image/jpeg\” data-trix-attributes=\“{&quot;presentation&quot;:&quot;gallery&quot;}\” class=\“attachment attachment--preview attachment--jpg\“>
   <img src=\“http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--9ece563b8519d50276db4cf816538a712315615c/happy_frog.jpg\” width=\“620\” height=\“386\“>
   <figcaption class=\“attachment__caption\“>
     <span class=\“attachment__name\“>happy_frog.jpg</span>
     <span class=\“attachment__size\“>89.07 KB</span>
   </figcaption>
 </figure>
</div> 

So, is there any plan to standardize it? or maybe introduce any option to install it like `rails action_text:install --api`` ?

I would be more than happy to lend a hand or even propose a pr, but first want to hear about the community due to being a couple of different ways to solve this

i18n considerations

Hello,

I like the inclusion of a rich-text editor in rails by default.

One issue I'd like to raise is internationalization/translations. I've been using the globalize gem to save translation records for fields on models that have translations. Now I was wondering if this will work for rich text fields, too.

Provide a meaningful error when forgetting has_rich_text in model

Hello everyone!

First of all, thanks for creating this gem and deciding to include it in Rails 6 🎉 🙏

Yesterday while I was watching @dhh 's demo video I decided to follow the steps to try ActionText myself. By doing this I luckily forgot to add the following has_rich_text class method to Post:

class Post < ApplicationRecord
  has_rich_text :content
end

The consequence was that when I tried to render the form with the rich text editor I got the following error:

ActionView::Template::Error (undefined method `body' for nil:NilClass):
    17:   </div>
    18: 
    19:   <div class="field">
    20:     <%= form.rich_text_area :content %>
    21:   </div>
    22: 
    23:   <div class="actions">

I would like to submit a patch that would make ActionText able to suggest the user that the has_rich_text class method for :content in the Post model may need to be added. Would you be happy with that?

Thanks in advance!

couldn't find file 'trix/dist/trix' with type 'text/css'

I just installed wanted to test drive Rails version: 6.0.0.alpha
(Ruby version: 2.5.3 (x86_64-darwin18)) and followed this guide to try out action text:
https://dev.to/adrienpoly/step-by-step-guide-to-test-rails-activetext-4b8o

Trix including image upload works but I have to throw out this line:

//= require trix/dist/trix

Otherwise I get the following error:

couldn't find file 'trix/dist/trix' with type 'text/css'
Checked in these paths:
/Users/bijan/Desktop/yabe/yabe6/app/assets/config
/Users/bijan/Desktop/yabe/yabe6/app/assets/images
/Users/bijan/Desktop/yabe/yabe6/app/assets/stylesheets
/Users/bijan/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/rails-1cc46865ecfe/actioncable/app/assets/javascripts
/Users/bijan/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/rails-1cc46865ecfe/activestorage/app/assets/javascripts
/Users/bijan/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/rails-1cc46865ecfe/actionview/app/assets/javascripts
/Users/bijan/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/turbolinks-source-5.2.0/lib/assets/javascripts

So Trix is unfortunately completely unstyled. Am I missing something?

The Frontend Editor Should be Configurable

As part of the Rails framework, I think the particular frontend text editor should be configurable. There's enough plumbing in ActionText to be valuable for every WYSIWYG editor, such as the action_text_rich_blogs table for baked content, the ActiveStorage integration and the other conveniences provided by the framework. The Trix editor is just but one component.

For example, one should be able to selected Quill as their editor of choice in the configuration file:

config.action_text.editor = :quill

This would then instantiate the Quill editor for any forms built with the f.rich_text_area helper.

I've browsed through the source code and have a decent idea of what would need to change in order to support something like Quill, but I'm unfamiliar with the best practices with making a configurable framework like this.

I'm happy to take a stab at the code if someone were willing to help guide me along the way with what would need to change to make this happen and get accepted.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.