@flozy/editor 4.4.8 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/dist/Editor/ChatEditor.js +2 -14
  2. package/dist/Editor/CommonEditor.js +17 -34
  3. package/dist/Editor/Editor.css +7 -1
  4. package/dist/Editor/Elements/AI/AIInput.js +4 -5
  5. package/dist/Editor/Elements/AI/PopoverAIInput.js +40 -29
  6. package/dist/Editor/Elements/AI/Styles.js +1 -1
  7. package/dist/Editor/Elements/Button/EditorButton.js +8 -4
  8. package/dist/Editor/Elements/Embed/Embed.css +1 -1
  9. package/dist/Editor/Elements/Embed/Image.js +4 -3
  10. package/dist/Editor/Elements/Embed/Video.js +4 -4
  11. package/dist/Editor/Elements/Form/Form.js +0 -1
  12. package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +3 -12
  13. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +27 -0
  14. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +2 -0
  15. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +3 -1
  16. package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +4 -0
  17. package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +5 -1
  18. package/dist/Editor/Elements/FreeGrid/styles.js +74 -1
  19. package/dist/Editor/Elements/Mentions/Mentions.js +2 -3
  20. package/dist/Editor/Elements/Signature/SignaturePopup.js +7 -3
  21. package/dist/Editor/Elements/Signature/Signed.js +1 -1
  22. package/dist/Editor/Elements/SimpleText/index.js +3 -2
  23. package/dist/Editor/Elements/Table/TableRow.js +1 -1
  24. package/dist/Editor/Styles/EditorStyles.js +2 -2
  25. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
  26. package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +35 -29
  27. package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +35 -30
  28. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -4
  29. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +22 -38
  30. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +0 -1
  31. package/dist/Editor/Toolbar/PopupTool/index.js +5 -5
  32. package/dist/Editor/common/FontLoader/FontLoader.js +6 -6
  33. package/dist/Editor/common/Icon.js +1 -1
  34. package/dist/Editor/common/RnD/DragOver/index.js +0 -1
  35. package/dist/Editor/common/RnD/ElementOptions/Actions.js +14 -1
  36. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -1
  37. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +53 -0
  38. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +32 -2
  39. package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +2 -1
  40. package/dist/Editor/common/RnD/Utils/gridDropItem.js +5 -3
  41. package/dist/Editor/common/RnD/index.js +64 -30
  42. package/dist/Editor/common/Section/index.js +11 -1
  43. package/dist/Editor/common/Section/styles.js +16 -0
  44. package/dist/Editor/common/Shorthands/mentions.js +1 -1
  45. package/dist/Editor/helper/RnD/focusNode.js +74 -0
  46. package/dist/Editor/helper/index.js +4 -2
  47. package/dist/Editor/hooks/useBreakpoints.js +1 -1
  48. package/dist/Editor/hooks/useDragging.js +51 -0
  49. package/dist/Editor/hooks/useMentions.js +13 -39
  50. package/dist/Editor/hooks/useMouseMove.js +5 -1
  51. package/dist/Editor/hooks/withCommon.js +3 -7
  52. package/dist/Editor/hooks/withRestrictedNodes.js +48 -0
  53. package/dist/Editor/plugins/withHTML.js +0 -29
  54. package/dist/Editor/utils/Decorators/highlightSelection.js +16 -0
  55. package/dist/Editor/utils/Decorators/index.js +3 -2
  56. package/dist/Editor/utils/RnD/RnDCtrlCmds.js +13 -1
  57. package/dist/Editor/utils/SlateUtilityFunctions.js +18 -0
  58. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +24 -1
  59. package/dist/Editor/utils/customHooks/useResize.js +4 -5
  60. package/dist/Editor/utils/events.js +36 -0
  61. package/dist/Editor/utils/helper.js +14 -5
  62. package/package.json +1 -1
@@ -0,0 +1,53 @@
1
+ import SignaturePopup from "../../../../Elements/Signature/SignaturePopup";
2
+ import { Path, Transforms } from "slate";
3
+ import { formatDate } from "../../../../utils/helper";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ const Signature = props => {
7
+ const {
8
+ onClose,
9
+ customProps,
10
+ editor,
11
+ path
12
+ } = props;
13
+ const pPath = path?.split("|")?.map(m => parseInt(m));
14
+ const element_path = [...pPath, 0];
15
+ const onSave = (data = {}) => {
16
+ onClear();
17
+ Transforms.insertNodes(editor, [{
18
+ type: "sign",
19
+ signature: null,
20
+ fontFamily: "",
21
+ signedBy: "",
22
+ signedOn: formatDate(new Date(), "MM/DD/YYYY"),
23
+ signedText: "",
24
+ children: [{
25
+ text: ""
26
+ }],
27
+ ...data
28
+ }], {
29
+ at: element_path
30
+ });
31
+ const parentPath = Path.parent(element_path);
32
+ Transforms.setNodes(editor, {
33
+ childType: "sign"
34
+ }, {
35
+ at: parentPath
36
+ });
37
+ };
38
+ const onClear = () => {
39
+ Transforms.removeNodes(editor, {
40
+ at: element_path
41
+ });
42
+ };
43
+ return /*#__PURE__*/_jsx(_Fragment, {
44
+ children: /*#__PURE__*/_jsx(SignaturePopup, {
45
+ onSave: onSave,
46
+ onClear: onClear,
47
+ handleClose: onClose,
48
+ customProps: customProps,
49
+ onlyPopup: true
50
+ })
51
+ });
52
+ };
53
+ export default Signature;
@@ -1,9 +1,39 @@
1
1
  import Settings from "./Settings";
2
2
  import Link from "./Link";
3
3
  import SavePopup from "./SaveAsTemplate";
4
+ import Signature from "./Signature";
5
+ import { Path, Transforms } from "slate";
4
6
  const OtherSettings = {
5
7
  link: Link,
6
8
  settings: Settings,
7
- saveAsTemplate: SavePopup
9
+ saveAsTemplate: SavePopup,
10
+ signatureSettings: Signature
8
11
  };
9
- export default OtherSettings;
12
+ export default OtherSettings;
13
+ export const removeSign = (editor, path = []) => {
14
+ const pPath = path?.split("|")?.map(m => parseInt(m));
15
+ const element_path = [...pPath, 0];
16
+ Transforms.removeNodes(editor, {
17
+ at: element_path
18
+ }); // remove signature
19
+
20
+ Transforms.insertNodes(editor, [{
21
+ type: "signature",
22
+ children: [{
23
+ text: ""
24
+ }],
25
+ data: {
26
+ name: "",
27
+ email: "",
28
+ date: ""
29
+ }
30
+ }], {
31
+ at: element_path
32
+ });
33
+ const parentPath = Path.parent(element_path);
34
+ Transforms.setNodes(editor, {
35
+ childType: "signature"
36
+ }, {
37
+ at: parentPath
38
+ });
39
+ };
@@ -18,5 +18,6 @@ export const ItemTypes = {
18
18
  appHeader: "App Header",
19
19
  form: "Form",
20
20
  table: "Table",
21
- embedScript: "Code"
21
+ embedScript: "Code",
22
+ signature: "Signature"
22
23
  };
@@ -123,8 +123,8 @@ export function onDropItem(props, parentClass) {
123
123
  dragOver,
124
124
  parentPath,
125
125
  path,
126
- diffX,
127
- x: cx,
126
+ // diffX,
127
+ // x: cx,
128
128
  breakpoint
129
129
  // calX,
130
130
  } = props;
@@ -134,7 +134,9 @@ export function onDropItem(props, parentClass) {
134
134
  let newPath = [];
135
135
  newPath = moveTo;
136
136
  const cCalx = isContainerElement(editor, moveTo, props);
137
- const posX = parseInt(cx - window.innerWidth / 2 + MARGIN_OF[breakpoint] - diffX);
137
+ // const posX = parseInt(
138
+ // cx - window.innerWidth / 2 + MARGIN_OF[breakpoint] - diffX
139
+ // );
138
140
  const toSectionNode = Node.get(editor, newPath);
139
141
  const addToSectionDOM = ReactEditor.toDOMNode(editor, toSectionNode);
140
142
  const rect = addToSectionDOM.getBoundingClientRect();
@@ -11,12 +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";
19
+ import { removeSign } from "./ElementSettings/OtherSettings";
20
+ import useDragging from "../../hooks/useDragging";
21
+ import { dragOverOn } from "../../helper/RnD/focusNode";
20
22
  import { jsx as _jsx } from "react/jsx-runtime";
21
23
  import { jsxs as _jsxs } from "react/jsx-runtime";
22
24
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -57,7 +59,6 @@ const RnD = props => {
57
59
  const {
58
60
  isSelectedElement,
59
61
  setSelectedElement,
60
- dragging,
61
62
  updateDragging,
62
63
  contextMenu,
63
64
  setContextMenu,
@@ -75,21 +76,25 @@ const RnD = props => {
75
76
  const open = Boolean(enable);
76
77
  const currentAction = str_path === sp ? selectedAction : null;
77
78
  const positionRef = useRef();
79
+ const {
80
+ draggingRef,
81
+ startDragging,
82
+ stopDragging,
83
+ setDragOver
84
+ } = useDragging();
85
+ const dragging = draggingRef?.current;
78
86
  const {
79
87
  active,
80
88
  id,
81
- parentPath,
82
- dragOver
89
+ parentPath
83
90
  } = dragging;
84
91
  const dragInfoOpen = id === str_path;
85
- const dragOverStatus = dragOver === str_path && parentPath !== str_path;
86
92
  const [absPosition, setAbsPosition] = useState({});
87
93
  const openContextMenu = contextMenu?.path === str_path;
88
94
  const [position, setPosition] = useState({
89
95
  x: 0,
90
96
  y: 0
91
97
  });
92
- const pathIsDragging = dragOver === str_path && dragging?.isDragging;
93
98
  const parentSectionPath = str_path?.split("|").slice(0, 2).join("_");
94
99
  useEffect(() => {
95
100
  if (ITEM_TYPES.includes(type)) {
@@ -225,6 +230,13 @@ const RnD = props => {
225
230
  selectedActionPath: path
226
231
  });
227
232
  break;
233
+ case "signatureSettings":
234
+ setSelectedElement({
235
+ ...selectedElementProps,
236
+ selectedAction: actionType,
237
+ selectedActionPath: path
238
+ });
239
+ break;
228
240
  case "imageFrame":
229
241
  setSelectedElement({
230
242
  ...selectedElementProps,
@@ -233,6 +245,9 @@ const RnD = props => {
233
245
  selectedActionPath: path
234
246
  });
235
247
  break;
248
+ case "removeSign":
249
+ removeSign(editor, sp);
250
+ break;
236
251
  case "saveAsTemplate":
237
252
  const curPath = type === "parent" ? Path.parent(path) : path;
238
253
  const currentNode = Node.get(editor, curPath);
@@ -270,6 +285,7 @@ const RnD = props => {
270
285
  dragOver: null
271
286
  }, null);
272
287
  }
288
+ stopDragging();
273
289
  };
274
290
  const onDragStart = e => {
275
291
  e.preventDefault();
@@ -288,6 +304,9 @@ const RnD = props => {
288
304
  diffX: parseInt(Math.abs(Math.floor(left - e.clientX))),
289
305
  diffY: parseInt(Math.abs(Math.floor(top - e.clientY)))
290
306
  };
307
+ const parentPath = getParentSectionPath({
308
+ ref
309
+ }, ".freegrid-container-parent");
291
310
  updateDragging({
292
311
  ...dragging,
293
312
  active: true,
@@ -300,20 +319,25 @@ const RnD = props => {
300
319
  height
301
320
  },
302
321
  isDragging: 1,
303
- parentPath: getParentSectionPath({
304
- ref
305
- }, ".freegrid-container-parent")
322
+ parentPath
306
323
  });
307
324
  setPosition({
308
325
  ...updatedPosition
309
326
  });
327
+ startDragging({
328
+ active: true,
329
+ id: str_path,
330
+ position: {
331
+ ...updatedPosition
332
+ },
333
+ isDragging: 1,
334
+ parentPath
335
+ });
310
336
  }
311
337
  };
312
- const onDrag = (e, d) => {
338
+ const onDrag = e => {
313
339
  e.preventDefault();
314
- e.stopPropagation();
315
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)");
316
- console.log(lines);
317
341
  setAbsPosition({
318
342
  ...absPosition,
319
343
  "--zIndex": 2000
@@ -333,16 +357,34 @@ const RnD = props => {
333
357
  y: e.clientY,
334
358
  lines: lines
335
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
+ });
336
378
  };
337
379
  const onDragStop = (e, d) => {
338
380
  e.preventDefault();
339
381
  e.stopPropagation();
340
- if (dragging?.isDragging === 2 && dragging?.position?.strXY) {
382
+ if (dragging?.isDragging === 2 && dragging?.position?.strXY && dragging?.dragOver) {
341
383
  d.x = e.x;
342
384
  d.y = e.y;
343
385
  d.offsetX = e.offsetX;
344
386
  d.offsetY = e.offsetY;
345
- d.dragOver = dragOver;
387
+ d.dragOver = dragging?.dragOver;
346
388
  d.parentPath = parentPath;
347
389
  d.diffX = position?.diffX;
348
390
  d.diffY = position?.diffY;
@@ -370,17 +412,11 @@ const RnD = props => {
370
412
  setAbsPosition({
371
413
  ...ud
372
414
  });
415
+ stopDragging();
373
416
  } else {
374
417
  // invalid drags
375
418
  // found in dev mode and in safari browser
376
- updateDragging({
377
- isDragging: 0,
378
- position: {},
379
- lines: [],
380
- active: false,
381
- id: null
382
- });
383
- setPosition({});
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}`,
@@ -104,6 +104,13 @@ const Section = props => {
104
104
  };
105
105
  const isFreeGrid = element?.children?.find(f => f.type === "freegrid");
106
106
  const needHover = element?.children?.find(f => f.type === "grid" && !list_types.includes(element.type)) ? "needHover" : "";
107
+ let tempProps = {};
108
+ if (element?.type === "temp") {
109
+ tempProps = {
110
+ "--left": `${element?.left}px`,
111
+ "--top": `${element?.top}px`
112
+ };
113
+ }
107
114
  const sectionBgImage = sectionBackgroundImage && sectionBackgroundImage !== "none" ? {
108
115
  backgroundImage: `url(${sectionBackgroundImage})`
109
116
  } : {};
@@ -122,7 +129,10 @@ const Section = props => {
122
129
  }, theme);
123
130
  return path.length === 1 && !isFreeGrid ? /*#__PURE__*/_jsxs(Box, {
124
131
  component: "div",
125
- className: `ed-section-wrapper ${readOnly ? "" : "hselect"} ${needHover}`,
132
+ className: `ed-section-wrapper ${readOnly ? "" : "hselect"} ${needHover} is-${element?.type}`,
133
+ style: {
134
+ ...tempProps
135
+ },
126
136
  sx: {
127
137
  ...classes.root,
128
138
  background: sectionBgColor,
@@ -52,6 +52,22 @@ const SectionStyle = theme => ({
52
52
  [theme.breakpoints.between("xs", "md")]: {
53
53
  maxWidth: `320px !important`
54
54
  }
55
+ },
56
+ "&.is-temp": {
57
+ position: "fixed",
58
+ background: "transparent",
59
+ padding: "12px",
60
+ width: "10px",
61
+ height: "10px",
62
+ left: 0,
63
+ top: 0,
64
+ bottom: 0,
65
+ right: 0,
66
+ margin: "auto",
67
+ // left: "var(--left)",
68
+ // top: "var(--top)",
69
+ zIndex: 1000,
70
+ pointerEvents: "none"
55
71
  }
56
72
  }
57
73
  });
@@ -3,6 +3,6 @@ const mentions = props => {
3
3
  CHARACTERS,
4
4
  search
5
5
  } = props;
6
- return CHARACTERS.filter(c => c?.name?.toLowerCase()?.startsWith(search?.toLowerCase())).slice(0, 10);
6
+ return CHARACTERS.filter(c => c.name.toLowerCase().startsWith(search?.toLowerCase())).slice(0, 10);
7
7
  };
8
8
  export default mentions;
@@ -0,0 +1,74 @@
1
+ import { Editor, Transforms } from "slate";
2
+ import { ReactEditor } from "slate-react";
3
+ const TEMP_NODE_ID = "temp-focus-node";
4
+ const ensureTemporaryFocusNode = (editor, selectedDOM) => {
5
+ // Check if the temporary focus node already exists
6
+ const {
7
+ left,
8
+ top
9
+ } = selectedDOM?.getBoundingClientRect();
10
+ const [tempNodeEntry] = Editor.nodes(editor, {
11
+ at: [],
12
+ match: n => n.temp === TEMP_NODE_ID
13
+ });
14
+ if (!tempNodeEntry) {
15
+ // If not, insert the temporary focus node at the start of the editor
16
+ Transforms.insertNodes(editor, {
17
+ type: "temp",
18
+ temp: TEMP_NODE_ID,
19
+ children: [{
20
+ type: "restrictedType",
21
+ text: ""
22
+ }],
23
+ left,
24
+ top
25
+ }, {
26
+ at: [editor.children.length]
27
+ });
28
+ }
29
+ };
30
+ export const focusUsingTemporaryNode = (editor, selectedDOM) => {
31
+ Transforms.deselect(editor);
32
+
33
+ // Ensure the temporary node exists
34
+ ensureTemporaryFocusNode(editor, selectedDOM);
35
+
36
+ // Select the temporary node without causing scroll
37
+ const [tempNodeEntry] = Editor.nodes(editor, {
38
+ at: [],
39
+ match: n => n.temp === TEMP_NODE_ID
40
+ });
41
+ if (tempNodeEntry) {
42
+ const [, path] = tempNodeEntry;
43
+ Transforms.select(editor, path);
44
+ }
45
+ ReactEditor.focus(editor);
46
+ };
47
+ export const cleanupTemporaryFocusNode = editor => {
48
+ // Remove the temporary focus node if it exists
49
+ for (const [, path] of Editor.nodes(editor, {
50
+ at: [],
51
+ match: n => n.temp === TEMP_NODE_ID
52
+ })) {
53
+ Transforms.removeNodes(editor, {
54
+ at: path
55
+ });
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
+ }
74
+ };
@@ -4,6 +4,7 @@ import html2canvas from "html2canvas";
4
4
  import { rectIntersection, closestCenter } from "@dnd-kit/core";
5
5
  import { getQueryStrings } from "../utils/SlateUtilityFunctions";
6
6
  import { Node } from "slate";
7
+ // import { focusUsingTemporaryNode } from "./RnD/focusNode";
7
8
  const HIDE_PLACHOLDERS = ["grid", "grid-item", "table"];
8
9
  const PREVIEW_IMAGE_HIDE_CLASS = ["grid-container-toolbar", "grid-item-toolbar", "element-toolbar", "mini-tool-wrpr-ei", "element-selector", "element-selector-ctrl"];
9
10
  const RND_ITEMS = ["freegridItem", "freegridBox"];
@@ -254,8 +255,9 @@ export const focusSelection = (editor, {
254
255
  const selectedDOM = ReactEditor.toDOMNode(editor, selectedNode);
255
256
  selectedDOM.scrollIntoView({
256
257
  behavior: "smooth",
257
- block: "center"
258
+ block: "nearest"
258
259
  });
260
+ // focusUsingTemporaryNode(editor, selectedDOM);
259
261
  } catch (err) {
260
262
  console.log(err);
261
263
  }
@@ -302,7 +304,7 @@ export const getTextColor = (color = "") => {
302
304
  WebkitTextFillColor: "transparent !important",
303
305
  color: "transparent !important",
304
306
  caretColor: "black",
305
- '& span': {
307
+ "& span": {
306
308
  color: "transparent !important"
307
309
  }
308
310
  } : {
@@ -1,6 +1,6 @@
1
1
  import { useMediaQuery } from "@mui/material";
2
2
  export const STIMULATOR_MOCK = {
3
- xs: "@media (min-width: 1200px) and (max-width: 7680px)"
3
+ xs: "@media (min-width: 1200px) and (max-width: 1980px)"
4
4
  };
5
5
  export const isStimulator = () => {
6
6
  try {
@@ -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;
@@ -13,7 +13,7 @@ const getStartEnd = ({
13
13
  // Get start and end, modify it as we move along.
14
14
  let [start, end] = Range.edges(selection);
15
15
 
16
- // Move backwards to find the start of the word
16
+ // Move backwards
17
17
  while (true) {
18
18
  const before = Editor.before(editor, start, {
19
19
  unit: "character"
@@ -22,15 +22,16 @@ const getStartEnd = ({
22
22
  anchor: before,
23
23
  focus: start
24
24
  });
25
- if (before) {
26
- if (wordBefore.trim() === "") {
27
- break;
28
- } else if (SHORTHAND_CMDS.indexOf(wordBefore) < 0) {
29
- start = before;
30
- } else {
31
- start = before;
25
+ if (before && wordBefore && SHORTHAND_CMDS.indexOf(wordBefore) < 0) {
26
+ start = before;
27
+ if (start.offset === 0) {
28
+ // Means we've wrapped to beginning of another block
32
29
  break;
33
30
  }
31
+ } else if (SHORTHAND_CMDS.indexOf(wordBefore) >= 0) {
32
+ // reached the character end
33
+ start = before;
34
+ break;
34
35
  } else {
35
36
  break;
36
37
  }
@@ -40,38 +41,11 @@ const getStartEnd = ({
40
41
  focus: end
41
42
  };
42
43
  const word = Editor.string(editor, wordRange);
43
- const firstChar = word[0];
44
-
45
- // Handle the commands
46
- if (firstChar === '@') {
47
- // Only trigger @ if preceded by a space
48
- const isPrecededBySpace = Editor.string(editor, {
49
- anchor: {
50
- path: start.path,
51
- offset: start.offset - 1
52
- },
53
- focus: start
54
- }).trim() === "";
55
- if (isPrecededBySpace) {
56
- return {
57
- word,
58
- search: word.substring(1),
59
- target: wordRange,
60
- type: TYPES[firstChar]
61
- };
62
- }
63
- } else if (firstChar === '/') {
64
- return {
65
- word,
66
- search: word.substring(1),
67
- target: wordRange,
68
- type: TYPES[firstChar]
69
- };
70
- }
71
44
  return {
72
- word: "",
73
- wordRange: null,
74
- type: null
45
+ word,
46
+ search: word?.substring(1, word.length),
47
+ target: wordRange,
48
+ type: TYPES[word[0]]
75
49
  };
76
50
  } catch (err) {
77
51
  return {
@@ -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,12 +9,8 @@ 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
- const withCommon = (props, {
13
- needLayout = false,
14
- isChatEditor = false
15
- }) => {
16
- const editor = needLayout ? withErrorHandling(withHtml(withEquation(withLayout(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))))) : withErrorHandling(withHtml(withEquation(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))));
17
- editor.isChatEditor = isChatEditor;
18
- return editor;
12
+ import withRestrictedNodes from "./withRestrictedNodes";
13
+ const withCommon = (props, rest = {}) => {
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))))))))));
19
15
  };
20
16
  export default withCommon;