Commit e3eb241f authored by Constance Okoghenun's avatar Constance Okoghenun Committed by Filipa Lacerda

Added tightLists option to copy_as_gfm markdown serializer

This removes extraneous newlines when copying comments
with an ordered list.
parent 4cfbe050
...@@ -173,7 +173,9 @@ export class CopyAsGFM { ...@@ -173,7 +173,9 @@ export class CopyAsGFM {
wrapEl.appendChild(node.cloneNode(true)); wrapEl.appendChild(node.cloneNode(true));
const doc = DOMParser.fromSchema(schema.default).parse(wrapEl); const doc = DOMParser.fromSchema(schema.default).parse(wrapEl);
const res = markdownSerializer.default.serialize(doc); const res = markdownSerializer.default.serialize(doc, {
tightLists: true,
});
return res; return res;
}) })
.catch(() => {}); .catch(() => {});
......
---
title: Fixed "Copying comment with ordered list includes extraneous newlines"
merge_request: 25695
author:
type: fixed
...@@ -55,15 +55,10 @@ describe 'Copy as GFM', :js do ...@@ -55,15 +55,10 @@ describe 'Copy as GFM', :js do
To see how GitLab looks please see the [features page on our website](https://about.gitlab.com/features/). To see how GitLab looks please see the [features page on our website](https://about.gitlab.com/features/).
* Manage Git repositories with fine grained access controls that keep your code secure * Manage Git repositories with fine grained access controls that keep your code secure
* Perform code reviews and enhance collaboration with merge requests * Perform code reviews and enhance collaboration with merge requests
* Complete continuous integration (CI) and CD pipelines to builds, test, and deploy your applications * Complete continuous integration (CI) and CD pipelines to builds, test, and deploy your applications
* Each project can also have an issue tracker, issue board, and a wiki * Each project can also have an issue tracker, issue board, and a wiki
* Used by more than 100,000 organizations, GitLab is the most popular solution to manage Git repositories on-premises * Used by more than 100,000 organizations, GitLab is the most popular solution to manage Git repositories on-premises
* Completely free and open source (MIT Expat license) * Completely free and open source (MIT Expat license)
GFM GFM
) )
...@@ -116,13 +111,11 @@ describe 'Copy as GFM', :js do ...@@ -116,13 +111,11 @@ describe 'Copy as GFM', :js do
<<~GFM, <<~GFM,
* [ ] Unchecked task * [ ] Unchecked task
* [x] Checked task * [x] Checked task
GFM GFM
<<~GFM <<~GFM
1. [ ] Unchecked ordered task 1. [ ] Unchecked ordered task
1. [x] Checked ordered task 1. [x] Checked ordered task
GFM GFM
) )
...@@ -551,7 +544,6 @@ describe 'Copy as GFM', :js do ...@@ -551,7 +544,6 @@ describe 'Copy as GFM', :js do
<<~GFM, <<~GFM,
* List item * List item
* List item 2 * List item 2
GFM GFM
...@@ -565,7 +557,6 @@ describe 'Copy as GFM', :js do ...@@ -565,7 +557,6 @@ describe 'Copy as GFM', :js do
# nested lists # nested lists
<<~GFM, <<~GFM,
* Nested * Nested
* Lists * Lists
GFM GFM
...@@ -578,7 +569,6 @@ describe 'Copy as GFM', :js do ...@@ -578,7 +569,6 @@ describe 'Copy as GFM', :js do
<<~GFM, <<~GFM,
1. Ordered list item 1. Ordered list item
1. Ordered list item 2 1. Ordered list item 2
GFM GFM
...@@ -592,7 +582,6 @@ describe 'Copy as GFM', :js do ...@@ -592,7 +582,6 @@ describe 'Copy as GFM', :js do
# nested ordered list # nested ordered list
<<~GFM, <<~GFM,
1. Nested 1. Nested
1. Ordered lists 1. Ordered lists
GFM GFM
......
...@@ -100,7 +100,7 @@ describe('CopyAsGFM', () => { ...@@ -100,7 +100,7 @@ describe('CopyAsGFM', () => {
simulateCopy(); simulateCopy();
setTimeout(() => { setTimeout(() => {
const expectedGFM = '* List Item1\n\n* List Item2'; const expectedGFM = '* List Item1\n* List Item2';
expect(clipboardData.setData).toHaveBeenCalledWith('text/x-gfm', expectedGFM); expect(clipboardData.setData).toHaveBeenCalledWith('text/x-gfm', expectedGFM);
done(); done();
...@@ -114,7 +114,7 @@ describe('CopyAsGFM', () => { ...@@ -114,7 +114,7 @@ describe('CopyAsGFM', () => {
simulateCopy(); simulateCopy();
setTimeout(() => { setTimeout(() => {
const expectedGFM = '1. List Item1\n\n1. List Item2'; const expectedGFM = '1. List Item1\n1. List Item2';
expect(clipboardData.setData).toHaveBeenCalledWith('text/x-gfm', expectedGFM); expect(clipboardData.setData).toHaveBeenCalledWith('text/x-gfm', expectedGFM);
done(); done();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment