@flozy/editor 4.0.4 → 4.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,15 +21,11 @@ const scrollToAIInput = editor => {
21
21
  } else {
22
22
  selectionRect = ReactEditor.toDOMRange(editor, getNextLine(editor).at).getBoundingClientRect();
23
23
  }
24
- const selectionScrollBottom = selectionRect.bottom;
25
-
26
- // if the cursor or selection top position is greater than 80
27
- if (selectionScrollBottom > 80) {
24
+ const wrapperTop = slateWrapper.getBoundingClientRect().top;
25
+ const cursorViewPortPosition = selectionRect.top - wrapperTop;
26
+ if (cursorViewPortPosition > 80) {
28
27
  // scroll to top of the slateWrapper
29
- slateWrapper.scrollTo({
30
- top: slateWrapper.scrollTop + selectionScrollBottom - 80,
31
- behavior: "smooth"
32
- });
28
+ slateWrapper.scrollBy(0, selectionRect.bottom - wrapperTop - 80);
33
29
  }
34
30
  }, 200);
35
31
  } catch (err) {
@@ -97,13 +93,17 @@ const getNextLine = editor => {
97
93
  return null;
98
94
  }
99
95
  };
100
- const updateAnchorEl = (setAnchorEl, editor) => {
96
+ const updateAnchorEl = (setAnchorEl, editor, openAI) => {
101
97
  try {
102
98
  if (!editor.selection) {
103
99
  return;
104
100
  }
105
101
  const selection = window.getSelection();
106
- if (selection.rangeCount && selection.anchorOffset !== selection.focusOffset) {
102
+ if (openAI === "fromToolBar" && selection.anchorOffset !== selection.focusOffset) {
103
+ // to fix some issue in Drag n Drop
104
+ return;
105
+ }
106
+ if (selection.rangeCount) {
107
107
  let caret;
108
108
  if (getSelectedText(editor)) {
109
109
  // selected text as caret
@@ -175,7 +175,7 @@ function PopoverAIInput({
175
175
  };
176
176
  const editorElement = document.querySelector(".ed-section-inner");
177
177
  useEffect(() => {
178
- updateAnchorEl(setAnchorEl, editor);
178
+ updateAnchorEl(setAnchorEl, editor, openAI);
179
179
  }, [openAI, editor.selection]);
180
180
  useEffect(() => {
181
181
  if (openAI) {
@@ -62,13 +62,14 @@ const EditorButton = props => {
62
62
  } = actionTrigger || {
63
63
  options: []
64
64
  };
65
- const isTrigger = linkType === "actionTrigger";
65
+ const isTrigger = linkType === "nextTrigger" || linkType === "prevTrigger";
66
66
  const refURl = isTrigger ? buttonLink?.url : url;
67
67
  const BtnIcon = buttonIcon ? buttonIcon : null;
68
68
  windowVar.lastButtonProps = element;
69
69
  const handleTrigger = async () => {
70
70
  if (metadata?.buttonLink?.handler) {
71
- metadata.buttonLink.handler("click");
71
+ const response = isTrigger ? linkType : "click";
72
+ metadata.buttonLink.handler(response);
72
73
  } else if (redirectOnURLResult) {
73
74
  // call api and redirect based on api result
74
75
  const apiResult = await actionButtonRedirect({}, {
@@ -71,11 +71,11 @@ const FormWorkflow = props => {
71
71
  children: [/*#__PURE__*/_jsx(Grid, {
72
72
  item: true,
73
73
  sx: classes.radioBtn,
74
- children: /*#__PURE__*/_jsx(RadioGroup, {
74
+ children: /*#__PURE__*/_jsxs(RadioGroup, {
75
75
  name: "set timing",
76
76
  value: schedule,
77
77
  defaultValue: 1,
78
- children: /*#__PURE__*/_jsx(FormControlLabel, {
78
+ children: [/*#__PURE__*/_jsx(FormControlLabel, {
79
79
  value: "immediately",
80
80
  label: "Immediately",
81
81
  onChange: () => {
@@ -84,7 +84,16 @@ const FormWorkflow = props => {
84
84
  control: /*#__PURE__*/_jsx(Radio, {
85
85
  size: "small"
86
86
  })
87
- })
87
+ }), /*#__PURE__*/_jsx(FormControlLabel, {
88
+ value: "after",
89
+ label: "After",
90
+ onChange: () => {
91
+ setSchedule("after");
92
+ },
93
+ control: /*#__PURE__*/_jsx(Radio, {
94
+ size: "small"
95
+ })
96
+ })]
88
97
  })
89
98
  }), schedule === "after" && /*#__PURE__*/_jsx(Grid, {
90
99
  item: true,
@@ -5,7 +5,7 @@ const imageOptions = ["settings", "link", "saveAsTemplate", "close"];
5
5
  const boxOptions = ["settings", "link", "saveAsTemplate", "close"];
6
6
  const appHeaderOptions = ["settings", "saveAsTemplate", "close"];
7
7
  const sectionOptions = ["addElement", "settings", "moveUp", "moveDown", "saveAsTemplate", "more"];
8
- const formOptions = ["drag", "edit", "settings", "addFormField", "workFlow", "close"];
8
+ const formOptions = ["drag", "edit", "settings", "addFormField", "workFlow", "saveAsTemplate", "close"];
9
9
  const itemOptions = {
10
10
  default: commonOptions,
11
11
  text: textOptions,
@@ -134,10 +134,13 @@ export const SelectPage = props => {
134
134
  });
135
135
  };
136
136
  export const Trigger = props => {
137
- return /*#__PURE__*/_jsx(Typography, {
137
+ const {
138
+ nav
139
+ } = props;
140
+ return /*#__PURE__*/_jsxs(Typography, {
138
141
  variant: "subtitle1",
139
142
  gutterBottom: true,
140
- children: "Choosing this will trigger the next step"
143
+ children: ["Choosing this will trigger the ", nav.type, " step"]
141
144
  });
142
145
  };
143
146
  const scrollToOptions = [{
@@ -18,7 +18,8 @@ const MAP_COMPONENT = {
18
18
  webAddress: TextInput,
19
19
  email: TextInput,
20
20
  phone: TextInput,
21
- actionTrigger: Trigger,
21
+ nextTrigger: Trigger,
22
+ prevTrigger: Trigger,
22
23
  scrollTopOrBottom: ScrollTopBottom,
23
24
  page: SelectPage
24
25
  };
@@ -3,8 +3,13 @@ export const getNavOptions = (hideTools = []) => {
3
3
  label: "None",
4
4
  value: ""
5
5
  }, {
6
- label: "Trigger",
7
- value: "actionTrigger"
6
+ label: "Next Trigger",
7
+ value: "nextTrigger",
8
+ type: "next"
9
+ }, {
10
+ label: "Previous Trigger",
11
+ value: "prevTrigger",
12
+ type: "previous"
8
13
  }, {
9
14
  label: "Web Address",
10
15
  value: "webAddress",
@@ -59,7 +59,7 @@ const ButtonLink = props => {
59
59
  value: elementProps?.url
60
60
  })
61
61
  });
62
- } else if (value?.linkType === "actionTrigger") {
62
+ } else if (value?.linkType === "prevTrigger" || value?.linkType === "nextTrigger") {
63
63
  return null;
64
64
  }
65
65
  };
@@ -247,7 +247,8 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
247
247
  props.target = "_blank";
248
248
  }
249
249
  break;
250
- case "actionTrigger":
250
+ case "nextTrigger":
251
+ case "prevTrigger":
251
252
  if (!readOnly) {
252
253
  props.component = "button";
253
254
  props.onClick = () => {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"