fix: slash commands are no more shown in the code blocks

This commit is contained in:
Palanikannan1437 2024-03-14 13:10:27 +05:30
parent 768d141729
commit 13ba7d59e0

View File

@ -54,7 +54,20 @@ const Command = Extension.create<SlashCommandOptions>({
props.command({ editor, range }); props.command({ editor, range });
}, },
allow({ editor }: { editor: Editor }) { allow({ editor }: { editor: Editor }) {
return !editor.isActive("table"); const { selection } = editor.state;
const parentNode = selection.$from.node(selection.$from.depth);
const blockType = parentNode.type.name;
if (blockType === "codeBlock") {
return false;
}
if (editor.isActive("table")) {
return false;
}
return true;
}, },
allowSpaces: true, allowSpaces: true,
}, },