@flozy/editor 3.2.6 → 3.2.7

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.
@@ -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,
@@ -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.6",
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": [