mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
compose: Remove extra blank line before lists.
Previously, inserting a bulleted or numbered list via the compose box added an extra blank line before and after the list. This commit removes the extra blank line inserted before the list. Fixes #32607.
This commit is contained in:
committed by
Tim Abbott
parent
c44c153b9a
commit
79be013882
@@ -658,14 +658,10 @@ export let format_text = (
|
||||
.split("\n")
|
||||
.map((line, i) => mark(line, i))
|
||||
.join("\n");
|
||||
// We always ensure a blank line before and after the list, as we want
|
||||
// We always ensure a blank line after the list, as we want
|
||||
// a clean separation between the list and the rest of the text, especially
|
||||
// when the markdown is rendered.
|
||||
|
||||
// Add blank line between text before and list if not already present.
|
||||
if (before_lines.length > 0 && before_lines.at(-1) !== "\n") {
|
||||
before_lines += "\n";
|
||||
}
|
||||
// Add blank line between list and rest of text if not already present.
|
||||
if (after_lines.length > 0 && after_lines.at(0) !== "\n") {
|
||||
after_lines = "\n" + after_lines;
|
||||
|
||||
@@ -696,6 +696,10 @@ run_test("format_text - bulleted and numbered lists", ({override_rewire}) => {
|
||||
compose_ui.format_text($textarea, "bulleted");
|
||||
assert.equal(get_textarea_state(), "<first_item\nsecond_item>");
|
||||
|
||||
init_textarea_state("before_first\n<* first_item\n* second_item>\nafter_last");
|
||||
compose_ui.format_text($textarea, "bulleted");
|
||||
assert.equal(get_textarea_state(), "before_first\n<first_item\nsecond_item>\nafter_last");
|
||||
|
||||
// Toggling on numbered list
|
||||
init_textarea_state("<first_item\nsecond_item>");
|
||||
compose_ui.format_text($textarea, "numbered");
|
||||
@@ -707,12 +711,12 @@ run_test("format_text - bulleted and numbered lists", ({override_rewire}) => {
|
||||
|
||||
init_textarea_state("before_first\nfirst_<item\nsecond>_item\nafter_last");
|
||||
compose_ui.format_text($textarea, "numbered");
|
||||
// // Notice the blank lines inserted right before and after the list to visually demarcate it.
|
||||
// // Notice the blank lines inserted right after the list to visually demarcate it.
|
||||
// // Had the blank line after `second_item` not been inserted, `after_last` would have been
|
||||
// // (wrongly) indented as part of the list's last item too.
|
||||
assert.equal(
|
||||
get_textarea_state(),
|
||||
"before_first\n\n<1. first_item\n2. second_item>\n\nafter_last",
|
||||
"before_first\n<1. first_item\n2. second_item>\n\nafter_last",
|
||||
);
|
||||
|
||||
// Toggling off numbered list
|
||||
|
||||
Reference in New Issue
Block a user