@flozy/editor 4.1.3 → 4.1.4

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.
@@ -426,16 +426,21 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
426
426
  };
427
427
  const handleCursorScroll = container => {
428
428
  try {
429
- const cursorPosition = window.getSelection()?.getRangeAt(0).getBoundingClientRect();
430
- const containerBottom = container.getBoundingClientRect().bottom;
431
- if (cursorPosition?.bottom > containerBottom - 250) {
432
- container.scrollBy({
433
- top: 200,
434
- behavior: "smooth"
435
- });
429
+ const selection = window?.getSelection();
430
+ if (selection && selection.rangeCount > 0) {
431
+ const cursorPosition = selection.getRangeAt(0)?.getBoundingClientRect();
432
+ const containerBottom = container?.getBoundingClientRect()?.bottom;
433
+ if (cursorPosition && cursorPosition.bottom > containerBottom - 250) {
434
+ container?.scrollBy({
435
+ top: 200,
436
+ behavior: "smooth"
437
+ });
438
+ }
439
+ } else {
440
+ console.warn('No valid selection range found');
436
441
  }
437
442
  } catch (err) {
438
- console.log(err);
443
+ console.log('handleCursorScroll', err);
439
444
  }
440
445
  };
441
446
  return /*#__PURE__*/_jsx(EditorProvider, {
@@ -1,12 +1,12 @@
1
1
  import { useEffect, useRef, useState } from "react";
2
- import useDragDom from "../../../hooks/useDragDom";
3
2
  import { IconButton, Popper } from "@mui/material";
4
3
  import Box from "@mui/material/Box";
5
4
  import ContinuousSlider from "./Slider";
6
- import frames from ".";
7
5
  import { useEditorContext } from "../../../hooks/useMouseMove";
8
6
  import { CloseIcon } from "../../../common/iconslist";
7
+ import useDragDom from "../../../hooks/useDragDom";
9
8
  import FramesStyles from "./Styles";
9
+ import frames from ".";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
12
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -48,18 +48,28 @@ const ImageFrame = props => {
48
48
  const SVGFrame = frame ? frames[frame] : null;
49
49
  const {
50
50
  selectedPath,
51
- setSelectedPath
52
- } = useEditorContext();
53
- const open = selectedPath === id && Boolean(anchorEl);
54
- const {
55
- theme
51
+ setSelectedPath,
52
+ selectedElement,
53
+ theme,
54
+ setSelectedElement
56
55
  } = useEditorContext();
56
+ const freeGridItemPath = `${selectedElement?.path?.split("|")?.join(",")},0`;
57
+ const isFreegridSelection = freeGridItemPath === id;
58
+ const open = (selectedPath === id || isFreegridSelection) && Boolean(anchorEl);
57
59
  const classes = FramesStyles(theme);
58
60
  useEffect(() => {
59
61
  if (imageRef?.current && !readOnly) {
60
62
  setDOM(dom);
61
63
  }
62
64
  }, [imageRef]);
65
+ useEffect(() => {
66
+ if (svgRef?.current && selectedElement?.selectedAction === "imageFrame") {
67
+ const imageFrameDom = document.getElementById(`opt_ref_${selectedElement?.path}`);
68
+ setAnchorEl(imageFrameDom);
69
+ } else {
70
+ setAnchorEl(null);
71
+ }
72
+ }, [isFreegridSelection, svgRef?.current, selectedElement?.selectedAction]);
63
73
  useEffect(() => {
64
74
  if (event === "end" && !readOnly) {
65
75
  onChange({
@@ -97,6 +107,11 @@ const ImageFrame = props => {
97
107
  const handleClose = () => {
98
108
  setAnchorEl(null);
99
109
  setSelectedPath(null);
110
+ setSelectedElement({
111
+ ...selectedElement,
112
+ enable: 1,
113
+ selectedAction: null
114
+ });
100
115
  };
101
116
  return /*#__PURE__*/_jsxs(_Fragment, {
102
117
  children: [/*#__PURE__*/_jsx(SVGFrame, {
@@ -118,8 +133,8 @@ const ImageFrame = props => {
118
133
  sx: {
119
134
  zIndex: 100
120
135
  },
121
- placement: "top",
122
- disablePortal: true,
136
+ placement: isFreegridSelection ? "bottom" : "top",
137
+ disablePortal: false,
123
138
  children: /*#__PURE__*/_jsxs(Box, {
124
139
  sx: classes?.sliderContainer,
125
140
  children: [/*#__PURE__*/_jsx(ContinuousSlider, {
@@ -295,6 +295,7 @@ const Image = ({
295
295
  id: path.join(","),
296
296
  onChange: onPosChange,
297
297
  readOnly: readOnly,
298
+ editor: editor,
298
299
  handleImageClick: handleImageClick
299
300
  })
300
301
  }) : null, selected && !readOnly && /*#__PURE__*/_jsx(IconButton, {
@@ -1,7 +1,7 @@
1
1
  const commonOptions = ["drag", "edit", "settings", "saveAsTemplate", "close"];
2
2
  const textOptions = ["edit", "settings", "link", "saveAsTemplate", "close"];
3
3
  const buttonOptions = ["settings", "link", "saveAsTemplate", "close"];
4
- const imageOptions = ["settings", "link", "saveAsTemplate", "close"];
4
+ const imageOptions = ["settings", "link", "imageFrame", "saveAsTemplate", "close"];
5
5
  const boxOptions = ["settings", "link", "saveAsTemplate", "close"];
6
6
  const appHeaderOptions = ["settings", "saveAsTemplate", "close"];
7
7
  const tableOptions = ["drag", "edit", "settings", "saveAsTemplate", "close"];
@@ -96,6 +96,11 @@ const useFreeGridStyles = ({
96
96
  "& .default-toolbar": {
97
97
  display: "block"
98
98
  }
99
+ },
100
+ "& .fgi_type_image": {
101
+ "& .visible-on-hover": {
102
+ display: "none !important"
103
+ }
99
104
  }
100
105
  },
101
106
  /** for element items */
@@ -11,6 +11,7 @@ import ArrowDownwardIcon from "@mui/icons-material/ArrowDownward";
11
11
  import SaveIcon from "@mui/icons-material/Save";
12
12
  import LinkIcon from "./Icons/LinkIcon";
13
13
  import CodeIcon from "@mui/icons-material/Code";
14
+ import FilterFramesIcon from "@mui/icons-material/FilterFrames";
14
15
  import { GridAddSectionIcon, WorkflowIcon } from "../../iconslist";
15
16
  const Actions = {
16
17
  ai: {
@@ -104,6 +105,12 @@ const Actions = {
104
105
  Button: IconButton,
105
106
  Icon: SaveIcon,
106
107
  title: "Save As Template"
108
+ },
109
+ imageFrame: {
110
+ type: "imageFrame",
111
+ Button: IconButton,
112
+ Icon: FilterFramesIcon,
113
+ title: "Image Frame Settings"
107
114
  }
108
115
  };
109
116
  export default Actions;
@@ -236,6 +236,14 @@ const RnD = props => {
236
236
  selectedActionPath: path
237
237
  });
238
238
  break;
239
+ case "imageFrame":
240
+ setSelectedElement({
241
+ ...selectedElementProps,
242
+ enable: 2,
243
+ selectedAction: actionType,
244
+ selectedActionPath: path
245
+ });
246
+ break;
239
247
  case "saveAsTemplate":
240
248
  const curPath = type === "parent" ? Path.parent(path) : path;
241
249
  const currentNode = Node.get(editor, curPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "4.1.3",
3
+ "version": "4.1.4",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"