import { EditorSelection } from '@codemirror/state'; import { ICommand } from '.'; export const underline: ICommand = { name: 'underline', keyCommand: 'underline', button: { 'aria-label': 'Add underline 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 + 3, range.to + 3), })), ); }, };