FIX: do not generate multiple detail blocks when the selected input (#5290)

consists of multiple lines
This commit is contained in:
Kyle Zhao 2017-11-06 02:03:52 -05:00 committed by Sam
parent c9df21e131
commit c1926e6dd2
2 changed files with 26 additions and 1 deletions

View File

@ -18,7 +18,7 @@ function initializeDetails(api) {
"\n" + `[details="${I18n.t("composer.details_title")}"]` + "\n",
"\n[/details]\n",
"details_text",
{ multiline: true }
{ multiline: false }
);
this.set('optionsVisible', false);
}

View File

@ -90,3 +90,28 @@ test('details button', (assert) => {
assert.equal(textarea.selectionEnd, 49, 'it should end highlighting at the right position');
});
});
test('details button surrounds all selected text in a single details block', (assert) => {
const multilineInput = 'first line\n\nsecond line\n\nthird line';
visit("/");
click('#create-topic');
fillIn('.d-editor-input', multilineInput);
andThen(() => {
const textarea = findTextarea();
textarea.selectionStart = 0;
textarea.selectionEnd = textarea.value.length;
});
click('button.options');
click('.popup-menu .d-icon-caret-right');
andThen(() => {
assert.equal(
find(".d-editor-input").val(),
`\n[details="${I18n.t('composer.details_title')}"]\n${multilineInput}\n[/details]\n`,
'it should contain the right output'
);
});
});