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.
Overview
Plugins extend the behavior of the Euclides Rich Editor by adding functionality such as keyboard shortcuts, history management, custom input rules, and synchronization with Angular’s state management.buildPlugins()
ThebuildPlugins() function creates and returns an array of ProseMirror plugins in a specific order.
Signature
Parameters
stateService(EditorStateService): Angular service for state synchronization
Returns
An array of ProseMirror plugins configured for the editor.Plugin Order
Available Plugins
1. Euclides Keymap
Custom keyboard shortcuts specific to Euclides Editor.- Bold, italic, undo/redo
- List item splitting
- Code blocks
- Line breaks
2. Base Keymap
ProseMirror’s standard keyboard shortcuts.- Basic text editing (backspace, delete, etc.)
- Cursor movement
- Selection commands
- Platform-specific defaults
3. History Plugin
Enables undo/redo functionality.- Tracks document changes
- Maintains undo/redo stack
- Integrates with keyboard shortcuts (Ctrl+Z, Ctrl+Y)
4. History State Plugin
Synchronizes undo/redo availability with Angular’sEditorStateService.
History State Plugin
The History State Plugin bridges ProseMirror’s history system with Angular’s reactive signals.Implementation
How it Works
-
Initialization: The
view()function executes once when the plugin connects to the editor -
State Updates: The
updateState()function:- Calls
undoDepth(view.state)to check available undo steps - Calls
redoDepth(view.state)to check available redo steps - Updates Angular signals
canUndoandcanRedoaccordingly
- Calls
-
Reactivity: The
update()method executes on every editor change, keeping the UI in sync
Use Case
This plugin enables/disables undo and redo buttons in the Angular UI based on editor state:- If
undoDepth > 0, the undo button becomes enabled - If
redoDepth > 0, the redo button becomes enabled
Plugin Capabilities
Plugins can:- Add keyboard shortcuts (keymap)
- Track history for undo/redo (history)
- Define input rules for automatic transformations
- React to editor changes through view updates
- Modify editor state based on user actions
- Synchronize with external state (e.g., Angular services)
Source References
- Plugin builder:
~/workspace/source/projects/euclides-rich-editor/src/lib/engine/plugins/euclides-plugins.ts - History state plugin:
~/workspace/source/projects/euclides-rich-editor/src/lib/engine/plugins/history-buttons.plugin.ts