fix slash command triggering

This commit is contained in:
Dallin Romney 2025-03-27 11:40:43 -07:00
parent ae9c97ca67
commit d448b5f4d8
5 changed files with 18 additions and 41 deletions

View file

@ -19,7 +19,7 @@ export function slashFromCustomCommand(
.slice(customCommand.name.length + 1, userInput.length)
.trimStart();
}
debugger;
// Render prompt template
let promptUserInput: string;
if (customCommand.prompt.includes("{{{ input }}}")) {

View file

@ -30,7 +30,6 @@ import { getFontSize } from "../../../util";
import { AddCodeToEdit } from "./extensions/AddCodeToEditExtension";
import { CodeBlockExtension } from "./extensions/CodeBlockExtension";
import { SlashCommand } from "./extensions/CommandsExtension";
import { MockExtension } from "./extensions/FillerExtension";
import { Mention } from "./extensions/MentionExtension";
import {
getContextProviderDropdownOptions,
@ -352,22 +351,20 @@ export function createEditorConfig(options: {
},
},
}),
props.availableSlashCommands.length
? SlashCommand.configure({
HTMLAttributes: {
class: "mention",
},
suggestion: getSlashCommandDropdownOptions(
availableSlashCommandsRef,
onClose,
onOpen,
ideMessenger,
),
renderText: (props) => {
return props.node.attrs.label;
},
})
: MockExtension,
SlashCommand.configure({
HTMLAttributes: {
class: "mention",
},
suggestion: getSlashCommandDropdownOptions(
availableSlashCommandsRef,
onClose,
onOpen,
ideMessenger,
),
renderText: (props) => {
return props.node.attrs.label;
},
}),
CodeBlockExtension,
],
editorProps: {

View file

@ -1,20 +0,0 @@
import { Node } from "@tiptap/core";
export const MockExtension = Node.create({
name: "mockExtension",
addOptions() {
return {
enabled: false,
};
},
addCommands() {
return {};
},
addKeyboardShortcuts() {
return {};
},
addProseMirrorPlugins() {
return [];
},
});

View file

@ -203,7 +203,7 @@ export function getSlashCommandDropdownOptions(
const filteredCommands =
query.length > 0
? options.filter((slashCommand) => {
const sc = slashCommand.title.substring(1).toLowerCase();
const sc = slashCommand.title.toLowerCase();
const iv = query.toLowerCase();
return sc.startsWith(iv);
})
@ -219,7 +219,7 @@ export function getSlashCommandDropdownOptions(
action: provider.action,
}));
if (query.length === 0 && commandItems.length > 0) {
if (query.length === 0 && commandItems.length === 0) {
commandItems.push({
title: "Explore prompts",
type: "action",

View file

@ -8,7 +8,7 @@ export const selectSlashCommandComboBoxInputs = createSelector(
return (
slashCommands?.map((cmd) => {
return {
title: `${cmd.name}`,
title: cmd.name,
description: cmd.description,
type: "slashCommand" as ComboBoxItemType,
};