mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-23 09:53:08 +08:00
956566eaad
* remove async createNodeViews * focus asynchronously to fix weird bugs in react
23 lines
423 B
TypeScript
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
|
|
}
|