@flozy/editor 3.9.4 → 3.9.6

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 (36) hide show
  1. package/dist/Editor/ChatEditor.js +55 -45
  2. package/dist/Editor/CommonEditor.js +3 -2
  3. package/dist/Editor/Editor.css +12 -1
  4. package/dist/Editor/Elements/Accordion/Accordion.js +76 -8
  5. package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +3 -2
  6. package/dist/Editor/Elements/Accordion/AccordionSummary.js +24 -64
  7. package/dist/Editor/Elements/Embed/Image.js +27 -19
  8. package/dist/Editor/Elements/Embed/Video.js +14 -10
  9. package/dist/Editor/Elements/Emoji/EmojiPicker.js +4 -2
  10. package/dist/Editor/Elements/Form/Form.js +1 -1
  11. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +5 -1
  12. package/dist/Editor/Elements/Table/Table.js +1 -1
  13. package/dist/Editor/Elements/Table/TableCell.js +1 -1
  14. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +25 -1
  15. package/dist/Editor/common/ColorPickerButton.js +12 -4
  16. package/dist/Editor/common/EditorCmds.js +35 -0
  17. package/dist/Editor/common/MentionsPopup/MentionsListCard.js +6 -1
  18. package/dist/Editor/common/MentionsPopup/Styles.js +5 -2
  19. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +9 -8
  20. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +16 -16
  21. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +26 -20
  22. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +18 -16
  23. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +6 -4
  24. package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +14 -3
  25. package/dist/Editor/helper/deserialize/index.js +14 -9
  26. package/dist/Editor/helper/index.js +22 -0
  27. package/dist/Editor/helper/theme.js +2 -1
  28. package/dist/Editor/hooks/useMouseMove.js +0 -1
  29. package/dist/Editor/plugins/withHTML.js +46 -4
  30. package/dist/Editor/plugins/withLayout.js +15 -10
  31. package/dist/Editor/plugins/withTable.js +1 -1
  32. package/dist/Editor/utils/SlateUtilityFunctions.js +2 -8
  33. package/dist/Editor/utils/draftToSlate.js +1 -1
  34. package/dist/Editor/utils/events.js +11 -4
  35. package/dist/Editor/utils/helper.js +43 -12
  36. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useMemo, useState } from "react";
2
2
  import { Grid, Button, Popover } from "@mui/material";
3
3
  import ColorPickerTool from "react-gcolor-picker";
4
4
  import { colors } from "../Elements/Color Picker/defaultColors";
@@ -11,7 +11,8 @@ const ColorPickerButton = props => {
11
11
  onSave,
12
12
  defaultColors = [],
13
13
  classes = {},
14
- recentColors = []
14
+ recentColors = [],
15
+ hideGradient
15
16
  } = props;
16
17
  const [anchorEl, setAnchorEl] = useState(null);
17
18
  const [color, setColor] = useState(value);
@@ -29,6 +30,13 @@ const ColorPickerButton = props => {
29
30
  const handleColorChange = color => {
30
31
  setColor(color);
31
32
  };
33
+ const initialColors = useMemo(() => {
34
+ let colors = [...recentColors, ...defaultColors];
35
+ if (hideGradient) {
36
+ colors = colors.filter(c => c && !c.includes("gradient"));
37
+ }
38
+ return colors;
39
+ }, [recentColors, defaultColors, hideGradient]);
32
40
  return /*#__PURE__*/_jsxs(_Fragment, {
33
41
  children: [/*#__PURE__*/_jsx(Button, {
34
42
  style: {
@@ -61,10 +69,10 @@ const ColorPickerButton = props => {
61
69
  xs: 12,
62
70
  children: [/*#__PURE__*/_jsx("div", {
63
71
  children: /*#__PURE__*/_jsx(ColorPickerTool, {
64
- gradient: true,
72
+ gradient: hideGradient ? false : true,
65
73
  value: color,
66
74
  onChange: handleColorChange,
67
- defaultColors: [...recentColors, ...defaultColors] || []
75
+ defaultColors: initialColors
68
76
  })
69
77
  }), /*#__PURE__*/_jsxs("div", {
70
78
  style: {
@@ -0,0 +1,35 @@
1
+ import { Editor, Transforms } from "slate";
2
+ const selectAll = (event, {
3
+ editor,
4
+ needLayout
5
+ }) => {
6
+ try {
7
+ if (needLayout) {
8
+ event.preventDefault();
9
+ // Select the entire document
10
+ const {
11
+ selection
12
+ } = editor;
13
+ const [firstNode] = Editor.nodes(editor, {
14
+ at: [0]
15
+ }); // First node
16
+ const [lastNode] = Editor.nodes(editor, {
17
+ at: [editor.children.length - 1]
18
+ }); // Last node
19
+
20
+ if (firstNode && lastNode) {
21
+ Transforms.select(editor, {
22
+ anchor: Editor.start(editor, [0]),
23
+ // Start at the first node
24
+ focus: Editor.end(editor, [editor.children.length - 1]) // End at the last node
25
+ });
26
+ }
27
+ }
28
+ } catch (err) {
29
+ console.log(err);
30
+ }
31
+ };
32
+ const EDITORCMDS = {
33
+ a: selectAll
34
+ };
35
+ export default EDITORCMDS;
@@ -39,7 +39,12 @@ const MentionsListCard = props => {
39
39
  },
40
40
  alt: name,
41
41
  children: /*#__PURE__*/_jsx(Avatar, {
42
- src: avatar_filename
42
+ sx: {
43
+ background: 'linear-gradient(90deg, #5351FC 0%, #19A9FC 100%)'
44
+ },
45
+ alt: name,
46
+ src: avatar_filename,
47
+ children: !avatar_filename && name && name.charAt(0).toUpperCase()
43
48
  })
44
49
  }), /*#__PURE__*/_jsx(Box, {
45
50
  sx: {
@@ -39,10 +39,13 @@ const usePopupStyles = theme => ({
39
39
  color: theme?.palette?.editor?.textColor
40
40
  },
41
41
  "&.active": {
42
- background: `${theme?.palette?.containers?.bg3 || "#E9F3FE"}`
42
+ background: `#2563EB2B`,
43
+ "& .MuiTypography-root": {
44
+ color: `${theme?.palette?.editor?.activeColor} !important`
45
+ }
43
46
  },
44
47
  "&:hover": {
45
- background: `${theme?.palette?.containers?.bg3 || "#E9F3FE"}`
48
+ background: theme?.palette?.action?.hover || `#F4F4F4`
46
49
  },
47
50
  "&.renderComp": {
48
51
  padding: "0px",
@@ -1,18 +1,19 @@
1
1
  const accordionTitleBtnStyle = [{
2
2
  tab: "Colors",
3
- value: "colors",
3
+ value: "accordionColor",
4
4
  fields: [{
5
- label: "Text Color",
6
- key: "textColor",
5
+ label: "Accordion Color",
6
+ key: "accordionTextColor",
7
7
  type: "color",
8
- needPreview: true
8
+ needPreview: true,
9
+ hideGradient: true
9
10
  }, {
10
- label: "Background Color",
11
- key: "bgColor",
11
+ label: "Accordion Background Color",
12
+ key: "accordionBgColor",
12
13
  type: "color"
13
14
  }, {
14
- label: "Border Color",
15
- key: "borderColor",
15
+ label: "Accordion Border Color",
16
+ key: "accordionBorderColor",
16
17
  type: "color"
17
18
  }]
18
19
  }];
@@ -1,20 +1,4 @@
1
1
  const accordionTitleStyle = [{
2
- tab: "Banner Spacing",
3
- value: "bannerSpacing",
4
- fields: [{
5
- label: "Banner Spacing",
6
- key: "bannerSpacing",
7
- type: "bannerSpacing"
8
- }]
9
- }, {
10
- tab: "Border Radius",
11
- value: "borderRadius",
12
- fields: [{
13
- label: "Border Radius",
14
- key: "borderRadius",
15
- type: "borderRadius"
16
- }]
17
- }, {
18
2
  tab: "Colors",
19
3
  value: "colors",
20
4
  fields: [{
@@ -31,5 +15,21 @@ const accordionTitleStyle = [{
31
15
  key: "borderColor",
32
16
  type: "color"
33
17
  }]
18
+ }, {
19
+ tab: "Banner Spacing",
20
+ value: "bannerSpacing",
21
+ fields: [{
22
+ label: "Banner Spacing",
23
+ key: "bannerSpacing",
24
+ type: "bannerSpacing"
25
+ }]
26
+ }, {
27
+ tab: "Border Radius",
28
+ value: "borderRadius",
29
+ fields: [{
30
+ label: "Border Radius",
31
+ key: "borderRadius",
32
+ type: "borderRadius"
33
+ }]
34
34
  }];
35
35
  export default accordionTitleStyle;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { Checkbox, FormControlLabel, Grid, Slider, Typography, Box } from "@mui/material";
3
3
  import { squreStyle } from "./radiusStyle";
4
- import { getBreakPointsValue } from "../../../helper/theme";
4
+ import { getBreakPointsValue, getCustomizationValue } from "../../../helper/theme";
5
5
  import useWindowResize from "../../../hooks/useWindowResize";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -78,10 +78,12 @@ const BannerSpacing = props => {
78
78
  component: "input",
79
79
  sx: classes.sapcingInput,
80
80
  name: "top",
81
- value: !lockSpacing ? "" : value?.top || 0,
82
- className: "sliderInput",
81
+ value: !lockSpacing ? "" : getCustomizationValue(value?.top),
82
+ className: "sliderInput removeScroll",
83
83
  disabled: !lockSpacing,
84
- onChange: handleChange
84
+ onChange: handleChange,
85
+ type: "number",
86
+ placeholder: "0"
85
87
  })]
86
88
  }), /*#__PURE__*/_jsx(FormControlLabel, {
87
89
  className: "ccheckbox-primary",
@@ -123,50 +125,54 @@ const BannerSpacing = props => {
123
125
  children: [/*#__PURE__*/_jsx("div", {
124
126
  className: "bannerSpaceBoxTop",
125
127
  children: /*#__PURE__*/_jsx("input", {
126
- type: "text",
128
+ type: "number",
127
129
  name: "top",
128
- value: value?.top,
129
- className: "borderInput",
130
+ value: getCustomizationValue(value?.top),
131
+ className: "borderInput removeScroll",
130
132
  style: {
131
133
  ...squreStyle.topRight
132
134
  },
133
- onChange: handleChange
135
+ onChange: handleChange,
136
+ placeholder: "0"
134
137
  })
135
138
  }), /*#__PURE__*/_jsx("div", {
136
139
  className: "bannerSpaceBoxRight",
137
140
  children: /*#__PURE__*/_jsx("input", {
138
- type: "text",
141
+ type: "number",
139
142
  name: "right",
140
- value: value?.right,
141
- className: "borderInput",
143
+ value: getCustomizationValue(value?.right),
144
+ className: "borderInput removeScroll",
142
145
  style: {
143
146
  ...squreStyle.bottomLeft
144
147
  },
145
- onChange: handleChange
148
+ onChange: handleChange,
149
+ placeholder: "0"
146
150
  })
147
151
  }), /*#__PURE__*/_jsx("div", {
148
152
  className: "bannerSpaceBoxBottom",
149
153
  children: /*#__PURE__*/_jsx("input", {
150
- type: "text",
154
+ type: "number",
151
155
  name: "bottom",
152
- value: value?.bottom,
153
- className: "borderInput",
156
+ value: getCustomizationValue(value?.bottom),
157
+ className: "borderInput removeScroll",
154
158
  style: {
155
159
  ...squreStyle.bottomRight
156
160
  },
157
- onChange: handleChange
161
+ onChange: handleChange,
162
+ placeholder: "0"
158
163
  })
159
164
  }), /*#__PURE__*/_jsx("div", {
160
165
  className: "bannerSpaceBoxLeft",
161
166
  children: /*#__PURE__*/_jsx("input", {
162
- type: "text",
167
+ type: "number",
163
168
  name: "left",
164
- className: "borderInput",
165
- value: value?.left,
169
+ className: "borderInput removeScroll",
170
+ value: getCustomizationValue(value?.left),
166
171
  style: {
167
172
  ...squreStyle.topLeft
168
173
  },
169
- onChange: handleChange
174
+ onChange: handleChange,
175
+ placeholder: "0"
170
176
  })
171
177
  })]
172
178
  })
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { Grid, Typography, Slider, FormControlLabel, Checkbox, Box } from "@mui/material";
3
3
  import { radiusStyle } from "./radiusStyle";
4
4
  import useWindowResize from "../../../hooks/useWindowResize";
5
- import { getBreakPointsValue } from "../../../helper/theme";
5
+ import { getBreakPointsValue, getCustomizationValue } from "../../../helper/theme";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
8
  const BORDER_RADIUS_KEYS = ["topLeft", "topRight", "bottomLeft", "bottomRight"];
@@ -80,11 +80,13 @@ const BorderRadius = props => {
80
80
  }), /*#__PURE__*/_jsx(Box, {
81
81
  sx: classes.sapcingInput,
82
82
  component: "input",
83
- value: !lockRadius ? "" : value?.topLeft || 0,
84
- className: "sliderInput",
83
+ value: !lockRadius ? "" : getCustomizationValue(value?.topLeft),
84
+ className: "sliderInput removeScroll",
85
85
  name: "topLeft",
86
86
  disabled: !lockRadius,
87
- onChange: handleChange
87
+ onChange: handleChange,
88
+ type: "number",
89
+ placeholder: "0"
88
90
  })]
89
91
  }), /*#__PURE__*/_jsx(FormControlLabel, {
90
92
  className: "ccheckbox-primary",
@@ -125,10 +127,10 @@ const BorderRadius = props => {
125
127
  borderRadius: `${value?.topLeft}px ${value?.topRight}px ${value?.bottomLeft}px ${value?.bottomRight}px`
126
128
  },
127
129
  children: [/*#__PURE__*/_jsx("input", {
128
- type: "text",
130
+ type: "number",
129
131
  name: "topLeft",
130
- value: value?.topLeft,
131
- className: "borderInput",
132
+ value: getCustomizationValue(value?.topLeft),
133
+ className: "borderInput removeScroll",
132
134
  placeholder: "0",
133
135
  style: {
134
136
  ...radiusStyle.topLeft,
@@ -136,10 +138,10 @@ const BorderRadius = props => {
136
138
  },
137
139
  onChange: handleChange
138
140
  }), /*#__PURE__*/_jsx("input", {
139
- type: "text",
141
+ type: "number",
140
142
  name: "topRight",
141
- value: value?.topRight,
142
- className: "borderInput",
143
+ value: getCustomizationValue(value?.topRight),
144
+ className: "borderInput removeScroll",
143
145
  placeholder: "0",
144
146
  style: {
145
147
  ...radiusStyle.topRight,
@@ -148,10 +150,10 @@ const BorderRadius = props => {
148
150
  },
149
151
  onChange: handleChange
150
152
  }), /*#__PURE__*/_jsx("input", {
151
- type: "text",
153
+ type: "number",
152
154
  name: "bottomLeft",
153
- value: value?.bottomLeft,
154
- className: "borderInput",
155
+ value: getCustomizationValue(value?.bottomLeft),
156
+ className: "borderInput removeScroll",
155
157
  placeholder: "0",
156
158
  style: {
157
159
  ...radiusStyle.bottomLeft,
@@ -160,10 +162,10 @@ const BorderRadius = props => {
160
162
  },
161
163
  onChange: handleChange
162
164
  }), /*#__PURE__*/_jsx("input", {
163
- type: "text",
165
+ type: "number",
164
166
  name: "bottomRight",
165
- value: value?.bottomRight,
166
- className: "borderInput",
167
+ value: getCustomizationValue(value?.bottomRight),
168
+ className: "borderInput removeScroll",
167
169
  placeholder: "0",
168
170
  style: {
169
171
  ...radiusStyle.bottomRight,
@@ -12,11 +12,12 @@ const Color = props => {
12
12
  } = props;
13
13
  const {
14
14
  key,
15
- label
15
+ label,
16
+ hideGradient
16
17
  } = data;
17
18
  const [recentColors, setRecentColors] = useState({});
18
19
  useEffect(() => {
19
- const storedColors = JSON.parse(localStorage.getItem('recentColors'));
20
+ const storedColors = JSON.parse(localStorage.getItem("recentColors"));
20
21
  if (storedColors) {
21
22
  setRecentColors(storedColors);
22
23
  }
@@ -39,7 +40,7 @@ const Color = props => {
39
40
  [key]: updatedColors
40
41
  };
41
42
  setRecentColors(updatedColors);
42
- localStorage.setItem('recentColors', JSON.stringify(updatedColors));
43
+ localStorage.setItem("recentColors", JSON.stringify(updatedColors));
43
44
  };
44
45
  return /*#__PURE__*/_jsxs(Grid, {
45
46
  item: true,
@@ -68,7 +69,8 @@ const Color = props => {
68
69
  classes: classes,
69
70
  value: value,
70
71
  onSave: onSave,
71
- recentColors: recentColors[key]
72
+ recentColors: recentColors[key],
73
+ hideGradient: hideGradient
72
74
  })
73
75
  })
74
76
  }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { useEffect, useState, useRef } from "react";
2
2
  import { Grid, Checkbox, FormControlLabel, FormHelperText } from "@mui/material";
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -6,12 +6,23 @@ const SelectBox = props => {
6
6
  const {
7
7
  value,
8
8
  data,
9
- onChange
9
+ onChange,
10
+ elementProps
10
11
  } = props;
11
12
  const {
12
13
  key,
13
14
  placeholder
14
15
  } = data;
16
+ const [checkedValue, setCheckedValue] = useState(false);
17
+ const isFirstRender = useRef(true);
18
+ useEffect(() => {
19
+ if (isFirstRender.current && elementProps.element === "email" && value === undefined) {
20
+ setCheckedValue(true);
21
+ isFirstRender.current = false;
22
+ } else {
23
+ setCheckedValue(value);
24
+ }
25
+ }, [elementProps.element, value]);
15
26
  const handleChange = e => {
16
27
  onChange({
17
28
  [key]: e.target.checked
@@ -26,7 +37,7 @@ const SelectBox = props => {
26
37
  children: [/*#__PURE__*/_jsx(FormControlLabel, {
27
38
  control: /*#__PURE__*/_jsx(Checkbox, {
28
39
  value: value,
29
- checked: value,
40
+ checked: checkedValue,
30
41
  onChange: handleChange
31
42
  }),
32
43
  label: placeholder
@@ -72,15 +72,20 @@ const ELEMENT_TAGS = {
72
72
  type: "paragraph"
73
73
  }),
74
74
  TABLE: (el, children = []) => {
75
- const bodyChild = children[0]?.children || [];
76
- const firstRowChildren = bodyChild[0]?.children || [];
77
- return {
78
- type: "table",
79
- overwriteChild: bodyChild,
80
- // we are not having table-body in our json format, just we are wrapping table-row's inside the table
81
- rows: bodyChild?.length,
82
- columns: firstRowChildren?.length
83
- };
75
+ try {
76
+ const tableBody = (children || [])?.find(f => f?.type === "table-body");
77
+ const bodyChild = tableBody?.children || [];
78
+ const firstRowChildren = tableBody[0]?.children || [];
79
+ return {
80
+ type: "table",
81
+ overwriteChild: bodyChild,
82
+ // we are not having table-body in our json format, just we are wrapping table-row's inside the table
83
+ rows: bodyChild?.length,
84
+ columns: firstRowChildren?.length
85
+ };
86
+ } catch (err) {
87
+ console.log(err);
88
+ }
84
89
  },
85
90
  THEAD: () => ({
86
91
  type: "table-head"
@@ -154,4 +154,26 @@ export const debounce = function (func, wait, immediate) {
154
154
  timeout = setTimeout(later, wait);
155
155
  if (callNow) func.apply(context, args);
156
156
  };
157
+ };
158
+ export const getTextColor = (color = "") => {
159
+ return color?.indexOf("gradient") >= 0 ? {
160
+ background: color?.concat("text"),
161
+ WebkitBackgroundClip: "text",
162
+ WebkitTextFillColor: "transparent",
163
+ color: "transparent",
164
+ caretColor: "black"
165
+ } : {
166
+ color
167
+ };
168
+ };
169
+ export const getBorderColor = (borderColor = "") => {
170
+ const borderStyle = borderColor ? {
171
+ border: "1px solid"
172
+ } : {};
173
+ if (borderColor?.indexOf("gradient") >= 0) {
174
+ borderStyle.borderImage = `${borderColor} 1`;
175
+ } else {
176
+ borderStyle.borderColor = borderColor;
177
+ }
178
+ return borderStyle;
157
179
  };
@@ -97,4 +97,5 @@ export const getTRBLBreakPoints = (value, breakpoint) => {
97
97
  } catch (err) {
98
98
  console.log(err);
99
99
  }
100
- };
100
+ };
101
+ export const getCustomizationValue = value => isNaN(parseInt(value)) ? null : parseInt(value);
@@ -75,7 +75,6 @@ const useMouseMove = () => {
75
75
  }, []);
76
76
  const onMouseMove = e => {
77
77
  const dpath = e?.target?.closest(".dpath");
78
- console.log(dpath);
79
78
  if (dpath) {
80
79
  console.log(`Stopped position: (${e.clientX}, ${e.clientY})`, dpath);
81
80
  setEvent({
@@ -1,4 +1,4 @@
1
- import { Transforms, Editor, Element, Node } from "slate";
1
+ import { Transforms, Editor, Element, Node, Path } from "slate";
2
2
  import deserialize from "../helper/deserialize";
3
3
  import { decodeAndParseBase64 } from "../utils/helper";
4
4
  const avoidDefaultInsert = ["table", "grid"];
@@ -26,6 +26,48 @@ const getCurrentElement = editor => {
26
26
  return null;
27
27
  }
28
28
  };
29
+ const getCurrentElementText = editor => {
30
+ try {
31
+ if (editor.selection) {
32
+ return Editor.string(editor, editor?.selection?.anchor?.path);
33
+ } else {
34
+ return null;
35
+ }
36
+ } catch (err) {
37
+ return null;
38
+ }
39
+ };
40
+ const insertAtNextNode = (editor, formattedFragment) => {
41
+ try {
42
+ const {
43
+ selection
44
+ } = editor;
45
+ if (selection) {
46
+ const parentPath = Path.parent(editor?.selection?.anchor?.path);
47
+ const nextPath = Path.next(parentPath);
48
+ Transforms.insertNodes(editor, {
49
+ type: "paragraph",
50
+ children: [{
51
+ text: ""
52
+ }]
53
+ }, {
54
+ at: nextPath
55
+ });
56
+ Transforms.insertFragment(editor, formattedFragment, {
57
+ at: nextPath
58
+ });
59
+ }
60
+ } catch (err) {
61
+ console.log(err);
62
+ }
63
+ };
64
+ const handleInsert = (editor, defaultInsert, fragment = []) => {
65
+ if (getCurrentElementText(editor) && fragment.some(f => f.type === "table")) {
66
+ insertAtNextNode(editor, fragment);
67
+ } else {
68
+ defaultInsert();
69
+ }
70
+ };
29
71
  const formatFragment = {
30
72
  "list-item": fragment => {
31
73
  let refactorFragment = [];
@@ -64,11 +106,11 @@ const withHtml = editor => {
64
106
  const currentEl = getCurrentElement(editor);
65
107
  const eltype = currentEl?.type;
66
108
  if (slateHTML && !formatFragment[eltype]) {
109
+ const decoded = decodeAndParseBase64(slateHTML);
67
110
  const [tableNode] = Editor.nodes(editor, {
68
111
  match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
69
112
  });
70
113
  if (tableNode && tableNode[0]) {
71
- const decoded = decodeAndParseBase64(slateHTML);
72
114
  const defaultInsert = loopChildren(decoded, true);
73
115
  if (defaultInsert) {
74
116
  insertData(data);
@@ -79,7 +121,7 @@ const withHtml = editor => {
79
121
  Transforms.insertText(editor, text);
80
122
  }
81
123
  } else {
82
- insertData(data);
124
+ handleInsert(editor, () => insertData(data), decoded);
83
125
  }
84
126
  } else if (html) {
85
127
  const parsed = new DOMParser().parseFromString(html, "text/html");
@@ -96,7 +138,7 @@ const withHtml = editor => {
96
138
  }
97
139
  const fragment = deserialize(parsed.body);
98
140
  const formattedFragment = formatFragment[eltype] ? formatFragment[eltype](fragment) : fragment;
99
- Transforms.insertFragment(editor, formattedFragment);
141
+ handleInsert(editor, () => Transforms.insertFragment(editor, formattedFragment), formattedFragment);
100
142
  return;
101
143
  } else {
102
144
  insertData(data);
@@ -32,16 +32,21 @@ const withLayout = editor => {
32
32
  editor.normalizeNode = ([node, path]) => {
33
33
  if (path.length === 0) {
34
34
  if (editor.children.length <= 1 && Editor.string(editor, [0, 0]) === "") {
35
- const title = {
36
- type: "title",
37
- children: [{
38
- text: "Untitled"
39
- }]
40
- };
41
- Transforms.insertNodes(editor, title, {
42
- at: path.concat(0),
43
- select: true
44
- });
35
+ const {
36
+ anchor
37
+ } = editor?.selection || {};
38
+ if (anchor?.offset !== 0) {
39
+ const title = {
40
+ type: "title",
41
+ children: [{
42
+ text: "Untitled"
43
+ }]
44
+ };
45
+ Transforms.insertNodes(editor, title, {
46
+ at: path.concat(0),
47
+ select: true
48
+ });
49
+ }
45
50
  }
46
51
  if (editor.children.length === 0) {
47
52
  const paragraph = {
@@ -8,7 +8,7 @@ const withTable = editor => {
8
8
  delete: slateDelete
9
9
  } = editor;
10
10
  editor.delete = arg => {
11
- if (arg.reverse) {
11
+ if (arg?.reverse) {
12
12
  const table = new TableUtil(editor);
13
13
  const cellsSelected = table.isCellSelected(editor.selection);
14
14
  if (cellsSelected && cellsSelected.length > 1) {
@@ -32,7 +32,7 @@ import FormField from "../Elements/Form/FormField";
32
32
  import InlineIcon from "../Elements/InlineIcon/InlineIcon";
33
33
  import SimpleText from "../Elements/SimpleText";
34
34
  import CheckList from "../Elements/List/CheckList";
35
- import { isEmptyTextNode } from "../helper";
35
+ import { getTextColor, isEmptyTextNode } from "../helper";
36
36
  import Attachments from "../Elements/Attachments/Attachments";
37
37
  import { getBreakPointsValue } from "../helper/theme";
38
38
  import Variables from "../Elements/Variables/Variable";
@@ -203,13 +203,7 @@ export const getMarked = (leaf, children) => {
203
203
  // cover under single span
204
204
  if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || className) {
205
205
  const family = fontFamilyMap[leaf?.fontFamily];
206
- const textStyles = leaf?.color?.indexOf("gradient") >= 0 ? {
207
- background: leaf?.color?.concat("text"),
208
- WebkitBackgroundClip: "text",
209
- WebkitTextFillColor: "transparent"
210
- } : {
211
- color: leaf.color
212
- };
206
+ const textStyles = getTextColor(leaf?.color);
213
207
  children = /*#__PURE__*/_jsx("span", {
214
208
  style: {
215
209
  background: leaf.bgColor
@@ -100,7 +100,7 @@ export const draftToSlate = props => {
100
100
  return a;
101
101
  }, []);
102
102
  return converted;
103
- } else if (data?.length) {
103
+ } else if (data?.length > 0) {
104
104
  return data;
105
105
  } else {
106
106
  return [{