Back to reference

EditorFactory

Factory that returns Editors, which represent HTML editors enhanced with Grammarly.

declare class EditorFactory {
  withElement(element: HTMLElement, config?: Partial<EditorConfig>): Editor;
  withQuerySelector(selectors: string, config?: Partial<EditorConfig>): void;
}

Examples:

const Grammarly = await init("YOUR_CLIENT_ID");
const editor = Grammarly.withElement(document.querySelector("textarea"));

Methods

withElement

Enhance a specific HTML element with Grammarly.

withElement(element: HTMLElement, config?: Partial<EditorConfig>): Editor;

Parameters

NameTypeDescription
elementHTMLElementElement to be enhanced
configPartial<EditorConfig>Optional EditorConfig

withQuerySelector

Enhance all elements that match provided selectors with Grammarly.

withQuerySelector(selectors: string, config?: Partial<EditorConfig>): void;

Parameters

NameTypeDescription
selectorsstringSelectors as provided to querySelectorAllopen in new window
configPartial<EditorConfig>Optional EditorConfig
Last Updated: 9/22/2021, 11:49:42 PM