|
|
@@ -8,7 +8,6 @@ import { useCodeMirrorEditorIsolated } from '@growi/editor/dist/client/stores/co
|
|
|
import { useSecondaryYdocs } from '@growi/editor/dist/client/stores/use-secondary-ydocs';
|
|
|
import { type Text as YText } from 'yjs';
|
|
|
|
|
|
-
|
|
|
import {
|
|
|
SseMessageSchema,
|
|
|
SseDetectedDiffSchema,
|
|
|
@@ -25,8 +24,6 @@ import { handleIfSuccessfullyParsed } from '~/features/openai/utils/handle-if-su
|
|
|
import { useIsEnableUnifiedMergeView } from '~/stores-universal/context';
|
|
|
import { useCurrentPageId } from '~/stores/page';
|
|
|
|
|
|
-import type { IApiv3PostMessageParams } from '../../interfaces/apiv3/edit';
|
|
|
-
|
|
|
interface PostMessage {
|
|
|
(threadId: string, userMessage: string): Promise<Response>;
|
|
|
}
|
|
|
@@ -116,20 +113,14 @@ export const useEditorAssistant: UseEditorAssistant = () => {
|
|
|
|
|
|
// Functions
|
|
|
const postMessage: PostMessage = useCallback(async(threadId, userMessage) => {
|
|
|
- const body: IApiv3PostMessageParams = {
|
|
|
- threadId,
|
|
|
- userMessage,
|
|
|
- };
|
|
|
-
|
|
|
- // Insert selectedText into object after null check since JSON.stringify returns empty string when selectedText is undefined
|
|
|
- if (selectedText != null) {
|
|
|
- body.markdown = selectedText;
|
|
|
- }
|
|
|
-
|
|
|
const response = await fetch('/_api/v3/openai/edit', {
|
|
|
method: 'POST',
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
- body: JSON.stringify(body),
|
|
|
+ body: JSON.stringify({
|
|
|
+ threadId,
|
|
|
+ userMessage,
|
|
|
+ markdown: selectedText,
|
|
|
+ }),
|
|
|
});
|
|
|
|
|
|
setSelectedText(undefined);
|