use super::core::RichTextEditor;
use super::{BlockType, EditOp, TextFormat};
impl RichTextEditor {
pub fn toggle_bold(&mut self) {
self.current_format.bold = !self.current_format.bold;
}
pub fn toggle_italic(&mut self) {
self.current_format.italic = !self.current_format.italic;
}
pub fn toggle_underline(&mut self) {
self.current_format.underline = !self.current_format.underline;
}
pub fn toggle_strikethrough(&mut self) {
self.current_format.strikethrough = !self.current_format.strikethrough;
}
pub fn toggle_code(&mut self) {
self.current_format.code = !self.current_format.code;
}
pub fn current_format(&self) -> TextFormat {
self.current_format
}
pub fn set_block_type(&mut self, block_type: BlockType) {
let old_type = self.blocks[self.cursor.0].block_type;
self.undo_stack.push(EditOp::ChangeBlockType {
block: self.cursor.0,
old: old_type,
new: block_type,
});
self.redo_stack.clear();
self.blocks[self.cursor.0].block_type = block_type;
}
pub fn current_block_type(&self) -> BlockType {
self.blocks[self.cursor.0].block_type
}
}