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

About "Fire" function

3 Answers 127 Views
Editor
This is a migrated thread and some comments may be shown as answers.
HelloULi
Top achievements
Rank 1
HelloULi asked on 16 Apr 2008, 01:30 AM
When I tried to use fire() function to execute the editor's command, I found sometimes it did not run, such as: Copy, Cut, Paste, InsertTable, etc. But some command can be run correctly, such as: Bold. Why ? And would you please tell me how to send the command's param in the fire() function ? Thand you very much.

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 16 Apr 2008, 08:38 AM
Hi,

We need to research more time why the Fire method does not execute the Copy / Paste commands - it is most likely due to browser restrictions, however it is quite easy to override the built-in editor's Copy and Paste commands with the following code and execute the browser Copy and Paste commands:

<telerik:RadEditor ID="RadEditir1" runat="server"></telerik:RadEditor>
<script type="text/javascript">
Telerik.Web.UI.Editor.CommandList["Copy"] = function(commandName, editor, args)
{     
      editor.setFocus();
      editor.get_document().execCommand('Copy'); 

};

Telerik.Web.UI.Editor.CommandList["Paste"] = function(commandName, editor, args)
{     
      editor.setFocus();
      editor.get_document().execCommand('Paste'); 

};
</script>

Here is how to fire the InsertTable command through an external button and insert 3x3 table:

<telerik:RadEditor ID="RadEditor1" runat="server"></telerik:RadEditor>
<input type="button" value="Insert 5x5 table" onclick="InsertTableFn()" />
<script type="text/javascript">
function InsertTableFn()
{
     var editor = $find("<%=RadEditor1.ClientID%>");     
     editor.setFocus();
    
     var selValue =
     {
        cols:3,
        rows:3
     };
   
     var oTable = Telerik.Web.UI.Editor.Utils.createTable(selValue.rows, selValue.cols);
     if (selValue)
     {
        var oTable = Telerik.Web.UI.Editor.Utils.createTable(selValue.rows, selValue.cols);
        var outerHtml = Telerik.Web.UI.Editor.Utils.getOuterHtml(oTable);                   
        editor.pasteHtml(outerHtml, "InsertTable");
     }
};
</script>

Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
HelloULi
Top achievements
Rank 1
answered on 17 Apr 2008, 08:41 AM
Thank you very much for your answers. I want to know how can I get the detail help information about the editor's inline commands and the method about how to use them by fire() function ?
0
Rumen
Telerik team
answered on 17 Apr 2008, 02:09 PM
Hi Li,

There is not a complete documentation for firing all editor commands with the fire method, because some of them are not public. You can easily fire the editor's commands using the editor fire method that receives as an argument the command name, e.g.

    //execute the Fire method
    editor.fire(
"InsertOrderedList"); //this will insert numbered list item
    editor.fire("InsertUnorderedList"); //this will insert bullet
    editor.fire("Bold"); //will apply Bold formatting
    editor.Fire("Italic"); //
will apply Italic formatting

If you need to fire the command of some of the editor's dropdowns, please specify which one you want to use and we will try to provide a solution.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
HelloULi
Top achievements
Rank 1
Answers by
Rumen
Telerik team
HelloULi
Top achievements
Rank 1
Share this question
or