Add prompts to the rest of rich text editors

This commit is contained in:
Jorge Manrubia
2025-06-19 13:34:44 +02:00
parent 68dededbca
commit 2dbb53da1f
5 changed files with 24 additions and 10 deletions
-4
View File
@@ -25,10 +25,6 @@ class User < ApplicationRecord
update! active: false, email_address: deactived_email_address
end
def to_attachable_partial_path
"users/attachable"
end
private
def deactived_email_address
email_address.sub(/@/, "-deactivated-#{SecureRandom.uuid}@")
+9
View File
@@ -3,6 +3,11 @@ module User::Mentionable
included do
has_many :mentions, dependent: :destroy, inverse_of: :mentionee
# Need to set in the included block so that it overrides Action Text's
def to_attachable_partial_path
"users/attachable"
end
end
def mentioned_by(mentioner, at:)
@@ -13,6 +18,10 @@ module User::Mentionable
[ initials, first_name, first_name_with_last_name_initial ].collect(&:downcase)
end
def content_type
"application/vnd.actiontext.mention"
end
private
def first_name_with_last_name_initial
"#{first_name}#{last_name&.first}"
+6 -3
View File
@@ -7,10 +7,13 @@
<div class="comment__body rich-text-content txt-align-start">
<%= form_with model: Comment.new, url: card_comments_path(card), class: "flex flex-column gap full-width",
data: { controller: "form local-save",
local_save_key_value: "comment-#{card.id}",
action: "turbo:submit-end->local-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do |form| %>
local_save_key_value: "comment-#{card.id}",
action: "turbo:submit-end->local-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do |form| %>
<%= form.rich_textarea :body, required: true, placeholder: new_comment_placeholder(card),
data: { local_save_target: "input", action: "actiontext:change->local-save#save turbo:morph-element->local-save#restoreContent" } %>
data: { local_save_target: "input", action: "actiontext:change->local-save#save turbo:morph-element->local-save#restoreContent" } do %>
<%= mentions_prompt %>
<%= cards_prompt %>
<% end %>
<%= form.button class: "comment__submit btn btn--reversed flex-item-justify-start" do %>
<span>Post this comment</span>
<% end %>
+5 -2
View File
@@ -8,7 +8,10 @@
<div class="comment__body rich-text-content txt-align-start">
<%= form_with model: [ @card, @comment ], class: "flex flex-column gap full-width",
data: { controller: "form", action: "keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do |form| %>
<%= form.rich_textarea :body, required: true, autofocus: true, placeholder: new_comment_placeholder(@card) %>
<%= form.rich_textarea :body, required: true, autofocus: true, placeholder: new_comment_placeholder(@card) do %>
<%= mentions_prompt %>
<%= cards_prompt %>
<% end %>
<div class="flex gap-half justify-start">
<%= form.button class: "btn btn--reversed", type: :submit do %>
<span>Save changes</span>
@@ -18,7 +21,7 @@
<% end %>
<%= tag.button type: :submit, class: "btn btn--negative flex-item-justify-end", form: dom_id(@comment, :delete_form),
data: { turbo_confirm: "Are you sure you want to delete this comment?" } do %>
data: { turbo_confirm: "Are you sure you want to delete this comment?" } do %>
<%= icon_tag "trash" %>
<span class="for-screen-reader">Delete</span>
<% end %>
+4 -1
View File
@@ -20,7 +20,10 @@
<div class="card__description rich-text-content margin-block-start-half margin-block-end">
<%= form.rich_textarea :description, class: "card-field__description",
placeholder: "Add some notes, context, pictures, or video about this…",
data: { action: "actiontext:change->auto-save#change focusout->auto-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } %>
data: { action: "actiontext:change->auto-save#change focusout->auto-save#submit keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } do %>
<%= mentions_prompt %>
<%= cards_prompt %>
<% end %>
</div>
<% end %>
<% end %>