Skip to content

Commit e4b56c1

Browse files
authored
Add wrap_attributes option to website UI (#2456)
Adds HTML attribute wrapping dropdown to the options panel, allowing users to control how attributes are wrapped directly from the website. Previously this option was only available via the Additional Settings JSON field. Fixes #1306
1 parent 3cdf82e commit e4b56c1

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,19 @@ <h2>Options</h2>
148148
</div>
149149
</div>
150150

151+
<div>
152+
<p style="margin:6px 0 0 0">HTML attribute wrapping:</p>
153+
<select id="wrap-attributes">
154+
<option value="auto">Wrap when line is too long</option>
155+
<option value="force">Wrap each attribute</option>
156+
<option value="force-aligned">Wrap and align attributes</option>
157+
<option value="force-expand-multiline">Always wrap multiline</option>
158+
<option value="aligned-multiple">Align multiple attributes</option>
159+
<option value="preserve">Preserve wrapping</option>
160+
<option value="preserve-aligned">Preserve and align</option>
161+
</select>
162+
</div>
163+
151164
<div class="options-checkboxes">
152165
<input class="checkbox" type="checkbox" id="end-with-newline">
153166
<label for="end-with-newline">End script and style with newline?</label>

web/common-function.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function read_settings_from_cookie() {
7474
$('#keep-array-indentation').prop('checked', Cookies.get('keep-array-indentation') === 'on');
7575
$('#break-chained-methods').prop('checked', Cookies.get('break-chained-methods') === 'on');
7676
$('#indent-scripts').val(any(Cookies.get('indent-scripts'), 'normal'));
77+
$('#wrap-attributes').val(any(Cookies.get('wrap-attributes'), 'auto'));
7778
$('#additional-options').val(any(Cookies.get('additional-options'), '{}'));
7879
$('#space-before-conditional').prop('checked', Cookies.get('space-before-conditional') !== 'off');
7980
$('#wrap-line-length').val(any(Cookies.get('wrap-line-length'), '0'));
@@ -104,6 +105,7 @@ function store_settings_to_cookie() {
104105
Cookies.set('end-with-newline', $('#end-with-newline').prop('checked') ? 'on' : 'off', opts);
105106
Cookies.set('wrap-line-length', $('#wrap-line-length').val(), opts);
106107
Cookies.set('indent-scripts', $('#indent-scripts').val(), opts);
108+
Cookies.set('wrap-attributes', $('#wrap-attributes').val(), opts);
107109
Cookies.set('additional-options', $('#additional-options').val(), opts);
108110
Cookies.set('indent-inner-html', $('#indent-inner-html').prop('checked') ? 'on' : 'off', opts);
109111
Cookies.set('comma-first', $('#comma-first').prop('checked') ? 'on' : 'off', opts);
@@ -211,6 +213,7 @@ function beautify() {
211213
opts.keep_array_indentation = $('#keep-array-indentation').prop('checked');
212214
opts.break_chained_methods = $('#break-chained-methods').prop('checked');
213215
opts.indent_scripts = $('#indent-scripts').val();
216+
opts.wrap_attributes = $('#wrap-attributes').val();
214217
opts.brace_style = $('#brace-style').val() + ($('#brace-preserve-inline').prop('checked') ? ",preserve-inline" : "");
215218
opts.space_before_conditional = $('#space-before-conditional').prop('checked');
216219
opts.unescape_strings = $('#unescape-strings').prop('checked');

0 commit comments

Comments
 (0)