How can we get selected html text in kendo editor

1 Answer 507 Views
Editor
Lavanya
Top achievements
Rank 1
Lavanya asked on 23 Mar 2023, 12:37 PM

Hi Team,

I would like to get selected text along with html tags but getting only plain text by using

editor.getSelection() or editor.getRange() methods. Please help me to get html selected text 

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 28 Mar 2023, 07:32 AM

Hello, Lavanya,

I am not entirely certain if I understand the exact requirement, however you can retrieve the parent element of the text node like this:

        var selection = editor.getSelection();
        console.log($(selection.anchorNode).parent()[0].outerHTML);

Dojo

https://dojo.telerik.com/@gdenchev/EnEyewAj 

If you select the text and then click on the button, you'll see the following result in the console:

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Editor
Asked by
Lavanya
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or