@flozy/editor 4.4.9 → 4.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ import DragAndDrop from "./common/DnD";
27
27
  import Section from "./common/Section";
28
28
  import decorators from "./utils/Decorators";
29
29
  import { getTRBLBreakPoints } from "./helper/theme";
30
- import { handleInsertLastElement, isFreeGridFragment, outsideEditorClickLabel } from "./utils/helper";
30
+ import { handleInsertLastElement, isFreeGrid, isFreeGridFragment, outsideEditorClickLabel } from "./utils/helper";
31
31
  import useWindowResize from "./hooks/useWindowResize";
32
32
  import PopoverAIInput from "./Elements/AI/PopoverAIInput";
33
33
  import RnDCopy from "./common/RnD/RnDCopy";
@@ -82,7 +82,6 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
82
82
  onSave,
83
83
  editor: collaborativeEditor,
84
84
  readOnly,
85
- toolbarOptions,
86
85
  otherProps,
87
86
  isIframe,
88
87
  theme,
@@ -288,10 +287,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
288
287
  index,
289
288
  type
290
289
  } = mentions;
291
- const chars = type ? Shorthands[type]({
290
+ const updatedHideTools = !isFreeGrid(content) ? [...hideTools, "freegrid"] : hideTools;
291
+ const chars = type && !isFreeGrid(content) ? Shorthands[type]({
292
292
  ...mentions,
293
293
  CHARACTERS,
294
- hideTools: hideTools || []
294
+ hideTools: updatedHideTools || []
295
295
  }) : [];
296
296
  const handleEditorChange = newValue => {
297
297
  setValue(newValue);
@@ -370,7 +370,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
370
370
  } else if (event.key === "ArrowDown" && otherProps?.tagName !== 'Pages') {
371
371
  upDownArrowKeyEvents(event, editor);
372
372
  }
373
- }, [chars, editor, target, mentions, setMentions, search, type, mentionsRef]);
373
+ }, [chars, target, mentions, setMentions, search, type, mentionsRef]);
374
374
  const Overlay = collaborativeEditor && !isReadOnly ? RemoteCursorOverlay : React.Fragment;
375
375
  const dotBg = needDotsBG ? {
376
376
  background: "white",
@@ -234,6 +234,18 @@ blockquote {
234
234
  background-color: #0052cc;
235
235
  }
236
236
 
237
+ .signature-btn-container .sign-placeholder {
238
+ display: none; /* will changed to flex on DnD */
239
+ flex-direction: column;
240
+ justify-content: center;
241
+ align-items: center;
242
+ border: 1px solid #E4E6E9;
243
+ border-radius: 10px;
244
+ background: white;
245
+ box-shadow: 0px 4px 16px 0px #0000000D;
246
+ gap: 10px;
247
+ }
248
+
237
249
  .signature-btn-grps {
238
250
  display: flex;
239
251
  justify-content: space-around;
@@ -225,8 +225,10 @@ const FreeGrid = props => {
225
225
  left: 50,
226
226
  marginTop: 0,
227
227
  top: 0,
228
- width: 150,
229
- height: 130
228
+ width: 217,
229
+ height: 173,
230
+ width_xs: 217,
231
+ height_xs: 173
230
232
  }], {
231
233
  at: [...insertAt]
232
234
  });
@@ -382,6 +384,7 @@ const FreeGrid = props => {
382
384
  Transforms.removeNodes(editor, {
383
385
  at: Path.parent(path)
384
386
  });
387
+ setSelectedElement({});
385
388
  } catch (err) {
386
389
  console.log(err);
387
390
  }
@@ -499,6 +502,8 @@ const FreeGrid = props => {
499
502
  backgroundSize: "cover"
500
503
  },
501
504
  "data-path": path.join("|"),
505
+ "data-dragOverId": path.join("|"),
506
+ "data-dragOverType": "parent",
502
507
  style: {
503
508
  "--cols": `100%`,
504
509
  "--rows": `repeat(${repeatTimes}, ${ROW_HEIGHT}px)`
@@ -190,6 +190,8 @@ const FreeGridBox = props => {
190
190
  ...attributes,
191
191
  className: "fgi_type_box freegrid-container-parent",
192
192
  "data-path": path.join("|"),
193
+ "data-dragOverId": path.join("|"),
194
+ "data-dragOverType": "parent",
193
195
  style: {
194
196
  "--height": `${height}px`,
195
197
  "--cols": `100%`,
@@ -20,6 +20,9 @@ const useFreeGridStyles = ({
20
20
  marginLeft: `calc((100% - ${MAX_DEVICE_WIDTH}px) * 0.5)`,
21
21
  "&.active-drag": {
22
22
  pointerEvents: "none",
23
+ "& *": {
24
+ pointerEvents: "none"
25
+ },
23
26
  zIndex: "9999 !important"
24
27
  },
25
28
  "&.inactive-drag": {
@@ -166,9 +169,17 @@ const useFreeGridStyles = ({
166
169
  height: "100%",
167
170
  "& .signature-btn-container": {
168
171
  height: "100%",
169
- "& button": {
172
+ display: "flex",
173
+ flexDirection: "column",
174
+ "& .sign-placeholder": {
175
+ display: "flex",
176
+ // remove hidden sign placeholder
170
177
  width: "100%",
171
- height: "100%"
178
+ background: theme?.palette?.editor?.background,
179
+ flexGrow: 1
180
+ },
181
+ "& button": {
182
+ margin: "6px 0px"
172
183
  }
173
184
  }
174
185
  }
@@ -206,9 +217,26 @@ const useFreeGridStyles = ({
206
217
  "& .freegrid-item": {
207
218
  marginLeft: "0px"
208
219
  // pointerEvents: "none",
220
+ },
221
+
222
+ "&.rnd-dragOver": {
223
+ outline: "2px solid #116dff",
224
+ "&:before": {
225
+ content: '"Attach to Box"',
226
+ position: "absolute",
227
+ top: "-36px",
228
+ left: 0,
229
+ right: 0,
230
+ margin: "0px auto",
231
+ width: "fit-content",
232
+ background: "#116dff",
233
+ padding: "8px 12px",
234
+ color: "#FFF",
235
+ fontSize: "14px",
236
+ borderRadius: "7px"
237
+ }
209
238
  }
210
239
  },
211
-
212
240
  "& .fgi_type_form": {
213
241
  "& .form-field": {
214
242
  "& input": {
@@ -289,6 +317,22 @@ const useFreeGridStyles = ({
289
317
  [theme.breakpoints.between("xs", "md")]: {
290
318
  marginLeft: `calc((100% - 320px) * 0.5)`
291
319
  }
320
+ },
321
+ "&.rnd-dragOver": {
322
+ "&:before": {
323
+ content: '"Attact to this Section"',
324
+ position: "absolute",
325
+ top: 0,
326
+ left: 0,
327
+ right: 0,
328
+ margin: "0px auto",
329
+ width: "fit-content",
330
+ background: "#116dff",
331
+ padding: "8px 12px",
332
+ color: "#FFF",
333
+ fontSize: "14px",
334
+ borderRadius: "7px"
335
+ }
292
336
  }
293
337
  }
294
338
  },
@@ -42,7 +42,8 @@ const TypeSignature = props => {
42
42
  overflow: "hidden",
43
43
  textOverflow: "ellipsis",
44
44
  warp: "noWarp",
45
- maxWidth: "120px"
45
+ maxWidth: "120px",
46
+ color: "#000000"
46
47
  },
47
48
  children: name || "Signature"
48
49
  })
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from "react";
2
- import { Dialog, DialogTitle, DialogContent, DialogActions, Button, IconButton, Grid, TextField, Typography, Tabs, Tab, InputAdornment } from "@mui/material";
2
+ import { Dialog, DialogTitle, DialogContent, DialogActions, Button, IconButton, Grid, TextField, Typography, Tabs, Tab, InputAdornment, Box } from "@mui/material";
3
3
  import CloseIcon from "@mui/icons-material/Close";
4
4
  import DatePicker from "react-datepicker";
5
5
  import "react-datepicker/dist/react-datepicker.css";
@@ -11,6 +11,7 @@ import { useEditorContext } from "../../hooks/useMouseMove";
11
11
  import { validationMethods } from "../Form/FormElements/validations";
12
12
  import { CalenderDownIconSignature, CalenderIconSignature } from "../../common/iconListV2";
13
13
  import ColorPickerButton from "../../common/ColorPickerButton";
14
+ import { SignaturePlaceholderIcon } from "../../common/iconslist";
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -129,13 +130,25 @@ const SignaturePopup = props => {
129
130
  isEmpty = signedData?.signature === "" && signedData?.signedText === "" || signedData?.signedBy === "" || signedData?.signedByEmail === "";
130
131
  }
131
132
  return /*#__PURE__*/_jsxs(_Fragment, {
132
- children: [onlyPopup ? null : /*#__PURE__*/_jsx("div", {
133
+ children: [onlyPopup ? null : /*#__PURE__*/_jsxs("div", {
133
134
  className: `signature-btn-container`,
134
- children: /*#__PURE__*/_jsx(Button, {
135
- contentEditable: false,
135
+ contentEditable: false,
136
+ children: [/*#__PURE__*/_jsxs(Box, {
137
+ className: "sign-placeholder",
138
+ children: [/*#__PURE__*/_jsx(SignaturePlaceholderIcon, {}), /*#__PURE__*/_jsx(Typography, {
139
+ variant: "body2",
140
+ style: {
141
+ color: "#A2B0B9"
142
+ },
143
+ children: "Your sign will be placed here"
144
+ })]
145
+ }), /*#__PURE__*/_jsx(Button, {
136
146
  onClick: handleOpen,
147
+ style: {
148
+ width: "fit-content"
149
+ },
137
150
  children: "Sign Here"
138
- })
151
+ })]
139
152
  }), /*#__PURE__*/_jsx(Dialog, {
140
153
  className: `${className} dialogComp`,
141
154
  open: onlyPopup || open,
@@ -17,7 +17,6 @@ const DragOver = props => {
17
17
  const open = Boolean(anchorEl);
18
18
  const isSectionHover = status && type === "parent";
19
19
  const isContainerHover = hover_on === path && type === "parent-container";
20
- console.log(isSectionHover, isContainerHover);
21
20
  useEffect(() => {
22
21
  if (ref?.current) {
23
22
  const getBoundingClientRect = () => ref?.current?.getBoundingClientRect();
@@ -42,6 +42,11 @@ const useElementOptionsStyle = ({
42
42
  "& .strokePath": {
43
43
  stroke: "#2563EB"
44
44
  }
45
+ },
46
+ "& .SignatureIcon": {
47
+ "& path": {
48
+ fill: theme?.palette?.editor?.textColor
49
+ }
45
50
  }
46
51
  }
47
52
  }
@@ -12,6 +12,8 @@ const RnDCopy = props => {
12
12
  useEffect(() => {
13
13
  if (selectedElement?.path) {
14
14
  window.selectedRnDElement = selectedElement;
15
+ } else {
16
+ window.selectedRnDElement = {};
15
17
  }
16
18
  }, [selectedElement?.path, selectedElement?.enable]);
17
19
  return !readOnly ? /*#__PURE__*/_jsx(Box, {
@@ -11,13 +11,14 @@ import DragInfo from "./DragInfo";
11
11
  import GuideLines from "./GuideLines";
12
12
  import ShadowElement from "./ShadowElement";
13
13
  import BoundaryLine from "./GuideLines/BoundaryLine";
14
- import DragOver from "./DragOver";
15
14
  import ContextMenu from "./ContextMenu";
16
15
  import VirtualElement from "./VirtualElement";
17
16
  import { ItemTypes } from "./ElementSettings/settingsConstants";
18
17
  import { focusSelection, clearSelection } from "../../helper";
19
18
  import { selectText } from "../../utils/helper";
20
19
  import { removeSign } from "./ElementSettings/OtherSettings";
20
+ import useDragging from "../../hooks/useDragging";
21
+ import { dragOverOn } from "../../helper/RnD/focusNode";
21
22
  import { jsx as _jsx } from "react/jsx-runtime";
22
23
  import { jsxs as _jsxs } from "react/jsx-runtime";
23
24
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -58,7 +59,6 @@ const RnD = props => {
58
59
  const {
59
60
  isSelectedElement,
60
61
  setSelectedElement,
61
- dragging,
62
62
  updateDragging,
63
63
  contextMenu,
64
64
  setContextMenu,
@@ -76,21 +76,25 @@ const RnD = props => {
76
76
  const open = Boolean(enable);
77
77
  const currentAction = str_path === sp ? selectedAction : null;
78
78
  const positionRef = useRef();
79
+ const {
80
+ draggingRef,
81
+ startDragging,
82
+ stopDragging,
83
+ setDragOver
84
+ } = useDragging();
85
+ const dragging = draggingRef?.current;
79
86
  const {
80
87
  active,
81
88
  id,
82
- parentPath,
83
- dragOver
89
+ parentPath
84
90
  } = dragging;
85
91
  const dragInfoOpen = id === str_path;
86
- const dragOverStatus = dragOver === str_path && parentPath !== str_path;
87
92
  const [absPosition, setAbsPosition] = useState({});
88
93
  const openContextMenu = contextMenu?.path === str_path;
89
94
  const [position, setPosition] = useState({
90
95
  x: 0,
91
96
  y: 0
92
97
  });
93
- const pathIsDragging = dragOver === str_path && dragging?.isDragging;
94
98
  const parentSectionPath = str_path?.split("|").slice(0, 2).join("_");
95
99
  useEffect(() => {
96
100
  if (ITEM_TYPES.includes(type)) {
@@ -156,7 +160,6 @@ const RnD = props => {
156
160
  switch (e.detail) {
157
161
  case 1:
158
162
  if (!enable) {
159
- // focusSelection(editor, { path });
160
163
  setSelectedElement({
161
164
  path: str_path,
162
165
  enable: 1,
@@ -164,6 +167,7 @@ const RnD = props => {
164
167
  anchorEl: rndRef?.current
165
168
  });
166
169
  }
170
+ // ReactEditor.focus(editor);
167
171
  break;
168
172
  case 2:
169
173
  focusSelection(editor, {
@@ -281,9 +285,8 @@ const RnD = props => {
281
285
  dragOver: null
282
286
  }, null);
283
287
  }
284
- // focusSelection(editor, { path: updated_at });
288
+ stopDragging();
285
289
  };
286
-
287
290
  const onDragStart = e => {
288
291
  e.preventDefault();
289
292
  if (e?.target?.dataset?.path?.split(",").join("|") === sp) {
@@ -301,6 +304,9 @@ const RnD = props => {
301
304
  diffX: parseInt(Math.abs(Math.floor(left - e.clientX))),
302
305
  diffY: parseInt(Math.abs(Math.floor(top - e.clientY)))
303
306
  };
307
+ const parentPath = getParentSectionPath({
308
+ ref
309
+ }, ".freegrid-container-parent");
304
310
  updateDragging({
305
311
  ...dragging,
306
312
  active: true,
@@ -312,17 +318,24 @@ const RnD = props => {
312
318
  width,
313
319
  height
314
320
  },
315
- isDragging: true,
316
- parentPath: getParentSectionPath({
317
- ref
318
- }, ".freegrid-container-parent")
321
+ isDragging: 1,
322
+ parentPath
319
323
  });
320
324
  setPosition({
321
325
  ...updatedPosition
322
326
  });
327
+ startDragging({
328
+ active: true,
329
+ id: str_path,
330
+ position: {
331
+ ...updatedPosition
332
+ },
333
+ isDragging: 1,
334
+ parentPath
335
+ });
323
336
  }
324
337
  };
325
- const onDrag = (e, d) => {
338
+ const onDrag = e => {
326
339
  e.preventDefault();
327
340
  const lines = getClosestDraggable(e.clientX, e.clientY, `.freegrid-section_${parentSectionPath} .freegrid-container .freegrid-item.inactive-drag`.replace(/\|/g, "\\|"), ".freegrid-item.active-drag:not(.exclude-virtual)");
328
341
  setAbsPosition({
@@ -330,7 +343,7 @@ const RnD = props => {
330
343
  "--zIndex": 2000
331
344
  });
332
345
  updateDragging({
333
- isDragging: true,
346
+ isDragging: 2,
334
347
  position: {
335
348
  ...dragging.position,
336
349
  x: e.clientX,
@@ -344,16 +357,34 @@ const RnD = props => {
344
357
  y: e.clientY,
345
358
  lines: lines
346
359
  });
360
+ const isDragOverOnParent = {};
361
+ let dragOverEle = e?.toElement?.dataset?.dragovertype !== "child" ? e?.toElement : e?.toElement?.closest(".freegrid-container-parent");
362
+
363
+ // some cases
364
+ if (dragOverEle?.dataset?.dragovertype === undefined) {
365
+ // means check for parent element
366
+ dragOverEle = e?.toElement?.parentElement;
367
+ }
368
+ if (dragOverEle?.dataset?.dragovertype !== "child") {
369
+ const oldPath = dragging.dragOver;
370
+ isDragOverOnParent.dragOver = dragOverEle?.dataset?.dragoverid;
371
+ isDragOverOnParent.dragOverType = dragOverEle?.dataset?.dragovertype;
372
+ dragOverOn(oldPath, dragOverEle?.dataset?.dragoverid);
373
+ }
374
+ startDragging({
375
+ isDragging: 2,
376
+ ...isDragOverOnParent
377
+ });
347
378
  };
348
379
  const onDragStop = (e, d) => {
349
380
  e.preventDefault();
350
381
  e.stopPropagation();
351
- if (dragging?.isDragging && dragging?.position?.strXY) {
382
+ if (dragging?.isDragging === 2 && dragging?.position?.strXY && dragging?.dragOver) {
352
383
  d.x = e.x;
353
384
  d.y = e.y;
354
385
  d.offsetX = e.offsetX;
355
386
  d.offsetY = e.offsetY;
356
- d.dragOver = dragOver;
387
+ d.dragOver = dragging?.dragOver;
357
388
  d.parentPath = parentPath;
358
389
  d.diffX = position?.diffX;
359
390
  d.diffY = position?.diffY;
@@ -381,6 +412,11 @@ const RnD = props => {
381
412
  setAbsPosition({
382
413
  ...ud
383
414
  });
415
+ stopDragging();
416
+ } else {
417
+ // invalid drags
418
+ // found in dev mode and in safari browser
419
+ onAfterDrop(path);
384
420
  }
385
421
  };
386
422
  const onResizeStop = (e, direction, ref, d, position) => {
@@ -431,6 +467,9 @@ const RnD = props => {
431
467
  e.stopPropagation();
432
468
  }
433
469
  if (type !== "child") {
470
+ setDragOver({
471
+ dragOver: str_path
472
+ });
434
473
  updateDragging({
435
474
  dragOver: str_path
436
475
  }, str_path);
@@ -504,14 +543,9 @@ const RnD = props => {
504
543
  "data-event": "rnd-click",
505
544
  className: "editor-blocker",
506
545
  "data-path": path,
507
- contentEditable: false
508
- }) : null, pathIsDragging ? /*#__PURE__*/_jsx(DragOver, {
509
- status: dragOverStatus,
510
- hover_on: dragOver,
511
- path: str_path,
512
- parentPath: parentPath,
513
- type: type,
514
- childType: childType
546
+ contentEditable: false,
547
+ "data-dragOverId": str_path,
548
+ "data-dragOverType": type
515
549
  }) : null]
516
550
  }, eId), !active && rndRef?.current && open ? /*#__PURE__*/_jsx(ElementOptions, {
517
551
  id: `opt_ref_${str_path}`,
@@ -55,15 +55,17 @@ const SectionStyle = theme => ({
55
55
  },
56
56
  "&.is-temp": {
57
57
  position: "fixed",
58
- background: "red",
58
+ background: "transparent",
59
59
  padding: "12px",
60
60
  width: "10px",
61
61
  height: "10px",
62
- // left: 0,
63
- // top: 0,
62
+ left: 0,
63
+ top: 0,
64
+ bottom: 0,
65
+ right: 0,
64
66
  margin: "auto",
65
- left: "var(--left)",
66
- top: "var(--top)",
67
+ // left: "var(--left)",
68
+ // top: "var(--top)",
67
69
  zIndex: 1000,
68
70
  pointerEvents: "none"
69
71
  }
@@ -2337,4 +2337,27 @@ export const ResetIcon = () => /*#__PURE__*/_jsxs("svg", {
2337
2337
  strokeLinecap: "round",
2338
2338
  strokeLinejoin: "round"
2339
2339
  })]
2340
+ });
2341
+ export const SignaturePlaceholderIcon = () => /*#__PURE__*/_jsxs("svg", {
2342
+ width: "39",
2343
+ height: "29",
2344
+ viewBox: "0 0 39 29",
2345
+ fill: "none",
2346
+ xmlns: "http://www.w3.org/2000/svg",
2347
+ children: [/*#__PURE__*/_jsx("path", {
2348
+ d: "M32.9361 2.30469L18.7107 16.5287C17.8881 17.3501 17.8881 18.6836 18.7107 19.5061L19.4967 20.2922C20.3182 21.1137 21.6528 21.1137 22.4742 20.2922L36.701 6.06677L32.9361 2.30469Z",
2349
+ fill: "#64748B"
2350
+ }), /*#__PURE__*/_jsx("path", {
2351
+ d: "M18.0898 20.1246C17.7023 19.7372 17.4549 19.2631 17.3415 18.7656L17.277 18.9424C17.1454 19.3043 16.9272 19.899 16.7945 20.2609L15.9122 22.6728C15.9074 22.6848 15.906 22.6972 15.9023 22.7056L16.9701 21.6392C17.0787 21.532 17.254 21.532 17.3626 21.6392C17.4711 21.7489 17.4711 21.9245 17.3626 22.0317L16.2962 23.1006C16.3083 23.0958 16.3181 23.0933 16.3304 23.0885L18.7423 22.2073C19.1042 22.0743 19.6978 21.8575 20.0608 21.7248L20.2376 21.6602C19.739 21.5458 19.2649 21.2983 18.8774 20.9132L18.0898 20.1246Z",
2352
+ fill: "#64748B"
2353
+ }), /*#__PURE__*/_jsx("path", {
2354
+ d: "M38.3842 1.40407L37.5982 0.617994C36.7756 -0.205998 35.4421 -0.205998 34.6207 0.617994L33.5664 1.67231L37.3299 5.43583L38.3842 4.38151C39.2057 3.55896 39.2057 2.22547 38.3842 1.40407Z",
2355
+ fill: "#64748B"
2356
+ }), /*#__PURE__*/_jsx("path", {
2357
+ d: "M36.7307 7.02477L30.3199 13.4356C30.0626 13.6928 30.0626 14.1095 30.3199 14.3667C30.5772 14.624 30.9938 14.624 31.251 14.3667L37.6604 7.95591C37.9177 7.69865 37.9177 7.28204 37.6604 7.02477C37.4034 6.76779 36.9865 6.76779 36.7307 7.02477Z",
2358
+ fill: "#64748B"
2359
+ }), /*#__PURE__*/_jsx("path", {
2360
+ d: "M19.034 24.3978H14.2468C12.5175 24.3978 11.4972 24.7574 10.8208 24.9951C10.0347 25.2742 9.97013 25.295 9.23397 24.6259C9.00841 24.4185 8.79632 24.1408 8.57216 23.8445C8.02117 23.1207 7.33161 22.2115 6.14206 22.2833C4.44193 22.3784 4.29183 24.1467 4.20291 25.2035C4.18833 25.3814 4.17121 25.58 4.14821 25.775C4.03234 25.4131 3.9204 25.0181 3.83511 24.7159C3.69624 24.221 3.55232 23.7116 3.39746 23.2826C3.07567 22.3966 2.51371 22.276 2.17738 22.2833C1.84465 22.2906 0.959808 22.3088 0.0410129 25.2229C-0.105155 25.6847 0.151831 26.1773 0.613894 26.3246C1.0782 26.4697 1.57054 26.2124 1.71698 25.7506C1.81208 25.4485 1.92907 25.134 2.04719 24.8512C2.07889 24.9634 2.11171 25.0779 2.14341 25.1912C2.59566 26.7976 2.95282 28.0638 3.9229 28.2955C3.99725 28.3126 4.08982 28.3261 4.19699 28.3261C4.47474 28.3261 4.84534 28.2285 5.20499 27.8337C5.79863 27.1843 5.88139 26.2102 5.95321 25.3534C5.98744 24.9438 6.05196 24.1796 6.23853 24.0371C6.49214 24.0273 6.76625 24.3724 7.17334 24.9085C7.42331 25.2376 7.70723 25.6104 8.05091 25.9224C9.46232 27.2081 10.2594 27.0558 11.4048 26.6512C12.0338 26.4293 12.8174 26.1541 14.2457 26.1541H19.0329C19.518 26.1541 19.9116 25.7591 19.9116 25.2754C19.9127 24.7915 19.5205 24.3979 19.034 24.3979L19.034 24.3978Z",
2361
+ fill: "#64748B"
2362
+ })]
2340
2363
  });
@@ -17,6 +17,7 @@ const ensureTemporaryFocusNode = (editor, selectedDOM) => {
17
17
  type: "temp",
18
18
  temp: TEMP_NODE_ID,
19
19
  children: [{
20
+ type: "restrictedType",
20
21
  text: ""
21
22
  }],
22
23
  left,
@@ -24,22 +25,9 @@ const ensureTemporaryFocusNode = (editor, selectedDOM) => {
24
25
  }, {
25
26
  at: [editor.children.length]
26
27
  });
27
- } else {
28
- Transforms.setNodes(editor, {
29
- type: "temp",
30
- temp: TEMP_NODE_ID,
31
- children: [{
32
- text: ""
33
- }],
34
- left,
35
- top
36
- }, {
37
- at: tempNodeEntry[1]
38
- });
39
28
  }
40
29
  };
41
30
  export const focusUsingTemporaryNode = (editor, selectedDOM) => {
42
- // de-select and select
43
31
  Transforms.deselect(editor);
44
32
 
45
33
  // Ensure the temporary node exists
@@ -52,9 +40,8 @@ export const focusUsingTemporaryNode = (editor, selectedDOM) => {
52
40
  });
53
41
  if (tempNodeEntry) {
54
42
  const [, path] = tempNodeEntry;
55
- Transforms.select(editor, path); // Move selection to the temp node
43
+ Transforms.select(editor, path);
56
44
  }
57
-
58
45
  ReactEditor.focus(editor);
59
46
  };
60
47
  export const cleanupTemporaryFocusNode = editor => {
@@ -67,4 +54,21 @@ export const cleanupTemporaryFocusNode = editor => {
67
54
  at: path
68
55
  });
69
56
  }
57
+ };
58
+ export const dragOverOn = (previousPath, currentPath) => {
59
+ try {
60
+ const previousElement = document.querySelector(`[data-dragoverid="${previousPath}"]`);
61
+ const currentElement = document.querySelector(`[data-dragoverid="${currentPath}"]`);
62
+ // Remove 'dragOver' class from the current element, if it exists
63
+ if (previousElement && previousElement.classList.contains("rnd-dragOver")) {
64
+ previousElement.classList.remove("rnd-dragOver");
65
+ }
66
+
67
+ // Add 'dragOver' class to the new element
68
+ if (currentElement) {
69
+ currentElement.classList.add("rnd-dragOver");
70
+ }
71
+ } catch (err) {
72
+ console.log(err);
73
+ }
70
74
  };
@@ -0,0 +1,51 @@
1
+ import { useState, useCallback, useRef } from "react";
2
+ const initialState = {
3
+ id: null,
4
+ active: false,
5
+ isDragging: 0,
6
+ dragOver: false,
7
+ dragOverType: null
8
+ };
9
+ const useDragging = () => {
10
+ const [dragging, setDragging] = useState({
11
+ ...initialState
12
+ });
13
+
14
+ // Ref to keep the latest draggingStatus
15
+ const draggingRef = useRef(dragging);
16
+ const updateDragging = newStatus => {
17
+ setDragging(prevStatus => {
18
+ const updatedStatus = {
19
+ ...prevStatus,
20
+ ...newStatus
21
+ };
22
+ draggingRef.current = updatedStatus; // Update the ref to hold latest status
23
+ return updatedStatus;
24
+ });
25
+ };
26
+ const startDragging = useCallback(data => {
27
+ // console.log("dragissue", "startDragging");
28
+ updateDragging({
29
+ ...data
30
+ });
31
+ }, []);
32
+ const stopDragging = useCallback(() => {
33
+ // console.log("dragissue", "stopDragging");
34
+ updateDragging({
35
+ ...initialState
36
+ });
37
+ }, []);
38
+ const setDragOver = useCallback(isOver => {
39
+ updateDragging({
40
+ dragOver: isOver
41
+ });
42
+ }, []);
43
+ return {
44
+ dragging,
45
+ draggingRef,
46
+ startDragging,
47
+ stopDragging,
48
+ setDragOver
49
+ };
50
+ };
51
+ export default useDragging;
@@ -98,7 +98,11 @@ export const EditorProvider = ({
98
98
  updateDragging,
99
99
  fontFamilies,
100
100
  setFontFamilies
101
- }), [path, editor?.selection, selectedPath, selectedElement, dragging.active, dragging.isDragging, dragging.dragOver, contextMenu, openAI, popupType, drop, fontFamilies]);
101
+ }), [path, editor?.selection, selectedPath, selectedElement,
102
+ // dragging.active,
103
+ // dragging.isDragging,
104
+ // dragging.dragOver,
105
+ contextMenu, openAI, popupType, drop]);
102
106
  return /*#__PURE__*/_jsx(EditorContext.Provider, {
103
107
  value: otherValues,
104
108
  children: children
@@ -9,6 +9,7 @@ import withLayout from "../plugins/withLayout";
9
9
  import withHtml from "../plugins/withHTML";
10
10
  import withErrorHandling from "./withErrorHandling";
11
11
  import withCustomDeleteBackward from "../plugins/withCustomDeleteBackward";
12
+ import withRestrictedNodes from "./withRestrictedNodes";
12
13
  const withCommon = (props, rest = {}) => {
13
14
  return rest.needLayout ? withErrorHandling(withHtml(withEquation(withLayout(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))))) : withErrorHandling(withHtml(withEquation(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))));
14
15
  };
@@ -0,0 +1,48 @@
1
+ import { Editor } from "slate";
2
+
3
+ // Custom insertText that prevents updates in specific node types
4
+ const withRestrictedNodes = editor => {
5
+ const {
6
+ insertText,
7
+ deleteBackward
8
+ } = editor;
9
+
10
+ // Override insertText
11
+ editor.insertText = text => {
12
+ const {
13
+ selection
14
+ } = editor;
15
+ if (selection) {
16
+ const [node] = Editor.node(editor, selection);
17
+ console.log(node);
18
+
19
+ // Prevent insertText if node type matches
20
+ if (node && node.type === "restrictedType") {
21
+ return; // Skip inserting text
22
+ }
23
+ }
24
+
25
+ // Call the original insertText if node type does not match
26
+ insertText(text);
27
+ };
28
+
29
+ // Similarly override deleteBackward if needed
30
+ editor.deleteBackward = (...args) => {
31
+ const {
32
+ selection
33
+ } = editor;
34
+ if (selection) {
35
+ const [node] = Editor.node(editor, selection);
36
+
37
+ // Prevent deletion if node type matches
38
+ if (node && node.type === "restrictedType") {
39
+ return; // Skip deleting text
40
+ }
41
+ }
42
+
43
+ // Call the original deleteBackward if node type does not match
44
+ deleteBackward(...args);
45
+ };
46
+ return editor;
47
+ };
48
+ export default withRestrictedNodes;
@@ -1,6 +1,7 @@
1
1
  import { Editor, Transforms, Node, Path } from "slate";
2
2
  import { isSelectionInNodeType, getCaretPosition, onPasteRnDNode, bringItemToFB } from "../../helper";
3
3
  import focusOnNewItem from "../../helper/RnD/focusOnNewItem";
4
+ import { ReactEditor } from "slate-react";
4
5
  const RND_ITEM_TYPES = ["freegrid", "freegridItem", "freegridBox"];
5
6
  const parsePath = path => path?.split("|").map(m => parseInt(m));
6
7
  const selectAll = (event, {
@@ -157,7 +158,7 @@ const onBringBack = (event, {
157
158
  console.log(err);
158
159
  }
159
160
  };
160
- export const onInsertFragment = async ({
161
+ export const onInsertFragment = ({
161
162
  editor,
162
163
  slateNodes
163
164
  }) => {
@@ -181,6 +182,20 @@ export const onInsertFragment = async ({
181
182
  setSelectedElement: window.updateSelectedItem
182
183
  });
183
184
  }
185
+ } else {
186
+ ReactEditor.focus(editor);
187
+ if (editor.children.length === 0) {
188
+ Transforms.insertNodes(editor, {
189
+ text: ""
190
+ }, {
191
+ at: [0]
192
+ });
193
+ }
194
+ Transforms.insertNodes(editor, [{
195
+ ...slateNodes
196
+ }], {
197
+ at: [editor.children.length - 1]
198
+ });
184
199
  }
185
200
  } catch (err) {
186
201
  console.log(err);
@@ -543,8 +543,8 @@ export const getBlock = props => {
543
543
  return /*#__PURE__*/_jsx("span", {
544
544
  ...attributes,
545
545
  ...element.attr,
546
- contentEditable: false,
547
546
  className: "temp-focus-node",
547
+ contentEditable: false,
548
548
  children: children
549
549
  });
550
550
  default:
@@ -1,4 +1,4 @@
1
- import { Editor, Node, Transforms, Element } from "slate";
1
+ import { Editor, Node, Transforms, Element, Path } from "slate";
2
2
  import { ReactEditor } from "slate-react";
3
3
  import insertNewLine from "./insertNewLine";
4
4
  import { getDevice } from "../helper/theme";
@@ -470,4 +470,20 @@ export const editorThemeStyle = {
470
470
  };
471
471
  export const getEditorTheme = (themeType = "light") => {
472
472
  return editorThemeStyle[themeType] || {};
473
+ };
474
+ export const isFreeGrid = (nodes, types = ["freegrid", "freegridItem", "freegridBox"]) => {
475
+ try {
476
+ for (const node of nodes) {
477
+ if (types.includes(node.type)) {
478
+ return true;
479
+ }
480
+ if (node.children && isFreeGrid(node.children, types)) {
481
+ return true;
482
+ }
483
+ }
484
+ return false;
485
+ } catch (err) {
486
+ console.log('isFreeGrid error:', err);
487
+ return false;
488
+ }
473
489
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "4.4.9",
3
+ "version": "4.5.1",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"