ContextMenuPlugin

The plugin that is embedded in the context menu of files, folders, rooms, images, video (audio).

Interface: IContextMenuPlugin.

Variables

contextMenuItems

Stores a collection of elements where the keys are the key parameters from the ContextMenuItem objects. A list for embedding into the context menu is generated based on this collection.

Type: collection of IContextMenuItem

Methods and their description

addContextMenuItem

Add a new context menu item.

Parameters:

NameTypeExampleDescription
contextMenuItemIContextMenuItemDefines a context menu item.

getContextMenuItems

Get all the context menu items.

getContextMenuItemsKeys

Get all the keys of the context menu items.

updateContextMenuItem

Update the context menu item.

Parameters:

NameTypeExampleDescription
contextMenuItemIContextMenuItemDefines a new context menu item.

Example

import {type IContextMenuItem, type IContextMenuPlugin} from "@onlyoffice/docspace-plugin-sdk"

class Plugin implements IContextMenuPlugin {
  contextMenuItems = new Map<string, IContextMenuItem>()

  addContextMenuItem = (item: IContextMenuItem): void => {
    this.contextMenuItems.set(item.key, item)
  }

  getContextMenuItems = (): Map<string, IContextMenuItem> => {
    return this.contextMenuItems
  }

  getContextMenuItemsKeys = (): string[] => {
    const keys = [...this.contextMenuItems].map(([key, item]) => {
      return key
    })
    return keys
  }

  updateContextMenuItem = (item: IContextMenuItem): void => {
    this.contextMenuItems.set(item.key, item)
  }
}

Get Help

  • If you have any questions about ONLYOFFICE DocSpace, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).