Remove CKEditor divs

This way the HTML does not depend on CKEditor, and changing the editor
we use in textareas will require very few changes.
This commit is contained in:
Javi Martín
2019-10-25 17:00:18 +02:00
parent 6ef07f8a54
commit e844b0b2db
16 changed files with 46 additions and 45 deletions

View File

@@ -1072,8 +1072,8 @@ form {
margin: $line-height / 2 0 $line-height / 2 $line-height / 4; margin: $line-height / 2 0 $line-height / 2 $line-height / 4;
} }
.ckeditor { .cke {
min-height: $line-height * 13; margin-bottom: $line-height;
} }
.checkbox, .checkbox,

View File

@@ -21,7 +21,7 @@
maxlength: Budget::Investment.title_max_length %> maxlength: Budget::Investment.title_max_length %>
</div> </div>
<div class="ckeditor small-12 column"> <div class="small-12 column">
<%= translations_form.text_area :description, <%= translations_form.text_area :description,
maxlength: Budget::Investment.description_max_length, maxlength: Budget::Investment.description_max_length,
class: "html-area" %> class: "html-area" %>

View File

@@ -22,21 +22,17 @@
<div class="row"> <div class="row">
<%= f.translatable_fields do |translations_form| %> <%= f.translatable_fields do |translations_form| %>
<div class="small-12 column"> <div class="small-12 column">
<div class="ckeditor"> <%= translations_form.text_area :description,
<%= translations_form.text_area :description, maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH,
maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, class: "html-area",
class: "html-area", hint: t("admin.budget_phases.edit.description_help_text") %>
hint: t("admin.budget_phases.edit.description_help_text") %>
</div>
</div> </div>
<div class="small-12 column"> <div class="small-12 column">
<div class="ckeditor"> <%= translations_form.text_area :summary,
<%= translations_form.text_area :summary, maxlength: Budget::Phase::SUMMARY_MAX_LENGTH,
maxlength: Budget::Phase::SUMMARY_MAX_LENGTH, class: "html-area",
class: "html-area", hint: t("admin.budget_phases.edit.summary_help_text") %>
hint: t("admin.budget_phases.edit.summary_help_text") %>
</div>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@@ -31,9 +31,7 @@
<%= f.text_field :short_description %> <%= f.text_field :short_description %>
</div> </div>
<div class="ckeditor"> <%= f.text_area :description, class: "html-area" %>
<%= f.text_area :description, class: "html-area" %>
</div>
</div> </div>
</div> </div>

View File

@@ -15,12 +15,10 @@
<div class="row"> <div class="row">
<%= f.translatable_fields do |translations_form| %> <%= f.translatable_fields do |translations_form| %>
<div class="small-12 column"> <div class="small-12 column">
<div class="ckeditor"> <%= translations_form.text_area :homepage,
<%= translations_form.text_area :homepage, language: I18n.locale,
language: I18n.locale, class: "html-area admin",
class: "html-area admin", hint: t("admin.legislation.processes.form.homepage_description") %>
hint: t("admin.legislation.processes.form.homepage_description") %>
</div>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@@ -6,7 +6,7 @@
<%= translatable_form_for [:admin, @process] do |f| %> <%= translatable_form_for [:admin, @process] do |f| %>
<div class="row"> <div class="row">
<%= f.translatable_fields do |translations_form| %> <%= f.translatable_fields do |translations_form| %>
<div class="ckeditor column"> <div class="column">
<%= translations_form.text_area :milestones_summary, class: "html-area" %> <%= translations_form.text_area :milestones_summary, class: "html-area" %>
</div> </div>
<% end %> <% end %>

View File

@@ -6,7 +6,7 @@
<div class="row"> <div class="row">
<%= f.translatable_fields do |translations_form| %> <%= f.translatable_fields do |translations_form| %>
<div class="ckeditor column"> <div class="column">
<span class="help-text"><%= t("admin.active_polls.form.description.help_text") %></span> <span class="help-text"><%= t("admin.active_polls.form.description.help_text") %></span>
<%= translations_form.text_area :description, class: "html-area", <%= translations_form.text_area :description, class: "html-area",
maxlength: ActivePoll.description_max_length %> maxlength: ActivePoll.description_max_length %>

View File

@@ -14,7 +14,7 @@
<div class="column end"> <div class="column end">
<%= translations_form.text_field :title %> <%= translations_form.text_field :title %>
</div> </div>
<div class="ckeditor column"> <div class="column">
<%= translations_form.text_area :description, maxlength: Poll::Question.description_max_length, class: "html-area" %> <%= translations_form.text_area :description, maxlength: Poll::Question.description_max_length, class: "html-area" %>
</div> </div>
<% end %> <% end %>

View File

@@ -46,7 +46,7 @@
<div class="small-12 column"> <div class="small-12 column">
<%= translations_form.text_field :subtitle %> <%= translations_form.text_field :subtitle %>
</div> </div>
<div class="ckeditor column"> <div class="column">
<%= translations_form.text_area :content, class: "html-area admin" %> <%= translations_form.text_area :content, class: "html-area admin" %>
</div> </div>
<% end %> <% end %>

View File

@@ -22,7 +22,7 @@
</div> </div>
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div> <div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>
<div class="ckeditor small-12 column"> <div class="small-12 column">
<%= translations_form.text_area :description, <%= translations_form.text_area :description,
maxlength: Budget::Investment.description_max_length, maxlength: Budget::Investment.description_max_length,
class: "html-area" %> class: "html-area" %>

View File

@@ -14,11 +14,9 @@
<div class="row expanded"> <div class="row expanded">
<div class="small-12 column"> <div class="small-12 column">
<div class="ckeditor"> <%= f.text_area :description,
<%= f.text_area :description, maxlength: Poll::Question.description_max_length,
maxlength: Poll::Question.description_max_length, class: "html-area" %>
class: "html-area" %>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -16,7 +16,7 @@
</div> </div>
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div> <div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>
<div class="ckeditor small-12 column"> <div class="small-12 column">
<%= translations_form.text_area :description, <%= translations_form.text_area :description,
maxlength: Debate.description_max_length, maxlength: Debate.description_max_length,
class: "html-area" %> class: "html-area" %>

View File

@@ -15,7 +15,7 @@
hint: t("proposals.form.proposal_summary_note") %> hint: t("proposals.form.proposal_summary_note") %>
</div> </div>
<div class="ckeditor small-12 column"> <div class="small-12 column">
<%= f.text_area :description, <%= f.text_area :description,
maxlength: Legislation::Proposal.description_max_length, maxlength: Legislation::Proposal.description_max_length,
class: "html-area" %> class: "html-area" %>

View File

@@ -21,7 +21,7 @@
hint: t("proposals.form.proposal_summary_note") %> hint: t("proposals.form.proposal_summary_note") %>
</div> </div>
<div class="ckeditor small-12 column"> <div class="small-12 column">
<%= translations_form.text_area :description, <%= translations_form.text_area :description,
maxlength: Proposal.description_max_length, maxlength: Proposal.description_max_length,
class: "html-area" %> class: "html-area" %>

View File

@@ -86,10 +86,9 @@ describe "Admin custom pages" do
scenario "Allows images in CKEditor", :js do scenario "Allows images in CKEditor", :js do
visit edit_admin_site_customization_page_path(custom_page) 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")
expect(page).to have_css(".cke_toolbar .cke_button__image_icon")
end
end end
end end

View File

@@ -1,15 +1,27 @@
RSpec::Matchers.define :have_ckeditor do |label, with:| RSpec::Matchers.define :have_ckeditor do |label, with:|
match do define_method :textarea_id do
return false unless has_css?(".ckeditor", text: label) 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) } within_frame(0) { has_content?(with) }
end end
end end
failure_message do failure_message do
if has_css?(".ckeditor", text: label) if has_ckeditor?
text = page.within(".ckeditor", text: label) { within_frame(0) { page.text } } text = page.within(ckeditor_id) { within_frame(0) { page.text } }
"expected to find visible CKEditor '#{label}' with '#{with}', but had '#{text}'" "expected to find visible CKEditor '#{label}' with '#{with}', but had '#{text}'"
else else