@flozy/editor 3.2.4 → 3.2.6

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() {
@@ -320,7 +324,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
320
324
  editor
321
325
  });
322
326
  } else if (event.key === "Enter") {
323
- enterEvent(event, editor);
327
+ enterEvent(event, editor, customProps?.isMobile);
324
328
  }
325
329
  }, [chars, editor, target, mentions, setMentions, search, type, mentionsRef]);
326
330
  const Overlay = collaborativeEditor && !isReadOnly ? RemoteCursorOverlay : React.Fragment;
@@ -187,6 +187,7 @@ const Grid = props => {
187
187
  const NewLineButtons = () => {
188
188
  return !readOnly && selected && path.length === 2 && !showTool ? /*#__PURE__*/_jsxs(_Fragment, {
189
189
  children: [/*#__PURE__*/_jsx("div", {
190
+ contentEditable: false,
190
191
  className: "element-selector-ctrl tc",
191
192
  children: /*#__PURE__*/_jsx(Tooltip, {
192
193
  title: "Add Space above",
@@ -197,6 +198,7 @@ const Grid = props => {
197
198
  })
198
199
  })
199
200
  }), /*#__PURE__*/_jsx("div", {
201
+ contentEditable: false,
200
202
  className: "element-selector-ctrl bc",
201
203
  children: /*#__PURE__*/_jsx(Tooltip, {
202
204
  title: "Add Space below",
@@ -69,6 +69,7 @@ const SignaturePopup = props => {
69
69
  });
70
70
  };
71
71
  const onChange = e => {
72
+ e?.stopPropagation();
72
73
  setSignedData({
73
74
  ...signedData,
74
75
  [e.target.name]: e.target.value
@@ -92,7 +93,8 @@ const SignaturePopup = props => {
92
93
  ...data
93
94
  });
94
95
  };
95
- const onTabChange = newValue => {
96
+ const onTabChange = (e, newValue) => {
97
+ e?.stopPropagation();
96
98
  setTab(newValue);
97
99
  setSignedData({
98
100
  signedOn: new Date(),
@@ -171,7 +173,7 @@ const SignaturePopup = props => {
171
173
  variant: "scrollable",
172
174
  value: tab,
173
175
  onChange: (e, newValue) => {
174
- onTabChange(newValue);
176
+ onTabChange(e, newValue);
175
177
  },
176
178
  "aria-label": "Element Tabs",
177
179
  children: [/*#__PURE__*/_jsx(Tab, {
@@ -264,6 +266,9 @@ const SignaturePopup = props => {
264
266
  })
265
267
  }), /*#__PURE__*/_jsx(Grid, {
266
268
  item: true,
269
+ onClick: e => {
270
+ e?.stopPropagation();
271
+ },
267
272
  xs: 12,
268
273
  children: /*#__PURE__*/_jsx(DatePicker, {
269
274
  showIcon: true,
@@ -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
  },
@@ -110,7 +110,8 @@ const AddTemplates = props => {
110
110
  if (!search) {
111
111
  return true;
112
112
  } else {
113
- return f.title.toLowerCase().includes(search);
113
+ const searchText = search?.toLowerCase();
114
+ return f?.title?.toLowerCase()?.includes(searchText);
114
115
  }
115
116
  };
116
117
  const renderTemplate = mapData => {
@@ -258,7 +258,7 @@ const usePopupStyle = theme => ({
258
258
  margin: "12px 0px",
259
259
  paddingRight: "8px",
260
260
  "&.fullscreen": {
261
- height: `${window.innerHeight - 300}px`
261
+ height: `${window.innerHeight - 197}px`
262
262
  }
263
263
  },
264
264
  templateCardTitle: {
@@ -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,
@@ -169,12 +169,12 @@ const checkListEnterEvent = (editor, type) => {
169
169
  insertNewLine(editor);
170
170
  }
171
171
  };
172
- export const enterEvent = (e, editor) => {
172
+ export const enterEvent = (e, editor, isMobile) => {
173
173
  try {
174
174
  const ele = isListItem(editor);
175
175
 
176
176
  // on shift enter break line in same node
177
- if (e.shiftKey) {
177
+ if (e.shiftKey && !isMobile) {
178
178
  e.preventDefault();
179
179
  Transforms.insertText(editor, "\n");
180
180
  } else if (ele && ele[0]) {
@@ -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.4",
3
+ "version": "3.2.6",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"