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

Fire the editors paste command from a button outside the editor

1 Answer 31 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dave Miller
Top achievements
Rank 2
Dave Miller asked on 14 Nov 2014, 06:08 PM
I am using the editor as a textbox and want to use a button outside the editor to fire it's paste command.
The function below works to insert text but what I am trying to do is paste a screenshot from the clipboard into the editor using IE 11 clipboardData.

function Paste() {

var editor = $find("<%=RadEditor1.ClientID%>");
//var clipBoardData = window.clipboardData.getData("URL");
editor.setFocus();
editor.pasteHtml("1234");
}

Using the editor's paste button works for this but I am trying to use the editor to load the screenshot and as a large preview textbox before saving it.

when I hide the toolbar if you put the cursor in the editor and do a ctrl - v it does paste the screenshot but if you right click there is no paste option.

I am trying to have a paste button outside the editor to make it more intuitive for the users.


Thanks in advance,
Dave

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 19 Nov 2014, 07:50 AM
Hi Dave,

Thank you for contacting the Telerik support.

I might be wrong, but it seems to me that the requirement is to replicate the native paste command of the browser via external button.

You can achieve this by using the executeBrowserComamnd method:
<telerik:RadEditor ID="RadEditor1" runat="server">
</telerik:RadEditor>
 
<telerik:RadButton runat="server" ID="RadButton1" AutoPostBack="false"
    OnClientClicked="OnClientClicked" text="Paste"></telerik:RadButton>
 
<script type="text/javascript">
    function OnClientClicked() {
        var editor = $find("<%=RadEditor1.ClientID %>");
 
        editor.executeBrowserCommand("Paste");
    }
</script>

Under IE browsers, this will behave as if the Ctrl+V shortcut is pressed.

If I am wrong about the required button's behavior, please provide more details, so that I could better understand the situation.

I am looking forward to your reply.

Regards,
Ianko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Editor
Asked by
Dave Miller
Top achievements
Rank 2
Answers by
Ianko
Telerik team
Share this question
or