reopt designreopt design
DocsExploreToolsPricingBuilder
Start
Start
Playground
Core Concepts
Core Concepts
Editor
Editor 개요
Block Types
Streaming
Markdown Conversion
Build & Operate
Skills
App Composition Guide
AI Integration
Authoring Playbook
Custom Blocks
Release Notes
Oopt-editor
reopt designreopt design

A design system for the AI era

  • Docs
  • Pricing
  • Releases
  • GitHub
  • Terms of Service
  • Privacy Policy

© 2026 reopt-ai. All rights reserved.

Start
  1. Docs
  2. /
  3. Start
  4. /
  5. Start

Getting Started

Install opt-editor, create an editor store, and render the first structured editor.

reopt design · Updated Jun 26, 2026

StartPlaygroundCore ConceptsOverviewBlock TypesStreamingMarkdown ConversionSkillsApp Composition GuideAI IntegrationAuthoring PlaybookCustom BlocksRelease Notes

1. Install the package

@reopt-ai/opt-editor requires React 19 or newer as a peer dependency. It works without an extra styling library or external state manager.

bash
# npm
npm install @reopt-ai/opt-editor

# bun
bun add @reopt-ai/opt-editor

Peer dependencies:

PackageVersion
react^19.0.0
react-dom^19.0.0

Import the editor stylesheet once from your application entrypoint:

tsx
import "@reopt-ai/opt-editor/styles.css";

2. Render the first editor

Rendering an editor needs three pieces: create state with createEditorStore, provide context with EditorProvider, then render the Editor component.

tsx
"use client";

import { useMemo } from "react";
import {
  Editor,
  EditorProvider,
  createEditorStore,
  defaultCatalog,
} from "@reopt-ai/opt-editor";
import "@reopt-ai/opt-editor/styles.css";

export default function App() {
  const store = useMemo(() => createEditorStore(), []);

  return (
    <EditorProvider store={store} catalog={defaultCatalog}>
      <Editor store={store} catalog={defaultCatalog} mode="edit" />
    </EditorProvider>
  );
}
ModeUseBehavior
streamDisplay AI-generated contentRead-only rendering with live NDJSON patch updates
editLet users edit content directlycontentEditable blocks, Markdown shortcuts, slash commands

3. Provide initial content

Pass an EditorSpec into createEditorStore to seed the document. The spec has three top-level fields.

  • root - ordered IDs for top-level elements
  • elements - a flat map of every element by ID
  • version - an optimistic concurrency version that increments on mutation
tsx
const store = createEditorStore({
  root: ["h1", "p1"],
  elements: {
    h1: {
      id: "h1",
      type: "heading",
      props: { text: "Hello", level: 1 },
    },
    p1: {
      id: "p1",
      type: "paragraph",
      props: { text: "Welcome to **opt-editor**." },
    },
  },
  version: 1,
});

Why a flat map? AI streams can add elements without index shifts, RFC 6902 JSON Patch maps cleanly to updates, and any element can be reached in constant time.

4. Use edit mode

In mode="edit", users can modify the document directly.

  • contentEditable - click a text block and write directly into the store-backed document
  • Markdown shortcuts - type #, >, or ``` at the start of a line to transform the block
  • Slash commands - type / to insert heading, list, code, quote, divider, callout, table, and image blocks
  • Inline marks - render Markdown-like **bold**, *italic*, and `code` as formatted inline content
  • Undo and redo - call store.undo() and store.redo() to move through history
tsx
// Markdown shortcuts at the start of a line
// "# "      -> heading (level 1)
// "## "     -> heading (level 2)
// "> "      -> quote
// "```"    -> code block
// "- "      -> unordered list
// "1. "     -> ordered list
// "---"     -> divider

// Slash command examples
// "/"        -> open the block type menu
// "/heading" -> insert a heading block
// "/table"   -> insert a table block
// "/image"   -> insert an image block

5. Next steps

Once the first editor is running, continue with the deeper guides:

  • Core Concepts - Flat Spec architecture, EditorStore API, catalog, and validation
  • Block Type Reference - props, nesting rules, and rendering behavior for built-in blocks
  • AI Integration - prompts, SSE streams, and the useEditorStream hook
  • Streaming Protocol - NDJSON patch rules, StreamCompiler, retry, and resume behavior
NextCore ConceptsFlat Spec 아키텍처, 블록 시스템, 인라인 마크, EditorStore, 카탈로그 구조Core Concepts