diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/api/useAIRewrite.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/api/useAIRewrite.tsx
index 9543ecc9..7506d033 100644
--- a/src/frontend/apps/impress/src/features/docs/doc-editor/api/useAIRewrite.tsx
+++ b/src/frontend/apps/impress/src/features/docs/doc-editor/api/useAIRewrite.tsx
@@ -2,10 +2,12 @@ import { useMutation } from '@tanstack/react-query';
import { APIError, errorCauses, fetchAPI } from '@/api';
+export type AIActions = 'rephrase' | 'summarize' | 'translate' | 'correct';
+
export type DocAIParams = {
docId: string;
text: string;
- action: 'rephrase' | 'summarize';
+ action: AIActions;
};
export type DocAIResponse = string;
diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/AIButton.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/AIButton.tsx
index 061b50b4..79bf9253 100644
--- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/AIButton.tsx
+++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/AIButton.tsx
@@ -7,16 +7,15 @@ import {
} from '@blocknote/react';
import { useMemo } from 'react';
+import { BoxButton } from '@/components';
+
import { Doc } from '../../doc-management';
-import { useAIRewrite } from '../api/useAIRewrite';
+import { AIActions, useAIRewrite } from '../api/useAIRewrite';
interface AIButtonProps {
doc: Doc;
}
-/**
- * Custom Formatting Toolbar Button to convert markdown to json.
- */
export function AIButton({ doc }: AIButtonProps) {
const editor = useBlockNoteEditor();
const Components = useComponentsContext();
@@ -29,22 +28,18 @@ export function AIButton({ doc }: AIButtonProps) {
}, editor);
const { mutateAsync: requestAI } = useAIRewrite();
- const handleRephraseAI = async () => {
+ const handleRephraseAI = async (action: AIActions) => {
const textCursorPosition = editor.getSelectedText();
const newText = await requestAI({
docId: doc.id,
text: textCursorPosition,
- action: 'rephrase',
+ action,
});
- editor.replaceBlocks(
- [selectedBlocks[0]],
- [
- {
- content: newText,
- },
- ],
- );
+ editor.insertInlineContent([
+ newText,
+ //{ type: 'text', text: 'World', styles: { bold: true } },
+ ]);
};
const show = useMemo(() => {
@@ -56,11 +51,34 @@ export function AIButton({ doc }: AIButtonProps) {
}
return (
- void handleRephraseAI()}
- >
- Rephrase
-
+
+
+
+ AI
+
+
+
+ {['rephrase', 'summarize', 'correct'].map((action) => (
+ void handleRephraseAI('rephrase')}
+ $hasTransition
+ $radius="6px"
+ $width="98%"
+ $align="center"
+ $css="&:hover{background-color: #f2f8ff;}text-transform: capitalize!important;"
+ >
+ {action}
+
+ ))}
+
+
);
}
diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteToolbar.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteToolbar.tsx
index 79a03d3f..3a16ea55 100644
--- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteToolbar.tsx
+++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteToolbar.tsx
@@ -18,6 +18,7 @@ import React, { useMemo } from 'react';
import { Doc } from '../../doc-management';
+// import { AIButton } from './AIButton';
import { AIButton } from './AIButton';
interface BlockNoteToolbarProps {