@flozy/editor 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +10 -8
- package/dist/Editor/Editor.css +15 -12
- package/dist/Editor/Elements/AppHeader/AppHeader.js +5 -11
- package/dist/Editor/Elements/Button/EditorButton.js +4 -10
- package/dist/Editor/Elements/Carousel/Arrows.js +6 -2
- package/dist/Editor/Elements/Carousel/Carousel.js +1 -1
- package/dist/Editor/Elements/ChipText/ChipText.js +8 -12
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +5 -3
- package/dist/Editor/Elements/Color Picker/Styles.js +3 -17
- package/dist/Editor/Elements/Color Picker/colorWheel.png +0 -0
- package/dist/Editor/Elements/Embed/Embed.css +48 -45
- package/dist/Editor/Elements/Embed/Image.js +8 -14
- package/dist/Editor/Elements/Embed/Video.js +1 -7
- package/dist/Editor/Elements/Form/Form.js +17 -23
- package/dist/Editor/Elements/Form/FormElements/FormText.js +8 -12
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +8 -12
- package/dist/Editor/Elements/Grid/Grid.js +8 -20
- package/dist/Editor/Elements/Grid/GridItem.js +13 -23
- package/dist/Editor/Elements/Grid/templates/carousel_item.js +2 -3
- package/dist/Editor/Elements/Grid/templates/default_grid.js +2 -2
- package/dist/Editor/Elements/SimpleText.js +0 -1
- package/dist/Editor/Elements/Table/Table.js +3 -1
- package/dist/Editor/Elements/TopBanner/TopBanner.js +3 -1
- package/dist/Editor/IframeEditor.js +36 -0
- package/dist/Editor/MiniEditor.js +6 -8
- package/dist/Editor/Styles/EditorStyles.js +13 -2
- package/dist/Editor/Toolbar/Basic/index.js +3 -1
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +30 -13
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +7 -1
- package/dist/Editor/common/Icon.js +3 -0
- package/dist/Editor/common/Section/index.js +13 -16
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +13 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/gridSize.js +10 -3
- package/dist/Editor/common/StyleBuilder/formStyle.js +3 -0
- package/dist/Editor/common/StyleBuilder/sectionStyle.js +1 -1
- package/dist/Editor/helper/theme.js +83 -0
- package/dist/Editor/hooks/useWindowMessage.js +35 -0
- package/dist/Editor/hooks/useWindowResize.js +5 -2
- package/dist/Editor/plugins/withLayout.js +42 -27
- package/dist/Editor/utils/SlateUtilityFunctions.js +22 -5
- package/dist/index.js +3 -1
- package/package.json +1 -1
- package/dist/Editor/Elements/Color Picker/LogoIcon.js +0 -25
@@ -0,0 +1,83 @@
|
|
1
|
+
import { sizeMap } from "../utils/font";
|
2
|
+
export const breakpoints = {
|
3
|
+
small: 0,
|
4
|
+
mobile: 600,
|
5
|
+
tablet: 900
|
6
|
+
};
|
7
|
+
export const BREAKPOINTS_DEVICES = ["xs", "sm", "md", "lg"];
|
8
|
+
export const getDevice = width => {
|
9
|
+
if (width > 0 && width < breakpoints.mobile) {
|
10
|
+
return "xs";
|
11
|
+
} else {
|
12
|
+
return "lg";
|
13
|
+
}
|
14
|
+
};
|
15
|
+
const copyAllLg = (value, ot) => {
|
16
|
+
return BREAKPOINTS_DEVICES.reduce((a, b) => {
|
17
|
+
return {
|
18
|
+
...a,
|
19
|
+
[b]: overrides[ot] ? overrides[ot](value) : value
|
20
|
+
};
|
21
|
+
}, {});
|
22
|
+
};
|
23
|
+
const overrideValues = (value, ot) => {
|
24
|
+
return Object.keys(value).reduce((a, b) => {
|
25
|
+
return {
|
26
|
+
...a,
|
27
|
+
[b]: overrides[ot] ? overrides[ot](value[b]) : value
|
28
|
+
};
|
29
|
+
}, {});
|
30
|
+
};
|
31
|
+
const overrides = {
|
32
|
+
overrideText: val => {
|
33
|
+
return sizeMap[val] || val;
|
34
|
+
},
|
35
|
+
overrideGridSize: val => {
|
36
|
+
return `${(val || 8) / 12 * 100}%`;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
export const getBreakPointsValue = (value, breakpoint, ot = null, ov = false) => {
|
40
|
+
try {
|
41
|
+
if (breakpoint) {
|
42
|
+
if (typeof value !== "object") {
|
43
|
+
return value;
|
44
|
+
}
|
45
|
+
return value ? value[breakpoint] || value["lg"] : value;
|
46
|
+
} else if (typeof value === "object") {
|
47
|
+
return !breakpoint && value["lg"] ? !ov ? value : overrideValues(value, ot) : value[breakpoint] || copyAllLg(value, ot);
|
48
|
+
} else {
|
49
|
+
// consider without breakpoints
|
50
|
+
return copyAllLg(value, ot);
|
51
|
+
}
|
52
|
+
} catch (err) {
|
53
|
+
console.log(err);
|
54
|
+
}
|
55
|
+
};
|
56
|
+
export const getTRBLBreakPoints = (value, breakpoint) => {
|
57
|
+
try {
|
58
|
+
const values = getBreakPointsValue(value, breakpoint);
|
59
|
+
const cssVal = BREAKPOINTS_DEVICES.reduce((a, b) => {
|
60
|
+
if (values[b] || values["lg"]) {
|
61
|
+
const {
|
62
|
+
top,
|
63
|
+
right,
|
64
|
+
bottom,
|
65
|
+
left
|
66
|
+
} = values[b] || values["lg"];
|
67
|
+
return {
|
68
|
+
...a,
|
69
|
+
[b]: `${top || 0}px ${right || 0}px ${bottom || 0}px ${left || 0}px`
|
70
|
+
};
|
71
|
+
} else {
|
72
|
+
return a;
|
73
|
+
}
|
74
|
+
}, {});
|
75
|
+
if (breakpoint) {
|
76
|
+
return value[breakpoint] || value["lg"] || value;
|
77
|
+
} else {
|
78
|
+
return cssVal;
|
79
|
+
}
|
80
|
+
} catch (err) {
|
81
|
+
console.log(err);
|
82
|
+
}
|
83
|
+
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { useEffect, useState } from "react";
|
2
|
+
const useWindowMessage = props => {
|
3
|
+
const {
|
4
|
+
type
|
5
|
+
} = props;
|
6
|
+
const [message, setMessage] = useState(null);
|
7
|
+
useEffect(() => {
|
8
|
+
if (window.addEventListener) {
|
9
|
+
window.addEventListener("message", onMessage, false);
|
10
|
+
} else {
|
11
|
+
window.attachEvent("onmessage", onMessage);
|
12
|
+
}
|
13
|
+
return () => {
|
14
|
+
if (window.addEventListener) {
|
15
|
+
window.removeEventListener("message", onMessage, false);
|
16
|
+
} else {
|
17
|
+
window.detachEvent("onmessage", onMessage);
|
18
|
+
}
|
19
|
+
};
|
20
|
+
}, []);
|
21
|
+
const onMessage = e => {
|
22
|
+
if (e?.data && e?.data[type]) {
|
23
|
+
setMessage(e?.data[type]);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
const sendMessage = action => {
|
27
|
+
if (window.parent) {
|
28
|
+
window.parent.postMessage({
|
29
|
+
...action
|
30
|
+
}, "http://localhost:3000");
|
31
|
+
}
|
32
|
+
};
|
33
|
+
return [message, sendMessage];
|
34
|
+
};
|
35
|
+
export default useWindowMessage;
|
@@ -1,13 +1,16 @@
|
|
1
1
|
import { useEffect, useState } from "react";
|
2
|
+
import { getDevice } from "../helper/theme";
|
2
3
|
const useWindowResize = () => {
|
3
4
|
const [size, setSize] = useState({
|
4
5
|
width: window.innerWidth,
|
5
|
-
height: window.innerHeight
|
6
|
+
height: window.innerHeight,
|
7
|
+
device: getDevice(window.innerWidth)
|
6
8
|
});
|
7
9
|
const onResize = () => {
|
8
10
|
setSize({
|
9
11
|
width: window.innerWidth,
|
10
|
-
height: window.innerHeight
|
12
|
+
height: window.innerHeight,
|
13
|
+
device: getDevice(window.innerWidth)
|
11
14
|
});
|
12
15
|
};
|
13
16
|
useEffect(() => {
|
@@ -1,4 +1,30 @@
|
|
1
|
-
import { Transforms, Node,
|
1
|
+
import { Transforms, Node, Editor } from "slate";
|
2
|
+
const ORDERS_LAYOUT = ["topbanner", "title", "paragraph"];
|
3
|
+
const ORDERS_LAYOUT_VALIDATIONS = {
|
4
|
+
topbanner: val => {
|
5
|
+
if (val.type !== ORDERS_LAYOUT[0]) {
|
6
|
+
return "title";
|
7
|
+
} else {
|
8
|
+
return val.type;
|
9
|
+
}
|
10
|
+
},
|
11
|
+
title: (val, prev) => {
|
12
|
+
if (prev?.type === "topbanner") {
|
13
|
+
return "title";
|
14
|
+
} else if (prev?.type === "title" && val?.type !== "title") {
|
15
|
+
return val.type;
|
16
|
+
} else {
|
17
|
+
return "paragraph";
|
18
|
+
}
|
19
|
+
},
|
20
|
+
paragraph: val => {
|
21
|
+
if (val.type === "title") {
|
22
|
+
return "paragraph";
|
23
|
+
} else {
|
24
|
+
return val.type;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
};
|
2
28
|
const withLayout = editor => {
|
3
29
|
const {
|
4
30
|
normalizeNode
|
@@ -17,7 +43,7 @@ const withLayout = editor => {
|
|
17
43
|
select: true
|
18
44
|
});
|
19
45
|
}
|
20
|
-
if (editor.children.length
|
46
|
+
if (editor.children.length === 0) {
|
21
47
|
const paragraph = {
|
22
48
|
type: "paragraph",
|
23
49
|
children: [{
|
@@ -28,34 +54,23 @@ const withLayout = editor => {
|
|
28
54
|
at: path.concat(1)
|
29
55
|
});
|
30
56
|
}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Transforms.setNodes(editor,
|
41
|
-
|
57
|
+
ORDERS_LAYOUT.forEach((enforce, index) => {
|
58
|
+
if (index < editor.children.length) {
|
59
|
+
const existsNode = Node.get(editor, [index]);
|
60
|
+
let prevNode = null;
|
61
|
+
if (index > 0) {
|
62
|
+
prevNode = Node.get(editor, [index - 1]);
|
63
|
+
}
|
64
|
+
const newType = ORDERS_LAYOUT_VALIDATIONS[enforce](existsNode, prevNode);
|
65
|
+
if (existsNode?.type !== newType) {
|
66
|
+
Transforms.setNodes(editor, {
|
67
|
+
type: newType
|
68
|
+
}, {
|
69
|
+
at: [index]
|
42
70
|
});
|
43
71
|
}
|
44
|
-
};
|
45
|
-
switch (slateIndex) {
|
46
|
-
case 0:
|
47
|
-
type = child.type === "topbanner" ? "topbanner" : "title";
|
48
|
-
prevType = type;
|
49
|
-
enforceType(type);
|
50
|
-
break;
|
51
|
-
case 1:
|
52
|
-
type = prevType === "topbanner" ? "title" : "paragraph";
|
53
|
-
enforceType(type);
|
54
|
-
break;
|
55
|
-
default:
|
56
|
-
break;
|
57
72
|
}
|
58
|
-
}
|
73
|
+
});
|
59
74
|
}
|
60
75
|
return normalizeNode([node, path]);
|
61
76
|
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Editor, Transforms, Element as SlateElement } from "slate";
|
2
|
+
import { Box } from "@mui/material";
|
2
3
|
import { fontFamilyMap, sizeMap } from "./font";
|
3
4
|
import Link from "../Elements/Link/Link";
|
4
5
|
import Image from "../Elements/Embed/Image";
|
@@ -34,6 +35,7 @@ import SimpleText from "../Elements/SimpleText";
|
|
34
35
|
import CheckList from "../Elements/List/CheckList";
|
35
36
|
import { isEmptyTextNode } from "../helper";
|
36
37
|
import Attachments from "../Elements/Attachments/Attachments";
|
38
|
+
import { getBreakPointsValue } from "../helper/theme";
|
37
39
|
import Variables from "../Elements/Variables/Variable";
|
38
40
|
import { jsx as _jsx } from "react/jsx-runtime";
|
39
41
|
const alignment = ["alignLeft", "alignRight", "alignCenter"];
|
@@ -86,7 +88,11 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
86
88
|
}
|
87
89
|
};
|
88
90
|
export const addMarkData = (editor, data) => {
|
89
|
-
|
91
|
+
try {
|
92
|
+
Editor.addMark(editor, data.format, data.value);
|
93
|
+
} catch (err) {
|
94
|
+
console.log(err);
|
95
|
+
}
|
90
96
|
};
|
91
97
|
export const toggleMark = (editor, format) => {
|
92
98
|
const isActive = isMarkActive(editor, format);
|
@@ -210,10 +216,13 @@ export const getMarked = (leaf, children) => {
|
|
210
216
|
});
|
211
217
|
}
|
212
218
|
if (leaf.fontSize) {
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
fontSize:
|
219
|
+
children = /*#__PURE__*/_jsx(Box, {
|
220
|
+
component: "span",
|
221
|
+
sx: {
|
222
|
+
fontSize: {
|
223
|
+
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
224
|
+
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
225
|
+
}
|
217
226
|
},
|
218
227
|
children: children
|
219
228
|
});
|
@@ -484,6 +493,14 @@ export const getBlock = props => {
|
|
484
493
|
return /*#__PURE__*/_jsx(Variables, {
|
485
494
|
...props
|
486
495
|
});
|
496
|
+
case "topbanner":
|
497
|
+
return /*#__PURE__*/_jsx("span", {
|
498
|
+
...props,
|
499
|
+
style: {
|
500
|
+
display: "none"
|
501
|
+
},
|
502
|
+
children: children
|
503
|
+
});
|
487
504
|
default:
|
488
505
|
return /*#__PURE__*/_jsx(SimpleText, {
|
489
506
|
...props,
|
package/dist/index.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import Collaborative from "./Editor/CollaborativeEditor";
|
2
2
|
import CommonEditor from "./Editor/CommonEditor";
|
3
3
|
import Mini from "./Editor/MiniEditor";
|
4
|
+
import EditorInFrame from "./Editor/IframeEditor";
|
4
5
|
export const Editor = CommonEditor;
|
5
6
|
export const MiniEditor = Mini;
|
6
|
-
export const CollaborativeEditor = Collaborative;
|
7
|
+
export const CollaborativeEditor = Collaborative;
|
8
|
+
export const IframeEditor = EditorInFrame;
|
package/package.json
CHANGED
@@ -1,25 +0,0 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
export const logo = {
|
3
|
-
color: color => /*#__PURE__*/_jsx("svg", {
|
4
|
-
width: "14",
|
5
|
-
height: "14",
|
6
|
-
viewBox: "0 0 11 14",
|
7
|
-
fill: "none",
|
8
|
-
xmlns: "http://www.w3.org/2000/svg",
|
9
|
-
children: /*#__PURE__*/_jsx("path", {
|
10
|
-
d: "M5.16796 0C5.16796 0 0 5.92326 0 8.8319C0 12.0176 2.65524 14 5.16796 14C7.83258 14 10.3359 11.9129 10.3359 8.8319C10.3359 5.92326 5.16796 0 5.16796 0ZM8.7402 9.70788C8.45278 11.3396 7.03388 12.0548 5.89918 12.0548C5.80706 12.0543 9.14466 10.6134 7.85834 6.30322C8.53622 7.06776 8.96266 8.4448 8.7402 9.70788Z",
|
11
|
-
fill: "#778599"
|
12
|
-
})
|
13
|
-
}),
|
14
|
-
bgColor: color => /*#__PURE__*/_jsx("svg", {
|
15
|
-
width: "14",
|
16
|
-
height: "14",
|
17
|
-
viewBox: "0 0 14 14",
|
18
|
-
fill: "none",
|
19
|
-
xmlns: "http://www.w3.org/2000/svg",
|
20
|
-
children: /*#__PURE__*/_jsx("path", {
|
21
|
-
d: "M13.5512 6.73405L6.71385 12.8277C6.30072 13.1996 5.76365 13.3648 5.22658 13.3442C4.6895 13.3235 4.19375 13.0756 3.80127 12.6625L0.516875 8.98561C-0.226762 8.13869 -0.164793 6.83733 0.682127 6.09369L7.51946 0L13.5512 6.7547V6.73405ZM13.3859 8.01475C13.4479 8.26263 11.6095 11.1959 13.138 11.3818C14.9558 11.5883 13.324 7.76687 13.3859 8.01475ZM12.5183 6.67208L7.47814 1.03283L1.19854 6.65142L12.5183 6.69273V6.67208Z",
|
22
|
-
fill: "#64748B"
|
23
|
-
})
|
24
|
-
})
|
25
|
-
};
|