agitcms
Version:
A hackable headless CMS for markdown blogs
26 lines (24 loc) • 569 B
JavaScript
new ToolbarItem({
initialChar: "B",
tooltip: "Bold",
weight: 1,
run: (editorView, _, { EditorSelection, Text }) => {
const changes = editorView.state.changeByRange((range) => {
return {
changes: [
{
from: range.from,
insert: Text.of(["**"]),
},
{
from: range.to,
insert: Text.of(["**"]),
},
],
range: EditorSelection.range(range.from + 2, range.to + 2),
};
});
editorView.dispatch(changes);
editorView.focus();
},
});