@flozy/editor 1.7.1 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/dist/Editor/CommonEditor.js +9 -79
  2. package/dist/Editor/Editor.css +123 -34
  3. package/dist/Editor/Elements/Button/EditorButton.js +7 -3
  4. package/dist/Editor/Elements/Carousel/Carousel.js +4 -4
  5. package/dist/Editor/Elements/Embed/Image.js +5 -1
  6. package/dist/Editor/Elements/Form/Form.js +3 -3
  7. package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +12 -12
  8. package/dist/Editor/Elements/Form/Workflow/Styles.js +2 -1
  9. package/dist/Editor/Elements/Form/Workflow/index.js +23 -25
  10. package/dist/Editor/Elements/Grid/GridItem.js +3 -0
  11. package/dist/Editor/Elements/Link/Link.js +39 -32
  12. package/dist/Editor/Elements/Link/LinkButton.js +62 -80
  13. package/dist/Editor/Elements/Signature/SignaturePopup.js +8 -3
  14. package/dist/Editor/Elements/SimpleText.js +9 -4
  15. package/dist/Editor/MiniEditor.js +118 -0
  16. package/dist/Editor/Styles/EditorStyles.js +20 -0
  17. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +1 -1
  18. package/dist/Editor/common/DnD/DragHandle.js +99 -0
  19. package/dist/Editor/common/DnD/Draggable.js +41 -0
  20. package/dist/Editor/common/DnD/Droppable.js +28 -0
  21. package/dist/Editor/common/DnD/index.js +48 -0
  22. package/dist/Editor/common/ImageSelector/Options/AddLink.js +3 -0
  23. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +4 -1
  24. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +4 -1
  25. package/dist/Editor/common/iconslist.js +17 -1
  26. package/dist/Editor/hooks/useMouseMove.js +9 -1
  27. package/dist/Editor/utils/embed.js +1 -0
  28. package/dist/Editor/utils/helper.js +1 -0
  29. package/dist/Editor/utils/pageSettings.js +2 -2
  30. package/dist/Editor/utils/serializeToHTML.js +5 -0
  31. package/dist/Editor/utils/{serializer.js → serializeToText.js} +3 -3
  32. package/dist/index.js +2 -0
  33. package/package.json +1 -1
  34. package/dist/Editor/Elements/Section.js +0 -42
@@ -0,0 +1,48 @@
1
+ import React from "react";
2
+ import { Transforms, Node } from "slate";
3
+ import { useSlateStatic } from "slate-react";
4
+ import { DndContext } from "@dnd-kit/core";
5
+ import { customCollisionDetectionAlgorithm } from "../../helper";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const DragAndDrop = ({
8
+ children
9
+ }) => {
10
+ const editor = useSlateStatic();
11
+ const handleDragStart = e => {
12
+ try {
13
+ // console.log(e);
14
+ } catch (err) {
15
+ console.log(err);
16
+ }
17
+ };
18
+ const handleDragEnd = e => {
19
+ try {
20
+ const {
21
+ active,
22
+ over
23
+ } = e;
24
+ const fromPath = active.id.split("_")[1].split("|");
25
+ const toPath = over.id.split("_")[1].split("|");
26
+ const toCloneNode = JSON.stringify(Node.get(editor, fromPath));
27
+ // set moved node delete
28
+ Transforms.setNodes(editor, {
29
+ moved: true
30
+ }, {
31
+ at: [...fromPath]
32
+ });
33
+ // clone node in the moved path
34
+ Transforms.insertNodes(editor, JSON.parse(toCloneNode), {
35
+ at: [...toPath]
36
+ });
37
+ } catch (err) {
38
+ console.log(err);
39
+ }
40
+ };
41
+ return /*#__PURE__*/_jsx(DndContext, {
42
+ collisionDetection: customCollisionDetectionAlgorithm,
43
+ onDragStart: handleDragStart,
44
+ onDragEnd: handleDragEnd,
45
+ children: children
46
+ });
47
+ };
48
+ export default DragAndDrop;
@@ -19,6 +19,9 @@ const AddLink = props => {
19
19
  item: true,
20
20
  xs: 12,
21
21
  className: "ims-right",
22
+ style: {
23
+ paddingTop: "8px"
24
+ },
22
25
  children: /*#__PURE__*/_jsx(TextField, {
23
26
  placeholder: `Add ${title} URL`,
24
27
  fullWidth: true,
@@ -13,9 +13,12 @@ const BannerSpacing = props => {
13
13
  onChange,
14
14
  elementProps
15
15
  } = props;
16
- const {
16
+ let {
17
17
  lockSpacing
18
18
  } = elementProps || {};
19
+ if (lockSpacing === undefined) {
20
+ lockSpacing = true;
21
+ }
19
22
  const {
20
23
  key
21
24
  } = data;
@@ -13,10 +13,13 @@ const BorderRadius = props => {
13
13
  onChange,
14
14
  elementProps
15
15
  } = props;
16
- const {
16
+ let {
17
17
  lockRadius,
18
18
  borderColor
19
19
  } = elementProps;
20
+ if (lockRadius === undefined) {
21
+ lockRadius = true;
22
+ }
20
23
  const {
21
24
  key
22
25
  } = data;
@@ -1529,4 +1529,20 @@ export const UploadImage = () => /*#__PURE__*/_jsx("svg", {
1529
1529
  fill: "#64748B",
1530
1530
  stroke: "#64748B"
1531
1531
  })
1532
- });
1532
+ });
1533
+ export const WorkflowIcon = () => {
1534
+ return /*#__PURE__*/_jsxs("svg", {
1535
+ xmlns: "http://www.w3.org/2000/svg",
1536
+ fill: "#000000",
1537
+ width: "800px",
1538
+ height: "800px",
1539
+ viewBox: "0 0 32 32",
1540
+ version: "1.1",
1541
+ children: [/*#__PURE__*/_jsx("title", {
1542
+ children: "lightning-bolt"
1543
+ }), /*#__PURE__*/_jsx("path", {
1544
+ d: "M23.5 13.187h-7.5v-12.187l-7.5 17.813h7.5v12.187l7.5-17.813z",
1545
+ fill: "#f3b814"
1546
+ })]
1547
+ });
1548
+ };
@@ -6,7 +6,11 @@ export const EditorProvider = ({
6
6
  }) => {
7
7
  const [event] = useMouseMove();
8
8
  const [previous, setPrevious] = useState("");
9
+ const [drop, setDrop] = useState(0);
9
10
  const path = event?.target?.getAttribute("data-path");
11
+ const onDrop = () => {
12
+ setDrop(drop + 1);
13
+ };
10
14
  const value = useMemo(() => {
11
15
  if (path) {
12
16
  setPrevious(path);
@@ -20,7 +24,11 @@ export const EditorProvider = ({
20
24
  }
21
25
  }, [path]);
22
26
  return /*#__PURE__*/_jsx(EditorContext.Provider, {
23
- value: value,
27
+ value: {
28
+ ...(value || {}),
29
+ onDrop: onDrop,
30
+ drop
31
+ },
24
32
  children: children
25
33
  });
26
34
  };
@@ -35,6 +35,7 @@ export const insertEmbed = (editor, embedData, format) => {
35
35
  } = embedData;
36
36
  if (!url && images.length === 0) return;
37
37
  const embed = createEmbedNode(format, embedData);
38
+ console.log(embed);
38
39
  Transforms.insertNodes(editor, embed, {
39
40
  at: editor.selection.anchor.path
40
41
  });
@@ -1,4 +1,5 @@
1
1
  export const formatDate = (date, format = "MM/DD/YYYY") => {
2
+ if (!date) return "";
2
3
  var d = new Date(date),
3
4
  month = "" + (d.getMonth() + 1),
4
5
  day = "" + d.getDate(),
@@ -35,8 +35,8 @@ export const insertPageSettings = (editor, pageProps = {}) => {
35
35
  Transforms.insertNodes(editor, [{
36
36
  type: "page-settings",
37
37
  pageProps: {
38
- ...pageProps,
39
- pageWidth: "fixed"
38
+ pageWidth: "fixed",
39
+ ...pageProps
40
40
  },
41
41
  children: [{
42
42
  text: ""
@@ -0,0 +1,5 @@
1
+ import { Node } from "slate";
2
+ const serializeToHTML = nodes => {
3
+ return nodes.map(n => Node.string(n)).join("\n");
4
+ };
5
+ export default serializeToHTML;
@@ -1,4 +1,4 @@
1
- export const serialize = node => {
1
+ export const serializeToText = node => {
2
2
  try {
3
3
  if (!node?.type && node?.text) {
4
4
  return node?.text;
@@ -6,8 +6,8 @@ export const serialize = node => {
6
6
  let n = Array.isArray(node) ? node : node?.children;
7
7
  n = n && Array.isArray(n) ? n : n ? [n] : [];
8
8
  let block = n.map(m => {
9
- return serialize(m);
10
- }).join(' ');
9
+ return serializeToText(m);
10
+ }).join(" ");
11
11
  return block;
12
12
  } catch (err) {
13
13
  console.log(err);
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import Collaborative from "./Editor/CollaborativeEditor";
2
2
  import CommonEditor from "./Editor/CommonEditor";
3
+ import Mini from "./Editor/MiniEditor";
3
4
  export const Editor = CommonEditor;
5
+ export const MiniEditor = Mini;
4
6
  export const CollaborativeEditor = Collaborative;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -1,42 +0,0 @@
1
- import React from "react";
2
- import { Box } from "@mui/material";
3
- import { ReactEditor, useSlateStatic } from "slate-react";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const SectionStyle = () => ({
6
- root: {
7
- position: "relative",
8
- padding: "0px",
9
- display: "flex",
10
- alignItems: "center",
11
- justifyContent: "center",
12
- width: "100%",
13
- "&.root-1": {
14
- "& .section-inner-ed.root-1": {
15
- width: "80%",
16
- maxWidth: "1440px"
17
- }
18
- }
19
- }
20
- });
21
- const Section = props => {
22
- const {
23
- element
24
- } = props;
25
- const editor = useSlateStatic();
26
- const path = ReactEditor.findPath(editor, element);
27
- console.log(path);
28
- const classes = SectionStyle();
29
- const {
30
- children
31
- } = props;
32
- return /*#__PURE__*/_jsx(Box, {
33
- component: "div",
34
- className: `root-${path.length}`,
35
- sx: classes.root,
36
- children: /*#__PURE__*/_jsx("div", {
37
- className: `section-inner-ed root-${path.length}`,
38
- children: children
39
- })
40
- });
41
- };
42
- export default Section;