Removal of Context Menus

5 posts, 1 answers
  1. Craig
    Craig avatar
    26 posts
    Member since:
    Jan 2019

    Posted 18 Jul 2019 Link to this post

    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>
  2. Answer
    Rumen
    Admin
    Rumen avatar
    14323 posts

    Posted 19 Jul 2019 Link to this post

    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.
  3. Craig
    Craig avatar
    26 posts
    Member since:
    Jan 2019

    Posted 19 Jul 2019 in reply to Rumen Link to this post

    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).

  4. Craig
    Craig avatar
    26 posts
    Member since:
    Jan 2019

    Posted 19 Jul 2019 in reply to Craig Link to this post

    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!

  5. Rumen
    Admin
    Rumen avatar
    14323 posts

    Posted 22 Jul 2019 Link to this post

    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.
Back to Top