create and insert the currentFile node on tiptap
This commit is contained in:
parent
59d79f5a06
commit
65445b6fe7
1 changed files with 25 additions and 1 deletions
|
|
@ -7,7 +7,7 @@ import { clearCodeToEdit } from "../../../redux/slices/editModeState";
|
|||
import { setNewestToolbarPreviewForInput } from "../../../redux/slices/sessionSlice";
|
||||
import { AppDispatch } from "../../../redux/store";
|
||||
import { loadSession, saveCurrentSession } from "../../../redux/thunks/session";
|
||||
import { CodeBlock, PromptBlock } from "./extensions";
|
||||
import { CodeBlock, Mention, PromptBlock } from "./extensions";
|
||||
|
||||
/**
|
||||
* Hook for setting up main editor specific webview listeners
|
||||
|
|
@ -178,4 +178,28 @@ export function useMainEditorWebviewListeners({
|
|||
},
|
||||
[],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"configUpdate",
|
||||
async (data) => {
|
||||
const currentFileProvider = data.result.config?.contextProviders.find(
|
||||
(provider) => provider.title === "currentFile",
|
||||
);
|
||||
|
||||
if (currentFileProvider && editor) {
|
||||
const node = editor.schema.nodes[Mention.name].create({
|
||||
name: currentFileProvider.displayTitle,
|
||||
description: currentFileProvider.description,
|
||||
id: currentFileProvider.title,
|
||||
label: currentFileProvider.displayTitle,
|
||||
renderInlineAs: currentFileProvider.renderInlineAs,
|
||||
type: currentFileProvider.type,
|
||||
itemType: 'contextProvider'
|
||||
});
|
||||
|
||||
editor.chain().insertContent(node.toJSON()).run();
|
||||
}
|
||||
},
|
||||
[editor],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue