Files
tiptap/packages/extension-gapcursor/src/gapcursor.ts
2021-02-19 17:41:11 +01:00

33 lines
662 B
TypeScript

import { Extension, callOrReturn } from '@tiptap/core'
import { gapCursor } from 'prosemirror-gapcursor'
declare module '@tiptap/core' {
interface NodeConfig<Options> {
/**
* Allow gap cursor
*/
allowGapCursor?:
| boolean
| null
| ((this: { options: Options }) => boolean | null),
}
}
export const Gapcursor = Extension.create({
name: 'gapCursor',
addProseMirrorPlugins() {
return [
gapCursor(),
]
},
extendNodeSchema(extension) {
const context = { options: extension.options }
return {
allowGapCursor: callOrReturn(extension.config.allowGapCursor, context) ?? null,
}
},
})