From 6173992e4af3d301366310460c96f49e78e222f7 Mon Sep 17 00:00:00 2001 From: Sascha Karnatz <122262394+sascha-karnatz@users.noreply.github.com> Date: Mon, 31 Jul 2023 22:47:45 +0200 Subject: [PATCH] Improve Richtext editor view Remove the element_id method from Richtext - ingredient and added the id directly to the input, label, and tinymce configuration. --- app/models/alchemy/ingredients/richtext.rb | 4 ---- app/views/alchemy/ingredients/_richtext_editor.html.erb | 7 ++++--- spec/models/alchemy/ingredients/richtext_spec.rb | 6 ------ 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/app/models/alchemy/ingredients/richtext.rb b/app/models/alchemy/ingredients/richtext.rb index b3db3a9924..3e62d97068 100644 --- a/app/models/alchemy/ingredients/richtext.rb +++ b/app/models/alchemy/ingredients/richtext.rb @@ -28,10 +28,6 @@ def preview_text(max_length = 30) stripped_body.to_s[0..max_length - 1] end - def element_id - "tinymce_#{id}" - end - def has_tinymce? true end diff --git a/app/views/alchemy/ingredients/_richtext_editor.html.erb b/app/views/alchemy/ingredients/_richtext_editor.html.erb index 8a7733d96d..829147db7f 100644 --- a/app/views/alchemy/ingredients/_richtext_editor.html.erb +++ b/app/views/alchemy/ingredients/_richtext_editor.html.erb @@ -1,17 +1,18 @@ <%= content_tag :div, class: richtext_editor.css_classes, data: richtext_editor.data_attributes do %> + <%- richtext_dom_id = "tinymce_#{richtext_editor.id}" %> <%= element_form.fields_for(:ingredients, richtext_editor.ingredient) do |f| %> - <%= ingredient_label(richtext_editor) %> + <%= ingredient_label(richtext_editor, :value, for: richtext_dom_id) %>
<%= f.text_area :value, class: "has_tinymce", - id: richtext_editor.element_id %> + id: richtext_dom_id %>
<% end %> <% if richtext_editor.has_custom_tinymce_config? %>