@flozy/editor 11.0.9 → 11.1.0

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.
Files changed (57) hide show
  1. package/dist/Editor/ChatEditor.js +10 -11
  2. package/dist/Editor/CommonEditor.js +14 -66
  3. package/dist/Editor/Editor.css +8 -3
  4. package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
  5. package/dist/Editor/Elements/AI/Styles.js +0 -1
  6. package/dist/Editor/Elements/Accordion/Accordion.js +22 -28
  7. package/dist/Editor/Elements/Accordion/AccordionButton.js +3 -12
  8. package/dist/Editor/Elements/Button/EditorButton.js +0 -1
  9. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
  10. package/dist/Editor/Elements/Embed/Embed.js +2 -1
  11. package/dist/Editor/Elements/Embed/Image.js +1 -0
  12. package/dist/Editor/Elements/Form/Form.js +10 -35
  13. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +4 -2
  14. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +3 -3
  15. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  16. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -3
  17. package/dist/Editor/Elements/Signature/SignaturePopup.js +6 -24
  18. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  19. package/dist/Editor/Elements/Table/Table.js +3 -3
  20. package/dist/Editor/Elements/Title/title.js +6 -6
  21. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  22. package/dist/Editor/MiniEditor.js +1 -2
  23. package/dist/Editor/Styles/EditorStyles.js +1 -5
  24. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -2
  25. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +7 -25
  26. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -10
  27. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +3 -5
  28. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +2 -7
  29. package/dist/Editor/Toolbar/PopupTool/index.js +0 -1
  30. package/dist/Editor/Toolbar/toolbarGroups.js +4 -8
  31. package/dist/Editor/common/ColorPickerButton.js +0 -3
  32. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  33. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
  34. package/dist/Editor/common/MentionsPopup/index.js +1 -9
  35. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +0 -1
  36. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -7
  37. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  38. package/dist/Editor/common/RnD/VirtualElement/helper.js +62 -72
  39. package/dist/Editor/common/Shorthands/elements.js +4 -8
  40. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  41. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  42. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +3 -3
  43. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  44. package/dist/Editor/common/Uploader.js +6 -13
  45. package/dist/Editor/commonStyle.js +15 -30
  46. package/dist/Editor/helper/index.js +1 -6
  47. package/dist/Editor/hooks/useMouseMove.js +4 -1
  48. package/dist/Editor/plugins/withEmbeds.js +0 -11
  49. package/dist/Editor/plugins/withHTML.js +0 -2
  50. package/dist/Editor/utils/SlateUtilityFunctions.js +3 -30
  51. package/dist/Editor/utils/accordion.js +39 -67
  52. package/dist/Editor/utils/draftToSlate.js +2 -3
  53. package/dist/Editor/utils/events.js +89 -94
  54. package/dist/Editor/utils/helper.js +20 -24
  55. package/package.json +4 -4
  56. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  57. package/dist/Editor/helper/textIndeces.js +0 -58
@@ -153,6 +153,14 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
153
153
  // needLayout = true,
154
154
  } = otherProps || {};
155
155
  const mentionsRef = useRef();
156
+ const customProps = {
157
+ ...(otherProps || {}),
158
+ hideTools: ["settings", "add_column", "drag", "resize"],
159
+ readOnly: isReadOnly,
160
+ editorPlaceholder: "Write Something",
161
+ page_id: 1,
162
+ translation: translation || translationMock
163
+ };
156
164
  const [mentions, setMentions] = useMentions({
157
165
  editor,
158
166
  selection: editor?.selection
@@ -214,15 +222,6 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
214
222
  debounced(newValue);
215
223
  debouncedValue.current = newValue;
216
224
  };
217
- const dummyTranslation = () => {};
218
- const customProps = {
219
- ...(otherProps || {}),
220
- hideTools: ["settings", "add_column", "drag", "resize"],
221
- readOnly: isReadOnly,
222
- editorPlaceholder: "Write Something",
223
- page_id: 1,
224
- translation: translation || translationMock || dummyTranslation
225
- };
226
225
  const Element = props => {
227
226
  return getBlock(props);
228
227
  };
@@ -298,10 +297,10 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
298
297
  }
299
298
  };
300
299
 
301
- const html = isMarkDown ? convertMDToHTML(markDownContent) : null;
302
300
  const handleFocus = () => {
303
301
  setIsFocused(true);
304
302
  };
303
+ const html = isMarkDown ? convertMDToHTML(markDownContent) : null;
305
304
  return !isMarkDown ? /*#__PURE__*/_jsx(EditorProvider, {
306
305
  theme: theme,
307
306
  editor: editor,
@@ -315,13 +314,13 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
315
314
  closeMainPopup: handleClose,
316
315
  customProps: customProps
317
316
  }), /*#__PURE__*/_jsx(Editable, {
317
+ onFocus: handleFocus,
318
318
  className: "chatEditorRoot",
319
319
  renderElement: renderElement,
320
320
  renderLeaf: renderLeaf,
321
321
  decorate: decorators,
322
322
  placeholder: "Start typing ...",
323
323
  spellCheck: true,
324
- onFocus: handleFocus,
325
324
  onBlur: handleBlur,
326
325
  onKeyDown: onKeyDown,
327
326
  onPaste: handlePaste,
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle, createContext } from "react";
3
3
  import PropTypes from "prop-types";
4
- import { createEditor, Editor, Range, Transforms } from "slate";
4
+ import { createEditor, Range, Transforms } from "slate";
5
5
  import { Slate, Editable, ReactEditor } from "slate-react";
6
6
  import { useDebouncedCallback } from "use-debounce";
7
7
  import { getMarked, getBlock } from "./utils/SlateUtilityFunctions";
@@ -42,7 +42,6 @@ import "animate.css";
42
42
  import FontLoader from "./common/FontLoader/FontLoader";
43
43
  import { ThemeAIIcon, ThemePaintIcon } from "./assets/svg/ThemeIcons";
44
44
  import { CustomDialogComponent } from "./common/CustomDialog";
45
- import { extractTextWithPath, replaceTextPath } from "./helper/textIndeces.js";
46
45
  import { jsx as _jsx } from "react/jsx-runtime";
47
46
  import { jsxs as _jsxs } from "react/jsx-runtime";
48
47
  export const ThemeContext = /*#__PURE__*/createContext(null);
@@ -87,7 +86,6 @@ const updateTopBanner = (content = [], setTopBanner) => {
87
86
  return firstNode?.type === "topbanner" ? firstNode : null;
88
87
  });
89
88
  };
90
- const dummyTranslation = () => {};
91
89
  const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
92
90
  const {
93
91
  id,
@@ -109,8 +107,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
109
107
  const editorWrapper = useRef();
110
108
  const mentionsRef = useRef();
111
109
  const convertedContent = draftToSlate({
112
- data: content,
113
- needLayout: otherProps?.needLayout
110
+ data: content
114
111
  });
115
112
  const [value, setValue] = useState(convertedContent);
116
113
  const [isInteracted, setIsInteracted] = useState(false);
@@ -220,11 +217,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
220
217
  const debounced = useDebouncedCallback(
221
218
  // function
222
219
  value => {
223
- debouncedValue.current = value;
224
220
  const {
225
221
  value: strVal,
226
222
  ...restVal
227
223
  } = getOnSaveData(value);
224
+ debouncedValue.current = value;
228
225
  onSave(strVal, restVal);
229
226
  },
230
227
  // delay in ms
@@ -235,18 +232,14 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
235
232
  return {
236
233
  value: JSON.stringify(val),
237
234
  text: text,
238
- title: serializeToText(title?.children) || ""
235
+ title: serializeToText(title?.children) || "Untitled"
239
236
  };
240
237
  };
241
238
  const getPreviewImage = async (needBackground = false, options = {}) => {
242
239
  ReactEditor.blur(editor);
243
240
  const dom = needBackground ? editorWrapper?.current : editorWrapper?.current.getElementsByClassName("innert-editor-textbox")[0];
244
- const pageBg = options?.fromBrains ? {
245
- pageColor
246
- } : {};
247
241
  const c = await getThumbnailImage(dom, {
248
242
  ...options,
249
- ...pageBg,
250
243
  proxy: `${otherProps?.PAGES_API_HOST}/page/2canvas`
251
244
  });
252
245
  return c;
@@ -585,62 +578,13 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
585
578
  console.log("handleCursorScroll", err);
586
579
  }
587
580
  };
588
- window.getTextIndeces = () => {
589
- try {
590
- const textWithPaths = extractTextWithPath(editor.children, []);
591
- return textWithPaths;
592
- } catch (err) {
593
- console.log(err);
594
- }
595
- };
596
- window.replaceTextIndeces = (path_data = []) => {
597
- try {
598
- const replacedJson = replaceTextPath(JSON.parse(JSON.stringify(editor.children)), path_data);
599
-
600
- // loop delete all
601
- editor.children.forEach(() => {
602
- Transforms.delete(editor, {
603
- at: [0]
604
- });
605
- });
606
-
607
- // Insert new nodes
608
- Transforms.insertNodes(editor, replacedJson, {
609
- at: [0]
610
- });
611
- } catch (err) {
612
- console.log(err);
613
- }
614
- };
615
- window.replaceEditorContent = (fragments = []) => {
616
- try {
617
- // loop delete all
618
- editor.children.forEach(() => {
619
- Transforms.delete(editor, {
620
- at: [0]
621
- });
622
- });
623
-
624
- // Insert new nodes
625
- Transforms.insertNodes(editor, fragments, {
626
- at: [0]
627
- });
628
- } catch (err) {
629
- console.log(err);
630
- }
631
- };
632
581
  return /*#__PURE__*/_jsxs(EditorProvider, {
633
582
  theme: theme,
634
583
  editor: editor,
635
584
  openTheme: openTheme,
636
585
  setOpenTheme: setOpenTheme,
637
586
  triggerRender: triggerRender,
638
- children: [/*#__PURE__*/_jsx(FontLoader, {
639
- otherProps: {
640
- services: otherProps?.services
641
- },
642
- readOnly: readOnly
643
- }), showThemeButtons ? /*#__PURE__*/_jsxs("div", {
587
+ children: [showThemeButtons ? /*#__PURE__*/_jsxs("div", {
644
588
  className: "theme-buttons",
645
589
  children: [/*#__PURE__*/_jsx(IconButton, {
646
590
  onClick: () => setOpenTheme(true),
@@ -653,7 +597,12 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
653
597
  },
654
598
  children: /*#__PURE__*/_jsx(ThemeAIIcon, {})
655
599
  })]
656
- }) : null, /*#__PURE__*/_jsx(DialogWrapper, {
600
+ }) : null, /*#__PURE__*/_jsx(FontLoader, {
601
+ otherProps: {
602
+ services: otherProps?.services
603
+ },
604
+ readOnly: readOnly
605
+ }), /*#__PURE__*/_jsx(DialogWrapper, {
657
606
  classes: classes,
658
607
  ...props,
659
608
  fullScreen: fullScreen,
@@ -741,8 +690,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
741
690
  chars: chars,
742
691
  type: type,
743
692
  theme: theme,
744
- customProps: customProps,
745
- otherProps: customProps
693
+ otherProps: customProps,
694
+ customProps: customProps
746
695
  }) : null, /*#__PURE__*/_jsx(RnDCopy, {
747
696
  readOnly: readOnly
748
697
  })]
@@ -785,9 +734,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
785
734
  setIsTextSelected: setIsTextSelected,
786
735
  customProps: customProps,
787
736
  editorWrapper: editorWrapper
788
- }) : null, !readOnly ? /*#__PURE__*/_jsx(SwitchViewport, {
737
+ }) : null, !readOnly && showViewport ? /*#__PURE__*/_jsx(SwitchViewport, {
789
738
  breakpoint: breakpoint,
790
- show: showViewport,
791
739
  onChange: b => onSwitchBreakpoint(b),
792
740
  translation: translationFn
793
741
  }) : null]
@@ -1132,8 +1132,6 @@ blockquote {
1132
1132
  margin: 0px;
1133
1133
  }
1134
1134
 
1135
-
1136
-
1137
1135
  .content-editable.empty {
1138
1136
  position: relative;
1139
1137
  }
@@ -1370,13 +1368,20 @@ code.markcode {
1370
1368
  background-color: #f3f3f3;
1371
1369
  font-family: 'Source Code Pro' !important;
1372
1370
  }
1373
-
1374
1371
  /* Hide the popper when the reference is hidden */
1375
1372
  .hide-popper-on-overlap[data-popper-escaped],
1376
1373
  .hide-popper-on-overlap[data-popper-reference-hidden] {
1377
1374
  visibility: hidden;
1378
1375
  pointer-events: none;
1379
1376
  }
1377
+ code.markcode {
1378
+ border-radius: 4px;
1379
+ padding: 6px 8px;
1380
+ margin: 8px 0px;
1381
+ display: block;
1382
+ background-color: #f3f3f3;
1383
+ font-family: 'Source Code Pro' !important;
1384
+ }
1380
1385
 
1381
1386
  .theme-buttons {
1382
1387
  display: flex;
@@ -167,7 +167,6 @@ 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("");
171
170
  const selectedEleRef = useRef({});
172
171
  const classes = Styles();
173
172
  const editor = useSlate();
@@ -189,7 +188,6 @@ function PopoverAIInput({
189
188
  useEffect(() => {
190
189
  if (openAI) {
191
190
  scrollToAIInput(editor);
192
- setThreadId("");
193
191
  }
194
192
  }, [openAI]);
195
193
  useEffect(() => {
@@ -198,12 +196,8 @@ function PopoverAIInput({
198
196
  const framePayload = (type, option) => {
199
197
  let payload = {
200
198
  mode: option.mode || 0,
201
- query: option?.inputValue || inputValue,
202
- useSession: true
199
+ query: option?.inputValue || inputValue
203
200
  };
204
- if (threadId) {
205
- payload.threadId = threadId;
206
- }
207
201
  if (option.mode === MODES.translate || option.mode === MODES.rephraseTone) {
208
202
  payload.textOptionInput = type;
209
203
  }
@@ -263,14 +257,12 @@ function PopoverAIInput({
263
257
  setLoading(false);
264
258
  setInputValue("");
265
259
  let {
266
- body: text,
267
- threadId
268
- } = result?.data || {};
260
+ data: text
261
+ } = result || {};
269
262
  if (!text) {
270
263
  onClickOutside();
271
264
  return;
272
265
  }
273
- setThreadId(threadId || "");
274
266
 
275
267
  // if (!option.replace) {
276
268
  if (type === "continue_writing") {
@@ -145,7 +145,6 @@ const Styles = theme => ({
145
145
  "& .option-label": {
146
146
  display: "flex",
147
147
  alignItems: "center",
148
- whiteSpace: 'nowrap',
149
148
  gap: "8px"
150
149
  },
151
150
  "&:hover": {
@@ -1,12 +1,12 @@
1
- import React, { useState } from "react";
2
- import { Transforms } from "slate";
3
- import { useSlateStatic, ReactEditor } from "slate-react";
1
+ import React, { useEffect, useState } from "react";
2
+ import { Editor, Range, Transforms } from "slate";
3
+ import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
4
4
  import AccordionBtnPopup from "./AccordionBtnPopup";
5
5
  import { IconButton, Tooltip, Box } from "@mui/material";
6
6
  import DeleteIcon from "@mui/icons-material/Delete";
7
7
  import { GridSettingsIcon } from "../../common/iconslist";
8
8
  import Icon from "../../common/Icon";
9
- import { useEditorContext } from "../../hooks/useMouseMove";
9
+ import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
10
10
  import useCommonStyle from "../../commonStyle";
11
11
  import { getBorderColor, getTextColor } from "../../helper";
12
12
  import { getBreakPointsValue, getTRBLBreakPoints } from "../../helper/theme";
@@ -75,6 +75,8 @@ const Accordion = props => {
75
75
  const [toggle, setToggle] = useState(false);
76
76
  const [openSetttings, setOpenSettings] = useState(false);
77
77
  const editor = useSlateStatic();
78
+ const [showTool] = useEditorSelection(editor);
79
+ const selected = useSelected();
78
80
  const path = ReactEditor.findPath(editor, element);
79
81
  const {
80
82
  textColor,
@@ -92,33 +94,25 @@ const Accordion = props => {
92
94
  theme
93
95
  } = useEditorContext();
94
96
  const classes = useCommonStyle(theme);
95
-
96
- // useEffect(() => {
97
- // if (!editor.selection || !children[1]) return;
98
-
99
- // try {
100
- // const accordionDetailsElement = element.children?.[1];
101
-
102
- // const detailsPath = ReactEditor.findPath(editor, accordionDetailsElement);
103
-
104
- // const detailsRange = Editor.range(editor, detailsPath);
105
-
106
- // const isInside = Range.intersection(detailsRange, editor.selection);
107
-
108
- // if (isInside && !toggle) {
109
- // setToggle(true);
110
- // }
111
- // } catch (e) {
112
- // console.error(e);
113
- // }
114
- // }, [editor.selection, children]);
115
-
97
+ useEffect(() => {
98
+ if (!editor.selection || !children[1]) return;
99
+ try {
100
+ const accordionDetailsElement = element.children?.[1];
101
+ const detailsPath = ReactEditor.findPath(editor, accordionDetailsElement);
102
+ const detailsRange = Editor.range(editor, detailsPath);
103
+ const isInside = Range.intersection(detailsRange, editor.selection);
104
+ if (isInside && !toggle) {
105
+ setToggle(true);
106
+ }
107
+ } catch (e) {
108
+ console.error(e);
109
+ }
110
+ }, [editor.selection, children]);
116
111
  const onToggle = () => {
117
112
  setToggle(!toggle);
118
- Transforms.deselect(editor);
119
113
  };
120
114
  const ToolBar = () => {
121
- return toggle ? /*#__PURE__*/_jsxs("div", {
115
+ return selected && !showTool ? /*#__PURE__*/_jsxs("div", {
122
116
  className: "element-toolbar hr",
123
117
  contentEditable: false,
124
118
  style: {
@@ -212,6 +206,7 @@ const Accordion = props => {
212
206
  className: "accordion-title"
213
207
  // style={{ background: bgColor, ...borderStyle }}
214
208
  ,
209
+ onClick: onToggle,
215
210
  children: [/*#__PURE__*/_jsx(Box, {
216
211
  role: "button",
217
212
  className: "accordion-summary-collapse-btn",
@@ -226,7 +221,6 @@ const Accordion = props => {
226
221
  },
227
222
  cursor: "pointer"
228
223
  },
229
- onClick: onToggle,
230
224
  children: !toggle ? /*#__PURE__*/_jsx(Icon, {
231
225
  icon: "accordionArrow"
232
226
  }) : /*#__PURE__*/_jsx(Icon, {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { insertAccordion, toggleAccordion } from "../../utils/accordion";
2
+ import { insertAccordion } from "../../utils/accordion";
3
3
  import ToolbarIcon from "../../common/ToolbarIcon";
4
4
  import Icon from "../../common/Icon";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -7,22 +7,13 @@ const AccordionButton = props => {
7
7
  const {
8
8
  editor,
9
9
  icoBtnType,
10
- customProps,
11
- commonProps
10
+ customProps
12
11
  } = props;
13
12
  const {
14
13
  translation
15
14
  } = customProps;
16
- const {
17
- listType
18
- } = commonProps || {};
19
- const isAccordion = listType === "accordion-summary";
20
15
  const handleInsertAccordion = () => {
21
- if (isAccordion) {
22
- toggleAccordion(editor);
23
- } else {
24
- insertAccordion(editor);
25
- }
16
+ insertAccordion(editor);
26
17
  };
27
18
  return /*#__PURE__*/_jsx(ToolbarIcon, {
28
19
  icon: /*#__PURE__*/_jsx(Icon, {
@@ -174,7 +174,6 @@ const EditorButton = props => {
174
174
  display: "inline-flex",
175
175
  color: "rgba(0, 0, 0, 0.54)",
176
176
  marginBottom: "0px !important",
177
- ...classes.buttonMoreOption,
178
177
  ...classes.buttonMoreOption3
179
178
  },
180
179
  ...btnProps,