@flozy/editor 5.5.7 → 5.5.9

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 (198) hide show
  1. package/dist/Editor/ChatEditor.js +34 -25
  2. package/dist/Editor/CommonEditor.js +13 -26
  3. package/dist/Editor/Editor.css +19 -102
  4. package/dist/Editor/Elements/AI/AIInput.js +1 -0
  5. package/dist/Editor/Elements/AI/CustomSelect.js +10 -17
  6. package/dist/Editor/Elements/AI/PopoverAIInput.js +53 -59
  7. package/dist/Editor/Elements/AI/Styles.js +6 -24
  8. package/dist/Editor/Elements/Accordion/Accordion.js +1 -8
  9. package/dist/Editor/Elements/AppHeader/AppHeader.js +6 -6
  10. package/dist/Editor/Elements/Button/EditorButton.js +1 -6
  11. package/dist/Editor/Elements/Carousel/CarouselItem.js +3 -11
  12. package/dist/Editor/Elements/Color Picker/ColorButtons.js +5 -7
  13. package/dist/Editor/Elements/Color Picker/Styles.js +3 -8
  14. package/dist/Editor/Elements/Color Picker/defaultColors.js +2 -2
  15. package/dist/Editor/Elements/Divider/Divider.js +20 -36
  16. package/dist/Editor/Elements/Embed/Image.js +16 -51
  17. package/dist/Editor/Elements/Embed/Video.js +3 -26
  18. package/dist/Editor/Elements/Form/Form.js +2 -38
  19. package/dist/Editor/Elements/Form/FormElements/FormCheckbox.js +1 -7
  20. package/dist/Editor/Elements/Form/FormElements/FormDate.js +1 -7
  21. package/dist/Editor/Elements/Form/FormElements/FormEmail.js +1 -7
  22. package/dist/Editor/Elements/Form/FormElements/FormNumbers.js +1 -7
  23. package/dist/Editor/Elements/Form/FormElements/FormRadioButton.js +1 -7
  24. package/dist/Editor/Elements/Form/FormElements/FormText.js +1 -7
  25. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -6
  26. package/dist/Editor/Elements/Form/FormPopup.js +9 -12
  27. package/dist/Editor/Elements/Form/Workflow/Styles.js +0 -2
  28. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
  29. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +2 -4
  30. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -20
  31. package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +4 -4
  32. package/dist/Editor/Elements/FreeGrid/styles.js +1 -1
  33. package/dist/Editor/Elements/Grid/GridButton.js +2 -2
  34. package/dist/Editor/Elements/Grid/GridItem.js +36 -47
  35. package/dist/Editor/Elements/Grid/Styles.js +0 -50
  36. package/dist/Editor/Elements/Link/LinkButton.js +1 -1
  37. package/dist/Editor/Elements/Search/SearchButton.js +0 -1
  38. package/dist/Editor/Elements/Signature/Signature.css +1 -1
  39. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -2
  40. package/dist/Editor/Elements/Signature/SignaturePopup.js +52 -17
  41. package/dist/Editor/Elements/SimpleText/style.js +0 -15
  42. package/dist/Editor/Elements/Table/Styles.js +78 -88
  43. package/dist/Editor/Elements/Table/Table.js +140 -263
  44. package/dist/Editor/Elements/Table/TableCell.js +111 -365
  45. package/dist/Editor/Elements/Table/TablePopup.js +3 -9
  46. package/dist/Editor/Elements/Table/TableRow.js +2 -10
  47. package/dist/Editor/Elements/TopBanner/TopBanner.js +1 -2
  48. package/dist/Editor/MiniEditor.js +2 -21
  49. package/dist/Editor/Styles/EditorStyles.js +4 -13
  50. package/dist/Editor/Toolbar/FormatTools/BlockButton.js +0 -10
  51. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +12 -7
  52. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -26
  53. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +0 -3
  54. package/dist/Editor/Toolbar/FormatTools/TextSize.js +5 -5
  55. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +8 -8
  56. package/dist/Editor/Toolbar/Mini/Styles.js +1 -9
  57. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/InfinityAITool.js +3 -7
  58. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -6
  59. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +15 -19
  60. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +58 -547
  61. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +16 -28
  62. package/dist/Editor/Toolbar/PopupTool/index.js +5 -3
  63. package/dist/Editor/Toolbar/Toolbar.js +0 -6
  64. package/dist/Editor/Toolbar/toolbarGroups.js +0 -4
  65. package/dist/Editor/assets/svg/BrainIcon.js +2 -2
  66. package/dist/Editor/assets/svg/SettingsIcon.js +4 -4
  67. package/dist/Editor/common/ColorPickerButton.js +45 -85
  68. package/dist/Editor/common/DnD/Draggable.js +1 -2
  69. package/dist/Editor/common/FontLoader/FontLoader.js +2 -2
  70. package/dist/Editor/common/Icon.js +21 -54
  71. package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -2
  72. package/dist/Editor/common/ImageSelector/Styles.js +6 -47
  73. package/dist/Editor/common/ImageSelector/UploadStyles.js +6 -18
  74. package/dist/Editor/common/LinkSettings/NavComponents.js +1 -2
  75. package/dist/Editor/common/LinkSettings/index.js +1 -2
  76. package/dist/Editor/common/MentionsPopup/Styles.js +8 -142
  77. package/dist/Editor/common/MentionsPopup/index.js +1 -1
  78. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +12 -107
  79. package/dist/Editor/common/RnD/GuideLines/styles.js +3 -3
  80. package/dist/Editor/common/RnD/ShadowElement.js +1 -1
  81. package/dist/Editor/common/RnD/VirtualElement/index.js +1 -5
  82. package/dist/Editor/common/RnD/index.js +3 -4
  83. package/dist/Editor/common/Section/index.js +3 -3
  84. package/dist/Editor/common/Section/styles.js +1 -5
  85. package/dist/Editor/common/Shorthands/elements.js +1 -13
  86. package/dist/Editor/common/StyleBuilder/fieldStyle.js +1 -2
  87. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +3 -4
  88. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +7 -35
  89. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +2 -15
  90. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +1 -2
  91. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +1 -1
  92. package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +0 -2
  93. package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +11 -11
  94. package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +6 -22
  95. package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +2 -21
  96. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +4 -20
  97. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +2 -12
  98. package/dist/Editor/common/StyleBuilder/formStyle.js +149 -268
  99. package/dist/Editor/common/StyleBuilder/index.js +20 -101
  100. package/dist/Editor/common/StyleBuilder/tableStyle.js +25 -69
  101. package/dist/Editor/common/SwipeableDrawer/style.js +4 -15
  102. package/dist/Editor/common/ToolbarIcon.js +1 -1
  103. package/dist/Editor/common/Uploader.js +37 -39
  104. package/dist/Editor/common/iconListV2.js +74 -598
  105. package/dist/Editor/common/iconslist.js +19 -25
  106. package/dist/Editor/commonStyle.js +15 -421
  107. package/dist/Editor/helper/deserialize/index.js +2 -31
  108. package/dist/Editor/helper/index.js +2 -15
  109. package/dist/Editor/helper/theme.js +1 -15
  110. package/dist/Editor/hooks/useBreakpoints.js +1 -1
  111. package/dist/Editor/plugins/withCustomDeleteBackward.js +3 -34
  112. package/dist/Editor/plugins/withEmbeds.js +26 -30
  113. package/dist/Editor/plugins/withHTML.js +12 -100
  114. package/dist/Editor/plugins/withLayout.js +0 -1
  115. package/dist/Editor/utils/SlateUtilityFunctions.js +11 -31
  116. package/dist/Editor/utils/brains.js +1 -1
  117. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +1 -26
  118. package/dist/Editor/utils/customHooks/useResize.js +4 -7
  119. package/dist/Editor/utils/customHooks/useTableResize.js +2 -6
  120. package/dist/Editor/utils/embed.js +1 -2
  121. package/dist/Editor/utils/events.js +1 -0
  122. package/dist/Editor/utils/font.js +4 -11
  123. package/dist/Editor/utils/formfield.js +4 -8
  124. package/dist/Editor/utils/helper.js +2 -100
  125. package/dist/Editor/utils/insertNewLine.js +1 -19
  126. package/dist/Editor/utils/serializeToText.js +0 -2
  127. package/dist/Editor/utils/table.js +24 -228
  128. package/package.json +2 -2
  129. package/dist/Editor/Elements/DataView/DataView.js +0 -124
  130. package/dist/Editor/Elements/DataView/DataViewButton.js +0 -23
  131. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +0 -83
  132. package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +0 -33
  133. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +0 -180
  134. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +0 -62
  135. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +0 -68
  136. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +0 -35
  137. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +0 -39
  138. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +0 -30
  139. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +0 -30
  140. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +0 -35
  141. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +0 -36
  142. package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +0 -17
  143. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +0 -29
  144. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +0 -38
  145. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +0 -86
  146. package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +0 -71
  147. package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +0 -138
  148. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +0 -213
  149. package/dist/Editor/Elements/DataView/Layouts/Formula.js +0 -29
  150. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +0 -113
  151. package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +0 -44
  152. package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +0 -146
  153. package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +0 -79
  154. package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +0 -57
  155. package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +0 -101
  156. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +0 -174
  157. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +0 -241
  158. package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +0 -45
  159. package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +0 -32
  160. package/dist/Editor/Elements/DataView/Layouts/Options/index.js +0 -110
  161. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +0 -217
  162. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +0 -131
  163. package/dist/Editor/Elements/DataView/Layouts/TableView.js +0 -253
  164. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +0 -85
  165. package/dist/Editor/Elements/DataView/Layouts/colStyles.js +0 -10
  166. package/dist/Editor/Elements/DataView/Layouts/index.js +0 -25
  167. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +0 -277
  168. package/dist/Editor/Elements/DataView/Utils/globalSearch.js +0 -15
  169. package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +0 -88
  170. package/dist/Editor/Elements/DataView/styles.js +0 -169
  171. package/dist/Editor/Elements/Table/AddRowCol.js +0 -77
  172. package/dist/Editor/Elements/Table/DragButton.js +0 -142
  173. package/dist/Editor/Elements/Table/DragStyles.js +0 -70
  174. package/dist/Editor/Elements/Table/Draggable.js +0 -25
  175. package/dist/Editor/Elements/Table/Droppable.js +0 -53
  176. package/dist/Editor/Elements/Table/TableTool.js +0 -101
  177. package/dist/Editor/Elements/Table/tableHelper.js +0 -71
  178. package/dist/Editor/assets/svg/ArrowDownIcon.js +0 -25
  179. package/dist/Editor/assets/svg/ArrowUpIcon.js +0 -25
  180. package/dist/Editor/assets/svg/CalenderIconTick.js +0 -64
  181. package/dist/Editor/assets/svg/ChervDown.js +0 -18
  182. package/dist/Editor/assets/svg/ChervUp.js +0 -18
  183. package/dist/Editor/assets/svg/DataTableIcon.js +0 -50
  184. package/dist/Editor/assets/svg/DuplicateIcon.js +0 -23
  185. package/dist/Editor/assets/svg/EyeIcon.js +0 -23
  186. package/dist/Editor/assets/svg/EyeSlash.js +0 -43
  187. package/dist/Editor/assets/svg/HashtagIcon.js +0 -33
  188. package/dist/Editor/assets/svg/PlusIcon.js +0 -23
  189. package/dist/Editor/assets/svg/SelectRoundedIcon.js +0 -24
  190. package/dist/Editor/assets/svg/SortByIcon.js +0 -33
  191. package/dist/Editor/assets/svg/TableIcons.js +0 -220
  192. package/dist/Editor/assets/svg/TickOutlined.js +0 -23
  193. package/dist/Editor/assets/svg/TrashCanIcon.js +0 -38
  194. package/dist/Editor/common/Select/index.js +0 -20
  195. package/dist/Editor/common/Select/styles.js +0 -17
  196. package/dist/Editor/helper/enforceDateFormat.js +0 -41
  197. package/dist/Editor/hooks/useTable.js +0 -210
  198. package/dist/Editor/utils/dataView.js +0 -43
@@ -1,5 +1,5 @@
1
1
  import { Transforms } from "slate";
2
- export const formField = data => {
2
+ export const formField = () => {
3
3
  return {
4
4
  type: "form-field",
5
5
  grid: 6,
@@ -12,18 +12,14 @@ export const formField = data => {
12
12
  text: ""
13
13
  }],
14
14
  field_type: "text",
15
- bgColor: data?.bgColor ? data?.bgColor : "rgba(255, 255, 255, 1)",
16
- borderColor: data?.borderColor ? data?.borderColor : "#ccc",
15
+ bgColor: "rgba(255, 255, 255, 1)",
16
+ borderColor: "#ccc",
17
17
  bannerSpacing: {
18
18
  left: 16,
19
19
  right: 16,
20
20
  top: 16,
21
21
  bottom: 16
22
- },
23
- fontFamily: data?.fontFamily ? data?.fontFamily : "",
24
- textSize: data?.textSize ? data?.textSize : "",
25
- textColor: data?.textColor ? data?.textColor : "",
26
- fontWeight: data?.fontWeight ? data?.fontWeight : "500"
22
+ }
27
23
  };
28
24
  };
29
25
  export const insertGridItem = editor => {
@@ -4,7 +4,6 @@ import insertNewLine from "./insertNewLine";
4
4
  import { getDevice } from "../helper/theme";
5
5
  export const windowVar = {};
6
6
  let ST_TIMEOUT = null;
7
- const BLOCKS = ["grid", "dataView"];
8
7
  export const formatDate = (date, format = "MM/DD/YYYY") => {
9
8
  if (!date) return "";
10
9
  var d = new Date(date),
@@ -164,7 +163,7 @@ export const handleInsertLastElement = (event, editor) => {
164
163
  if (isFreeGrid) {
165
164
  return;
166
165
  }
167
- const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => BLOCKS.includes(c.type));
166
+ const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => c.type === "grid");
168
167
  if (!ReactEditor.isFocused(editor)) {
169
168
  if (isLastElementEmpty) {
170
169
  if (hasPath) {
@@ -213,7 +212,7 @@ export const isListItem = editor => {
213
212
  });
214
213
  return node;
215
214
  };
216
- export const getNode = (editor, path) => {
215
+ const getNode = (editor, path) => {
217
216
  try {
218
217
  return Node.get(editor, path);
219
218
  } catch (err) {
@@ -265,17 +264,6 @@ export const decodeAndParseBase64 = encodedString => {
265
264
  const jsonData = JSON.parse(decodedURLString);
266
265
  return jsonData;
267
266
  };
268
- export const encodeToBase64 = data => {
269
- // Convert the data to a JSON string
270
- const jsonString = JSON.stringify(data);
271
-
272
- // URL-encode the JSON string
273
- const encodedURLString = encodeURIComponent(jsonString);
274
-
275
- // Base64-encode the URL-encoded string
276
- const base64EncodedString = btoa(encodedURLString);
277
- return base64EncodedString;
278
- };
279
267
  export const hasVerticalScrollbar = (element = {}) => {
280
268
  return element.scrollHeight > element.clientHeight;
281
269
  };
@@ -623,90 +611,4 @@ export const isPageSettings = (event, editor) => {
623
611
  isPageSettingsNode = true;
624
612
  return isPageSettingsNode;
625
613
  }
626
- };
627
- export const insertLineBreakAtEndOfPath = (editor, path) => {
628
- try {
629
- const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
630
- if (node) {
631
- // Insert the line break
632
- Transforms.insertNodes(editor, {
633
- type: "paragraph",
634
- children: [{
635
- text: ""
636
- }]
637
- }, {
638
- at: nodePath
639
- });
640
- }
641
- } catch (err) {
642
- console.log(err);
643
- }
644
- };
645
- const omitNodes = ["site-settings", "page-settings"];
646
- export function getInitialValue(value = [], readOnly) {
647
- if (readOnly === "readonly" && value?.length) {
648
- // remove last empty nodes on readonly mode, to remove empty spaces
649
-
650
- let lastNonEmptyElementIndex;
651
- for (let i = value?.length; i > 0; i--) {
652
- const elementIndex = i - 1;
653
- const node = value[elementIndex];
654
- if (lastNonEmptyElementIndex) {
655
- break;
656
- }
657
- if (node?.type === "paragraph") {
658
- // Ensure all children of the paragraph node are text nodes
659
- const hasOnlyTextChildren = node.children.every(child => Text.isText(child));
660
- const text = node.children[node.children.length - 1]?.text;
661
- lastNonEmptyElementIndex = hasOnlyTextChildren ? text ? elementIndex : null : elementIndex;
662
- } else if (omitNodes.includes(node?.type)) {
663
- continue;
664
- } else {
665
- lastNonEmptyElementIndex = elementIndex;
666
- }
667
- }
668
- const newValue = [...value].slice(0, lastNonEmptyElementIndex + 1);
669
- return newValue;
670
- }
671
- return value;
672
- }
673
- export function capitalizeFirstLetter(str) {
674
- if (!str) return str;
675
- return str.charAt(0).toUpperCase() + str.slice(1);
676
- }
677
- export function isHavingSelection(editor) {
678
- try {
679
- return editor?.selection && !Range.isCollapsed(editor.selection);
680
- } catch (err) {
681
- console.log(err);
682
- }
683
- }
684
- export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
685
- return `${defaultCls} ${selected ? selectedClsName : ""}`;
686
- }
687
- export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
688
- try {
689
- const options = {
690
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === nodeType,
691
- ...(otherOptions || {})
692
- };
693
- const [node, nodePath] = Editor.nodes(editor, options);
694
- return node ? [node, nodePath] : [];
695
- } catch (err) {
696
- console.log(err);
697
- return [];
698
- }
699
- };
700
- export const containsSurrogatePair = text => {
701
- // Match surrogate pairs (high and low surrogate)
702
- const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
703
- return surrogatePairRegex.test(text);
704
- };
705
- export const getSlateDom = (editor, range) => {
706
- try {
707
- const slateDom = ReactEditor.toDOMRange(editor, range);
708
- return slateDom;
709
- } catch (err) {
710
- console.log(err);
711
- }
712
614
  };
@@ -1,4 +1,4 @@
1
- import { Editor, Element, Path, Transforms } from "slate";
1
+ import { Transforms } from "slate";
2
2
  const insertNewLine = editor => {
3
3
  Transforms.insertNodes(editor, {
4
4
  type: "paragraph",
@@ -9,22 +9,4 @@ const insertNewLine = editor => {
9
9
  at: [editor.children.length]
10
10
  });
11
11
  };
12
- export const insertNewLineAfterCurrentPath = editor => {
13
- const currentPath = editor?.selection?.anchor?.path;
14
- const [tableNode] = Editor.nodes(editor, {
15
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
16
- });
17
- if (currentPath && tableNode) {
18
- const currentParentPath = Path.parent(currentPath);
19
- const nextPath = Path.next(currentParentPath);
20
- Transforms.insertNodes(editor, {
21
- type: "paragraph",
22
- children: [{
23
- text: ""
24
- }]
25
- }, {
26
- at: nextPath
27
- });
28
- }
29
- };
30
12
  export default insertNewLine;
@@ -2,8 +2,6 @@ export const serializeToText = node => {
2
2
  try {
3
3
  if (!node?.type && node?.text) {
4
4
  return node?.text;
5
- } else if (node?.type === 'mention') {
6
- return '@' + node?.character?.name || '';
7
5
  }
8
6
  let n = Array.isArray(node) ? node : node?.children;
9
7
  n = n && Array.isArray(n) ? n : n ? [n] : [];
@@ -1,6 +1,6 @@
1
1
  import { Transforms, Editor, Range, Element, Path, Node } from "slate";
2
2
  import { ReactEditor } from "slate-react";
3
- import { customInsertNode, getNode } from "./helper";
3
+ import { customInsertNode } from "./helper";
4
4
  export const DEFAULT_TABLE_NODE = () => ({
5
5
  type: "table",
6
6
  children: [{
@@ -13,10 +13,7 @@ export const DEFAULT_TABLE_NODE = () => ({
13
13
  text: ""
14
14
  }],
15
15
  cellBgColor: "#FFFFFF"
16
- }],
17
- size: {
18
- width: 120
19
- }
16
+ }]
20
17
  }, {
21
18
  type: "table-cell",
22
19
  children: [{
@@ -25,10 +22,7 @@ export const DEFAULT_TABLE_NODE = () => ({
25
22
  text: ""
26
23
  }],
27
24
  cellBgColor: "#FFFFFF"
28
- }],
29
- size: {
30
- width: 120
31
- }
25
+ }]
32
26
  }, {
33
27
  type: "table-cell",
34
28
  children: [{
@@ -37,10 +31,7 @@ export const DEFAULT_TABLE_NODE = () => ({
37
31
  text: ""
38
32
  }],
39
33
  cellBgColor: "#FFFFFF"
40
- }],
41
- size: {
42
- width: 120
43
- }
34
+ }]
44
35
  }]
45
36
  }, {
46
37
  type: "table-row",
@@ -52,10 +43,7 @@ export const DEFAULT_TABLE_NODE = () => ({
52
43
  text: ""
53
44
  }],
54
45
  cellBgColor: "#FFFFFF"
55
- }],
56
- size: {
57
- width: 120
58
- }
46
+ }]
59
47
  }, {
60
48
  type: "table-cell",
61
49
  children: [{
@@ -64,10 +52,7 @@ export const DEFAULT_TABLE_NODE = () => ({
64
52
  text: ""
65
53
  }],
66
54
  cellBgColor: "#FFFFFF"
67
- }],
68
- size: {
69
- width: 120
70
- }
55
+ }]
71
56
  }, {
72
57
  type: "table-cell",
73
58
  children: [{
@@ -78,7 +63,9 @@ export const DEFAULT_TABLE_NODE = () => ({
78
63
  cellBgColor: "#FFFFFF"
79
64
  }],
80
65
  size: {
81
- width: 120
66
+ widthInPercent: 100,
67
+ height: 100,
68
+ width: 365.3307291666667
82
69
  }
83
70
  }]
84
71
  }, {
@@ -91,10 +78,7 @@ export const DEFAULT_TABLE_NODE = () => ({
91
78
  text: ""
92
79
  }],
93
80
  cellBgColor: "#FFFFFF"
94
- }],
95
- size: {
96
- width: 120
97
- }
81
+ }]
98
82
  }, {
99
83
  type: "table-cell",
100
84
  children: [{
@@ -103,10 +87,7 @@ export const DEFAULT_TABLE_NODE = () => ({
103
87
  text: ""
104
88
  }],
105
89
  cellBgColor: "#FFFFFF"
106
- }],
107
- size: {
108
- width: 120
109
- }
90
+ }]
110
91
  }, {
111
92
  type: "table-cell",
112
93
  children: [{
@@ -117,14 +98,14 @@ export const DEFAULT_TABLE_NODE = () => ({
117
98
  cellBgColor: "#FFFFFF"
118
99
  }],
119
100
  size: {
120
- width: 120
101
+ height: 300,
102
+ widthInPercent: 100
121
103
  }
122
104
  }]
123
105
  }],
124
106
  rows: 3,
125
107
  columns: 3
126
108
  });
127
- const isFreeGridTable = n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "freegridItem" && n.childType === "table";
128
109
  const prefixKey = (obj, pk = "") => {
129
110
  return Object.keys(obj).reduce((a, b) => {
130
111
  a[`${pk}${b}`] = obj[b];
@@ -163,49 +144,12 @@ export class TableUtil {
163
144
  customInsertNode(this.editor, newTable);
164
145
  };
165
146
  removeTable = () => {
166
- const [freeGridItem] = Editor.nodes(this.editor, {
167
- match: isFreeGridTable
147
+ Transforms.removeNodes(this.editor, {
148
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
149
+ // mode:'highest'
168
150
  });
169
- if (freeGridItem) {
170
- Transforms.removeNodes(this.editor, {
171
- match: isFreeGridTable
172
- });
173
- } else {
174
- Transforms.removeNodes(this.editor, {
175
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
176
- });
177
- }
178
- };
179
- duplicateTable = () => {
180
- const {
181
- selection
182
- } = this.editor;
183
- if (!!selection && Range.isCollapsed(selection)) {
184
- const [freeGridItem] = Editor.nodes(this.editor, {
185
- match: isFreeGridTable
186
- });
187
- let clone;
188
- let path;
189
- if (freeGridItem) {
190
- const [freeGridNode, freeGridPath] = freeGridItem;
191
- clone = freeGridNode;
192
- path = freeGridPath;
193
- } else {
194
- const [[tableNode, tablePath]] = Editor.nodes(this.editor, {
195
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
196
- });
197
- clone = tableNode;
198
- path = tablePath;
199
- }
200
- const nextPath = Path.next(path);
201
- if (clone) {
202
- const clonedNode = JSON.parse(JSON.stringify(clone));
203
- Transforms.insertNodes(this.editor, clonedNode, {
204
- at: nextPath
205
- });
206
- }
207
- }
208
151
  };
152
+
209
153
  getDOMNode = path => {
210
154
  try {
211
155
  const [tableNode] = Editor.nodes(this.editor, {
@@ -242,12 +186,9 @@ export class TableUtil {
242
186
  const [[table, tablePath]] = Editor.nodes(this.editor, {
243
187
  match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
244
188
  });
245
- const [currentRowData, currentRow] = tableNode;
246
- const isDuplicate = action === "duplicate";
247
- const isInsertNext = action === "after" || isDuplicate;
248
- const path = isInsertNext ? Path.next(currentRow) : currentRow;
249
- const insertData = isDuplicate ? JSON.parse(JSON.stringify(currentRowData)) : createRowOnInsertAbove(currentRowData, currentRow, this.editor);
250
- Transforms.insertNodes(this.editor, insertData, {
189
+ const [, currentRow] = tableNode;
190
+ const path = action === "after" ? Path.next(currentRow) : currentRow;
191
+ Transforms.insertNodes(this.editor, createRow(Array(table.columns).fill("")), {
251
192
  at: path
252
193
  });
253
194
  Transforms.setNodes(this.editor, {
@@ -258,23 +199,6 @@ export class TableUtil {
258
199
  }
259
200
  }
260
201
  };
261
- clearRow = () => {
262
- const {
263
- selection
264
- } = this.editor;
265
- if (!!selection && Range.isCollapsed(selection)) {
266
- const [tableRow] = Editor.nodes(this.editor, {
267
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-row"
268
- });
269
- if (tableRow) {
270
- const [tableRowNode, tableRowPath] = tableRow;
271
- tableRowNode?.children?.forEach((cell, index) => {
272
- const currentCellPath = [...tableRowPath, index];
273
- clearCellText(this.editor, currentCellPath);
274
- });
275
- }
276
- }
277
- };
278
202
  deleteRow = () => {
279
203
  try {
280
204
  const {
@@ -335,58 +259,6 @@ export class TableUtil {
335
259
  }
336
260
  }
337
261
  };
338
- duplicateColumn = () => {
339
- const {
340
- selection
341
- } = this.editor;
342
- if (!!selection && Range.isCollapsed(selection)) {
343
- const [tableNode] = Editor.nodes(this.editor, {
344
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
345
- });
346
- if (tableNode) {
347
- const [[table, tablePath]] = Editor.nodes(this.editor, {
348
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
349
- });
350
- const [, currentCell] = tableNode;
351
- const currentCellPath = currentCell;
352
- const insertNextCellPath = Path.next(currentCell);
353
- for (let row = 0; row < table.rows; row++) {
354
- currentCellPath[currentCellPath.length - 2] = row;
355
- insertNextCellPath[insertNextCellPath?.length - 2] = row;
356
- const cellNode = getNode(this.editor, currentCellPath);
357
- Transforms.insertNodes(this.editor, JSON.parse(JSON.stringify(cellNode)), {
358
- at: insertNextCellPath
359
- });
360
- }
361
- Transforms.setNodes(this.editor, {
362
- columns: table.columns + 1
363
- }, {
364
- at: tablePath
365
- });
366
- }
367
- }
368
- };
369
- clearColumn = () => {
370
- const {
371
- selection
372
- } = this.editor;
373
- if (!!selection && Range.isCollapsed(selection)) {
374
- const [tableNode] = Editor.nodes(this.editor, {
375
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
376
- });
377
- if (tableNode) {
378
- const [[table]] = Editor.nodes(this.editor, {
379
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
380
- });
381
- const [, currentCell] = tableNode;
382
- const currentCellPath = currentCell;
383
- for (let row = 0; row < table.rows; row++) {
384
- currentCellPath[currentCellPath.length - 2] = row;
385
- clearCellText(this.editor, currentCellPath);
386
- }
387
- }
388
- }
389
- };
390
262
  deleteColumn = () => {
391
263
  try {
392
264
  const {
@@ -454,7 +326,6 @@ export class TableUtil {
454
326
  }, {
455
327
  at: currentCellPath
456
328
  });
457
- applyColumnStyle(this.editor, currentCellPath, currentTablePath, cellProps, tableProps?.rows);
458
329
 
459
330
  // cell bg entire
460
331
  if (cellProps?.entireBgColor || tableProps?.borderColor || rowProps?.borderColor) {
@@ -492,14 +363,6 @@ export class TableUtil {
492
363
  console.log(err);
493
364
  }
494
365
  };
495
- resizeTableCell = (styleProps, path) => {
496
- const cellProps = parseByPrefixKey(styleProps, "col.");
497
- Transforms.setNodes(this.editor, {
498
- ...cellProps
499
- }, {
500
- at: path
501
- });
502
- };
503
366
  getTableProps = () => {
504
367
  const {
505
368
  selection
@@ -622,14 +485,14 @@ export class TableUtil {
622
485
  }
623
486
  };
624
487
  }
625
- const createRow = (cellText, other) => {
626
- const newRow = Array.from(cellText, value => createTableCell(value, other));
488
+ const createRow = cellText => {
489
+ const newRow = Array.from(cellText, value => createTableCell(value));
627
490
  return {
628
491
  type: "table-row",
629
492
  children: newRow
630
493
  };
631
494
  };
632
- export const createTableCell = (text, other = {}) => {
495
+ export const createTableCell = text => {
633
496
  return {
634
497
  type: "table-cell",
635
498
  children: [{
@@ -637,35 +500,7 @@ export const createTableCell = (text, other = {}) => {
637
500
  children: [{
638
501
  text
639
502
  }]
640
- }],
641
- size: {
642
- width: 120
643
- },
644
- ...other
645
- };
646
- };
647
- const createRowOnInsertAbove = (currentRow, currRowPath, editor) => {
648
- const isFirstRow = currRowPath[currRowPath?.length - 1] === 0;
649
- const rowChild = currentRow?.children?.map((cell, i) => {
650
- let other = {};
651
-
652
- // remove the current row's size and add it on the currently inserting cell
653
- if (isFirstRow) {
654
- const cellPath = [...currRowPath, i];
655
- Transforms.setNodes(editor, {
656
- size: null
657
- }, {
658
- at: cellPath
659
- });
660
- other = {
661
- size: cell?.size
662
- };
663
- }
664
- return createTableCell("", other);
665
- });
666
- return {
667
- type: "table-row",
668
- children: rowChild
503
+ }]
669
504
  };
670
505
  };
671
506
 
@@ -714,43 +549,4 @@ const createTableNode = (cellText, rows, columns) => {
714
549
  columns
715
550
  };
716
551
  return tableNode;
717
- };
718
- const columnStyleKeys = ["entireBgColor", "entireBorderColor", "entireTextColor", "entireFontFamily", "entireFontWeight", "entireTextSize"];
719
- const applyColumnStyle = (editor, currentCellPath, currentTablePath, cellProps, rows) => {
720
- const colStyle = columnStyleKeys.reduce((acc, key) => {
721
- const style = cellProps[key];
722
- if (style) {
723
- acc[key] = style;
724
- }
725
- return acc;
726
- }, {});
727
- for (let r = 0; r < rows; r++) {
728
- const cellPosition = currentCellPath[currentCellPath?.length - 1]; // cell position on each row as per selected column cell
729
-
730
- Transforms.setNodes(editor, colStyle, {
731
- at: [...currentTablePath, r, cellPosition]
732
- });
733
- }
734
- };
735
- export const clearCellText = (editor, currentCellPath) => {
736
- try {
737
- const existingCellNode = getNode(editor, currentCellPath);
738
- Transforms.removeNodes(editor, {
739
- at: currentCellPath
740
- });
741
- Transforms.insertNodes(editor, {
742
- ...(existingCellNode || {}),
743
- children: [{
744
- type: "paragraph",
745
- children: [{
746
- text: ""
747
- }],
748
- cellBgColor: "#FFFFFF"
749
- }]
750
- }, {
751
- at: currentCellPath
752
- });
753
- } catch (err) {
754
- console.log(err);
755
- }
756
552
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "5.5.7",
3
+ "version": "5.5.9",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -68,7 +68,7 @@
68
68
  "storybook": "storybook dev -p 6006",
69
69
  "build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
70
70
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
71
- "publish:local": "rm -rf /Users/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist --copy-files"
71
+ "publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files"
72
72
  },
73
73
  "eslintConfig": {
74
74
  "extends": [