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

Use tool bar button to insert tags at beginning and end of selected text

1 Answer 20 Views
Editor
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 16 Aug 2010, 09:59 PM
On a custom toolbar button click I would like to insert a start html tag at begining of  selected content and and an close tag at the end of the selection.

There is a help on inserting HTML tag at the beginning of the selection, the problem is inserted the close tag at the end of the selection

for example a user selcts some text in content area;
Telerik.Web.UI.Editor.CommandList["MyTestButton"] = function(commandName, editor, args)
{
   editor.pasteHtml(
'<TagBegin>');

       /*some way to find end of selection ???*/

   editor.pastHtml('<TagEnd>');
 
};

Thanks in advanced

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 19 Aug 2010, 12:00 PM
Hello John,

Here is an example how to implement your scenario using the getSelectionHtml method of RadEditor, e.g.

<telerik:radeditor runat="server" ID="RadEditor1">
    <Tools><telerik:EditorToolGroup>
        <telerik:EditorTool Name="MyTestButton" />
    </telerik:EditorToolGroup></Tools>
</telerik:radeditor>
<script type="text/javascript">
    Telerik.Web.UI.Editor.CommandList["MyTestButton"] = function (commandName, editor, args) {
        var selection = editor.getSelectionHtml();
        editor.pasteHtml('<My:StartTag>' + selection + '</My:EndTag>');
 
    };
</script>


All the best,
Rumen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Editor
Asked by
John
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or