fix: copy code-samples included \n\r characters

fixes #296
This commit is contained in:
Roman Hotsiy 2017-08-02 15:49:57 +03:00
parent 8193194e7a
commit cd962faba4
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -27,7 +27,10 @@ export class CopyButton implements OnInit {
onClick() {
let copied;
if (this.copyText) {
copied = Clipboard.copyCustom(JSON.stringify(this.copyText, null, 2));
const text = (typeof this.copyText === 'string')
? this.copyText
: JSON.stringify(this.copyText, null, 2);
copied = Clipboard.copyCustom(text);
} else {
copied = Clipboard.copyElement(this.copyElement);
}