Skip to content

Commit

Permalink
gst
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 24, 2023
1 parent a9f8c72 commit 6089f63
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/components/editor/action/command-functions.jsx

This file was deleted.

31 changes: 31 additions & 0 deletions src/components/editor/action/command-functions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Commands, Extension } from '@tiptap/react'
import { Editor } from "@tiptap/core";
import { Transaction } from "prosemirror-state";
import { PromptAction } from "@/types/custom-action.type";

export const CommandFunctions = Extension.create({
name: 'commandFunctions',
// @ts-ignore
addCommands: () => {
return {
// for examples: $selection, $beforeCursor
variable: (variableName: string, variableValue: string) => () => {
console.log('variable', variableName, variableValue)
},
getSelectedText: () => ({ editor }: { editor: Editor }) => {
if (!editor.state) return null

const { from, to, empty } = editor.state.selection

if (empty) return null

return editor.state.doc.textBetween(from, to, ' ')
},
callLlm: (action: PromptAction) => ({ tr, commands }: { tr: Transaction, commands: Commands }) => {
// TODO: @phodal convert action to request
// TODO: @genffy add LLM request type
// do execute action
}
}
},
})

0 comments on commit 6089f63

Please sign in to comment.