Skip to content

Commit 665282f

Browse files
committed
fix addToEdit handling
1 parent 8e1288e commit 665282f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { AppDispatch } from "../../../redux/store";
1010
import { loadSession, saveCurrentSession } from "../../../redux/thunks/session";
1111
import { CodeBlock, PromptBlock } from "./extensions";
1212
import { insertCurrentFileContextMention } from "./utils/insertCurrentFileContextMention";
13-
import { Mention } from "@tiptap/extension-mention";
1413

1514
/**
1615
* Hook for setting up main editor specific webview listeners
@@ -206,15 +205,18 @@ export function useMainEditorWebviewListeners({
206205
if (!editor) return;
207206
let chain = editor.chain();
208207

209-
for (let payload of data.data) {
210-
const node = editor.schema.nodes[Mention.name].create({
211-
name: payload.name,
212-
id: payload.fullPath,
213-
label: payload.name,
214-
itemType: payload.type,
215-
});
216-
217-
chain.insertContent([node.toJSON(), { type: "text", text: " " }]);
208+
for (let mention of data.data) {
209+
chain
210+
.insertContent({
211+
type: "mention",
212+
attrs: {
213+
id: mention.fullPath,
214+
query: mention.fullPath,
215+
itemType: mention.type,
216+
label: mention.name,
217+
},
218+
})
219+
.insertContent(" ");
218220
}
219221

220222
chain.run();

0 commit comments

Comments
 (0)