@flozy/editor 10.6.6 → 10.6.8

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.
@@ -1136,7 +1136,7 @@ blockquote {
1136
1136
  margin-left: -20px;
1137
1137
  }
1138
1138
 
1139
- li:has(.accordion-container) {
1139
+ .accordion-summary-container li:first-child {
1140
1140
  list-style: none;
1141
1141
  }
1142
1142
 
@@ -1,5 +1,5 @@
1
- import React, { useEffect, useState } from "react";
2
- import { Editor, Range, Transforms } from "slate";
1
+ import React, { useState } from "react";
2
+ import { Transforms } from "slate";
3
3
  import { useSelected, useSlateStatic, ReactEditor } from "slate-react";
4
4
  import AccordionBtnPopup from "./AccordionBtnPopup";
5
5
  import { IconButton, Tooltip, Box } from "@mui/material";
@@ -94,21 +94,30 @@ const Accordion = props => {
94
94
  theme
95
95
  } = useEditorContext();
96
96
  const classes = useCommonStyle(theme);
97
- useEffect(() => {
98
- if (!editor.selection) return;
99
- try {
100
- const detailsPath = [...path, 1];
101
- const detailsRange = Editor.range(editor, detailsPath);
102
- const isInside = Range.intersection(detailsRange, editor.selection);
103
- if (isInside && !toggle) {
104
- setToggle(!toggle);
105
- }
106
- } catch (e) {
107
- console.error(e);
108
- }
109
- }, [editor.selection, children]);
97
+
98
+ // useEffect(() => {
99
+ // if (!editor.selection || !children[1]) return;
100
+
101
+ // try {
102
+ // const accordionDetailsElement = element.children?.[1];
103
+
104
+ // const detailsPath = ReactEditor.findPath(editor, accordionDetailsElement);
105
+
106
+ // const detailsRange = Editor.range(editor, detailsPath);
107
+
108
+ // const isInside = Range.intersection(detailsRange, editor.selection);
109
+
110
+ // if (isInside && !toggle) {
111
+ // setToggle(true);
112
+ // }
113
+ // } catch (e) {
114
+ // console.error(e);
115
+ // }
116
+ // }, [editor.selection, children]);
117
+
110
118
  const onToggle = () => {
111
119
  setToggle(!toggle);
120
+ Transforms.deselect(editor);
112
121
  };
113
122
  const ToolBar = () => {
114
123
  return selected && !showTool ? /*#__PURE__*/_jsxs("div", {
@@ -205,7 +214,6 @@ const Accordion = props => {
205
214
  className: "accordion-title"
206
215
  // style={{ background: bgColor, ...borderStyle }}
207
216
  ,
208
- onClick: onToggle,
209
217
  children: [/*#__PURE__*/_jsx(Box, {
210
218
  role: "button",
211
219
  className: "accordion-summary-collapse-btn",
@@ -220,6 +228,7 @@ const Accordion = props => {
220
228
  },
221
229
  cursor: "pointer"
222
230
  },
231
+ onClick: onToggle,
223
232
  children: !toggle ? /*#__PURE__*/_jsx(Icon, {
224
233
  icon: "accordionArrow"
225
234
  }) : /*#__PURE__*/_jsx(Icon, {
@@ -4,8 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  const AccordionSummary = props => {
5
5
  const {
6
6
  attributes,
7
- children,
8
- element
7
+ children
9
8
  } = props;
10
9
  return /*#__PURE__*/_jsx(Box, {
11
10
  className: `accordion-summary-container`,
@@ -106,7 +106,7 @@ const EditorButton = props => {
106
106
  };
107
107
  const buttonProps = handleLinkType(refURl, linkType, true,
108
108
  // button functionalities have to work on both edit mode and normal mode
109
- openInNewTab, handleTrigger, metadata, !readOnly);
109
+ openInNewTab, handleTrigger, !readOnly, false, metadata);
110
110
  const onMenuClick = val => () => {
111
111
  switch (val) {
112
112
  case "edit":
@@ -293,7 +293,7 @@ const EditorButton = props => {
293
293
  "&:hover": {
294
294
  color: `${textColorHover || textColor || "#FFFFFF"}`,
295
295
  background: bgColorHover || bgColor || "rgb(30, 75, 122)",
296
- borderColor: borderColorHover || borderColor || "",
296
+ borderColor: borderColorHover || borderColor || "transparent",
297
297
  "& .element-toolbar": {
298
298
  display: "flex"
299
299
  }
@@ -134,15 +134,15 @@ const EditOption = props => {
134
134
  size: "small",
135
135
  onClick: onBack,
136
136
  children: /*#__PURE__*/_jsx(Icon, {
137
- icon: 'leftArrow'
137
+ icon: "leftArrow"
138
138
  })
139
139
  }) : null, translation("Edit Option")]
140
140
  }), /*#__PURE__*/_jsx(IconButton, {
141
141
  className: "tv-act-ico bg br1",
142
142
  size: "small",
143
143
  sx: {
144
- '& svg': {
145
- '& path': {
144
+ "& svg": {
145
+ "& path": {
146
146
  strokeWidth: 0
147
147
  }
148
148
  }
@@ -187,7 +187,7 @@ const EditOption = props => {
187
187
  onClick: onDeleteOption,
188
188
  children: [/*#__PURE__*/_jsx(ListItemIcon, {
189
189
  children: /*#__PURE__*/_jsx(Icon, {
190
- icon: 'trashIcon'
190
+ icon: "trashIcon"
191
191
  })
192
192
  }), /*#__PURE__*/_jsx(ListItemText, {
193
193
  children: translation("Delete Option")
@@ -35,13 +35,13 @@ const FormTextArea = props => {
35
35
  onChange: onChange,
36
36
  sx: {
37
37
  width: "100%",
38
+ borderWidth: "1px",
38
39
  borderBlockStyle: "solid",
39
40
  padding: {
40
41
  ...getTRBLBreakPoints(bannerSpacing)
41
42
  },
42
43
  height: height || "150px",
43
44
  borderColor: borderColor && `${borderColor} !important`,
44
- borderWidth: borderWidth || "1px",
45
45
  borderRadius: {
46
46
  ...getBreakPointsValue(borderRadius || {}, null, "overrideBorderRadius", true)
47
47
  },
@@ -3,7 +3,7 @@ const textOptions = ["edit", "settings", "link", "saveAsTemplate", "close"];
3
3
  const buttonOptions = ["settings", "link", "saveAsTemplate", "close"];
4
4
  const imageOptions = ["settings", "link", "imageFrame", "saveAsTemplate", "close"];
5
5
  const videoOptions = ["settings", "saveAsTemplate", "close"];
6
- const boxOptions = ["settings", "link", "saveAsTemplate", "close"];
6
+ const boxOptions = ["settings", "saveAsTemplate", "close"];
7
7
  const appHeaderOptions = ["settings", "saveAsTemplate", "close"];
8
8
  const tableOptions = ["drag", "edit", "settings", "saveAsTemplate", "close"];
9
9
  const embedScriptOptions = ["embedScript", "saveAsTemplate", "close"];
@@ -133,7 +133,11 @@ const editorStyles = ({
133
133
  },
134
134
  "& .accordion-summary-collapse-btn": {
135
135
  padding: "4px",
136
- width: "5px"
136
+ width: "5px",
137
+ "& svg:hover": {
138
+ background: theme?.palette?.editor?.tv_hover_bg,
139
+ borderRadius: "4px"
140
+ }
137
141
  },
138
142
  "& .workflow-icon-btn": {
139
143
  pointerEvents: "none",
@@ -292,7 +296,7 @@ const editorStyles = ({
292
296
  },
293
297
  "& ::selection": {
294
298
  // background: 'rgba(35, 131, 226, 0.35)!important',
295
- color: 'inherit'
299
+ color: "inherit"
296
300
  },
297
301
  "&.readOnlyContainer": {
298
302
  "& .max-content": {
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from "react";
2
- import { isBlockActive, toggleBlock } from "../../../utils/SlateUtilityFunctions";
2
+ import { isBlockActive, isListActive, toggleBlock } from "../../../utils/SlateUtilityFunctions";
3
3
  import CustomSelectTool from "./CustomSelectTool";
4
4
  import Icon from "../../../common/Icon";
5
5
  import { insertAccordion } from "../../../utils/accordion";
@@ -79,7 +79,9 @@ function SelectList({
79
79
  } = customProps;
80
80
  const listOptions = getListOptions(translation);
81
81
  const selectedList = useMemo(() => {
82
- return listOptions.find(t => isBlockActive(editor, t.value));
82
+ const listActive = isListActive(editor);
83
+ let selected = listOptions.find(t => listActive === t.value);
84
+ return selected;
83
85
  }, [listOptions, isBlockActive, editor]);
84
86
  const onChange = (format, option) => {
85
87
  if (option.type === "block") {
@@ -1498,6 +1498,26 @@ export function SectionDragIcon() {
1498
1498
  })]
1499
1499
  });
1500
1500
  }
1501
+ export function ResetIcon() {
1502
+ return /*#__PURE__*/_jsxs("svg", {
1503
+ width: "24",
1504
+ height: "24",
1505
+ viewBox: "0 0 24 24",
1506
+ fill: "none",
1507
+ xmlns: "http://www.w3.org/2000/svg",
1508
+ children: [/*#__PURE__*/_jsx("circle", {
1509
+ cx: "11.646",
1510
+ cy: "11.6452",
1511
+ r: "11.5",
1512
+ transform: "rotate(-89.2717 11.646 11.6452)",
1513
+ fill: "#2563EB",
1514
+ fillOpacity: "0.16"
1515
+ }), /*#__PURE__*/_jsx("path", {
1516
+ d: "M18.2814 11.8168V11.8168C18.2813 11.8313 18.2987 11.8387 18.3091 11.8287L19.2379 10.9273C19.6367 10.5404 20.247 10.5482 20.6358 10.9451C21.0245 11.342 21.0168 11.9495 20.6181 12.3364L17.9434 14.9012C17.5478 15.2806 16.9205 15.2708 16.5369 14.8792L13.9636 12.2519C13.7692 12.0534 13.674 11.7974 13.677 11.5622C13.6802 11.3075 13.7819 11.054 13.981 10.8801C14.3797 10.4932 14.9901 10.501 15.3788 10.8979L16.2708 11.8085C16.286 11.824 16.3124 11.8135 16.3126 11.7917V11.7917C16.351 8.77391 13.9017 6.27324 10.8698 6.2347C7.83784 6.19615 5.32577 8.63374 5.28741 11.6516C5.24904 14.6694 7.69833 17.1701 10.7303 17.2086C11.2815 17.2156 11.7092 17.6522 11.7022 18.2009C11.6952 18.7496 11.2566 19.1752 10.7054 19.1682C6.5709 19.1157 3.2663 15.7418 3.31861 11.6265C3.37093 7.51133 6.76023 4.22251 10.8947 4.27507C15.0095 4.32738 18.3338 7.70154 18.2814 11.8168Z",
1517
+ fill: "#2563EB"
1518
+ })]
1519
+ });
1520
+ }
1501
1521
  export function PenIcon() {
1502
1522
  return /*#__PURE__*/_jsxs("svg", {
1503
1523
  width: "17",
@@ -1523,26 +1543,6 @@ export function PenIcon() {
1523
1543
  })]
1524
1544
  });
1525
1545
  }
1526
- export function ResetIcon() {
1527
- return /*#__PURE__*/_jsxs("svg", {
1528
- width: "24",
1529
- height: "24",
1530
- viewBox: "0 0 24 24",
1531
- fill: "none",
1532
- xmlns: "http://www.w3.org/2000/svg",
1533
- children: [/*#__PURE__*/_jsx("circle", {
1534
- cx: "11.646",
1535
- cy: "11.6452",
1536
- r: "11.5",
1537
- transform: "rotate(-89.2717 11.646 11.6452)",
1538
- fill: "#2563EB",
1539
- fillOpacity: "0.16"
1540
- }), /*#__PURE__*/_jsx("path", {
1541
- d: "M18.2814 11.8168V11.8168C18.2813 11.8313 18.2987 11.8387 18.3091 11.8287L19.2379 10.9273C19.6367 10.5404 20.247 10.5482 20.6358 10.9451C21.0245 11.342 21.0168 11.9495 20.6181 12.3364L17.9434 14.9012C17.5478 15.2806 16.9205 15.2708 16.5369 14.8792L13.9636 12.2519C13.7692 12.0534 13.674 11.7974 13.677 11.5622C13.6802 11.3075 13.7819 11.054 13.981 10.8801C14.3797 10.4932 14.9901 10.501 15.3788 10.8979L16.2708 11.8085C16.286 11.824 16.3124 11.8135 16.3126 11.7917V11.7917C16.351 8.77391 13.9017 6.27324 10.8698 6.2347C7.83784 6.19615 5.32577 8.63374 5.28741 11.6516C5.24904 14.6694 7.69833 17.1701 10.7303 17.2086C11.2815 17.2156 11.7092 17.6522 11.7022 18.2009C11.6952 18.7496 11.2566 19.1752 10.7054 19.1682C6.5709 19.1157 3.2663 15.7418 3.31861 11.6265C3.37093 7.51133 6.76023 4.22251 10.8947 4.27507C15.0095 4.32738 18.3338 7.70154 18.2814 11.8168Z",
1542
- fill: "#2563EB"
1543
- })]
1544
- });
1545
- }
1546
1546
  export function SaveTemplIcon() {
1547
1547
  return /*#__PURE__*/_jsxs("svg", {
1548
1548
  width: "18",
@@ -1,4 +1,4 @@
1
- import { Editor, Transforms, Element as SlateElement, Range } from "slate";
1
+ import { Editor, Transforms, Element as SlateElement, Range, Path } from "slate";
2
2
  import { Box } from "@mui/material";
3
3
  import { sizeMap } from "./font";
4
4
  import Link from "../Elements/Link/Link";
@@ -50,7 +50,7 @@ import SearchAttachment from "../Elements/Search/SearchAttachment";
50
50
  import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
51
51
  import { jsx as _jsx } from "react/jsx-runtime";
52
52
  const alignment = ["alignLeft", "alignRight", "alignCenter", "alignJustify"];
53
- const list_types = ["orderedList", "unorderedList"];
53
+ const list_types = ["orderedList", "unorderedList", "accordion-details"];
54
54
  const LIST_FORMAT_TYPE = {
55
55
  orderedList: "list-item",
56
56
  unorderedList: "list-item"
@@ -66,8 +66,51 @@ const LIST_FORMAT_TYPE = {
66
66
  // ];
67
67
 
68
68
  const THEME_BLOCK_FIELDS = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
69
+ const convertAccordionToListItem = (editor, format) => {
70
+ const accordionLists = Array.from(Editor.nodes(editor, {
71
+ match: n => {
72
+ let accordionList = false;
73
+ if (n.type === "accordion") {
74
+ const [summary] = n.children;
75
+ accordionList = [format, "paragraph"].includes(summary.children?.[0]?.type);
76
+ }
77
+ return accordionList;
78
+ }
79
+ }));
80
+ accordionLists?.forEach(accordionList => {
81
+ const [node, path] = accordionList;
82
+ const [summary, details] = node.children;
83
+ const listItem = {
84
+ ...(summary.children[0] || {})
85
+ };
86
+ const isPara = listItem.type === "paragraph";
87
+ if (isPara) {
88
+ listItem.type = "list-item";
89
+ }
90
+
91
+ // Replace the accordion with the format
92
+ Transforms.removeNodes(editor, {
93
+ at: path
94
+ });
95
+ Transforms.insertNodes(editor, listItem, {
96
+ at: path
97
+ });
98
+ if (isPara) {
99
+ Transforms.wrapNodes(editor, {
100
+ type: format,
101
+ children: []
102
+ }, {
103
+ at: path
104
+ });
105
+ }
106
+ const nextPath = Path.next(path);
107
+ Transforms.insertNodes(editor, details.children, {
108
+ at: nextPath
109
+ });
110
+ });
111
+ };
69
112
  export const toggleBlock = (editor, format, selection = true, attr = {}) => {
70
- const isActive = isBlockActive(editor, format);
113
+ let isActive = isBlockActive(editor, format);
71
114
  const isList = list_types.includes(format);
72
115
  const isIndent = alignment.includes(format);
73
116
  const isAligned = alignment.some(alignmentType => isBlockActive(editor, alignmentType));
@@ -89,11 +132,26 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
89
132
  });
90
133
  return;
91
134
  }
92
- Transforms.unwrapNodes(editor, {
93
- match: n => list_types.includes(!Editor.isEditor(n) && SlateElement.isElement(n) && n.type),
94
- split: true
135
+ const [match] = Editor.nodes(editor, {
136
+ match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && list_types.includes(n.type),
137
+ mode: "lowest" // To ensure it's the closest parent
95
138
  });
96
139
 
140
+ if (match) {
141
+ const [matchNode, matchPath] = match;
142
+ if (matchNode.type !== "accordion-details") {
143
+ Transforms.unwrapNodes(editor, {
144
+ match: (n, n2) => {
145
+ const isList = !Editor.isEditor(n) && SlateElement.isElement(n) && list_types.includes(n.type);
146
+ return isList && n2.toString() === matchPath.toString();
147
+ },
148
+ split: true
149
+ });
150
+ } else {
151
+ isActive = false;
152
+ }
153
+ }
154
+
97
155
  // inserting blocks from "/"" commands remove searched word
98
156
  if (!selection) {
99
157
  Transforms.insertText(editor, "");
@@ -113,8 +171,9 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
113
171
  // if (NEWLINESAFTER.indexOf(format) > -1) {
114
172
  // insertNewLine(editor);
115
173
  // }
116
- };
117
174
 
175
+ convertAccordionToListItem(editor, format);
176
+ };
118
177
  export const addMarkData = (editor, data) => {
119
178
  try {
120
179
  Editor.addMark(editor, data.format, data.value);
@@ -202,6 +261,18 @@ export const isBlockActive = (editor, format) => {
202
261
  });
203
262
  return !!match;
204
263
  };
264
+ export const isListActive = editor => {
265
+ const list_types = ["orderedList", "unorderedList", "check-list-item", "accordion"];
266
+ const [match] = Editor.nodes(editor, {
267
+ match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && list_types.includes(n.type),
268
+ mode: "lowest" // To ensure it's the closest parent
269
+ });
270
+
271
+ if (match) {
272
+ const [matchNode] = match;
273
+ return matchNode.type;
274
+ }
275
+ };
205
276
  export const getBlockActive = (editor, format) => {
206
277
  const [match] = Editor.nodes(editor, {
207
278
  match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
@@ -62,18 +62,13 @@ export const insertAccordion = (editor, path) => {
62
62
  };
63
63
  }
64
64
  let accordion = getAccordionNode([currNode]);
65
- if (isListItem) {
66
- accordion = {
67
- type: "list-item",
68
- children: [accordion]
69
- };
70
- }
71
65
  Transforms.removeNodes(editor, {
72
66
  at: path
73
67
  });
74
68
  Transforms.insertNodes(editor, accordion, {
75
69
  at: path
76
70
  });
71
+ accordionPath = path;
77
72
  }
78
73
  const lastNode = selectedNodes[selectedNodes.length - 1];
79
74
  const lastNodePath = lastNode[1];
@@ -1,4 +1,4 @@
1
- import { Editor, Transforms, Element, Node, Path, Range, Point } from "slate";
1
+ import { Editor, Transforms, Element, Node, Path, Range } from "slate";
2
2
  import { toggleBlock } from "./SlateUtilityFunctions";
3
3
  import insertNewLine from "./insertNewLine";
4
4
  import { insertAccordion } from "./accordion";
@@ -339,8 +339,9 @@ const handleLinkBtnClick = (e, props, isMobilePreview, metadata) => {
339
339
  }
340
340
  }
341
341
  };
342
- export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}, metadata = {}, isEditMode, isCustomMobile // for drawer in App Header
343
- ) => {
342
+ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}, isEditMode, isCustomMobile,
343
+ // for drawer in App Header
344
+ metadata = {}) => {
344
345
  const props = {};
345
346
  if (!readOnly) {
346
347
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.6.6",
3
+ "version": "10.6.8",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"