From cd962faba43332d90425849fa467a16df9202a67 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 2 Aug 2017 15:49:57 +0300 Subject: [PATCH] fix: copy code-samples included \n\r characters fixes #296 --- lib/shared/components/CopyButton/copy-button.directive.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/shared/components/CopyButton/copy-button.directive.ts b/lib/shared/components/CopyButton/copy-button.directive.ts index 6cd7810c..60384a14 100644 --- a/lib/shared/components/CopyButton/copy-button.directive.ts +++ b/lib/shared/components/CopyButton/copy-button.directive.ts @@ -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); }