Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy text as HTML #80

Open
DDeis opened this issue Oct 5, 2017 · 3 comments
Open

Copy text as HTML #80

DDeis opened this issue Oct 5, 2017 · 3 comments

Comments

@DDeis
Copy link

DDeis commented Oct 5, 2017

I'm have HTML text in a variable (e.g. const html = '<strong>Hello <em>world</em></strong>';).
When I'm copying this variable using clipboardService.copyFromContent:

const html = `
  <h1>Just a title</h1>
  <p>
    <strong>Hello <em>world</em></strong>
  </p>
`
this.clipboardService.copyFromContent(html, this.renderer);

Then paste it into a mail the pasted text is

<h1>Just a title</h1><p><strong>Hello <em>world</em></strong></p>

Is there a way to copy text as HTML so it stays formatted when pasted, i.e. having the titles in big font size, bold text, italic, etc.

On a previous project on AngularJS, I was using https://www.npmjs.com/package/clipboard-js (not https://www.npmjs.com/package/clipboard) and it was working fine, so maybe it can be possible with this library as well ?

@maxisam
Copy link
Owner

maxisam commented Oct 5, 2017

Interesting. But currently, I am swamped with my work projects. I don't think I will implement it anytime soon.

@stevenernst131
Copy link

@DDeis did you ever find a work around for your specific case? I am trying to do the same thing.

@DDeis
Copy link
Author

DDeis commented Jun 26, 2018

Hi @stevenernst131, a bit late but to answer your question, I used clipboard-js library which is now depracated and replaced by clipboard-polyfill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants