mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-11 06:44:30 +08:00
29 lines
605 B
TypeScript
29 lines
605 B
TypeScript
import { Plugin } from 'prosemirror-state'
|
|
import Editor from '../..'
|
|
|
|
export default (editor: Editor) => new Plugin({
|
|
props: {
|
|
attributes: {
|
|
tabindex: '0',
|
|
},
|
|
handleDOMEvents: {
|
|
focus: () => {
|
|
editor.isFocused = true
|
|
|
|
const transaction = editor.state.tr.setMeta('focused', true)
|
|
editor.view.dispatch(transaction)
|
|
|
|
return true
|
|
},
|
|
blur: () => {
|
|
editor.isFocused = false
|
|
|
|
const transaction = editor.state.tr.setMeta('focused', false)
|
|
editor.view.dispatch(transaction)
|
|
|
|
return true
|
|
},
|
|
},
|
|
},
|
|
})
|