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

Not allow copy any data in radeditor control

6 Answers 123 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Jiten
Top achievements
Rank 1
Jiten asked on 06 Jan 2015, 11:10 AM
Hello,

  I am looking to block any kind copy in radeditor control like CTRL+C and Mouse Right Click and copy option.


This is basic requirement of security for clinical prospective.
Please help me to solve this issue.

Thanks.

6 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 08 Jan 2015, 09:41 AM
Hello Jiten,

The following implementation should do the job:
<telerik:RadEditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad">
</telerik:RadEditor>
 
<script type="text/javascript">
    function OnClientLoad(sender, args) {
        // Disable copying from Design and Preview mode
        $telerik.addExternalHandler(sender.get_contentArea(), "copy", function myfunction(ev) {
            alert("This content cannot be copied!");
            $telerik.cancelRawEvent(ev);
        });
 
        // Disable copying from HTML mode
        $telerik.addExternalHandler(sender.get_textArea(), "copy", function myfunction(ev) {
            alert("This content cannot be copied!");
            $telerik.cancelRawEvent(ev);
        });
    }
</script>


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.

 
0
Jiten
Top achievements
Rank 1
answered on 08 Jan 2015, 11:06 AM
Thanks a lot.
Your solution is great.
0
Jiten
Top achievements
Rank 1
answered on 15 Jan 2015, 07:37 AM
Your solution working fine but my medical Illustration command link not enable in RadEditor. So I could not open the medical Illustration page.
Here is my code:
<telerik:RadEditor runat="server" ID="RTF1" EnableTextareaMode="false" Skin="Office2007" ContentFilters="None"
                                    Width="99%" Height="440px" AutoResizeHeight="false" StripFormattingOptions="NoneSupressCleanMessage"
                                    ToolsFile="~/Include/XML/WordProcessorEditorTools.xml" OnClientSelectionChange="OnClientSelectionChange"
                                    OnClientLoad="OnClientLoad" OnClientPasteHtml="OnClientPasteHtml">
                                    <CssFiles>
                                        <telerik:EditorCssFile Value="~/EditorContentArea.css" />
                                    </CssFiles>
                                    <SpellCheckSettings AllowAddCustom="true" />
                                    <ImageManager ViewPaths="~/medical_illustration" />
                                </telerik:RadEditor>


And Javascript:
<script type="text/javascript">
    function OnClientLoad(sender, args) {
        // Disable copying from Design and Preview mode
        $telerik.addExternalHandler(sender.get_contentArea(), "copy", function myfunction(ev) {
            alert("This content cannot be copied!");
            $telerik.cancelRawEvent(ev);
        });

        // Disable copying from HTML mode
        $telerik.addExternalHandler(sender.get_textArea(), "copy", function myfunction(ev) {
            alert("This content cannot be copied!");
            $telerik.cancelRawEvent(ev);
        });
    }
</script>
Also I attach image file. Please see the image and give me the solution.

I Hope will give me the solution.

Thanks.
0
Ianko
Telerik team
answered on 15 Jan 2015, 12:33 PM
Hi,

I am not sure if I can define how this custom command is related to the copy restriction or what is wrong with it.

Could you provide more details about it, so that I could understand the situation?

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.

 
0
Jiten
Top achievements
Rank 1
answered on 17 Jan 2015, 06:15 AM
I use this javascript code in OnClientLoad property to enable medical illustration link command in rad editor:
<script type='text/javascript'>
        function OnClientEditorLoad(editor, args) {
            var style = editor.get_contentArea().style;
            style.fontFamily = 'Tahoma';
            style.fontSize = 11 + 'pt';

            var mode = editor.get_mode();

            switch (mode) {
                case 4:
                    setTimeout(function() {
                        var ImageEditor = editor.getToolByName("ImageEditor");
                        var MedicalIllustration = editor.getToolByName("MedicalIllustration");
                        var ExportToRtf = editor.getToolByName("ExportToRtf");

                        ImageEditor.setState(0);
                        MedicalIllustration.setState(0);
                        ExportToRtf.setState(0);
                    }, 0);
                    break;
            }
        }
    </script>

Another point is restriction to copy the radeditor data I use OnClientLoad property in radeditor javascript code is here:
<script type="text/javascript">
    function OnClientLoad(sender, args) {
        // Disable copying from Design and Preview mode
        $telerik.addExternalHandler(sender.get_contentArea(), "copy", function myfunction(ev) {
            alert("This content cannot be copied!");
            $telerik.cancelRawEvent(ev);
        });

        // Disable copying from HTML mode
        $telerik.addExternalHandler(sender.get_textArea(), "copy", function myfunction(ev) {
            alert("This content cannot be copied!");
            $telerik.cancelRawEvent(ev);
        });
    }
</script>
I have achieved one functionality either medical illustration Link Command or restriction copy.

My Point is how we go these two functionalists in rad editor control.
I hope you understand my query.

Please help me as soon as possible.
Thanks your reply. I appreciate.
0
Ianko
Telerik team
answered on 20 Jan 2015, 08:55 AM
Hi,

The provided code is only an example, it is not a must to add it as it is in your code.

If you already have a handler method attached to the load event of the RadEditor you can further add the same logic to to implement the additional functionality. I.e., you need to merge the OnClientEditorLoad and the OnClientLoad methods.

If this is not the case, please provide exact details about the custom tools, the expected behavior and the result you are getting. Also, it would be best if you could isolate the difficulties encountered in a sample solution, so that I could be able to examine the exact situation and suggest proper solutions as per to the exact scenario.

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
Jiten
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Jiten
Top achievements
Rank 1
Share this question
or