TypeScript type definitions for developing plugins for the Red editor.
npm install --save-dev @red-editor/typesor
yarn add -D @red-editor/typesIn your plugin's TypeScript file:
/// <reference types="@red-editor/types" />
export async function activate(red: Red.RedAPI) {
// Your plugin code with full type safety
red.addCommand("MyCommand", async () => {
const info = await red.getEditorInfo();
red.log(`Current buffer: ${info.buffers[info.current_buffer_index].name}`);
});
}Or with ES modules:
import type { RedAPI } from '@red-editor/types';
export async function activate(red: RedAPI) {
// Your plugin code
}See the Plugin System Documentation for detailed API usage.
The type definitions include:
- All Red API methods
- Event types with proper typing for event data
- Configuration structure
- Buffer and editor information interfaces
- Style and UI component types
If you find any issues with the type definitions or want to add missing types, please submit a pull request to the main Red editor repository.