Back to reference

Editor

An instance of Editor represents an HTML editor from your app enhanced with Grammarly.

declare class Editor {
  get config(): EditorConfig;
  disconnect(): void;
  get element(): GrammarlyEditorPluginElement;
  setConfig(config: EditorConfig): void;
}

Examples

// returns instance of Editor
const editor = Grammarly.withElement(document.querySelector("textarea"));

Properties

configEditorConfig
Current editor configuration
Since: v1.6.3

elementGrammarlyEditorPluginElement
Returns the GrammarlyEditorPlugin element directly if you need to connect to it after the DOM has changed.
Since: v1.7.5

Methods

disconnect()

Close Grammarly connection and clean up any state.

disconnect(): void;

setConfig()

Update editor configuration by merging new configuration with current configuration.

Setting a property to undefined would remove it, e.g., setConfig({ documentDialect: undefined }) would remove configured dialect.

setConfig(config: EditorConfig): void;

Parameters

NameTypeDescription
configEditorConfignew editor configuration
Last Updated: 3/14/2023, 9:49:03 PM