0
# Editor Creation and Configuration
1
2
Core functionality for creating and configuring Slate editors with Plate enhancements, plugin integration, and comprehensive type safety.
3
4
## Capabilities
5
6
### createSlateEditor
7
8
Creates a new Slate editor instance with Plate enhancements and plugin integration.
9
10
```typescript { .api }
11
/**
12
* Creates a Slate editor with Plate enhancements
13
* @param options - Configuration options for the editor
14
* @returns Fully configured SlateEditor instance
15
*/
16
function createSlateEditor(options?: {
17
plugins?: any[];
18
value?: any[];
19
editor?: BaseEditor;
20
}): SlateEditor;
21
```
22
23
**Usage Examples:**
24
25
```typescript
26
import { createSlateEditor, getCorePlugins } from "@platejs/core";
27
28
// Create editor with core plugins
29
const editor = createSlateEditor({
30
plugins: getCorePlugins()
31
});
32
33
// Create editor with initial value
34
const editorWithValue = createSlateEditor({
35
plugins: getCorePlugins(),
36
value: [
37
{
38
type: 'p',
39
children: [{ text: 'Initial content' }]
40
}
41
]
42
});
43
```
44
45
### withSlate
46
47
Applies Plate enhancements to an existing Slate editor instance.
48
49
```typescript { .api }
50
/**
51
* Applies Plate enhancements to an existing editor
52
* @param editor - Base Slate editor instance
53
* @returns Enhanced SlateEditor with Plate features
54
*/
55
function withSlate(editor: BaseEditor): SlateEditor;
56
```
57
58
### getCorePlugins
59
60
Returns the default set of core plugins that provide essential editor functionality.
61
62
```typescript { .api }
63
/**
64
* Get the default core plugins for basic editor functionality
65
* @returns Array of core plugin instances
66
*/
67
function getCorePlugins(): CorePlugin[];
68
```
69
70
**Usage Examples:**
71
72
```typescript
73
import { createSlateEditor, getCorePlugins, createSlatePlugin } from "@platejs/core";
74
75
// Use core plugins with custom additions
76
const CustomPlugin = createSlatePlugin({
77
key: 'custom',
78
node: { type: 'custom' }
79
});
80
81
const editor = createSlateEditor({
82
plugins: [
83
...getCorePlugins(),
84
CustomPlugin
85
]
86
});
87
```
88
89
## Core Editor Features
90
91
The created editor instances include:
92
93
- **Plugin System Integration**: Automatic plugin loading and configuration
94
- **Type Safety**: Full TypeScript integration with inferred plugin types
95
- **API Extensions**: Plugin-specific API methods accessible via `editor.api`
96
- **Transform Methods**: Enhanced transform functions via `editor.transforms`
97
- **Event Handling**: Comprehensive event pipeline and hotkey support
98
- **State Management**: Built-in state management with plugin isolation