Skip to content

Type Editor


Type Editor / @type-editor/state / plugin/PluginKey / PluginKey

Class: PluginKey<PluginState>

Defined in: state/src/plugin/PluginKey.ts:13

A key is used to tag plugins in a way that makes it possible to find them, given an editor state. Assigning a key does mean only one plugin of that type can be active in a state.

Extends

Type Parameters

Type ParameterDefault type
PluginStateany

Implements

  • PmPluginKey<PluginState>

Constructors

Constructor

ts
new PluginKey<PluginState>(name?): PluginKey<PluginState>;

Defined in: state/src/plugin/PluginKey.ts:20

Create a plugin key.

Parameters

ParameterTypeDefault value
namestring'key'

Returns

PluginKey<PluginState>

Overrides

PluginBase.constructor

Accessors

key

Get Signature

ts
get key(): string;

Defined in: state/src/plugin/PluginKey.ts:25

Returns

string

Implementation of

ts
PmPluginKey.key;

Methods

createKey()

ts
protected createKey(name): string;

Defined in: state/src/plugin/PluginBase.ts:10

Creates a unique key by appending a counter to the given name. Each call with the same name increments the counter.

Parameters

ParameterType
namestring

Returns

string

Inherited from

PluginBase.createKey


get()

ts
get(state): PmPlugin<PluginState>;

Defined in: state/src/plugin/PluginKey.ts:33

Get the active plugin with this key, if any, from an editor state.

Parameters

ParameterType
statePmEditorState

Returns

PmPlugin<PluginState>

Implementation of

ts
PmPluginKey.get;

getState()

ts
getState(state): PluginState;

Defined in: state/src/plugin/PluginKey.ts:53

Get the plugin's state from an editor state.

Parameters

ParameterType
statePmEditorState

Returns

PluginState

Implementation of

ts
PmPluginKey.getState;