Back to reference

GrammarlyEditorPluginCallbacks

Callback functions for custom eventsopen in new window emitted by the Grammarly Text Editor Plugin.

interface GrammarlyEditorPluginCallbacks {
  onDocumentStats?: (event: CustomEvent<DocumentStats>) => void;
  onPluginError?: (event: CustomEvent<Error>) => void;
  onPluginTurnedOff?: (event: CustomEvent) => void;
  onSessionStats?: (event: CustomEvent<SessionStats>) => void;
  onSuggestionCardAction?: (event: CustomEvent<{
        action: /** Suggestion was accepted by the user. */ "accept" | /** Suggestion was dismissed by the user. */ "dismiss" | /** Suggestion card was closed by the user using close button. (excludes when closed due to click-outside) */ "close";
    }>) => void;
  onSuggestionCardClose?: (event: CustomEvent) => void;
  onSuggestionCardOpen?: (event: CustomEvent) => void;
}

Properties

onDocumentStatsoptionalType: (event: CustomEvent<DocumentStats>) => void

Triggered when new text information is available. This event can be used to track features of text as it is being written.

Since: v1.9.0

document-stats is available only on the Plus plan. Learn moreopen in new window about our plans.

onPluginErroroptionalType: (event: CustomEvent<Error>) => void

Triggered on fatal error with the plugin.

Since: v1.9.0

onPluginTurnedOffoptionalType: (event: CustomEvent) => void

Triggered when the user turns off Grammarly.

Since: v1.9.0

onSessionStatsoptionalType: (event: CustomEvent<SessionStats>) => void

Triggered when new session information is available. This event can be used to track information about the writing session.

Since: v1.9.0

session-stats is available only on the Plus plan. Learn moreopen in new window about our plans.

onSuggestionCardActionoptionalType: (event: CustomEvent<{ action: "accept" | "dismiss" | "close"; }>) => void

Triggered when a suggestion card is acted upon by the user (accept, dismiss, or close).

Since: v2.3.14

onSuggestionCardCloseoptionalType: (event: CustomEvent) => void

Triggered when a suggestion card is closed.

Since: v1.8.0

onSuggestionCardOpenoptionalType: (event: CustomEvent) => void

Triggered when a suggestion card is opened.

Since: v1.8.0

Last Updated: 5/16/2023, 7:11:22 PM