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

21 lines
353 B
TypeScript
Raw Normal View History

2021-02-10 16:59:35 +08:00
import { Command, Commands } from '../types'
2020-11-05 05:38:52 +08:00
2021-02-11 01:05:02 +08:00
declare module '@tiptap/core' {
2021-02-16 18:27:58 +08:00
interface AllCommands {
blur: {
/**
* Removes focus from the editor.
*/
blur: () => Command,
}
2021-02-11 01:05:02 +08:00
}
}
2021-02-10 16:59:35 +08:00
export const blur: Commands['blur'] = () => ({ view }) => {
2020-11-05 05:38:52 +08:00
const element = view.dom as HTMLElement
element.blur()
return true
}