use crate::doc::BlockKind;
use crate::widget::Command;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Features {
pub tables: bool,
pub task_lists: bool,
pub strikethrough: bool,
}
impl Default for Features {
fn default() -> Self {
Self::ALL
}
}
impl Features {
pub const ALL: Self = Self {
tables: true,
task_lists: true,
strikethrough: true,
};
pub const COMMONMARK: Self = Self {
tables: false,
task_lists: false,
strikethrough: false,
};
pub fn allows(&self, command: &Command) -> bool {
match command {
Command::ToggleStrike => self.strikethrough,
Command::SetBlock(BlockKind::Task) | Command::ToggleChecked => self.task_lists,
Command::InsertTable { .. }
| Command::InsertRow { .. }
| Command::InsertColumn { .. }
| Command::DeleteRow
| Command::DeleteColumn
| Command::DeleteTable
| Command::SetColumnAlign(_) => self.tables,
_ => true,
}
}
}