@flozy/editor 3.7.1 → 3.7.3

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 (104) hide show
  1. package/dist/Editor/ChatEditor.js +211 -0
  2. package/dist/Editor/CommonEditor.js +169 -111
  3. package/dist/Editor/Elements/Accordion/Accordion.js +74 -7
  4. package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +3 -2
  5. package/dist/Editor/Elements/Accordion/AccordionSummary.js +4 -60
  6. package/dist/Editor/Elements/AppHeader/AppHeader.js +26 -4
  7. package/dist/Editor/Elements/Button/EditorButton.js +34 -18
  8. package/dist/Editor/Elements/ChipText/ChipText.js +3 -3
  9. package/dist/Editor/Elements/Color Picker/ColorButtons.js +60 -17
  10. package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
  11. package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
  12. package/dist/Editor/Elements/Color Picker/Styles.js +2 -1
  13. package/dist/Editor/Elements/Embed/Frames/ImageFrame.js +1 -0
  14. package/dist/Editor/Elements/Embed/Image.js +28 -20
  15. package/dist/Editor/Elements/Embed/Video.js +15 -11
  16. package/dist/Editor/Elements/Emoji/EmojiButton.js +2 -2
  17. package/dist/Editor/Elements/Emoji/EmojiPicker.js +16 -0
  18. package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +12 -3
  19. package/dist/Editor/Elements/Form/Workflow/UserInputs.js +2 -1
  20. package/dist/Editor/Elements/Grid/Grid.js +3 -1
  21. package/dist/Editor/Elements/Grid/GridItem.js +4 -2
  22. package/dist/Editor/Elements/InlineIcon/InlineIcon.js +2 -3
  23. package/dist/Editor/Elements/Link/Link.js +6 -1
  24. package/dist/Editor/Elements/Link/LinkButton.js +4 -2
  25. package/dist/Editor/Elements/Link/LinkPopup.js +11 -3
  26. package/dist/Editor/Elements/Link/LinkPopupStyles.js +28 -0
  27. package/dist/Editor/Elements/List/CheckList.js +6 -2
  28. package/dist/Editor/Elements/Table/TableCell.js +1 -1
  29. package/dist/Editor/MiniEditor.js +3 -1
  30. package/dist/Editor/Styles/EditorStyles.js +3 -2
  31. package/dist/Editor/Toolbar/Basic/index.js +4 -2
  32. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +26 -2
  33. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  34. package/dist/Editor/Toolbar/FormatTools/TextSize.js +5 -11
  35. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +4 -11
  36. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +213 -86
  37. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
  38. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +20 -13
  39. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +52 -7
  40. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +438 -0
  41. package/dist/Editor/Toolbar/PopupTool/index.js +9 -2
  42. package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
  43. package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
  44. package/dist/Editor/common/ColorPickerButton.js +25 -9
  45. package/dist/Editor/common/CustomColorPicker/index.js +106 -0
  46. package/dist/Editor/common/CustomColorPicker/style.js +53 -0
  47. package/dist/Editor/common/CustomDialog/index.js +94 -0
  48. package/dist/Editor/common/CustomDialog/style.js +67 -0
  49. package/dist/Editor/common/CustomSelect.js +33 -0
  50. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  51. package/dist/Editor/common/EditorCmds.js +35 -0
  52. package/dist/Editor/common/Icon.js +30 -2
  53. package/dist/Editor/common/MUIIcon/index.js +48 -0
  54. package/dist/Editor/common/MentionsPopup/MentionsListCard.js +5 -2
  55. package/dist/Editor/common/MentionsPopup/Styles.js +6 -3
  56. package/dist/Editor/common/Shorthands/elements.js +54 -0
  57. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +7 -7
  58. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +16 -16
  59. package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
  60. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +13 -3
  61. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
  62. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +31 -7
  63. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
  64. package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +12 -28
  65. package/dist/Editor/common/StyleBuilder/fieldTypes/loadIcon.js +13 -0
  66. package/dist/Editor/common/StyleBuilder/fieldTypes/mui_filled_icons.js +2 -0
  67. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +14 -4
  68. package/dist/Editor/common/StyleBuilder/formStyle.js +25 -26
  69. package/dist/Editor/common/StyleBuilder/index.js +1 -1
  70. package/dist/Editor/helper/index.js +15 -0
  71. package/dist/Editor/helper/theme.js +190 -4
  72. package/dist/Editor/hooks/useEditorTheme.js +139 -0
  73. package/dist/Editor/hooks/useMouseMove.js +15 -6
  74. package/dist/Editor/plugins/withEmbeds.js +1 -1
  75. package/dist/Editor/plugins/withHTML.js +47 -5
  76. package/dist/Editor/plugins/withLayout.js +15 -10
  77. package/dist/Editor/plugins/withTable.js +2 -2
  78. package/dist/Editor/theme/ThemeList.js +50 -173
  79. package/dist/Editor/theme/index.js +144 -0
  80. package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
  81. package/dist/Editor/themeSettings/buttons/index.js +290 -0
  82. package/dist/Editor/themeSettings/buttons/style.js +21 -0
  83. package/dist/Editor/themeSettings/colorTheme/index.js +290 -0
  84. package/dist/Editor/themeSettings/colorTheme/style.js +77 -0
  85. package/dist/Editor/themeSettings/fonts/PreviewElement.js +123 -0
  86. package/dist/Editor/themeSettings/fonts/index.js +213 -0
  87. package/dist/Editor/themeSettings/fonts/style.js +44 -0
  88. package/dist/Editor/themeSettings/icons.js +60 -0
  89. package/dist/Editor/themeSettings/index.js +320 -0
  90. package/dist/Editor/themeSettings/style.js +152 -0
  91. package/dist/Editor/themeSettingsAI/icons.js +96 -0
  92. package/dist/Editor/themeSettingsAI/index.js +356 -0
  93. package/dist/Editor/themeSettingsAI/saveTheme.js +190 -0
  94. package/dist/Editor/themeSettingsAI/style.js +247 -0
  95. package/dist/Editor/utils/SlateUtilityFunctions.js +157 -25
  96. package/dist/Editor/utils/button.js +1 -17
  97. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +361 -0
  98. package/dist/Editor/utils/events.js +11 -4
  99. package/dist/Editor/utils/font.js +40 -37
  100. package/dist/Editor/utils/form.js +2 -2
  101. package/dist/Editor/utils/helper.js +71 -12
  102. package/dist/Editor/utils/serializeToHTML.js +25 -13
  103. package/dist/index.js +5 -1
  104. package/package.json +4 -4
@@ -0,0 +1,211 @@
1
+ import React, { useCallback, useMemo, useRef, useState, useEffect, useImperativeHandle, forwardRef } from "react";
2
+ import { Editable, Slate, ReactEditor } from 'slate-react';
3
+ import { createEditor } from 'slate';
4
+ import { useDebounce } from "use-debounce";
5
+ import withCommon from "./hooks/withCommon";
6
+ import { getBlock, getMarked } from "./utils/chatEditor/SlateUtilityFunctions";
7
+ import MiniTextFormat from "./Toolbar/PopupTool/MiniTextFormat";
8
+ import { commands, mentionsEvent } from "./utils/events";
9
+ import { insertEmoji } from "./utils/emoji";
10
+ import { draftToSlate } from "./utils/draftToSlate";
11
+ import MentionsPopup from "./common/MentionsPopup";
12
+ import { serializeToText } from "./utils/serializeToText";
13
+ import useMentions from "./hooks/useMentions";
14
+ import Shorthands from "./common/Shorthands";
15
+ import usePopupStyle from "./Toolbar/PopupTool/PopupToolStyle";
16
+ import { EditorProvider } from "./hooks/useMouseMove";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
20
+ const {
21
+ id,
22
+ theme,
23
+ content,
24
+ readOnly,
25
+ otherProps,
26
+ needLayout = false,
27
+ toolBar = true,
28
+ onSave,
29
+ onsubmit
30
+ } = props;
31
+ const classes = usePopupStyle(theme);
32
+ const convertedContent = draftToSlate({
33
+ data: content
34
+ });
35
+ const [isInteracted, setIsInteracted] = useState(false);
36
+ const [value, setValue] = useState(convertedContent);
37
+ const [loadedValue] = useState(value);
38
+ const [deboundedValue] = useDebounce(value, 500);
39
+ const editor = useMemo(() => {
40
+ return withCommon(createEditor(), {
41
+ needLayout
42
+ });
43
+ }, []);
44
+ const isReadOnly = readOnly === "readonly";
45
+ useImperativeHandle(ref, () => ({
46
+ emojiClick: emoji => {
47
+ if (editor) {
48
+ insertEmoji(editor, emoji?.native, editor.selection);
49
+ ReactEditor.focus(editor);
50
+ }
51
+ },
52
+ // Focus enable
53
+ enableFocus: () => {
54
+ if (editor) {
55
+ ReactEditor.focus(editor);
56
+ }
57
+ }
58
+ }));
59
+ useEffect(() => {
60
+ setValue(draftToSlate({
61
+ data: content
62
+ }));
63
+ }, [id, content]);
64
+ useEffect(() => {
65
+ if (JSON.stringify(loadedValue) !== JSON.stringify(deboundedValue) && isInteracted && onSave) {
66
+ const {
67
+ value: strVal,
68
+ ...restVal
69
+ } = getOnSaveData(deboundedValue);
70
+ onSave(strVal, restVal);
71
+ }
72
+ }, [deboundedValue]);
73
+ const getOnSaveData = val => {
74
+ const text = serializeToText(val);
75
+ const title = val?.find(f => f.type === "title");
76
+ return {
77
+ value: JSON.stringify(val),
78
+ text: text,
79
+ title: serializeToText(title?.children) || "Untitled"
80
+ };
81
+ };
82
+ const {
83
+ CHARACTERS = [],
84
+ hideTools
85
+ // needLayout = true,
86
+ } = otherProps || {};
87
+ const mentionsRef = useRef();
88
+ const customProps = {
89
+ ...(otherProps || {}),
90
+ readOnly: isReadOnly,
91
+ editorPlaceholder: "Write Something",
92
+ page_id: 1
93
+ };
94
+ const [mentions, setMentions] = useMentions({
95
+ editor,
96
+ selection: editor?.selection
97
+ });
98
+ const {
99
+ search,
100
+ target,
101
+ index
102
+ } = mentions;
103
+ let {
104
+ type
105
+ } = mentions;
106
+ if (type && type === "elements" && hideTools.indexOf("slash") > -1) {
107
+ type = null;
108
+ }
109
+ const chars = type ? Shorthands[type]({
110
+ ...mentions,
111
+ CHARACTERS,
112
+ hideTools: hideTools
113
+ }) : [];
114
+ const Leaf = ({
115
+ attributes,
116
+ children,
117
+ leaf
118
+ }) => {
119
+ children = getMarked(leaf, children);
120
+ return /*#__PURE__*/_jsx("span", {
121
+ ...attributes,
122
+ children: children
123
+ });
124
+ };
125
+ const handleEditorChange = newValue => {
126
+ setValue(newValue);
127
+ if (!isInteracted) {
128
+ setIsInteracted(true);
129
+ }
130
+ };
131
+ const Element = props => {
132
+ return getBlock(props);
133
+ };
134
+ const renderElement = useCallback(props => {
135
+ return /*#__PURE__*/_jsx(Element, {
136
+ ...props,
137
+ customProps: customProps
138
+ });
139
+ }, []);
140
+ const renderLeaf = useCallback(props => {
141
+ return /*#__PURE__*/_jsx(Leaf, {
142
+ ...props,
143
+ customProps: customProps
144
+ });
145
+ }, []);
146
+ const onKeyDown = useCallback(event => {
147
+ const isMetaKey = event.metaKey && event.keyCode >= 65 && event.keyCode <= 90;
148
+ const isCtrlKey = event.ctrlKey || isMetaKey;
149
+ if (target && chars.length > 0 && !isCtrlKey) {
150
+ mentionsEvent({
151
+ event,
152
+ mentions,
153
+ setMentions,
154
+ chars,
155
+ target,
156
+ editor,
157
+ type,
158
+ mentionsRef
159
+ });
160
+ } else if (isCtrlKey) {
161
+ commands({
162
+ event,
163
+ editor
164
+ });
165
+ } else if (event.key === "Enter" && !event.shiftKey) {
166
+ const {
167
+ value: strVal,
168
+ ...restVal
169
+ } = getOnSaveData(value);
170
+ onsubmit(false, {
171
+ strVal,
172
+ restVal
173
+ });
174
+ }
175
+ }, [chars, editor, target, mentions, setMentions, search, type, mentionsRef]);
176
+ const handleClose = () => {};
177
+ return /*#__PURE__*/_jsx(EditorProvider, {
178
+ theme: theme,
179
+ editor: editor,
180
+ children: /*#__PURE__*/_jsxs(Slate, {
181
+ editor: editor,
182
+ initialValue: value,
183
+ onChange: handleEditorChange,
184
+ children: [toolBar && /*#__PURE__*/_jsx(MiniTextFormat, {
185
+ classes: classes,
186
+ editor: editor,
187
+ closeMainPopup: handleClose
188
+ }), /*#__PURE__*/_jsx(Editable, {
189
+ className: "chatEditorRoot",
190
+ renderElement: renderElement,
191
+ renderLeaf: renderLeaf,
192
+ placeholder: "Start typing ...",
193
+ spellCheck: true,
194
+ autoFocus: true,
195
+ onKeyDown: onKeyDown
196
+ }), !readOnly ? /*#__PURE__*/_jsx(MentionsPopup, {
197
+ ref: mentionsRef,
198
+ mentions: mentions,
199
+ setMentions: setMentions,
200
+ editor: editor,
201
+ target: target,
202
+ index: index,
203
+ chars: chars,
204
+ type: type,
205
+ theme: theme
206
+ }) : null]
207
+ }, id)
208
+ });
209
+ });
210
+ ChatEditor.displayName = "ChatEditor";
211
+ export default ChatEditor;
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
- import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle } from "react";
2
+ import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle, createContext } from "react";
3
3
  import { createEditor, Transforms } from "slate";
4
4
  import { Slate, Editable, ReactEditor } from "slate-react";
5
5
  import { useDebounce, useDebouncedCallback } from "use-debounce";
@@ -18,7 +18,7 @@ import { getThumbnailImage, invertColor } from "./helper";
18
18
  import PopupTool from "./Toolbar/PopupTool";
19
19
  import "./font.css";
20
20
  import "./Editor.css";
21
- import { Box, Button, Typography } from "@mui/material";
21
+ import { Box, IconButton, Typography } from "@mui/material";
22
22
  import Shorthands from "./common/Shorthands";
23
23
  import MiniToolbar from "./Toolbar/Mini/MiniToolbar";
24
24
  import { EditorProvider } from "./hooks/useMouseMove";
@@ -28,12 +28,19 @@ import DragAndDrop from "./common/DnD";
28
28
  import Section from "./common/Section";
29
29
  import "animate.css";
30
30
  import decorators from "./utils/Decorators";
31
- import { getTRBLBreakPoints } from "./helper/theme";
32
- import { handleInsertLastElement, outsideEditorClickLabel } from "./utils/helper";
31
+ import { getTRBLBreakPoints, getVariableValue } from "./helper/theme";
32
+ import { handleInsertLastElement, onDeleteKey, outsideEditorClickLabel } from "./utils/helper";
33
33
  import useWindowResize from "./hooks/useWindowResize";
34
+ import { getTheme } from "./theme";
35
+ import { useTheme } from "@emotion/react";
36
+ import ThemeSettings from "./themeSettings";
37
+ import ThemeSettingsAI from "./themeSettingsAI";
38
+ import { Experimental_CssVarsProvider as CssVarsProvider, experimental_extendTheme as extendTheme } from "@mui/material/styles";
34
39
  import PopoverAIInput from "./Elements/AI/PopoverAIInput";
40
+ import { ThemeAIIcon, ThemePaintIcon } from "./assets/svg/ThemeIcons";
35
41
  import { jsx as _jsx } from "react/jsx-runtime";
36
42
  import { jsxs as _jsxs } from "react/jsx-runtime";
43
+ export const ThemeContext = /*#__PURE__*/createContext(null);
37
44
  const Item = /*#__PURE__*/forwardRef(({
38
45
  children,
39
46
  ...props
@@ -60,7 +67,8 @@ const Leaf = ({
60
67
  children,
61
68
  leaf
62
69
  }) => {
63
- children = getMarked(leaf, children);
70
+ const theme = useTheme();
71
+ children = getMarked(leaf, children, theme);
64
72
  return /*#__PURE__*/_jsx("span", {
65
73
  ...attributes,
66
74
  children: children
@@ -79,7 +87,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
79
87
  toolbarOptions,
80
88
  otherProps,
81
89
  isIframe,
82
- theme
90
+ theme,
91
+ showThemeButtons
83
92
  } = props;
84
93
  const editorWrapper = useRef();
85
94
  const mentionsRef = useRef();
@@ -123,10 +132,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
123
132
  const {
124
133
  bannerSpacing,
125
134
  pageBgImage,
126
- pageColor,
135
+ pageColor = "",
127
136
  color: pageTextColor,
128
137
  pageWidth,
129
- maxWidth: pageMaxWidth
138
+ maxWidth: pageMaxWidth,
139
+ theme: selectedTheme
130
140
  } = pageSt?.pageProps || {
131
141
  bannerSpacing: {
132
142
  left: 0,
@@ -137,9 +147,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
137
147
  };
138
148
  const classes = editorStyles({
139
149
  padHeight: !fullScreen ? otherProps?.padHeight : 20,
140
- placeHolderColor: invertColor(pageColor || "#FFF"),
150
+ placeHolderColor: invertColor(pageColor.startsWith("var") ? getVariableValue(pageColor) : pageColor || "#FFF"),
141
151
  theme
142
152
  });
153
+ const [openTheme, setOpenTheme] = useState(false);
154
+ const [openAITheme, setOpenAITheme] = useState(false);
143
155
  useEffect(() => {
144
156
  setValue(draftToSlate({
145
157
  data: content
@@ -239,6 +251,12 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
239
251
  redo() {
240
252
  editor?.redo();
241
253
  },
254
+ toggleTheme() {
255
+ setOpenTheme(!openTheme);
256
+ },
257
+ toggleAITheme() {
258
+ setOpenAITheme(!openAITheme);
259
+ },
242
260
  getPageSettings: {
243
261
  background: pageBgImage && pageBgImage !== "none" ? `url(${pageBgImage})` : pageColor || ""
244
262
  }
@@ -319,7 +337,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
319
337
  } else if (isCtrlKey) {
320
338
  commands({
321
339
  event,
322
- editor
340
+ editor,
341
+ needLayout
323
342
  });
324
343
  } else if (event.key === "Tab") {
325
344
  event.preventDefault();
@@ -385,113 +404,152 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
385
404
  }
386
405
  return style;
387
406
  }, [pageBgImage, pageColor]);
388
- return /*#__PURE__*/_jsx(EditorProvider, {
389
- theme: theme,
390
- editor: editor,
391
- children: /*#__PURE__*/_jsx(DialogWrapper, {
392
- classes: classes,
393
- ...props,
394
- fullScreen: fullScreen,
395
- footer: footer || "",
396
- children: /*#__PURE__*/_jsx(Box, {
397
- component: "div",
398
- className: `${editorClass || ""} ${isIframe ? "iframe-editor" : ""}`,
399
- sx: classes.root,
400
- style: {
401
- ...dotBg
402
- },
403
- children: /*#__PURE__*/_jsxs(Slate, {
404
- editor: editor,
405
- initialValue: value,
406
- onChange: handleEditorChange,
407
- children: [/*#__PURE__*/_jsx(DragAndDrop, {
408
- children: /*#__PURE__*/_jsxs(Overlay, {
409
- children: [/*#__PURE__*/_jsx(Box, {
410
- className: `${hasTopBanner() ? "has-topbanner" : ""} ${!pageColor ? "no-color" : ""} ${isScrolling ? "" : "hideScroll"} scrollable-content scrollSmooth`,
411
- sx: classes.slateWrapper,
412
- id: "slate-wrapper-scroll-container"
413
- // style={editorWrapperStyle}
414
- ,
415
- ref: editorWrapper,
416
- onClick: e => {
417
- handleInsertLastElement(e, editor);
418
- },
419
- onScroll: handleScroll,
420
- style: editorWrapperStyle,
421
- children: /*#__PURE__*/_jsxs(Box, {
422
- component: "div",
423
- className: "max-content",
424
- "data-info": outsideEditorClickLabel,
425
- children: [renderTopBanner(), /*#__PURE__*/_jsx("div", {
426
- className: "scroll-area",
427
- "data-info": outsideEditorClickLabel,
407
+ const themeProps = getTheme(selectedTheme);
408
+ return /*#__PURE__*/_jsx(ThemeContext.Provider, {
409
+ value: {
410
+ openTheme,
411
+ setOpenTheme
412
+ },
413
+ children: /*#__PURE__*/_jsx(CssVarsProvider, {
414
+ theme: extendTheme(selectedTheme?.theme?.cssVars || {}),
415
+ children: /*#__PURE__*/_jsxs(EditorProvider, {
416
+ theme: theme,
417
+ editor: editor,
418
+ children: [showThemeButtons ? /*#__PURE__*/_jsxs("div", {
419
+ style: {
420
+ display: "flex",
421
+ justifyContent: "end",
422
+ alignItems: "center",
423
+ gap: "8px",
424
+ width: "70vw",
425
+ margin: "auto"
426
+ },
427
+ children: [/*#__PURE__*/_jsx(IconButton, {
428
+ onClick: () => setOpenTheme(true),
429
+ children: /*#__PURE__*/_jsx(ThemePaintIcon, {})
430
+ }), /*#__PURE__*/_jsx(IconButton, {
431
+ onClick: () => setOpenAITheme(true),
432
+ style: {
433
+ marginTop: "4px"
434
+ },
435
+ children: /*#__PURE__*/_jsx(ThemeAIIcon, {})
436
+ })]
437
+ }) : null, /*#__PURE__*/_jsx(DialogWrapper, {
438
+ classes: classes,
439
+ ...props,
440
+ fullScreen: fullScreen,
441
+ footer: footer || "",
442
+ children: /*#__PURE__*/_jsx(Box, {
443
+ component: "div",
444
+ className: `${editorClass || ""} ${isIframe ? "iframe-editor" : ""}`,
445
+ sx: classes.root,
446
+ style: {
447
+ ...dotBg
448
+ },
449
+ children: /*#__PURE__*/_jsxs(Slate, {
450
+ editor: editor,
451
+ initialValue: value,
452
+ onChange: handleEditorChange,
453
+ children: [/*#__PURE__*/_jsx(DragAndDrop, {
454
+ children: /*#__PURE__*/_jsxs(Overlay, {
455
+ children: [/*#__PURE__*/_jsx(Box, {
456
+ className: `${hasTopBanner() ? "has-topbanner" : ""} ${!pageColor ? "no-color" : ""} ${isScrolling ? "" : "hideScroll"} scrollable-content scrollSmooth`,
457
+ sx: classes.slateWrapper,
458
+ id: "slate-wrapper-scroll-container"
459
+ // style={editorWrapperStyle}
460
+ ,
461
+ ref: editorWrapper,
462
+ onClick: e => {
463
+ handleInsertLastElement(e, editor);
464
+ },
465
+ onScroll: handleScroll,
466
+ style: editorWrapperStyle,
428
467
  children: /*#__PURE__*/_jsxs(Box, {
429
468
  component: "div",
430
- className: `editor-wrapper ${pageWidth === "fixed" ? "fixed" : "full"}`,
431
- sx: {
432
- backgroundColor: "transparent",
433
- padding: {
434
- ...getTRBLBreakPoints(bannerSpacing)
435
- },
436
- width: !pageWidth || pageWidth === "fixed" ? fixedWidth : fullWidth,
437
- height: viewport.h ? `${viewport.h}px` : `100%`,
438
- alignSelf: "center",
439
- transformOrigin: "left top",
440
- transition: "all 0.3s",
441
- minHeight: "87%",
442
- maxWidth: pageMaxWidth ? `${parseInt(pageMaxWidth)}px !important` : "auto"
443
- },
469
+ className: "max-content",
470
+ sx: themeProps?.sxProps || {},
444
471
  "data-info": outsideEditorClickLabel,
445
- children: [/*#__PURE__*/_jsx(Editable, {
446
- className: "innert-editor-textbox",
447
- readOnly: isReadOnly,
448
- renderElement: renderElement,
449
- renderLeaf: renderLeaf,
450
- decorate: decorators,
451
- onKeyDown: onKeyDown
452
- }), !readOnly ? /*#__PURE__*/_jsx(MentionsPopup, {
453
- ref: mentionsRef,
454
- mentions: mentions,
455
- setMentions: setMentions,
456
- editor: editor,
457
- target: target,
458
- index: index,
459
- chars: chars,
460
- type: type,
472
+ children: [renderTopBanner(), /*#__PURE__*/_jsx("div", {
473
+ className: "scroll-area",
474
+ "data-info": outsideEditorClickLabel,
475
+ children: /*#__PURE__*/_jsxs(Box, {
476
+ component: "div",
477
+ className: `editor-wrapper ${pageWidth === "fixed" ? "fixed" : "full"}`,
478
+ sx: {
479
+ backgroundColor: "transparent",
480
+ padding: {
481
+ ...getTRBLBreakPoints(bannerSpacing)
482
+ },
483
+ width: !pageWidth || pageWidth === "fixed" ? fixedWidth : fullWidth,
484
+ height: viewport.h ? `${viewport.h}px` : `100%`,
485
+ alignSelf: "center",
486
+ transformOrigin: "left top",
487
+ transition: "all 0.3s",
488
+ minHeight: "87%",
489
+ maxWidth: pageMaxWidth ? `${parseInt(pageMaxWidth)}px !important` : "auto"
490
+ },
491
+ "data-info": outsideEditorClickLabel,
492
+ children: [/*#__PURE__*/_jsx(Editable, {
493
+ className: "innert-editor-textbox",
494
+ readOnly: isReadOnly,
495
+ renderElement: renderElement,
496
+ renderLeaf: renderLeaf,
497
+ decorate: decorators,
498
+ onKeyDown: onKeyDown
499
+ }), !readOnly ? /*#__PURE__*/_jsx(MentionsPopup, {
500
+ ref: mentionsRef,
501
+ mentions: mentions,
502
+ setMentions: setMentions,
503
+ editor: editor,
504
+ target: target,
505
+ index: index,
506
+ chars: chars,
507
+ type: type,
508
+ theme: theme
509
+ }) : null]
510
+ })
511
+ }), !hideMiniToolBar ? /*#__PURE__*/_jsx(MiniToolbar, {
512
+ customProps: customProps,
513
+ toolbarOptions: toolbarOptions,
461
514
  theme: theme
462
- }) : null]
515
+ }) : null, /*#__PURE__*/_jsx(PopoverAIInput, {
516
+ otherProps: otherProps || {}
517
+ }), footer && (fullScreen || readOnly) && /*#__PURE__*/_jsx(Typography, {
518
+ sx: {
519
+ color: "rgb(100, 116, 139)",
520
+ fontSize: "13px",
521
+ paddingBottom: hideMiniToolBar ? "0px" : "12px",
522
+ cursor: "pointer"
523
+ },
524
+ align: "center",
525
+ "data-info": outsideEditorClickLabel,
526
+ onClick: handleFooterClick,
527
+ children: footer
528
+ }), openTheme ? /*#__PURE__*/_jsx(ThemeSettings, {
529
+ open: openTheme,
530
+ setOpen: setOpenTheme,
531
+ editor: editor,
532
+ services: otherProps?.services
533
+ }) : null, /*#__PURE__*/_jsx(ThemeSettingsAI, {
534
+ openAITheme: openAITheme,
535
+ setOpenAITheme: setOpenAITheme,
536
+ onSaveTheme: otherProps?.onSaveTheme
537
+ })]
463
538
  })
464
- }), !hideMiniToolBar ? /*#__PURE__*/_jsx(MiniToolbar, {
465
- customProps: customProps,
466
- toolbarOptions: toolbarOptions,
467
- theme: theme
468
- }) : null, /*#__PURE__*/_jsx(PopoverAIInput, {
469
- otherProps: otherProps || {}
470
- }), footer && (fullScreen || readOnly) && /*#__PURE__*/_jsx(Typography, {
471
- sx: {
472
- color: "rgb(100, 116, 139)",
473
- fontSize: "13px",
474
- paddingBottom: hideMiniToolBar ? "0px" : "12px",
475
- cursor: "pointer"
476
- },
477
- align: "center",
478
- "data-info": outsideEditorClickLabel,
479
- onClick: handleFooterClick,
480
- children: footer
481
- })]
539
+ }), !readOnly ? /*#__PURE__*/_jsx(PopupTool, {
540
+ onDrawerOpen: onDrawerOpen,
541
+ theme: theme,
542
+ setIsTextSelected: setIsTextSelected,
543
+ customProps: customProps
544
+ }) : null]
482
545
  })
483
- }), !readOnly ? /*#__PURE__*/_jsx(PopupTool, {
484
- onDrawerOpen: onDrawerOpen,
485
- theme: theme,
486
- setIsTextSelected: setIsTextSelected,
487
- customProps: customProps
488
- }) : null]
489
- })
490
- }), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
491
- ...htmlAction,
492
- handleCodeToText: handleCodeToText
493
- })]
494
- }, id)
546
+ }), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
547
+ ...htmlAction,
548
+ handleCodeToText: handleCodeToText
549
+ })]
550
+ }, id)
551
+ })
552
+ })]
495
553
  })
496
554
  })
497
555
  });
@@ -9,6 +9,55 @@ import Icon from "../../common/Icon";
9
9
  import { useEditorSelection } from "../../hooks/useMouseMove";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ const accordionBtnStyleKeys = {
13
+ accordionTextColor: "textColor",
14
+ accordionBgColor: "bgColor",
15
+ accordionBorderColor: "borderColor"
16
+ };
17
+ const getAccordionData = updateData => {
18
+ const accordionBtnStyle = {}; // accordion btn style will come under type: accordion node
19
+ const accordionTitleStyle = {}; // accordion title style will come under type: accordion-summary node
20
+
21
+ Object.entries(updateData).forEach(([key, value]) => {
22
+ const accordionBtnStyleKey = accordionBtnStyleKeys[key];
23
+ if (accordionBtnStyleKey) {
24
+ // converting accordion button elementProp keys to node keys e.g: accordionTextColor -> textColor
25
+ accordionBtnStyle[accordionBtnStyleKey] = value;
26
+ return;
27
+ }
28
+ accordionTitleStyle[key] = value;
29
+ });
30
+ return {
31
+ accordionBtnStyle,
32
+ accordionTitleStyle
33
+ };
34
+ };
35
+ const convertAccordionBtnStyleKeys = (data = {}) => {
36
+ const style = {
37
+ ...data
38
+ };
39
+ Object.entries(accordionBtnStyleKeys).forEach(([key, value]) => {
40
+ const val = data[value];
41
+ if (val) {
42
+ // deleting the existing style key in node e.g: textColor
43
+ delete style[value];
44
+
45
+ // convertint into new key in element props e.g: accordionTextColor
46
+ style[key] = val;
47
+ }
48
+ });
49
+ return style;
50
+ };
51
+ const getElementProps = element => {
52
+ const accordionSummary = element.children?.find(c => c.type === "accordion-summary");
53
+
54
+ // joining accordion title and button styles
55
+ const elementProps = {
56
+ ...accordionSummary,
57
+ ...convertAccordionBtnStyleKeys(element)
58
+ };
59
+ return elementProps;
60
+ };
12
61
  const Accordion = props => {
13
62
  const {
14
63
  attributes,
@@ -69,16 +118,34 @@ const Accordion = props => {
69
118
  at: path
70
119
  });
71
120
  };
121
+ const setNodes = (data, path) => {
122
+ Transforms.setNodes(editor, data, {
123
+ at: path
124
+ });
125
+ };
72
126
  const onSave = data => {
73
127
  const updateData = {
74
128
  ...data
75
129
  };
76
- delete updateData.children;
77
- Transforms.setNodes(editor, {
78
- ...updateData
79
- }, {
80
- at: path
81
- });
130
+ const {
131
+ accordionBtnStyle,
132
+ accordionTitleStyle
133
+ } = getAccordionData(updateData);
134
+
135
+ // applying accordion title style
136
+ const accordionSummary = data.children?.find(c => c.type === "accordion-summary");
137
+ const accordionSummaryPath = ReactEditor.findPath(editor, accordionSummary);
138
+ setNodes({
139
+ ...accordionTitleStyle,
140
+ type: "accordion-summary",
141
+ children: accordionSummary.children
142
+ }, accordionSummaryPath);
143
+
144
+ // applying accordion button style
145
+ delete accordionBtnStyle.children;
146
+ setNodes({
147
+ ...accordionBtnStyle
148
+ }, path);
82
149
  onClose();
83
150
  };
84
151
  const onClose = () => {
@@ -123,7 +190,7 @@ const Accordion = props => {
123
190
  },
124
191
  children: children[1]
125
192
  }), !readOnly && /*#__PURE__*/_jsx(ToolBar, {}), openSetttings ? /*#__PURE__*/_jsx(AccordionBtnPopup, {
126
- element: element,
193
+ element: getElementProps(element),
127
194
  onSave: onSave,
128
195
  onClose: onClose,
129
196
  customProps: customProps