@tiptap/core
Version:
headless rich text editor
22 lines (18 loc) • 451 B
text/typescript
import { RawCommands } from '../types.js'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
scrollIntoView: {
/**
* Scroll the selection into view.
* @example editor.commands.scrollIntoView()
*/
scrollIntoView: () => ReturnType,
}
}
}
export const scrollIntoView: RawCommands['scrollIntoView'] = () => ({ tr, dispatch }) => {
if (dispatch) {
tr.scrollIntoView()
}
return true
}