@flozy/editor 9.7.6 → 9.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -167,6 +167,7 @@ function PopoverAIInput({
|
|
167
167
|
const [generatedText, setGeneratedText] = useState("");
|
168
168
|
const [inputValue, setInputValue] = useState("");
|
169
169
|
const [selectedOption, setSelectedOption] = useState();
|
170
|
+
const [threadId, setThreadId] = useState("");
|
170
171
|
const selectedEleRef = useRef({});
|
171
172
|
const classes = Styles();
|
172
173
|
const editor = useSlate();
|
@@ -188,6 +189,7 @@ function PopoverAIInput({
|
|
188
189
|
useEffect(() => {
|
189
190
|
if (openAI) {
|
190
191
|
scrollToAIInput(editor);
|
192
|
+
setThreadId("");
|
191
193
|
}
|
192
194
|
}, [openAI]);
|
193
195
|
useEffect(() => {
|
@@ -196,8 +198,12 @@ function PopoverAIInput({
|
|
196
198
|
const framePayload = (type, option) => {
|
197
199
|
let payload = {
|
198
200
|
mode: option.mode || 0,
|
199
|
-
query: option?.inputValue || inputValue
|
201
|
+
query: option?.inputValue || inputValue,
|
202
|
+
useSession: true
|
200
203
|
};
|
204
|
+
if (threadId) {
|
205
|
+
payload.threadId = threadId;
|
206
|
+
}
|
201
207
|
if (option.mode === MODES.translate || option.mode === MODES.rephraseTone) {
|
202
208
|
payload.textOptionInput = type;
|
203
209
|
}
|
@@ -257,12 +263,14 @@ function PopoverAIInput({
|
|
257
263
|
setLoading(false);
|
258
264
|
setInputValue("");
|
259
265
|
let {
|
260
|
-
|
261
|
-
|
266
|
+
body: text,
|
267
|
+
threadId
|
268
|
+
} = result?.data || {};
|
262
269
|
if (!text) {
|
263
270
|
onClickOutside();
|
264
271
|
return;
|
265
272
|
}
|
273
|
+
setThreadId(threadId || "");
|
266
274
|
|
267
275
|
// if (!option.replace) {
|
268
276
|
if (type === "continue_writing") {
|
@@ -95,9 +95,9 @@ const PopupTool = props => {
|
|
95
95
|
const isFreeGridEnabled = enable === 1 && isFreeGridElement;
|
96
96
|
if (!selection || Range.isCollapsed(selection) || Editor.string(editor, selection) === "" || isFreeGridEnabled) {
|
97
97
|
setAnchorEl(null);
|
98
|
+
hideSlateSelection(); // removes slate selection background, when there is no selection
|
98
99
|
} else {
|
99
100
|
updateAnchorEl();
|
100
|
-
hideSlateSelection(); // removes slate selection background, when there is no selection
|
101
101
|
}
|
102
102
|
}, [selection, event, selectedElement?.enable]);
|
103
103
|
const handleClose = () => {
|