This is a migrated thread and some comments may be shown as answers.

How to insert specified content into RichTextEditor?

3 Answers 497 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Xu
Top achievements
Rank 1
Xu asked on 09 Apr 2021, 06:24 AM

Hello everyone.

Since the richtexteditor control now supports setting a selection range programmatically, by the method EditBox.SelectionRange  = new RichTextSelectionRange(startPosition,endPosition);

I just need to know how to insert specified plain text or html code at the current selected range or cursor position?

I guess probably I can achieve this by invoking javascript, but the webView.EvaluateJavaScriptAsync("<Your JS goes here>") not seems to be exposed.

Thank you.

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 12 Apr 2021, 10:00 AM

Hello Xu,

For the time being RadRichTextEditor does not provide API for inserting/modifying the text at a specific location. 

Please add more details on concrete scenarios/use cases where such functionality would be beneficial in the feature request item in our feedback portal at the link below:

Please add the support for programmatically changing or inserting plain text/html code at the cursor point or replace the current selection.

Thank you in advance.

Regards,
Yana
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Xu
Top achievements
Rank 1
answered on 12 Apr 2021, 01:41 PM

Hello Yana,

Glad to be replied at another post from you.

Many thanks for your work.

Since "Add a comment" button is not responding on the feature request page for me, I'd like to post the scenario details here .

 

I thinks the inserting / modifying text (or html code) at a specific location is essential to a rich text document control, because many extra functions can be extended on this basis.

In my case, some of my app functions are closely connected to the feature:

1. Insert a table with custom row and column numbers.

I can easily do this if html code like <table><tr><td> could be inserted.

2. In my App, hyper links' urls are in a customized format to navigate to other Xamarin pages with specified constructor parameter. So the url format is probably like "{pagename.parameterid.modalOrPush}", which will also be easily achieved if I could insert codes like "<a href="{pagename.parameterid.modalOrPush}">HyperLinkText</a>" and handling the "OpenHyperlinkError" event to finish the rest work.

3. My app's documents are sharing a united beginning pattern: 

The first line is the document's title and the second line is the date time it was created, I will insert them at the start of the document if they don't exist.

For now I have to dump all the html code by RTE.GetHtmlAsync() and try to analyze the code to find the start of the html part, insert the beginning pattern to the string, and set the Source property again to make this happen.

4. For common rich text editing functions like keyword's "find and replace" /  "replace all", it won't be realizable unless  specific position's text could be selected, and replaced with new ones.

5. Actually inserting Base64 images may also be realized if html code inserting feature is completed.

 

Please let me know if I could be of any help.

 

Regards,

 

Xu

0
Yana
Telerik team
answered on 14 Apr 2021, 02:47 PM

Hello Xu,

Thank you for the nice words and for sending the detailed information. I completely understand the need of exposing method to insert html at a concrete position.

Furthermore, I noticed a few more feature requests that we consider would be a valuable addition to the RichTextEditor feature-set, so I logged them separately:

RichTextEditor: Provide a way to insert a table

RichTextEditor: Provide a way to insert images

RichTextEditor: Provide Find & Replace feature

We're going to track the demand and will schedule them accordingly.

I've updated your points for the detailed feedback on RichTextEditor control.

Regards,
Yana
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Xu
Top achievements
Rank 1
commented on 17 May 2021, 02:25 AM

Thank you Yana, really appreciate your help, glad to help improving telerik controls.
Chris
Top achievements
Rank 1
commented on 10 Aug 2022, 06:44 AM | edited

I know this is a little bit old but I did find a simplified solution to inserting text.

It is not quite as complete as the original posters request but it did suit my needs.

I use the clip board of the device and the past command of the richtexteditor.  It also will insert at the current selected point which defaults to the start if the user has not clicked somewhere else.

I used the Xamarin Essentials Clipboard class to get my text into the clipboard and then simply call the paste command on the richtexteditor passing in the correct param .... which did take some searching to find!

await Clipboard.SetTextAsync("Test Paste");
richTextEditor.PasteCommand.Execute(Telerik.XamarinForms.RichTextEditor.RichTextPasteType.Text);

Hope this is useful.

Cheers

Chris ...

Tags
RichTextEditor
Asked by
Xu
Top achievements
Rank 1
Answers by
Yana
Telerik team
Xu
Top achievements
Rank 1
Share this question
or