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

Removal of Context Menus

4 Answers 10 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 18 Jul 2019, 07:40 PM

I'd like to remove all context menu options except for "Open Link" on the hyperlink context menu.  I've tried to manually set the context menus (based off of old code found in the forums), but it doesn't seem to be working.  Is there a list somewhere that tells me ALL of the context menus so that I can disable them?  And am I missing something on the method of disabling them?  The snippet below represents a few things I've tried.  It seems to remove the context menu for "A", but that's the one I'm trying to keep (although I'd like to strip it down to the single "Open Link" option).

 

This is one of the workarounds I'm trying in regards to my other question from a few days ago (no answers on that one yet either)

 

Thanks so much for any help!

 

<ContextMenus>
    <telerik:EditorContextMenu TagName="P" Enabled="false">
        <telerik:EditorTool Name="JustifyLeft" Enabled="false" />
        <telerik:EditorTool Name="JustifyCenter" Visible="false" />
        <telerik:EditorTool Name="JustifyRight" Visible="false" />
        <telerik:EditorTool Name="JustifyFull" Visible="false" />
    </telerik:EditorContextMenu>
    <telerik:EditorContextMenu TagName="BODY" Enabled="false">
        <telerik:EditorTool Name="Cut" Visible="false" />
        <telerik:EditorTool Name="Copy" Visible="false" />
        <telerik:EditorTool Name="Paste" Visible="false" />
        <telerik:EditorTool Name="PasteFromWord" Visible="false" />
        <telerik:EditorTool Name="PastePlainText" Visible="false" />
        <telerik:EditorTool Name="PasteAsHtml" Visible="false" />
    </telerik:EditorContextMenu>
</ContextMenus>

4 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 19 Jul 2019, 11:18 AM

Hi,

You can predefine the context menu for A tags like this

 

        <telerik:RadEditor ID="RadEditor1" runat="server">
            <Content>
                <a href="https://www.google.com">Google link</a>
            </Content>
            <ContextMenus>
                <telerik:EditorContextMenu TagName="A">
                    <telerik:EditorTool Name="OpenLink" />
                </telerik:EditorContextMenu>
            </ContextMenus>
        </telerik:RadEditor>

Set the TagName to specify the tag for the context menus you'd like to disable:

                <telerik:EditorContextMenu TagName="Table" Enabled="false"></telerik:EditorContextMenu>
                <telerik:EditorContextMenu TagName="TR" Enabled="false"></telerik:EditorContextMenu>
                <telerik:EditorContextMenu TagName="TD" Enabled="false"></telerik:EditorContextMenu>
                <telerik:EditorContextMenu TagName="IMG" Enabled="false"></telerik:EditorContextMenu>
                <telerik:EditorContextMenu TagName="BODY" Enabled="false"></telerik:EditorContextMenu>

 

Regards, Rumen
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Craig
Top achievements
Rank 1
answered on 19 Jul 2019, 05:01 PM

Rumen,

  That got me most of the way there, but I still see the Cut/Copy/Paste/PasteFromWord/PastePlainText and PasteAsHtml if I right-click anywhere in the content of the editor (besides the Hyperlink... that is only showing the OpenLink... as desired).  I can live with this if I have to, but it'd be nice to remove them to avoid any confusion for users.

I'm still trying to get a natural, read-only version of the editor where a user can still use the ribbons.  This seems like it's going to be the closest I can get (the only difference being that a user will have to use a context menu to follow a link).

0
Craig
Top achievements
Rank 1
answered on 19 Jul 2019, 05:15 PM

I got it... I needed to use

 

<telerik:EditorContextMenu TagName="*" Enabled="false"></telerik:EditorContextMenu>

 

To block that last one

 

Thanks again for all your help!

0
Rumen
Telerik team
answered on 22 Jul 2019, 10:17 AM

You are welcome, Craig!

Indeed, the * symbol represents all HTML elements.

Regards, Rumen
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Editor
Asked by
Craig
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Craig
Top achievements
Rank 1
Share this question
or