mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-05 09:37:48 +08:00
23 lines
418 B
TypeScript
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
|
|
}
|