@flozy/editor 10.4.8 → 10.4.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.
@@ -71,9 +71,7 @@ const SelectV1 = props => {
71
71
  setResolvedSelectedOptions(resolved);
72
72
  }, [selectedOptions, availableOptionsMap]);
73
73
  useEffect(() => {
74
- // console.log("Options received:", options);
75
74
  const enrichedAvailable = hasIds(options) ? options : generateStableIds(options);
76
- // console.log("Enriched available options:", enrichedAvailable);
77
75
  setAvailableOptions(enrichedAvailable);
78
76
  const enrichedSelected = hasIds(value) ? value : value?.map(sel => {
79
77
  const match = enrichedAvailable.find(opt => opt?.value === sel?.value);
@@ -81,7 +79,6 @@ const SelectV1 = props => {
81
79
  id: match.id
82
80
  } : sel;
83
81
  });
84
- // console.log("Enriched selected options:", enrichedSelected);
85
82
  setSelectedOptions(enrichedSelected);
86
83
  }, []);
87
84
  const mode = useMemo(() => ({
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { useDataView } from "../../Providers/DataViewProvider";
3
- import MultiSelectWithPopover from "./Components/MultiSelect";
4
3
  import SelectV1 from "./Components/SelectV1";
5
4
  import { jsx as _jsx } from "react/jsx-runtime";
6
5
  const MultiSelectType = props => {
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { useDataView } from "../../Providers/DataViewProvider";
3
- // import Select from "./Components/Select";
4
3
  import SelectV1 from "./Components/SelectV1";
5
4
  import { jsx as _jsx } from "react/jsx-runtime";
6
5
  const SelectType = props => {
@@ -1,6 +1,7 @@
1
1
  import { Button } from "@mui/material";
2
2
  import { useMemo, useState } from "react";
3
3
  import useTable from "../../hooks/useTable";
4
+ import AddRoundedIcon from "@mui/icons-material/AddRounded";
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  const showAddButton = (addType, tableNode, hoverPath) => {
6
7
  const [row, col] = hoverPath && hoverPath?.length ? hoverPath.slice(-2) : [];
@@ -61,7 +62,7 @@ function AddRowCol(props) {
61
62
  fontSize: "14px",
62
63
  border: "1px dashed #8DA8E3",
63
64
  color: "#2563EB !important",
64
- padding: "0px 4px",
65
+ padding: "4px 4px",
65
66
  minWidth: "unset",
66
67
  lineHeight: "18px",
67
68
  fontWeight: "normal !important",
@@ -70,7 +71,12 @@ function AddRowCol(props) {
70
71
  },
71
72
  disabled: !showBtn,
72
73
  onClick: onAdd,
73
- children: "+"
74
+ children: /*#__PURE__*/_jsx(AddRoundedIcon, {
75
+ sx: {
76
+ width: 18,
77
+ height: 18
78
+ }
79
+ })
74
80
  })
75
81
  });
76
82
  }
@@ -991,11 +991,15 @@ const handleCopiedList = (el, domRange) => {
991
991
  el.insertAdjacentText("afterbegin", "- ");
992
992
  }
993
993
  };
994
+ const cleanCopiedDOM = container => {
995
+ container.querySelectorAll('[style*="display: none"], [contenteditable="false"]').forEach(el => el.remove());
996
+ return container;
997
+ };
994
998
  const getCopiedTextFormat = domRange => {
995
999
  const contents = domRange.cloneContents();
996
1000
  const div = document.createElement("div");
997
1001
  div.appendChild(contents);
998
-
1002
+ cleanCopiedDOM(div);
999
1003
  // Replace <br> with newlines
1000
1004
  div.querySelectorAll("br").forEach(br => br.replaceWith("\n"));
1001
1005
  const BLOCK_TAGS = ["DIV", "P", "LI", "H1", "H2", "H3", "H4", "H5", "H6"];
@@ -1023,6 +1027,7 @@ const getCopiedHTMLFormat = domRange => {
1023
1027
  const htmlContents = domRange.cloneContents();
1024
1028
  const container = document.createElement("div");
1025
1029
  container.appendChild(htmlContents);
1030
+ cleanCopiedDOM(container);
1026
1031
  const html = container.innerHTML;
1027
1032
  return html;
1028
1033
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "10.4.8",
3
+ "version": "10.4.9",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -1,482 +0,0 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from "react";
2
- import Autocomplete from "@mui/material/Autocomplete";
3
- import Box from "@mui/material/Box";
4
- import Chip from "@mui/material/Chip";
5
- import Divider from "@mui/material/Divider";
6
- import Popover from "@mui/material/Popover";
7
- import TextField from "@mui/material/TextField";
8
- import Typography from "@mui/material/Typography";
9
- import List from "@mui/material/List";
10
- import ListItem from "@mui/material/ListItem";
11
- import ListItemButton from "@mui/material/ListItemButton";
12
- import IconButton from "@mui/material/IconButton";
13
- import Tooltip from "@mui/material/Tooltip";
14
- import { CloseIcon } from "../../../../../common/iconslist";
15
- import { useEditorContext } from "../../../../../hooks/useMouseMove";
16
- import SwipeableDrawer from "@mui/material/SwipeableDrawer";
17
- import Icon from "../../../../../common/Icon";
18
- import { colors } from "../../../../Color Picker/defaultColors";
19
- import PropertySettings from "../../Options";
20
- import SnackbarAlert from "../../../../../common/SnackBar";
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
- import { jsxs as _jsxs } from "react/jsx-runtime";
23
- const EXCLUDED_COLORS = new Set(["#000000", "#0F172A", "#2563EB", "#FFFFFF", "#64748B"]);
24
- const DEFAULT_COLORS = colors?.filter(f => !f?.includes("linear") && !EXCLUDED_COLORS?.has(f));
25
- const generateRandomColor = () => {
26
- const randomIndex = Math.floor(Math.random() * DEFAULT_COLORS?.length);
27
- return DEFAULT_COLORS[randomIndex];
28
- };
29
- const hasIds = arr => Array.isArray(arr) && arr.every(item => 'id' in item);
30
- const generateStableIds = arr => arr.map((item, index) => ({
31
- ...item,
32
- id: `multi_${item.value}_${index}`
33
- }));
34
- const MultiSelectWithPopover = props => {
35
- const {
36
- options = [],
37
- value,
38
- onChange,
39
- onUpdate,
40
- property,
41
- wrapColumn = false,
42
- translation = () => {}
43
- } = props;
44
- const [anchorEl, setAnchorEl] = useState(null);
45
- const [anchorElOption, setAnchorElOption] = useState(null);
46
- const [currentIndex, setCurrentIndex] = useState(null);
47
- const [selectedOptions, setSelectedOptions] = useState([]);
48
- const [availableOptions, setAvailableOptions] = useState([]);
49
- const [showSnackBar, setShowSnackBar] = useState(false);
50
- const [chipColor, setChipColor] = useState(generateRandomColor());
51
- const [inputValue, setInputValue] = useState("");
52
- const {
53
- theme
54
- } = useEditorContext();
55
- const isMobile = window.matchMedia("(max-width: 899px)")?.matches || false;
56
- const PopoverComponent = isMobile ? SwipeableDrawer : Popover;
57
- useEffect(() => {
58
- console.log("Options received:", options);
59
- const enrichedAvailable = hasIds(options) ? options : generateStableIds(options);
60
- console.log("Enriched available options:", enrichedAvailable);
61
- setAvailableOptions(enrichedAvailable);
62
- const enrichedSelected = hasIds(value) ? value : value.map(sel => {
63
- const match = enrichedAvailable.find(opt => opt.value === sel.value);
64
- return match ? {
65
- ...sel,
66
- id: match.id
67
- } : sel;
68
- });
69
- console.log("Enriched selected options:", enrichedSelected);
70
- setSelectedOptions(enrichedSelected);
71
- }, []);
72
- const mode = useMemo(() => ({
73
- type: "editOptionMulti",
74
- edit: {
75
- label: "Multi Select",
76
- visible: true,
77
- key: property,
78
- type: "multi-select",
79
- options: availableOptions || [],
80
- optionIndex: currentIndex,
81
- hideBackButton: true
82
- }
83
- }), [availableOptions, property, currentIndex]);
84
- const customScrollStyles = {
85
- scrollbarWidth: "thin",
86
- scrollbarColor: `${theme?.palette?.editor?.brainPopupScroll} transparent`,
87
- "&::-webkit-scrollbar": {
88
- width: "6px"
89
- },
90
- "&::-webkit-scrollbar-thumb": {
91
- backgroundColor: theme?.palette?.editor?.brainPopupScroll,
92
- borderRadius: "3px"
93
- },
94
- "&::-webkit-scrollbar-track": {
95
- display: "none"
96
- }
97
- };
98
- useEffect(() => {
99
- if (inputValue?.trim() && !chipColor) {
100
- setChipColor(generateRandomColor());
101
- }
102
- }, [inputValue, chipColor]);
103
- useEffect(() => {
104
- if (inputValue?.trim() && !chipColor) {
105
- setChipColor(generateRandomColor());
106
- }
107
- }, [inputValue, chipColor]);
108
- useEffect(() => {
109
- const enriched = hasIds(options) ? options : generateStableIds(options);
110
- const isDifferent = JSON.stringify(enriched) !== JSON.stringify(availableOptions);
111
- if (isDifferent) {
112
- setAvailableOptions(enriched);
113
- }
114
- }, [options]);
115
- const handleOpenPopover = useCallback(event => {
116
- setAnchorEl(event.currentTarget);
117
- }, []);
118
- const handleClosePopover = useCallback(e => {
119
- e?.stopPropagation();
120
- setAnchorEl(null);
121
- }, []);
122
- const handleAddOption = newValue => {
123
- const trimmedValue = newValue?.trim();
124
- if (!trimmedValue) return;
125
- const newOption = {
126
- value: trimmedValue,
127
- color: chipColor
128
- };
129
- if (!availableOptions?.some(opt => opt?.value === trimmedValue)) {
130
- setAvailableOptions(prev => [...prev, newOption]);
131
- setSelectedOptions(prev => [...prev, newOption]);
132
- onUpdate([newOption, ...availableOptions]);
133
- onChange([...selectedOptions, newOption]);
134
- }
135
- setInputValue("");
136
- setChipColor("");
137
- };
138
- const onClose = () => {
139
- setAnchorEl(anchorElOption);
140
- setAnchorElOption(null);
141
- };
142
- const onEditOption = (type, data) => {
143
- const updateData = data?.edit ? data?.edit?.options : data?.options;
144
- onUpdate(updateData);
145
- if (data?.edit?.options) {
146
- const updatedSelectedOptions = selectedOptions?.filter(selOption => updateData?.some(availOption => availOption?.value === selOption?.value && availOption?.color === selOption?.color));
147
- setSelectedOptions(updatedSelectedOptions);
148
- onClose();
149
- }
150
- };
151
- const handleEditOption = (e, index) => {
152
- e.stopPropagation();
153
- setCurrentIndex(index);
154
- setAnchorElOption(anchorEl);
155
- setAnchorEl(null);
156
- };
157
- const handleSelectOption = option => {
158
- if (!selectedOptions?.some(opt => opt?.value === option?.value)) {
159
- const updatedOptions = [...selectedOptions, option];
160
- setSelectedOptions(updatedOptions);
161
- onChange(updatedOptions);
162
- } else {
163
- setShowSnackBar(true);
164
- }
165
- };
166
- const handleClearSelection = () => {
167
- setSelectedOptions([]);
168
- };
169
- const handleDeleteChip = (event, option) => {
170
- event.stopPropagation();
171
- setSelectedOptions(prev => {
172
- const updatedOptions = prev.filter(selected => selected?.value !== option?.value);
173
- onChange(updatedOptions);
174
- return updatedOptions;
175
- });
176
- };
177
- const filteredOptions = availableOptions?.filter(option => option?.value?.toLowerCase()?.includes(inputValue?.toLowerCase()));
178
- const isExactMatch = availableOptions?.some(opt => opt?.value?.toLowerCase() === inputValue?.toLowerCase());
179
- const open = Boolean(anchorEl);
180
- const openEditOption = Boolean(anchorElOption);
181
- const id = open ? "autocomplete-popover" : undefined;
182
- return /*#__PURE__*/_jsxs("div", {
183
- children: [/*#__PURE__*/_jsx(Box, {
184
- sx: {
185
- display: "flex",
186
- flexWrap: wrapColumn ? "wrap" : "nowrap",
187
- overflowX: wrapColumn ? "hidden" : "auto",
188
- gap: 0.5,
189
- padding: "8px",
190
- cursor: "pointer"
191
- },
192
- onClick: handleOpenPopover,
193
- children: selectedOptions?.map((option, index) => /*#__PURE__*/_jsx(Chip, {
194
- label: option?.value,
195
- onDelete: event => {
196
- handleDeleteChip(event, option);
197
- },
198
- deleteIcon: /*#__PURE__*/_jsx(CloseIcon, {}),
199
- variant: "filled",
200
- sx: {
201
- backgroundColor: option?.color,
202
- color: "#0F172A",
203
- "& .MuiChip-deleteIcon": {
204
- flexShrink: 0,
205
- "& path": {
206
- stroke: "#0F172A !important"
207
- }
208
- },
209
- "&:hover": {
210
- opacity: 0.8
211
- }
212
- }
213
- }, index))
214
- }), /*#__PURE__*/_jsx(PopoverComponent, {
215
- id: id,
216
- open: open,
217
- anchorEl: anchorEl,
218
- anchor: "bottom",
219
- onClose: e => handleClosePopover(e),
220
- anchorOrigin: {
221
- vertical: "top",
222
- horizontal: "left"
223
- },
224
- transformOrigin: {
225
- vertical: "top",
226
- horizontal: "left"
227
- },
228
- sx: {
229
- "& .MuiPaper-root": {
230
- borderRadius: "20px",
231
- background: theme?.palette?.editor?.textFormatBgColor,
232
- border: `1px solid ${theme?.palette?.editor?.popUpBorderColor}`,
233
- boxShadow: "0px 4px 10px 0px #00000029"
234
- }
235
- },
236
- disableAutoFocus: true,
237
- disableEnforceFocus: true,
238
- disableRestoreFocus: true,
239
- children: /*#__PURE__*/_jsxs(Box, {
240
- sx: {
241
- width: isMobile ? "100%" : 300
242
- },
243
- children: [/*#__PURE__*/_jsx(Autocomplete, {
244
- multiple: true,
245
- freeSolo: true,
246
- disablePortal: true,
247
- PopperComponent: () => null,
248
- sx: {
249
- "& .MuiFormControl-root": {
250
- maxHeight: "250px",
251
- overflowY: "auto",
252
- overflowX: "hidden",
253
- pr: "12px",
254
- pl: "12px",
255
- marginTop: "12px",
256
- ...customScrollStyles
257
- }
258
- },
259
- disableClearable: true,
260
- options: [],
261
- getOptionLabel: option => options?.value || "",
262
- value: selectedOptions,
263
- onChange: (event, newValues) => {
264
- const addedOptions = newValues?.filter(value => typeof value === "object" || typeof value === "string" && value?.trim() !== "")?.map(value => typeof value === "string" ? {
265
- value,
266
- color: chipColor
267
- } : value);
268
- const isDuplicate = addedOptions?.some(newOpt => (selectedOptions || [])?.some(opt => opt.value === newOpt.value));
269
- if (!isDuplicate) {
270
- setSelectedOptions([...selectedOptions, ...addedOptions]);
271
- }
272
- },
273
- inputValue: inputValue,
274
- onInputChange: (event, newInputValue) => setInputValue(newInputValue),
275
- onKeyDown: event => {
276
- if (event.key === "Enter" && inputValue.trim()) {
277
- event.preventDefault();
278
- handleAddOption(inputValue);
279
- }
280
- },
281
- filterOptions: (options, params) => options?.filter(option => option?.value?.toLowerCase()?.includes(params?.inputValue?.toLowerCase())),
282
- renderInput: params => /*#__PURE__*/_jsx(TextField, {
283
- ...params,
284
- variant: "standard",
285
- InputProps: {
286
- ...params.InputProps,
287
- disableUnderline: true,
288
- sx: {
289
- display: "flex",
290
- flexWrap: "wrap",
291
- fontFamily: "Inter",
292
- fontWeight: 400,
293
- fontSize: "12px",
294
- color: theme?.palette?.editor?.secondaryTextColor,
295
- "&::placeholder": {
296
- color: theme?.palette?.editor?.secondaryTextColor
297
- },
298
- "& .MuiAutocomplete-input": {
299
- minWidth: "100px !important"
300
- }
301
- },
302
- endAdornment: /*#__PURE__*/_jsx(Tooltip, {
303
- arrow: true,
304
- title: "Clear Selected",
305
- children: /*#__PURE__*/_jsx(IconButton, {
306
- onClick: handleClearSelection,
307
- sx: {
308
- padding: 0,
309
- minWidth: "unset",
310
- "& .MuiSvgIcon-root": {
311
- fontSize: 20
312
- },
313
- "& rect": {
314
- fill: theme?.palette?.editor?.closeButtonSvgStroke
315
- },
316
- "&:hover": {
317
- backgroundColor: "transparent"
318
- }
319
- },
320
- children: /*#__PURE__*/_jsx(Icon, {
321
- icon: "resetIconNew"
322
- })
323
- })
324
- })
325
- },
326
- sx: {
327
- backgroundColor: "transparent",
328
- fontFamily: "Inter",
329
- fontWeight: 400,
330
- fontSize: "12px"
331
- },
332
- placeholder: "Create new one..."
333
- }),
334
- renderTags: (tagValues, getTagProps) => tagValues.map((option, index) => /*#__PURE__*/_jsx(Chip, {
335
- variant: "filled",
336
- label: option?.value,
337
- ...getTagProps({
338
- index
339
- }),
340
- onDelete: event => {
341
- handleDeleteChip(event, option);
342
- },
343
- deleteIcon: /*#__PURE__*/_jsx(CloseIcon, {}),
344
- sx: {
345
- backgroundColor: option?.color,
346
- color: "#0F172A",
347
- "& .MuiChip-deleteIcon": {
348
- flexShrink: 0,
349
- "& path": {
350
- stroke: "#0F172A !important"
351
- }
352
- },
353
- "&:hover": {
354
- opacity: 0.8
355
- }
356
- }
357
- }, index))
358
- }), /*#__PURE__*/_jsx(Divider, {
359
- sx: {
360
- mt: "12px",
361
- borderBottom: `1px solid ${theme?.palette?.editor?.popUpBorderColor}`,
362
- boxShadow: theme?.palette?.editor?.dividerDropShadow
363
- }
364
- }), /*#__PURE__*/_jsx(Box, {
365
- sx: {
366
- pl: "4px"
367
- },
368
- children: /*#__PURE__*/_jsxs(List, {
369
- sx: {
370
- maxHeight: "250px",
371
- overflowY: "auto",
372
- ...customScrollStyles
373
- },
374
- children: [/*#__PURE__*/_jsx(Typography, {
375
- sx: {
376
- mb: 1,
377
- pl: "8px",
378
- color: theme?.palette?.editor?.secondaryTextColor,
379
- fontFamily: "Inter",
380
- fontWeight: 400,
381
- fontSize: "12px"
382
- },
383
- children: "Choose an option or create one"
384
- }), filteredOptions?.map((option, index) => /*#__PURE__*/_jsx(ListItem, {
385
- sx: {
386
- padding: 0
387
- },
388
- disablePadding: true,
389
- children: /*#__PURE__*/_jsxs(ListItemButton, {
390
- onClick: () => handleSelectOption(option),
391
- sx: {
392
- paddingTop: "4px",
393
- paddingBottom: "4px",
394
- justifyContent: "space-between",
395
- "&:hover": {
396
- "& path": {
397
- stroke: theme?.palette?.editor?.activeColor
398
- },
399
- borderRadius: "12px"
400
- }
401
- },
402
- children: [/*#__PURE__*/_jsx(Chip, {
403
- label: option?.value,
404
- sx: {
405
- backgroundColor: option?.color,
406
- color: "#0F172A",
407
- fontWeight: 500,
408
- fontSize: "12px",
409
- fontFamily: "Inter",
410
- padding: "4px 12px",
411
- borderRadius: "16px",
412
- maxWidth: "180px",
413
- whiteSpace: "nowrap",
414
- overflow: "hidden",
415
- textOverflow: "ellipsis"
416
- }
417
- }), /*#__PURE__*/_jsx(IconButton, {
418
- size: "small",
419
- sx: {
420
- "& path": {
421
- stroke: theme?.palette?.editor?.closeButtonSvgStroke
422
- },
423
- "&:hover": {
424
- backgroundColor: "transparent"
425
- }
426
- },
427
- onClick: e => handleEditOption(e, index),
428
- children: /*#__PURE__*/_jsx(Icon, {
429
- icon: "rightArrow"
430
- })
431
- })]
432
- })
433
- }, index)), inputValue?.trim() && !isExactMatch && /*#__PURE__*/_jsx(ListItem, {
434
- disablePadding: true,
435
- children: /*#__PURE__*/_jsxs(ListItemButton, {
436
- onClick: () => handleAddOption(inputValue),
437
- sx: {
438
- display: "flex",
439
- alignItems: "center"
440
- },
441
- children: [/*#__PURE__*/_jsx(Typography, {
442
- sx: {
443
- color: theme?.palette?.editor?.secondaryTextColor,
444
- marginRight: "6px",
445
- fontSize: "14px",
446
- fontFamily: "Inter"
447
- },
448
- children: "Create"
449
- }), /*#__PURE__*/_jsx(Chip, {
450
- label: `${inputValue}`,
451
- sx: {
452
- backgroundColor: chipColor,
453
- color: "#0F172A",
454
- fontWeight: 500,
455
- fontSize: "12px",
456
- fontFamily: "Inter",
457
- borderRadius: "16px",
458
- maxWidth: "180px",
459
- whiteSpace: "nowrap",
460
- overflow: "hidden",
461
- textOverflow: "ellipsis"
462
- }
463
- })]
464
- })
465
- })]
466
- })
467
- })]
468
- })
469
- }), openEditOption ? /*#__PURE__*/_jsx(PropertySettings, {
470
- open: openEditOption,
471
- anchorEl: anchorElOption,
472
- mode: mode,
473
- onClose: onClose,
474
- onEvent: onEditOption,
475
- translation: translation
476
- }) : null, showSnackBar ? /*#__PURE__*/_jsx(SnackbarAlert, {
477
- message: "Option already selected!",
478
- setShowSnackBar: setShowSnackBar
479
- }) : null]
480
- });
481
- };
482
- export default MultiSelectWithPopover;