pub struct MarkdownEditor { /* private fields */ }Expand description
Coordinated markdown editor that owns both the text Editor and the
MarkdownTree. After every mutation that changes text content, the tree
is automatically synced via set_source(). This is the single
coordination point — callers should never need to manually sync.
Implementations§
Source§impl MarkdownEditor
impl MarkdownEditor
Sourcepub fn editor_mut(&mut self) -> &mut Editor
pub fn editor_mut(&mut self) -> &mut Editor
Mutable access to the inner Editor.
Important: If you mutate the editor text through this reference
(e.g., via MarkdownCommands, InputRules, or direct calls to
insert(), backspace(), undo(), redo(), etc.), you must call
sync_tree() afterward to keep the tree in sync.
Sourcepub fn tree(&self) -> &MarkdownTree
pub fn tree(&self) -> &MarkdownTree
Immutable access to the MarkdownTree.
Sourcepub fn sync_tree(&mut self)
pub fn sync_tree(&mut self)
Full reparse of the tree from the editor’s current text.
Call this after using editor_mut() to make direct mutations.
Sourcepub fn insert(&mut self, text: &str)
pub fn insert(&mut self, text: &str)
Insert text at the cursor. If there’s a selection, replace it.
Sourcepub fn delete_forward(&mut self)
pub fn delete_forward(&mut self)
Delete the character after the cursor (forward delete).
Sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Insert a newline at the cursor.
Sourcepub fn delete_selection(&mut self)
pub fn delete_selection(&mut self)
Delete the current selection. No-op if cursor only.
Sourcepub fn apply_transaction(&mut self, tx: Transaction)
pub fn apply_transaction(&mut self, tx: Transaction)
Apply a pre-built transaction atomically.
Sourcepub fn duplicate_lines(&mut self)
pub fn duplicate_lines(&mut self)
Duplicate the current line or all selected lines.
Sourcepub fn delete_word_back(&mut self)
pub fn delete_word_back(&mut self)
Delete from cursor to start of previous word (Ctrl+Backspace).
Sourcepub fn delete_word_forward(&mut self)
pub fn delete_word_forward(&mut self)
Delete from cursor to end of next word (Ctrl+Delete).
Sourcepub fn selected_text(&self) -> String
pub fn selected_text(&self) -> String
Get the selected text, or empty string if cursor only.
Sourcepub fn set_cursor(&mut self, pos: Position)
pub fn set_cursor(&mut self, pos: Position)
Set the cursor to a position, collapsing any selection.
Sourcepub fn set_selection(&mut self, anchor: Position, head: Position)
pub fn set_selection(&mut self, anchor: Position, head: Position)
Set a selection range.
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Select all text.
Sourcepub fn move_right(&mut self)
pub fn move_right(&mut self)
Move cursor right by one character.
Sourcepub fn move_word_left(&mut self)
pub fn move_word_left(&mut self)
Move cursor left to the start of the previous word.
Sourcepub fn move_word_right(&mut self)
pub fn move_word_right(&mut self)
Move cursor right to the end of the next word.
Sourcepub fn move_to_line_start(&mut self)
pub fn move_to_line_start(&mut self)
Move cursor to start of current line.
Sourcepub fn move_to_line_end(&mut self)
pub fn move_to_line_end(&mut self)
Move cursor to end of current line.
Sourcepub fn move_to_start(&mut self)
pub fn move_to_start(&mut self)
Move cursor to start of document.
Sourcepub fn move_to_end(&mut self)
pub fn move_to_end(&mut self)
Move cursor to end of document.
Sourcepub fn extend_selection_left(&mut self)
pub fn extend_selection_left(&mut self)
Extend selection one character left (Shift+Left).
Sourcepub fn extend_selection_right(&mut self)
pub fn extend_selection_right(&mut self)
Extend selection one character right (Shift+Right).
Sourcepub fn extend_selection_up(&mut self)
pub fn extend_selection_up(&mut self)
Extend selection up one line (Shift+Up).
Sourcepub fn extend_selection_down(&mut self)
pub fn extend_selection_down(&mut self)
Extend selection down one line (Shift+Down).
Sourcepub fn extend_selection(&mut self, head: Position)
pub fn extend_selection(&mut self, head: Position)
Extend selection to a specific position.
Sourcepub fn extend_selection_word_left(&mut self)
pub fn extend_selection_word_left(&mut self)
Extend selection to word boundary left (Ctrl+Shift+Left).
Sourcepub fn extend_selection_word_right(&mut self)
pub fn extend_selection_word_right(&mut self)
Extend selection to word boundary right (Ctrl+Shift+Right).
Sourcepub fn extend_selection_to_line_start(&mut self)
pub fn extend_selection_to_line_start(&mut self)
Extend selection to line start (Shift+Home).
Sourcepub fn extend_selection_to_line_end(&mut self)
pub fn extend_selection_to_line_end(&mut self)
Extend selection to line end (Shift+End).
Sourcepub fn extend_selection_to_start(&mut self)
pub fn extend_selection_to_start(&mut self)
Extend selection to document start (Ctrl+Shift+Home).
Sourcepub fn extend_selection_to_end(&mut self)
pub fn extend_selection_to_end(&mut self)
Extend selection to document end (Ctrl+Shift+End).
Sourcepub fn select_word(&mut self)
pub fn select_word(&mut self)
Select the word at the cursor (double-click behavior).
Sourcepub fn select_line(&mut self)
pub fn select_line(&mut self)
Select the entire current line (triple-click behavior).
Sourcepub fn mark_clean(&mut self)
pub fn mark_clean(&mut self)
Mark the editor as clean (e.g., after saving).