CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-platejs--core

Core plugin system and editor functionality for the Plate rich text editor framework

Pending
Overview
Eval results
Files

editor-creation.mddocs/

Editor Creation and Configuration

Core functionality for creating and configuring Slate editors with Plate enhancements, plugin integration, and comprehensive type safety.

Capabilities

createSlateEditor

Creates a new Slate editor instance with Plate enhancements and plugin integration.

/**
 * Creates a Slate editor with Plate enhancements
 * @param options - Configuration options for the editor
 * @returns Fully configured SlateEditor instance
 */
function createSlateEditor(options?: {
  plugins?: any[];
  value?: any[];
  editor?: BaseEditor;
}): SlateEditor;

Usage Examples:

import { createSlateEditor, getCorePlugins } from "@platejs/core";

// Create editor with core plugins
const editor = createSlateEditor({
  plugins: getCorePlugins()
});

// Create editor with initial value
const editorWithValue = createSlateEditor({
  plugins: getCorePlugins(),
  value: [
    {
      type: 'p',
      children: [{ text: 'Initial content' }]
    }
  ]
});

withSlate

Applies Plate enhancements to an existing Slate editor instance.

/**
 * Applies Plate enhancements to an existing editor
 * @param editor - Base Slate editor instance
 * @returns Enhanced SlateEditor with Plate features
 */
function withSlate(editor: BaseEditor): SlateEditor;

getCorePlugins

Returns the default set of core plugins that provide essential editor functionality.

/**
 * Get the default core plugins for basic editor functionality
 * @returns Array of core plugin instances
 */
function getCorePlugins(): CorePlugin[];

Usage Examples:

import { createSlateEditor, getCorePlugins, createSlatePlugin } from "@platejs/core";

// Use core plugins with custom additions
const CustomPlugin = createSlatePlugin({
  key: 'custom',
  node: { type: 'custom' }
});

const editor = createSlateEditor({
  plugins: [
    ...getCorePlugins(),
    CustomPlugin
  ]
});

Core Editor Features

The created editor instances include:

  • Plugin System Integration: Automatic plugin loading and configuration
  • Type Safety: Full TypeScript integration with inferred plugin types
  • API Extensions: Plugin-specific API methods accessible via editor.api
  • Transform Methods: Enhanced transform functions via editor.transforms
  • Event Handling: Comprehensive event pipeline and hotkey support
  • State Management: Built-in state management with plugin isolation

Install with Tessl CLI

npx tessl i tessl/npm-platejs--core

docs

core-plugins.md

editor-creation.md

event-handling.md

html-serialization.md

index.md

multi-format-serialization.md

plugin-system.md

transform-functions.md

type-system.md

utility-functions.md

tile.json