@grammarly/editor-sdk

Overview

See the Text Editor SDK guide for installation options.

The Text Editor SDK can be configured according to your app's needs. For example, withElement accepts a configuration object as its optional second parameter:

import { init } from "@grammarly/editor-sdk";

const Grammarly = await init("YOUR_CLIENT_ID");

Grammarly.withElement(
  document.querySelector("textarea"),
  { document: { dialect: "british" } },
);

This allows your app to:

  • specify aspects of the input (DocumentConfig) to improve Grammarly suggestions
  • influence Grammarly suggestion types (SuggestionCategories)
  • react to events (onPluginDisable, onPluginError, onTextStats)

Refer to EditorConfig for full details.

Theming

CSS variables that allow you to theme your app are detailed in Customization.

Reference

  • ClientId — Identifier used to authenticate with Grammarly.
  • Dialect — Specific variety of English being written.
  • DocumentConfig — Characteristics and context of the document that inform Grammarly suggestions.
  • Domain — The style or type of writing to be checked.
  • Editor — An instance of Editor represents an HTML editor from your app enhanced with Grammarly.
  • EditorConfig — Configuration to customize the Grammarly integration.
  • EditorFactory — Factory that returns Editors, which represent HTML editors enhanced with Grammarly.
  • init() — Initialize Grammarly and start using EditorFactory to connect editors.
  • PluginDisableReason — Provides more detail when the plugin is disabled by a user.
  • SessionStats — Statistics about the Grammarly session.
  • SessionSuggestionBreakdown — Suggestion total along with counts by type.
  • SuggestionCategories — Categories of suggestions that can be muted.
  • TextStats — Statistics about the user-entered text.
  • Time — Time in hours, minutes, and seconds.
Last Updated: 10/14/2021, 7:00:57 PM