@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"),
{ documentDialect: "british" },
);
This allows your app to:
- specify information about the end user's input to improve Grammarly's 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
- init() — Initialize Grammarly. The ClientId must be passed another way.
- init(clientId, config, win) — Initialize Grammarly and start using EditorSDK to connect editors.
- ClientId — Identifier used to authenticate with Grammarly.
- Config — Configuration to customize the Grammarly integration.
- Dialect — Specific variety of English being written.
- DocumentStats — Statistics about the user-entered text.
- 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 per editor instance.
- EditorSDK — Overall API for the Editor SDK which can be used to create Editors, which represent HTML editors enhanced with Grammarly.
- Event — Custom event
- EventListener — Event handler callback
- GrammarlyButtonElement —
<grammarly-button>
is a web component that allows you to place the Grammarly button in a custom position in your app. - GrammarlyEditorPluginCallbacks —
- GrammarlyEditorPluginElement —
<grammarly-editor-plugin>
is a web component that adds Grammarly suggestions to the HTML element it wraps. Emits custom events: GrammarlyEditorPluginElementEventMap - GrammarlyEditorPluginElementEventMap — Custom events emitted by GrammarlyEditorPluginElement Try it outopen in new window
- SessionStats — Statistics about the Grammarly session.
- SessionSuggestionBreakdown — Suggestion total along with counts by type.
- SuggestionCategories — Categories of suggestions that can be muted.
- Time — Time in hours, minutes, and seconds.
- TonePosition — Position of the tone detectoropen in new window (if present) relative to the Grammarly button.
DocumentConfigdeprecated — Characteristics and context of the document that inform Grammarly suggestions.EditorFactorydeprecated — Factory that returns Editors, which represent HTML editors enhanced with Grammarly.OAuthConfigdeprecated — Configuration for connected accountsPluginDisableReasondeprecated — Provides more detail when the plugin is disabled by a user.SuggestionCategoriesDeprecateddeprecated — Categories of suggestions that can be muted.TextStatsdeprecated — Statistics about the user-entered text.UIConfigdeprecated — Configuration for the user interface of Grammarly.