tiptap/packages/core/src/commands/scrollIntoView.ts

21 lines
397 B
TypeScript
Raw Normal View History

2021-06-05 03:56:29 +08:00
import { RawCommands } from '../types'
2020-11-05 05:38:52 +08:00
2021-02-11 01:05:02 +08:00
declare module '@tiptap/core' {
2021-06-05 03:56:29 +08:00
interface Commands<ReturnType> {
2021-02-16 18:27:58 +08:00
scrollIntoView: {
/**
* Scroll the selection into view.
*/
2021-06-05 03:56:29 +08:00
scrollIntoView: () => ReturnType,
2021-02-16 18:27:58 +08:00
}
2021-02-11 01:05:02 +08:00
}
}
2021-02-17 01:36:37 +08:00
export const scrollIntoView: RawCommands['scrollIntoView'] = () => ({ tr, dispatch }) => {
2020-11-05 05:38:52 +08:00
if (dispatch) {
tr.scrollIntoView()
}
return true
}