tiptap/packages/core/src/commands/blur.ts
Philipp Kühn 956566eaad
fix: fix some react focus issues (#1724), fix #1716, fix #1608, fix #1520
* remove async createNodeViews

* focus asynchronously to fix weird bugs in react
2021-08-12 18:03:45 +02:00

23 lines
423 B
TypeScript

import { RawCommands } from '../types'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
blur: {
/**
* Removes focus from the editor.
*/
blur: () => ReturnType,
}
}
}
export const blur: RawCommands['blur'] = () => ({ editor, view }) => {
requestAnimationFrame(() => {
if (!editor.isDestroyed) {
(view.dom as HTMLElement).blur()
}
})
return true
}