use markdown::Mark;
let formatting = editor.read(cx).formatting(); // once per frame
let enabled = formatting.mode == editor::Mode::Blocks;
let bold = formatting.marks.contains(&Mark::Bold);
let label = formatting.block.clone(); // "Heading 2"
editor.update(cx, |editor, cx| editor.toggle_mark(Mark::Bold, cx)); // on press
let block = editor.read(cx).selection().head.block;
for (name, kind) in editor::turns() { // the dropdown's rows
// on click: editor.update(cx, |editor, cx| editor.set_block(block, kind.clone(), cx));
}markslights a button only when the whole selection carries the mark. At a bare caret it includes a mark pressed before typing.fenceableistruewhenMark::Codewould make a fence rather than an inline span.toggle_markdoes nothing inMode::Source, so grey the bar out there.- For a mark of your own, register it with
cx.set_marks(markdown::Marks::new().with("highlight", "==")), then press it withtoggle_mark(Mark::Custom("highlight".into())).