From 9df4cd4e353ecb4ea6d1d23f36dee3bb0f35ab4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Thu, 24 Sep 2020 22:21:44 +0200 Subject: [PATCH] add scrollIntoView command --- packages/core/src/commands/index.ts | 1 + packages/core/src/commands/scrollIntoView.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 packages/core/src/commands/scrollIntoView.ts 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 +}