|
1 | 1 | <div class="app-markdown-editor" data-module="ajax-markdown-preview" data-ajax-markdown-endpoint="<%= render_preview_path %>" data-i18n="<%= translations.to_json() %>"> |
2 | | - <label class="govuk-label govuk-label--m" for='<%= form_field_id %>'> |
3 | | - <h2 class="govuk-heading-m"><%= label %></h2> |
4 | | - </label> |
| 2 | + <% if label_heading %> |
| 3 | + <label class="govuk-label govuk-label--m" for='<%= form_field_id %>'> |
| 4 | + <h2 class="govuk-heading-m"><%= label %></h2> |
| 5 | + </label> |
| 6 | + <% else %> |
| 7 | + <label class="govuk-label" for='<%= form_field_id %>'><%= label %></label> |
| 8 | + <% end %> |
5 | 9 | <div class="govuk-hint" id="<%= form_field_id %>-hint"><%= hint %></div> |
6 | | - <%= govuk_tabs(title: nil) do |component| %> |
7 | | - <% component.with_tab(label: translations[:write_tab_text]) do %> |
| 10 | + <%= govuk_tabs(title: nil, id: "#{form_field_id}-tabs") do |component| %> |
| 11 | + <% component.with_tab(label: translations[:write_tab_text], id: "#{form_field_id}-write") do %> |
8 | 12 | <%= f.govuk_text_area(attribute_name, |
9 | 13 | label: nil, |
10 | 14 | hint: nil, |
11 | 15 | rows: 15, |
12 | 16 | id: "#{form_field_id}", |
| 17 | + lang:, |
13 | 18 | aria: { describedby: "#{form_field_id}-hint" }, |
14 | 19 | "data-module": "markdown-editor-toolbar", |
15 | 20 | "data-ajax-markdown-source": true, |
|
51 | 56 | <% end %> |
52 | 57 | <% end %> |
53 | 58 |
|
54 | | - <% component.with_tab(label: translations[:preview_tab_text]) do %> |
55 | | - <% if preview_html.present? %> |
| 59 | + <% component.with_tab(label: translations[:preview_tab_text], id: "#{form_field_id}-preview") do %> |
| 60 | + <% if preview_html.present? || render_preview_path.present? %> |
56 | 61 | <div class="app-markdown-editor__preview-intro"> |
57 | 62 | <h2 class="govuk-heading-m"><%= translations[:preview_heading] %></h2> |
58 | 63 |
|
59 | 64 | <p><%= translations[:preview_description] %></p> |
60 | 65 | </div> |
61 | 66 |
|
62 | 67 | <div class="app-markdown-editor__preview-area" role="region" aria-label="<%= translations[:preview_area_label] %>" data-ajax-markdown-target> |
63 | | - <%= preview_html.html_safe %> |
| 68 | + <%= preview_html&.html_safe %> |
64 | 69 | </div> |
65 | 70 |
|
66 | 71 | <%= govuk_link_to translations[:edit_markdown_link], "##{form_field_id}", class: "app-markdown-editor__edit-link" %> |
|
0 commit comments