@flozy/editor 4.6.0 → 4.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -439,12 +439,14 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
439
439
  }
440
440
  return style;
441
441
  }, [pageBgImage, pageColor]);
442
- const handleContextMenu = e => {
443
- if (!readOnly) {
444
- e.preventDefault();
445
- e.stopPropagation();
446
- }
447
- };
442
+
443
+ // const handleContextMenu = (e) => {
444
+ // if (!readOnly) {
445
+ // e.preventDefault();
446
+ // e.stopPropagation();
447
+ // }
448
+ // };
449
+
448
450
  const handleCursorScroll = container => {
449
451
  try {
450
452
  if (!customProps?.isMobile) {
@@ -481,8 +483,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
481
483
  style: {
482
484
  ...dotBg
483
485
  },
484
- "data-breakpoint": breakpoint,
485
- onContextMenu: handleContextMenu,
486
+ "data-breakpoint": breakpoint
487
+ // onContextMenu={handleContextMenu}
488
+ ,
486
489
  children: /*#__PURE__*/_jsxs(Slate, {
487
490
  editor: editor,
488
491
  initialValue: value,
@@ -1206,4 +1206,17 @@ blockquote {
1206
1206
 
1207
1207
  .freegrid-section {
1208
1208
  max-width: 100% !important;
1209
+ }
1210
+
1211
+ .divider-settings {
1212
+ display: none;
1213
+ position: absolute;
1214
+ }
1215
+
1216
+ .dividerComponent:hover {
1217
+ padding: 10px 0;
1218
+ }
1219
+
1220
+ .dividerComponent:hover .divider-settings {
1221
+ display: block;
1209
1222
  }
@@ -1,30 +1,129 @@
1
- import React from "react";
1
+ import React, { useState } from "react";
2
+ import { useEditorContext, useEditorSelection } from "../../hooks/useMouseMove";
3
+ import { ReactEditor, useSlateStatic } from "slate-react";
4
+ import { IconButton, Tooltip } from "@mui/material";
5
+ import { GridSettingsIcon } from "../../common/iconslist";
6
+ import DividerPopup from "./DividerPopup";
7
+ import { Transforms } from "slate";
2
8
  import { jsx as _jsx } from "react/jsx-runtime";
3
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
4
10
  const Divider = props => {
5
11
  const {
6
12
  attributes,
7
- children
13
+ children,
14
+ element,
15
+ customProps
8
16
  } = props;
17
+ const {
18
+ theme
19
+ } = useEditorContext();
20
+ const {
21
+ borderColor = theme?.palette?.text?.primary || '#0F172A',
22
+ borderWidth = '1px',
23
+ borderStyle = 'solid'
24
+ } = element;
25
+ const {
26
+ readOnly
27
+ } = customProps;
28
+ const editor = useSlateStatic();
29
+ const path = ReactEditor.findPath(editor, element);
30
+ const [openSettings, setOpenSettings] = useState(false);
31
+ const {
32
+ hoverPath
33
+ } = useEditorContext();
34
+ const [showTool] = useEditorSelection(editor);
35
+ const selected = hoverPath === path.join(",");
36
+ const onSettings = () => {
37
+ setOpenSettings(true);
38
+ };
39
+ const DividerToolbar = ({
40
+ selected,
41
+ showTool,
42
+ onSettings
43
+ }) => {
44
+ return /*#__PURE__*/_jsx("div", {
45
+ contentEditable: false,
46
+ className: "divider-settings",
47
+ style: {
48
+ top: "-20px",
49
+ left: 0
50
+ },
51
+ children: /*#__PURE__*/_jsx(Tooltip, {
52
+ title: "Divider Settings",
53
+ arrow: true,
54
+ children: /*#__PURE__*/_jsx(IconButton, {
55
+ size: "small",
56
+ sx: {
57
+ boxShadow: '0px 0px 4px 0px #00000040',
58
+ borderRadius: '50%'
59
+ },
60
+ onClick: onSettings,
61
+ children: /*#__PURE__*/_jsx(GridSettingsIcon, {})
62
+ })
63
+ })
64
+ });
65
+ };
66
+ const onSave = data => {
67
+ const updateData = {
68
+ ...data
69
+ };
70
+ delete updateData.children;
71
+ Transforms.setNodes(editor, {
72
+ ...updateData
73
+ }, {
74
+ at: path
75
+ });
76
+ onClose();
77
+ };
78
+ const onClose = () => {
79
+ setOpenSettings(false);
80
+ };
81
+ const onDelete = () => {
82
+ if (path) {
83
+ Transforms.removeNodes(editor, {
84
+ at: path
85
+ });
86
+ }
87
+ };
9
88
  return /*#__PURE__*/_jsxs("div", {
10
89
  ...attributes,
11
90
  className: "dividerComponent",
12
- contentEditable: "false",
13
91
  style: {
14
- userSelect: "none"
92
+ userSelect: "none",
93
+ position: 'relative'
15
94
  },
16
- children: [/*#__PURE__*/_jsx("hr", {
17
- contentEditable: "false",
95
+ children: [!readOnly && /*#__PURE__*/_jsx("div", {
96
+ className: `element-root element-selector`,
97
+ contentEditable: false,
98
+ style: {
99
+ zIndex: 1000
100
+ },
101
+ children: /*#__PURE__*/_jsx(DividerToolbar, {
102
+ selected: selected,
103
+ showTool: showTool,
104
+ onSettings: onSettings
105
+ })
106
+ }), /*#__PURE__*/_jsx("hr", {
107
+ contentEditable: false,
18
108
  className: "editorDivider",
19
109
  style: {
20
- userSelect: "none"
110
+ userSelect: "none",
111
+ borderTop: !borderColor?.includes("linear") ? `${borderWidth} ${borderStyle} ${borderColor}` : `transparent`,
112
+ backgroundImage: borderColor?.includes("linear") ? borderColor : "none",
113
+ height: borderColor?.includes("linear") ? borderWidth : undefined
21
114
  }
22
115
  }), /*#__PURE__*/_jsx("span", {
23
116
  style: {
24
117
  display: "none"
25
118
  },
26
119
  children: children
27
- })]
120
+ }), openSettings ? /*#__PURE__*/_jsx(DividerPopup, {
121
+ element: element,
122
+ onSave: onSave,
123
+ onClose: onClose,
124
+ onDelete: onDelete,
125
+ customProps: customProps
126
+ }) : null]
28
127
  });
29
128
  };
30
129
  export default Divider;
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import StyleBuilder from "../../common/StyleBuilder";
3
+ import dividerStyle from "../../common/StyleBuilder/dividerStyles";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const DividerPopup = props => {
6
+ const {
7
+ element,
8
+ onSave,
9
+ onClose,
10
+ onDelete,
11
+ customProps
12
+ } = props;
13
+ return /*#__PURE__*/_jsx(StyleBuilder, {
14
+ title: "Divider",
15
+ type: "dividerStyle",
16
+ element: element,
17
+ onSave: onSave,
18
+ onClose: onClose,
19
+ renderTabs: dividerStyle,
20
+ onDelete: onDelete,
21
+ customProps: customProps
22
+ });
23
+ };
24
+ export default DividerPopup;
@@ -6,14 +6,16 @@ const EmojiPicker = props => {
6
6
  const {
7
7
  onEmojiSelect,
8
8
  onClose,
9
- theme = 'light'
9
+ theme = 'light',
10
+ ...rest
10
11
  } = props;
11
12
  return /*#__PURE__*/_jsx(_Fragment, {
12
13
  children: /*#__PURE__*/_jsx(Picker, {
13
14
  data: data,
14
15
  onEmojiSelect: onEmojiSelect,
15
16
  onClickOutside: onClose,
16
- theme: theme
17
+ theme: theme,
18
+ ...rest
17
19
  })
18
20
  });
19
21
  };
@@ -47,7 +47,8 @@ const FreeGrid = props => {
47
47
  } = element;
48
48
  const {
49
49
  readOnly,
50
- customSX
50
+ customSX,
51
+ hideTools
51
52
  } = customProps;
52
53
  const {
53
54
  updated_at,
@@ -342,6 +343,26 @@ const FreeGrid = props => {
342
343
  at: [...insertAt]
343
344
  });
344
345
  break;
346
+ case "addDivider":
347
+ Transforms.insertNodes(editor, [{
348
+ type: "freegridItem",
349
+ childType: "divider",
350
+ children: [{
351
+ type: "divider",
352
+ children: [{
353
+ text: ""
354
+ }]
355
+ }],
356
+ gridArea: "3 / 1 / 4 / 2",
357
+ left: 50,
358
+ marginTop: 0,
359
+ top: 0,
360
+ width: 170,
361
+ height: 30
362
+ }], {
363
+ at: [...insertAt]
364
+ });
365
+ break;
345
366
  default:
346
367
  }
347
368
  // focus on newly added element
@@ -414,6 +435,7 @@ const FreeGrid = props => {
414
435
  ...getBreakPointsValue(sectionBorderRadius || {}, null, "overrideBorderRadius", true)
415
436
  }
416
437
  }, theme);
438
+ const sectionTypeOptions = (itemOptions?.section || []).filter(f => (hideTools || []).indexOf(f) === -1);
417
439
  return /*#__PURE__*/_jsx(RnD, {
418
440
  id: `freegrid_container_${path.join("|")}_${updated_at}_${breakpoint}`,
419
441
  className: `
@@ -441,7 +463,7 @@ const FreeGrid = props => {
441
463
  bottomLeft: false,
442
464
  bottomRight: false
443
465
  },
444
- actions: itemOptions?.section || [],
466
+ actions: sectionTypeOptions,
445
467
  type: "parent",
446
468
  optionsProps: {
447
469
  placement: "right",
@@ -462,7 +484,8 @@ const FreeGrid = props => {
462
484
  placement: "left",
463
485
  title: "Add Element",
464
486
  props: {
465
- handleClick: handleAddElementClick
487
+ handleClick: handleAddElementClick,
488
+ hideTools: hideTools || []
466
489
  }
467
490
  },
468
491
  more: {
@@ -28,7 +28,8 @@ const FreeGridItem = props => {
28
28
  const editor = useSlateStatic();
29
29
  const path = ReactEditor.findPath(editor, element);
30
30
  const {
31
- readOnly
31
+ readOnly,
32
+ hideTools
32
33
  } = customProps;
33
34
  const {
34
35
  updated_at,
@@ -211,12 +212,13 @@ const FreeGridItem = props => {
211
212
  break;
212
213
  }
213
214
  };
215
+ const itemTypeOptions = (itemOptions[childType] || itemOptions?.default).filter(f => (hideTools || []).indexOf(f) === -1);
214
216
  return /*#__PURE__*/_jsx(RnD, {
215
217
  id: `freegrid_item_${path.join("|")}_${updated_at}_${breakpoint}`,
216
218
  className: `freegrid-item path-${path.length} breakpoint-${breakpoint}`,
217
219
  editor: editor,
218
220
  path: path,
219
- actions: itemOptions[childType] || itemOptions?.default,
221
+ actions: itemTypeOptions,
220
222
  settingsProps: {
221
223
  settings: "freegridItem",
222
224
  onChange: onChangeSettings,
@@ -43,15 +43,25 @@ const FREE_GRID_ELEMENTS = [{
43
43
  actionType: "addSignature",
44
44
  label: "Signature",
45
45
  icon: "signature"
46
+ }, {
47
+ actionType: "addDivider",
48
+ label: "Divider",
49
+ icon: "divider"
46
50
  }];
47
51
  const AddElement = props => {
48
52
  const {
49
- handleClick
53
+ handleClick,
54
+ hideTools
50
55
  } = props;
56
+ const ADD_ELEMENTS = FREE_GRID_ELEMENTS.filter(f => (hideTools || []).indexOf(f.actionType) === -1);
51
57
  return /*#__PURE__*/_jsx(Box, {
58
+ sx: {
59
+ maxHeight: "500px",
60
+ overflowY: 'auto'
61
+ },
52
62
  children: /*#__PURE__*/_jsx(List, {
53
63
  className: "item-list-wrpr",
54
- children: FREE_GRID_ELEMENTS.map(m => {
64
+ children: ADD_ELEMENTS.map(m => {
55
65
  return /*#__PURE__*/_jsxs(ListItemButton, {
56
66
  className: "item-wrapper",
57
67
  onClick: handleClick(m.actionType),
@@ -7,10 +7,11 @@ const boxOptions = ["settings", "link", "saveAsTemplate", "close"];
7
7
  const appHeaderOptions = ["settings", "saveAsTemplate", "close"];
8
8
  const tableOptions = ["drag", "edit", "settings", "saveAsTemplate", "close"];
9
9
  const embedScriptOptions = ["embedScript", "saveAsTemplate", "close"];
10
- const sectionOptions = ["addElement", "settings", "moveUp", "moveDown", "saveAsTemplate", "more"];
10
+ const sectionOptions = ["addElementInSection", "settings", "moveUp", "moveDown", "saveAsTemplate", "more"];
11
11
  const formOptions = ["drag", "edit", "settings", "addFormField", "workFlow", "saveAsTemplate", "close"];
12
12
  const signatureOptions = ["signatureSettings", "saveAsTemplate", "close"];
13
13
  const signOptions = ["removeSign", "saveAsTemplate", "close"];
14
+ const dividerOptions = ["settings", "saveAsTemplate", "close"];
14
15
  const itemOptions = {
15
16
  default: commonOptions,
16
17
  text: textOptions,
@@ -24,6 +25,7 @@ const itemOptions = {
24
25
  embedScript: embedScriptOptions,
25
26
  video: videoOptions,
26
27
  signature: signatureOptions,
27
- sign: signOptions
28
+ sign: signOptions,
29
+ divider: dividerOptions
28
30
  };
29
31
  export default itemOptions;
@@ -27,7 +27,7 @@ const Actions = {
27
27
  Icon: null,
28
28
  title: "Add Section"
29
29
  },
30
- addElement: {
30
+ addElementInSection: {
31
31
  type: "addElement",
32
32
  Button: IconButton,
33
33
  Icon: AddIcon,
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+ import { Transforms, Node } from "slate";
3
+ import { Box } from "@mui/material";
4
+ import { StyleContent } from "../../../StyleBuilder";
5
+ import dividerStyle from "../../../StyleBuilder/dividerStyles";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const DividerSettings = props => {
8
+ const {
9
+ editor,
10
+ path,
11
+ customProps
12
+ } = props;
13
+ const item_path = path?.split("|").map(m => parseInt(m));
14
+ const element_path = [...item_path, 0];
15
+ const element = Node.get(editor, element_path);
16
+ const onChange = data => {
17
+ console.log("🚀 ~ onChange ~ data:", data);
18
+ console.log("🚀 ~ onChange ~ element:", element);
19
+ const updated_props = {
20
+ ...element,
21
+ ...data,
22
+ field_type: data?.element
23
+ };
24
+ delete updated_props.children;
25
+ Transforms.setNodes(editor, {
26
+ ...updated_props
27
+ }, {
28
+ at: element_path
29
+ });
30
+ };
31
+ const handleClose = () => {
32
+ console.log("close");
33
+ };
34
+ return /*#__PURE__*/_jsx(Box, {
35
+ component: "div",
36
+ className: "item-w",
37
+ children: dividerStyle?.map((m, i) => {
38
+ return /*#__PURE__*/_jsx(StyleContent, {
39
+ renderTabs: dividerStyle,
40
+ value: m.value,
41
+ element: element,
42
+ onChange: onChange,
43
+ customProps: customProps,
44
+ handleClose: handleClose
45
+ }, `tab_${m.value}_$${i}`);
46
+ })
47
+ });
48
+ };
49
+ export default DividerSettings;
@@ -7,6 +7,7 @@ import AppHeaderSettings from "./AppHeaderSettings";
7
7
  import FormSettings from "./FormSettings";
8
8
  import TableSettings from "./TableSettings";
9
9
  import CodeSettings from "./CodeSettings";
10
+ import DividerSettings from "./DividerSettings";
10
11
  const SettingsComponents = {
11
12
  text: TextSettings,
12
13
  button: ButtonSettings,
@@ -16,6 +17,7 @@ const SettingsComponents = {
16
17
  appHeader: AppHeaderSettings,
17
18
  form: FormSettings,
18
19
  table: TableSettings,
19
- embedScript: CodeSettings
20
+ embedScript: CodeSettings,
21
+ divider: DividerSettings
20
22
  };
21
23
  export default SettingsComponents;
@@ -7,7 +7,8 @@ export const settingsLabel = {
7
7
  appHeader: "App Header Settings",
8
8
  form: "Form Settings",
9
9
  table: "Table Settings",
10
- embedScript: "Code Settings"
10
+ embedScript: "Code Settings",
11
+ divider: 'Divider Settings'
11
12
  };
12
13
  export const ItemTypes = {
13
14
  text: "Text",
@@ -19,5 +20,6 @@ export const ItemTypes = {
19
20
  form: "Form",
20
21
  table: "Table",
21
22
  embedScript: "Code",
22
- signature: "Signature"
23
+ signature: "Signature",
24
+ divider: 'Divider'
23
25
  };
@@ -0,0 +1,56 @@
1
+ import Icon from "../Icon";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ const dividerStyle = [{
4
+ tab: "Border",
5
+ value: "sectionBorderRadius",
6
+ fields: [{
7
+ label: "Divider Color",
8
+ key: "borderColor",
9
+ type: "color",
10
+ infoIcon: /*#__PURE__*/_jsx(Icon, {
11
+ icon: "info"
12
+ })
13
+ }, {
14
+ label: "Divider Width",
15
+ key: "borderWidth",
16
+ type: "text",
17
+ placeholder: "1px",
18
+ width: 6
19
+ }, {
20
+ label: "Divider Style",
21
+ key: "borderStyle",
22
+ type: "textOptions",
23
+ width: 6,
24
+ options: [{
25
+ text: "Solid",
26
+ value: "solid"
27
+ }, {
28
+ text: "Dotted",
29
+ value: "dotted"
30
+ }, {
31
+ text: "Dashed",
32
+ value: "dashed"
33
+ }, {
34
+ text: "Double",
35
+ value: "double"
36
+ }, {
37
+ text: "Groove",
38
+ value: "groove"
39
+ }, {
40
+ text: "Ridge",
41
+ value: "ridge"
42
+ }, {
43
+ text: "Inset",
44
+ value: "inset"
45
+ }, {
46
+ text: "Outset",
47
+ value: "outset"
48
+ }],
49
+ renderOption: option => {
50
+ return /*#__PURE__*/_jsx("span", {
51
+ children: option.text
52
+ });
53
+ }
54
+ }]
55
+ }];
56
+ export default dividerStyle;
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { Grid, TextField, InputAdornment, Typography } from "@mui/material";
2
+ import { Grid, TextField, InputAdornment, Typography, Tooltip } from "@mui/material";
3
3
  import ColorPickerButton from "../../ColorPickerButton";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -46,15 +46,30 @@ const Color = props => {
46
46
  item: true,
47
47
  xs: 12,
48
48
  className: "btnColorPicker",
49
- children: [/*#__PURE__*/_jsx(Typography, {
49
+ children: [/*#__PURE__*/_jsxs(Typography, {
50
50
  variant: "body1",
51
51
  color: "primary",
52
52
  sx: {
53
53
  fontSize: "14px",
54
54
  fontWeight: 500,
55
- marginBottom: "5px"
55
+ marginBottom: "5px",
56
+ display: 'flex',
57
+ alignItems: 'center',
58
+ '& svg': {
59
+ width: '20px',
60
+ height: '20px'
61
+ }
56
62
  },
57
- children: label
63
+ children: [label, data?.infoIcon ? /*#__PURE__*/_jsx(Tooltip, {
64
+ arrow: true,
65
+ title: "Note: If color gradient is used, divider styles will not apply",
66
+ children: /*#__PURE__*/_jsx("span", {
67
+ style: {
68
+ display: 'inline-block'
69
+ },
70
+ children: data?.infoIcon
71
+ })
72
+ }) : null]
58
73
  }), /*#__PURE__*/_jsx(TextField, {
59
74
  fullWidth: true,
60
75
  value: value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"