Back to reference

Editor

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

See EditorConfig to customize per editor instance.

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

Examples

// returns instance of GrammarlyEditorPluginElement
const grammarlyPluginElement = Grammarly.addPlugin(document.querySelector("textarea"));

Properties

configType: EditorConfig

Current editor configuration

Since: v1.6.3


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: 1/30/2023, 10:49:17 PM