|
1 | 1 | // This example is for an Editor with `ReactEditor` and `HistoryEditor` |
2 | | -import { Descendant, Editor } from "slate"; |
3 | | -import { Editable, Slate } from "slate-react"; |
4 | 2 | import { |
| 3 | + TextareaHTMLAttributes, |
5 | 4 | useCallback, |
6 | 5 | useEffect, |
7 | 6 | useMemo, |
8 | 7 | useState, |
9 | | - TextareaHTMLAttributes, |
10 | 8 | } from "react"; |
| 9 | +import { Descendant, Editor } from "slate"; |
| 10 | +import { Editable, Slate } from "slate-react"; |
11 | 11 | import { |
12 | 12 | AutosuggestionsBareFunction, |
13 | 13 | useAutosuggestions, |
14 | 14 | } 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"; |
18 | 15 | 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"; |
25 | 16 | import { |
26 | 17 | getFullEditorTextWithNewlines, |
27 | 18 | getTextAroundCursor, |
28 | 19 | } from "../../../lib/get-text-around-cursor"; |
| 20 | +import { addAutocompletionsToEditor } from "../../../lib/slatejs-edits/add-autocompletions"; |
| 21 | +import { clearAutocompletionsFromEditor } from "../../../lib/slatejs-edits/clear-autocompletions"; |
29 | 22 | 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"; |
30 | 30 |
|
31 | 31 | export interface BaseCopilotTextareaProps |
32 | 32 | extends TextareaHTMLAttributes<HTMLDivElement> { |
33 | 33 | placeholderStyle?: React.CSSProperties; |
34 | 34 | value?: string; |
35 | 35 | onValueChange?: (value: string) => void; |
36 | | - autosuggestionsConfig: Partial<BaseAutosuggestionsConfig>; |
| 36 | + autosuggestionsConfig: Partial<BaseAutosuggestionsConfig> & { |
| 37 | + textareaPurpose: string; |
| 38 | + }; |
37 | 39 | } |
38 | 40 |
|
39 | 41 | export function BaseCopilotTextarea( |
|
0 commit comments