diff --git a/packages/extension-gapcursor/src/gapcursor.ts b/packages/extension-gapcursor/src/gapcursor.ts index 6ec394164..73bf9325f 100644 --- a/packages/extension-gapcursor/src/gapcursor.ts +++ b/packages/extension-gapcursor/src/gapcursor.ts @@ -1,6 +1,15 @@ -import { Extension } from '@tiptap/core' +import { Extension, callOrReturn } from '@tiptap/core' import { gapCursor } from 'prosemirror-gapcursor' +declare module '@tiptap/core' { + interface NodeConfig { + /** + * Allow gap cursor + */ + allowGapCursor?: boolean | ((this: { options: Options }) => boolean), + } +} + export const Gapcursor = Extension.create({ name: 'gapCursor', @@ -9,4 +18,12 @@ export const Gapcursor = Extension.create({ gapCursor(), ] }, + + extendNodeSchema(extension) { + const context = { options: extension.options } + + return { + allowGapCursor: callOrReturn(extension.config.allowGapCursor, context) ?? null, + } + }, })