@flozy/editor 11.1.0 → 11.1.2

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
- data: text
261
- } = result || {};
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") {
@@ -186,7 +186,8 @@ const Attachments = props => {
186
186
  textDecoration: "none",
187
187
  flexDirection: "column",
188
188
  color: "#0F172A",
189
- flexGrow: uploadStatus?.isUploading && 1
189
+ flexGrow: uploadStatus?.isUploading && 1,
190
+ width: "80%"
190
191
  },
191
192
  children: [/*#__PURE__*/_jsx(Typography, {
192
193
  style: {
@@ -95,6 +95,7 @@ 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
101
  viewSlateSelection();
@@ -41,9 +41,15 @@ const BackgroundImage = props => {
41
41
  setOpen(false);
42
42
  };
43
43
  const onSelectImage = img => {
44
- setBase64(img);
44
+ let imgUrl = "";
45
+ if (typeof img === "object") {
46
+ imgUrl = img?.embedURL;
47
+ } else {
48
+ imgUrl = img;
49
+ }
50
+ setBase64(imgUrl);
45
51
  onChange({
46
- [key]: img
52
+ [key]: imgUrl
47
53
  });
48
54
  handleClose();
49
55
  };
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import { Grid, TextField, Typography } from "@mui/material";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -20,6 +20,17 @@ const Text = props => {
20
20
  } = data;
21
21
  const [value, setValue] = useState(pro_value);
22
22
  const [error, setError] = useState(false);
23
+ useEffect(() => {
24
+ if (["sectionBackgroundImage", "pageBgImage"].includes(key)) {
25
+ let bgUrl = "";
26
+ if (typeof props?.value === "string" && props?.value !== "none") {
27
+ bgUrl = props.value;
28
+ } else if (props?.value?.embedURL) {
29
+ bgUrl = props.value.embedURL;
30
+ }
31
+ setValue(bgUrl);
32
+ }
33
+ }, [props?.value]);
23
34
  const handleChange = e => {
24
35
  const newValue = e.target.value;
25
36
  setValue(newValue);
@@ -55,10 +66,10 @@ const Text = props => {
55
66
  fullWidth: true,
56
67
  required: required,
57
68
  error: error,
58
- helperText: error ? translation("This field is required") : '',
69
+ helperText: error ? translation("This field is required") : "",
59
70
  sx: {
60
- '& .MuiFormHelperText-root': {
61
- color: '#d32f2f !important'
71
+ "& .MuiFormHelperText-root": {
72
+ color: "#d32f2f !important"
62
73
  }
63
74
  }
64
75
  })]
@@ -1,4 +1,4 @@
1
- import { Editor, Element, Path, Transforms } from "slate";
1
+ import { Editor, Path, Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
3
  import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType, getSelectedText } from "./helper";
4
4
  import { isMobileWindow } from "../helper";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "11.1.0",
3
+ "version": "11.1.2",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"