diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index b7e0265dc..85a5a304f 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1072,8 +1072,8 @@ form { margin: $line-height / 2 0 $line-height / 2 $line-height / 4; } - .ckeditor { - min-height: $line-height * 13; + .cke { + margin-bottom: $line-height; } .checkbox, diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb index da30985db..e7d36337f 100644 --- a/app/views/admin/budget_investments/edit.html.erb +++ b/app/views/admin/budget_investments/edit.html.erb @@ -21,7 +21,7 @@ maxlength: Budget::Investment.title_max_length %> -
+
<%= translations_form.text_area :description, maxlength: Budget::Investment.description_max_length, class: "html-area" %> diff --git a/app/views/admin/budget_phases/_form.html.erb b/app/views/admin/budget_phases/_form.html.erb index 5753603f1..f8e5cd964 100644 --- a/app/views/admin/budget_phases/_form.html.erb +++ b/app/views/admin/budget_phases/_form.html.erb @@ -22,21 +22,17 @@
<%= f.translatable_fields do |translations_form| %>
-
- <%= translations_form.text_area :description, - maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, - class: "html-area", - hint: t("admin.budget_phases.edit.description_help_text") %> -
+ <%= translations_form.text_area :description, + maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, + class: "html-area", + hint: t("admin.budget_phases.edit.description_help_text") %>
-
- <%= translations_form.text_area :summary, - maxlength: Budget::Phase::SUMMARY_MAX_LENGTH, - class: "html-area", - hint: t("admin.budget_phases.edit.summary_help_text") %> -
+ <%= translations_form.text_area :summary, + maxlength: Budget::Phase::SUMMARY_MAX_LENGTH, + class: "html-area", + hint: t("admin.budget_phases.edit.summary_help_text") %>
<% end %>
diff --git a/app/views/admin/dashboard/actions/_form.html.erb b/app/views/admin/dashboard/actions/_form.html.erb index c2d150c41..810726868 100644 --- a/app/views/admin/dashboard/actions/_form.html.erb +++ b/app/views/admin/dashboard/actions/_form.html.erb @@ -31,9 +31,7 @@ <%= f.text_field :short_description %>
-
- <%= f.text_area :description, class: "html-area" %> -
+ <%= f.text_area :description, class: "html-area" %>
diff --git a/app/views/admin/legislation/homepages/_form.html.erb b/app/views/admin/legislation/homepages/_form.html.erb index fea2d3a5b..a0758efed 100644 --- a/app/views/admin/legislation/homepages/_form.html.erb +++ b/app/views/admin/legislation/homepages/_form.html.erb @@ -15,12 +15,10 @@
<%= f.translatable_fields do |translations_form| %>
-
- <%= translations_form.text_area :homepage, - language: I18n.locale, - class: "html-area admin", - hint: t("admin.legislation.processes.form.homepage_description") %> -
+ <%= translations_form.text_area :homepage, + language: I18n.locale, + class: "html-area admin", + hint: t("admin.legislation.processes.form.homepage_description") %>
<% end %>
diff --git a/app/views/admin/legislation/milestones/_summary_form.html.erb b/app/views/admin/legislation/milestones/_summary_form.html.erb index 6b708c8c4..27442d377 100644 --- a/app/views/admin/legislation/milestones/_summary_form.html.erb +++ b/app/views/admin/legislation/milestones/_summary_form.html.erb @@ -6,7 +6,7 @@ <%= translatable_form_for [:admin, @process] do |f| %>
<%= f.translatable_fields do |translations_form| %> -
+
<%= translations_form.text_area :milestones_summary, class: "html-area" %>
<% end %> diff --git a/app/views/admin/poll/active_polls/_form.html.erb b/app/views/admin/poll/active_polls/_form.html.erb index 0911e09f1..5794b641f 100644 --- a/app/views/admin/poll/active_polls/_form.html.erb +++ b/app/views/admin/poll/active_polls/_form.html.erb @@ -6,7 +6,7 @@
<%= f.translatable_fields do |translations_form| %> -
+
<%= t("admin.active_polls.form.description.help_text") %> <%= translations_form.text_area :description, class: "html-area", maxlength: ActivePoll.description_max_length %> diff --git a/app/views/admin/poll/questions/answers/_form.html.erb b/app/views/admin/poll/questions/answers/_form.html.erb index 68114d2a6..53eceae17 100644 --- a/app/views/admin/poll/questions/answers/_form.html.erb +++ b/app/views/admin/poll/questions/answers/_form.html.erb @@ -14,7 +14,7 @@
<%= translations_form.text_field :title %>
-
+
<%= translations_form.text_area :description, maxlength: Poll::Question.description_max_length, class: "html-area" %>
<% end %> diff --git a/app/views/admin/site_customization/pages/_form.html.erb b/app/views/admin/site_customization/pages/_form.html.erb index 5a9475b03..b5a8b42c3 100644 --- a/app/views/admin/site_customization/pages/_form.html.erb +++ b/app/views/admin/site_customization/pages/_form.html.erb @@ -46,7 +46,7 @@
<%= translations_form.text_field :subtitle %>
-
+
<%= translations_form.text_area :content, class: "html-area admin" %>
<% end %> diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index 330931d59..3eff59f72 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -22,7 +22,7 @@
-
+
<%= translations_form.text_area :description, maxlength: Budget::Investment.description_max_length, class: "html-area" %> diff --git a/app/views/dashboard/polls/_question_answer_fields.html.erb b/app/views/dashboard/polls/_question_answer_fields.html.erb index b3e6d9e4e..3cf81e8ee 100644 --- a/app/views/dashboard/polls/_question_answer_fields.html.erb +++ b/app/views/dashboard/polls/_question_answer_fields.html.erb @@ -14,11 +14,9 @@
-
- <%= f.text_area :description, - maxlength: Poll::Question.description_max_length, - class: "html-area" %> -
+ <%= f.text_area :description, + maxlength: Poll::Question.description_max_length, + class: "html-area" %>
diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index 08b24eceb..155bb7da5 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -16,7 +16,7 @@
-
+
<%= translations_form.text_area :description, maxlength: Debate.description_max_length, class: "html-area" %> diff --git a/app/views/legislation/proposals/_form.html.erb b/app/views/legislation/proposals/_form.html.erb index e21a605f6..9985bfa03 100644 --- a/app/views/legislation/proposals/_form.html.erb +++ b/app/views/legislation/proposals/_form.html.erb @@ -15,7 +15,7 @@ hint: t("proposals.form.proposal_summary_note") %>
-
+
<%= f.text_area :description, maxlength: Legislation::Proposal.description_max_length, class: "html-area" %> diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 86f86e918..eba35f60d 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -21,7 +21,7 @@ hint: t("proposals.form.proposal_summary_note") %>
-
+
<%= translations_form.text_area :description, maxlength: Proposal.description_max_length, class: "html-area" %> diff --git a/spec/features/admin/site_customization/pages_spec.rb b/spec/features/admin/site_customization/pages_spec.rb index 42042f028..3671ba64a 100644 --- a/spec/features/admin/site_customization/pages_spec.rb +++ b/spec/features/admin/site_customization/pages_spec.rb @@ -86,10 +86,9 @@ describe "Admin custom pages" do scenario "Allows images in CKEditor", :js do visit edit_admin_site_customization_page_path(custom_page) + fill_in_ckeditor "Content", with: "Will add an image" - within(".ckeditor") do - expect(page).to have_css(".cke_toolbar .cke_button__image_icon") - end + expect(page).to have_css(".cke_toolbar .cke_button__image_icon") end end diff --git a/spec/support/matchers/have_ckeditor.rb b/spec/support/matchers/have_ckeditor.rb index 7e23245ec..8072ad511 100644 --- a/spec/support/matchers/have_ckeditor.rb +++ b/spec/support/matchers/have_ckeditor.rb @@ -1,15 +1,27 @@ RSpec::Matchers.define :have_ckeditor do |label, with:| - match do - return false unless has_css?(".ckeditor", text: label) + define_method :textarea_id do + find("label", text: label)[:for] + end - page.within(".ckeditor", text: label) do + define_method :ckeditor_id do + "#cke_#{textarea_id}" + end + + define_method :has_ckeditor? do + has_css?("label", text: label) && has_css?(ckeditor_id) + end + + match do + return false unless has_ckeditor? + + page.within(ckeditor_id) do within_frame(0) { has_content?(with) } end end failure_message do - if has_css?(".ckeditor", text: label) - text = page.within(".ckeditor", text: label) { within_frame(0) { page.text } } + if has_ckeditor? + text = page.within(ckeditor_id) { within_frame(0) { page.text } } "expected to find visible CKEditor '#{label}' with '#{with}', but had '#{text}'" else