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

pasteHtml issue, editor appears to lose focus?

1 Answer 70 Views
Editor
This is a migrated thread and some comments may be shown as answers.
DH
Top achievements
Rank 1
DH asked on 21 Sep 2015, 10:40 PM

Having an issue with an editor. Fairly certain it is not control version related, as it is working fine in a radwindow. 

 Editor (shortened it)

 

<telerik:RadEditor  ID="txtEditorBody" runat="server" Height="400px" Width="700px"   ContentAreaMode="Iframe" OnClientCommandExecuting="customTokens">
       <Tools>
           <telerik:EditorToolGroup Tag="MainToolbar">
               <telerik:EditorTool Name="AjaxSpellCheck" Visible="true" Enabled="true" />
               <telerik:EditorSeparator />
           </telerik:EditorToolGroup>
           <telerik:EditorToolGroup Tag="Formatting">
               <telerik:EditorTool Name="Bold" />
               <telerik:EditorSeparator />
               <telerik:EditorSplitButton Name="ForeColor">
               </telerik:EditorSplitButton>
               <telerik:EditorSeparator />
               <telerik:EditorDropDown Name="FontName">
               </telerik:EditorDropDown>
               <telerik:EditorDropDown Name="FontSize">
               </telerik:EditorDropDown>
           </telerik:EditorToolGroup>
           <telerik:EditorToolGroup>
               <telerik:EditorDropDown Name="Info" Width="50" Text="Info">
                   <telerik:EditorDropDownItem Name="First Name" Value=" %firstname% " />
               </telerik:EditorDropDown>
           </telerik:EditorToolGroup>
       </Tools>
       <Content>
       </Content>
       <TrackChangesSettings CanAcceptTrackChanges="False"></TrackChangesSettings>
   </telerik:RadEditor>

 

 Javascript:

 

function customTokens(editor, args) {
    var name = args.get_name();
    var val = args.get_value();
    if (name == "Info") {
        editor.pasteHtml(val);
        args.set_cancel(true);
    };
};

 

It seems that when the page loads, the cursor is not visible in the editor. If you type in it, it then becomes visible. When you ensure the cursor is in the editor, and then click the custom drop down, the cursor leaves the editor. After you click the drop down item, nothing happens, and the cursor does not return to the window. Interestingly if you hi-light some text and then click the drop down item, it just removes the hilighted text instead of inserting the value. 

Running a simple alert(name); and alert(val); shows that JS is pulling the correct info to insert, so the issue appears to be with editor.pastHtml()

Even trying something simple like OnLoad and then attempting pasteHtml("Test") does not work.

 

1 Answer, 1 is accepted

Sort by
0
Joana
Telerik team
answered on 25 Sep 2015, 07:57 AM
Hi Dan,

Let me summarize the issue and the desired behavior.
  1. You want the Editor to be focused when the page is loaded. This could be easily achieved as follows:
    function pageLoad() {
       $find("txtEditorBody").setFocus();
    }
  2. It is expected that the cursor will leave the editor once a dropdown is clicked or any other tool. However, once the dropdown item is selected the cursor should return to the editor and the respective command for the dropdown should be executed. On my side, this is what I observe and I am not able to reproduce the described behavior. I have attached a video.

Could you please give us more detailed information how to reproduce the issue:

  1. Is it browser specific?
  2. Are there any js errors that interrupt pasteHtml()?

You could open a support thread and send us a runnable project where we'll examine the prerequisites for replicating the issue.

I am looking forward to your reply.


Regards,
Joana
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Editor
Asked by
DH
Top achievements
Rank 1
Answers by
Joana
Telerik team
Share this question
or