Commit ec92e269 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '24020-copy-markdown-from-comments' into 'master'

Resolve "copy markdown from comments does often only  copy alt value of images"

See merge request gitlab-org/gitlab!24871
parents 2ac1c4cf b8638500
......@@ -327,7 +327,10 @@ export const getSelectedFragment = restrictToNode => {
documentFragment.originalNodes.push(range.commonAncestorContainer);
}
}
if (documentFragment.textContent.length === 0) return null;
if (documentFragment.textContent.length === 0 && documentFragment.children.length === 0) {
return null;
}
return documentFragment;
};
......
---
title: Fix copy markdown with elements with no text content
merge_request: 24020
author:
type: fixed
......@@ -52,6 +52,7 @@ describe('ShortcutsIssuable', function() {
return documentFragment;
});
};
describe('with empty selection', () => {
it('does not return an error', () => {
ShortcutsIssuable.replyWithSelectedText(true);
......@@ -297,5 +298,18 @@ describe('ShortcutsIssuable', function() {
});
});
});
describe('with a valid selection with no text content', () => {
it('returns the proper markdown', done => {
stubSelection('<img src="foo" alt="image" />');
ShortcutsIssuable.replyWithSelectedText(true);
setTimeout(() => {
expect($(FORM_SELECTOR).val()).toBe('> ![image](http://localhost:9876/foo)\n\n');
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