mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
compose: Fix bug where extra line breaks were pasted between blocks.
Due to the way turndown pads every block element with 2 new lines, and makes `br` double space by default, we would get 3 blank lines pasted when there's just 1 line break between 2 paragraphs. Now we set `br` to an empty string, and since turndown collapses sequences of multiple new lines to `\n\n` (1 blank line), so any 2 block elements will now always have 1 blank line between them, irrespective of if and how many line breaks there are between them in the copied HTML.
This commit is contained in:
@@ -337,6 +337,7 @@ export function paste_handler_converter(paste_html) {
|
||||
emDelimiter: "*",
|
||||
codeBlockStyle: "fenced",
|
||||
headingStyle: "atx",
|
||||
br: "",
|
||||
});
|
||||
turndownService.addRule("style", {
|
||||
filter: "style",
|
||||
|
||||
@@ -97,6 +97,11 @@ run_test("paste_handler_converter", () => {
|
||||
"* bulleted\n* nested\n * nested level 1\n * nested level 1 continue\n * nested level 2\n * nested level 2 continue",
|
||||
);
|
||||
|
||||
// 2 paragraphs with line break/s in between
|
||||
input =
|
||||
'<meta http-equiv="content-type" content="text/html; charset=utf-8"><p>paragraph 1</p><br><p>paragraph 2</p>';
|
||||
assert.equal(copy_and_paste.paste_handler_converter(input), "paragraph 1\n\nparagraph 2");
|
||||
|
||||
// Pasting from external sources
|
||||
// Pasting list from GitHub
|
||||
input =
|
||||
|
||||
Reference in New Issue
Block a user