Euclides Rich Editor is built on top of ProseMirror, a powerful toolkit for building rich text editors. This page explains the core architecture and how it integrates with Angular.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/euclidesseg/euclides-workspace/llms.txt
Use this file to discover all available pages before exploring further.
ProseMirror Core Concepts
ProseMirror is built around three main concepts that work together to create a functional editor:EditorState
EditorState is the complete, immutable representation of the editor at any given moment. It contains:- The current document (all content)
- The selection (cursor position or text selection)
- Active plugins and their state
- Internal tracking information
The state is immutable. Every change creates a new state through transactions, making undo/redo and time-travel debugging possible.
EditorView
EditorView is the visual representation of the editor that renders in the DOM. It:- Takes an EditorState and displays it
- Handles user interactions (typing, clicking, selecting)
- Dispatches transactions to update the state
- Re-renders when the state changes
Schema
Schema is the “dictionary” that defines what types of content are allowed in your editor. It specifies:- What nodes exist (paragraph, heading, list, code_block, etc.)
- What marks exist (bold, italic, link, strike, etc.)
- How they parse from HTML and serialize back to HTML
- What attributes they can have
Angular Integration
Euclides Rich Editor bridges ProseMirror’s functional architecture with Angular’s component-based system.Component Structure
The main editor component isEuclidesRichEditorComponent (euclides-rich-editor.component.ts:20):
- ViewChild reference - Gets the DOM element where the editor will mount
- ngAfterViewInit - Creates the editor after Angular renders the view
- Services - Injects Angular services for commands and state management
EditorEngine: The Factory
TheEditorEngine class provides a factory method to create fully configured editor instances (editor-engine.ts:18):
This factory pattern separates ProseMirror initialization from Angular component lifecycle, making the code more testable and maintainable.
State Management Bridge
TheEditorStateService (editor-state.service.ts:4) bridges ProseMirror state with Angular’s reactive system:
Plugin System
Plugins extend the editor’s functionality. Euclides uses a modular plugin system (euclides-plugins.ts:31):What Plugins Do
Plugins can:- Handle keyboard shortcuts - Custom key bindings for formatting
- Implement undo/redo - History tracking and restoration
- Add input rules - Automatic formatting as you type (e.g.,
**bold**→ bold) - React to state changes - Update Angular services when editor state changes
- Modify transactions - Transform or validate changes before they’re applied
Data Flow
Here’s how data flows through the architecture:- User types → EditorView captures the event
- View creates transaction → Describes the change
- Plugins process transaction → Can modify or cancel it
- Transaction applied → Creates new EditorState
- View updates → Re-renders with new state
- Angular services notified → Update signals for UI reactivity
Command Pattern
Euclides uses Angular services to encapsulate editor commands (euclides-rich-editor.component.ts:41):- Keeps components focused on UI logic
- Makes commands reusable and testable
- Returns boolean indicating if the command succeeded
- Maintains focus after successful operations
Why This Architecture?
Separation of Concerns
Separation of Concerns
ProseMirror handles document model and editing logic, while Angular handles UI components and state management. Each does what it’s best at.
Immutability
Immutability
EditorState immutability makes undo/redo trivial, enables time-travel debugging, and prevents bugs from shared mutable state.
Extensibility
Extensibility
The plugin system allows adding features without modifying core code. New behaviors are composed through plugins.
Type Safety
Type Safety
TypeScript and ProseMirror’s schema system provide compile-time guarantees about document structure.
Next Steps
Schema
Learn how to define document structure
Nodes vs Marks
Understand content vs formatting
Editor State
Deep dive into state management