tiptap/packages/core/src/commands/deleteRange.ts
2021-02-16 11:27:58 +01:00

23 lines
418 B
TypeScript

import { Command, Commands, Range } from '../types'
declare module '@tiptap/core' {
interface AllCommands {
deleteRange: {
/**
* Delete a given range.
*/
deleteRange: (range: Range) => Command,
}
}
}
export const deleteRange: Commands['deleteRange'] = range => ({ tr, dispatch }) => {
const { from, to } = range
if (dispatch) {
tr.delete(from, to)
}
return true
}