@flozy/editor 9.8.2 → 9.8.4

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.
@@ -32,9 +32,9 @@ const ChatEditor = /*#__PURE__*/forwardRef((props, ref) => {
32
32
  onBlur = () => {},
33
33
  isMobile = false,
34
34
  debounceTimeOut = 10,
35
- translation,
36
35
  isMarkDown = false,
37
- markDownContent = ""
36
+ markDownContent = "",
37
+ translation
38
38
  } = props;
39
39
  const classes = usePopupStyle(theme);
40
40
  const convertedContent = draftToSlate({
@@ -369,6 +369,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
369
369
  const onDrawerOpen = status => {
370
370
  setIsDrawerOpen(status);
371
371
  };
372
+ const lineH = getBreakpointLineSpacing(lineHeight, breakpoint || (isMobile ? "xs" : ""));
372
373
  const isReadOnly = readOnly === "readonly";
373
374
  const customProps = {
374
375
  ...(otherProps || {}),
@@ -381,9 +382,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
381
382
  onDrawerOpen: onDrawerOpen,
382
383
  ICON_API: "https://assets.agenciflow.com",
383
384
  translation: translationFn,
384
- getTitleSaveData
385
+ getTitleSaveData,
386
+ customLineHeight: lineH
385
387
  };
386
- const lineH = getBreakpointLineSpacing(lineHeight, breakpoint || (isMobile ? "xs" : ""));
387
388
  const renderElement = useCallback(props => {
388
389
  return /*#__PURE__*/_jsx(Element, {
389
390
  ...props,
@@ -88,7 +88,8 @@ const MultiSelectWithPopover = props => {
88
88
  const handleOpenPopover = useCallback(event => {
89
89
  setAnchorEl(event.currentTarget);
90
90
  }, []);
91
- const handleClosePopover = useCallback(() => {
91
+ const handleClosePopover = useCallback(e => {
92
+ e?.stopPropagation();
92
93
  setAnchorEl(null);
93
94
  }, []);
94
95
  const handleAddOption = newValue => {
@@ -180,7 +181,7 @@ const MultiSelectWithPopover = props => {
180
181
  open: open,
181
182
  anchorEl: anchorEl,
182
183
  anchor: "bottom",
183
- onClose: handleClosePopover,
184
+ onClose: e => handleClosePopover(e),
184
185
  anchorOrigin: {
185
186
  vertical: "top",
186
187
  horizontal: "left"
@@ -197,6 +198,9 @@ const MultiSelectWithPopover = props => {
197
198
  boxShadow: "0px 4px 10px 0px #00000029"
198
199
  }
199
200
  },
201
+ disableAutoFocus: true,
202
+ disableEnforceFocus: true,
203
+ disableRestoreFocus: true,
200
204
  children: /*#__PURE__*/_jsxs(Box, {
201
205
  sx: {
202
206
  width: isMobile ? "100%" : 300
@@ -77,8 +77,8 @@ const VideoPlaceholder = props => {
77
77
  readOnly,
78
78
  onSettings,
79
79
  classes,
80
- translation,
81
- type
80
+ type,
81
+ translation
82
82
  } = props;
83
83
  return !url ? !readOnly ? /*#__PURE__*/_jsxs(Box, {
84
84
  component: "button",
@@ -27,6 +27,9 @@ const CheckList = props => {
27
27
  checked
28
28
  } = element;
29
29
  const path = ReactEditor.findPath(editor, element);
30
+ const {
31
+ customLineHeight
32
+ } = customProps || {};
30
33
  const handleCheck = e => {
31
34
  Transforms.setNodes(editor, {
32
35
  checked: e.target.checked
@@ -45,7 +48,7 @@ const CheckList = props => {
45
48
  justifyContent: "center",
46
49
  alignItems: "center",
47
50
  ...(style || {}),
48
- lineHeight: 1.43
51
+ lineHeight: `${customLineHeight} !important`
49
52
  },
50
53
  children: [/*#__PURE__*/_jsxs("div", {
51
54
  contentEditable: false,
@@ -5,6 +5,7 @@ import { Box } from "@mui/material";
5
5
  import { isTextSelected } from "../../utils/helper";
6
6
  import { useEditorContext } from "../../hooks/useMouseMove";
7
7
  import SimpleTextStyle from "./style";
8
+ import { getBreakpointLineSpacing } from "../../helper/theme";
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
10
  import { Fragment as _Fragment } from "react/jsx-runtime";
10
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -27,10 +28,17 @@ const SimpleText = props => {
27
28
  editorPlaceholder,
28
29
  translation
29
30
  } = customProps;
31
+ const {
32
+ activeBreakPoint
33
+ } = useEditorContext();
30
34
  // const { element: pageSt } = getPageSettings(editor) || {};
31
35
  // const { pageColor } = pageSt?.pageProps || {};
36
+ const isMobile = window.matchMedia("(max-width: 899px)")?.matches || false;
37
+ const lineH = element?.children[0]?.lineHeight;
38
+ const lineHeight = getBreakpointLineSpacing(lineH, activeBreakPoint || (isMobile ? "xs" : "lg"));
32
39
  const classes = SimpleTextStyle({
33
- pageColor: "#FFFFFF"
40
+ pageColor: "#FFFFFF",
41
+ lineHeight
34
42
  });
35
43
  const selected = useSelected();
36
44
  const path = ReactEditor.findPath(editor, element);
@@ -100,8 +100,8 @@ const ToolBar = props => {
100
100
  handleAction,
101
101
  exandTools,
102
102
  openSetttings,
103
- hideTools,
104
- translation
103
+ translation,
104
+ hideTools
105
105
  } = props;
106
106
  const {
107
107
  getSelectedCells
@@ -88,6 +88,23 @@ export const reRenderChildNodes = (editor, path) => {
88
88
  console.log(err);
89
89
  }
90
90
  };
91
+ function getLeft(editor, moveToNode, moveTopath, appenBp) {
92
+ let topBoxNode = moveToNode;
93
+ let left = topBoxNode[`left${appenBp}`];
94
+ if (moveToNode?.type === "freegridBox") {
95
+ const [firstNode] = Array.from([...Editor.nodes(editor, {
96
+ at: moveTopath,
97
+ match: n => n.type === "freegridBox",
98
+ reverse: true
99
+ })]);
100
+ if (firstNode?.length && firstNode[1].toString() !== moveTopath?.toString()) {
101
+ const parentBoxNode = firstNode[0];
102
+ const parentLeft = parentBoxNode[`left${appenBp}`];
103
+ left += parentLeft;
104
+ }
105
+ }
106
+ return left;
107
+ }
91
108
  function isContainerElement(editor, moveTopath, props, appenBp) {
92
109
  try {
93
110
  const {
@@ -104,7 +121,7 @@ function isContainerElement(editor, moveTopath, props, appenBp) {
104
121
  parentNode = Node.get(editor, Path.parent(dragItemPath));
105
122
  }
106
123
  const moveToNode = Node.get(editor, moveTopath);
107
- const leftOfMoveToNode = moveToNode[`left${appenBp}`];
124
+ const leftOfMoveToNode = getLeft(editor, moveToNode, moveTopath, appenBp);
108
125
  if (moveToNode.type === "freegridBox") {
109
126
  if (parentNode.type === "freegridBox") {
110
127
  // same box
@@ -365,13 +365,11 @@ const elements = props => {
365
365
  const nodeType = canOpen(editor);
366
366
  const translatedElements = ELEMENTS_LIST.map(element => ({
367
367
  ...element,
368
- name: translation(element.name),
369
- renderComponent: element.renderComponent ? rest => {
370
- return element.renderComponent({
371
- ...rest,
372
- translation
373
- });
374
- } : undefined
368
+ name: translation ? translation(element.name) : element.name,
369
+ renderComponent: element.renderComponent ? rest => element.renderComponent({
370
+ ...rest,
371
+ translation
372
+ }) : undefined
375
373
  }));
376
374
  const filteredElements = translatedElements.filter(f => (hideTools || []).indexOf(f.type) === -1 && (!f?.hideFor || f?.hideFor?.indexOf(nodeType) === -1));
377
375
  return filteredElements.filter(c => c.name.toLowerCase().includes(search?.toLowerCase()));
@@ -53,9 +53,9 @@ const LineSpacing = props => {
53
53
  defaultValue: value || 1.43,
54
54
  "aria-label": "Default",
55
55
  valueLabelDisplay: "auto",
56
- min: 0.5,
57
- max: 3.0,
58
- step: 0.1,
56
+ min: 0.50,
57
+ max: 3.00,
58
+ step: 0.01,
59
59
  name: "lineHeight",
60
60
  onChange: handleChange
61
61
  }), /*#__PURE__*/_jsx(Box, {
@@ -65,15 +65,16 @@ const LineSpacing = props => {
65
65
  color: theme?.palette?.editor?.textColor
66
66
  },
67
67
  name: "lineHeight",
68
- value: pro_value,
68
+ value: pro_value || 1.43,
69
69
  className: "sliderInput",
70
70
  onChange: handleChange,
71
71
  type: "number",
72
72
  placeholder: "0",
73
- disabled: true,
74
- defaultValue: pro_value || 1.43
73
+ disabled: true
74
+ // defaultValue={pro_value || 1.43}
75
75
  })]
76
76
  })]
77
77
  });
78
78
  };
79
+
79
80
  export default LineSpacing;
@@ -395,6 +395,9 @@ export const getBlock = props => {
395
395
  children,
396
396
  customProps
397
397
  } = props;
398
+ const {
399
+ customLineHeight
400
+ } = customProps || {};
398
401
  const attributes = props.attributes ?? {};
399
402
  const isEmpty = isEmptyTextNode(element);
400
403
  const {
@@ -490,7 +493,7 @@ export const getBlock = props => {
490
493
  margin: `${element?.bgColor ? "16px" : "0px"} 0px`,
491
494
  width: element?.bgColor ? "calc(100% - 16px)" : "100%",
492
495
  borderWidth: element?.color ? "0px 0px 0px 3px" : "0px",
493
- lineHeight: 1.43
496
+ lineHeight: `${customLineHeight} !important`
494
497
  },
495
498
  children: children
496
499
  });
@@ -544,14 +547,15 @@ export const getBlock = props => {
544
547
  className: `content-editable ${isEmpty ? "empty" : ""}`,
545
548
  placeholder: translation("List"),
546
549
  style: {
547
- color: firstChildren?.color
550
+ color: firstChildren?.color,
551
+ lineHeight: `${customLineHeight} !important`
548
552
  },
549
553
  children: children
550
554
  });
551
555
  case "orderedList":
552
556
  return /*#__PURE__*/_jsx("ol", {
553
557
  style: {
554
- lineHeight: 1.43
558
+ lineHeight: `${customLineHeight} !important`
555
559
  },
556
560
  className: "listItemMargin",
557
561
  type: "1",
@@ -561,7 +565,7 @@ export const getBlock = props => {
561
565
  case "unorderedList":
562
566
  return /*#__PURE__*/_jsx("ul", {
563
567
  style: {
564
- lineHeight: 1.43
568
+ lineHeight: `${customLineHeight} !important`
565
569
  },
566
570
  className: "listItemMargin",
567
571
  ...attributes,
@@ -17,8 +17,7 @@ export const insertBrain = (editor, data, position) => {
17
17
  }]
18
18
  };
19
19
  const [currentNode, currentPath] = Editor.node(editor, selection);
20
- console.log('W1', Node.string(currentNode));
21
- const cleanedText = Node.string(currentNode).replace(/\/(?:b(?:rain|rai|ra|r)?)?/g, "").trim();
20
+ const cleanedText = Node.string(currentNode).toLowerCase().replace(/\/(?:b(?:rain|rai|ra|r)?)?/g, "").trim();
22
21
  if (cleanedText) {
23
22
  Transforms.delete(editor, {
24
23
  at: Editor.range(editor, currentPath)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "9.8.2",
3
+ "version": "9.8.4",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"