Skip to content

Latest commit

 

History

History
71 lines (57 loc) · 2.34 KB

File metadata and controls

71 lines (57 loc) · 2.34 KB
hidden true
title Extensions API
sidebarTitle Overview

Extensions are the building blocks of SuperDoc. Every feature—from bold text to track changes—comes from an extension.

Understanding extensions

Extensions provide:

  • Commands - Actions like toggleBold() or insertTable()
  • Schema - Define what can exist in documents
  • Behavior - Keyboard shortcuts, input rules, events

Using extensions

You don't typically configure extensions directly. SuperDoc handles it:

```javascript Usage // These commands come from extensions editor.commands.toggleBold(); // Bold extension editor.commands.insertTable(); // Table extension editor.commands.acceptAllTrackedChanges(); // TrackChanges extension ```
import { SuperDoc } from 'superdoc';
import 'superdoc/style.css';

const superdoc = new SuperDoc({
  selector: '#editor',
  document: yourFile,
  onReady: (superdoc) => {
    const editor = superdoc.activeEditor;
    // These commands come from extensions
    editor.commands.toggleBold();        // Bold extension
    editor.commands.insertTable();       // Table extension
    editor.commands.acceptAllTrackedChanges();  // TrackChanges extension
  },
});

Extension categories

Core editing

Basic document capabilities:

Advanced features

Complex functionality:

Custom extensions

Build your own →

How extensions work

  1. Registration - Extensions load with the editor
  2. Schema definition - Define nodes/marks
  3. Command registration - Add to editor.commands
  4. Event handling - React to changes