How to copy formatting from selected text?

Here is one of us that puzzled me. When I select text and paste it into any of Google’s applications, such as documents or a laptop, it somehow manages to insert text with its original formatting, and sometimes with images. Can someone tell me how to do this using javascript / jquery?

Edit: Another scenario that I am considering is designing a copy / paste mechanism on the server.

+3
source share
1 answer

You can use contenteditableto do this:

<div contenteditable="true">Stuff pasted in here will retain their original HTML</div>

Here is a simple demo for this: http://jsfiddle.net/AA3Kq/


, API- JavaScript. , , :

+6

Source: https://habr.com/ru/post/1793332/


All Articles