From d4cd6ab691a95ff6a264d5208b78c01dbd8aa0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 21 Aug 2020 23:50:22 +0200 Subject: [PATCH] add blur command --- packages/core/src/commands/blur.ts | 16 ++++++++++++++++ packages/core/src/commands/index.ts | 1 + 2 files changed, 17 insertions(+) create mode 100644 packages/core/src/commands/blur.ts diff --git a/packages/core/src/commands/blur.ts b/packages/core/src/commands/blur.ts new file mode 100644 index 00000000..ffe18b02 --- /dev/null +++ b/packages/core/src/commands/blur.ts @@ -0,0 +1,16 @@ +import { Editor } from '../Editor' + +type BlurCommand = () => Editor + +declare module '../Editor' { + interface Editor { + blur: BlurCommand, + } +} + +export default (next: Function, { view }: Editor) => () => { + const element = view.dom as HTMLElement + + element.blur() + next() +} diff --git a/packages/core/src/commands/index.ts b/packages/core/src/commands/index.ts index 6ef7d1b3..797ec377 100644 --- a/packages/core/src/commands/index.ts +++ b/packages/core/src/commands/index.ts @@ -1,3 +1,4 @@ +export { default as blur } from './blur' export { default as clearContent } from './clearContent' export { default as deleteSelection } from './deleteSelection' export { default as focus } from './focus'