@flozy/editor 3.2.5 → 3.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -324,7 +324,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
324
324
  editor
325
325
  });
326
326
  } else if (event.key === "Enter") {
327
- enterEvent(event, editor);
327
+ enterEvent(event, editor, customProps?.isMobile);
328
328
  }
329
329
  }, [chars, editor, target, mentions, setMentions, search, type, mentionsRef]);
330
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,
@@ -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: {
@@ -55,10 +55,6 @@ const PopupTool = props => {
55
55
  const updateAnchorEl = () => {
56
56
  try {
57
57
  const domSelection = window.getSelection();
58
- if (!domSelection?.anchorOffset) {
59
- // no selection
60
- return;
61
- }
62
58
  const domRange = domSelection?.getRangeAt(0);
63
59
  const {
64
60
  startOffset,
@@ -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]) {
@@ -204,6 +204,9 @@ export const decodeAndParseBase64 = encodedString => {
204
204
  const jsonData = JSON.parse(decodedURLString);
205
205
  return jsonData;
206
206
  };
207
+ const hasVerticalScrollbar = (element = {}) => {
208
+ return element.scrollHeight > element.clientHeight;
209
+ };
207
210
  export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}) => {
208
211
  const props = {};
209
212
  if (!readOnly) {
@@ -252,15 +255,17 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
252
255
  case "scrollTopOrBottom":
253
256
  props.component = "button";
254
257
  props.onClick = () => {
255
- const scrollEle = document.getElementById("slate-wrapper-scroll-container");
256
- if (scrollEle) {
257
- if (url === "top") {
258
- // top of the page
259
- scrollEle.scrollTo(0, 0);
260
- } else if (url === "bottom") {
261
- // bottom of the page
262
- scrollEle.scrollTo(0, scrollEle.scrollHeight);
263
- }
258
+ const slateWrapper = document.getElementById("slate-wrapper-scroll-container");
259
+ const isSlateWrapperScroll = hasVerticalScrollbar(slateWrapper);
260
+ const scrollFrom = isSlateWrapperScroll ? slateWrapper : window;
261
+ if (url === "top") {
262
+ // top of the page
263
+ scrollFrom.scrollTo(0, 0);
264
+ } else if (url === "bottom") {
265
+ const pageHeight = isSlateWrapperScroll ? slateWrapper.scrollHeight : document.body.scrollHeight;
266
+
267
+ // bottom of the page
268
+ scrollFrom.scrollTo(0, pageHeight);
264
269
  }
265
270
  };
266
271
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "3.2.5",
3
+ "version": "3.2.7",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -63,7 +63,7 @@
63
63
  "storybook": "storybook dev -p 6006",
64
64
  "build-storybook": "storybook build",
65
65
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
66
- "publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files"
66
+ "publish:local": "rm -rf /Users/agmac23/Desktop/surya/sweetpsocial-2.0/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac23/Desktop/surya/sweetpsocial-2.0/client/node_modules/@flozy/editor/dist --copy-files"
67
67
  },
68
68
  "eslintConfig": {
69
69
  "extends": [