import { EditorSelection } from '@codemirror/state'; import { ICommand } from '.'; export const italic: ICommand = { name: 'italic', keyCommand: 'italic', button: { 'aria-label': 'Add italic text' }, icon: ( ), execute: ({ state, view }) => { if (!state || !view) return; view.dispatch( view.state.changeByRange((range) => ({ changes: [ { from: range.from, insert: '*' }, { from: range.to, insert: '*' }, ], range: EditorSelection.range(range.from + 1, range.to + 1), })), ); }, };