@flozy/editor 11.0.8 → 11.1.0

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 (58) hide show
  1. package/dist/Editor/ChatEditor.js +10 -11
  2. package/dist/Editor/CommonEditor.js +14 -66
  3. package/dist/Editor/Editor.css +9 -4
  4. package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
  5. package/dist/Editor/Elements/AI/Styles.js +0 -1
  6. package/dist/Editor/Elements/Accordion/Accordion.js +22 -28
  7. package/dist/Editor/Elements/Accordion/AccordionButton.js +3 -12
  8. package/dist/Editor/Elements/Button/EditorButton.js +0 -1
  9. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +454 -0
  10. package/dist/Editor/Elements/Embed/Embed.js +2 -1
  11. package/dist/Editor/Elements/Embed/Image.js +14 -7
  12. package/dist/Editor/Elements/Embed/Video.js +40 -25
  13. package/dist/Editor/Elements/Form/Form.js +10 -35
  14. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +4 -2
  15. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +3 -3
  16. package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
  17. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -3
  18. package/dist/Editor/Elements/Signature/SignaturePopup.js +6 -24
  19. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  20. package/dist/Editor/Elements/Table/Table.js +3 -3
  21. package/dist/Editor/Elements/Title/title.js +6 -6
  22. package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
  23. package/dist/Editor/MiniEditor.js +1 -2
  24. package/dist/Editor/Styles/EditorStyles.js +1 -5
  25. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -2
  26. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +7 -25
  27. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -10
  28. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +3 -5
  29. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +2 -7
  30. package/dist/Editor/Toolbar/PopupTool/index.js +0 -1
  31. package/dist/Editor/Toolbar/toolbarGroups.js +4 -8
  32. package/dist/Editor/common/ColorPickerButton.js +0 -3
  33. package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
  34. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -6
  35. package/dist/Editor/common/MentionsPopup/index.js +1 -9
  36. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +0 -1
  37. package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -7
  38. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
  39. package/dist/Editor/common/RnD/VirtualElement/helper.js +62 -72
  40. package/dist/Editor/common/Shorthands/elements.js +4 -8
  41. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  42. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
  43. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +3 -3
  44. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  45. package/dist/Editor/common/Uploader.js +6 -13
  46. package/dist/Editor/commonStyle.js +15 -30
  47. package/dist/Editor/helper/index.js +1 -6
  48. package/dist/Editor/hooks/useMouseMove.js +4 -1
  49. package/dist/Editor/plugins/withEmbeds.js +0 -11
  50. package/dist/Editor/plugins/withHTML.js +0 -2
  51. package/dist/Editor/utils/SlateUtilityFunctions.js +3 -30
  52. package/dist/Editor/utils/accordion.js +39 -67
  53. package/dist/Editor/utils/draftToSlate.js +2 -3
  54. package/dist/Editor/utils/events.js +89 -94
  55. package/dist/Editor/utils/helper.js +20 -24
  56. package/package.json +4 -4
  57. package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
  58. package/dist/Editor/helper/textIndeces.js +0 -58
@@ -1,5 +1,7 @@
1
1
  import { Editor, Element, Path, Transforms } from "slate";
2
+ import insertNewLine from "./insertNewLine";
2
3
  import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType, getSelectedText } from "./helper";
4
+ import { isMobileWindow } from "../helper";
3
5
  import { removeAccordion } from "./events";
4
6
  import { ReactEditor } from "slate-react";
5
7
  const focusAccordion = (editor, upPath) => {
@@ -7,74 +9,51 @@ const focusAccordion = (editor, upPath) => {
7
9
  path: upPath,
8
10
  offset: 0
9
11
  });
10
- ReactEditor.focus(editor);
11
12
  };
12
- const getAccordionNode = summaryNode => {
13
- return {
14
- type: "accordion",
15
- children: [{
16
- type: "accordion-summary",
17
- children: summaryNode
18
- }, {
19
- type: "accordion-details",
13
+ export const insertAccordion = (editor, path) => {
14
+ try {
15
+ const selectedText = getSelectedText(editor);
16
+ const accordion = {
17
+ type: "accordion",
20
18
  children: [{
21
- type: "paragraph",
19
+ type: "accordion-summary",
22
20
  children: [{
23
- text: ""
21
+ type: "paragraph",
22
+ children: [{
23
+ text: selectedText || ""
24
+ }]
24
25
  }]
25
- }]
26
- }]
27
- };
28
- };
29
- export const insertAccordion = (editor, path) => {
30
- try {
31
- const {
32
- selection
33
- } = editor;
34
- let accordionPath;
35
- if (path) {
36
- const summaryNode = {
37
- type: "paragraph",
26
+ }, {
27
+ type: "accordion-details",
38
28
  children: [{
39
- text: ""
29
+ type: "paragraph",
30
+ children: [{
31
+ text: ""
32
+ }]
40
33
  }]
41
- };
42
- const accordion = getAccordionNode([summaryNode]);
43
- Transforms.insertNodes(editor, accordion, {
44
- at: path
45
- });
46
- accordionPath = path;
47
- } else if (selection) {
48
- const selectedNodes = Array.from(Editor.nodes(editor, {
49
- match: n => Element.isElement(n),
50
- mode: "lowest" // use 'lowest' to get individual blocks
51
- }));
52
-
53
- for (const [node, path] of selectedNodes) {
54
- let currNode = node;
55
- // const isListItem = node.type === "list-item";
56
- // if (isListItem) {
57
- // currNode = {
58
- // type: "paragraph",
59
- // children: node.children,
60
- // };
61
- // }
34
+ }]
35
+ };
36
+ const props = path ? {
37
+ at: path,
38
+ select: true
39
+ } : {
40
+ select: true
41
+ };
42
+ Transforms.insertNodes(editor, accordion, props);
43
+ const curPath = [...editor?.selection?.anchor?.path];
44
+ const upPath = [...curPath];
45
+ // get title index
46
+ const summaryIndex = upPath.length - 3;
47
+ upPath[summaryIndex] = upPath[summaryIndex] === 0 ? 0 : upPath[summaryIndex] - 1;
62
48
 
63
- let accordion = getAccordionNode([currNode]);
64
- Transforms.removeNodes(editor, {
65
- at: path
66
- });
67
- Transforms.insertNodes(editor, accordion, {
68
- at: path
69
- });
70
- accordionPath = path;
71
- }
72
- const lastNode = selectedNodes[selectedNodes.length - 1];
73
- const lastNodePath = lastNode[1];
74
- accordionPath = lastNodePath;
49
+ // select accordion title by default
50
+ if (isMobileWindow()) {
51
+ // timeout to resolve focus issue in mobile
52
+ setTimeout(() => focusAccordion(editor, upPath), 0);
53
+ } else {
54
+ focusAccordion(editor, upPath);
75
55
  }
76
- const focusPath = [...accordionPath, 0, 0, 0];
77
- focusAccordion(editor, focusPath);
56
+ insertNewLine(editor);
78
57
  } catch (err) {
79
58
  console.log(err);
80
59
  }
@@ -154,11 +133,4 @@ export const onDeleteBackwardAccordion = editor => {
154
133
  } catch (err) {
155
134
  console.log(err);
156
135
  }
157
- };
158
- export const toggleAccordion = editor => {
159
- const parentAccordion = Editor.above(editor, {
160
- match: node => Element.isElement(node) && node.type === "accordion"
161
- });
162
- const [, accordionPath] = parentAccordion;
163
- removeAccordion(editor, accordionPath);
164
136
  };
@@ -82,8 +82,7 @@ const splitInlineStyleRanges = (text, inlineStyleRanges, data) => {
82
82
  };
83
83
  export const draftToSlate = props => {
84
84
  const {
85
- data,
86
- needLayout
85
+ data
87
86
  } = props;
88
87
  if (data?.blocks && data?.blocks?.length > 0) {
89
88
  const converted = data?.blocks?.reduce((a, b) => {
@@ -105,7 +104,7 @@ export const draftToSlate = props => {
105
104
  return data;
106
105
  } else {
107
106
  return [{
108
- type: needLayout ? "title" : "paragraph",
107
+ type: "paragraph",
109
108
  children: [{
110
109
  text: ""
111
110
  }]
@@ -197,102 +197,9 @@ export const removeAccordion = (editor, accordionPath) => {
197
197
  select: true
198
198
  });
199
199
  };
200
- export const customizeEnterEvent = (editor, ele, e) => {
201
- const {
202
- type
203
- } = ele[0];
204
- const path = ele[1];
205
- const text = Node.string(ele[0]);
206
- let breakNext = false;
207
- switch (type) {
208
- case "list-item":
209
- if (!text) {
210
- e?.preventDefault();
211
- escapeEvent({
212
- editor
213
- });
214
- }
215
- break;
216
- case "check-list-item":
217
- const selectionPath = editor?.selection?.anchor?.path;
218
- const currEle = Node.parent(editor, selectionPath);
219
- const currEleText = Node.string(currEle);
220
- if (!currEleText) {
221
- e?.preventDefault();
222
- checkListEnterEvent(editor, type);
223
- }
224
- break;
225
- case "accordion-summary":
226
- e?.preventDefault();
227
- breakNext = true;
228
- if (!text) {
229
- const accordionIndex = ele[1].slice(0, Math.max(ele[1].length - 1));
230
- removeAccordion(editor, accordionIndex);
231
- } else {
232
- const nextPath = Path.next(Path.parent(ele[1]));
233
- insertAccordion(editor, nextPath);
234
- }
235
- break;
236
- case "headingOne":
237
- case "headingTwo":
238
- case "headingThree":
239
- const {
240
- selection
241
- } = editor;
242
- if (selection && Range.isCollapsed(selection)) {
243
- const isAtEnd = Editor.isEnd(editor, selection.anchor, path);
244
- const isAtStart = Editor.isStart(editor, selection.anchor, path);
245
- if (isAtEnd) {
246
- e?.preventDefault();
247
- Transforms.insertNodes(editor, {
248
- type: "paragraph",
249
- children: [{
250
- text: ""
251
- }]
252
- });
253
- const newLocation = Editor.after(editor, selection);
254
- if (newLocation) {
255
- Transforms.select(editor, newLocation);
256
- }
257
- } else if (!isAtStart) {
258
- e?.preventDefault();
259
- Transforms.splitNodes(editor);
260
- Transforms.setNodes(editor, {
261
- type: "paragraph"
262
- }, {
263
- at: Editor.after(editor, selection)
264
- });
265
- const newLocation = Editor.after(editor, selection);
266
- if (newLocation) {
267
- Transforms.select(editor, newLocation);
268
- }
269
- } else if (isAtStart) {
270
- e?.preventDefault();
271
- Transforms.insertNodes(editor, {
272
- type: "paragraph",
273
- children: [{
274
- text: ""
275
- }]
276
- }, {
277
- at: Editor.before(editor, selection)
278
- });
279
- Transforms.select(editor, Editor.before(editor, selection));
280
- const newLocation = Editor.before(editor, selection);
281
- if (newLocation) {
282
- Transforms.select(editor, newLocation);
283
- }
284
- }
285
- return;
286
- }
287
- break;
288
- default:
289
- }
290
- return {
291
- breakNext
292
- };
293
- };
294
200
  export const enterEvent = (e, editor, isMobile) => {
295
201
  try {
202
+ const ele = isListItem(editor);
296
203
  // on shift enter break line in same node
297
204
  if (e.shiftKey && !isMobile) {
298
205
  e.preventDefault();
@@ -304,6 +211,94 @@ export const enterEvent = (e, editor, isMobile) => {
304
211
  } else {
305
212
  Transforms.insertText(editor, "\n");
306
213
  }
214
+ } else if (ele && ele[0]) {
215
+ const {
216
+ type
217
+ } = ele[0];
218
+ const path = ele[1];
219
+ const text = Node.string(ele[0]);
220
+ switch (type) {
221
+ case "list-item":
222
+ if (!text) {
223
+ e.preventDefault();
224
+ escapeEvent({
225
+ editor
226
+ });
227
+ }
228
+ break;
229
+ case "check-list-item":
230
+ const selectionPath = editor?.selection?.anchor?.path;
231
+ const currEle = Node.parent(editor, selectionPath);
232
+ const currEleText = Node.string(currEle);
233
+ if (!currEleText) {
234
+ e.preventDefault();
235
+ checkListEnterEvent(editor, type);
236
+ }
237
+ break;
238
+ case "accordion-summary":
239
+ e.preventDefault();
240
+ if (!text) {
241
+ const accordionIndex = ele[1].slice(0, Math.max(ele[1].length - 1));
242
+ removeAccordion(editor, accordionIndex);
243
+ } else {
244
+ const nextPath = Path.next(Path.parent(ele[1]));
245
+ insertAccordion(editor, nextPath);
246
+ }
247
+ break;
248
+ case "headingOne":
249
+ case "headingTwo":
250
+ case "headingThree":
251
+ const {
252
+ selection
253
+ } = editor;
254
+ if (selection && Range.isCollapsed(selection)) {
255
+ const isAtEnd = Editor.isEnd(editor, selection.anchor, path);
256
+ const isAtStart = Editor.isStart(editor, selection.anchor, path);
257
+ if (isAtEnd) {
258
+ e.preventDefault();
259
+ Transforms.insertNodes(editor, {
260
+ type: "paragraph",
261
+ children: [{
262
+ text: ""
263
+ }]
264
+ });
265
+ const newLocation = Editor.after(editor, selection);
266
+ if (newLocation) {
267
+ Transforms.select(editor, newLocation);
268
+ }
269
+ } else if (!isAtStart) {
270
+ e.preventDefault();
271
+ Transforms.splitNodes(editor);
272
+ Transforms.setNodes(editor, {
273
+ type: "paragraph"
274
+ }, {
275
+ at: Editor.after(editor, selection)
276
+ });
277
+ const newLocation = Editor.after(editor, selection);
278
+ if (newLocation) {
279
+ Transforms.select(editor, newLocation);
280
+ }
281
+ } else if (isAtStart) {
282
+ e.preventDefault();
283
+ Transforms.insertNodes(editor, {
284
+ type: "paragraph",
285
+ children: [{
286
+ text: ""
287
+ }]
288
+ }, {
289
+ at: Editor.before(editor, selection)
290
+ });
291
+ Transforms.select(editor, Editor.before(editor, selection));
292
+ const newLocation = Editor.before(editor, selection);
293
+ if (newLocation) {
294
+ Transforms.select(editor, newLocation);
295
+ }
296
+ }
297
+ return;
298
+ }
299
+ break;
300
+ default:
301
+ }
307
302
  }
308
303
  // Handle blockquote splitting
309
304
  if (!e.shiftKey) {
@@ -219,13 +219,9 @@ export const handleInsertLastElement = (event, editor) => {
219
219
  };
220
220
  export const isListItem = editor => {
221
221
  const format = ["list-item", "check-list-item", "accordion-summary", "headingOne", "headingTwo", "headingThree"];
222
- const [node1, node2] = Editor.nodes(editor, {
222
+ const [node] = Editor.nodes(editor, {
223
223
  match: n => !Editor.isEditor(n) && Element.isElement(n) && format.indexOf(n.type) > -1
224
224
  });
225
- let node = node1;
226
- if (node2 && node2[0] && node2[0].type === "accordion-summary") {
227
- node = node2;
228
- }
229
225
  return node;
230
226
  };
231
227
  export const getNode = (editor, path) => {
@@ -743,10 +739,6 @@ export const isRestrictedNode = (event, editor) => {
743
739
  return isNodeRestricted;
744
740
  }
745
741
  };
746
- export function capitalizeFirstLetter(str) {
747
- if (!str) return str;
748
- return str.charAt(0).toUpperCase() + str.slice(1);
749
- }
750
742
  export const insertLineBreakAtEndOfPath = (editor, path) => {
751
743
  try {
752
744
  const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
@@ -765,13 +757,6 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
765
757
  console.log(err);
766
758
  }
767
759
  };
768
- export function isHavingSelection(editor) {
769
- try {
770
- return editor?.selection && !Range.isCollapsed(editor.selection);
771
- } catch (err) {
772
- console.log(err);
773
- }
774
- }
775
760
  const omitNodes = ["site-settings", "page-settings"];
776
761
  export function getInitialValue(value = [], readOnly) {
777
762
  if (readOnly === "readonly" && value?.length) {
@@ -802,17 +787,20 @@ export function getInitialValue(value = [], readOnly) {
802
787
  }
803
788
  return value;
804
789
  }
790
+ export function capitalizeFirstLetter(str) {
791
+ if (!str) return str;
792
+ return str.charAt(0).toUpperCase() + str.slice(1);
793
+ }
794
+ export function isHavingSelection(editor) {
795
+ try {
796
+ return editor?.selection && !Range.isCollapsed(editor.selection);
797
+ } catch (err) {
798
+ console.log(err);
799
+ }
800
+ }
805
801
  export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
806
802
  return `${defaultCls} ${selected ? selectedClsName : ""}`;
807
803
  }
808
- export function handleNegativeInteger(val) {
809
- return val < 0 ? 0 : val;
810
- }
811
- export const containsSurrogatePair = text => {
812
- // Match surrogate pairs (high and low surrogate)
813
- const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
814
- return surrogatePairRegex.test(text);
815
- };
816
804
  export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
817
805
  try {
818
806
  const options = {
@@ -826,6 +814,11 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
826
814
  return [];
827
815
  }
828
816
  };
817
+ export const containsSurrogatePair = text => {
818
+ // Match surrogate pairs (high and low surrogate)
819
+ const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
820
+ return surrogatePairRegex.test(text);
821
+ };
829
822
  export const getSlateDom = (editor, range) => {
830
823
  try {
831
824
  const slateDom = ReactEditor.toDOMRange(editor, range);
@@ -876,6 +869,9 @@ export const hideSlateSelection = () => {
876
869
  const root = document.documentElement;
877
870
  root.style.setProperty("--slate-highlight-bg", "none");
878
871
  };
872
+ export function handleNegativeInteger(val) {
873
+ return val < 0 ? 0 : val;
874
+ }
879
875
  export const insertSlashNode = (editor, insertNode) => {
880
876
  try {
881
877
  // Delete the currently selected text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "11.0.8",
3
+ "version": "11.1.0",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -38,6 +38,7 @@
38
38
  "react-icons": "^4.10.1",
39
39
  "react-katex": "^3.0.1",
40
40
  "react-rnd": "^10.4.11",
41
+ "react-scripts": "5.0.1",
41
42
  "react-signature-canvas": "^1.0.6",
42
43
  "react-slick": "^0.29.0",
43
44
  "sanitize-html": "^2.13.0",
@@ -68,7 +69,7 @@
68
69
  "storybook": "storybook dev -p 6006",
69
70
  "build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
70
71
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
71
- "publish:local": "rm -rf /Users/agenciflow08/Documents/flozyapp/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agenciflow08/Documents/flozyapp/client/node_modules/@flozy/editor/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",
72
73
  "publish:flozy": "./publish-flozy.sh",
73
74
  "publish:flozy2": "./publish-flozy2.sh",
74
75
  "publish:permission": "chmod +x publish-flozy.sh && chmod +x publish-flozy2.sh"
@@ -121,8 +122,7 @@
121
122
  "prop-types": "^15.8.1",
122
123
  "source-map-explorer": "^2.5.3",
123
124
  "storybook": "^7.4.0",
124
- "webpack": "^5.88.2",
125
- "react-scripts": "5.0.1"
125
+ "webpack": "^5.88.2"
126
126
  },
127
127
  "overrides": {
128
128
  "react-refresh": "0.11.0"
@@ -1,115 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Grid, Button, Typography } from "@mui/material";
3
- import ImageSelector from "../../ImageSelector/ImageSelector";
4
- import UploadStyles from "../../ImageSelector/UploadStyles";
5
- import Icon from "../../Icon";
6
- import { useEditorContext } from "../../../hooks/useMouseMove";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
- const EmbedUpload = props => {
10
- const {
11
- value,
12
- data,
13
- customProps,
14
- onChange
15
- } = props;
16
- const {
17
- translation
18
- } = customProps;
19
- const {
20
- key
21
- } = data;
22
- const [base64, setBase64] = useState(value);
23
- const [open, setOpen] = useState(false);
24
- const {
25
- theme
26
- } = useEditorContext();
27
- const classes = UploadStyles(theme);
28
- const onRemoveBG = () => {
29
- setBase64(null);
30
- onChange({
31
- [key]: "none"
32
- });
33
- };
34
- const handleClick = () => {
35
- setOpen(true);
36
- };
37
- const handleClose = () => {
38
- setOpen(false);
39
- };
40
- const onSelectImage = img => {
41
- setBase64(img);
42
- onChange({
43
- [key]: img
44
- });
45
- handleClose();
46
- };
47
- return /*#__PURE__*/_jsxs(Grid, {
48
- item: true,
49
- xs: 12,
50
- children: [/*#__PURE__*/_jsx(Typography, {
51
- variant: "body1",
52
- color: "primary",
53
- sx: {
54
- fontSize: "14px",
55
- fontWeight: "500",
56
- marginBottom: "8px"
57
- },
58
- children: translation("Upload Video")
59
- }), /*#__PURE__*/_jsx(Grid, {
60
- container: true,
61
- sx: classes.uploadContainer,
62
- children: /*#__PURE__*/_jsx(Grid, {
63
- item: true,
64
- xs: 12,
65
- sx: classes.uploadField,
66
- children: /*#__PURE__*/_jsx(Grid, {
67
- className: "uploadImageSection",
68
- children: base64 ? /*#__PURE__*/_jsxs(Grid, {
69
- justifyItems: "center",
70
- alignItems: "center",
71
- children: [/*#__PURE__*/_jsx(Typography, {
72
- style: {
73
- padding: "8px",
74
- fontSize: "8px",
75
- color: theme?.palette?.editor?.textColor,
76
- textAlign: "center"
77
- },
78
- children: base64
79
- }), /*#__PURE__*/_jsx(Grid, {
80
- className: "removeImageText",
81
- onClick: onRemoveBG,
82
- children: translation("REMOVE")
83
- })]
84
- }) : /*#__PURE__*/_jsx(Grid, {
85
- className: "uploadImageText",
86
- children: /*#__PURE__*/_jsxs(Button, {
87
- component: "label",
88
- variant: "text",
89
- style: {
90
- background: "none"
91
- },
92
- onClick: handleClick,
93
- sx: classes.uploadIcon,
94
- children: [/*#__PURE__*/_jsx(Icon, {
95
- icon: "fileUpload"
96
- }), /*#__PURE__*/_jsx("span", {
97
- style: {
98
- paddingLeft: "8px"
99
- },
100
- children: translation("Upload a Video")
101
- })]
102
- })
103
- })
104
- })
105
- })
106
- }), /*#__PURE__*/_jsx(ImageSelector, {
107
- open: open,
108
- title: "Video",
109
- onClose: handleClose,
110
- customProps: customProps,
111
- onSelectImage: onSelectImage
112
- })]
113
- });
114
- };
115
- export default EmbedUpload;
@@ -1,58 +0,0 @@
1
- export function extractTextWithPath(data, path = []) {
2
- let result = [];
3
- data.forEach((item, index) => {
4
- const currentPath = [...path, index];
5
- if (item.text) {
6
- result.push({
7
- path_id: currentPath.join(","),
8
- text: item.text
9
- });
10
- }
11
- if (item.children) {
12
- result = result.concat(extractTextWithPath(item.children, currentPath));
13
- }
14
- });
15
- return result;
16
- }
17
- export function replaceTextPath(nestedJson, pathIdJson) {
18
- // Create a map from path_id JSON for quick lookup
19
- const pathIdMap = new Map(pathIdJson.map(item => [item.path_id, item.text]));
20
- console.log(pathIdMap);
21
- function extractTextWithPath(data, path = []) {
22
- data.forEach((item, index) => {
23
- const currentPath = [...path, index];
24
- if (item.text) {
25
- if (pathIdMap.has(currentPath?.join(","))) {
26
- item.text = pathIdMap.get(currentPath?.join(","));
27
- }
28
- }
29
- if (item.children) {
30
- extractTextWithPath(item.children, currentPath);
31
- }
32
- });
33
- }
34
- extractTextWithPath(nestedJson, []);
35
- return nestedJson;
36
- }
37
-
38
- // export function replaceTextPath(nestedJson, pathIdJson) {
39
- // // Create a map from path_id JSON for quick lookup
40
- // const pathIdMap = new Map(
41
- // pathIdJson.map((item) => [item.path_id, item.text])
42
- // );
43
-
44
- // function traverseAndReplace(node) {
45
- // if (Array.isArray(node)) {
46
- // node.forEach(traverseAndReplace);
47
- // } else if (typeof node === "object" && node !== null) {
48
- // console.log(node);
49
- // if (node.text && pathIdMap.has(node.text)) {
50
- // node.text = pathIdMap.get(node.path_id);
51
- // }
52
- // Object.values(node).forEach(traverseAndReplace);
53
- // }
54
- // }
55
-
56
- // traverseAndReplace(nestedJson);
57
- // return nestedJson;
58
- // }