A class responsible for building a menu for a ProseMirror instance.

Hierarchy (view full)

Constructors

Properties

Additional options to configure the plugin's behaviour.

#renderTarget: HTMLTemplateElement = ...

An HTML element that we write HTML to before injecting it into the DOM.

#editingSource: boolean = false

Track whether we are currently in a state of editing the HTML source.

_MENU_ITEM_SCOPES: {
    BOTH: string;
    TEXT: string;
    HTML: string;
} = ...

An enumeration of editor scopes in which a menu item can appear

Type declaration

  • BOTH: string
  • TEXT: string
  • HTML: string

Methods

  • Attach event listeners.

    Parameters

    • html: HTMLMenuElement

      The root menu element.

    Returns void

  • Called whenever the view's state is updated.

    Parameters

    • view: EditorView

      The current editor state.

    • prevState: EditorView

      The previous editor state.

    Returns void

  • Called when the view is destroyed or receives a state with different plugins.

    Returns void

  • Protected

    Instantiate the ProseMirrorDropDown instances and configure them with the defined menu items.

    Returns void

  • Protected

    Determine whether the given menu item is currently active or not.

    Parameters

    Returns boolean

    Whether the cursor or selection is in a state represented by the given menu item.

  • Protected

    Determine whether the given menu item representing a mark is active or not.

    Parameters

    Returns boolean

    Whether the cursor or selection is in a state represented by the given mark.

  • Protected

    Determine whether the given menu item representing a node is active or not.

    Parameters

    Returns boolean

    Whether the cursor or selection is currently within a block of this menu item's node type.

  • Protected

    Handle a button press.

    Parameters

    • event: MouseEvent

      The click event.

    Returns void

  • Protected

    Wrap the editor view element and inject our template ready to be rendered into.

    Returns void

  • Protected

    Handle requests to save the editor contents

    Returns any

  • Protected

    Handle a request to edit the source HTML directly.

    Returns void

  • Protected

    Display the insert image prompt.

    Returns Promise<void>

  • Protected

    Display the insert link prompt.

    Returns Promise<void>

  • Protected

    Display the insert table prompt.

    Returns Promise<void>

  • Protected

    Create a dialog for a menu button.

    Parameters

    • action: string

      The unique menu button action.

    • template: string

      The dialog's template.

    • Optional options: {
          data: object;
      } = {}

      Additional options to configure the dialog's behaviour.

      • data: object

        Data to pass to the template.

    Returns HTMLDialogElement

  • Protected

    Clear any marks from the current selection.

    Returns void

  • Protected

    Toggle link recommendations

    Returns Promise<void>

  • Protected

    Toggle the given selection by wrapping it in a given block or lifting it out of one.

    Parameters

    • node: NodeType

      The type of node being interacted with.

    • wrap: MenuToggleBlockWrapCommand

      The wrap command specific to the given node.

    • Optional options: {
          attrs: object;
      } = {}

      Additional options to configure behaviour.

      • attrs: object

        Attributes for the node.

    Returns void

  • Protected

    Toggle the given selection by wrapping it in a given text block, or reverting to a paragraph block.

    Parameters

    • node: NodeType

      The type of node being interacted with.

    • Optional options: {
          attrs: object;
      } = {}

      Additional options to configure behaviour.

      • attrs: object

        Attributes for the node.

    Returns void

  • Conclude editing the source HTML textarea. Clear its contents and return the HTML which was contained.

    Returns string

    The HTML text contained within the textarea before it was cleared

  • Create and activate the source code editing textarea

    Returns void

  • Commit changes from the source textarea to the view.

    Returns void

  • Handle keypresses while editing editor source.

    Parameters

    • event: KeyboardEvent

      The keyboard event.

    Returns void

  • Inserts a horizontal rule at the cursor.

    Returns void

  • Toggle a particular alignment for the given selection.

    Parameters

    • alignment: string

      The text alignment to toggle.

    Returns void

  • Build the plugin.

    Parameters

    • schema: any

      The ProseMirror schema to build the plugin against.

    • options: {} = {}

      Additional options to pass to the plugin.

      Returns Plugin<any>

      Abstract

    • Global listeners for the drop-down menu.

      Returns void