@flozy/editor 11.0.2 → 11.0.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 (147) hide show
  1. package/dist/Editor/ChatEditor.js +16 -17
  2. package/dist/Editor/CommonEditor.js +16 -129
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +8 -36
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
  6. package/dist/Editor/Elements/AI/Styles.js +0 -1
  7. package/dist/Editor/Elements/Accordion/Accordion.js +22 -28
  8. package/dist/Editor/Elements/Accordion/AccordionButton.js +3 -12
  9. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  10. package/dist/Editor/Elements/Attachments/Attachments.js +11 -153
  11. package/dist/Editor/Elements/Attachments/AttachmentsButton.js +3 -8
  12. package/dist/Editor/Elements/Button/EditorButton.js +7 -23
  13. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  14. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  15. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  16. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
  18. package/dist/Editor/Elements/Embed/Embed.js +43 -36
  19. package/dist/Editor/Elements/Embed/Image.js +23 -236
  20. package/dist/Editor/Elements/Embed/Video.js +15 -245
  21. package/dist/Editor/Elements/Form/FormField.js +1 -1
  22. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  23. package/dist/Editor/Elements/Form/Workflow/constant.js +1 -25
  24. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +74 -31
  25. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +5 -9
  26. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -3
  27. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  28. package/dist/Editor/Elements/FreeGrid/styles.js +0 -15
  29. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  30. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +1 -2
  31. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -3
  32. package/dist/Editor/Elements/Signature/SignaturePopup.js +1 -4
  33. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  34. package/dist/Editor/Elements/Table/Table.js +3 -3
  35. package/dist/Editor/Elements/Title/title.js +6 -6
  36. package/dist/Editor/Elements/TopBanner/TopBanner.js +2 -4
  37. package/dist/Editor/Elements/TopBanner/TopBannerButton.js +3 -5
  38. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  39. package/dist/Editor/MiniEditor.js +1 -2
  40. package/dist/Editor/Styles/EditorStyles.js +7 -19
  41. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  42. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  43. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  44. package/dist/Editor/Toolbar/FormatTools/TextSize.js +29 -33
  45. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  46. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  47. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +23 -25
  48. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +7 -25
  49. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  50. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +8 -24
  51. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  52. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +10 -70
  53. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +14 -73
  54. package/dist/Editor/Toolbar/PopupTool/index.js +3 -4
  55. package/dist/Editor/Toolbar/toolbarGroups.js +10 -56
  56. package/dist/Editor/common/ColorPickerButton.js +16 -38
  57. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  58. package/dist/Editor/common/FontLoader/FontLoader.js +0 -4
  59. package/dist/Editor/common/Icon.js +0 -28
  60. package/dist/Editor/common/ImageSelector/ImageSelector.js +7 -45
  61. package/dist/Editor/common/ImageSelector/Options/Upload.js +11 -26
  62. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  63. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
  64. package/dist/Editor/common/MentionsPopup/index.js +1 -9
  65. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  66. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  67. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  68. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  69. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  70. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  71. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +7 -20
  72. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  73. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -9
  74. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +7 -20
  75. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  76. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  77. package/dist/Editor/common/RnD/Utils/gridDropItem.js +11 -28
  78. package/dist/Editor/common/RnD/Utils/index.js +1 -3
  79. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +63 -52
  80. package/dist/Editor/common/RnD/VirtualElement/helper.js +130 -320
  81. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -22
  82. package/dist/Editor/common/RnD/index.js +14 -61
  83. package/dist/Editor/common/Shorthands/elements.js +4 -62
  84. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  85. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  86. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +2 -15
  87. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  88. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  89. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  90. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  91. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  92. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  93. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +1 -0
  94. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  95. package/dist/Editor/common/StyleBuilder/index.js +4 -8
  96. package/dist/Editor/common/Uploader.js +17 -125
  97. package/dist/Editor/common/iconslist.js +0 -21
  98. package/dist/Editor/commonStyle.js +45 -64
  99. package/dist/Editor/helper/index.js +2 -10
  100. package/dist/Editor/helper/theme.js +2 -203
  101. package/dist/Editor/hooks/useMouseMove.js +3 -9
  102. package/dist/Editor/plugins/withEmbeds.js +1 -12
  103. package/dist/Editor/plugins/withHTML.js +1 -3
  104. package/dist/Editor/plugins/withTable.js +1 -1
  105. package/dist/Editor/service/fileupload.js +0 -70
  106. package/dist/Editor/theme/ThemeList.js +173 -50
  107. package/dist/Editor/utils/SlateUtilityFunctions.js +41 -191
  108. package/dist/Editor/utils/accordion.js +40 -68
  109. package/dist/Editor/utils/button.js +17 -1
  110. package/dist/Editor/utils/draftToSlate.js +2 -3
  111. package/dist/Editor/utils/events.js +89 -94
  112. package/dist/Editor/utils/font.js +37 -40
  113. package/dist/Editor/utils/formfield.js +2 -2
  114. package/dist/Editor/utils/helper.js +22 -98
  115. package/package.json +4 -4
  116. package/dist/Editor/Elements/Attachments/AttachmentStyles.js +0 -16
  117. package/dist/Editor/Elements/FreeGrid/helper.js +0 -194
  118. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  119. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  120. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  121. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  122. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  123. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  124. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  125. package/dist/Editor/common/CustomSelect.js +0 -43
  126. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  127. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  128. package/dist/Editor/common/UploaderWithProgress.js +0 -183
  129. package/dist/Editor/helper/textIndeces.js +0 -58
  130. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  131. package/dist/Editor/hooks/useThemeValues.js +0 -63
  132. package/dist/Editor/theme/index.js +0 -149
  133. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  134. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  135. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  136. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  137. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  138. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  139. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  140. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  141. package/dist/Editor/themeSettings/icons.js +0 -60
  142. package/dist/Editor/themeSettings/index.js +0 -380
  143. package/dist/Editor/themeSettings/style.js +0 -299
  144. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  145. package/dist/Editor/themeSettingsAI/index.js +0 -355
  146. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  147. package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -34,12 +34,12 @@ import SimpleText from "../Elements/SimpleText";
34
34
  import CheckList from "../Elements/List/CheckList";
35
35
  import { getTextColor, isEmptyTextNode } from "../helper";
36
36
  import Attachments from "../Elements/Attachments/Attachments";
37
- import { getBreakpointLineSpacing, getBreakPointsValue, getDevice, getElementProperty, textThemeFields } from "../helper/theme";
37
+ import { getBreakpointLineSpacing, getBreakPointsValue, getDevice, groupByBreakpoint } from "../helper/theme";
38
38
  import Variables from "../Elements/Variables/Variable";
39
+ import insertNewLine from "./insertNewLine";
39
40
  import Divider from "../Elements/Divider/Divider";
40
41
  import { getBorderColor, getSlateDom } from "./helper";
41
42
  import Code from "../Elements/EmbedScript/Code";
42
- import { ReactEditor } from "slate-react";
43
43
  import FreeGrid from "../Elements/FreeGrid/FreeGrid";
44
44
  import FreeGridItem from "../Elements/FreeGrid/FreeGridItem";
45
45
  import FreeGridBox from "../Elements/FreeGrid/FreeGridBox";
@@ -47,27 +47,17 @@ import DataView from "../Elements/DataView/DataView";
47
47
  import ViewData from "../Elements/DataView/Layouts/ViewData";
48
48
  import ColumnView from "../Elements/DataView/Layouts/ColumnView";
49
49
  import SearchAttachment from "../Elements/Search/SearchAttachment";
50
- import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
50
+ // import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
51
51
  import { jsx as _jsx } from "react/jsx-runtime";
52
52
  const alignment = ["alignLeft", "alignRight", "alignCenter", "alignJustify"];
53
- export const list_types = ["orderedList", "unorderedList"];
53
+ const list_types = ["orderedList", "unorderedList"];
54
54
  const LIST_FORMAT_TYPE = {
55
55
  orderedList: "list-item",
56
56
  unorderedList: "list-item"
57
57
  };
58
-
59
- // const NEWLINESAFTER = [
60
- // "headingOne",
61
- // "headingTwo",
62
- // "headingThree",
63
- // "headingFour",
64
- // "headingFive",
65
- // "headingSix",
66
- // ];
67
-
68
- const THEME_BLOCK_FIELDS = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
58
+ const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix"];
69
59
  export const toggleBlock = (editor, format, selection = true, attr = {}) => {
70
- let isActive = isBlockActive(editor, format);
60
+ const isActive = isBlockActive(editor, format);
71
61
  const isList = list_types.includes(format);
72
62
  const isIndent = alignment.includes(format);
73
63
  const isAligned = alignment.some(alignmentType => isBlockActive(editor, alignmentType));
@@ -98,9 +88,8 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
98
88
  if (!selection) {
99
89
  Transforms.insertText(editor, "");
100
90
  }
101
- const forActiveType = THEME_BLOCK_FIELDS.some(f => f === format) ? format : "paragraph";
102
91
  Transforms.setNodes(editor, {
103
- type: isActive ? forActiveType : isList ? LIST_FORMAT_TYPE[format] : format,
92
+ type: isActive ? "paragraph" : isList ? LIST_FORMAT_TYPE[format] : format,
104
93
  ...attr
105
94
  });
106
95
  if (isList && !isActive) {
@@ -109,12 +98,10 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
109
98
  children: []
110
99
  });
111
100
  }
112
-
113
- // if (NEWLINESAFTER.indexOf(format) > -1) {
114
- // insertNewLine(editor);
115
- // }
101
+ if (NEWLINESAFTER.indexOf(format) > -1) {
102
+ insertNewLine(editor);
103
+ }
116
104
  };
117
-
118
105
  export const addMarkData = (editor, data) => {
119
106
  try {
120
107
  Editor.addMark(editor, data.format, data.value);
@@ -123,14 +110,9 @@ export const addMarkData = (editor, data) => {
123
110
  }
124
111
  };
125
112
  export const toggleMark = (editor, format) => {
126
- const isActive = isMarkBtnActive(editor, format);
113
+ const isActive = isMarkActive(editor, format);
127
114
  if (isActive) {
128
- const isThemeSupportedMark = textThemeFields.some(f => f === format);
129
- if (isThemeSupportedMark) {
130
- Editor.addMark(editor, format, false);
131
- } else {
132
- Editor.removeMark(editor, format);
133
- }
115
+ Editor.removeMark(editor, format);
134
116
  } else {
135
117
  Editor.addMark(editor, format, true);
136
118
  }
@@ -144,91 +126,12 @@ export const isMarkActive = (editor, format) => {
144
126
  return null;
145
127
  }
146
128
  };
147
- export const isMarkBtnActive = (editor, format) => {
148
- switch (format) {
149
- case "bold":
150
- {
151
- const style = getSelectedElementStyle("font-weight", editor);
152
- return style === "700";
153
- }
154
- case "italic":
155
- {
156
- const style = getSelectedElementStyle("font-style", editor);
157
- return style === format;
158
- }
159
- // case "underline": {
160
- // const style = getSelectedElementStyle("text-decoration");
161
-
162
- // return style?.includes(format);
163
- // }
164
- // case "strikethrough": {
165
- // const style = getSelectedElementStyle("text-decoration");
166
-
167
- // return style?.includes("line-through");
168
- // }
169
- default:
170
- return isMarkActive(editor, format);
171
- }
172
- };
173
- export const getSelectedElementStyle = (styleProperty, editor, format) => {
174
- try {
175
- if (!editor.selection) {
176
- return "";
177
- }
178
- if (Range.isCollapsed(editor.selection)) {
179
- return "";
180
- }
181
- if (format) {
182
- const value = activeMark(editor, format, true);
183
- if (value) {
184
- return value;
185
- }
186
- }
187
- const domRange = ReactEditor.toDOMRange(editor, editor.selection);
188
- const selectedDomNode = domRange.commonAncestorContainer;
189
-
190
- // If it's a text node, get its parent element
191
- const selectedElement = selectedDomNode.nodeType === 3 ? selectedDomNode.parentElement : selectedDomNode;
192
- if (selectedElement) {
193
- return getElementProperty(selectedElement, styleProperty);
194
- }
195
- } catch (err) {
196
- console.log(err);
197
- }
198
- };
199
129
  export const isBlockActive = (editor, format) => {
200
130
  const [match] = Editor.nodes(editor, {
201
131
  match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
202
132
  });
203
133
  return !!match;
204
134
  };
205
- export const isListActive = editor => {
206
- const list_types = ["orderedList", "unorderedList", "check-list-item", "accordion"];
207
- const [match] = Editor.nodes(editor, {
208
- match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && list_types.includes(n.type),
209
- mode: "lowest" // To ensure it's the closest parent
210
- });
211
-
212
- if (match) {
213
- const [matchNode] = match;
214
- return matchNode.type;
215
- }
216
- };
217
- export const getListType = editor => {
218
- const [accordionSummary] = Editor.nodes(editor, {
219
- match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === "accordion-summary"
220
- });
221
- if (accordionSummary) {
222
- return "accordion-summary";
223
- }
224
- const listItems = ["list-item", "check-list-item"];
225
- const [listItem] = Editor.nodes(editor, {
226
- match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && listItems.includes(n.type)
227
- });
228
- if (listItem) {
229
- return "list-item";
230
- }
231
- };
232
135
  export const getBlockActive = (editor, format) => {
233
136
  const [match] = Editor.nodes(editor, {
234
137
  match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
@@ -248,7 +151,7 @@ export const upateBlockActive = (editor, format, attr = {}) => {
248
151
  });
249
152
  }
250
153
  };
251
- export const activeMark = (editor, format, noDefaultValue) => {
154
+ export const activeMark = (editor, format) => {
252
155
  const defaultMarkData = {
253
156
  color: "#000000",
254
157
  bgColor: "#FFFFFF",
@@ -258,7 +161,7 @@ export const activeMark = (editor, format, noDefaultValue) => {
258
161
  };
259
162
  try {
260
163
  const marks = Editor.marks(editor);
261
- let defaultValue = noDefaultValue ? "" : defaultMarkData[format];
164
+ let defaultValue = defaultMarkData[format];
262
165
  const {
263
166
  selection
264
167
  } = editor || {};
@@ -275,31 +178,6 @@ export const activeMark = (editor, format, noDefaultValue) => {
275
178
  return null;
276
179
  }
277
180
  };
278
-
279
- // to avoid the styles, that automatically assign from themes
280
- const getThemeMarkedLeaf = (leaf, children) => {
281
- const {
282
- italic,
283
- bold
284
- } = leaf || {};
285
- const style = {};
286
- if (italic === false) {
287
- style.fontStyle = "normal";
288
- }
289
- if (bold === false) {
290
- style.fontWeight = "normal";
291
- }
292
- if (Object.keys(style).length) {
293
- children = /*#__PURE__*/_jsx(Box, {
294
- component: "span",
295
- sx: {
296
- "& span": style
297
- },
298
- children: children
299
- });
300
- }
301
- return children;
302
- };
303
181
  export const getMarked = (leaf, children, theme) => {
304
182
  const className = leaf?.doublequote ? "doublequote" : "";
305
183
  const lineH = leaf?.lineHeight;
@@ -329,7 +207,6 @@ export const getMarked = (leaf, children, theme) => {
329
207
  children: children
330
208
  });
331
209
  }
332
- children = getThemeMarkedLeaf(leaf, children);
333
210
  if (leaf.strikethrough) {
334
211
  children = /*#__PURE__*/_jsx("span", {
335
212
  style: {
@@ -357,15 +234,6 @@ export const getMarked = (leaf, children, theme) => {
357
234
  if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || lineHeight || className) {
358
235
  const family = leaf?.fontFamily;
359
236
  const textStyles = getTextColor(leaf?.color);
360
- const fontSize = {
361
- lg: sizeMap[leaf.fontSize] || leaf.fontSize,
362
- ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
363
- };
364
- const fontSizesImportant = {};
365
- Object.entries(fontSize).forEach(([key, value]) => {
366
- fontSizesImportant[key] = `${value} !important`;
367
- });
368
- const fontSizeWithBreakpoints = wrapThemeBreakpoints(fontSizesImportant, "fontSize", theme);
369
237
  children = /*#__PURE__*/_jsx("span", {
370
238
  style: {
371
239
  background: leaf.bgColor
@@ -374,13 +242,12 @@ export const getMarked = (leaf, children, theme) => {
374
242
  className: `${className} leaf-item`,
375
243
  component: "span",
376
244
  sx: {
377
- "& span": {
378
- // fontSize: fontSizesImportant,
379
- // ...groupByBreakpoint(fontSizesImportant, theme),
380
- background: leaf.bgColor,
381
- ...fontSizeWithBreakpoints
382
- },
383
- ...fontSizeWithBreakpoints,
245
+ ...groupByBreakpoint({
246
+ fontSize: {
247
+ lg: sizeMap[leaf.fontSize] || leaf.fontSize,
248
+ ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
249
+ }
250
+ }, theme),
384
251
  // ...wrapThemeBreakpoints(
385
252
  // {
386
253
  // lg: sizeMap[leaf.fontSize] || leaf.fontSize,
@@ -401,8 +268,7 @@ export const getMarked = (leaf, children, theme) => {
401
268
  WebkitTextFillColor: "unset !important"
402
269
  },
403
270
  style: {
404
- "--fontSize_xs": leaf?.fontSize?.xs || "auto",
405
- "--fontSize_lg": leaf?.fontSize?.lg || "auto"
271
+ "--fontSize_xs": leaf?.fontSize?.xs || "auto"
406
272
  },
407
273
  children: children
408
274
  })
@@ -433,78 +299,63 @@ export const getBlock = props => {
433
299
  const {
434
300
  translation
435
301
  } = customProps;
436
- const commonHeadingProps = () => ({
437
- ...attributes,
438
- ...element.attr,
439
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent`
440
- });
441
- const commonParaProps = paraType => ({
442
- ...attributes,
443
- ...element.attr,
444
- className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent ${paraType}`
445
- });
446
302
  const breakpoint = getDevice(window.innerWidth);
447
303
  const lineH = element?.children[0]?.lineHeight;
448
304
  const selectedLineHeight = getBreakpointLineSpacing(lineH, breakpoint);
449
305
  switch (element.type) {
450
306
  case "headingOne":
451
307
  return /*#__PURE__*/_jsx("h1", {
452
- ...commonHeadingProps(),
308
+ ...attributes,
309
+ ...element.attr,
310
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
453
311
  placeholder: translation("Heading 1"),
454
312
  children: children
455
313
  });
456
314
  case "headingTwo":
457
315
  return /*#__PURE__*/_jsx("h2", {
458
- ...commonHeadingProps(),
316
+ ...attributes,
317
+ ...element.attr,
318
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
459
319
  placeholder: translation("Heading 2"),
460
320
  children: children
461
321
  });
462
322
  case "headingThree":
463
323
  return /*#__PURE__*/_jsx("h3", {
464
- ...commonHeadingProps(),
324
+ ...attributes,
325
+ ...element.attr,
326
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
465
327
  placeholder: translation("Heading 3"),
466
328
  children: children
467
329
  });
468
330
  case "headingFour":
469
331
  return /*#__PURE__*/_jsx("h4", {
470
- ...commonHeadingProps(),
332
+ ...attributes,
333
+ ...element.attr,
334
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
471
335
  placeholder: translation("Heading 4"),
472
336
  children: children
473
337
  });
474
338
  case "headingFive":
475
339
  return /*#__PURE__*/_jsx("h5", {
476
- ...commonHeadingProps(),
340
+ ...attributes,
341
+ ...element.attr,
342
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
477
343
  placeholder: translation("Heading 5"),
478
344
  children: children
479
345
  });
480
346
  case "headingSix":
481
347
  return /*#__PURE__*/_jsx("h6", {
482
- ...commonHeadingProps(),
348
+ ...attributes,
349
+ ...element.attr,
350
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
483
351
  placeholder: translation("Heading 6"),
484
352
  children: children
485
353
  });
486
- case "paragraphOne":
487
- return /*#__PURE__*/_jsx("p", {
488
- ...commonParaProps("para1"),
489
- placeholder: "Paragraph 1",
490
- children: children
491
- });
492
- case "paragraphTwo":
493
- return /*#__PURE__*/_jsx("p", {
494
- ...commonParaProps("para2"),
495
- placeholder: "Paragraph 2",
496
- children: children
497
- });
498
- case "paragraphThree":
499
- return /*#__PURE__*/_jsx("p", {
500
- ...commonParaProps("para3"),
501
- placeholder: "Paragraph 3",
502
- children: children
503
- });
504
354
  case "blockquote":
505
355
  return /*#__PURE__*/_jsx("blockquote", {
506
356
  ...attributes,
507
357
  ...element.attr,
358
+ className: "blockQuoteComp",
508
359
  style: {
509
360
  // borderColor: element?.color || "transparent",
510
361
  ...getBorderColor(element?.color || "transparent", 3),
@@ -734,8 +585,7 @@ export const getBlock = props => {
734
585
  case "docs":
735
586
  case "pdf":
736
587
  case "xls":
737
- case "doc":
738
- case "ppt":
588
+ case "csv":
739
589
  return /*#__PURE__*/_jsx(Attachments, {
740
590
  ...props
741
591
  });
@@ -1,5 +1,7 @@
1
1
  import { Editor, Element, Path, Transforms } from "slate";
2
- import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType } from "./helper";
2
+ import insertNewLine from "./insertNewLine";
3
+ import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType, getSelectedText } from "./helper";
4
+ import { isMobileWindow } from "../helper";
3
5
  import { removeAccordion } from "./events";
4
6
  import { ReactEditor } from "slate-react";
5
7
  const focusAccordion = (editor, upPath) => {
@@ -7,74 +9,51 @@ const focusAccordion = (editor, upPath) => {
7
9
  path: upPath,
8
10
  offset: 0
9
11
  });
10
- ReactEditor.focus(editor);
11
12
  };
12
- const getAccordionNode = summaryNode => {
13
- return {
14
- type: "accordion",
15
- children: [{
16
- type: "accordion-summary",
17
- children: summaryNode
18
- }, {
19
- type: "accordion-details",
13
+ export const insertAccordion = (editor, path) => {
14
+ try {
15
+ const selectedText = getSelectedText(editor);
16
+ const accordion = {
17
+ type: "accordion",
20
18
  children: [{
21
- type: "paragraph",
19
+ type: "accordion-summary",
22
20
  children: [{
23
- text: ""
21
+ type: "paragraph",
22
+ children: [{
23
+ text: selectedText || ""
24
+ }]
24
25
  }]
25
- }]
26
- }]
27
- };
28
- };
29
- export const insertAccordion = (editor, path) => {
30
- try {
31
- const {
32
- selection
33
- } = editor;
34
- let accordionPath;
35
- if (path) {
36
- const summaryNode = {
37
- type: "paragraph",
26
+ }, {
27
+ type: "accordion-details",
38
28
  children: [{
39
- text: ""
29
+ type: "paragraph",
30
+ children: [{
31
+ text: ""
32
+ }]
40
33
  }]
41
- };
42
- const accordion = getAccordionNode([summaryNode]);
43
- Transforms.insertNodes(editor, accordion, {
44
- at: path
45
- });
46
- accordionPath = path;
47
- } else if (selection) {
48
- const selectedNodes = Array.from(Editor.nodes(editor, {
49
- match: n => Element.isElement(n),
50
- mode: "lowest" // use 'lowest' to get individual blocks
51
- }));
52
-
53
- for (const [node, path] of selectedNodes) {
54
- let currNode = node;
55
- // const isListItem = node.type === "list-item";
56
- // if (isListItem) {
57
- // currNode = {
58
- // type: "paragraph",
59
- // children: node.children,
60
- // };
61
- // }
34
+ }]
35
+ };
36
+ const props = path ? {
37
+ at: path,
38
+ select: true
39
+ } : {
40
+ select: true
41
+ };
42
+ Transforms.insertNodes(editor, accordion, props);
43
+ const curPath = [...editor?.selection?.anchor?.path];
44
+ const upPath = [...curPath];
45
+ // get title index
46
+ const summaryIndex = upPath.length - 3;
47
+ upPath[summaryIndex] = upPath[summaryIndex] === 0 ? 0 : upPath[summaryIndex] - 1;
62
48
 
63
- let accordion = getAccordionNode([currNode]);
64
- Transforms.removeNodes(editor, {
65
- at: path
66
- });
67
- Transforms.insertNodes(editor, accordion, {
68
- at: path
69
- });
70
- accordionPath = path;
71
- }
72
- const lastNode = selectedNodes[selectedNodes.length - 1];
73
- const lastNodePath = lastNode[1];
74
- accordionPath = lastNodePath;
49
+ // select accordion title by default
50
+ if (isMobileWindow()) {
51
+ // timeout to resolve focus issue in mobile
52
+ setTimeout(() => focusAccordion(editor, upPath), 0);
53
+ } else {
54
+ focusAccordion(editor, upPath);
75
55
  }
76
- const focusPath = [...accordionPath, 0, 0, 0];
77
- focusAccordion(editor, focusPath);
56
+ insertNewLine(editor);
78
57
  } catch (err) {
79
58
  console.log(err);
80
59
  }
@@ -154,11 +133,4 @@ export const onDeleteBackwardAccordion = editor => {
154
133
  } catch (err) {
155
134
  console.log(err);
156
135
  }
157
- };
158
- export const toggleAccordion = editor => {
159
- const parentAccordion = Editor.above(editor, {
160
- match: node => Element.isElement(node) && node.type === "accordion"
161
- });
162
- const [, accordionPath] = parentAccordion;
163
- removeAccordion(editor, accordionPath);
164
136
  };
@@ -1,5 +1,6 @@
1
1
  import { Path, Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
+ import { windowVar } from "./helper";
3
4
  import { getCurrentElementText } from "../plugins/withHTML";
4
5
  export const insertButton = editor => {
5
6
  const button = {
@@ -10,7 +11,22 @@ export const insertButton = editor => {
10
11
  buttonLink: {
11
12
  linkType: "webAddress"
12
13
  },
13
- iconPosition: "start"
14
+ iconPosition: "start",
15
+ bgColor: "#2563EB",
16
+ textColor: "#FFF",
17
+ borderRadius: {
18
+ topLeft: 30,
19
+ topRight: 30,
20
+ bottomLeft: 30,
21
+ bottomRight: 30
22
+ },
23
+ bannerSpacing: {
24
+ left: 16,
25
+ top: 8,
26
+ right: 16,
27
+ bottom: 8
28
+ },
29
+ ...(windowVar.lastButtonProps || {})
14
30
  };
15
31
  const hasText = getCurrentElementText(editor);
16
32
  const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor?.selection.focus.path;
@@ -82,8 +82,7 @@ const splitInlineStyleRanges = (text, inlineStyleRanges, data) => {
82
82
  };
83
83
  export const draftToSlate = props => {
84
84
  const {
85
- data,
86
- needLayout
85
+ data
87
86
  } = props;
88
87
  if (data?.blocks && data?.blocks?.length > 0) {
89
88
  const converted = data?.blocks?.reduce((a, b) => {
@@ -105,7 +104,7 @@ export const draftToSlate = props => {
105
104
  return data;
106
105
  } else {
107
106
  return [{
108
- type: needLayout ? "title" : "paragraph",
107
+ type: "paragraph",
109
108
  children: [{
110
109
  text: ""
111
110
  }]