@flozy/editor 4.6.5 → 4.6.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -93,9 +93,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
93
93
  data: content
94
94
  });
95
95
  const [value, setValue] = useState(convertedContent);
96
- const [loadedValue] = useState(value);
97
96
  const [isInteracted, setIsInteracted] = useState(false);
98
- const [deboundedValue] = useDebounce(value, 500);
99
97
  const [fullScreen, setFullScreen] = useState(false);
100
98
  const [toolbarShow, setToolbarShow] = useState(true);
101
99
  const [isDrawerOpen, setIsDrawerOpen] = useState(false);
@@ -105,6 +103,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
105
103
  });
106
104
  const [isTextSelected, setIsTextSelected] = useState(false);
107
105
  const [breakpoint, setBreakpoint] = useState("");
106
+ const debouncedValue = useRef(value);
108
107
  const [size] = useWindowResize();
109
108
  const {
110
109
  needDotsBG,
@@ -153,15 +152,18 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
153
152
  ReactEditor.focus(editor);
154
153
  }
155
154
  }, [id, content]);
156
- useEffect(() => {
157
- if (editorWrapper && editorWrapper?.current && JSON.stringify(loadedValue) !== JSON.stringify(deboundedValue) && isInteracted && onSave) {
158
- const {
159
- value: strVal,
160
- ...restVal
161
- } = getOnSaveData(deboundedValue);
162
- onSave(strVal, restVal);
163
- }
164
- }, [deboundedValue]);
155
+ const debounced = useDebouncedCallback(
156
+ // function
157
+ value => {
158
+ const {
159
+ value: strVal,
160
+ ...restVal
161
+ } = getOnSaveData(value);
162
+ debouncedValue.current = value;
163
+ onSave(strVal, restVal);
164
+ },
165
+ // delay in ms
166
+ 500);
165
167
  const getOnSaveData = val => {
166
168
  const text = serializeToText(val);
167
169
  const title = val?.find(f => f.type === "title");
@@ -205,7 +207,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
205
207
  return editor;
206
208
  },
207
209
  getContent() {
208
- return getOnSaveData(deboundedValue);
210
+ return getOnSaveData(debouncedValue?.current);
209
211
  },
210
212
  insertFragments(fragments, clearAll = false, rest = {}) {
211
213
  try {
@@ -294,7 +296,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
294
296
  hideTools: updatedHideTools || []
295
297
  }) : [];
296
298
  const handleEditorChange = newValue => {
297
- setValue(newValue);
299
+ debounced(newValue);
298
300
  if (!isInteracted) {
299
301
  setIsInteracted(true);
300
302
  }
@@ -129,7 +129,6 @@ function AppHeader(props) {
129
129
  }
130
130
  };
131
131
  const drawer = /*#__PURE__*/_jsxs(Box, {
132
- onClick: handleDrawerToggle,
133
132
  sx: {
134
133
  textAlign: "center"
135
134
  },
@@ -139,6 +138,7 @@ function AppHeader(props) {
139
138
  my: 2,
140
139
  color: textColor
141
140
  },
141
+ onClick: closeDrawer,
142
142
  children: appLogo && appLogo !== "none" ? /*#__PURE__*/_jsx("img", {
143
143
  alt: `${appTitle} Logo`,
144
144
  style: {
@@ -150,16 +150,20 @@ function AppHeader(props) {
150
150
  }), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsx(List, {
151
151
  children: menus.map((item, i) => {
152
152
  const buttonProps = handleLinkType(item.url, item.linkType, true, item.target === "_blank");
153
+ const onButtonClick = e => {
154
+ closeDrawer();
155
+ setTimeout(() => {
156
+ buttonProps?.onClick(e);
157
+ }, 200);
158
+ };
153
159
  const onTouchEnd = e => {
154
160
  if (buttonProps?.onTouchEnd) {
155
- buttonProps?.onTouchEnd(e);
156
- closeDrawer();
161
+ onButtonClick(e);
157
162
  }
158
163
  };
159
164
  const onClick = e => {
160
165
  if (buttonProps?.onClick) {
161
- buttonProps?.onClick(e);
162
- closeDrawer();
166
+ onButtonClick(e);
163
167
  }
164
168
  };
165
169
  const props = {
@@ -171,6 +175,9 @@ function AppHeader(props) {
171
175
  disablePadding: true,
172
176
  children: /*#__PURE__*/_jsx(ListItemButton, {
173
177
  ...props,
178
+ component: "button",
179
+ href: "" // to avoid <a> tag
180
+ ,
174
181
  sx: {
175
182
  textAlign: "center"
176
183
  },
@@ -33,6 +33,7 @@ const Divider = props => {
33
33
  } = useEditorContext();
34
34
  const [showTool] = useEditorSelection(editor);
35
35
  const selected = hoverPath === path.join(",");
36
+ const width = borderWidth?.includes('px') ? borderWidth : `${borderWidth}px`;
36
37
  const onSettings = () => {
37
38
  setOpenSettings(true);
38
39
  };
@@ -116,7 +117,7 @@ const Divider = props => {
116
117
  className: "editorDivider",
117
118
  style: {
118
119
  userSelect: "none",
119
- borderTop: !borderColor?.includes("linear") ? `${borderWidth} ${borderStyle} ${borderColor}` : `transparent`,
120
+ borderTop: !borderColor?.includes("linear") ? `${width} ${borderStyle} ${borderColor}` : `transparent`,
120
121
  backgroundImage: borderColor?.includes("linear") ? borderColor : "none",
121
122
  height: borderColor?.includes("linear") ? borderWidth : undefined
122
123
  }
@@ -241,6 +241,7 @@ const FreeGrid = props => {
241
241
  children: [{
242
242
  type: "image",
243
243
  url: "",
244
+ objectFit: true,
244
245
  images: [],
245
246
  children: [{
246
247
  text: ""
@@ -1,14 +1,7 @@
1
1
  import React from "react";
2
- import { useSlateStatic } from "slate-react";
3
2
  import RedoIcon from "../../assets/svg/RedoIcon";
4
3
  import { jsx as _jsx } from "react/jsx-runtime";
5
4
  const RedoButton = () => {
6
- const editor = useSlateStatic();
7
- const onRedo = () => {
8
- editor?.redo();
9
- };
10
- return /*#__PURE__*/_jsx(RedoIcon, {
11
- onClick: onRedo
12
- });
5
+ return /*#__PURE__*/_jsx(RedoIcon, {});
13
6
  };
14
7
  export default RedoButton;
@@ -1,14 +1,7 @@
1
1
  import React from "react";
2
- import { useSlateStatic } from "slate-react";
3
2
  import UndoIcon from "../../assets/svg/UndoIcon";
4
3
  import { jsx as _jsx } from "react/jsx-runtime";
5
4
  const UndoButton = () => {
6
- const editor = useSlateStatic();
7
- const onUndo = () => {
8
- editor?.undo();
9
- };
10
- return /*#__PURE__*/_jsx(UndoIcon, {
11
- onClick: onUndo
12
- });
5
+ return /*#__PURE__*/_jsx(UndoIcon, {});
13
6
  };
14
7
  export default UndoButton;
@@ -42,6 +42,8 @@ const MiniToolbar = props => {
42
42
  const [popper, setPopper] = useState(null);
43
43
  const [anchorEl, setAnchorEl] = useState(null);
44
44
  const [fullScreen, setFullScreen] = useState(false);
45
+ const [undoCooldown, setUndoCooldown] = useState(false);
46
+ const [redoCooldown, setRedoCooldown] = useState(false);
45
47
  const [search, setSearch] = useState("");
46
48
  const PopupComponent = POPUP_TYPES[popper] || null;
47
49
  const open = Boolean(PopupComponent);
@@ -56,8 +58,9 @@ const MiniToolbar = props => {
56
58
  selectedElement,
57
59
  setSelectedElement
58
60
  } = useEditorContext();
59
- const canUndo = editor.history.undos.length > 0;
60
- const canRedo = editor.history.redos.length > 0;
61
+ const cooldownTime = 200;
62
+ const canUndo = editor.history.undos.length > 0 && !undoCooldown;
63
+ const canRedo = editor.history.redos.length > 0 && !redoCooldown;
61
64
  const [toolTip, setToolTip] = useState(false);
62
65
  const [data, setData] = useState(null);
63
66
  useEffect(() => {
@@ -72,6 +75,18 @@ const MiniToolbar = props => {
72
75
  }
73
76
  }, [editor.selection]);
74
77
  const handleClick = type => e => {
78
+ if (type === "undo" && canUndo && !undoCooldown) {
79
+ editor.undo();
80
+ setUndoCooldown(true);
81
+ setTimeout(() => setUndoCooldown(false), cooldownTime);
82
+ return;
83
+ }
84
+ if (type === "redo" && canRedo && !redoCooldown) {
85
+ editor.redo();
86
+ setRedoCooldown(true);
87
+ setTimeout(() => setRedoCooldown(false), cooldownTime);
88
+ return;
89
+ }
75
90
  if (type === "page-settings") {
76
91
  setToolTip(true);
77
92
  }
@@ -129,7 +144,7 @@ const MiniToolbar = props => {
129
144
  title: label,
130
145
  disableHoverListener: toolTip,
131
146
  children: /*#__PURE__*/_jsx(IconButton, {
132
- className: `${type === popper ? "active" : ""} ${type === "undo" && !canUndo || type === "redo" && !canRedo ? "disabled" : ""}`,
147
+ className: `${type === popper ? "active" : ""} ${type === "undo" && !canUndo || type === "redo" && !canRedo ? "disabled" : ""} ${type === "undo" ? canUndo ? "activeUndo" : "disabledUndo" : type === "redo" ? canRedo ? "activeRedo" : "disabledRedo" : ""}`,
133
148
  onClick: handleClick(type),
134
149
  disabled: isDisabled,
135
150
  children: type === "page-settings" ? /*#__PURE__*/_jsx(PageSettingsButton, {
@@ -28,8 +28,8 @@ const miniToolbarStyles = theme => ({
28
28
  }
29
29
  },
30
30
  "&.mini-tool-wrpr-ei": {
31
- background: theme?.palette?.editor?.background,
32
- borderColor: theme?.palette?.editor?.borderColor,
31
+ background: theme?.palette?.editor?.miniToolBarBackground,
32
+ border: `1px solid ${theme?.palette?.editor?.miniToolBarBorder} !important`,
33
33
  "& button": {
34
34
  "& svg": {
35
35
  stroke: theme?.palette?.editor?.svgStroke
@@ -42,9 +42,37 @@ const miniToolbarStyles = theme => ({
42
42
  stroke: theme?.palette?.editor?.activeColor
43
43
  }
44
44
  },
45
+ "&.activeUndo": {
46
+ "& svg": {
47
+ "& path": {
48
+ stroke: theme?.palette?.editor?.miniToolBarSvgStroke
49
+ }
50
+ }
51
+ },
52
+ "&.activeRedo": {
53
+ "& svg": {
54
+ "& path": {
55
+ stroke: theme?.palette?.editor?.miniToolBarSvgStroke
56
+ }
57
+ }
58
+ },
59
+ "&.disabledRedo": {
60
+ "& svg": {
61
+ "& path": {
62
+ stroke: theme?.palette?.editor?.miniToolBarSvgStrokeDiabled
63
+ }
64
+ }
65
+ },
66
+ "&.disabledUndo": {
67
+ "& svg": {
68
+ "& path": {
69
+ stroke: theme?.palette?.editor?.miniToolBarSvgStrokeDiabled
70
+ }
71
+ }
72
+ },
45
73
  "&.disabled": {
46
74
  "& svg": {
47
- '& path': {
75
+ "& path": {
48
76
  stroke: theme?.palette?.editor?.svgStrokeDisabled
49
77
  }
50
78
  }
@@ -112,19 +112,7 @@ const PopupTool = props => {
112
112
  anchorEl: anchorEl,
113
113
  transition: true,
114
114
  sx: classes.popupWrapper,
115
- placement: "bottom-start" // or "top" depending on the preferred direction
116
- ,
117
- modifiers: [{
118
- name: "preventOverflow",
119
- options: {
120
- boundary: editorWrapper?.current
121
- }
122
- }, {
123
- name: "flip",
124
- options: {
125
- fallbackPlacements: ["top-start", "bottom-start"]
126
- }
127
- }],
115
+ placement: "top-start",
128
116
  children: ({
129
117
  TransitionProps
130
118
  }) => /*#__PURE__*/_jsx(Fade, {
@@ -7,7 +7,7 @@ import TuneIcon from "@mui/icons-material/Tune";
7
7
  import SectionPopup from "../../Elements/Grid/SectionPopup";
8
8
  import { getBreakPointsValue, getTRBLBreakPoints, groupByBreakpoint } from "../../helper/theme";
9
9
  import DragHandle from "../DnD/DragHandleButton";
10
- import { useEditorSelection } from "../../hooks/useMouseMove";
10
+ import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
11
11
  import SectionStyle from "./styles";
12
12
  import useWindowResize from "../../hooks/useWindowResize";
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -15,8 +15,9 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
15
15
  import { Fragment as _Fragment } from "react/jsx-runtime";
16
16
  const list_types = ["orderedList", "unorderedList"];
17
17
  const Section = props => {
18
- const theme = useTheme();
19
- const classes = SectionStyle(theme);
18
+ const themeReact = useTheme();
19
+ const theme = useEditorContext();
20
+ const classes = SectionStyle(themeReact, theme?.theme);
20
21
  const {
21
22
  children,
22
23
  element,
@@ -1,4 +1,4 @@
1
- const SectionStyle = theme => ({
1
+ const SectionStyle = (themeReact, theme) => ({
2
2
  root: {
3
3
  "&:hover": {
4
4
  "& .dh-para": {
@@ -42,14 +42,14 @@ const SectionStyle = theme => ({
42
42
  },
43
43
  "&:hover": {
44
44
  opacity: 1,
45
- background: "#eee"
45
+ background: theme?.palette?.editor?.sectionSettingIconHover
46
46
  },
47
47
  "&.active": {
48
48
  opacity: 1
49
49
  }
50
50
  },
51
51
  "& .ed-section-inner": {
52
- [theme.breakpoints.between("xs", "md")]: {
52
+ [themeReact.breakpoints.between("xs", "md")]: {
53
53
  maxWidth: `320px !important`
54
54
  }
55
55
  },
@@ -2140,37 +2140,7 @@ export const InfinityIcon = () => /*#__PURE__*/_jsxs("svg", {
2140
2140
  viewBox: "0 0 22 14",
2141
2141
  fill: "none",
2142
2142
  xmlns: "http://www.w3.org/2000/svg",
2143
- children: [/*#__PURE__*/_jsx("path", {
2144
- d: "M0.915756 6.95902C1.12067 5.41363 1.86206 4.92055 2.20714 4.86719C2.08975 5.03795 1.83787 5.44564 1.76957 5.71032C1.68419 6.04118 1.63082 6.95902 2.20714 7.8662C2.78347 8.77337 3.81871 9.29633 4.81127 9.60583C5.60531 9.85344 6.3588 9.80861 6.63628 9.75525C6.89243 9.76592 6.67063 10.0044 5.73978 10.3422C4.71521 10.7158 3.59459 10.8118 2.66607 10.2889C1.73755 9.76592 0.659613 8.89077 0.915756 6.95902Z",
2145
- fill: "url(#paint0_linear_3_7)"
2146
- }), /*#__PURE__*/_jsx("path", {
2147
- d: "M0.915756 6.95902C1.12067 5.41363 1.86206 4.92055 2.20714 4.86719C2.08975 5.03795 1.83787 5.44564 1.76957 5.71032C1.68419 6.04118 1.63082 6.95902 2.20714 7.86619C2.46246 8.26809 2.80785 8.59457 3.1997 8.8605C3.37046 8.9548 3.4345 9.01884 3.4345 9.01884C3.16768 9.0722 2.75145 9.13624 2.20714 9.01884C1.66284 8.90144 1.13988 8.59193 0.930734 8.12234C0.868272 7.78378 0.857446 7.39878 0.915756 6.95902Z",
2148
- fill: "url(#paint1_linear_3_7)"
2149
- }), /*#__PURE__*/_jsx("path", {
2150
- d: "M2.15304 9.10612C1.64075 8.44442 1.13537 7.33708 1.77573 5.71484C1.63699 6.18444 1.83445 7.07297 2.01589 7.52122C2.19732 7.96947 2.89531 8.8014 4.05821 9.35159C5.05076 9.82119 6.23709 9.82119 6.79562 9.7785C6.50746 9.91368 5.69208 10.1862 4.73581 10.1947C3.54047 10.2054 2.74003 9.69312 2.15304 9.10612Z",
2151
- fill: "url(#paint2_linear_3_7)"
2152
- }), /*#__PURE__*/_jsx("path", {
2153
- d: "M16.4362 12.7797C18.4637 12.4072 19.9581 11.4316 21.144 9.00646C20.8404 9.27254 20.1806 9.908 19.6785 10.2241C19.0509 10.6192 17.887 11.0693 17.4547 11.5271C16.6737 12.2487 15.4362 12.6472 14.9104 12.7027C14.3846 12.7582 14.6598 13.0473 16.4362 12.7797Z",
2154
- fill: "url(#paint3_linear_3_7)"
2155
- }), /*#__PURE__*/_jsx("path", {
2156
- d: "M2.48878 3.38168C0.992124 4.16676 0.598877 5.99203 0.70329 7.17193C0.807704 8.35183 1.11378 8.54174 1.05295 8.43731C0.854563 7.0486 1.11051 5.49084 2.22774 5.08363C3.34498 4.67641 4.43089 5.58482 5.38106 6.50366C6.33123 7.42251 8.16893 9.05138 8.87895 9.7614C9.58897 10.4714 12.3107 12.7602 14.3781 12.8751C16.2993 12.9818 17.3539 11.9667 18.151 10.9726C18.6301 10.3751 19.0072 8.91564 18.8192 9.09315C18.6313 9.27065 18.1196 9.75096 17.159 10.012C16.1984 10.273 14.9454 10.1477 13.8595 9.81361C12.7736 9.47948 11.364 8.50842 10.4765 7.69399C9.58897 6.87956 7.43803 4.71818 6.44609 3.97684C5.45415 3.2355 3.92934 2.62603 2.48878 3.38168Z",
2157
- fill: "url(#paint4_linear_3_7)"
2158
- }), /*#__PURE__*/_jsx("path", {
2159
- d: "M6.45603 3.95461C5.46409 3.21327 3.91876 2.5659 2.49872 3.35945C1.47193 3.95461 1.20045 4.64584 1.35708 4.46834C1.5137 4.29083 2.63093 2.78726 4.46863 3.7792C6.30632 4.77114 8.20667 7.35018 9.72068 8.77022C11.2347 10.1903 12.2754 11.0256 13.8695 11.4954C15.4635 11.9653 17.4927 11.6583 18.1609 10.9504C18.6401 10.3528 19.0171 8.89341 18.8292 9.07092C18.6412 9.24842 18.1296 9.72873 17.169 9.98976C16.2083 10.2508 14.9554 10.1255 13.8695 9.79138C12.7836 9.45725 11.374 8.48619 10.4864 7.67176C9.59891 6.85733 7.44797 4.69595 6.45603 3.95461Z",
2160
- fill: "url(#paint5_linear_3_7)"
2161
- }), /*#__PURE__*/_jsx("path", {
2162
- d: "M17.9698 11.1279C17.8237 11.2845 19.0573 10.8051 20.2477 9.87581C20.6099 9.593 20.7786 9.48856 21.0188 9.21708C21.2432 8.96331 21.699 7.3072 21.699 6.5241C21.6573 4.937 21.2393 3.94621 21.1456 3.74576C21.0187 3.47416 20.977 3.35945 21.0188 4.16344C21.0605 4.96743 20.9561 6.05334 20.5071 6.99307C19.9328 7.9328 19.5778 8.18338 18.9618 8.83075C18.826 8.97693 18.8783 9.24843 18.7634 9.593C18.6381 10.0002 18.116 10.9712 17.9698 11.1279Z",
2163
- fill: "url(#paint6_linear_3_7)"
2164
- }), /*#__PURE__*/_jsx("path", {
2165
- d: "M3.44581 9.00993C3.27874 9.06005 3.70684 9.34419 4.91804 9.72008C5.40879 9.82449 6.45294 10.1167 6.92281 9.78272C7.58062 9.47317 9.08419 8.04944 9.72112 7.40207C10.2571 6.89044 11.5713 5.72935 12.5403 5.17804C13.7515 4.48891 15.5579 3.68491 16.9362 4.1339C18.3144 4.58288 18.8574 6.31616 18.8783 7.04706C18.8992 7.77797 18.8783 8.7177 18.8783 8.95785C18.8748 9.0205 18.943 9.05809 19.2437 8.70725C19.6196 8.26871 20.0686 8.04944 20.6429 6.71294C20.8622 6.16302 21.227 4.63509 21.0814 3.78933C20.9556 3.05843 20.6528 2.67209 20.079 2.02472C19.5052 1.37735 18.2309 0.448066 16.696 0.437625C15.1611 0.427183 13.9603 1.07455 13.3025 1.3878C12.1957 1.89943 10.3894 3.26726 9.41832 4.23831C8.43682 5.13628 7.44488 6.13866 6.82884 6.75471C6.336 7.24754 5.60022 7.96243 5.29394 8.25827C4.67789 8.73858 3.68596 8.93789 3.44581 9.00993Z",
2166
- fill: "url(#paint7_linear_3_7)"
2167
- }), /*#__PURE__*/_jsx("path", {
2168
- d: "M6.93299 9.79053C6.50698 9.991 5.41897 9.8323 4.92822 9.72788C5.11809 9.65819 5.74215 9.30791 6.71947 8.46434C7.94112 7.40988 9.69528 5.78076 11.2719 4.78895C13.1618 3.62995 14.9672 3.09756 16.9463 4.1417C15.5681 3.69272 13.7617 4.49671 12.5505 5.18585C11.5815 5.73715 10.2673 6.89824 9.7313 7.40988C9.09437 8.05724 7.5908 9.48097 6.93299 9.79053Z",
2169
- fill: "url(#paint8_linear_3_7)"
2170
- }), /*#__PURE__*/_jsx("path", {
2171
- d: "M19.2123 2.0471C18.3519 1.23685 16.682 1.20831 15.9546 1.29532L20.4235 4.72012C20.4235 4.72012 20.2878 3.05993 19.2123 2.0471Z",
2172
- fill: "url(#paint9_linear_3_7)"
2173
- }), /*#__PURE__*/_jsxs("defs", {
2143
+ children: [/*#__PURE__*/_jsxs("defs", {
2174
2144
  children: [/*#__PURE__*/_jsxs("linearGradient", {
2175
2145
  id: "paint0_linear_3_7",
2176
2146
  x1: "5.86156",
@@ -2310,6 +2280,36 @@ export const InfinityIcon = () => /*#__PURE__*/_jsxs("svg", {
2310
2280
  stopOpacity: "0"
2311
2281
  })]
2312
2282
  })]
2283
+ }), /*#__PURE__*/_jsx("path", {
2284
+ d: "M0.915756 6.95902C1.12067 5.41363 1.86206 4.92055 2.20714 4.86719C2.08975 5.03795 1.83787 5.44564 1.76957 5.71032C1.68419 6.04118 1.63082 6.95902 2.20714 7.8662C2.78347 8.77337 3.81871 9.29633 4.81127 9.60583C5.60531 9.85344 6.3588 9.80861 6.63628 9.75525C6.89243 9.76592 6.67063 10.0044 5.73978 10.3422C4.71521 10.7158 3.59459 10.8118 2.66607 10.2889C1.73755 9.76592 0.659613 8.89077 0.915756 6.95902Z",
2285
+ fill: "url(#paint0_linear_3_7)"
2286
+ }), /*#__PURE__*/_jsx("path", {
2287
+ d: "M0.915756 6.95902C1.12067 5.41363 1.86206 4.92055 2.20714 4.86719C2.08975 5.03795 1.83787 5.44564 1.76957 5.71032C1.68419 6.04118 1.63082 6.95902 2.20714 7.86619C2.46246 8.26809 2.80785 8.59457 3.1997 8.8605C3.37046 8.9548 3.4345 9.01884 3.4345 9.01884C3.16768 9.0722 2.75145 9.13624 2.20714 9.01884C1.66284 8.90144 1.13988 8.59193 0.930734 8.12234C0.868272 7.78378 0.857446 7.39878 0.915756 6.95902Z",
2288
+ fill: "url(#paint1_linear_3_7)"
2289
+ }), /*#__PURE__*/_jsx("path", {
2290
+ d: "M2.15304 9.10612C1.64075 8.44442 1.13537 7.33708 1.77573 5.71484C1.63699 6.18444 1.83445 7.07297 2.01589 7.52122C2.19732 7.96947 2.89531 8.8014 4.05821 9.35159C5.05076 9.82119 6.23709 9.82119 6.79562 9.7785C6.50746 9.91368 5.69208 10.1862 4.73581 10.1947C3.54047 10.2054 2.74003 9.69312 2.15304 9.10612Z",
2291
+ fill: "url(#paint2_linear_3_7)"
2292
+ }), /*#__PURE__*/_jsx("path", {
2293
+ d: "M16.4362 12.7797C18.4637 12.4072 19.9581 11.4316 21.144 9.00646C20.8404 9.27254 20.1806 9.908 19.6785 10.2241C19.0509 10.6192 17.887 11.0693 17.4547 11.5271C16.6737 12.2487 15.4362 12.6472 14.9104 12.7027C14.3846 12.7582 14.6598 13.0473 16.4362 12.7797Z",
2294
+ fill: "url(#paint3_linear_3_7)"
2295
+ }), /*#__PURE__*/_jsx("path", {
2296
+ d: "M2.48878 3.38168C0.992124 4.16676 0.598877 5.99203 0.70329 7.17193C0.807704 8.35183 1.11378 8.54174 1.05295 8.43731C0.854563 7.0486 1.11051 5.49084 2.22774 5.08363C3.34498 4.67641 4.43089 5.58482 5.38106 6.50366C6.33123 7.42251 8.16893 9.05138 8.87895 9.7614C9.58897 10.4714 12.3107 12.7602 14.3781 12.8751C16.2993 12.9818 17.3539 11.9667 18.151 10.9726C18.6301 10.3751 19.0072 8.91564 18.8192 9.09315C18.6313 9.27065 18.1196 9.75096 17.159 10.012C16.1984 10.273 14.9454 10.1477 13.8595 9.81361C12.7736 9.47948 11.364 8.50842 10.4765 7.69399C9.58897 6.87956 7.43803 4.71818 6.44609 3.97684C5.45415 3.2355 3.92934 2.62603 2.48878 3.38168Z",
2297
+ fill: "url(#paint4_linear_3_7)"
2298
+ }), /*#__PURE__*/_jsx("path", {
2299
+ d: "M6.45603 3.95461C5.46409 3.21327 3.91876 2.5659 2.49872 3.35945C1.47193 3.95461 1.20045 4.64584 1.35708 4.46834C1.5137 4.29083 2.63093 2.78726 4.46863 3.7792C6.30632 4.77114 8.20667 7.35018 9.72068 8.77022C11.2347 10.1903 12.2754 11.0256 13.8695 11.4954C15.4635 11.9653 17.4927 11.6583 18.1609 10.9504C18.6401 10.3528 19.0171 8.89341 18.8292 9.07092C18.6412 9.24842 18.1296 9.72873 17.169 9.98976C16.2083 10.2508 14.9554 10.1255 13.8695 9.79138C12.7836 9.45725 11.374 8.48619 10.4864 7.67176C9.59891 6.85733 7.44797 4.69595 6.45603 3.95461Z",
2300
+ fill: "url(#paint5_linear_3_7)"
2301
+ }), /*#__PURE__*/_jsx("path", {
2302
+ d: "M17.9698 11.1279C17.8237 11.2845 19.0573 10.8051 20.2477 9.87581C20.6099 9.593 20.7786 9.48856 21.0188 9.21708C21.2432 8.96331 21.699 7.3072 21.699 6.5241C21.6573 4.937 21.2393 3.94621 21.1456 3.74576C21.0187 3.47416 20.977 3.35945 21.0188 4.16344C21.0605 4.96743 20.9561 6.05334 20.5071 6.99307C19.9328 7.9328 19.5778 8.18338 18.9618 8.83075C18.826 8.97693 18.8783 9.24843 18.7634 9.593C18.6381 10.0002 18.116 10.9712 17.9698 11.1279Z",
2303
+ fill: "url(#paint6_linear_3_7)"
2304
+ }), /*#__PURE__*/_jsx("path", {
2305
+ d: "M3.44581 9.00993C3.27874 9.06005 3.70684 9.34419 4.91804 9.72008C5.40879 9.82449 6.45294 10.1167 6.92281 9.78272C7.58062 9.47317 9.08419 8.04944 9.72112 7.40207C10.2571 6.89044 11.5713 5.72935 12.5403 5.17804C13.7515 4.48891 15.5579 3.68491 16.9362 4.1339C18.3144 4.58288 18.8574 6.31616 18.8783 7.04706C18.8992 7.77797 18.8783 8.7177 18.8783 8.95785C18.8748 9.0205 18.943 9.05809 19.2437 8.70725C19.6196 8.26871 20.0686 8.04944 20.6429 6.71294C20.8622 6.16302 21.227 4.63509 21.0814 3.78933C20.9556 3.05843 20.6528 2.67209 20.079 2.02472C19.5052 1.37735 18.2309 0.448066 16.696 0.437625C15.1611 0.427183 13.9603 1.07455 13.3025 1.3878C12.1957 1.89943 10.3894 3.26726 9.41832 4.23831C8.43682 5.13628 7.44488 6.13866 6.82884 6.75471C6.336 7.24754 5.60022 7.96243 5.29394 8.25827C4.67789 8.73858 3.68596 8.93789 3.44581 9.00993Z",
2306
+ fill: "url(#paint7_linear_3_7)"
2307
+ }), /*#__PURE__*/_jsx("path", {
2308
+ d: "M6.93299 9.79053C6.50698 9.991 5.41897 9.8323 4.92822 9.72788C5.11809 9.65819 5.74215 9.30791 6.71947 8.46434C7.94112 7.40988 9.69528 5.78076 11.2719 4.78895C13.1618 3.62995 14.9672 3.09756 16.9463 4.1417C15.5681 3.69272 13.7617 4.49671 12.5505 5.18585C11.5815 5.73715 10.2673 6.89824 9.7313 7.40988C9.09437 8.05724 7.5908 9.48097 6.93299 9.79053Z",
2309
+ fill: "url(#paint8_linear_3_7)"
2310
+ }), /*#__PURE__*/_jsx("path", {
2311
+ d: "M19.2123 2.0471C18.3519 1.23685 16.682 1.20831 15.9546 1.29532L20.4235 4.72012C20.4235 4.72012 20.2878 3.05993 19.2123 2.0471Z",
2312
+ fill: "url(#paint9_linear_3_7)"
2313
2313
  })]
2314
2314
  });
2315
2315
  export const ResetIcon = () => /*#__PURE__*/_jsxs("svg", {
@@ -98,11 +98,7 @@ export const EditorProvider = ({
98
98
  updateDragging,
99
99
  fontFamilies,
100
100
  setFontFamilies
101
- }), [path, editor?.selection, selectedPath, selectedElement,
102
- // dragging.active,
103
- // dragging.isDragging,
104
- // dragging.dragOver,
105
- contextMenu, openAI, popupType, drop]);
101
+ }), [path, editor?.selection, selectedPath, selectedElement, contextMenu, openAI, popupType, drop]);
106
102
  return /*#__PURE__*/_jsx(EditorContext.Provider, {
107
103
  value: otherValues,
108
104
  children: children
@@ -206,6 +206,7 @@ export const getMarked = (leaf, children, theme) => {
206
206
  }
207
207
  // cover under single span
208
208
  if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || className) {
209
+ console.log("🚀 ~ getMarked ~ leaf:", leaf);
209
210
  const family = leaf?.fontFamily;
210
211
  const textStyles = getTextColor(leaf?.color);
211
212
  children = /*#__PURE__*/_jsx("span", {
@@ -190,7 +190,14 @@ export const enterEvent = (e, editor, isMobile) => {
190
190
  // on shift enter break line in same node
191
191
  if (e.shiftKey && !isMobile) {
192
192
  e.preventDefault();
193
- Transforms.insertText(editor, "\n");
193
+ const [blockquote] = Editor.nodes(editor, {
194
+ match: n => Element.isElement(n) && n.type === "blockquote"
195
+ });
196
+ if (blockquote) {
197
+ Transforms.insertText(editor, "\n");
198
+ } else {
199
+ Transforms.insertText(editor, "\n");
200
+ }
194
201
  } else if (ele && ele[0]) {
195
202
  const {
196
203
  type
@@ -283,39 +290,41 @@ export const enterEvent = (e, editor, isMobile) => {
283
290
  }
284
291
  }
285
292
  // Handle blockquote splitting
286
- const [blockquote] = Editor.nodes(editor, {
287
- match: n => Element.isElement(n) && n.type === "blockquote"
288
- });
289
- if (blockquote) {
290
- e.preventDefault();
291
- const {
292
- selection
293
- } = editor;
294
- if (selection && Range.isCollapsed(selection)) {
295
- const isAtEnd = Editor.isEnd(editor, selection.anchor, blockquote[1]);
296
- if (isAtEnd) {
297
- Transforms.insertNodes(editor, {
298
- type: "paragraph",
299
- children: [{
300
- text: ""
301
- }]
302
- });
303
- const newLocation = Editor.after(editor, selection);
304
- if (newLocation) {
305
- Transforms.select(editor, newLocation);
293
+ if (!e.shiftKey) {
294
+ const [blockquote] = Editor.nodes(editor, {
295
+ match: n => Element.isElement(n) && n.type === "blockquote"
296
+ });
297
+ if (blockquote) {
298
+ e.preventDefault();
299
+ const {
300
+ selection
301
+ } = editor;
302
+ if (selection && Range.isCollapsed(selection)) {
303
+ const isAtEnd = Editor.isEnd(editor, selection.anchor, blockquote[1]);
304
+ if (isAtEnd) {
305
+ Transforms.insertNodes(editor, {
306
+ type: "paragraph",
307
+ children: [{
308
+ text: ""
309
+ }]
310
+ });
311
+ const newLocation = Editor.after(editor, selection);
312
+ if (newLocation) {
313
+ Transforms.select(editor, newLocation);
314
+ }
315
+ } else {
316
+ Transforms.splitNodes(editor, {
317
+ always: true
318
+ });
319
+ Transforms.setNodes(editor, {
320
+ type: "paragraph"
321
+ }, {
322
+ at: editor.selection
323
+ });
306
324
  }
307
- } else {
308
- Transforms.splitNodes(editor, {
309
- always: true
310
- });
311
- Transforms.setNodes(editor, {
312
- type: "paragraph"
313
- }, {
314
- at: editor.selection
315
- });
316
325
  }
326
+ return;
317
327
  }
318
- return;
319
328
  }
320
329
  } catch (err) {
321
330
  console.log(err);
@@ -64,7 +64,7 @@ export const getBorderColor = (color, borderWidth = 3) => {
64
64
  export const absoluteLink = url => {
65
65
  try {
66
66
  if (url?.indexOf("://") === -1) {
67
- return `//${url}`;
67
+ return `/${url}`;
68
68
  }
69
69
  return url;
70
70
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "4.6.5",
3
+ "version": "4.6.7",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"