demo_hardbreaks_setting.patch

Marius BALTEANU, 2021-07-27 01:29

Download (3.56 KB)

View differences:

app/views/settings/_general.html.erb
19 19

  
20 20
<p><%= setting_select :protocol, [['HTTP', 'http'], ['HTTPS', 'https']] %></p>
21 21

  
22
<p><%= setting_select :text_formatting, Redmine::WikiFormatting.formats_for_select, :blank => :label_none %></p>
23

  
22
<p><%= setting_select :text_formatting, Redmine::WikiFormatting.formats_for_select, :blank => :label_none %>
23
<label class="block <%= "hidden" unless Setting.text_formatting == "common_mark" %>">
24
  <%= setting_check_box :text_formatting_common_mark_hardbreaks, label: false %>
25
  <%= l(:setting_text_formatting_common_mark_hardbreaks) %>
26
</label>
27
</p>
24 28
<p><%= setting_check_box :cache_formatted_text %></p>
25 29

  
26 30
<p><%= setting_select :wiki_compression, [['Gzip', 'gzip']], :blank => :label_none %></p>
......
32 36

  
33 37
<%= submit_tag l(:button_save) %>
34 38
<% end %>
39

  
40
<%= javascript_tag do %>
41
  $('#settings_text_formatting').on('change', function(e){
42
    const formatter = e.target.value;
43
    const parent_block = document.getElementById("settings_text_formatting_common_mark_hardbreaks").parentElement;
44

  
45
    if (formatter == "common_mark") {
46
      parent_block.classList.remove('hidden');
47
    } else {
48
      parent_block.classList.add('hidden');
49
    }
50
  });
51
<% end %>
config/locales/en.yml
511 511
  setting_project_list_defaults: Projects list defaults
512 512
  setting_twofa: Two-factor authentication
513 513
  setting_default_issue_query: Default Query
514
  setting_text_formatting_common_mark_hardbreaks: "Use regular line breaks (\\n) as hardbreaks"
514 515

  
515 516
  permission_add_project: Create project
516 517
  permission_add_subprojects: Create subprojects
config/settings.yml
98 98
  default: 0
99 99
text_formatting:
100 100
  default: textile
101
text_formatting_common_mark_hardbreaks:
102
  default: 1
101 103
cache_formatted_text:
102 104
  default: 0
103 105
wiki_compression:
lib/redmine/wiki_formatting/common_mark/formatter.rb
43 43
        # https://github.com/gjtorikian/commonmarker#render-options
44 44
        commonmarker_render_options: [
45 45
          :UNSAFE
46
        ].freeze,
46
        ],
47 47
      }.freeze
48 48

  
49
      if Setting.text_formatting_common_mark_hardbreaks?
50
        PIPELINE_CONFIG[:commonmarker_render_options].push(:HARDBREAKS)
51
        PIPELINE_CONFIG[:commonmarker_render_options].freeze
52
      end
53

  
49 54
      MarkdownPipeline = HTML::Pipeline.new [
50 55
        MarkdownFilter,
51 56
        SanitizationFilter,
public/stylesheets/application.css
844 844
  float: none;
845 845
}
846 846

  
847
.tabular label.block.hidden {
848
  display: none;
849
}
850

  
847 851
.tabular label.inline{
848 852
  font-weight: normal;
849 853
  float:none;