Skip to content

Ability to control a plugin from outside (e.g. from an extension). #1282

Description

@tobiasfuhlroth

The problem I am facing
I'm implementing a Mention-like Extension using the Suggestion-Plugin and would like to access its internal state and/or trigger its methods. In my case i would like to use an Escape-KeyboardShortCut to close the Suggestion if it's active.

The solution I would like
A way to access the internal state and/or methods of the plugin.

Alternatives I have considered
Implementing the functionality inside the render function of the Suggestion – but i think that function should really only be handling the visual representation of the Suggestion.

Additional context
Internal state is accessible on state.suggestion$, but i don't think that it is meant to be accessed directly (https://github.com/ueberdosis/tiptap/blob/main/packages/suggestion/src/suggestion.ts#L130).

addKeyboardShortcuts () {
  return {
    Escape: () => this.editor.commands.command(({ tr, state }) => {
      // How to access `active` on the internal state? 
      // How to 'close' the suggestion if active?
    }),
  }
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions