仅在选择文本时显示上下文菜单命令

时间:2019-03-01 14:00:58

标签: office-js

我在清单中使用以下xml来显示一些上下文菜单控件:

      <ExtensionPoint xsi:type="ContextMenu">
        <!--The id of the menu specifies the existing context menu being extended-->
        <!--ContextMenuCell (Excel) and ContextMenuText (Word) are currently supported-->
      <OfficeMenu id="ContextMenuText">
        <Control xsi:type="Menu" id="Contoso.TestMenu2">
          <Label resid="Contoso.Group1Label" />
          <Supertip>
            <Title resid="Contoso.TaskpaneButton.Label" />
            <Description resid="Contoso.TaskpaneButton.Tooltip" />
          </Supertip>
          <Icon>
              <bt:Image size="16" resid="Contoso.tpicon_16x16" />
              <bt:Image size="32" resid="Contoso.tpicon_32x32" />
              <bt:Image size="80" resid="Contoso.tpicon_80x80" />
          </Icon>
          <Items>
            <Item id="showGallery2">
              <Label resid="Contoso.TaskpaneButton.Label"/>
              <Supertip>
                <Title resid="Contoso.TaskpaneButton.Label" />
                <Description resid="Contoso.TaskpaneButton.Tooltip" />
              </Supertip>
              <Icon>
              <bt:Image size="16" resid="Contoso.tpicon_16x16" />
              <bt:Image size="32" resid="Contoso.tpicon_32x32" />
              <bt:Image size="80" resid="Contoso.tpicon_80x80" />
          </Icon>
              <Action xsi:type="ShowTaskpane">
                <!--TaskPaneId is required. It is currently not used by the framework but it will be in a future iteration -->
                <TaskpaneId>ButtonId1</TaskpaneId>
                <!--The URL to show inside the taskpane -->
                <SourceLocation resid="Contoso.Taskpane.Url" />
              </Action>
            </Item>
          <Item id="showGallery3">
              <Label resid="Contoso.TaskpaneButton.Label"/>
              <Supertip>
                <Title resid="Contoso.TaskpaneButton.Label" />
                <Description resid="Contoso.TaskpaneButton.Tooltip" />
              </Supertip>
              <Icon>
              <bt:Image size="16" resid="Contoso.tpicon_16x16" />
              <bt:Image size="32" resid="Contoso.tpicon_32x32" />
              <bt:Image size="80" resid="Contoso.tpicon_80x80" />
          </Icon>
              <Action xsi:type="ShowTaskpane">
                <TaskpaneId>ButtonId1</TaskpaneId>
                <SourceLocation resid="Contoso.Taskpane.Url" />
              </Action>
            </Item>
          </Items>
        </Control>
      </OfficeMenu>
     </ExtensionPoint> 

这很好,但是即使没有选择任何文本,我的上下文菜单项也始终显示。有没有一种方法只能在选择某些文本时显示它们?

此外,它仅显示在桌面客户端上,而不显示在Web客户端(Chrome浏览器)上...是否也可以将其添加到Web应用程序中?

0 个答案:

没有答案