@flozy/editor 3.3.7 → 3.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -468,7 +468,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
468
468
  toolbarOptions: toolbarOptions,
469
469
  theme: theme
470
470
  }) : null, /*#__PURE__*/_jsx(PopoverAIInput, {
471
- otherProps: otherProps
471
+ otherProps: otherProps || {}
472
472
  }), footer && (fullScreen || readOnly) && /*#__PURE__*/_jsx(Typography, {
473
473
  sx: {
474
474
  color: "rgb(100, 116, 139)",
@@ -26,7 +26,7 @@ const Form = props => {
26
26
  readOnly,
27
27
  site_id,
28
28
  page_id,
29
- onFormSubmit
29
+ onFormSubmit = () => {}
30
30
  } = customProps;
31
31
  const {
32
32
  buttonProps,
@@ -78,6 +78,8 @@ const Form = props => {
78
78
  if (event) {
79
79
  event.preventDefault();
80
80
  }
81
+ let headerHtml = document?.getElementsByClassName('app-logo');
82
+ headerHtml = headerHtml[0]?.outerHTML;
81
83
  if ((readOnly || test) && formEle && formEle?.current) {
82
84
  const formData = new FormData(formEle?.current);
83
85
  setLoading(true);
@@ -96,7 +98,8 @@ const Form = props => {
96
98
  meta_data.push({
97
99
  [isMetaKey?.element_metadatakey]: pair[1],
98
100
  type: "board",
99
- metadatamapping: element?.metadatamapping
101
+ metadatamapping: element?.metadatamapping,
102
+ headerHtml: headerHtml
100
103
  });
101
104
  }
102
105
  const fieldData = getFieldProps("name", pair[0]);
@@ -124,15 +127,13 @@ const Form = props => {
124
127
  rules: rule?.length > 0 && rule
125
128
  });
126
129
  }
127
- // response = {
128
- // ...response,
129
- // [pair[0]]: pair[1],
130
- // };
131
130
  const placeholder = fieldData?.name === pair[0] ? fieldData?.placeholder : "";
132
131
  response?.push({
132
+ fieldKey: pair[0],
133
133
  [pair[0]]: pair[1],
134
134
  placeholder: placeholder,
135
- form_name: formName
135
+ form_name: formName,
136
+ headerHtml: headerHtml
136
137
  });
137
138
  }
138
139
  let params = {
@@ -9,7 +9,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
9
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
10
10
  const SimpleText = props => {
11
11
  const {
12
- theme
12
+ theme,
13
+ openAI
13
14
  } = useEditorContext() || {};
14
15
  const editor = useSlateStatic();
15
16
  const {
@@ -42,7 +43,7 @@ const SimpleText = props => {
42
43
  ...attributes,
43
44
  className: `simple-text`,
44
45
  sx: classes.root,
45
- children: [children, /*#__PURE__*/_jsx("span", {
46
+ children: [children, openAI ? null : /*#__PURE__*/_jsx("span", {
46
47
  className: "placeholder-simple-text",
47
48
  children: isEmptyEditor ? editorPlaceholder || "Write Something..." : showPlaceHolder ? opacity && selected ? "Type / to browse elements" : "" : ""
48
49
  })]
@@ -3,6 +3,7 @@ import { Button, Grid, Radio, RadioGroup, TextField, FormControl, FormLabel, For
3
3
  import DeleteIcon from "@mui/icons-material/Delete";
4
4
  import Settings from "@mui/icons-material/Settings";
5
5
  import LinkSettings from "../../LinkSettings";
6
+ import { getLinkType } from "../../../utils/helper";
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
9
  const MenusArray = props => {
@@ -182,7 +183,7 @@ const MenusArray = props => {
182
183
  });
183
184
  setOpenNav(false);
184
185
  },
185
- navType: selectedMenu?.linkType,
186
+ navType: getLinkType(selectedMenu?.linkType, selectedMenu?.url),
186
187
  navValue: selectedMenu?.url,
187
188
  openInNewTab: selectedMenu?.target === "_blank",
188
189
  customProps: customProps
@@ -133,7 +133,7 @@ const formStyle = [{
133
133
  tab: "Add to Boards",
134
134
  value: "metadatamapping",
135
135
  fields: [{
136
- label: "Add each response to contacts board",
136
+ label: "Add response to contacts board",
137
137
  key: "metadatamapping",
138
138
  type: "metadatamapping",
139
139
  compType: "card",
@@ -0,0 +1,181 @@
1
+ import { MenuItem, Select, useTheme } from "@mui/material";
2
+ import { fontOptions } from "../utils/font";
3
+ import { toolbarGroups } from "../Toolbar/toolbarGroups";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ const themes = [{
7
+ label: "Theme 1",
8
+ colors: ["#c90c1f", "#ff5d05"]
9
+ }, {
10
+ label: "Theme 2",
11
+ colors: ["#4c0be3", "#43f7ee"]
12
+ }, {
13
+ label: "Theme 3",
14
+ colors: ["#22f20f", "#fff705"]
15
+ }];
16
+ const allTools = toolbarGroups.flat();
17
+ function ThemeList(props) {
18
+ const {
19
+ selectedTheme,
20
+ setSelectedTheme
21
+ } = props;
22
+ const fontWeight = allTools.find(f => f.format === "fontWeight");
23
+ const fontStyles = [{
24
+ text: "Bold",
25
+ value: "bold",
26
+ styleField: "fontWeight"
27
+ }, {
28
+ text: "Italic",
29
+ value: "italic",
30
+ styleField: "fontStyle"
31
+ }
32
+ // {
33
+ // text: "Underline",
34
+ // value: "underline",
35
+ // styleField: "textDecoration",
36
+ // },
37
+ // {
38
+ // text: "Line through",
39
+ // value: "line-through",
40
+ // styleField: "textDecoration",
41
+ // },
42
+ ];
43
+
44
+ const theme = useTheme();
45
+ const colorVars = theme?.vars?.colors || {};
46
+ const handleTypographyTheme = (key, value, elementType) => {
47
+ setSelectedTheme(prev => {
48
+ const newValue = {
49
+ ...prev,
50
+ typography: {
51
+ ...(prev.typography || {}),
52
+ [elementType]: {
53
+ ...(prev?.typography?.[elementType] || {}),
54
+ [key]: value
55
+ }
56
+ }
57
+ };
58
+ if (!value) {
59
+ delete newValue?.typography?.[elementType]?.[key];
60
+ }
61
+ return newValue;
62
+ });
63
+ };
64
+ return /*#__PURE__*/_jsxs("div", {
65
+ children: [themes.map((theme, i) => {
66
+ return /*#__PURE__*/_jsxs("button", {
67
+ style: {
68
+ margin: "10px"
69
+ },
70
+ onClick: () => setSelectedTheme(prev => ({
71
+ ...prev,
72
+ colors: theme.colors
73
+ })),
74
+ children: [theme.label, /*#__PURE__*/_jsx("div", {
75
+ children: theme.colors.map((c, j) => {
76
+ return /*#__PURE__*/_jsx("div", {
77
+ style: {
78
+ width: "20px",
79
+ height: "20px",
80
+ background: c,
81
+ margin: "10px"
82
+ }
83
+ }, j);
84
+ })
85
+ })]
86
+ }, i);
87
+ }), /*#__PURE__*/_jsxs("div", {
88
+ children: ["Heading 1 Font Family", /*#__PURE__*/_jsx(Select
89
+ // value={""}
90
+ , {
91
+ label: "Font Family",
92
+ onChange: e => {
93
+ handleTypographyTheme("fontFamily", e.target.value, "h1");
94
+ },
95
+ children: fontOptions.map((font, i) => {
96
+ const {
97
+ text,
98
+ value
99
+ } = font;
100
+ return /*#__PURE__*/_jsx(MenuItem, {
101
+ value: value,
102
+ children: text
103
+ }, i);
104
+ })
105
+ }), "Font Weight", /*#__PURE__*/_jsx(Select
106
+ // value={""}
107
+ , {
108
+ label: "Font Weight",
109
+ onChange: e => {
110
+ handleTypographyTheme("fontWeight", e.target.value, "h1");
111
+ },
112
+ children: fontWeight.options.map((option, i) => {
113
+ const {
114
+ text,
115
+ value
116
+ } = option;
117
+ return /*#__PURE__*/_jsx(MenuItem, {
118
+ value: value,
119
+ children: text
120
+ }, i);
121
+ })
122
+ }), /*#__PURE__*/_jsx("input", {
123
+ type: "number",
124
+ placeholder: "font size",
125
+ onChange: e => {
126
+ handleTypographyTheme("fontSize", e.target.value, "h1");
127
+ }
128
+ }), /*#__PURE__*/_jsxs("div", {
129
+ children: ["Text", /*#__PURE__*/_jsx("br", {}), "Theme color", Object.values(colorVars).map((colorVar, i) => {
130
+ return /*#__PURE__*/_jsx("button", {
131
+ style: {
132
+ width: "20px",
133
+ height: "20px",
134
+ background: colorVar,
135
+ margin: "10px",
136
+ outline: "none"
137
+ },
138
+ onClick: () => handleTypographyTheme("color", colorVar, "h1")
139
+ }, i);
140
+ }), "normal color", /*#__PURE__*/_jsx("button", {
141
+ style: {
142
+ width: "20px",
143
+ height: "20px",
144
+ background: "#ff00e1",
145
+ margin: "10px",
146
+ outline: "none"
147
+ },
148
+ onClick: () => handleTypographyTheme("color", "#ff00e1", "h1")
149
+ })]
150
+ }), /*#__PURE__*/_jsxs("div", {
151
+ children: ["Font styles", fontStyles.map((option, i) => {
152
+ const styles = selectedTheme?.typography?.h1 || {};
153
+ const {
154
+ text,
155
+ value,
156
+ styleField
157
+ } = option;
158
+ return /*#__PURE__*/_jsxs("button", {
159
+ onClick: () => {
160
+ handleTypographyTheme(styleField, styles[styleField] === value ? null : value, "h1");
161
+ },
162
+ children: [text, " ", styles[styleField] === value]
163
+ }, i);
164
+ })]
165
+ }), /*#__PURE__*/_jsx("input", {
166
+ type: "number",
167
+ placeholder: "Margin text Spacing",
168
+ onChange: e => {
169
+ handleTypographyTheme("letterSpacing", e.target.value, "h1");
170
+ }
171
+ }), /*#__PURE__*/_jsx("input", {
172
+ type: "number",
173
+ placeholder: "Line spacing",
174
+ onChange: e => {
175
+ handleTypographyTheme("lineHeight", e.target.value, "h1");
176
+ }
177
+ })]
178
+ })]
179
+ });
180
+ }
181
+ export default ThemeList;
@@ -207,6 +207,9 @@ export const decodeAndParseBase64 = encodedString => {
207
207
  export const hasVerticalScrollbar = (element = {}) => {
208
208
  return element.scrollHeight > element.clientHeight;
209
209
  };
210
+ const isHomePage = page => {
211
+ return page === "home" || page === "iframe.html" || !page;
212
+ };
210
213
  export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}) => {
211
214
  const props = {};
212
215
  if (!readOnly) {
@@ -214,13 +217,7 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
214
217
  component: "button"
215
218
  };
216
219
  }
217
- if (!linkType && url) {
218
- if (url?.includes("http")) {
219
- linkType = "webAddress";
220
- } else {
221
- linkType = "page";
222
- }
223
- }
220
+ linkType = getLinkType(linkType, url);
224
221
  switch (linkType) {
225
222
  case "webAddress":
226
223
  const refUrl = url ? url.includes("http") ? url : `//${url}` : "Link";
@@ -245,10 +242,13 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
245
242
  props.component = "a";
246
243
  const [page, section] = url?.split("#") || [];
247
244
  const sec = section ? `#${section}` : "";
248
- const isHome = page === "home" || !page;
249
- props.href = isHome ? `${sec}` : `/${url}`;
245
+ props.href = isHomePage(page) ? `./home${sec}` : `./${url}`;
250
246
  if (openInNewTab) {
251
- props.target = "_blank";
247
+ if (isCurrentPage(page)) {
248
+ // temp fix, if user is presented in current page, open in new tab option is restricted, we will scroll to the element in current page
249
+ } else {
250
+ props.target = "_blank";
251
+ }
252
252
  }
253
253
  break;
254
254
  case "email":
@@ -304,4 +304,21 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
304
304
  }
305
305
  return props;
306
306
  };
307
+ const isCurrentPage = page => {
308
+ const paths = window.location.pathname.split("/");
309
+ let currentUserPage = paths[paths?.length - 1];
310
+ currentUserPage = isHomePage(currentUserPage) ? "home" : currentUserPage;
311
+ const buttonPage = isHomePage(page) ? "home" : page;
312
+ return currentUserPage === buttonPage;
313
+ };
314
+ export const getLinkType = (linkType, url) => {
315
+ if (!linkType && url) {
316
+ if (url?.includes("http")) {
317
+ linkType = "webAddress";
318
+ } else {
319
+ linkType = "page";
320
+ }
321
+ }
322
+ return linkType;
323
+ };
307
324
  export const allowedDomains = ["youtube.com", "lemcal.com", "facebook.com", "calendly.com"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "3.3.7",
3
+ "version": "3.3.9",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -64,7 +64,7 @@
64
64
  "storybook": "storybook dev -p 6006",
65
65
  "build-storybook": "storybook build",
66
66
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
67
- "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"
67
+ "publish:local": "rm -rf /Users/agenciflow08/Documents/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agenciflow08/Documents/flozy/client/node_modules/@flozy/editor/dist --copy-files"
68
68
  },
69
69
  "eslintConfig": {
70
70
  "extends": [