@flozy/editor 9.2.0 → 9.2.1

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 (44) hide show
  1. package/dist/Editor/ChatEditor.js +2 -2
  2. package/dist/Editor/CommonEditor.js +11 -41
  3. package/dist/Editor/Editor.css +3 -17
  4. package/dist/Editor/Elements/Color Picker/ColorPicker.js +1 -0
  5. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +1 -4
  6. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +4 -3
  7. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +1 -6
  8. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +9 -19
  9. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +2 -32
  10. package/dist/Editor/Elements/DataView/Layouts/TableView.js +29 -126
  11. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +3 -3
  12. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +1 -1
  13. package/dist/Editor/Elements/DataView/styles.js +8 -8
  14. package/dist/Editor/Elements/Grid/GridItem.js +2 -1
  15. package/dist/Editor/Elements/Link/Link.js +43 -70
  16. package/dist/Editor/Elements/SimpleText/index.js +1 -0
  17. package/dist/Editor/Elements/Table/TableCell.js +2 -1
  18. package/dist/Editor/Elements/Variables/Style.js +2 -28
  19. package/dist/Editor/Elements/Variables/VariableButton.js +3 -7
  20. package/dist/Editor/Toolbar/FormatTools/TextSize.js +2 -0
  21. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +8 -9
  22. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +6 -3
  23. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +3 -6
  24. package/dist/Editor/Toolbar/PopupTool/index.js +16 -4
  25. package/dist/Editor/common/DnD/Draggable.js +1 -0
  26. package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -1
  27. package/dist/Editor/common/ImageSelector/UploadStyles.js +10 -9
  28. package/dist/Editor/common/MentionsPopup/Styles.js +3 -3
  29. package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
  30. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -15
  31. package/dist/Editor/common/RnD/Utils/gridDropItem.js +4 -5
  32. package/dist/Editor/common/RnD/VirtualElement/index.js +2 -1
  33. package/dist/Editor/commonStyle.js +4 -59
  34. package/dist/Editor/helper/index.js +14 -10
  35. package/dist/Editor/hooks/useDrag.js +11 -17
  36. package/dist/Editor/hooks/useEditorScroll.js +6 -10
  37. package/dist/Editor/hooks/useMouseMove.js +10 -16
  38. package/dist/Editor/hooks/useTable.js +1 -1
  39. package/dist/Editor/plugins/withHTML.js +3 -2
  40. package/dist/Editor/utils/helper.js +1 -13
  41. package/dist/Editor/utils/link.js +1 -1
  42. package/package.json +3 -6
  43. package/dist/Editor/common/CustomDialog/index.js +0 -90
  44. package/dist/Editor/common/CustomDialog/styles.js +0 -80
@@ -287,18 +287,22 @@ export const bringItemToFB = (editor, {
287
287
  };
288
288
  export const debounce = function (func, wait, immediate) {
289
289
  let timeout;
290
- return function () {
291
- const context = this,
292
- args = arguments,
293
- later = function () {
294
- timeout = null;
295
- if (!immediate) func.apply(context, args);
296
- },
297
- callNow = immediate && !timeout;
290
+ function debounced(...args) {
291
+ const context = this;
292
+ const later = function () {
293
+ timeout = null;
294
+ if (!immediate) func.apply(context, args);
295
+ };
296
+ const callNow = immediate && !timeout;
298
297
  clearTimeout(timeout);
299
298
  timeout = setTimeout(later, wait);
300
299
  if (callNow) func.apply(context, args);
300
+ }
301
+ debounced.cancel = function () {
302
+ clearTimeout(timeout);
303
+ timeout = null;
301
304
  };
305
+ return debounced;
302
306
  };
303
307
  export const getTextColor = (color = "") => {
304
308
  return color?.indexOf("gradient") >= 0 ? {
@@ -337,14 +341,14 @@ export const isCarouselSelected = editor => {
337
341
  return false;
338
342
  }
339
343
  const [nodeEntry] = Editor.nodes(editor, {
340
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === 'carousel'
344
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "carousel"
341
345
  });
342
346
  if (!nodeEntry) {
343
347
  return false;
344
348
  }
345
349
  const [node] = nodeEntry;
346
350
  const carouselDom = ReactEditor.toDOMNode(editor, node);
347
- const isEdit = carouselDom.classList.contains('carousel_slider_edit');
351
+ const isEdit = carouselDom.classList.contains("carousel_slider_edit");
348
352
  return !isEdit;
349
353
  } catch (err) {
350
354
  console.log(err);
@@ -1,26 +1,20 @@
1
- import { useEffect, useState } from "react";
1
+ import { useCallback, useEffect, useState } from "react";
2
2
  const useDrag = () => {
3
3
  const [event, setEvent] = useState("");
4
4
  useEffect(() => {
5
- addListener();
6
- return () => {
7
- removeListener();
5
+ const onMouseDown = () => {
6
+ setEvent("start");
7
+ };
8
+ const onMouseUp = () => {
9
+ setEvent("end");
8
10
  };
9
- }, []);
10
- const onMouseDown = () => {
11
- setEvent("start");
12
- };
13
- const onMouseUp = () => {
14
- setEvent("end");
15
- };
16
- const addListener = () => {
17
11
  document.addEventListener("pointerdown", onMouseDown);
18
12
  document.addEventListener("pointerup", onMouseUp);
19
- };
20
- const removeListener = () => {
21
- document.removeEventListener("pointerdown", onMouseDown);
22
- document.removeEventListener("pointerup", onMouseUp);
23
- };
13
+ return () => {
14
+ document.removeEventListener("pointerdown", onMouseDown);
15
+ document.removeEventListener("pointerup", onMouseUp);
16
+ };
17
+ }, []);
24
18
  return [event];
25
19
  };
26
20
  export default useDrag;
@@ -3,22 +3,18 @@ function useEditorScroll(editorWrapper = {
3
3
  current: null
4
4
  }, callback) {
5
5
  useEffect(() => {
6
+ if (!editorWrapper?.current) return;
6
7
  const handleScroll = () => {
7
- if (editorWrapper.current) {
8
- callback("scroll");
9
- }
8
+ console.log("Editor debug useEditorScroll ====>", editorWrapper, callback);
9
+ callback("scroll");
10
10
  };
11
11
  const currentEditorWrapper = editorWrapper.current;
12
- if (currentEditorWrapper) {
13
- currentEditorWrapper.addEventListener("scroll", handleScroll);
14
- }
12
+ currentEditorWrapper.addEventListener("scroll", handleScroll);
15
13
 
16
14
  // Cleanup the event listener on component unmount
17
15
  return () => {
18
- if (currentEditorWrapper) {
19
- currentEditorWrapper.removeEventListener("scroll", handleScroll);
20
- }
16
+ currentEditorWrapper.removeEventListener("scroll", handleScroll);
21
17
  };
22
- }, [editorWrapper.current, callback]);
18
+ }, [editorWrapper, callback]);
23
19
  }
24
20
  export default useEditorScroll;
@@ -1,4 +1,4 @@
1
- import { useEffect, useState, createContext, useContext, useMemo } from "react";
1
+ import { useEffect, useState, createContext, useContext, useMemo, useCallback } from "react";
2
2
  import { getSelectedText } from "../utils/helper";
3
3
  import { debounce } from "../helper";
4
4
  import { defaultFontFamilies } from "../common/FontLoader/FontList";
@@ -115,13 +115,7 @@ const useMouseMove = dragging => {
115
115
  const [event, setEvent] = useState({
116
116
  target: null
117
117
  });
118
- useEffect(() => {
119
- addListener();
120
- return () => {
121
- removeListener();
122
- };
123
- }, []);
124
- const onMouseMove = e => {
118
+ const onMouseMove = useCallback(debounce(e => {
125
119
  if (!dragging?.id) {
126
120
  const dpath = e?.target?.closest(".dpath");
127
121
  if (dpath) {
@@ -130,14 +124,14 @@ const useMouseMove = dragging => {
130
124
  });
131
125
  }
132
126
  }
133
- };
134
- const debounceMouseMove = debounce(onMouseMove, 100);
135
- const addListener = () => {
136
- document.addEventListener("mousemove", debounceMouseMove);
137
- };
138
- const removeListener = () => {
139
- document.removeEventListener("mousemove", debounceMouseMove);
140
- };
127
+ }, 100), [dragging]);
128
+ useEffect(() => {
129
+ document.addEventListener("mousemove", onMouseMove);
130
+ return () => {
131
+ document.removeEventListener("mousemove", onMouseMove);
132
+ onMouseMove.cancel(); // Cancel any pending debounced calls
133
+ };
134
+ }, [onMouseMove]);
141
135
  return [event];
142
136
  };
143
137
  export default useMouseMove;
@@ -184,7 +184,7 @@ export const TableProvider = ({
184
184
  window.removeEventListener("copy", handleCopy);
185
185
  window.removeEventListener("cut", handleCut);
186
186
  };
187
- }, [tableSelection, editor, tableSelection]);
187
+ }, [tableSelection, editor]);
188
188
 
189
189
  // useEffect(() => {
190
190
  // selectFirstCell(tablePath, editor, updateTableSelection);
@@ -9,7 +9,7 @@ const parseCopiedHTML = html => {
9
9
  const parsed = new DOMParser().parseFromString(html, "text/html");
10
10
 
11
11
  // if ol, ul are inside li, remove and push ol,ul after that li to maintain format between our slate list and external source list's json
12
- parsed.querySelectorAll("li > ul, li > ol, li > table").forEach(list => {
12
+ parsed.querySelectorAll("li > ul, li > ol").forEach(list => {
13
13
  // Find the parent li
14
14
  const parentLi = list.parentElement;
15
15
 
@@ -149,6 +149,7 @@ const getFocusedNode = (editor, nodeType = "") => {
149
149
  console.log(err);
150
150
  }
151
151
  };
152
+ const voidTypes = ["image", "page-settings"];
152
153
  const withHtml = editor => {
153
154
  const {
154
155
  insertData,
@@ -159,7 +160,7 @@ const withHtml = editor => {
159
160
  return element.type === "link" ? true : isInline(element);
160
161
  };
161
162
  editor.isVoid = element => {
162
- return element.type === "image" ? true : isVoid(element);
163
+ return voidTypes.includes(element.type) ? true : isVoid(element);
163
164
  };
164
165
  editor.insertData = data => {
165
166
  const slateHTML = data?.getData("application/x-slate-fragment");
@@ -764,16 +764,4 @@ export const hideSlateSelection = () => {
764
764
  };
765
765
  export function handleNegativeInteger(val) {
766
766
  return val < 0 ? 0 : val;
767
- }
768
- export const isEverythingSelected = editor => {
769
- const {
770
- selection
771
- } = editor;
772
- if (selection && Range.isExpanded(selection)) {
773
- if (Range.includes(selection, Editor.start(editor, [])) && Range.includes(selection, Editor.end(editor, []))) {
774
- return true;
775
- } else {
776
- return false;
777
- }
778
- }
779
- };
767
+ }
@@ -3,7 +3,7 @@ import { isBlockActive } from "./SlateUtilityFunctions";
3
3
  export const createLinkNode = (href, showInNewTab, text, linkType) => ({
4
4
  type: "link",
5
5
  href,
6
- target: showInNewTab === "_blank" ? "_blank" : "_self",
6
+ target: showInNewTab ? "_blank" : "_self",
7
7
  linkType,
8
8
  children: [{
9
9
  text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.2.0",
3
+ "version": "9.2.1",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -61,7 +61,7 @@
61
61
  "scripts": {
62
62
  "prepare": "husky install .husky",
63
63
  "analyze": "source-map-explorer build/static/js/*.js",
64
- "lint": "./node_modules/.bin/eslint --ignore-path .gitignore .",
64
+ "lint": "./node_modules/. bin/eslint --ignore-path .gitignore .",
65
65
  "start": "craco start",
66
66
  "build": "NODE_OPTIONS='--max_old_space_size=4096' craco build",
67
67
  "test": "craco test --passWithNoTests",
@@ -69,10 +69,7 @@
69
69
  "storybook": "storybook dev -p 6006",
70
70
  "build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
71
71
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
72
- "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",
73
- "publish:flozy": "./publish-flozy.sh",
74
- "publish:flozy2": "./publish-flozy2.sh",
75
- "publish:permission": "chmod +x publish-flozy.sh && chmod +x publish-flozy2.sh"
72
+ "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"
76
73
  },
77
74
  "eslintConfig": {
78
75
  "extends": [
@@ -1,90 +0,0 @@
1
- import { Button, Dialog, DialogActions, DialogContent, Grid, SwipeableDrawer, Typography, useMediaQuery } from "@mui/material";
2
- import PropTypes from "prop-types";
3
- import { useEditorContext } from "../../hooks/useMouseMove";
4
- import CustomDialogStyles from "./styles";
5
- import { forwardRef, useImperativeHandle, useState } from "react";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
- import { Fragment as _Fragment } from "react/jsx-runtime";
9
- const CustomDialog = (props, ref) => {
10
- const {
11
- content,
12
- confirmText,
13
- cancelText,
14
- onConfirm
15
- } = props;
16
- const [open, setOpen] = useState(false);
17
- const isMobile = useMediaQuery("(max-width:899px)");
18
- const {
19
- theme
20
- } = useEditorContext();
21
- const classes = CustomDialogStyles(theme);
22
- useImperativeHandle(ref, () => ({
23
- handleOpen: () => setOpen(true),
24
- handleClose: () => setOpen(false)
25
- }));
26
- const DialogueContent = () => /*#__PURE__*/_jsxs(_Fragment, {
27
- children: [/*#__PURE__*/_jsx(DialogContent, {
28
- children: /*#__PURE__*/_jsx(Typography, {
29
- children: content
30
- })
31
- }), /*#__PURE__*/_jsxs(DialogActions, {
32
- children: [/*#__PURE__*/_jsx(Button, {
33
- className: "closeBtn",
34
- onClick: () => setOpen(false),
35
- children: cancelText
36
- }), /*#__PURE__*/_jsx(Button, {
37
- className: "confirmBtn",
38
- onClick: () => {
39
- onConfirm();
40
- setOpen(false);
41
- },
42
- children: confirmText
43
- })]
44
- })]
45
- });
46
- return /*#__PURE__*/_jsx(_Fragment, {
47
- children: !isMobile ? /*#__PURE__*/_jsx(Dialog, {
48
- className: `${classes.MuiBackdropRoot}`,
49
- open: open,
50
- onClose: () => setOpen(false),
51
- fullWidth: true,
52
- maxWidth: "sm",
53
- sx: classes.CustomDialogu,
54
- children: /*#__PURE__*/_jsx(DialogueContent, {})
55
- }) : /*#__PURE__*/_jsxs(SwipeableDrawer, {
56
- open: open,
57
- anchor: "bottom",
58
- onClose: () => setOpen(false),
59
- style: {
60
- zIndex: "1300"
61
- },
62
- sx: classes.CustomDialogu,
63
- disableBackdropTransition: true,
64
- disableSwipeToOpen: true,
65
- children: [/*#__PURE__*/_jsx(Grid, {
66
- container: true,
67
- justifyContent: "center",
68
- className: "pullerRoot",
69
- children: /*#__PURE__*/_jsx(Grid, {
70
- item: true,
71
- className: "pullerGrid"
72
- })
73
- }), /*#__PURE__*/_jsx(DialogueContent, {})]
74
- })
75
- });
76
- };
77
- const CustomDialogComponent = /*#__PURE__*/forwardRef(CustomDialog);
78
- CustomDialogComponent.defaultProps = {
79
- content: "Are you sure you want to proceed?",
80
- confirmText: "Confirm",
81
- cancelText: "Cancel",
82
- onConfirm: () => console.warn("onConfirm not provided")
83
- };
84
- CustomDialogComponent.propTypes = {
85
- content: PropTypes.string,
86
- confirmText: PropTypes.string,
87
- cancelText: PropTypes.string,
88
- onConfirm: PropTypes.func
89
- };
90
- export { CustomDialogComponent };
@@ -1,80 +0,0 @@
1
- const CustomDialogStyles = theme => ({
2
- MuiBackdropRoot: {
3
- opacity: "1",
4
- transition: "opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"
5
- },
6
- CustomDialogu: {
7
- "& .MuiPaper-root": {
8
- borderRadius: "12px 12px 0px 0px",
9
- backgroundColor: `${theme?.palette?.greyshades?.light9} !important`,
10
- "@media only screen and (min-width: 899px)": {
11
- maxWidth: "400px",
12
- border: `1px solid ${theme?.palette?.editor?.customDialogueBorder}`,
13
- borderRadius: "12px"
14
- }
15
- },
16
- "& .MuiDialogContent-root": {
17
- padding: "20px 24px 8px 24px",
18
- "& .MuiTypography-root": {
19
- textAlign: "center",
20
- fontFamily: "Inter, sans-serif",
21
- fontSize: "14px",
22
- fontWeight: 500,
23
- color: theme?.palette?.editor?.textColor
24
- }
25
- },
26
- "& .confirmBtn": {
27
- backgroundColor: "#2563EB",
28
- padding: "8px 12px",
29
- color: "#ffffff",
30
- fontWeight: 600,
31
- fontSize: "14px",
32
- opacity: 1,
33
- borderRadius: "8px",
34
- textTransform: "math-auto",
35
- height: "36px",
36
- padding: "0px 12px",
37
- minWidth: "90px",
38
- "&:hover": {
39
- backgroundColor: "#2563EB"
40
- },
41
- "@media only screen and (max-width: 899px)": {
42
- width: "50%"
43
- }
44
- },
45
- "& .MuiDialogActions-root": {
46
- justifyContent: "center",
47
- paddingBottom: "20px"
48
- },
49
- "& .closeBtn": {
50
- padding: "8px 12px",
51
- color: theme?.palette?.editor?.customDialogueCloseBtnColor,
52
- fontWeight: 600,
53
- fontSize: "14px",
54
- opacity: 1,
55
- borderRadius: "8px",
56
- textTransform: "math-auto",
57
- height: "36px",
58
- padding: "0px 12px",
59
- minWidth: "90px",
60
- backgroundColor: theme?.palette?.editor?.closeButtonBackground,
61
- border: `1px solid ${theme?.palette?.editor?.customDialogueCloseBtnBorder}`,
62
- "&:hover": {
63
- backgroundColor: theme?.palette?.editor?.closeButtonBackground
64
- },
65
- "@media only screen and (max-width: 899px)": {
66
- width: "50%"
67
- }
68
- },
69
- "& .pullerRoot": {
70
- padding: "8px 0"
71
- },
72
- "& .pullerGrid": {
73
- width: "40px",
74
- height: "5px",
75
- backgroundColor: "#ccc",
76
- borderRadius: "10px"
77
- }
78
- }
79
- });
80
- export default CustomDialogStyles;