@flozy/editor 10.7.1 → 10.7.3

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.
@@ -1132,13 +1132,7 @@ blockquote {
1132
1132
  margin: 0px;
1133
1133
  }
1134
1134
 
1135
- .listItemMargin .accordion-container {
1136
- margin-left: -20px;
1137
- }
1138
1135
 
1139
- .accordion-summary-container li:first-child {
1140
- list-style: none;
1141
- }
1142
1136
 
1143
1137
  .content-editable.empty {
1144
1138
  position: relative;
@@ -18,6 +18,10 @@ const AttachmentsButton = props => {
18
18
  const {
19
19
  translation
20
20
  } = customProps;
21
+ const [uploadStatus, setUploadStatus] = useState({
22
+ isUploading: false,
23
+ uploadPercentage: 0
24
+ });
21
25
  const handleClick = () => {
22
26
  SetOpen(true);
23
27
  };
@@ -47,7 +51,8 @@ const AttachmentsButton = props => {
47
51
  onClose: handleClose,
48
52
  customProps: customProps,
49
53
  onSelectImage: onSelectImage,
50
- title: "Document"
54
+ title: "Document",
55
+ setUploadStatus: setUploadStatus
51
56
  })]
52
57
  });
53
58
  };
@@ -6,6 +6,7 @@ import { useEditorContext } from "../../../../../hooks/useMouseMove";
6
6
  import useCompStyles from "./styles";
7
7
  import { CloseIcon } from "../../../../../common/iconslist";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
10
  const AvatarIcon = props => {
10
11
  const {
11
12
  option,
@@ -41,7 +42,8 @@ export default function Select(props) {
41
42
  placeholder = "",
42
43
  disabled = false,
43
44
  optionAvatar = false,
44
- className = ""
45
+ className = "",
46
+ wrapColumn = false
45
47
  } = props;
46
48
  const value = Array.isArray(pValue) ? pValue : [];
47
49
  const options = selectOptions?.length ? selectOptions.filter(s => s.value) : [];
@@ -57,7 +59,8 @@ export default function Select(props) {
57
59
  newValue?.forEach(m => {
58
60
  if (multiple) {
59
61
  fv.push({
60
- value: m.inputValue || m.value
62
+ value: m.inputValue || m.value,
63
+ ...m
61
64
  });
62
65
  } else {
63
66
  fv[0] = {
@@ -100,51 +103,51 @@ export default function Select(props) {
100
103
  }
101
104
  // Regular option
102
105
  return option.value || "";
103
- },
104
- renderTags: (value, getTagProps) => {
105
- return /*#__PURE__*/_jsx(Box, {
106
- className: `tv-ms-tag-wrpr ${className}`,
107
- sx: {
108
- "& svg": {
109
- marginRight: "5px",
110
- "& path": {
111
- stroke: "#000"
112
- }
113
- }
114
- },
115
- children: value?.map((option, index) => {
116
- const {
117
- key,
118
- ...tagProps
119
- } = getTagProps({
120
- index
121
- }) || {};
122
- return option?.value ? /*#__PURE__*/_jsx(Chip, {
123
- variant: "outlined",
124
- label: option?.label || option?.value,
125
- ...tagProps,
126
- sx: {
127
- background: option?.color || appTheme?.palette?.editor?.tv_border1,
128
- border: "none",
129
- "& .MuiChip-label": {
130
- paddingLeft: "12px !important",
131
- paddingRight: disabled ? "12px !important" : ""
132
- }
133
- },
134
- avatar: /*#__PURE__*/_jsx(AvatarIcon, {
135
- option: option,
136
- avatar: optionAvatar
137
- }),
138
- deleteIcon: /*#__PURE__*/_jsx(CloseIcon, {
139
- style: {
140
- cursor: "pointer",
141
- display: disabled ? "none" : ""
142
- }
143
- })
144
- }, key) : null;
145
- })
146
- });
147
- },
106
+ }
107
+ // renderTags={(value, getTagProps) => {
108
+ // return (
109
+ // <Box
110
+ // className={`tv-ms-tag-wrpr ${className}`}
111
+ // sx={{
112
+ // "& svg": { marginRight: "5px", "& path": { stroke: "#000" } },
113
+ // flexWrap: wrapColumn ? "wrap" : "nowrap",
114
+ // overflowX: wrapColumn ? "hidden" : "auto",
115
+ // }}
116
+ // >
117
+ // {value?.map((option, index) => {
118
+ // const { key, ...tagProps } = getTagProps({ index }) || {};
119
+ // return option?.value ? (
120
+ // <Chip
121
+ // variant="outlined"
122
+ // label={option?.label || option?.value}
123
+ // key={key}
124
+ // {...tagProps}
125
+ // sx={{
126
+ // background:
127
+ // option?.color || appTheme?.palette?.editor?.tv_border1,
128
+ // border: "none",
129
+ // "& .MuiChip-label": {
130
+ // paddingLeft: "12px !important",
131
+ // paddingRight: disabled ? "12px !important" : "",
132
+ // },
133
+ // }}
134
+ // avatar={<AvatarIcon option={option} avatar={optionAvatar} />}
135
+ // deleteIcon={
136
+ // <CloseIcon
137
+ // style={{
138
+ // cursor: "pointer",
139
+ // display: disabled ? "none" : "",
140
+ // }}
141
+ // />
142
+ // }
143
+ // />
144
+ // ) : null;
145
+ // })}
146
+ // </Box>
147
+ // );
148
+ // }}
149
+ ,
150
+ renderTags: () => null,
148
151
  renderOption: (props, option) => {
149
152
  const {
150
153
  key,
@@ -168,13 +171,76 @@ export default function Select(props) {
168
171
  },
169
172
  freeSolo: true,
170
173
  size: "small",
171
- fullWidth: true,
174
+ fullWidth: true
175
+ // renderInput={(params) => {
176
+ // return (
177
+ // <TextField
178
+ // fullWidth
179
+ // size="small"
180
+ // {...params}
181
+ // placeholder={placeholder}
182
+ // />
183
+ // );
184
+ // }}
185
+ ,
172
186
  renderInput: params => {
173
- return /*#__PURE__*/_jsx(TextField, {
174
- fullWidth: true,
175
- size: "small",
176
- ...params,
177
- placeholder: placeholder
187
+ const {
188
+ InputProps,
189
+ ...rest
190
+ } = params;
191
+ return /*#__PURE__*/_jsxs(Box, {
192
+ className: `tv-ms-tag-wrpr ${className}`,
193
+ sx: {
194
+ display: "flex",
195
+ flexWrap: wrapColumn ? "wrap" : "nowrap",
196
+ alignItems: "center",
197
+ minHeight: "40px",
198
+ padding: "2px",
199
+ gap: "4px",
200
+ "& .MuiChip-root": {
201
+ margin: "2px"
202
+ }
203
+ },
204
+ children: [value?.map((option, index) => /*#__PURE__*/_jsx(Chip, {
205
+ variant: "outlined",
206
+ label: option?.label || option?.value,
207
+ sx: {
208
+ background: option?.color || appTheme?.palette?.editor?.tv_border1,
209
+ border: "none",
210
+ "& .MuiChip-label": {
211
+ paddingLeft: "12px !important",
212
+ paddingRight: disabled ? "12px !important" : ""
213
+ }
214
+ },
215
+ avatar: /*#__PURE__*/_jsx(AvatarIcon, {
216
+ option: option,
217
+ avatar: optionAvatar
218
+ }),
219
+ deleteIcon: /*#__PURE__*/_jsx(CloseIcon, {
220
+ style: {
221
+ cursor: "pointer",
222
+ display: disabled ? "none" : ""
223
+ }
224
+ }),
225
+ ...InputProps?.startAdornment?.[index]?.props
226
+ }, index)), /*#__PURE__*/_jsx(TextField, {
227
+ ...rest,
228
+ InputProps: {
229
+ ...InputProps,
230
+ disableUnderline: true,
231
+ sx: {
232
+ minWidth: 120,
233
+ flexGrow: 1,
234
+ input: {
235
+ padding: "4px 8px"
236
+ }
237
+ }
238
+ },
239
+ size: "small",
240
+ placeholder: placeholder,
241
+ disabled: disabled,
242
+ variant: "standard"
243
+ })]
178
244
  });
179
245
  },
180
246
  slotProps: {
@@ -7,8 +7,12 @@ const PersonType = props => {
7
7
  rowIndex,
8
8
  property,
9
9
  value,
10
- readOnly
10
+ readOnly,
11
+ settings
11
12
  } = props;
13
+ const {
14
+ wrapColumn
15
+ } = settings;
12
16
  const {
13
17
  onChange,
14
18
  users
@@ -22,9 +26,10 @@ const PersonType = props => {
22
26
  value: value || [],
23
27
  onChange: handleChange,
24
28
  options: users || [],
25
- multiple: false,
29
+ multiple: true,
26
30
  disabled: readOnly,
27
- optionAvatar: true
31
+ optionAvatar: true,
32
+ wrapColumn: wrapColumn
28
33
  });
29
34
  };
30
35
  export default PersonType;
@@ -7,7 +7,7 @@ import Icon from "../../../../common/Icon";
7
7
  import CloseIcon from "@mui/icons-material/Close";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
10
- const NEED_WRAPS = ["text", "multi-select"];
10
+ const NEED_WRAPS = ["text", "multi-select", "person"];
11
11
  const EditProperty = props => {
12
12
  const {
13
13
  classes,
@@ -101,7 +101,7 @@ const useTableStyles = (theme, appTheme) => ({
101
101
  position: "relative",
102
102
  "& .tv-ms-tag-wrpr": {
103
103
  display: "flex",
104
- flexWrap: "nowrap",
104
+ // flexWrap: "nowrap",
105
105
  overflow: "auto",
106
106
  minWidth: "58px",
107
107
  "& .MuiChip-deleteIcon": {
@@ -15,6 +15,10 @@ export const TopBannerToolbar = props => {
15
15
  editor
16
16
  } = props;
17
17
  const [open, setOpen] = useState(false);
18
+ const [uploadStatus, setUploadStatus] = useState({
19
+ isUploading: false,
20
+ uploadPercentage: 0
21
+ });
18
22
  const handleClick = type => () => {
19
23
  switch (type) {
20
24
  case "change":
@@ -56,7 +60,8 @@ export const TopBannerToolbar = props => {
56
60
  open: open,
57
61
  onClose: handleClose,
58
62
  customProps: customProps,
59
- onSelectImage: onSelectImage
63
+ onSelectImage: onSelectImage,
64
+ setUploadStatus: setUploadStatus
60
65
  })]
61
66
  });
62
67
  };
@@ -16,10 +16,14 @@ const TopBannerButton = props => {
16
16
  const {
17
17
  translation
18
18
  } = customProps;
19
+ const [uploadStatus, setUploadStatus] = useState({
20
+ isUploading: false,
21
+ uploadPercentage: 0
22
+ });
19
23
  const onSelectImage = url => {
20
24
  if (url) {
21
25
  insertTopBanner(editor, {
22
- url
26
+ url: url?.embedURL
23
27
  });
24
28
  }
25
29
  setOpen(false);
@@ -42,7 +46,9 @@ const TopBannerButton = props => {
42
46
  open: open,
43
47
  onClose: handleClose,
44
48
  customProps: customProps,
45
- onSelectImage: onSelectImage
49
+ onSelectImage: onSelectImage,
50
+ setUploadStatus: setUploadStatus,
51
+ disableProgress: true
46
52
  })]
47
53
  });
48
54
  };
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from "react";
2
- import { isBlockActive, isListActive, toggleBlock } from "../../../utils/SlateUtilityFunctions";
2
+ import { isBlockActive, toggleBlock } from "../../../utils/SlateUtilityFunctions";
3
3
  import CustomSelectTool from "./CustomSelectTool";
4
4
  import Icon from "../../../common/Icon";
5
5
  import { insertAccordion } from "../../../utils/accordion";
@@ -16,8 +16,8 @@ function Label({
16
16
  }), " ", label]
17
17
  });
18
18
  }
19
- function getListOptions(translation) {
20
- return [{
19
+ function getListOptions(translation, listType) {
20
+ const list = [{
21
21
  id: 15,
22
22
  value: "orderedList",
23
23
  type: "block",
@@ -53,7 +53,8 @@ function getListOptions(translation) {
53
53
  icon: "check-list-item"
54
54
  }),
55
55
  group: "list"
56
- }, {
56
+ }];
57
+ const accordion = [{
57
58
  id: 30,
58
59
  value: "accordion",
59
60
  type: "accordion",
@@ -67,21 +68,32 @@ function getListOptions(translation) {
67
68
  icon: "accordion"
68
69
  })
69
70
  }];
71
+ let options = [];
72
+ if (listType === "accordion-summary") {
73
+ options = [...accordion];
74
+ } else if (listType === "list-item") {
75
+ options = [...list];
76
+ } else {
77
+ options = [...list, ...accordion];
78
+ }
79
+ return options;
70
80
  }
71
81
  function SelectList({
72
82
  editor,
73
83
  classes,
74
84
  closeMainPopup,
75
- customProps
85
+ customProps,
86
+ commonProps
76
87
  }) {
77
88
  const {
78
89
  translation
79
90
  } = customProps;
80
- const listOptions = getListOptions(translation);
91
+ const {
92
+ listType
93
+ } = commonProps || {};
94
+ const listOptions = getListOptions(translation, listType);
81
95
  const selectedList = useMemo(() => {
82
- const listActive = isListActive(editor);
83
- let selected = listOptions.find(t => listActive === t.value);
84
- return selected;
96
+ return listOptions.find(t => isBlockActive(editor, t.value));
85
97
  }, [listOptions, isBlockActive, editor]);
86
98
  const onChange = (format, option) => {
87
99
  if (option.type === "block") {
@@ -3,7 +3,7 @@ import SelectTypography from "./SelectTypography";
3
3
  import SelectList from "./SelectList";
4
4
  import { toolbarGroups } from "../../toolbarGroups";
5
5
  import { MarkButton } from "../../FormatTools";
6
- import { activeMark, isBlockActive } from "../../../utils/SlateUtilityFunctions";
6
+ import { activeMark, getListType, isBlockActive } from "../../../utils/SlateUtilityFunctions";
7
7
  import LinkButton from "../../../Elements/Link/LinkButton";
8
8
  import TextToolIcon from "../../../assets/svg/TextToolIcon";
9
9
  import TextFormat from "../TextFormat";
@@ -36,6 +36,10 @@ const MiniTextFormat = props => {
36
36
  const id = open ? "popup-edit-tool" : "";
37
37
  const [size] = useWindowResize();
38
38
  const theme = useTheme();
39
+ const listType = getListType(editor);
40
+ const commonProps = {
41
+ listType
42
+ };
39
43
  const removeFontStyles = ["superscript", "subscript"];
40
44
  const fontStyle = allTools.filter(f => f.type === "mark" && !removeFontStyles.includes(f.format));
41
45
  const link = allTools.find(f => f.format?.indexOf("link") >= 0);
@@ -66,7 +70,8 @@ const MiniTextFormat = props => {
66
70
  classes: classes,
67
71
  editor: editor,
68
72
  closeMainPopup: closeMainPopup,
69
- customProps: customProps
73
+ customProps: customProps,
74
+ commonProps: commonProps
70
75
  }), /*#__PURE__*/_jsx("div", {
71
76
  className: "verticalLine mr-1"
72
77
  }), /*#__PURE__*/_jsx(SelectAlignment, {
@@ -141,7 +146,8 @@ const MiniTextFormat = props => {
141
146
  editor: editor,
142
147
  classes: classes,
143
148
  closeMainPopup: closeMainPopup,
144
- customProps: customProps
149
+ customProps: customProps,
150
+ commonProps: commonProps
145
151
  })]
146
152
  })
147
153
  })
@@ -31,7 +31,8 @@ const TextFormat = props => {
31
31
  editor,
32
32
  onClose,
33
33
  closeMainPopup,
34
- customProps
34
+ customProps,
35
+ commonProps
35
36
  } = props;
36
37
  const [anchorEl, setAnchorEl] = useState(null);
37
38
  const [type, setType] = useState(null);
@@ -39,6 +40,9 @@ const TextFormat = props => {
39
40
  const {
40
41
  translation
41
42
  } = customProps;
43
+ const {
44
+ listType
45
+ } = commonProps || {};
42
46
  const {
43
47
  element: pageSt
44
48
  } = getPageSettings(editor) || {};
@@ -52,7 +56,13 @@ const TextFormat = props => {
52
56
  const fontStyle = allTools.filter(f => f.type === "mark" && f.format !== "strikethrough" && f.format !== "superscript" && f.format !== "subscript");
53
57
  const fontAlign = allTools.filter(f => f.format?.indexOf("align") >= 0);
54
58
  const link = allTools.find(f => f.format?.indexOf("link") >= 0);
55
- const lists = allTools.filter(f => f.group?.indexOf("list") >= 0);
59
+ const lists = allTools.filter(f => {
60
+ let listTool = f.group?.indexOf("list") >= 0;
61
+ if (listTool) {
62
+ const hide = f.hideFor?.includes(listType);
63
+ return !hide;
64
+ }
65
+ });
56
66
  const {
57
67
  isActive: isBlockQuoteActive,
58
68
  props: bqProps
@@ -154,19 +154,22 @@ export const toolbarGroups = [[{
154
154
  format: "orderedList",
155
155
  type: "block",
156
156
  title: "Ordered List",
157
- group: "list"
157
+ group: "list",
158
+ hideFor: ["accordion-summary"]
158
159
  }, {
159
160
  id: 16,
160
161
  format: "unorderedList",
161
162
  type: "block",
162
163
  title: "Bulleted List",
163
- group: "list"
164
+ group: "list",
165
+ hideFor: ["accordion-summary"]
164
166
  }, {
165
167
  id: 43,
166
168
  format: "check-list-item",
167
169
  type: "block",
168
170
  title: "Check List",
169
- group: "list"
171
+ group: "list",
172
+ hideFor: ["accordion-summary"]
170
173
  }], [{
171
174
  id: 17,
172
175
  format: "alignLeft",
@@ -269,7 +272,8 @@ export const toolbarGroups = [[{
269
272
  format: "accordion",
270
273
  type: "accordion",
271
274
  group: "list",
272
- component: "AccordionButton"
275
+ component: "AccordionButton",
276
+ hideFor: ["list-item"]
273
277
  }, {
274
278
  id: 31,
275
279
  format: "signature",
@@ -41,7 +41,7 @@ const ImageSelector = props => {
41
41
  const [uniqueId, setUniqueId] = useState(null);
42
42
  const title = props.title || "Image";
43
43
  const translation = customProps?.translation;
44
- const [tabValue, setTabValue] = useState(title === "Image" ? "choose" : "Video" ? "upload" : "addLink");
44
+ const [tabValue, setTabValue] = useState(title === "Image" ? "choose" : "addLink");
45
45
  const [image, setImage] = useState(value || "");
46
46
  const [s3UploadProp, setS3UploadProp] = useState({
47
47
  file: null,
@@ -9,6 +9,7 @@ import usePopupStyle from "./Styles";
9
9
  import { useEditorContext } from "../../hooks/useMouseMove";
10
10
  import { checkTypings } from "../../hooks/useMentions";
11
11
  import canOpen from "../../helper/canOpen";
12
+ import { getListType } from "../../utils/SlateUtilityFunctions";
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
13
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
14
15
  const POPUP_LIST_TYPES = {
@@ -64,7 +65,14 @@ const MentionsPopup = /*#__PURE__*/forwardRef((props, ref) => {
64
65
  }, [editor?.selection]);
65
66
  useEffect(() => {
66
67
  try {
67
- const onNodeType = canOpen(editor);
68
+ let onNodeType = canOpen(editor);
69
+ if (onNodeType === "accordion") {
70
+ const isAccordion = getListType(editor) === "accordion-summary";
71
+ if (isAccordion) {
72
+ // if cursor at accordion-summary
73
+ onNodeType = "accordion-summary";
74
+ }
75
+ }
68
76
  if (target && chars.length > 0 && onNodeType !== false) {
69
77
  const domRange = ReactEditor.toDOMRange(editor, target);
70
78
  const rect = domRange?.getBoundingClientRect();
@@ -139,7 +139,8 @@ const ELEMENTS_LIST = [{
139
139
  icon: /*#__PURE__*/_jsx(Icon, {
140
140
  icon: "orderedList"
141
141
  }),
142
- onInsert: editor => toggleBlock(editor, "orderedList", false)
142
+ onInsert: editor => toggleBlock(editor, "orderedList", false),
143
+ hideFor: ["accordion-summary"]
143
144
  }, {
144
145
  name: "Bulleted List",
145
146
  desc: "",
@@ -148,7 +149,8 @@ const ELEMENTS_LIST = [{
148
149
  icon: /*#__PURE__*/_jsx(Icon, {
149
150
  icon: "unorderedList"
150
151
  }),
151
- onInsert: editor => toggleBlock(editor, "unorderedList", false)
152
+ onInsert: editor => toggleBlock(editor, "unorderedList", false),
153
+ hideFor: ["accordion-summary"]
152
154
  }, {
153
155
  name: "Check List",
154
156
  desc: "",
@@ -157,7 +159,8 @@ const ELEMENTS_LIST = [{
157
159
  icon: /*#__PURE__*/_jsx(Icon, {
158
160
  icon: "check-list-item"
159
161
  }),
160
- onInsert: editor => toggleBlock(editor, "check-list-item", false)
162
+ onInsert: editor => toggleBlock(editor, "check-list-item", false),
163
+ hideFor: ["accordion-summary"]
161
164
  }, {
162
165
  name: "Image",
163
166
  desc: "",
@@ -294,7 +297,8 @@ const ELEMENTS_LIST = [{
294
297
  onInsert: editor => {
295
298
  Transforms.delete(editor, editor.selection); // remove text '/accordion' typed by user
296
299
  insertAccordion(editor);
297
- }
300
+ },
301
+ hideFor: ["unorderedList", "orderedList", "check-list-item"]
298
302
  }, {
299
303
  name: "Button",
300
304
  group: "Elements",
@@ -28,6 +28,10 @@ const BackgroundImage = props => {
28
28
  } = useEditorContext();
29
29
  const classes = UploadStyles(theme);
30
30
  const disableProgress = title === "Page Settings" || elementProps?.type === "freegridBox" || elementProps?.type === "freegrid";
31
+ const [uploadStatus, setUploadStatus] = useState({
32
+ isUploading: false,
33
+ uploadPercentage: 0
34
+ });
31
35
  const onRemoveBG = () => {
32
36
  setBase64(null);
33
37
  onChange({
@@ -113,7 +117,8 @@ const BackgroundImage = props => {
113
117
  customProps: customProps,
114
118
  onSelectImage: onSelectImage,
115
119
  title: getTitle(),
116
- disableProgress: disableProgress
120
+ disableProgress: disableProgress,
121
+ setUploadStatus: setUploadStatus
117
122
  })]
118
123
  });
119
124
  };
@@ -29,7 +29,7 @@ const BannerSpacing = props => {
29
29
  const {
30
30
  bannerSpacing,
31
31
  lockbannerSpacing
32
- } = selectedTheme?.elementProps?.button || {};
32
+ } = selectedTheme?.elementProps[elementProps?.type] || {};
33
33
  const isUserValue = Object.keys(props?.value || {})?.length;
34
34
  const isUserLockedSpacing = typeof elementProps[lockKeyVal] === "boolean";
35
35
  const val = isUserValue ? props?.value : bannerSpacing;
@@ -29,7 +29,7 @@ const BorderRadius = props => {
29
29
  const {
30
30
  borderRadius,
31
31
  lockRadius: themeLockRadius
32
- } = selectedTheme?.elementProps?.button || {};
32
+ } = selectedTheme?.elementProps[elementProps?.type] || {};
33
33
  const isUserValue = Object.keys(props?.value || {})?.length;
34
34
  const isUserLockedRadius = typeof elementProps?.lockRadius === "boolean";
35
35
  const val = isUserValue ? props?.value : borderRadius;
@@ -1,4 +1,4 @@
1
- import { Editor, Transforms, Element as SlateElement, Range, Path } from "slate";
1
+ import { Editor, Transforms, Element as SlateElement, Range } 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", "accordion-details"];
53
+ export const list_types = ["orderedList", "unorderedList"];
54
54
  const LIST_FORMAT_TYPE = {
55
55
  orderedList: "list-item",
56
56
  unorderedList: "list-item"
@@ -66,49 +66,6 @@ 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
- };
112
69
  export const toggleBlock = (editor, format, selection = true, attr = {}) => {
113
70
  let isActive = isBlockActive(editor, format);
114
71
  const isList = list_types.includes(format);
@@ -132,26 +89,11 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
132
89
  });
133
90
  return;
134
91
  }
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
92
+ Transforms.unwrapNodes(editor, {
93
+ match: n => list_types.includes(!Editor.isEditor(n) && SlateElement.isElement(n) && n.type),
94
+ split: true
138
95
  });
139
96
 
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
-
155
97
  // inserting blocks from "/"" commands remove searched word
156
98
  if (!selection) {
157
99
  Transforms.insertText(editor, "");
@@ -171,9 +113,8 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
171
113
  // if (NEWLINESAFTER.indexOf(format) > -1) {
172
114
  // insertNewLine(editor);
173
115
  // }
174
-
175
- convertAccordionToListItem(editor, format);
176
116
  };
117
+
177
118
  export const addMarkData = (editor, data) => {
178
119
  try {
179
120
  Editor.addMark(editor, data.format, data.value);
@@ -273,6 +214,20 @@ export const isListActive = editor => {
273
214
  return matchNode.type;
274
215
  }
275
216
  };
217
+ export const getListType = editor => {
218
+ const [accordionSummary] = Editor.nodes(editor, {
219
+ match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === "accordion-summary"
220
+ });
221
+ if (accordionSummary) {
222
+ return "accordion-summary";
223
+ }
224
+ const [listItem] = Editor.nodes(editor, {
225
+ match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === "list-item"
226
+ });
227
+ if (listItem) {
228
+ return "list-item";
229
+ }
230
+ };
276
231
  export const getBlockActive = (editor, format) => {
277
232
  const [match] = Editor.nodes(editor, {
278
233
  match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
@@ -47,20 +47,20 @@ export const insertAccordion = (editor, path) => {
47
47
  accordionPath = path;
48
48
  } else if (selection) {
49
49
  const selectedNodes = Array.from(Editor.nodes(editor, {
50
- at: selection,
51
50
  match: n => Element.isElement(n),
52
51
  mode: "lowest" // use 'lowest' to get individual blocks
53
52
  }));
54
53
 
55
54
  for (const [node, path] of selectedNodes) {
56
55
  let currNode = node;
57
- const isListItem = node.type === "list-item";
58
- if (isListItem) {
59
- currNode = {
60
- type: "paragraph",
61
- children: node.children
62
- };
63
- }
56
+ // const isListItem = node.type === "list-item";
57
+ // if (isListItem) {
58
+ // currNode = {
59
+ // type: "paragraph",
60
+ // children: node.children,
61
+ // };
62
+ // }
63
+
64
64
  let accordion = getAccordionNode([currNode]);
65
65
  Transforms.removeNodes(editor, {
66
66
  at: path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.7.1",
3
+ "version": "10.7.3",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"