EditorSDK
Overall API for the Editor SDK which can be used to create Editors, which represent HTML editors enhanced with Grammarly.
declare class EditorSDK {
handleOAuthCallback(url: string): Promise<void>;
withElement(editor: HTMLElement, config?: EditorConfig, viewport?: HTMLElement): Editor;
withQuerySelector(selectors: string, config?: EditorConfig): void;
}
Examples
const Grammarly = await init("YOUR_CLIENT_ID");
const editor = Grammarly.withElement(document.querySelector("textarea"));
Methods
handleOAuthCallback()
Process OAuth callback and complete account connection.
handleOAuthCallback(url: string): Promise<void>;
Parameters
Name | Type | Description |
---|---|---|
url | string |
withElement()
Enhance a specific HTML element with Grammarly.
withElement(editor: HTMLElement, config?: EditorConfig, viewport?: HTMLElement): Editor;
Parameters
Name | Type | Description |
---|---|---|
editor | HTMLElement | Element to be enhanced |
config | EditorConfig | Optional EditorConfig |
viewport | HTMLElement | Parent scrolling element, if different from editor element (since 1.6.7) |
withQuerySelector()
Enhance all elements that match provided selectors with Grammarly.
withQuerySelector(selectors: string, config?: EditorConfig): void;
Parameters
Name | Type | Description |
---|---|---|
selectors | string | Selectors as provided to querySelectorAll open in new window |
config | EditorConfig | Optional EditorConfig |