Skip to content

Commit 62beb43

Browse files
committed
must specify text area purpose, no default purpose
1 parent 2e11449 commit 62beb43

3 files changed

Lines changed: 26 additions & 17 deletions

File tree

packages/react-textarea/src/components/copilot-textarea/base-copilot-textarea/base-copilot-textarea.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
// This example is for an Editor with `ReactEditor` and `HistoryEditor`
2-
import { Descendant, Editor } from "slate";
3-
import { Editable, Slate } from "slate-react";
42
import {
3+
TextareaHTMLAttributes,
54
useCallback,
65
useEffect,
76
useMemo,
87
useState,
9-
TextareaHTMLAttributes,
108
} from "react";
9+
import { Descendant, Editor } from "slate";
10+
import { Editable, Slate } from "slate-react";
1111
import {
1212
AutosuggestionsBareFunction,
1313
useAutosuggestions,
1414
} from "../../../hooks/use-autosuggestions";
15-
import { AutosuggestionState } from "../../../types/autosuggestion-state";
16-
import { clearAutocompletionsFromEditor } from "../../../lib/slatejs-edits/clear-autocompletions";
17-
import { addAutocompletionsToEditor } from "../../../lib/slatejs-edits/add-autocompletions";
1815
import { useCopilotTextareaEditor } from "../../../hooks/use-copilot-textarea-editor";
19-
import { renderElement } from "./render-element";
20-
import {
21-
BaseAutosuggestionsConfig,
22-
defaultBaseAutosuggestionsConfig,
23-
} from "../../../types/autosuggestions-config";
24-
import { makeRenderPlaceholderFunction } from "./render-placeholder";
2516
import {
2617
getFullEditorTextWithNewlines,
2718
getTextAroundCursor,
2819
} from "../../../lib/get-text-around-cursor";
20+
import { addAutocompletionsToEditor } from "../../../lib/slatejs-edits/add-autocompletions";
21+
import { clearAutocompletionsFromEditor } from "../../../lib/slatejs-edits/clear-autocompletions";
2922
import { replaceEditorText } from "../../../lib/slatejs-edits/replace-text";
23+
import { AutosuggestionState } from "../../../types/autosuggestion-state";
24+
import {
25+
BaseAutosuggestionsConfig,
26+
defaultBaseAutosuggestionsConfig,
27+
} from "../../../types/autosuggestions-config";
28+
import { renderElement } from "./render-element";
29+
import { makeRenderPlaceholderFunction } from "./render-placeholder";
3030

3131
export interface BaseCopilotTextareaProps
3232
extends TextareaHTMLAttributes<HTMLDivElement> {
3333
placeholderStyle?: React.CSSProperties;
3434
value?: string;
3535
onValueChange?: (value: string) => void;
36-
autosuggestionsConfig: Partial<BaseAutosuggestionsConfig>;
36+
autosuggestionsConfig: Partial<BaseAutosuggestionsConfig> & {
37+
textareaPurpose: string;
38+
};
3739
}
3840

3941
export function BaseCopilotTextarea(

packages/react-textarea/src/components/copilot-textarea/copilot-textarea.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import {
1010
} from "./base-copilot-textarea/base-copilot-textarea";
1111

1212
export interface CopilotTextareaProps extends BaseCopilotTextareaProps {
13-
autosuggestionsConfig: Partial<AutosuggestionsConfig>;
13+
autosuggestionsConfig: Partial<AutosuggestionsConfig> & {
14+
textareaPurpose: string;
15+
};
1416
}
1517

1618
export function CopilotTextarea(props: CopilotTextareaProps): JSX.Element {

packages/react-textarea/src/types/autosuggestions-config.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ export interface BaseAutosuggestionsConfig {
1212
disableWhenEmpty: boolean;
1313
}
1414

15-
export const defaultBaseAutosuggestionsConfig: BaseAutosuggestionsConfig = {
16-
textareaPurpose: "A generic textbox",
15+
export const defaultBaseAutosuggestionsConfig: Omit<
16+
BaseAutosuggestionsConfig,
17+
"textareaPurpose"
18+
> = {
1719
debounceTime: 500,
1820
acceptAutosuggestionKey: "Tab",
1921
disableWhenEmpty: true,
@@ -88,7 +90,10 @@ export const defaultFewShotMessages: MinimalChatGPTMessage[] = [
8890
' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\'s "Pro Rata Share"; ',
8991
},
9092
];
91-
export const defaultAutosuggestionsConfig: AutosuggestionsConfig = {
93+
export const defaultAutosuggestionsConfig: Omit<
94+
AutosuggestionsConfig,
95+
"textareaPurpose"
96+
> = {
9297
...defaultBaseAutosuggestionsConfig,
9398

9499
apiEndpoint: "api/autosuggestions",

0 commit comments

Comments
 (0)