UBERF-8079 Disable slash menu in codeblock (#6548)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-09-13 15:39:11 +07:00 committed by GitHub
parent 15fca07f96
commit c236b90b6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,8 +14,8 @@
//
import { Extension } from '@tiptap/core'
import Suggestion, { type SuggestionOptions } from './suggestion'
import { PluginKey } from '@tiptap/pm/state'
import Suggestion, { type SuggestionOptions } from './suggestion'
export interface InlineCommandsOptions {
suggestion: Omit<SuggestionOptions, 'editor'>
@ -31,7 +31,11 @@ export const InlineCommandsExtension = Extension.create<InlineCommandsOptions>({
return {
suggestion: {
char: '/',
startOfLine: true
allow: ({ state }) => {
const { $anchor } = state.selection
const parent = $anchor.parent
return parent.type.name === 'paragraph'
}
}
}
},