@flozy/editor 3.6.9 → 3.7.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 (100) hide show
  1. package/dist/Editor/CommonEditor.js +111 -169
  2. package/dist/Editor/Elements/Accordion/Accordion.js +7 -74
  3. package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +2 -3
  4. package/dist/Editor/Elements/Accordion/AccordionSummary.js +60 -4
  5. package/dist/Editor/Elements/AppHeader/AppHeader.js +15 -39
  6. package/dist/Editor/Elements/Button/EditorButton.js +18 -34
  7. package/dist/Editor/Elements/ChipText/ChipText.js +3 -3
  8. package/dist/Editor/Elements/Color Picker/ColorButtons.js +17 -60
  9. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  10. package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
  11. package/dist/Editor/Elements/Color Picker/Styles.js +1 -2
  12. package/dist/Editor/Elements/Embed/Frames/ImageFrame.js +0 -1
  13. package/dist/Editor/Elements/Emoji/EmojiButton.js +2 -2
  14. package/dist/Editor/Elements/Emoji/EmojiPicker.js +0 -16
  15. package/dist/Editor/Elements/Form/Workflow/UserInputs.js +1 -2
  16. package/dist/Editor/Elements/Grid/Grid.js +1 -3
  17. package/dist/Editor/Elements/Grid/GridItem.js +2 -4
  18. package/dist/Editor/Elements/InlineIcon/InlineIcon.js +3 -2
  19. package/dist/Editor/Elements/Link/Link.js +1 -6
  20. package/dist/Editor/Elements/Link/LinkButton.js +2 -4
  21. package/dist/Editor/Elements/Link/LinkPopup.js +3 -11
  22. package/dist/Editor/Elements/List/CheckList.js +2 -6
  23. package/dist/Editor/Elements/Table/TableCell.js +1 -1
  24. package/dist/Editor/MiniEditor.js +1 -3
  25. package/dist/Editor/Styles/EditorStyles.js +2 -3
  26. package/dist/Editor/Toolbar/Basic/index.js +2 -4
  27. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +2 -26
  28. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  29. package/dist/Editor/Toolbar/FormatTools/TextSize.js +11 -5
  30. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +11 -4
  31. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +86 -213
  32. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +1 -2
  33. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +13 -20
  34. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +7 -52
  35. package/dist/Editor/Toolbar/PopupTool/index.js +11 -12
  36. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  37. package/dist/Editor/common/ColorPickerButton.js +9 -25
  38. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  39. package/dist/Editor/common/Icon.js +2 -30
  40. package/dist/Editor/common/LinkSettings/NavComponents.js +20 -54
  41. package/dist/Editor/common/MentionsPopup/MentionsListCard.js +2 -5
  42. package/dist/Editor/common/MentionsPopup/Styles.js +3 -6
  43. package/dist/Editor/common/Shorthands/elements.js +0 -54
  44. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +7 -7
  45. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +16 -16
  46. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  47. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +3 -13
  48. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  49. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +7 -31
  50. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +4 -13
  51. package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +28 -12
  52. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +4 -14
  53. package/dist/Editor/common/StyleBuilder/index.js +1 -1
  54. package/dist/Editor/helper/index.js +0 -15
  55. package/dist/Editor/helper/theme.js +4 -190
  56. package/dist/Editor/hooks/useMouseMove.js +6 -15
  57. package/dist/Editor/plugins/withEmbeds.js +1 -1
  58. package/dist/Editor/plugins/withHTML.js +5 -47
  59. package/dist/Editor/plugins/withLayout.js +10 -15
  60. package/dist/Editor/plugins/withTable.js +2 -2
  61. package/dist/Editor/theme/ThemeList.js +173 -50
  62. package/dist/Editor/utils/SlateUtilityFunctions.js +25 -157
  63. package/dist/Editor/utils/button.js +17 -1
  64. package/dist/Editor/utils/events.js +4 -11
  65. package/dist/Editor/utils/font.js +37 -40
  66. package/dist/Editor/utils/helper.js +22 -104
  67. package/dist/Editor/utils/serializeToHTML.js +13 -25
  68. package/dist/index.js +1 -5
  69. package/package.json +4 -4
  70. package/dist/Editor/ChatEditor.js +0 -211
  71. package/dist/Editor/Elements/Link/LinkPopupStyles.js +0 -28
  72. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -438
  73. package/dist/Editor/assets/svg/ThemeIcons.js +0 -291
  74. package/dist/Editor/common/CustomColorPicker/index.js +0 -106
  75. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  76. package/dist/Editor/common/CustomDialog/index.js +0 -94
  77. package/dist/Editor/common/CustomDialog/style.js +0 -67
  78. package/dist/Editor/common/CustomSelect.js +0 -33
  79. package/dist/Editor/common/EditorCmds.js +0 -35
  80. package/dist/Editor/common/MUIIcon/index.js +0 -48
  81. package/dist/Editor/common/StyleBuilder/fieldTypes/loadIcon.js +0 -13
  82. package/dist/Editor/common/StyleBuilder/fieldTypes/mui_filled_icons.js +0 -2
  83. package/dist/Editor/hooks/useEditorTheme.js +0 -139
  84. package/dist/Editor/theme/index.js +0 -144
  85. package/dist/Editor/themeSettings/ActiveTheme.js +0 -72
  86. package/dist/Editor/themeSettings/buttons/index.js +0 -290
  87. package/dist/Editor/themeSettings/buttons/style.js +0 -21
  88. package/dist/Editor/themeSettings/colorTheme/index.js +0 -290
  89. package/dist/Editor/themeSettings/colorTheme/style.js +0 -77
  90. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -123
  91. package/dist/Editor/themeSettings/fonts/index.js +0 -213
  92. package/dist/Editor/themeSettings/fonts/style.js +0 -44
  93. package/dist/Editor/themeSettings/icons.js +0 -60
  94. package/dist/Editor/themeSettings/index.js +0 -320
  95. package/dist/Editor/themeSettings/style.js +0 -152
  96. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  97. package/dist/Editor/themeSettingsAI/index.js +0 -356
  98. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -190
  99. package/dist/Editor/themeSettingsAI/style.js +0 -247
  100. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +0 -361
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
- import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle, createContext } from "react";
2
+ import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle } 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, IconButton, Typography } from "@mui/material";
21
+ import { Box, Button, 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,19 +28,12 @@ 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, getVariableValue } from "./helper/theme";
32
- import { handleInsertLastElement, onDeleteKey, outsideEditorClickLabel } from "./utils/helper";
31
+ import { getTRBLBreakPoints } from "./helper/theme";
32
+ import { handleInsertLastElement, 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";
39
34
  import PopoverAIInput from "./Elements/AI/PopoverAIInput";
40
- import { ThemeAIIcon, ThemePaintIcon } from "./assets/svg/ThemeIcons";
41
35
  import { jsx as _jsx } from "react/jsx-runtime";
42
36
  import { jsxs as _jsxs } from "react/jsx-runtime";
43
- export const ThemeContext = /*#__PURE__*/createContext(null);
44
37
  const Item = /*#__PURE__*/forwardRef(({
45
38
  children,
46
39
  ...props
@@ -67,8 +60,7 @@ const Leaf = ({
67
60
  children,
68
61
  leaf
69
62
  }) => {
70
- const theme = useTheme();
71
- children = getMarked(leaf, children, theme);
63
+ children = getMarked(leaf, children);
72
64
  return /*#__PURE__*/_jsx("span", {
73
65
  ...attributes,
74
66
  children: children
@@ -87,8 +79,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
87
79
  toolbarOptions,
88
80
  otherProps,
89
81
  isIframe,
90
- theme,
91
- showThemeButtons
82
+ theme
92
83
  } = props;
93
84
  const editorWrapper = useRef();
94
85
  const mentionsRef = useRef();
@@ -132,11 +123,10 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
132
123
  const {
133
124
  bannerSpacing,
134
125
  pageBgImage,
135
- pageColor = "",
126
+ pageColor,
136
127
  color: pageTextColor,
137
128
  pageWidth,
138
- maxWidth: pageMaxWidth,
139
- theme: selectedTheme
129
+ maxWidth: pageMaxWidth
140
130
  } = pageSt?.pageProps || {
141
131
  bannerSpacing: {
142
132
  left: 0,
@@ -147,11 +137,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
147
137
  };
148
138
  const classes = editorStyles({
149
139
  padHeight: !fullScreen ? otherProps?.padHeight : 20,
150
- placeHolderColor: invertColor(pageColor.startsWith("var") ? getVariableValue(pageColor) : pageColor || "#FFF"),
140
+ placeHolderColor: invertColor(pageColor || "#FFF"),
151
141
  theme
152
142
  });
153
- const [openTheme, setOpenTheme] = useState(false);
154
- const [openAITheme, setOpenAITheme] = useState(false);
155
143
  useEffect(() => {
156
144
  setValue(draftToSlate({
157
145
  data: content
@@ -251,12 +239,6 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
251
239
  redo() {
252
240
  editor?.redo();
253
241
  },
254
- toggleTheme() {
255
- setOpenTheme(!openTheme);
256
- },
257
- toggleAITheme() {
258
- setOpenAITheme(!openAITheme);
259
- },
260
242
  getPageSettings: {
261
243
  background: pageBgImage && pageBgImage !== "none" ? `url(${pageBgImage})` : pageColor || ""
262
244
  }
@@ -337,8 +319,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
337
319
  } else if (isCtrlKey) {
338
320
  commands({
339
321
  event,
340
- editor,
341
- needLayout
322
+ editor
342
323
  });
343
324
  } else if (event.key === "Tab") {
344
325
  event.preventDefault();
@@ -404,152 +385,113 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
404
385
  }
405
386
  return style;
406
387
  }, [pageBgImage, pageColor]);
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,
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,
467
428
  children: /*#__PURE__*/_jsxs(Box, {
468
429
  component: "div",
469
- className: "max-content",
470
- sx: themeProps?.sxProps || {},
471
- "data-info": outsideEditorClickLabel,
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,
514
- theme: theme
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"
430
+ className: `editor-wrapper ${pageWidth === "fixed" ? "fixed" : "full"}`,
431
+ sx: {
432
+ backgroundColor: "transparent",
433
+ padding: {
434
+ ...getTRBLBreakPoints(bannerSpacing)
523
435
  },
524
- align: "center",
525
- "data-info": outsideEditorClickLabel,
526
- onClick: handleFooterClick,
527
- children: footer
528
- }), openTheme ? /*#__PURE__*/_jsx(ThemeSettings, {
529
- open: openTheme,
530
- setOpen: setOpenTheme,
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
+ },
444
+ "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,
531
456
  editor: editor,
532
- services: otherProps?.services
533
- }) : null, /*#__PURE__*/_jsx(ThemeSettingsAI, {
534
- openAITheme: openAITheme,
535
- setOpenAITheme: setOpenAITheme,
536
- onSaveTheme: otherProps?.onSaveTheme
537
- })]
457
+ target: target,
458
+ index: index,
459
+ chars: chars,
460
+ type: type,
461
+ theme: theme
462
+ }) : null]
538
463
  })
539
- }), !readOnly ? /*#__PURE__*/_jsx(PopupTool, {
540
- onDrawerOpen: onDrawerOpen,
541
- theme: theme,
542
- setIsTextSelected: setIsTextSelected,
543
- customProps: customProps
544
- }) : null]
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
+ })]
545
482
  })
546
- }), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
547
- ...htmlAction,
548
- handleCodeToText: handleCodeToText
549
- })]
550
- }, id)
551
- })
552
- })]
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)
553
495
  })
554
496
  })
555
497
  });
@@ -9,55 +9,6 @@ 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
- };
61
12
  const Accordion = props => {
62
13
  const {
63
14
  attributes,
@@ -118,34 +69,16 @@ const Accordion = props => {
118
69
  at: path
119
70
  });
120
71
  };
121
- const setNodes = (data, path) => {
122
- Transforms.setNodes(editor, data, {
123
- at: path
124
- });
125
- };
126
72
  const onSave = data => {
127
73
  const updateData = {
128
74
  ...data
129
75
  };
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);
76
+ delete updateData.children;
77
+ Transforms.setNodes(editor, {
78
+ ...updateData
79
+ }, {
80
+ at: path
81
+ });
149
82
  onClose();
150
83
  };
151
84
  const onClose = () => {
@@ -190,7 +123,7 @@ const Accordion = props => {
190
123
  },
191
124
  children: children[1]
192
125
  }), !readOnly && /*#__PURE__*/_jsx(ToolBar, {}), openSetttings ? /*#__PURE__*/_jsx(AccordionBtnPopup, {
193
- element: getElementProps(element),
126
+ element: element,
194
127
  onSave: onSave,
195
128
  onClose: onClose,
196
129
  customProps: customProps
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import StyleBuilder from "../../common/StyleBuilder";
3
3
  import accordionTitleBtnStyle from "../../common/StyleBuilder/accordionTitleBtnStyle";
4
- import accordionTitleStyle from "../../common/StyleBuilder/accordionTitleStyle";
5
4
  import { jsx as _jsx } from "react/jsx-runtime";
6
5
  const AccordionBtnPopup = props => {
7
6
  const {
@@ -11,12 +10,12 @@ const AccordionBtnPopup = props => {
11
10
  customProps
12
11
  } = props;
13
12
  return /*#__PURE__*/_jsx(StyleBuilder, {
14
- title: "Accordion Settings",
13
+ title: "Accordion Collapse Button",
15
14
  type: "accordionTitleBtnStyle",
16
15
  element: element,
17
16
  onSave: onSave,
18
17
  onClose: onClose,
19
- renderTabs: [...accordionTitleBtnStyle, ...accordionTitleStyle],
18
+ renderTabs: accordionTitleBtnStyle,
20
19
  customProps: customProps
21
20
  });
22
21
  };
@@ -1,17 +1,68 @@
1
- import React from "react";
1
+ import React, { useState } from "react";
2
+ import { Transforms } from "slate";
3
+ import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
4
+ import AccordionTitlePopup from "./AccordionTitlePopup";
5
+ import { IconButton, Tooltip } from "@mui/material";
6
+ import { GridSettingsIcon } from "../../common/iconslist";
7
+ import { useEditorSelection } from "../../hooks/useMouseMove";
2
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
3
10
  const AccordionSummary = props => {
4
11
  const {
5
12
  attributes,
6
13
  children,
7
- element
14
+ element,
15
+ customProps
8
16
  } = props;
17
+ const {
18
+ readOnly
19
+ } = customProps;
20
+ const [openSetttings, setOpenSettings] = useState(false);
21
+ const editor = useSlateStatic();
22
+ const [showTool] = useEditorSelection(editor);
23
+ const selected = useSelected();
24
+ const path = ReactEditor.findPath(editor, element);
9
25
  const {
10
26
  textColor,
11
27
  bgColor,
12
28
  borderColor
13
29
  } = element;
14
- return /*#__PURE__*/_jsx("div", {
30
+ const ToolBar = () => {
31
+ return selected && !showTool ? /*#__PURE__*/_jsx("div", {
32
+ className: "element-toolbar hr",
33
+ contentEditable: false,
34
+ style: {
35
+ top: "-42px"
36
+ },
37
+ children: /*#__PURE__*/_jsx(Tooltip, {
38
+ title: "Settings",
39
+ arrow: true,
40
+ children: /*#__PURE__*/_jsx(IconButton, {
41
+ onClick: onSettings,
42
+ children: /*#__PURE__*/_jsx(GridSettingsIcon, {})
43
+ })
44
+ })
45
+ }) : null;
46
+ };
47
+ const onSettings = () => {
48
+ setOpenSettings(true);
49
+ };
50
+ const onSave = data => {
51
+ const updateData = {
52
+ ...data
53
+ };
54
+ delete updateData.children;
55
+ Transforms.setNodes(editor, {
56
+ ...updateData
57
+ }, {
58
+ at: path
59
+ });
60
+ onClose();
61
+ };
62
+ const onClose = () => {
63
+ setOpenSettings(false);
64
+ };
65
+ return /*#__PURE__*/_jsxs("div", {
15
66
  className: `accordion-summary-container`,
16
67
  ...attributes,
17
68
  style: {
@@ -21,7 +72,12 @@ const AccordionSummary = props => {
21
72
  border: `1px solid ${borderColor}`,
22
73
  color: textColor
23
74
  },
24
- children: children
75
+ children: [children, !readOnly && /*#__PURE__*/_jsx(ToolBar, {}), openSetttings ? /*#__PURE__*/_jsx(AccordionTitlePopup, {
76
+ element: element,
77
+ onSave: onSave,
78
+ onClose: onClose,
79
+ customProps: customProps
80
+ }) : null]
25
81
  });
26
82
  };
27
83
  export default AccordionSummary;
@@ -62,11 +62,6 @@ function AppHeader(props) {
62
62
  const handleDrawerToggle = () => {
63
63
  setMobileOpen(prevState => !prevState);
64
64
  };
65
- const closeDrawer = () => {
66
- if (mobileOpen) {
67
- handleDrawerToggle();
68
- }
69
- };
70
65
  const onSettings = e => {
71
66
  if (!readOnly) {
72
67
  e.stopPropagation();
@@ -151,38 +146,19 @@ function AppHeader(props) {
151
146
  src: appLogo
152
147
  }) : appTitle
153
148
  }), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsx(List, {
154
- children: menus.map((item, i) => {
155
- const buttonProps = handleLinkType(item.url, item.linkType, true, item.target === "_blank");
156
- const onTouchEnd = e => {
157
- if (buttonProps?.onTouchEnd) {
158
- buttonProps?.onTouchEnd(e);
159
- closeDrawer();
160
- }
161
- };
162
- const onClick = e => {
163
- if (buttonProps?.onClick) {
164
- buttonProps?.onClick(e);
165
- closeDrawer();
166
- }
167
- };
168
- const props = {
169
- ...buttonProps,
170
- onTouchEnd,
171
- onClick
172
- };
173
- return /*#__PURE__*/_jsx(ListItem, {
174
- disablePadding: true,
175
- children: /*#__PURE__*/_jsx(ListItemButton, {
176
- ...props,
177
- sx: {
178
- textAlign: "center"
179
- },
180
- children: /*#__PURE__*/_jsx(ListItemText, {
181
- primary: item.text
182
- })
149
+ children: menus.map((item, i) => /*#__PURE__*/_jsx(ListItem, {
150
+ disablePadding: true,
151
+ children: /*#__PURE__*/_jsx(ListItemButton, {
152
+ component: "a",
153
+ href: item.url,
154
+ sx: {
155
+ textAlign: "center"
156
+ },
157
+ children: /*#__PURE__*/_jsx(ListItemText, {
158
+ primary: item.text
183
159
  })
184
- }, `${item.text}_${i}`);
185
- })
160
+ })
161
+ }, `${item.text}_${i}`))
186
162
  })]
187
163
  });
188
164
  const container = window !== undefined ? () => window().document.body : undefined;
@@ -251,7 +227,7 @@ function AppHeader(props) {
251
227
  style: {
252
228
  display: "inline-flex",
253
229
  alignItems: "center",
254
- color: textColor || "#000000",
230
+ color: textColor,
255
231
  fontSize: logoFontSize,
256
232
  fontFamily: titleFontFamily,
257
233
  justifyContent: isLogoRight ? "end" : "start"
@@ -299,7 +275,7 @@ function AppHeader(props) {
299
275
  fontFamily: fontFamily,
300
276
  textTransform: "none",
301
277
  fontSize: fontSize || "16px",
302
- color: textColor || "#000",
278
+ color: textColor || "#FFF",
303
279
  background: bgColor || "none",
304
280
  "& .m-settings": {
305
281
  display: "none",
@@ -314,7 +290,7 @@ function AppHeader(props) {
314
290
  background: "#FFF"
315
291
  },
316
292
  "&:hover": {
317
- color: textColorHover || textColor || "#000",
293
+ color: textColorHover || textColor || "#FFF",
318
294
  background: bgColorHover || bgColor || "none",
319
295
  "& .m-settings": {
320
296
  display: "block"