Back to reference

GrammarlyEditorPluginElement

A web component to encapsulate DOM elements rendered for displaying highlights and suggestion cards.

Emits custom events: GrammarlyEditorPluginElementEventMap

declare class GrammarlyEditorPluginElement extends HTMLElement {
  addEventListener<K extends keyof GrammarlyEditorPluginElementEventMap>(type: K, listener: (this: HTMLElement, ev: GrammarlyEditorPluginElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
  get clientId(): ClientId | undefined;
  get config(): EditorConfig;
  connect(editor: EditorElement, viewport?: HTMLElement): void;
  removeEventListener<K extends keyof GrammarlyEditorPluginElementEventMap>(type: K, listener: (this: HTMLElement, ev: GrammarlyEditorPluginElementEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
}

Properties

clientIdClientId | undefined

configEditorConfig
Current editor configuration

Methods

addEventListener()

addEventListener<K extends keyof GrammarlyEditorPluginElementEventMap>(type: K, listener: (this: HTMLElement, ev: GrammarlyEditorPluginElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;

Parameters

NameTypeDescription
typeK
listener(this: HTMLElement, ev: GrammarlyEditorPluginElementEventMap[K]) => any
optionsboolean | AddEventListenerOptions | undefined

connect()

When inserted into the DOM, the GrammarlyEditorPlugin will automatically detect and connect to an editable child element (editor) and its scrollable container (viewport). This function provides a way to specify the editor and viewport, overriding what was automatically detected.

connect(editor: EditorElement, viewport?: HTMLElement): void;

Parameters

NameTypeDescription
editorEditorElementthe editable element
viewportHTMLElementscrollable outer element of the editable element

removeEventListener()

removeEventListener<K extends keyof GrammarlyEditorPluginElementEventMap>(type: K, listener: (this: HTMLElement, ev: GrammarlyEditorPluginElementEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;

Parameters

NameTypeDescription
typeK
listener(this: HTMLElement, ev: GrammarlyEditorPluginElementEventMap[K]) => any
optionsboolean | EventListenerOptions | undefined
Last Updated: 6/28/2022, 7:24:10 PM