-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #709 - #2200 (review) Markdown is cool, but it's nerd-forward. ActionText is a much more human-friendly way of implementing rich text in Rails applications. I don't know enough about [Trix] to know if it will work in multi-user contexts; or how it will work with rich-embeds, ala Notion or Google Docs But I think it's a good-enough-default for now; and if we get to the point where embeddables or multi-user editing of a field is important we can figure that out. [Trix]: https://trix-editor.org/
- Loading branch information
Showing
11 changed files
with
115 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and | ||
* the trix-editor content (whether displayed or under editing). Feel free to incorporate this | ||
* inclusion directly in any other asset bundle and remove this file. | ||
* | ||
*= require trix | ||
*/ | ||
|
||
/* | ||
* We need to override trix.css’s image gallery styles to accommodate the | ||
* <action-text-attachment> element we wrap around attachments. Otherwise, | ||
* images in galleries will be squished by the max-width: 33%; rule. | ||
*/ | ||
.trix-content .attachment-gallery > action-text-attachment, | ||
.trix-content .attachment-gallery > .attachment { | ||
flex: 1 0 33%; | ||
padding: 0 0.5em; | ||
max-width: 33%; | ||
} | ||
|
||
.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment, | ||
.trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment, | ||
.trix-content .attachment-gallery.attachment-gallery--4 > .attachment { | ||
flex-basis: 50%; | ||
max-width: 50%; | ||
} | ||
|
||
.trix-content action-text-attachment .attachment { | ||
padding: 0 !important; | ||
max-width: 100% !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
|
||
@import "./utilities.scss"; | ||
@import "./components.scss"; | ||
@import 'actiontext.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>"> | ||
<% if blob.representable? %> | ||
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %> | ||
<% end %> | ||
|
||
<figcaption class="attachment__caption"> | ||
<% if caption = blob.try(:caption) %> | ||
<%= caption %> | ||
<% else %> | ||
<span class="attachment__name"><%= blob.filename %></span> | ||
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span> | ||
<% end %> | ||
</figcaption> | ||
</figure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="trix-content"> | ||
<%= yield -%> | ||
</div> |
27 changes: 27 additions & 0 deletions
27
db/migrate/20240216213129_create_action_text_tables.action_text.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This migration comes from action_text (originally 20180528164100) | ||
class CreateActionTextTables < ActiveRecord::Migration[6.0] | ||
def change | ||
# Use Active Record's configured type for primary and foreign keys | ||
primary_key_type, foreign_key_type = primary_and_foreign_key_types | ||
|
||
create_table :action_text_rich_texts, id: primary_key_type do |t| | ||
t.string :name, null: false | ||
t.text :body, size: :long | ||
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type | ||
|
||
t.timestamps | ||
|
||
t.index [:record_type, :record_id, :name], name: "index_action_text_rich_texts_uniqueness", unique: true | ||
end | ||
end | ||
|
||
private | ||
|
||
def primary_and_foreign_key_types | ||
config = Rails.configuration.generators | ||
setting = config.options[config.orm][:primary_key_type] | ||
primary_key_type = setting || :primary_key | ||
foreign_key_type = setting || :bigint | ||
[primary_key_type, foreign_key_type] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters