FIX: do not generate multiple detail blocks when the selected input (#5290)
consists of multiple lines
This commit is contained in:
parent
c9df21e131
commit
c1926e6dd2
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue