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

Rad Editor Context Menu In Preview Mode

3 Answers 105 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ivan Stoilkov
Top achievements
Rank 1
Ivan Stoilkov asked on 06 Jan 2009, 07:43 PM
Hi everyone! I have an issue with Rad Editor in Preview mode. It actually happens with IE7, but does not with FireFox 3.0.4. When I select a part of the editor's content, I expect to use the default context menu of IE. When I right-click my selection, it gets erased and I am also able to paste another text on the editor. The "copy" item of the context menu appears disabled, so I can't even select it.
If someone knows a way to fix that I would greatly appreciate.

Thanks,
Ivan

3 Answers, 1 is accepted

Sort by
0
Nikolay Raykov
Telerik team
answered on 08 Jan 2009, 12:48 PM
Hi Ivan,

We were able to confirm the behavior under IE7. The problem is not manifested in IE6, FF, Safari or Opera.
Our research showed that it is due to the following reasons:

By default, in IE the editor will re-direct the paste in a hidden container to examine it for MS Word formatting - and then prompt the user whether they want this formatting stripped. In order for this functionality to work, the editor attaches to both onbeforepaste and onpaste events.

The assumption is that the onbeforepaste event is only raised when a paste is about to occur (as IE documentation claims). However, this is not the case!

In fact, IE would raise the onbeforepaste even in multiple other cases - such as when showing the browser context menu, or when opening the Edit menu on the browser toolbar. Unfortunately, this causes unexpected results in the editor, as this no actual paste operation is really going to happen. This is how the IE7 problematic behavior occurs.

We were able to develop a workaround that we suggest for you for the time being until we integrate this solution into the editor itself.


<script type="text/javascript"
        function OnClientLoad(editor) 
        { 
            editor.add_modeChange(function() 
            {             
                var option = (editor.get_mode() == Telerik.Web.UI.EditModes.Preview) ? 
                            Telerik.Web.UI.StripFormattingOptions.NoneSupressCleanMessage :  
                            Telerik.Web.UI.StripFormattingOptions.None; 
                editor.set_stripFormattingOptions(option);             
            }); 
        }     
    </script> 

As it can be seen, the code is fired when editor modes are changed. If the mode is Preview, then the editor is "told" not to examine pasted content, so if onbeforepaste is raised, it has no effect on what the editor does. When mode is changed back to Design, the old default setting is restored.

Sincerely yours,
Nikolay Raykov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ivan Stoilkov
Top achievements
Rank 1
answered on 08 Jan 2009, 02:36 PM
Hi Nik,

Thank you for trying to help me with the problem.

I tried the script you suggested, but it still does not work. Even worst, when I select formatted text (i.e. “bolded”) it raises JavaScript exception. However, for not formatted text it still erases my selection on a right-click.

If you have another idea, I would greatly appreciate, because the Preview mode of the editor is a key feature in our project.

My goal is actually to use the editor to load text on the user’s browser in read-only mode. On that state, the user should be able to read the content and to use the editor’s “Print” button, to print-out the content.

Anything would work for me as long as this requirement is satisfied. I would be fine even if we can disable somehow the right-click on the editor’s page. I do not need the default context menu of IE7, but to stop erasing the text on right-click.

 

Thank you in advance!

Ivan

0
Ivan Stoilkov
Top achievements
Rank 1
answered on 08 Jan 2009, 03:04 PM
Hi Nik,
I used your idea to affect the Editor's behavior. By playing around with the script I got to a solution that perfectly works in my case. Well, because I am loading the Editor in Preview mode directly, I do not need to examine the mode state, so that's what I use:

<

 

script type="text/javascript" language="javascript">

 

 

    function OnClientLoad(editor, args)

 

    {

        editor.set_stripFormattingOptions(Telerik.Web.UI.StripFormattingOptions.NoneSupressCleanMessage);

    }

</

 

script>

 


This works perfect for me.
Thanks again!

Ivan
Tags
Editor
Asked by
Ivan Stoilkov
Top achievements
Rank 1
Answers by
Nikolay Raykov
Telerik team
Ivan Stoilkov
Top achievements
Rank 1
Share this question
or