@flozy/editor 3.2.3 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -185,29 +185,33 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
185
185
  return getOnSaveData(deboundedValue);
186
186
  },
187
187
  insertFragments(fragments, clearAll = false, rest = {}) {
188
- if (!clearAll) {
189
- if (rest?.nextLine) {
190
- const {
191
- anchor
192
- } = editor?.selection || {};
193
- if (anchor?.path !== undefined && anchor?.path[0] !== undefined) {
194
- editor.insertNode(fragments, {
195
- at: [anchor?.path[0] + 1]
196
- });
188
+ try {
189
+ if (!clearAll) {
190
+ if (rest?.nextLine) {
191
+ const {
192
+ anchor
193
+ } = editor?.selection || {};
194
+ if (anchor?.path !== undefined && anchor?.path[0] !== undefined) {
195
+ editor.insertNode(fragments, {
196
+ at: [anchor?.path[0] + 1]
197
+ });
198
+ }
199
+ } else {
200
+ editor.insertNode(fragments);
197
201
  }
198
202
  } else {
199
- editor.insertNode(fragments);
200
- }
201
- } else {
202
- // loop delete all
203
- editor.children.forEach(() => {
204
- Transforms.delete(editor, {
205
- at: [0]
203
+ // loop delete all
204
+ editor.children.forEach(() => {
205
+ Transforms.delete(editor, {
206
+ at: [0]
207
+ });
206
208
  });
207
- });
208
209
 
209
- // reset init
210
- editor.children = fragments;
210
+ // reset init
211
+ editor.children = fragments;
212
+ }
213
+ } catch (err) {
214
+ console.log(err);
211
215
  }
212
216
  },
213
217
  toggleFullscreen() {
@@ -451,7 +455,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
451
455
  customProps: customProps,
452
456
  toolbarOptions: toolbarOptions,
453
457
  theme: theme
454
- }) : null, footer && /*#__PURE__*/_jsx(Typography, {
458
+ }) : null, footer && (fullScreen || readOnly) && /*#__PURE__*/_jsx(Typography, {
455
459
  sx: {
456
460
  color: "rgb(100, 116, 139)",
457
461
  fontSize: "13px",
@@ -24,10 +24,10 @@ const editorStyles = ({
24
24
  left: 0,
25
25
  width: "100%",
26
26
  zIndex: 99999,
27
- backgroundColor: theme?.palette?.editor?.background,
28
- color: theme?.palette?.editor?.textColor,
27
+ backgroundColor: theme?.palette?.editor?.background || "#fff",
28
+ color: theme?.palette?.editor?.textColor || "black",
29
29
  "& .MuiOutlinedInput-input": {
30
- color: theme?.palette?.editor?.textColor
30
+ color: theme?.palette?.editor?.textColor || "black"
31
31
  }
32
32
  }
33
33
  },
@@ -483,7 +483,7 @@ const usePopupStyle = theme => ({
483
483
  gap: "4px"
484
484
  },
485
485
  "& .verticalLine": {
486
- borderLeft: `1px solid ${theme?.palette?.primary?.border8}`,
486
+ borderLeft: `1px solid ${theme?.palette?.primary?.border8 || "black"}`,
487
487
  minHeight: "20px",
488
488
  height: "100%"
489
489
  },
@@ -531,7 +531,7 @@ const usePopupStyle = theme => ({
531
531
  }
532
532
  },
533
533
  "& .customSelectOptionLabel": {
534
- color: theme?.palette?.editor?.textColor,
534
+ color: theme?.palette?.editor?.textColor || "black",
535
535
  margin: "0px",
536
536
  width: "100%",
537
537
  justifyContent: "start",
@@ -539,7 +539,7 @@ const usePopupStyle = theme => ({
539
539
  fontSize: "14px",
540
540
  lineHeight: "1.75 !important",
541
541
  fontWeight: 400,
542
- background: theme?.palette?.editor?.background,
542
+ background: theme?.palette?.editor?.background || "#fff",
543
543
  "&:hover": {
544
544
  background: `${theme?.palette?.action?.selected} !important`
545
545
  },
@@ -53,19 +53,27 @@ const PopupTool = props => {
53
53
  }
54
54
  }, [selection]);
55
55
  const updateAnchorEl = () => {
56
- const domSelection = window.getSelection();
57
- const domRange = domSelection?.getRangeAt(0);
58
- const {
59
- startOffset,
60
- endOffset
61
- } = domRange || {};
62
- if (startOffset !== endOffset) {
63
- const rect = domRange.getBoundingClientRect();
64
- setAnchorEl({
65
- clientWidth: rect.width,
66
- clientHeight: rect.height,
67
- getBoundingClientRect: () => rect
68
- });
56
+ try {
57
+ const domSelection = window.getSelection();
58
+ if (!domSelection?.anchorOffset) {
59
+ // no selection
60
+ return;
61
+ }
62
+ const domRange = domSelection?.getRangeAt(0);
63
+ const {
64
+ startOffset,
65
+ endOffset
66
+ } = domRange || {};
67
+ if (startOffset !== endOffset) {
68
+ const rect = domRange.getBoundingClientRect();
69
+ setAnchorEl({
70
+ clientWidth: rect.width,
71
+ clientHeight: rect.height,
72
+ getBoundingClientRect: () => rect
73
+ });
74
+ }
75
+ } catch (err) {
76
+ console.log(err);
69
77
  }
70
78
  };
71
79
  const handleClose = () => {
@@ -78,7 +78,7 @@ export const SelectPage = props => {
78
78
  }, [value, pages]);
79
79
  return /*#__PURE__*/_jsxs("div", {
80
80
  children: [/*#__PURE__*/_jsx(FreeSoloCreateOption, {
81
- label: page?.label,
81
+ label: page?.label || "Home",
82
82
  setValue: val => onChange(val?.value),
83
83
  placeholder: "Select Page",
84
84
  options: pages
@@ -137,7 +137,8 @@ const MenusArray = props => {
137
137
  value: m.url,
138
138
  onChange: handleChange(i),
139
139
  size: "small",
140
- fullWidth: true
140
+ fullWidth: true,
141
+ disabled: true
141
142
  }), /*#__PURE__*/_jsx(Tooltip, {
142
143
  title: "Link Settings",
143
144
  arrow: true,
@@ -235,7 +235,8 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
235
235
  props.component = "a";
236
236
  const [page, section] = url.split("#");
237
237
  const sec = section ? `#${section}` : "";
238
- props.href = page === "home" ? `/${sec}` : `/${url}`;
238
+ const isHome = page === "home" || !page;
239
+ props.href = isHome ? `${sec}` : `/${url}`;
239
240
  if (openInNewTab) {
240
241
  props.target = "_blank";
241
242
  }
@@ -274,8 +275,11 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
274
275
  }
275
276
 
276
277
  props.onTouchEnd = e => {
277
- e.preventDefault();
278
- e.stopPropagation();
278
+ if (e) {
279
+ // onTouchEnd will get triggered on web, only for image element, for that case event is getting undefined.
280
+ e.preventDefault();
281
+ e.stopPropagation();
282
+ }
279
283
  if (props.target) {
280
284
  window.open(props.href);
281
285
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "3.2.3",
3
+ "version": "3.2.5",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"