Skip to content

textmode.js / plugins / TextmodePluginContext

Interface: TextmodePluginContext

Host facilities available while installing a plugin.

Methods

defineExtension()

ts
defineExtension<TTarget>(
   target, 
   propertyName, 
   descriptor): () => void;

Define one plugin-owned method or accessor on runtime objects.

Type Parameters

Type Parameter
TTarget extends TextmodeExtensionTarget

Parameters

ParameterType
targetTTarget
propertyNamestring
descriptorTextmodeExtensionDescriptor<TextmodeExtensionInstance<TTarget>>

Returns

A function that removes the extension.

() => void

Example

ts
context.defineExtension('textmodifier', 'effect', { value() {} });

on()

ts
on<K>(hook, callback): () => void;

Register a lifecycle hook or output transform.

Setup hooks may be asynchronous. Draw, layer, and output hooks must finish synchronously. Callbacks run in plugin installation order and then registration order.

Type Parameters

Type Parameter
K extends keyof TextmodePluginHookMap

Parameters

ParameterType
hookK
callbackTextmodePluginHookMap[K]

Returns

A function that unregisters the callback.

() => void

Example

ts
context.on('postDraw', () => updateOverlay());