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
Euclides Rich Editor provides several text formatting options through theEditorCommandsService. These formatting options are implemented as marks in ProseMirror, which means they apply styles to text within a block without changing the document structure.
Available Formatting Methods
Bold Text
Toggle bold formatting using thetoggleBold method:
The
toggleBold method uses ProseMirror’s toggleMark command with the strong mark from the schema. It returns true if the command was successfully executed.Italic Text
Toggle italic formatting using thetoggleItailc method:
Strikethrough Text
Toggle strikethrough formatting using thetoggleStrike method:
Code Blocks
Convert a block to a code block using thetoggleCodeBlock method:
turnIntoCodeBlock method has special handling for lists. When converting a list to a code block, it extracts the text from all list items and creates a single code block:
How Marks Work
Text formatting in Euclides Editor is implemented using ProseMirror marks. Marks are inline styles that can be applied to ranges of text without changing the document structure.Mark Types in the Schema
The editor includes these marks fromprosemirror-schema-basic:
strong- Bold text (<strong>)em- Italic text (<em>)code- Inline code (<code>)link- Hyperlinks (<a>)
strike- Strikethrough text (<s>)
Toggle Behavior
All formatting methods use thetoggleMark command, which means:
- If the selection has the mark, it will be removed
- If the selection doesn’t have the mark, it will be added
- If part of the selection has the mark, it will be applied to the entire selection
Implementation Details
All formatting commands follow the same pattern:- Create a command using ProseMirror’s
toggleMarkfunction - Pass the mark type from
EuclidesEditorSchema.marks - Execute the command with the current editor state
- Return
trueif successful
~/workspace/source/projects/euclides-rich-editor/src/lib/core/editor-commands.service.ts:23-44
Best Practices
Always refocus the editor
After applying formatting, call
this.view.focus() to return focus to the editor:Check the return value
Formatting methods return
boolean to indicate success. Only refocus if the command succeeded:Next Steps
- Learn about Text Alignment for block-level formatting
- Explore Links for creating hyperlinks
- See Custom Schema to add your own marks like underline or highlight