Hello, I have a question how to return selected text from editor in HTML format? getSelection method can be used for text only. I've been struggling with this for few days now. Any help would be highly appreciated.
Quill doesn't work with HTML, it works with own Delta format. But you can get HTML from selection easily with plain js and browser API (you can paste this snippet to your browser console to test it):
var selection = window.getSelection();
if (selection.rangeCount > 0) {
var range = selection.getRangeAt(0);
var documentFragment = range.cloneContents();
}
console.log(documentFragment || 'nothing selected');
@DmitrySkripkin thank you for your time. Your code doesn't seems to be doing what I was hoping for. It works for content outside of Quill but not for its content:
You can see an example I trying it on here: https://codepen.io/anon/pen/EbRVxV
result for me is below. I would expect first fragment to be surrounded in html too.

Check this CodePen
I was sure I posted comment with the link same day you add your last comment. Sorry.
DmitrySkripkin, thanks. The above example seems to work.
Most helpful comment
Check this CodePen
I was sure I posted comment with the link same day you add your last comment. Sorry.