@flozy/editor 1.1.1 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. package/dist/Editor/CollaborativeEditor.js +7 -2
  2. package/dist/Editor/CommonEditor.js +59 -37
  3. package/dist/Editor/Editor.css +209 -12
  4. package/dist/Editor/Elements/Accordion/Accordion.js +100 -0
  5. package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +20 -0
  6. package/dist/Editor/Elements/Accordion/AccordionButton.js +22 -0
  7. package/dist/Editor/Elements/Accordion/AccordionDetails.js +18 -0
  8. package/dist/Editor/Elements/Accordion/AccordionSummary.js +69 -0
  9. package/dist/Editor/Elements/Accordion/AccordionTitlePopup.js +20 -0
  10. package/dist/Editor/Elements/Button/ButtonPopup.js +20 -0
  11. package/dist/Editor/Elements/Button/ButtonToolIcon.js +19 -0
  12. package/dist/Editor/Elements/Button/EditorButton.js +124 -0
  13. package/dist/Editor/Elements/Carousel/Arrows.js +39 -0
  14. package/dist/Editor/Elements/Carousel/Carousel.js +82 -0
  15. package/dist/Editor/Elements/Carousel/CarouselButton.js +19 -0
  16. package/dist/Editor/Elements/Carousel/CarouselItem.js +13 -0
  17. package/dist/Editor/Elements/Carousel/slick-theme.min.css +143 -0
  18. package/dist/Editor/Elements/Carousel/slick.min.css +83 -0
  19. package/dist/Editor/Elements/Color Picker/ColorPicker.js +1 -1
  20. package/dist/Editor/Elements/Embed/Embed.css +22 -2
  21. package/dist/Editor/Elements/Embed/Embed.js +89 -74
  22. package/dist/Editor/Elements/Embed/EmbedPopup.js +23 -0
  23. package/dist/Editor/Elements/Embed/Image.js +92 -10
  24. package/dist/Editor/Elements/Embed/Video.js +31 -5
  25. package/dist/Editor/Elements/Equation/EquationButton.js +12 -12
  26. package/dist/Editor/Elements/Grid/Grid.js +64 -8
  27. package/dist/Editor/Elements/Grid/GridButton.js +2 -4
  28. package/dist/Editor/Elements/Grid/GridItem.js +59 -5
  29. package/dist/Editor/Elements/Grid/GridItemPopup.js +20 -0
  30. package/dist/Editor/Elements/Grid/GridPopup.js +22 -0
  31. package/dist/Editor/Elements/ID/Id.js +1 -1
  32. package/dist/Editor/Elements/ImageText/ImageText.js +14 -0
  33. package/dist/Editor/Elements/ImageText/ImageTextWrapper.js +14 -0
  34. package/dist/Editor/Elements/Link/LinkButton.js +1 -1
  35. package/dist/Editor/Elements/NewLine/NewLineButton.js +2 -1
  36. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +88 -0
  37. package/dist/Editor/Elements/PageSettings/PageSettingsPopup.js +22 -0
  38. package/dist/Editor/Elements/Signature/Signature.js +50 -0
  39. package/dist/Editor/Elements/Signature/SignatureButton.js +19 -0
  40. package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +39 -0
  41. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +84 -0
  42. package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +50 -0
  43. package/dist/Editor/Elements/Signature/SignatureOptions/index.js +5 -0
  44. package/dist/Editor/Elements/Signature/SignaturePopup.js +243 -0
  45. package/dist/Editor/Elements/Signature/Signed.js +80 -0
  46. package/dist/Editor/Elements/Table/DeleteCellIcon.js +24 -0
  47. package/dist/Editor/Elements/Table/DeleteRowIcon.js +24 -0
  48. package/dist/Editor/Elements/Table/Table.js +9 -1
  49. package/dist/Editor/Elements/Table/TableCell.js +181 -0
  50. package/dist/Editor/Elements/Table/TablePopup.js +22 -0
  51. package/dist/Editor/Elements/Table/TableRow.js +31 -0
  52. package/dist/Editor/Elements/Table/TableSelector.js +62 -68
  53. package/dist/Editor/Toolbar/Toolbar.js +47 -10
  54. package/dist/Editor/Toolbar/styles.css +20 -11
  55. package/dist/Editor/Toolbar/toolbarGroups.js +17 -19
  56. package/dist/Editor/common/Button.js +4 -8
  57. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +23 -0
  58. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +35 -0
  59. package/dist/Editor/common/StyleBuilder/buttonStyle.js +47 -0
  60. package/dist/Editor/common/StyleBuilder/embedImageStyle.js +63 -0
  61. package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +88 -0
  62. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +87 -0
  63. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +136 -0
  64. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +126 -0
  65. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +89 -0
  66. package/dist/Editor/common/StyleBuilder/fieldTypes/elementSize.js +110 -0
  67. package/dist/Editor/common/StyleBuilder/fieldTypes/gridSize.js +42 -0
  68. package/dist/Editor/common/StyleBuilder/fieldTypes/imageTexts.js +75 -0
  69. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +21 -0
  70. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +46 -0
  71. package/dist/Editor/common/StyleBuilder/gridItemStyle.js +51 -0
  72. package/dist/Editor/common/StyleBuilder/gridStyle.js +51 -0
  73. package/dist/Editor/common/StyleBuilder/index.js +114 -0
  74. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +10 -0
  75. package/dist/Editor/common/StyleBuilder/tableStyle.js +38 -0
  76. package/dist/Editor/common/Uploader.js +87 -0
  77. package/dist/Editor/plugins/withEmbeds.js +12 -5
  78. package/dist/Editor/plugins/withTable.js +5 -4
  79. package/dist/Editor/service/fileupload.js +17 -0
  80. package/dist/Editor/utils/SlateUtilityFunctions.js +72 -23
  81. package/dist/Editor/utils/accordion.js +25 -0
  82. package/dist/Editor/utils/button.js +11 -0
  83. package/dist/Editor/utils/carousel.js +13 -0
  84. package/dist/Editor/utils/carouselItem.js +19 -0
  85. package/dist/Editor/utils/customHooks/useContextMenu.js +8 -8
  86. package/dist/Editor/utils/customHooks/useResize.js +1 -1
  87. package/dist/Editor/utils/font.js +59 -0
  88. package/dist/Editor/utils/helper.js +32 -0
  89. package/dist/Editor/utils/imageText.js +19 -0
  90. package/dist/Editor/utils/signature.js +23 -0
  91. package/dist/Editor/utils/table.js +172 -0
  92. package/package.json +11 -3
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { Grid, TextField } from "@mui/material";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
+ const Text = props => {
6
+ const {
7
+ value,
8
+ data,
9
+ onChange
10
+ } = props;
11
+ const {
12
+ key
13
+ } = data;
14
+ const handleChange = e => {
15
+ onChange({
16
+ [key]: e.target.value
17
+ });
18
+ };
19
+ return /*#__PURE__*/_jsxs(Grid, {
20
+ container: true,
21
+ padding: 1,
22
+ children: [/*#__PURE__*/_jsx(Grid, {
23
+ item: true,
24
+ xs: 12,
25
+ style: {
26
+ fontWeight: "bold",
27
+ marginBottom: "8px"
28
+ },
29
+ children: /*#__PURE__*/_jsx("label", {
30
+ children: data?.label
31
+ })
32
+ }), /*#__PURE__*/_jsx(Grid, {
33
+ item: true,
34
+ xs: 12,
35
+ children: /*#__PURE__*/_jsx(TextField, {
36
+ name: key,
37
+ type: "text",
38
+ value: value,
39
+ onChange: handleChange,
40
+ size: "small",
41
+ fullWidth: true
42
+ })
43
+ })]
44
+ });
45
+ };
46
+ export default Text;
@@ -0,0 +1,51 @@
1
+ const gridItemStyle = [{
2
+ tab: "Banner Spacing",
3
+ value: "bannerSpacing",
4
+ fields: [{
5
+ label: "Banner Spacing",
6
+ key: "bannerSpacing",
7
+ type: "bannerSpacing"
8
+ }]
9
+ }, {
10
+ tab: "Border Radius",
11
+ value: "borderRadius",
12
+ fields: [{
13
+ label: "Border Radius",
14
+ key: "borderRadius",
15
+ type: "borderRadius"
16
+ }]
17
+ }, {
18
+ tab: "Colors",
19
+ value: "colors",
20
+ fields: [{
21
+ label: "Text",
22
+ key: "textColor",
23
+ type: "color",
24
+ needPreview: true
25
+ }, {
26
+ label: "Background",
27
+ key: "bgColor",
28
+ type: "color"
29
+ }, {
30
+ label: "Border",
31
+ key: "borderColor",
32
+ type: "color"
33
+ }]
34
+ }, {
35
+ tab: "Position",
36
+ value: "position",
37
+ fields: [{
38
+ label: "Set Postion (Vertical & Horizantal)",
39
+ key: "alignment",
40
+ type: "alignment"
41
+ }]
42
+ }, {
43
+ tab: "Size",
44
+ value: "gridSize",
45
+ fields: [{
46
+ label: "Grid Size",
47
+ key: "grid",
48
+ type: "gridSize"
49
+ }]
50
+ }];
51
+ export default gridItemStyle;
@@ -0,0 +1,51 @@
1
+ const gridStyle = [{
2
+ tab: "Banner Spacing",
3
+ value: "bannerSpacing",
4
+ fields: [{
5
+ label: "Banner Spacing",
6
+ key: "bannerSpacing",
7
+ type: "bannerSpacing"
8
+ }]
9
+ }, {
10
+ tab: "Border Radius",
11
+ value: "borderRadius",
12
+ fields: [{
13
+ label: "Border Radius",
14
+ key: "borderRadius",
15
+ type: "borderRadius"
16
+ }]
17
+ }, {
18
+ tab: "Colors",
19
+ value: "colors",
20
+ fields: [{
21
+ label: "Text",
22
+ key: "textColor",
23
+ type: "color",
24
+ needPreview: true
25
+ }, {
26
+ label: "Background",
27
+ key: "bgColor",
28
+ type: "color"
29
+ }, {
30
+ label: "Border",
31
+ key: "borderColor",
32
+ type: "color"
33
+ }]
34
+ }, {
35
+ tab: "Position",
36
+ value: "position",
37
+ fields: [{
38
+ label: "Set Postion (Vertical & Horizantal)",
39
+ key: "alignment",
40
+ type: "alignment"
41
+ }]
42
+ }, {
43
+ tab: "Background",
44
+ value: "backgroundImage",
45
+ fields: [{
46
+ label: "Background Image",
47
+ key: "backgroundImage",
48
+ type: "backgroundImage"
49
+ }]
50
+ }];
51
+ export default gridStyle;
@@ -0,0 +1,114 @@
1
+ import React, { useState } from "react";
2
+ import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Tabs, Tab, Grid } from "@mui/material";
3
+ import FieldMap from "./fieldTypes";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ const StyleContent = props => {
7
+ const {
8
+ value,
9
+ renderTabs,
10
+ onChange,
11
+ element,
12
+ customProps
13
+ } = props;
14
+ const tabContent = renderTabs.find(f => f.value === value);
15
+ const {
16
+ fields
17
+ } = tabContent || {
18
+ fields: []
19
+ };
20
+ return /*#__PURE__*/_jsx(Grid, {
21
+ container: true,
22
+ spacing: 2,
23
+ children: /*#__PURE__*/_jsx(Grid, {
24
+ item: true,
25
+ xs: 12,
26
+ style: {
27
+ marginTop: "12px"
28
+ },
29
+ children: [...fields].map(m => {
30
+ const FieldComponent = FieldMap[m.type];
31
+ return FieldComponent ? /*#__PURE__*/_jsx(FieldComponent, {
32
+ data: m,
33
+ value: element[m.key],
34
+ onChange: onChange,
35
+ elementProps: element,
36
+ customProps: customProps
37
+ }, `ei_stt_tab_${value}_${m.key}`) : null;
38
+ })
39
+ })
40
+ }, value);
41
+ };
42
+ const StyleTabs = props => {
43
+ const {
44
+ value,
45
+ handleChange,
46
+ renderTabs
47
+ } = props;
48
+ return /*#__PURE__*/_jsx(Tabs, {
49
+ value: value,
50
+ onChange: handleChange,
51
+ variant: "scrollable",
52
+ scrollButtons: "auto",
53
+ "aria-label": "scrollable auto tabs example",
54
+ children: renderTabs.map((m, i) => {
55
+ return /*#__PURE__*/_jsx(Tab, {
56
+ value: m.value,
57
+ label: m.tab
58
+ }, `editor-stt-tab-${m.value}`);
59
+ })
60
+ });
61
+ };
62
+ const StyleBuilder = props => {
63
+ const {
64
+ title,
65
+ renderTabs,
66
+ element,
67
+ onSave,
68
+ onClose,
69
+ customProps
70
+ } = props;
71
+ const [elementProps, setElementProps] = useState(element);
72
+ const [tab, setTab] = useState(renderTabs[0]?.value);
73
+ const handleChange = (e, newValue) => {
74
+ setTab(newValue);
75
+ };
76
+ const onElementPropsChange = data => {
77
+ console.log(data);
78
+ setElementProps({
79
+ ...elementProps,
80
+ ...data
81
+ });
82
+ };
83
+ const handleSave = () => {
84
+ onSave(elementProps);
85
+ };
86
+ return /*#__PURE__*/_jsxs(Dialog, {
87
+ open: true,
88
+ fullWidth: true,
89
+ children: [/*#__PURE__*/_jsx(DialogTitle, {
90
+ children: title
91
+ }), /*#__PURE__*/_jsxs(DialogContent, {
92
+ children: [/*#__PURE__*/_jsx(StyleTabs, {
93
+ renderTabs: renderTabs,
94
+ value: tab,
95
+ handleChange: handleChange
96
+ }), /*#__PURE__*/_jsx(StyleContent, {
97
+ renderTabs: renderTabs,
98
+ value: tab,
99
+ element: elementProps,
100
+ onChange: onElementPropsChange,
101
+ customProps: customProps
102
+ })]
103
+ }), /*#__PURE__*/_jsxs(DialogActions, {
104
+ children: [/*#__PURE__*/_jsx(Button, {
105
+ onClick: onClose,
106
+ children: "Cancel"
107
+ }), /*#__PURE__*/_jsx(Button, {
108
+ onClick: handleSave,
109
+ children: "Save"
110
+ })]
111
+ })]
112
+ });
113
+ };
114
+ export default StyleBuilder;
@@ -0,0 +1,10 @@
1
+ const pageSettingsStyle = [{
2
+ tab: "Colors",
3
+ value: "colors",
4
+ fields: [{
5
+ label: "Background",
6
+ key: "pageColor",
7
+ type: "color"
8
+ }]
9
+ }];
10
+ export default pageSettingsStyle;
@@ -0,0 +1,38 @@
1
+ const tableStyle = [{
2
+ tab: "Table",
3
+ value: "tableSettings",
4
+ fields: [{
5
+ label: "Table Background",
6
+ key: "table.bgColor",
7
+ type: "color"
8
+ }, {
9
+ label: "Border",
10
+ key: "table.borderColor",
11
+ type: "color"
12
+ }]
13
+ }, {
14
+ tab: "Row",
15
+ value: "rowSettings",
16
+ fields: [{
17
+ label: "Background",
18
+ key: "row.bgColor",
19
+ type: "color"
20
+ }, {
21
+ label: "Border",
22
+ key: "row.borderColor",
23
+ type: "color"
24
+ }]
25
+ }, {
26
+ tab: "Column",
27
+ value: "columnSettings",
28
+ fields: [{
29
+ label: "Background",
30
+ key: "col.bgColor",
31
+ type: "color"
32
+ }, {
33
+ label: "Border",
34
+ key: "col.borderColor",
35
+ type: "color"
36
+ }]
37
+ }];
38
+ export default tableStyle;
@@ -0,0 +1,87 @@
1
+ import React, { useState } from "react";
2
+ import { Grid, Button } from "@mui/material";
3
+ import CloudUploadIcon from "@mui/icons-material/CloudUpload";
4
+ import { convertBase64 } from "../utils/helper";
5
+ import { uploadFile } from "../service/fileupload";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ const Uploader = props => {
9
+ const {
10
+ value,
11
+ data,
12
+ onUploaded,
13
+ customProps
14
+ } = props;
15
+ const {
16
+ key
17
+ } = data;
18
+ const [base64, setBase64] = useState(value);
19
+ const [uploading, setUploading] = useState(false);
20
+ const handleChange = async e => {
21
+ const file = e.target.files[0];
22
+ const strImage = await convertBase64(file);
23
+ setBase64(strImage);
24
+ doUpload(strImage);
25
+ };
26
+ const doUpload = async strImage => {
27
+ setUploading(true);
28
+ const result = await uploadFile({
29
+ image: strImage
30
+ }, customProps);
31
+ setUploading(false);
32
+ if (result && result?.imageURL) {
33
+ onUploaded({
34
+ [key]: result?.imageURL
35
+ });
36
+ }
37
+ };
38
+ const onRemoveBG = () => {
39
+ setBase64(null);
40
+ onUploaded({
41
+ [key]: "none"
42
+ });
43
+ };
44
+ return /*#__PURE__*/_jsxs(Grid, {
45
+ container: true,
46
+ padding: 3,
47
+ children: [/*#__PURE__*/_jsxs(Grid, {
48
+ item: true,
49
+ xs: 12,
50
+ style: {
51
+ display: "flex"
52
+ },
53
+ justifyContent: "center",
54
+ alignItems: "center",
55
+ children: [/*#__PURE__*/_jsxs(Button, {
56
+ component: "label",
57
+ variant: "contained",
58
+ startIcon: /*#__PURE__*/_jsx(CloudUploadIcon, {}),
59
+ children: ["Upload file", /*#__PURE__*/_jsx("input", {
60
+ type: "file",
61
+ style: {
62
+ opacity: 0
63
+ },
64
+ onChange: handleChange
65
+ })]
66
+ }), /*#__PURE__*/_jsx("input", {
67
+ type: "checkbox",
68
+ value: "none",
69
+ checked: value === "none",
70
+ onChange: onRemoveBG
71
+ }), " ", "None"]
72
+ }), uploading ? "Uploading..." : "", /*#__PURE__*/_jsx(Grid, {
73
+ item: true,
74
+ xs: 12,
75
+ style: {
76
+ marginTop: "12px",
77
+ width: "100%",
78
+ backgroundImage: base64 ? `url(${base64})` : "none",
79
+ backgroundSize: "contain",
80
+ backgroundRepeat: "no-repeat",
81
+ backgroundPosition: "center",
82
+ height: "100px"
83
+ }
84
+ })]
85
+ });
86
+ };
87
+ export default Uploader;
@@ -1,20 +1,27 @@
1
- import { Transforms, Path, Node } from 'slate';
1
+ import { Transforms, Path, Node } from "slate";
2
2
  const withEmbeds = editor => {
3
3
  const {
4
4
  isVoid,
5
5
  insertBreak
6
6
  } = editor;
7
- editor.isVoid = element => ['video', 'image', 'htmlCode'].includes(element.type) ? true : isVoid(element);
7
+ editor.isVoid = element => {
8
+ if (["video", "htmlCode"].includes(element.type)) {
9
+ return true;
10
+ } else if (element.type === "image") {
11
+ return true;
12
+ } else {
13
+ return isVoid(element);
14
+ }
15
+ };
8
16
  editor.insertBreak = (...args) => {
9
17
  const parentPath = Path.parent(editor.selection.focus.path);
10
18
  const parentNode = Node.get(editor, parentPath);
11
- // console.log(parentNode);
12
19
  if (editor.isVoid(parentNode)) {
13
20
  const nextPath = Path.next(parentPath);
14
21
  Transforms.insertNodes(editor, {
15
- type: 'paragraph',
22
+ type: "paragraph",
16
23
  children: [{
17
- text: ''
24
+ text: ""
18
25
  }]
19
26
  }, {
20
27
  at: nextPath,
@@ -1,4 +1,5 @@
1
1
  import { Editor, Range, Point, Element } from "slate";
2
+ const NON_DELETABLE_BLOCKS = ["table-cell", "carousel-item"];
2
3
  const withTable = editor => {
3
4
  const {
4
5
  deleteBackward,
@@ -10,12 +11,12 @@ const withTable = editor => {
10
11
  } = editor;
11
12
  if (selection) {
12
13
  const [cell] = Editor.nodes(editor, {
13
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
14
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && NON_DELETABLE_BLOCKS.indexOf(n.type) > -1
14
15
  });
15
16
  const prevNodePath = Editor.before(editor, selection);
16
17
  const [tableNode] = Editor.nodes(editor, {
17
18
  at: prevNodePath,
18
- match: n => !Editor.isEditor(n) && Element.isElement && n.type === "table-cell"
19
+ match: n => !Editor.isEditor(n) && Element.isElement && NON_DELETABLE_BLOCKS.indexOf(n.type) > -1
19
20
  });
20
21
  if (cell) {
21
22
  const [, cellPath] = cell;
@@ -36,12 +37,12 @@ const withTable = editor => {
36
37
  } = editor;
37
38
  if (selection && Range.isCollapsed(selection)) {
38
39
  const [cell] = Editor.nodes(editor, {
39
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
40
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && NON_DELETABLE_BLOCKS.indexOf(n.type) > -1
40
41
  });
41
42
  const prevNodePath = Editor.after(editor, selection);
42
43
  const [tableNode] = Editor.nodes(editor, {
43
44
  at: prevNodePath,
44
- match: n => !Editor.isEditor(n) && Element.isElement && n.type === "table-cell"
45
+ match: n => !Editor.isEditor(n) && Element.isElement && NON_DELETABLE_BLOCKS.indexOf(n.type) > -1
45
46
  });
46
47
  if (cell) {
47
48
  const [, cellPath] = cell;
@@ -0,0 +1,17 @@
1
+ export const uploadFile = async (formData, props) => {
2
+ try {
3
+ const response = await fetch(`${props.API_HOST}/api/v1/general/notes/file_upload`, {
4
+ method: "POST",
5
+ headers: {
6
+ "Content-Type": "application/json",
7
+ Authorization: `Bearer ${props.token}`
8
+ },
9
+ body: JSON.stringify(formData)
10
+ });
11
+ const result = await response.json();
12
+ return result.data;
13
+ } catch (err) {
14
+ console.log(err);
15
+ return err;
16
+ }
17
+ };
@@ -1,27 +1,29 @@
1
1
  import { Editor, Transforms, Element as SlateElement } from "slate";
2
+ import { fontFamilyMap, sizeMap } from "./font";
2
3
  import Link from "../Elements/Link/Link";
3
4
  import Image from "../Elements/Embed/Image";
4
5
  import Video from "../Elements/Embed/Video";
5
6
  import Equation from "../Elements/Equation/Equation";
6
7
  import HtmlCode from "../Elements/CodeToText/HtmlCode";
7
8
  import Table from "../Elements/Table/Table";
9
+ import TableRow from "../Elements/Table/TableRow";
10
+ import TableCell from "../Elements/Table/TableCell";
8
11
  import Mentions from "../Elements/Mentions/Mentions";
9
12
  import Grid from "../Elements/Grid/Grid";
10
13
  import GridItem from "../Elements/Grid/GridItem";
14
+ import Accordion from "../Elements/Accordion/Accordion";
15
+ import AccordionSummary from "../Elements/Accordion/AccordionSummary";
16
+ import AccordionDetails from "../Elements/Accordion/AccordionDetails";
17
+ import Signature from "../Elements/Signature/Signature";
18
+ import Signed from "../Elements/Signature/Signed";
19
+ import EditorButton from "../Elements/Button/EditorButton";
20
+ import Carousel from "../Elements/Carousel/Carousel";
21
+ import CarouselItem from "../Elements/Carousel/CarouselItem";
22
+ import ImageTextWrapper from "../Elements/ImageText/ImageTextWrapper";
23
+ import ImageText from "../Elements/ImageText/ImageText";
11
24
  import { jsx as _jsx } from "react/jsx-runtime";
12
25
  const alignment = ["alignLeft", "alignRight", "alignCenter"];
13
26
  const list_types = ["orderedList", "unorderedList"];
14
- export const sizeMap = {
15
- small: "0.75em",
16
- normal: "1em",
17
- medium: "1.75em",
18
- huge: "2.5em"
19
- };
20
- export const fontFamilyMap = {
21
- sans: "Helvetica,Arial, sans serif",
22
- serif: "Georgia, Times New Roaman,serif",
23
- monospace: "Monaco, Courier New,monospace"
24
- };
25
27
  export const toggleBlock = (editor, format) => {
26
28
  const isActive = isBlockActive(editor, format);
27
29
  const isList = list_types.includes(format);
@@ -71,8 +73,13 @@ export const toggleMark = (editor, format) => {
71
73
  }
72
74
  };
73
75
  export const isMarkActive = (editor, format) => {
74
- const marks = Editor.marks(editor);
75
- return marks ? marks[format] === true : false;
76
+ try {
77
+ const marks = Editor.marks(editor);
78
+ return marks ? marks[format] === true : false;
79
+ } catch (err) {
80
+ console.log(err);
81
+ return null;
82
+ }
76
83
  };
77
84
  export const isBlockActive = (editor, format) => {
78
85
  const [match] = Editor.nodes(editor, {
@@ -87,9 +94,14 @@ export const activeMark = (editor, format) => {
87
94
  fontSize: "normal",
88
95
  fontFamily: "sans"
89
96
  };
90
- const marks = Editor.marks(editor);
91
- const defaultValue = defaultMarkData[format];
92
- return marks?.[format] ?? defaultValue;
97
+ try {
98
+ const marks = Editor.marks(editor);
99
+ const defaultValue = defaultMarkData[format];
100
+ return marks?.[format] ?? defaultValue;
101
+ } catch (err) {
102
+ console.log(err);
103
+ return null;
104
+ }
93
105
  };
94
106
  export const getMarked = (leaf, children) => {
95
107
  if (leaf.bold) {
@@ -256,20 +268,25 @@ export const getBlock = props => {
256
268
  ...props
257
269
  });
258
270
  case "table-row":
259
- return /*#__PURE__*/_jsx("tr", {
260
- ...attributes,
261
- children: children
271
+ return /*#__PURE__*/_jsx(TableRow, {
272
+ ...props
262
273
  });
263
274
  case "table-cell":
264
- return /*#__PURE__*/_jsx("td", {
265
- ...element.attr,
266
- ...attributes,
267
- children: children
275
+ return /*#__PURE__*/_jsx(TableCell, {
276
+ ...props
268
277
  });
269
278
  case "image":
270
279
  return /*#__PURE__*/_jsx(Image, {
271
280
  ...props
272
281
  });
282
+ case "image-text-wrapper":
283
+ return /*#__PURE__*/_jsx(ImageTextWrapper, {
284
+ ...props
285
+ });
286
+ case "image-text":
287
+ return /*#__PURE__*/_jsx(ImageText, {
288
+ ...props
289
+ });
273
290
  case "video":
274
291
  return /*#__PURE__*/_jsx(Video, {
275
292
  ...props
@@ -294,6 +311,38 @@ export const getBlock = props => {
294
311
  return /*#__PURE__*/_jsx(GridItem, {
295
312
  ...props
296
313
  });
314
+ case "accordion":
315
+ return /*#__PURE__*/_jsx(Accordion, {
316
+ ...props
317
+ });
318
+ case "accordion-summary":
319
+ return /*#__PURE__*/_jsx(AccordionSummary, {
320
+ ...props
321
+ });
322
+ case "accordion-details":
323
+ return /*#__PURE__*/_jsx(AccordionDetails, {
324
+ ...props
325
+ });
326
+ case "signature":
327
+ return /*#__PURE__*/_jsx(Signature, {
328
+ ...props
329
+ });
330
+ case "sign":
331
+ return /*#__PURE__*/_jsx(Signed, {
332
+ ...props
333
+ });
334
+ case "button":
335
+ return /*#__PURE__*/_jsx(EditorButton, {
336
+ ...props
337
+ });
338
+ case "carousel":
339
+ return /*#__PURE__*/_jsx(Carousel, {
340
+ ...props
341
+ });
342
+ case "carousel-item":
343
+ return /*#__PURE__*/_jsx(CarouselItem, {
344
+ ...props
345
+ });
297
346
  default:
298
347
  return /*#__PURE__*/_jsx("div", {
299
348
  ...element.attr,
@@ -0,0 +1,25 @@
1
+ import { Transforms } from "slate";
2
+ export const insertAccordion = editor => {
3
+ const accordion = {
4
+ type: "accordion",
5
+ children: [{
6
+ type: "accordion-summary",
7
+ children: [{
8
+ type: "paragraph",
9
+ children: [{
10
+ text: "Accordion Header"
11
+ }]
12
+ }]
13
+ }, {
14
+ type: "accordion-details",
15
+ children: [{
16
+ type: "paragraph",
17
+ children: [{
18
+ text: "Accordion Content"
19
+ }]
20
+ }]
21
+ }]
22
+ };
23
+ Transforms.insertNodes(editor, accordion);
24
+ Transforms.move(editor);
25
+ };
@@ -0,0 +1,11 @@
1
+ import { Transforms } from "slate";
2
+ export const insertButton = editor => {
3
+ const button = {
4
+ type: "button",
5
+ children: [{
6
+ text: ""
7
+ }]
8
+ };
9
+ Transforms.insertNodes(editor, button);
10
+ Transforms.move(editor);
11
+ };
@@ -0,0 +1,13 @@
1
+ import { Transforms } from "slate";
2
+ import { carouselItem } from "./carouselItem";
3
+ export const insertCarousel = editor => {
4
+ const grid = {
5
+ type: "carousel",
6
+ grid: "container",
7
+ children: [{
8
+ ...carouselItem()
9
+ }]
10
+ };
11
+ Transforms.insertNodes(editor, grid);
12
+ Transforms.move(editor);
13
+ };