diff --git a/packages/core/src/commands/index.ts b/packages/core/src/commands/index.ts index 68b1315b..90def10d 100644 --- a/packages/core/src/commands/index.ts +++ b/packages/core/src/commands/index.ts @@ -8,6 +8,7 @@ export { liftListItem } from './liftListItem' export { removeMark } from './removeMark' export { removeMarks } from './removeMarks' export { replaceWithNode } from './replaceWithNode' +export { scrollIntoView } from './scrollIntoView' export { selectAll } from './selectAll' export { selectParentNode } from './selectParentNode' export { setContent } from './setContent' diff --git a/packages/core/src/commands/scrollIntoView.ts b/packages/core/src/commands/scrollIntoView.ts new file mode 100644 index 00000000..142dbee3 --- /dev/null +++ b/packages/core/src/commands/scrollIntoView.ts @@ -0,0 +1,15 @@ +import { Command } from '../Editor' + +type ScrollIntoViewCommand = () => Command + +declare module '../Editor' { + interface Commands { + scrollIntoView: ScrollIntoViewCommand, + } +} + +export const scrollIntoView: ScrollIntoViewCommand = () => ({ tr }) => { + tr.scrollIntoView() + + return true +}