From 2dbb53da1f145a999c6d2bcc6fa668e045481881 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 19 Jun 2025 13:34:44 +0200 Subject: [PATCH] Add prompts to the rest of rich text editors --- app/models/user.rb | 4 ---- app/models/user/mentionable.rb | 9 +++++++++ app/views/cards/comments/_new.html.erb | 9 ++++++--- app/views/cards/comments/edit.html.erb | 7 +++++-- app/views/cards/container/_title.html.erb | 5 ++++- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index c1dbc8c83..23b2f1cb2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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}@") diff --git a/app/models/user/mentionable.rb b/app/models/user/mentionable.rb index 7a930ab02..be82f3d95 100644 --- a/app/models/user/mentionable.rb +++ b/app/models/user/mentionable.rb @@ -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}" diff --git a/app/views/cards/comments/_new.html.erb b/app/views/cards/comments/_new.html.erb index 68659dd38..8237fda1e 100644 --- a/app/views/cards/comments/_new.html.erb +++ b/app/views/cards/comments/_new.html.erb @@ -7,10 +7,13 @@
<%= 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 %> Post this comment <% end %> diff --git a/app/views/cards/comments/edit.html.erb b/app/views/cards/comments/edit.html.erb index 726693c47..ebf55a8b1 100644 --- a/app/views/cards/comments/edit.html.erb +++ b/app/views/cards/comments/edit.html.erb @@ -8,7 +8,10 @@
<%= 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 %>
<%= form.button class: "btn btn--reversed", type: :submit do %> Save changes @@ -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" %> Delete <% end %> diff --git a/app/views/cards/container/_title.html.erb b/app/views/cards/container/_title.html.erb index 0a45685e9..e95064726 100644 --- a/app/views/cards/container/_title.html.erb +++ b/app/views/cards/container/_title.html.erb @@ -20,7 +20,10 @@
<%= 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 %>
<% end %> <% end %>