@flozy/editor 10.6.4 → 10.6.5

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 (173) hide show
  1. package/dist/Editor/ChatEditor.js +16 -17
  2. package/dist/Editor/CommonEditor.js +14 -129
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +11 -57
  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 +9 -45
  8. package/dist/Editor/Elements/Accordion/AccordionSummary.js +23 -1
  9. package/dist/Editor/Elements/AppHeader/AppHeader.js +5 -10
  10. package/dist/Editor/Elements/Button/EditorButton.js +10 -26
  11. package/dist/Editor/Elements/Carousel/CarouselItem.js +1 -2
  12. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
  13. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  14. package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
  15. package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
  16. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/{SelectV1.js → MultiSelect.js} +69 -125
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +10 -10
  18. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +9 -28
  19. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +5 -12
  20. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +14 -40
  21. package/dist/Editor/Elements/Divider/Divider.js +1 -1
  22. package/dist/Editor/Elements/Embed/Embed.css +0 -4
  23. package/dist/Editor/Elements/Embed/Video.js +1 -1
  24. package/dist/Editor/Elements/Form/Form.js +3 -3
  25. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -0
  26. package/dist/Editor/Elements/Form/FormField.js +1 -1
  27. package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
  28. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +31 -35
  29. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -7
  30. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +0 -1
  31. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  32. package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +1 -1
  33. package/dist/Editor/Elements/FreeGrid/styles.js +0 -14
  34. package/dist/Editor/Elements/Grid/Grid.js +2 -14
  35. package/dist/Editor/Elements/Grid/GridItem.js +1 -1
  36. package/dist/Editor/Elements/Signature/Signature.css +1 -2
  37. package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +5 -18
  38. package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +3 -16
  39. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  40. package/dist/Editor/Elements/Table/AddRowCol.js +2 -8
  41. package/dist/Editor/Elements/Table/DragButton.js +1 -0
  42. package/dist/Editor/Elements/Table/Draggable.js +2 -6
  43. package/dist/Editor/Elements/Table/Styles.js +0 -7
  44. package/dist/Editor/Elements/Table/Table.js +3 -3
  45. package/dist/Editor/Elements/Table/TableCell.js +5 -24
  46. package/dist/Editor/Elements/Title/title.js +11 -8
  47. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  48. package/dist/Editor/MiniEditor.js +1 -2
  49. package/dist/Editor/Styles/EditorStyles.js +4 -4
  50. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  51. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  52. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  53. package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -10
  54. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  55. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
  56. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
  57. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
  58. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -7
  59. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
  60. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +13 -73
  61. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +10 -58
  62. package/dist/Editor/Toolbar/PopupTool/index.js +5 -12
  63. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  64. package/dist/Editor/common/ColorPickerButton.js +16 -41
  65. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  66. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  67. package/dist/Editor/common/Icon.js +0 -28
  68. package/dist/Editor/common/ImageSelector/ImageSelector.js +2 -2
  69. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  70. package/dist/Editor/common/LinkSettings/NavComponents.js +63 -47
  71. package/dist/Editor/common/LinkSettings/index.js +28 -17
  72. package/dist/Editor/common/LinkSettings/navOptions.js +2 -2
  73. package/dist/Editor/common/LinkSettings/style.js +244 -164
  74. package/dist/Editor/common/RnD/ElementOptions/Actions.js +5 -4
  75. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  76. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +3 -4
  77. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  78. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  79. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  80. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  81. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  82. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
  83. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  84. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -3
  85. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
  86. package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
  87. package/dist/Editor/common/RnD/OptionsPopup/style.js +1 -0
  88. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  89. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  90. package/dist/Editor/common/RnD/Utils/gridDropItem.js +19 -28
  91. package/dist/Editor/common/RnD/Utils/index.js +25 -58
  92. package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +58 -42
  93. package/dist/Editor/common/RnD/VirtualElement/helper.js +132 -323
  94. package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -16
  95. package/dist/Editor/common/RnD/index.js +38 -72
  96. package/dist/Editor/common/Select/index.js +7 -44
  97. package/dist/Editor/common/Select/styles.js +2 -30
  98. package/dist/Editor/common/Shorthands/elements.js +0 -54
  99. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +2 -2
  100. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +9 -12
  101. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  102. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
  103. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  104. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  105. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  106. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  107. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
  108. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
  109. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  110. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +0 -2
  111. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  112. package/dist/Editor/common/SwipeableDrawer/style.js +12 -14
  113. package/dist/Editor/common/Uploader.js +0 -16
  114. package/dist/Editor/common/iconListV2.js +0 -76
  115. package/dist/Editor/common/iconslist.js +0 -21
  116. package/dist/Editor/commonStyle.js +61 -116
  117. package/dist/Editor/helper/deserialize/index.js +4 -6
  118. package/dist/Editor/helper/index.js +2 -6
  119. package/dist/Editor/helper/theme.js +2 -203
  120. package/dist/Editor/hooks/useMouseMove.js +3 -9
  121. package/dist/Editor/hooks/useTable.js +4 -5
  122. package/dist/Editor/plugins/withCustomDeleteBackward.js +1 -6
  123. package/dist/Editor/plugins/withEmbeds.js +1 -1
  124. package/dist/Editor/plugins/withHTML.js +5 -14
  125. package/dist/Editor/plugins/withTable.js +1 -1
  126. package/dist/Editor/theme/ThemeList.js +173 -50
  127. package/dist/Editor/utils/SlateUtilityFunctions.js +50 -173
  128. package/dist/Editor/utils/accordion.js +37 -158
  129. package/dist/Editor/utils/button.js +17 -1
  130. package/dist/Editor/utils/customHooks/useTableResize.js +9 -49
  131. package/dist/Editor/utils/draftToSlate.js +2 -3
  132. package/dist/Editor/utils/events.js +6 -18
  133. package/dist/Editor/utils/font.js +37 -40
  134. package/dist/Editor/utils/formfield.js +0 -1
  135. package/dist/Editor/utils/helper.js +30 -149
  136. package/dist/Editor/utils/insertAppHeader.js +5 -9
  137. package/dist/Editor/utils/signature.js +9 -2
  138. package/package.json +4 -4
  139. package/dist/Editor/Elements/FreeGrid/helper.js +0 -115
  140. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
  141. package/dist/Editor/assets/svg/BackIcon.js +0 -18
  142. package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
  143. package/dist/Editor/common/Checkbox/index.js +0 -46
  144. package/dist/Editor/common/Checkbox/styles.js +0 -45
  145. package/dist/Editor/common/CustomColorPicker/index.js +0 -130
  146. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  147. package/dist/Editor/common/CustomDialog2/index.js +0 -94
  148. package/dist/Editor/common/CustomDialog2/style.js +0 -67
  149. package/dist/Editor/common/CustomSelect.js +0 -43
  150. package/dist/Editor/common/RadioGroup/index.js +0 -48
  151. package/dist/Editor/common/RadioGroup/styles.js +0 -29
  152. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  153. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  154. package/dist/Editor/helper/textIndeces.js +0 -58
  155. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  156. package/dist/Editor/hooks/useThemeValues.js +0 -63
  157. package/dist/Editor/theme/index.js +0 -149
  158. package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
  159. package/dist/Editor/themeSettings/buttons/index.js +0 -300
  160. package/dist/Editor/themeSettings/buttons/style.js +0 -23
  161. package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
  162. package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
  163. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  164. package/dist/Editor/themeSettings/fonts/index.js +0 -240
  165. package/dist/Editor/themeSettings/fonts/style.js +0 -62
  166. package/dist/Editor/themeSettings/icons.js +0 -60
  167. package/dist/Editor/themeSettings/index.js +0 -380
  168. package/dist/Editor/themeSettings/style.js +0 -299
  169. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  170. package/dist/Editor/themeSettingsAI/index.js +0 -355
  171. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
  172. package/dist/Editor/themeSettingsAI/style.js +0 -332
  173. package/dist/Editor/utils/updateFormName.js +0 -22
@@ -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,25 +47,16 @@ 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
+ import { jsxs as _jsxs } from "react/jsx-runtime";
52
53
  const alignment = ["alignLeft", "alignRight", "alignCenter", "alignJustify"];
53
54
  const list_types = ["orderedList", "unorderedList"];
54
55
  const LIST_FORMAT_TYPE = {
55
56
  orderedList: "list-item",
56
57
  unorderedList: "list-item"
57
58
  };
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"];
59
+ const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix"];
69
60
  export const toggleBlock = (editor, format, selection = true, attr = {}) => {
70
61
  const isActive = isBlockActive(editor, format);
71
62
  const isList = list_types.includes(format);
@@ -98,9 +89,8 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
98
89
  if (!selection) {
99
90
  Transforms.insertText(editor, "");
100
91
  }
101
- const forActiveType = THEME_BLOCK_FIELDS.some(f => f === format) ? format : "paragraph";
102
92
  Transforms.setNodes(editor, {
103
- type: isActive ? forActiveType : isList ? LIST_FORMAT_TYPE[format] : format,
93
+ type: isActive ? "paragraph" : isList ? LIST_FORMAT_TYPE[format] : format,
104
94
  ...attr
105
95
  });
106
96
  if (isList && !isActive) {
@@ -109,12 +99,10 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
109
99
  children: []
110
100
  });
111
101
  }
112
-
113
- // if (NEWLINESAFTER.indexOf(format) > -1) {
114
- // insertNewLine(editor);
115
- // }
102
+ if (NEWLINESAFTER.indexOf(format) > -1) {
103
+ insertNewLine(editor);
104
+ }
116
105
  };
117
-
118
106
  export const addMarkData = (editor, data) => {
119
107
  try {
120
108
  Editor.addMark(editor, data.format, data.value);
@@ -123,14 +111,9 @@ export const addMarkData = (editor, data) => {
123
111
  }
124
112
  };
125
113
  export const toggleMark = (editor, format) => {
126
- const isActive = isMarkBtnActive(editor, format);
114
+ const isActive = isMarkActive(editor, format);
127
115
  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
- }
116
+ Editor.removeMark(editor, format);
134
117
  } else {
135
118
  Editor.addMark(editor, format, true);
136
119
  }
@@ -144,58 +127,6 @@ export const isMarkActive = (editor, format) => {
144
127
  return null;
145
128
  }
146
129
  };
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
130
  export const isBlockActive = (editor, format) => {
200
131
  const [match] = Editor.nodes(editor, {
201
132
  match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
@@ -221,7 +152,7 @@ export const upateBlockActive = (editor, format, attr = {}) => {
221
152
  });
222
153
  }
223
154
  };
224
- export const activeMark = (editor, format, noDefaultValue) => {
155
+ export const activeMark = (editor, format) => {
225
156
  const defaultMarkData = {
226
157
  color: "#000000",
227
158
  bgColor: "#FFFFFF",
@@ -231,7 +162,7 @@ export const activeMark = (editor, format, noDefaultValue) => {
231
162
  };
232
163
  try {
233
164
  const marks = Editor.marks(editor);
234
- let defaultValue = noDefaultValue ? "" : defaultMarkData[format];
165
+ let defaultValue = defaultMarkData[format];
235
166
  const {
236
167
  selection
237
168
  } = editor || {};
@@ -248,31 +179,6 @@ export const activeMark = (editor, format, noDefaultValue) => {
248
179
  return null;
249
180
  }
250
181
  };
251
-
252
- // to avoid the styles, that automatically assign from themes
253
- const getThemeMarkedLeaf = (leaf, children) => {
254
- const {
255
- italic,
256
- bold
257
- } = leaf || {};
258
- const style = {};
259
- if (italic === false) {
260
- style.fontStyle = "normal";
261
- }
262
- if (bold === false) {
263
- style.fontWeight = "normal";
264
- }
265
- if (Object.keys(style).length) {
266
- children = /*#__PURE__*/_jsx(Box, {
267
- component: "span",
268
- sx: {
269
- "& span": style
270
- },
271
- children: children
272
- });
273
- }
274
- return children;
275
- };
276
182
  export const getMarked = (leaf, children, theme) => {
277
183
  const className = leaf?.doublequote ? "doublequote" : "";
278
184
  const lineH = leaf?.lineHeight;
@@ -302,7 +208,6 @@ export const getMarked = (leaf, children, theme) => {
302
208
  children: children
303
209
  });
304
210
  }
305
- children = getThemeMarkedLeaf(leaf, children);
306
211
  if (leaf.strikethrough) {
307
212
  children = /*#__PURE__*/_jsx("span", {
308
213
  style: {
@@ -330,15 +235,6 @@ export const getMarked = (leaf, children, theme) => {
330
235
  if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || lineHeight || className) {
331
236
  const family = leaf?.fontFamily;
332
237
  const textStyles = getTextColor(leaf?.color);
333
- const fontSize = {
334
- lg: sizeMap[leaf.fontSize] || leaf.fontSize,
335
- ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
336
- };
337
- const fontSizesImportant = {};
338
- Object.entries(fontSize).forEach(([key, value]) => {
339
- fontSizesImportant[key] = `${value} !important`;
340
- });
341
- const fontSizeWithBreakpoints = wrapThemeBreakpoints(fontSizesImportant, "fontSize", theme);
342
238
  children = /*#__PURE__*/_jsx("span", {
343
239
  style: {
344
240
  background: leaf.bgColor
@@ -347,13 +243,12 @@ export const getMarked = (leaf, children, theme) => {
347
243
  className: `${className} leaf-item`,
348
244
  component: "span",
349
245
  sx: {
350
- "& span": {
351
- // fontSize: fontSizesImportant,
352
- // ...groupByBreakpoint(fontSizesImportant, theme),
353
- background: leaf.bgColor,
354
- ...fontSizeWithBreakpoints
355
- },
356
- ...fontSizeWithBreakpoints,
246
+ ...groupByBreakpoint({
247
+ fontSize: {
248
+ lg: sizeMap[leaf.fontSize] || leaf.fontSize,
249
+ ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
250
+ }
251
+ }, theme),
357
252
  // ...wrapThemeBreakpoints(
358
253
  // {
359
254
  // lg: sizeMap[leaf.fontSize] || leaf.fontSize,
@@ -405,85 +300,69 @@ export const getBlock = props => {
405
300
  const {
406
301
  translation
407
302
  } = customProps;
408
- const commonHeadingProps = () => ({
409
- ...attributes,
410
- ...element.attr,
411
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element`
412
- });
413
- const commonParaProps = paraType => ({
414
- ...attributes,
415
- ...element.attr,
416
- className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
417
- });
418
303
  const breakpoint = getDevice(window.innerWidth);
419
304
  const lineH = element?.children[0]?.lineHeight;
420
305
  const selectedLineHeight = getBreakpointLineSpacing(lineH, breakpoint);
421
306
  switch (element.type) {
422
307
  case "headingOne":
423
- return /*#__PURE__*/_jsx("h1", {
308
+ return /*#__PURE__*/_jsxs("h1", {
424
309
  ...attributes,
425
310
  ...element.attr,
426
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
311
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
427
312
  placeholder: translation("Heading 1"),
428
- children: children
313
+ children: [children, /*#__PURE__*/_jsx("span", {
314
+ contentEditable: false
315
+ })]
429
316
  });
430
317
  case "headingTwo":
431
- return /*#__PURE__*/_jsx("h2", {
318
+ return /*#__PURE__*/_jsxs("h2", {
432
319
  ...attributes,
433
320
  ...element.attr,
434
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
321
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
435
322
  placeholder: translation("Heading 2"),
436
- children: children
323
+ children: [children, /*#__PURE__*/_jsx("span", {
324
+ contentEditable: false
325
+ })]
437
326
  });
438
327
  case "headingThree":
439
- return /*#__PURE__*/_jsx("h3", {
328
+ return /*#__PURE__*/_jsxs("h3", {
440
329
  ...attributes,
441
330
  ...element.attr,
442
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
331
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
443
332
  placeholder: translation("Heading 3"),
444
- children: children
333
+ children: [children, /*#__PURE__*/_jsx("span", {
334
+ contentEditable: false
335
+ })]
445
336
  });
446
337
  case "headingFour":
447
- return /*#__PURE__*/_jsx("h4", {
338
+ return /*#__PURE__*/_jsxs("h4", {
448
339
  ...attributes,
449
340
  ...element.attr,
450
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
341
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
451
342
  placeholder: translation("Heading 4"),
452
- children: children
343
+ children: [children, /*#__PURE__*/_jsx("span", {
344
+ contentEditable: false
345
+ })]
453
346
  });
454
347
  case "headingFive":
455
- return /*#__PURE__*/_jsx("h5", {
348
+ return /*#__PURE__*/_jsxs("h5", {
456
349
  ...attributes,
457
350
  ...element.attr,
458
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
351
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
459
352
  placeholder: translation("Heading 5"),
460
- children: children
353
+ children: [children, /*#__PURE__*/_jsx("span", {
354
+ contentEditable: false
355
+ })]
461
356
  });
462
357
  case "headingSix":
463
- return /*#__PURE__*/_jsx("h6", {
358
+ return /*#__PURE__*/_jsxs("h6", {
464
359
  ...attributes,
465
360
  ...element.attr,
466
- className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
361
+ className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
467
362
  placeholder: translation("Heading 6"),
468
- children: children
469
- });
470
- case "paragraphOne":
471
- return /*#__PURE__*/_jsx("p", {
472
- ...commonParaProps("para1"),
473
- placeholder: "Paragraph 1",
474
- children: children
475
- });
476
- case "paragraphTwo":
477
- return /*#__PURE__*/_jsx("p", {
478
- ...commonParaProps("para2"),
479
- placeholder: "Paragraph 2",
480
- children: children
481
- });
482
- case "paragraphThree":
483
- return /*#__PURE__*/_jsx("p", {
484
- ...commonParaProps("para3"),
485
- placeholder: "Paragraph 3",
486
- children: children
363
+ children: [children, /*#__PURE__*/_jsx("span", {
364
+ contentEditable: false
365
+ })]
487
366
  });
488
367
  case "blockquote":
489
368
  return /*#__PURE__*/_jsx("blockquote", {
@@ -793,10 +672,8 @@ export const getQueryStrings = urlString => {
793
672
  const newUrl = new URL(urlString);
794
673
  var youCode = newUrl.searchParams.get("v");
795
674
  if (!youCode) {
796
- const parts = newUrl.pathname.split("/");
797
- youCode = parts[parts.length - 1]; // video ID
675
+ youCode = newUrl.pathname.replace("/", "");
798
676
  }
799
-
800
677
  return `https://www.youtube.com/embed/${youCode}`;
801
678
  } else {
802
679
  return urlString;
@@ -1,169 +1,48 @@
1
- import { Editor, Element, Path, Transforms } from "slate";
1
+ import { Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
- import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType } from "./helper";
4
- import { isMobileWindow } from "../helper";
5
- import { removeAccordion } from "./events";
6
- import { ReactEditor } from "slate-react";
7
- const focusAccordion = (editor, upPath) => {
8
- Transforms.select(editor, {
9
- path: upPath,
10
- offset: 0
11
- });
12
- };
13
- const getAccordionNode = summaryNode => {
14
- return {
15
- type: "accordion",
16
- children: [{
17
- type: "accordion-summary",
18
- children: summaryNode
19
- }, {
20
- type: "accordion-details",
3
+ import { getSelectedText } from "./helper";
4
+ export const insertAccordion = (editor, path) => {
5
+ try {
6
+ const selectedText = getSelectedText(editor);
7
+ const accordion = {
8
+ type: "accordion",
21
9
  children: [{
22
- type: "paragraph",
10
+ type: "accordion-summary",
23
11
  children: [{
24
- text: ""
12
+ type: "paragraph",
13
+ children: [{
14
+ text: selectedText || ""
15
+ }]
25
16
  }]
26
- }]
27
- }]
28
- };
29
- };
30
- export const insertAccordion = (editor, path) => {
31
- try {
32
- const {
33
- selection
34
- } = editor;
35
- let accordionPath;
36
- if (path) {
37
- const summaryNode = {
38
- type: "paragraph",
17
+ }, {
18
+ type: "accordion-details",
39
19
  children: [{
40
- text: ""
20
+ type: "paragraph",
21
+ children: [{
22
+ text: ""
23
+ }]
41
24
  }]
42
- };
43
- const accordion = getAccordionNode([summaryNode]);
44
- Transforms.insertNodes(editor, accordion, {
45
- at: path
46
- });
47
- accordionPath = path;
48
- } else if (selection) {
49
- const selectedNodes = Array.from(Editor.nodes(editor, {
50
- at: selection,
51
- match: n => Element.isElement(n),
52
- mode: "lowest" // use 'lowest' to get individual blocks
53
- }));
54
-
55
- for (const [node, path] of selectedNodes) {
56
- let currNode = node;
57
- const isListItem = node.type === "list-item";
58
- if (isListItem) {
59
- currNode = {
60
- type: "paragraph",
61
- children: node.children
62
- };
63
- }
64
- let accordion = getAccordionNode([currNode]);
65
- if (isListItem) {
66
- accordion = {
67
- type: "list-item",
68
- children: [accordion]
69
- };
70
- }
71
- Transforms.removeNodes(editor, {
72
- at: path
73
- });
74
- Transforms.insertNodes(editor, accordion, {
75
- at: path
76
- });
77
- }
78
- const lastNode = selectedNodes[selectedNodes.length - 1];
79
- const lastNodePath = lastNode[1];
80
- accordionPath = lastNodePath;
81
- }
82
- const focusPath = [...accordionPath, 0, 0, 0];
83
- if (isMobileWindow()) {
84
- // timeout to resolve focus issue in mobile
85
- setTimeout(() => focusAccordion(editor, focusPath), 0);
86
- } else {
87
- focusAccordion(editor, focusPath);
88
- }
25
+ }]
26
+ };
27
+ const props = path ? {
28
+ at: path,
29
+ select: true
30
+ } : {
31
+ select: true
32
+ };
33
+ Transforms.insertNodes(editor, accordion, props);
34
+ const curPath = [...editor?.selection?.anchor?.path];
35
+ const upPath = [...curPath];
36
+ // get title index
37
+ const summaryIndex = upPath.length - 3;
38
+ upPath[summaryIndex] = upPath[summaryIndex] === 0 ? 0 : upPath[summaryIndex] - 1;
39
+ // select accordion title by default
40
+ Transforms.select(editor, {
41
+ path: upPath,
42
+ offset: 0
43
+ });
89
44
  insertNewLine(editor);
90
45
  } catch (err) {
91
46
  console.log(err);
92
47
  }
93
- };
94
- export const onDeleteBackwardAccordion = editor => {
95
- try {
96
- let preventDefault = false;
97
- const {
98
- selection
99
- } = editor;
100
- const {
101
- path: currentPath,
102
- offset
103
- } = selection.anchor || {};
104
- const isCursorAtStart = offset === 0;
105
- if (isCursorAtStart) {
106
- // If the cursor is at the start of the accordion-summary and backspace is pressed,
107
- // unwrap the accordion by removing both the summary and details,
108
- // and insert their contents as regular nodes without the accordion wrapper.
109
- const [accordionSummary] = getNodeWithType(editor, "accordion-summary");
110
- const [accordionTitle, accordionTitlePath] = accordionSummary || [];
111
- if (accordionTitle) {
112
- const accordionPath = Path.parent(accordionTitlePath);
113
- removeAccordion(editor, accordionPath);
114
- preventDefault = true;
115
- return;
116
- }
117
- const parentPath = Path.parent(currentPath);
118
- const parentNode = getNode(editor, parentPath);
119
- const isTextNode = ALLOWED_TEXT_NODES.includes(parentNode?.type);
120
- if (isTextNode) {
121
- const prevEntry = Editor.previous(editor, {
122
- at: parentPath,
123
- match: n => n.type === "accordion"
124
- });
125
- if (prevEntry) {
126
- const [accordionNode, accordionPath] = prevEntry;
127
- const dom = ReactEditor.toDOMNode(editor, accordionNode);
128
- const aContent = dom.querySelector(".accordion-content");
129
- const isContentVisible = aContent.style.display !== "none";
130
- if (!isContentVisible) {
131
- // If the accordion content is not visible and backspace is pressed,
132
- // the content from the current node should be merged with the accordion title,
133
- // and the cursor should move to the title.
134
- // Otherwise, Slate will by default merge the current node into the hidden details section,
135
- // which makes the content invisible.
136
-
137
- let targetPath = [...accordionPath, 0, 0];
138
- const targetNodeEntry = getNode(editor, targetPath);
139
- if (targetNodeEntry) {
140
- const nodeText = getNodeText(parentNode);
141
- const endPath = Editor.end(editor, targetPath);
142
-
143
- // Move current paragraph text into the end of the target block
144
- Transforms.select(editor, Editor.start(editor, parentPath));
145
- Transforms.delete(editor, {
146
- at: parentPath
147
- });
148
- Transforms.insertText(editor, nodeText, {
149
- at: endPath
150
- });
151
-
152
- // move the focus and cursor to the inserted node
153
- Transforms.select(editor, {
154
- anchor: endPath,
155
- focus: endPath
156
- });
157
- ReactEditor.focus(editor);
158
- preventDefault = true;
159
- return;
160
- }
161
- }
162
- }
163
- }
164
- }
165
- return preventDefault;
166
- } catch (err) {
167
- console.log(err);
168
- }
169
48
  };
@@ -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;