tiptap/packages/core/src/commands/scrollIntoView.ts
2021-02-16 18:39:37 +01:00

21 lines
391 B
TypeScript

import { Command, RawCommands } from '../types'
declare module '@tiptap/core' {
interface Commands {
scrollIntoView: {
/**
* Scroll the selection into view.
*/
scrollIntoView: () => Command,
}
}
}
export const scrollIntoView: RawCommands['scrollIntoView'] = () => ({ tr, dispatch }) => {
if (dispatch) {
tr.scrollIntoView()
}
return true
}