0
# Core Plugins
1
2
Essential plugins that provide fundamental editor functionality including history, debugging, DOM management, and node handling.
3
4
## Capabilities
5
6
### HistoryPlugin
7
8
Provides undo/redo functionality for the editor with configurable history stack management.
9
10
```typescript { .api }
11
/**
12
* History plugin for undo/redo functionality
13
*/
14
const HistoryPlugin: SlatePlugin;
15
```
16
17
**Usage Examples:**
18
19
```typescript
20
import { createSlateEditor, HistoryPlugin } from "@platejs/core";
21
22
const editor = createSlateEditor({
23
plugins: [HistoryPlugin]
24
});
25
26
// Undo last operation
27
editor.undo();
28
29
// Redo last undone operation
30
editor.redo();
31
```
32
33
### DebugPlugin
34
35
Development and debugging plugin with configurable logging and error handling.
36
37
```typescript { .api }
38
/**
39
* Debug plugin for development and error handling
40
*/
41
const DebugPlugin: SlatePlugin;
42
```
43
44
### DOMPlugin
45
46
Manages DOM state including focus, composition, and read-only states.
47
48
```typescript { .api }
49
/**
50
* DOM plugin for state management
51
*/
52
const DOMPlugin: SlatePlugin;
53
```
54
55
**Features:**
56
- Focus state management
57
- Composition event handling
58
- Read-only state control
59
- Keyboard event tracking
60
61
### ParserPlugin
62
63
Generic data format parsing system with extensible parser registration.
64
65
```typescript { .api }
66
/**
67
* Parser plugin for data format handling
68
*/
69
const ParserPlugin: SlatePlugin;
70
71
/**
72
* Register a custom parser for a specific data format
73
* @param format - Format identifier
74
* @param parser - Parser function
75
*/
76
function registerParser(
77
format: string,
78
parser: (data: string) => any[]
79
): void;
80
```
81
82
### NodeIdPlugin
83
84
Automatic node ID management for tracking and referencing editor nodes.
85
86
```typescript { .api }
87
/**
88
* Node ID plugin for automatic ID assignment
89
*/
90
const NodeIdPlugin: SlatePlugin;
91
```
92
93
### AstPlugin
94
95
Handles Slate AST fragment serialization for clipboard and drag-and-drop operations.
96
97
```typescript { .api }
98
/**
99
* AST plugin for fragment handling
100
*/
101
const AstPlugin: SlatePlugin;
102
```
103
104
### ChunkingPlugin
105
106
Performance optimization plugin that implements Slate's chunking for better typing performance.
107
108
```typescript { .api }
109
/**
110
* Chunking plugin for performance optimization
111
*/
112
const ChunkingPlugin: SlatePlugin;
113
```
114
115
### LengthPlugin
116
117
Character count limitations and length tracking functionality.
118
119
```typescript { .api }
120
/**
121
* Length plugin for character counting
122
*/
123
const LengthPlugin: SlatePlugin;
124
```
125
126
### AffinityPlugin
127
128
Controls mark and element boundary behavior for consistent selection handling.
129
130
```typescript { .api }
131
/**
132
* Affinity plugin for boundary behavior
133
*/
134
const AffinityPlugin: SlatePlugin;
135
```
136
137
### OverridePlugin
138
139
Plugin override system for customizing and extending existing plugin behavior.
140
141
```typescript { .api }
142
/**
143
* Override plugin for plugin customization
144
*/
145
const OverridePlugin: SlatePlugin;
146
```
147
148
### SlateExtensionPlugin
149
150
Opinionated extensions to Slate's default behavior for improved editor experience.
151
152
```typescript { .api }
153
/**
154
* Slate extension plugin for enhanced behavior
155
*/
156
const SlateExtensionPlugin: SlatePlugin;
157
```
158
159
### BaseParagraphPlugin
160
161
Default paragraph handling and normalization functionality.
162
163
```typescript { .api }
164
/**
165
* Base paragraph plugin for default text blocks
166
*/
167
const BaseParagraphPlugin: SlatePlugin;
168
```
169
170
## Plugin Configuration
171
172
Core plugins can be configured with options:
173
174
```typescript { .api }
175
interface CorePluginOptions {
176
/** History plugin options */
177
history?: {
178
maxSize?: number;
179
delay?: number;
180
};
181
/** Debug plugin options */
182
debug?: {
183
logLevel?: 'error' | 'warn' | 'info' | 'debug';
184
enabled?: boolean;
185
};
186
/** Length plugin options */
187
length?: {
188
maxLength?: number;
189
units?: 'character' | 'word';
190
};
191
}
192
```
193
194
**Usage Examples:**
195
196
```typescript
197
import { createSlateEditor, getCorePlugins } from "@platejs/core";
198
199
// Configure core plugins with options
200
const editor = createSlateEditor({
201
plugins: getCorePlugins().map(plugin => {
202
if (plugin.key === 'history') {
203
return {
204
...plugin,
205
options: { maxSize: 100, delay: 500 }
206
};
207
}
208
return plugin;
209
})
210
});
211
```
212
213
## Core Plugin Integration
214
215
All core plugins work together to provide:
216
217
- **Consistent Behavior**: Unified approach to editor operations
218
- **Type Safety**: Full TypeScript integration across all plugins
219
- **Performance**: Optimized for large documents and complex operations
220
- **Extensibility**: Easy to override or extend core functionality
221
- **Development Support**: Rich debugging and error handling capabilities