How udecode/plate works
Project Type & Purpose
• This is an open-source monorepo (“Plate”) hosting a rich-text editor framework for React (slate-react).
• It’s organized as a Yarn / Turborepo workspace containing:
• Core library (packages/core)
• Dozens of plugin packages under packages/… (e.g., alignment, autoformat, media, yjs, etc.)
• Primitives and headless UI components
• A Next.js documentation site at apps/www
• Several starter templates under templates/…
• Tooling and CI config under tooling and .github
Key Top-Level Components
• Monorepo Orchestrator
• Yarn Workspaces & turbo.json — manages the build/test pipeline, hoists dependencies.
• Core Package
• packages/core — the heart of the Plate plugin system, exposes the plugin API & slate-react integrations.
• Plugin Packages
• packages/<feature> (e.g., autoformat, media, table, yjs) each implements a Base…Plugin + React wrapper.
• Primitives & Components
• UI primitives built on Radix UI under packages/* and apps/www/src/components/ui.
• Documentation Site
• Next.js app at apps/www — renders markdown (docs/…), Contentlayer, static and API routes (src/app/api/registry).
• Templates
• templates/plate-playground-template & templates/plate-template — project starters that wire core + plugins + Next.js.
• Tooling & CI
• tooling folder: ESLint configs, Playwright tests, Vitest, Turborepo watch scripts.
• .github/workflows: CI, release, lint, test, cache cleanup, registry sync.
Relationships & Data Flows
• The docs site depends on the registry of plugins and primitives generated by scripts (apps/www/scripts/*) and the @udecode/plate-* packages.
• Templates consume the same registry and packages/* to spin up new projects.
• CI pipelines (GitHub Actions) trigger Turborepo tasks: build, lint, test across all packages and the docs app.
• Tooling scripts in tooling/scripts scaffold new plugin packages, update the registry, or bump versions.
• At runtime, a consumer app:
• Installs core + selected plugin packages
• Configures a PlateProvider (from @udecode/plate-core) and registers plugins
• Renders the editor via Plate and optional UI components.
Architectural Patterns & Principles
• Monorepo / Turborepo: central orchestrator for builds & tests; workspace dependency graph.
• Plugin Architecture: Core defines plugin injection & pipelines; each feature is a self-contained plugin package.
• Headless vs. UI Layer: Plugins expose headless behavior; separate React wrapper packages for UI integration.
• Content Registry: Scripts generate a JSON registry consumed by the docs site and Playground.
• Template-Driven Development: Prewired project templates let users scaffold with minimal setup.