@flozy/editor 5.8.6 → 5.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Editor/CommonEditor.js +6 -4
- package/dist/Editor/Editor.css +30 -15
- package/dist/Editor/Elements/Button/EditorButton.js +2 -1
- package/dist/Editor/Elements/Divider/Divider.js +3 -3
- package/dist/Editor/Elements/Grid/GridItem.js +1 -2
- package/dist/Editor/Elements/Link/Link.js +42 -31
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Title/title.js +13 -1
- package/dist/Editor/Elements/Variables/Style.js +28 -2
- package/dist/Editor/Elements/Variables/VariableButton.js +17 -4
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +5 -0
- package/dist/Editor/common/FontLoader/FontList.js +3 -11
- package/dist/Editor/common/FontLoader/FontLoader.js +33 -7
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +1 -0
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +8 -2
- package/dist/Editor/common/Section/styles.js +15 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
- package/dist/Editor/common/Uploader.js +8 -0
- package/dist/Editor/commonStyle.js +55 -59
- package/dist/Editor/helper/deserialize/index.js +18 -5
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/helper/markdown.js +45 -0
- package/dist/Editor/plugins/withHTML.js +8 -1
- package/dist/Editor/plugins/withLayout.js +1 -1
- package/dist/Editor/utils/SlateUtilityFunctions.js +31 -0
- package/dist/Editor/utils/button.js +4 -4
- package/dist/Editor/utils/draftToSlate.js +3 -2
- package/dist/Editor/utils/helper.js +20 -20
- package/package.json +3 -2
@@ -96,7 +96,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
96
96
|
const editorWrapper = useRef();
|
97
97
|
const mentionsRef = useRef();
|
98
98
|
const convertedContent = draftToSlate({
|
99
|
-
data: content
|
99
|
+
data: content,
|
100
|
+
needLayout: otherProps?.needLayout
|
100
101
|
});
|
101
102
|
const [value, setValue] = useState(convertedContent);
|
102
103
|
const [isInteracted, setIsInteracted] = useState(false);
|
@@ -167,11 +168,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
167
168
|
const debounced = useDebouncedCallback(
|
168
169
|
// function
|
169
170
|
value => {
|
171
|
+
debouncedValue.current = value;
|
170
172
|
const {
|
171
173
|
value: strVal,
|
172
174
|
...restVal
|
173
175
|
} = getOnSaveData(value);
|
174
|
-
debouncedValue.current = value;
|
175
176
|
onSave(strVal, restVal);
|
176
177
|
},
|
177
178
|
// delay in ms
|
@@ -182,7 +183,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
182
183
|
return {
|
183
184
|
value: JSON.stringify(val),
|
184
185
|
text: text,
|
185
|
-
title: serializeToText(title?.children) || "
|
186
|
+
title: serializeToText(title?.children) || ""
|
186
187
|
};
|
187
188
|
};
|
188
189
|
const getPreviewImage = async (needBackground = false, options = {}) => {
|
@@ -596,8 +597,9 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
596
597
|
setIsTextSelected: setIsTextSelected,
|
597
598
|
customProps: customProps,
|
598
599
|
editorWrapper: editorWrapper
|
599
|
-
}) : null, !readOnly
|
600
|
+
}) : null, !readOnly ? /*#__PURE__*/_jsx(SwitchViewport, {
|
600
601
|
breakpoint: breakpoint,
|
602
|
+
show: showViewport,
|
601
603
|
onChange: b => onSwitchBreakpoint(b)
|
602
604
|
}) : null]
|
603
605
|
})
|
package/dist/Editor/Editor.css
CHANGED
@@ -1258,11 +1258,24 @@ blockquote {
|
|
1258
1258
|
}
|
1259
1259
|
|
1260
1260
|
.dividerComponent:hover .divider-settings,
|
1261
|
-
.dividerComponent:hover .
|
1261
|
+
.dividerComponent:hover .sectionIcon button {
|
1262
1262
|
display: block;
|
1263
1263
|
pointer-events: auto;
|
1264
1264
|
}
|
1265
1265
|
|
1266
|
+
@media (max-width: 899px) {
|
1267
|
+
.MuiPopover-root {
|
1268
|
+
z-index: 1302 !important;
|
1269
|
+
}
|
1270
|
+
canvas {
|
1271
|
+
max-width: 100% !important;
|
1272
|
+
}
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
.settingsHeader {
|
1276
|
+
font-size: 14px !important;
|
1277
|
+
font-weight: 500 !important;
|
1278
|
+
}
|
1266
1279
|
.hideScroll {
|
1267
1280
|
overflow-anchor: none;
|
1268
1281
|
}
|
@@ -1278,20 +1291,6 @@ blockquote {
|
|
1278
1291
|
.hideScroll::-webkit-scrollbar-thumb:hover {
|
1279
1292
|
background: none !important;
|
1280
1293
|
}
|
1281
|
-
@media (max-width: 899px) {
|
1282
|
-
.MuiPopover-root {
|
1283
|
-
z-index: 1302 !important;
|
1284
|
-
}
|
1285
|
-
|
1286
|
-
canvas {
|
1287
|
-
max-width: 100% !important;
|
1288
|
-
}
|
1289
|
-
}
|
1290
|
-
|
1291
|
-
.settingsHeader {
|
1292
|
-
font-size: 14px !important;
|
1293
|
-
font-weight: 500 !important;
|
1294
|
-
}
|
1295
1294
|
|
1296
1295
|
.custom-scroll::-webkit-scrollbar {
|
1297
1296
|
height: .6rem;
|
@@ -1330,3 +1329,19 @@ blockquote {
|
|
1330
1329
|
background: linear-gradient(112.61deg, #2C63ED 19.3%, #8360FD 88.14%) !important;
|
1331
1330
|
text-transform: math-auto !important;
|
1332
1331
|
}
|
1332
|
+
|
1333
|
+
code.markcode {
|
1334
|
+
border-radius: 4px;
|
1335
|
+
padding: 6px 8px;
|
1336
|
+
margin: 8px 0px;
|
1337
|
+
display: block;
|
1338
|
+
background-color: #f3f3f3;
|
1339
|
+
font-family: 'Source Code Pro' !important;
|
1340
|
+
}
|
1341
|
+
|
1342
|
+
/* Hide the popper when the reference is hidden */
|
1343
|
+
.hide-popper-on-overlap[data-popper-escaped],
|
1344
|
+
.hide-popper-on-overlap[data-popper-reference-hidden] {
|
1345
|
+
visibility: hidden;
|
1346
|
+
pointer-events: none;
|
1347
|
+
}
|
@@ -162,6 +162,7 @@ const EditorButton = props => {
|
|
162
162
|
display: "inline-flex",
|
163
163
|
color: "rgba(0, 0, 0, 0.54)",
|
164
164
|
marginBottom: "0px !important",
|
165
|
+
...classes.buttonMoreOption,
|
165
166
|
...classes.buttonMoreOption3
|
166
167
|
},
|
167
168
|
...btnProps,
|
@@ -264,7 +265,7 @@ const EditorButton = props => {
|
|
264
265
|
...btnSp,
|
265
266
|
borderStyle: borderStyle || "solid",
|
266
267
|
color: `${textColor || "#FFFFFF"}`,
|
267
|
-
fontSize: textSize || "
|
268
|
+
fontSize: textSize || "12px",
|
268
269
|
fontFamily: fontFamily || "PoppinsRegular",
|
269
270
|
display: "inline-flex",
|
270
271
|
alignItems: "center",
|
@@ -57,9 +57,9 @@ const Divider = props => {
|
|
57
57
|
// : {};
|
58
58
|
return /*#__PURE__*/_jsx("div", {
|
59
59
|
contentEditable: false,
|
60
|
-
className: "
|
60
|
+
className: "element-toolbar dividerIcon",
|
61
61
|
style: {
|
62
|
-
top: "
|
62
|
+
top: "3px",
|
63
63
|
left: 0
|
64
64
|
},
|
65
65
|
children: /*#__PURE__*/_jsx(Tooltip, {
|
@@ -76,7 +76,7 @@ const Divider = props => {
|
|
76
76
|
// theme?.palette?.type === "dark"
|
77
77
|
// ? "1px solid #E4E8EB33"
|
78
78
|
// : "none",
|
79
|
-
boxShadow: "0px 0px 4px 0px #00000040",
|
79
|
+
boxShadow: "0px 0px 4px 0px #00000040 !important",
|
80
80
|
borderRadius: "50%",
|
81
81
|
"& svg": {
|
82
82
|
width: '16px',
|
@@ -50,8 +50,7 @@ const GridItemToolbar = props => {
|
|
50
50
|
open: true,
|
51
51
|
placement: "top-end",
|
52
52
|
sx: classes.popTools,
|
53
|
-
className: "gi-tool-pp",
|
54
|
-
disablePortal: true,
|
53
|
+
className: "gi-tool-pp hide-popper-on-overlap",
|
55
54
|
contentEditable: false,
|
56
55
|
children: /*#__PURE__*/_jsxs(Box, {
|
57
56
|
className: "ico-grp-ss",
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React, { useState } from "react";
|
1
|
+
import React, { useRef, useState } from "react";
|
2
2
|
import { Node, Transforms } from "slate";
|
3
3
|
import { ReactEditor, useFocused, useSelected, useSlateStatic } from "slate-react";
|
4
|
-
import { Box, IconButton, Tooltip } from "@mui/material";
|
4
|
+
import { Box, IconButton, Popper, Tooltip } from "@mui/material";
|
5
5
|
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
|
6
6
|
import EditIcon from "@mui/icons-material/Edit";
|
7
7
|
import LinkOffIcon from "@mui/icons-material/LinkOff";
|
@@ -53,6 +53,7 @@ const Link = props => {
|
|
53
53
|
const showInNewTab = element?.showInNewTab || element?.target;
|
54
54
|
const linkType = element?.linkType;
|
55
55
|
const classes = linkStyles();
|
56
|
+
const linkRef = useRef(null);
|
56
57
|
const updateLink = data => {
|
57
58
|
Transforms.setNodes(editor, data, {
|
58
59
|
at: path
|
@@ -81,43 +82,53 @@ const Link = props => {
|
|
81
82
|
const btnProps = handleLinkType(urlPath, linkType, true, showInNewTab === "_blank");
|
82
83
|
const navType = getLinkType(linkType, urlPath);
|
83
84
|
const hideOpenLink = navType === "page" || !navType;
|
84
|
-
return selected && focused ? /*#__PURE__*/
|
85
|
-
|
85
|
+
return selected && focused ? /*#__PURE__*/_jsx(Popper, {
|
86
|
+
anchorEl: linkRef?.current,
|
87
|
+
open: true,
|
88
|
+
placement: "top-start",
|
89
|
+
className: "hide-popper-on-overlap",
|
86
90
|
contentEditable: false,
|
87
91
|
style: {
|
88
|
-
|
89
|
-
top: "100%",
|
90
|
-
left: "0px",
|
91
|
-
display: "flex"
|
92
|
+
zIndex: 1
|
92
93
|
},
|
93
|
-
children:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
children: /*#__PURE__*/_jsx(
|
114
|
-
|
115
|
-
|
94
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
95
|
+
className: "element-toolbar hr",
|
96
|
+
style: {
|
97
|
+
width: "150px",
|
98
|
+
display: "flex",
|
99
|
+
position: "unset"
|
100
|
+
},
|
101
|
+
component: "div",
|
102
|
+
children: [hideOpenLink ? null : /*#__PURE__*/_jsx(Tooltip, {
|
103
|
+
title: "Open",
|
104
|
+
children: /*#__PURE__*/_jsx(Box, {
|
105
|
+
sx: {
|
106
|
+
display: "inline-flex",
|
107
|
+
color: "rgba(0, 0, 0, 0.54)"
|
108
|
+
},
|
109
|
+
...btnProps,
|
110
|
+
children: /*#__PURE__*/_jsx(OpenInNewIcon, {})
|
111
|
+
})
|
112
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
113
|
+
title: "Edit",
|
114
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
115
|
+
onClick: onEditLink,
|
116
|
+
children: /*#__PURE__*/_jsx(EditIcon, {})
|
117
|
+
})
|
118
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
119
|
+
title: "Remove",
|
120
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
121
|
+
onClick: () => removeLink(editor),
|
122
|
+
children: /*#__PURE__*/_jsx(LinkOffIcon, {})
|
123
|
+
})
|
124
|
+
})]
|
125
|
+
})
|
116
126
|
}) : null;
|
117
127
|
};
|
118
128
|
const buttonProps = handleLinkType(urlPath, linkType, readOnly, showInNewTab === "_blank");
|
119
129
|
return /*#__PURE__*/_jsxs("div", {
|
120
130
|
className: "link",
|
131
|
+
ref: linkRef,
|
121
132
|
children: [/*#__PURE__*/_jsx(Box, {
|
122
133
|
...attributes,
|
123
134
|
...element.attr,
|
@@ -35,8 +35,8 @@ const SimpleTextStyle = ({
|
|
35
35
|
height: "24px",
|
36
36
|
overflow: "hidden",
|
37
37
|
fontSize: "14px",
|
38
|
-
display:
|
39
|
-
alignItems:
|
38
|
+
display: "inline-flex",
|
39
|
+
alignItems: "center",
|
40
40
|
"& .bg-pad-sl": {
|
41
41
|
padding: "2px 4px 2px 4px",
|
42
42
|
background: "transparent",
|
@@ -1,12 +1,24 @@
|
|
1
1
|
import React from "react";
|
2
|
+
import { Text } from "slate";
|
2
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
const isEmptyTextNode = node => {
|
5
|
+
if (Text.isText(node)) {
|
6
|
+
return !node.text.trim();
|
7
|
+
}
|
8
|
+
return false;
|
9
|
+
};
|
3
10
|
const Title = props => {
|
4
11
|
const {
|
12
|
+
element,
|
5
13
|
attributes,
|
6
|
-
children
|
14
|
+
children,
|
15
|
+
customProps
|
7
16
|
} = props;
|
17
|
+
const isEmpty = !customProps?.readOnly && isEmptyTextNode(element?.children[0]) ? "empty" : "";
|
8
18
|
return /*#__PURE__*/_jsx("div", {
|
9
19
|
...attributes,
|
20
|
+
placeholder: "Title",
|
21
|
+
className: `content-editable ${isEmpty}`,
|
10
22
|
style: {
|
11
23
|
fontWeight: "bold",
|
12
24
|
fontSize: "20px"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
const VariableStyles =
|
1
|
+
const VariableStyles = theme => ({
|
2
2
|
variablesItem: {
|
3
3
|
color: "#2563EB",
|
4
4
|
background: "#EEEEEE"
|
@@ -37,8 +37,34 @@ const VariableStyles = () => ({
|
|
37
37
|
"& .MuiMenuItem-root": {
|
38
38
|
color: "#64748B"
|
39
39
|
},
|
40
|
+
"& .MuiPaper-root": {
|
41
|
+
borderRadius: '8px',
|
42
|
+
backgroundColor: `${theme?.palette?.editor?.miniToolBarBackground} !important`,
|
43
|
+
marginTop: '5px',
|
44
|
+
"@media only screen and (max-width: 599px)": {
|
45
|
+
padding: '10px 0px'
|
46
|
+
}
|
47
|
+
},
|
48
|
+
"& .MuiList-root": {
|
49
|
+
padding: '0px'
|
50
|
+
},
|
51
|
+
"& .MuiButtonBase-root": {
|
52
|
+
margin: '6px',
|
53
|
+
borderRadius: '8px',
|
54
|
+
padding: '6px 14px',
|
55
|
+
fontSize: '14px',
|
56
|
+
fontWeight: '400',
|
57
|
+
color: theme?.palette?.editor?.deletePopUpButtonTextColor,
|
58
|
+
"&:hover": {
|
59
|
+
background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
|
60
|
+
},
|
61
|
+
"@media only screen and (max-width: 599px)": {
|
62
|
+
minHeight: '30px',
|
63
|
+
margin: '0px 6px'
|
64
|
+
}
|
65
|
+
},
|
40
66
|
"& .Mui-selected": {
|
41
|
-
backgroundColor:
|
67
|
+
backgroundColor: 'unset !important'
|
42
68
|
}
|
43
69
|
}
|
44
70
|
});
|
@@ -3,11 +3,15 @@ import { useSlateStatic } from "slate-react";
|
|
3
3
|
import { MenuItem, Select } from "@mui/material";
|
4
4
|
import { insertVariables } from "../../utils/variables";
|
5
5
|
import VariableStyles from "./Style";
|
6
|
-
import
|
6
|
+
import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded';
|
7
|
+
import { useEditorContext } from "../../hooks/useMouseMove";
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
10
|
const VariableButton = props => {
|
10
|
-
const
|
11
|
+
const {
|
12
|
+
theme
|
13
|
+
} = useEditorContext();
|
14
|
+
const classes = VariableStyles(theme);
|
11
15
|
const editor = useSlateStatic();
|
12
16
|
const {
|
13
17
|
options
|
@@ -24,13 +28,14 @@ const VariableButton = props => {
|
|
24
28
|
value: "",
|
25
29
|
sx: classes.variableBtn,
|
26
30
|
onChange: updateVariable,
|
27
|
-
IconComponent: () => /*#__PURE__*/_jsx(
|
31
|
+
IconComponent: () => /*#__PURE__*/_jsx(KeyboardArrowDownRoundedIcon, {}),
|
28
32
|
MenuProps: {
|
29
33
|
sx: classes.variableMenuItem,
|
30
34
|
PaperProps: {
|
31
35
|
style: {
|
32
36
|
maxHeight: 300,
|
33
|
-
overflowY: "auto"
|
37
|
+
overflowY: "auto",
|
38
|
+
transformOrigin: 'top left'
|
34
39
|
},
|
35
40
|
sx: {
|
36
41
|
"&::-webkit-scrollbar-track": {
|
@@ -40,6 +45,14 @@ const VariableButton = props => {
|
|
40
45
|
borderRadius: "16px"
|
41
46
|
}
|
42
47
|
}
|
48
|
+
},
|
49
|
+
anchorOrigin: {
|
50
|
+
vertical: 'bottom',
|
51
|
+
horizontal: 'right'
|
52
|
+
},
|
53
|
+
transformOrigin: {
|
54
|
+
vertical: 'top',
|
55
|
+
horizontal: 'right'
|
43
56
|
}
|
44
57
|
},
|
45
58
|
children: [/*#__PURE__*/_jsx(MenuItem, {
|
@@ -416,6 +416,11 @@ const usePopupStyle = theme => ({
|
|
416
416
|
"& .MuiOutlinedInput-notchedOutline": {
|
417
417
|
border: `1px solid ${theme?.palette?.editor?.inputFieldBorder} !important`
|
418
418
|
},
|
419
|
+
'& .MuiInputBase-root': {
|
420
|
+
'& input': {
|
421
|
+
border: "none !important"
|
422
|
+
}
|
423
|
+
},
|
419
424
|
"& svg": {
|
420
425
|
width: "20px",
|
421
426
|
height: "24px"
|
@@ -1,11 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
export const otherFonts = ["PoppinsRegular", "PoppinsBold", "Monaco", "Qwitcher Grypen", "Bulgarian Garamond", "Redacted Script", "Herr Von Muellerhoff", "Dawning of a New Day", "Coming Soon", "Engagement", "Ingrid Darling", "La Belle Aurore", "Mea Culpa", "The Girl Next Door", "Helvetica", "Georgia", "Times New Roman", "Courier New", "Impact"];
|
5
|
-
export const googleFontList = ["Roboto", "Noto Sans JP", "Poppins", "Lato", "Inter", "Roboto Condensed", "Roboto Mono", "Oswald", "Noto Sans", "Nunito", "Nunito Sans", "Ubuntu", "Rubik", "Playfair Display", "Noto Sans KR", "Roboto Slab", "PT Sans", "Kanit", "Work Sans", "Lora", "DM Sans", "Mulish", "Quicksand", "Fira Sans", "Noto Sans TC", "Inconsolata", "Barlow", "Manrope", "IBM Plex Sans", "PT Serif", "Karla", "Titillium Web", "Heebo", "Noto Serif", "Nanum Gothic", "Noto Color Emoji", "Agdasima", "Bebas Neue", "Libre Franklin", "Mukta", "Outfit", "Josefin Sans", "Source Code Pro", "Jost", "Space Grotesk", "Hind Siliguri", "Arimo", "Cabin", "Barlow Condensed", "Dosis", "Fira Sans Condensed", "Bitter", "Archivo", "Figtree", "Noto Serif JP", "PT Sans Narrow", "Abel", "Noto Sans SC",
|
6
|
-
// "Source Sans 3",
|
7
|
-
"Hind",
|
8
|
-
// "Exo 2",
|
9
|
-
"Teko", "Oxygen", "Cairo", "Crimson Text", "Plus Jakarta Sans", "Overpass", "Pacifico", "Prompt", "Red Hat Display", "Varela Round", "Cormorant Garamond", "Assistant", "Comfortaa", "Lexend", "Signika Negative",
|
10
|
-
// "M PLUS Rounded 1c",
|
11
|
-
"Fjalla One", "Caveat", "IBM Plex Mono", "Arvo", "Lobster", "Schibsted Grotesk", "Chakra Petch", "Maven Pro", "Sora", "Kalam", "Onest", "Space Grotesk", "Outfit", 'Titillium Web', ...defaultFonts];
|
1
|
+
const otherFonts = ["PoppinsRegular", "PoppinsBold", "Qwitcher Grypen", "Bulgarian Garamond", "Redacted Script", "Herr Von Muellerhoff", "Dawning of a New Day", "Coming Soon", "Engagement", "Ingrid Darling", "La Belle Aurore", "Mea Culpa", "The Girl Next Door"];
|
2
|
+
const mostUsedGoogleFonts = ["Roboto", "Poppins", "Lato", "Inter", "Nunito", "Ubuntu", "Oswald", "Rubik", "Roboto Slab", "PT Sans", "Work Sans", "Lora", "Mulish", "DM Sans", "Fira Sans", "Quicksand", "Barlow", "Manrope", "IBM Plex Sans", "PT Serif", "Libre Franklin", "Bebas Neue", "Cabin", "Titillium Web", "Heebo", "Noto Serif", "Jost", "Source Code Pro", "Josefin Sans", "Dosis", "Fira Sans Condensed", "Archivo", "Noto Serif JP", "Crimson Text", "Cairo", "Pacifico", "Red Hat Display", "Assistant", "Comfortaa", "Lexend", "Fjalla One", "Caveat", "Arvo", "Lobster", "Schibsted Grotesk", "EB Garamond", "Sora", "Kalam", "Onest", "Space Grotesk", "Outfit", "Plus Jakarta Sans"];
|
3
|
+
export const googleFontList = [...mostUsedGoogleFonts, ...otherFonts];
|
@@ -1,7 +1,11 @@
|
|
1
|
-
import { useEffect } from "react";
|
1
|
+
import { useEffect, useState } from "react";
|
2
2
|
import WebFont from "webfontloader";
|
3
3
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
4
|
-
import {
|
4
|
+
import { googleFontList } from "./FontList";
|
5
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
6
|
+
import Box from "@mui/material/Box";
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
5
9
|
const FontLoader = props => {
|
6
10
|
const {
|
7
11
|
otherProps,
|
@@ -10,14 +14,20 @@ const FontLoader = props => {
|
|
10
14
|
const {
|
11
15
|
setFontFamilies
|
12
16
|
} = useEditorContext();
|
17
|
+
const [loading, setLoading] = useState(false);
|
13
18
|
const loadFontsInBatches = (families, batchSize = 5, maxRetries = 3) => {
|
14
19
|
let currentIndex = 0;
|
15
20
|
let retryCount = 0;
|
21
|
+
let hideLoaderOn = 30;
|
16
22
|
function loadNextBatch() {
|
17
23
|
if (currentIndex >= families?.length) {
|
18
24
|
// console.log("All fonts have been loaded");
|
25
|
+
setLoading(false);
|
19
26
|
return;
|
20
27
|
}
|
28
|
+
if (currentIndex >= hideLoaderOn) {
|
29
|
+
setLoading(false);
|
30
|
+
}
|
21
31
|
const batch = families?.slice(currentIndex, currentIndex + batchSize);
|
22
32
|
const batchWithWeights = batch.map(font => `${font}:300,400,600,700`);
|
23
33
|
WebFont.load({
|
@@ -54,21 +64,21 @@ const FontLoader = props => {
|
|
54
64
|
loadNextBatch();
|
55
65
|
};
|
56
66
|
useEffect(() => {
|
57
|
-
let families = [...
|
67
|
+
let families = [...googleFontList];
|
58
68
|
if (!readOnly) {
|
59
69
|
otherProps?.services("listGoogleFont", []).then(data => {
|
60
|
-
families = [...
|
61
|
-
const filteredfamilies = families?.filter(font => !font?.includes("Material"));
|
70
|
+
families = [...(data?.data || [])];
|
62
71
|
setFontFamilies({
|
63
72
|
id: 1,
|
64
73
|
format: "fontFamily",
|
65
74
|
type: "fontfamilydropdown",
|
66
|
-
options:
|
75
|
+
options: families || []
|
67
76
|
});
|
68
77
|
loadFontsInBatches(families);
|
69
78
|
}).catch(err => {
|
70
79
|
// console.log(err);
|
71
80
|
});
|
81
|
+
// setLoading(true);
|
72
82
|
} else {
|
73
83
|
function correctFontArray(fontString) {
|
74
84
|
let fontsArray = fontString.split(",");
|
@@ -90,9 +100,25 @@ const FontLoader = props => {
|
|
90
100
|
families = families?.map(font => font?.replace(/\"/g, ""));
|
91
101
|
families = families?.map(font => font?.replace(", sans-serif", "")); //This is temporary fix for patch
|
92
102
|
families = families.filter(font => googleFontList.includes(font));
|
103
|
+
// setLoading(true);
|
93
104
|
loadFontsInBatches(families);
|
94
105
|
}
|
95
106
|
}, []);
|
96
|
-
return
|
107
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
108
|
+
children: loading ? /*#__PURE__*/_jsx(Box, {
|
109
|
+
sx: {
|
110
|
+
position: 'absolute',
|
111
|
+
top: 0,
|
112
|
+
left: 0,
|
113
|
+
right: 0,
|
114
|
+
bottom: 0,
|
115
|
+
zIndex: 99999,
|
116
|
+
display: 'flex',
|
117
|
+
justifyContent: 'center',
|
118
|
+
alignItems: 'center'
|
119
|
+
},
|
120
|
+
children: /*#__PURE__*/_jsx(CircularProgress, {})
|
121
|
+
}) : null
|
122
|
+
});
|
97
123
|
};
|
98
124
|
export default FontLoader;
|
@@ -9,17 +9,23 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
const SwitchViewport = props => {
|
10
10
|
const {
|
11
11
|
breakpoint,
|
12
|
-
onChange
|
12
|
+
onChange,
|
13
|
+
show
|
13
14
|
} = props;
|
14
15
|
const classes = useSwitchViewport();
|
15
16
|
const {
|
17
|
+
setSelectedElement,
|
16
18
|
setActiveBreakPoint
|
17
19
|
} = useEditorContext();
|
18
20
|
useEffect(() => {
|
19
|
-
|
21
|
+
// to reset selection on viewport changes - FS-6589
|
22
|
+
setSelectedElement({});
|
20
23
|
}, [breakpoint]);
|
21
24
|
return /*#__PURE__*/_jsxs(Box, {
|
22
25
|
sx: classes.root,
|
26
|
+
style: {
|
27
|
+
display: show ? "block" : "none"
|
28
|
+
},
|
23
29
|
children: [/*#__PURE__*/_jsx(Tooltip, {
|
24
30
|
title: "Desktop View",
|
25
31
|
children: /*#__PURE__*/_jsx(IconButton, {
|
@@ -11,6 +11,9 @@ const SectionStyle = (themeReact, theme) => ({
|
|
11
11
|
"& .sectionIcon": {
|
12
12
|
opacity: 1
|
13
13
|
},
|
14
|
+
'& .dividerIcon': {
|
15
|
+
opacity: 1
|
16
|
+
},
|
14
17
|
"& .sectionPopper": {
|
15
18
|
opacity: 1
|
16
19
|
}
|
@@ -52,6 +55,18 @@ const SectionStyle = (themeReact, theme) => ({
|
|
52
55
|
opacity: 1
|
53
56
|
}
|
54
57
|
},
|
58
|
+
"& .dividerIcon": {
|
59
|
+
opacity: 0,
|
60
|
+
padding: "0px",
|
61
|
+
background: "transparent",
|
62
|
+
border: "none",
|
63
|
+
width: "20px",
|
64
|
+
height: "20px",
|
65
|
+
"& button": {
|
66
|
+
boxShadow: "none",
|
67
|
+
background: "transparent"
|
68
|
+
}
|
69
|
+
},
|
55
70
|
"& .ed-section-inner": {
|
56
71
|
[themeReact.breakpoints.between("xs", "md")]: {
|
57
72
|
maxWidth: `320px !important`,
|
@@ -73,6 +73,11 @@ const BackgroundImage = props => {
|
|
73
73
|
children: "REMOVE"
|
74
74
|
}) : /*#__PURE__*/_jsx(Grid, {
|
75
75
|
className: "uploadImageText",
|
76
|
+
sx: {
|
77
|
+
padding: 0,
|
78
|
+
background: `${theme?.palette?.editor?.inputFieldBgColor}`,
|
79
|
+
border: `1px solid ${theme?.palette?.editor?.inputFieldBorder}`
|
80
|
+
},
|
76
81
|
children: /*#__PURE__*/_jsxs(Button, {
|
77
82
|
component: "label",
|
78
83
|
variant: "text",
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Box, Card, Checkbox, FormControlLabel, Grid, Tooltip, Typography } from "@mui/material";
|
2
2
|
import React from "react";
|
3
3
|
import Icon from "../../Icon";
|
4
|
+
import { useEditorContext } from "../../../hooks/useMouseMove";
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
6
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
6
7
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
@@ -15,7 +16,10 @@ const RenderCard = ({
|
|
15
16
|
return /*#__PURE__*/_jsx(Card, {
|
16
17
|
sx: {
|
17
18
|
position: 'relative',
|
18
|
-
padding: "10px"
|
19
|
+
padding: "10px",
|
20
|
+
'& .MuiCheckbox-root svg': {
|
21
|
+
fill: 'unset !important'
|
22
|
+
}
|
19
23
|
},
|
20
24
|
children: /*#__PURE__*/_jsx(FormControlLabel, {
|
21
25
|
control: /*#__PURE__*/_jsx(Checkbox, {
|
@@ -81,6 +85,9 @@ const CardsMapping = props => {
|
|
81
85
|
selectedCard,
|
82
86
|
infoIcon
|
83
87
|
} = data;
|
88
|
+
const {
|
89
|
+
theme
|
90
|
+
} = useEditorContext();
|
84
91
|
const activeCard = value === selectedCard;
|
85
92
|
const handleChange = e => {
|
86
93
|
if (selectedCard === data?.value) {
|
@@ -99,7 +106,8 @@ const CardsMapping = props => {
|
|
99
106
|
sx: {
|
100
107
|
marginBottom: "12px",
|
101
108
|
"& .MuiPaper-root": {
|
102
|
-
|
109
|
+
background: theme?.palette?.editor?.miniToolBarBackground,
|
110
|
+
border: activeCard ? "1px solid #2563EB" : `1px solid ${theme?.palette?.editor?.inputFieldBorder}`,
|
103
111
|
borderRadius: "8px",
|
104
112
|
boxShadow: activeCard ? "0px 4px 16px 0px #2563EB40" : "unset"
|
105
113
|
}
|
@@ -4,6 +4,7 @@ import { convertBase64 } from "../utils/helper";
|
|
4
4
|
import { uploadFile } from "../service/fileupload";
|
5
5
|
import Icon from "./Icon";
|
6
6
|
import UploadStyles from "../common/ImageSelector/UploadStyles";
|
7
|
+
import { useEditorContext } from "../hooks/useMouseMove";
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
9
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
9
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
@@ -18,6 +19,9 @@ const Uploader = props => {
|
|
18
19
|
const [base64, setBase64] = useState(value?.url);
|
19
20
|
const [fileName, setFileName] = useState("");
|
20
21
|
const [uploading, setUploading] = useState(false);
|
22
|
+
const {
|
23
|
+
theme
|
24
|
+
} = useEditorContext();
|
21
25
|
const handleChange = async e => {
|
22
26
|
const uFile = e.target.files[0];
|
23
27
|
const strImage = await convertBase64(uFile);
|
@@ -99,6 +103,10 @@ const Uploader = props => {
|
|
99
103
|
className: "uploadImageSection",
|
100
104
|
children: base64 ? renderThumb() : /*#__PURE__*/_jsx(Grid, {
|
101
105
|
className: "uploadImageText",
|
106
|
+
sx: {
|
107
|
+
background: `${theme?.palette?.editor?.inputFieldBgColor}`,
|
108
|
+
border: `1px solid ${theme?.palette?.editor?.inputFieldBorder}`
|
109
|
+
},
|
102
110
|
children: /*#__PURE__*/_jsxs(Button, {
|
103
111
|
component: "label",
|
104
112
|
variant: "text",
|
@@ -51,18 +51,17 @@ const useCommonStyle = theme => ({
|
|
51
51
|
},
|
52
52
|
"& .MuiPaper-root": {
|
53
53
|
border: `unset !important`,
|
54
|
-
borderRadius:
|
55
|
-
height:
|
54
|
+
borderRadius: "0px",
|
55
|
+
height: "fit-content",
|
56
|
+
padding: "2px"
|
56
57
|
},
|
57
58
|
"& p": {
|
58
59
|
marginBottom: "7px",
|
59
60
|
marginTop: "4px"
|
60
61
|
},
|
61
|
-
"&
|
62
|
-
|
63
|
-
|
64
|
-
height: 'fit-content',
|
65
|
-
padding: '2px'
|
62
|
+
"& p": {
|
63
|
+
marginBottom: "7px",
|
64
|
+
marginTop: "4px"
|
66
65
|
},
|
67
66
|
"& .muiIconsListParent": {
|
68
67
|
"& svg": {
|
@@ -76,15 +75,12 @@ const useCommonStyle = theme => ({
|
|
76
75
|
},
|
77
76
|
"&::-webkit-scrollbar-thumb": {
|
78
77
|
background: `${theme?.palette?.editor?.brainPopupScroll} !important`
|
79
|
-
},
|
80
|
-
"&::-webkit-scrollbar-track": {
|
81
|
-
visibility: "hidden"
|
82
78
|
}
|
83
79
|
},
|
84
80
|
"& .MuiGrid-root>.MuiGrid-item": {
|
85
81
|
paddingRight: "0px !important",
|
86
82
|
fontFamily: "Inter, sans-serif",
|
87
|
-
height:
|
83
|
+
height: "fit-content"
|
88
84
|
},
|
89
85
|
"& .MuiInputBase-root": {
|
90
86
|
borderRadius: "10px",
|
@@ -145,11 +141,11 @@ const useCommonStyle = theme => ({
|
|
145
141
|
borderRadius: "10px",
|
146
142
|
width: "46px !important",
|
147
143
|
marginLeft: "10px",
|
148
|
-
height:
|
144
|
+
height: "36px !important"
|
149
145
|
}
|
150
146
|
},
|
151
|
-
|
152
|
-
margin:
|
147
|
+
"& .MuiFormHelperText-root": {
|
148
|
+
margin: "4px 0px 0px 0px",
|
153
149
|
color: theme?.palette?.editor?.closeButtonSvgStroke,
|
154
150
|
fontFamily: "Inter, sans-serif"
|
155
151
|
}
|
@@ -405,14 +401,14 @@ const useCommonStyle = theme => ({
|
|
405
401
|
padding: "8px 12px",
|
406
402
|
fontSize: "12px",
|
407
403
|
color: theme?.palette?.editor?.menuOptionTextColor,
|
408
|
-
fontWeight:
|
404
|
+
fontWeight: "500",
|
409
405
|
fontFamily: "Inter, sans-serif",
|
410
|
-
minHeight:
|
406
|
+
minHeight: "36px",
|
411
407
|
"&:hover": {
|
412
408
|
backgroundColor: theme?.palette?.editor?.menuOptionHoverBackground
|
413
409
|
}
|
414
410
|
},
|
415
|
-
|
411
|
+
"& .Mui-selected": {
|
416
412
|
background: `${theme?.palette?.editor?.menuOptionSelectedOption} !important`
|
417
413
|
},
|
418
414
|
"& .MuiListSubheader-root": {
|
@@ -421,16 +417,16 @@ const useCommonStyle = theme => ({
|
|
421
417
|
fontSize: "12px"
|
422
418
|
},
|
423
419
|
"& .MuiPaper-root": {
|
424
|
-
borderRadius:
|
425
|
-
padding:
|
420
|
+
borderRadius: "8px",
|
421
|
+
padding: "0px",
|
426
422
|
background: `${theme?.palette?.editor?.textWeightPopUpBackground} !important`
|
427
423
|
},
|
428
|
-
|
429
|
-
margin:
|
430
|
-
borderRadius:
|
424
|
+
"& .MuiButtonBase-root": {
|
425
|
+
margin: "4px",
|
426
|
+
borderRadius: "6px"
|
431
427
|
},
|
432
|
-
|
433
|
-
padding:
|
428
|
+
"& .MuiList-root": {
|
429
|
+
padding: "0px"
|
434
430
|
}
|
435
431
|
},
|
436
432
|
datePicker: {
|
@@ -475,27 +471,27 @@ const useCommonStyle = theme => ({
|
|
475
471
|
}
|
476
472
|
}
|
477
473
|
},
|
478
|
-
pageSettingPopUpRoot: {
|
479
|
-
padding: "16px 8px 16px 10px!important",
|
480
|
-
height: "100%"
|
481
|
-
},
|
482
474
|
buttonMoreOption: {
|
483
475
|
background: `${theme?.palette?.editor?.aiInputBackground} !important`,
|
484
476
|
border: `1px solid ${theme?.palette?.editor?.buttonBorder1} !important`,
|
485
|
-
padding:
|
486
|
-
|
487
|
-
width:
|
488
|
-
height:
|
489
|
-
|
477
|
+
padding: "4px !important",
|
478
|
+
"& svg": {
|
479
|
+
width: "18px !important",
|
480
|
+
height: "18px !important",
|
481
|
+
"& path": {
|
490
482
|
stroke: `${theme?.palette?.editor?.closeButtonSvgStroke} !important`
|
491
483
|
}
|
492
484
|
}
|
493
485
|
},
|
486
|
+
pageSettingPopUpRoot: {
|
487
|
+
padding: "16px 8px 16px 10px!important",
|
488
|
+
height: "100%"
|
489
|
+
},
|
494
490
|
buttonMoreOption2: {
|
495
491
|
background: `${theme?.palette?.editor?.aiInputBackground} !important`,
|
496
492
|
border: `1px solid ${theme?.palette?.editor?.buttonBorder1} !important`,
|
497
|
-
|
498
|
-
|
493
|
+
"& svg": {
|
494
|
+
"& path": {
|
499
495
|
fill: `${theme?.palette?.editor?.closeButtonSvgStroke} !important`
|
500
496
|
}
|
501
497
|
}
|
@@ -503,11 +499,11 @@ const useCommonStyle = theme => ({
|
|
503
499
|
buttonMoreOption3: {
|
504
500
|
background: `${theme?.palette?.editor?.aiInputBackground} !important`,
|
505
501
|
border: `1px solid ${theme?.palette?.editor?.buttonBorder1} !important`,
|
506
|
-
padding:
|
507
|
-
|
508
|
-
width:
|
509
|
-
height:
|
510
|
-
|
502
|
+
padding: "5px !important",
|
503
|
+
"& svg": {
|
504
|
+
width: "16px !important",
|
505
|
+
height: "16px !important",
|
506
|
+
"& path": {
|
511
507
|
stroke: `${theme?.palette?.editor?.closeButtonSvgStroke} !important`
|
512
508
|
}
|
513
509
|
}
|
@@ -515,37 +511,37 @@ const useCommonStyle = theme => ({
|
|
515
511
|
resizeButton: {
|
516
512
|
background: theme?.palette?.editor?.aiInputBackground,
|
517
513
|
border: `1px solid ${theme?.palette?.editor?.buttonBorder1}`,
|
518
|
-
padding:
|
519
|
-
borderRadius:
|
520
|
-
|
521
|
-
width:
|
522
|
-
height:
|
523
|
-
|
514
|
+
padding: "5px !important",
|
515
|
+
borderRadius: "50% !important",
|
516
|
+
"& svg": {
|
517
|
+
width: "18px",
|
518
|
+
height: "18px",
|
519
|
+
"& path": {
|
524
520
|
fill: `${theme?.palette?.editor?.closeButtonSvgStroke}`
|
525
521
|
}
|
526
522
|
},
|
527
|
-
|
523
|
+
"&:hover": {
|
528
524
|
background: theme?.palette?.editor?.aiInputBackground
|
529
525
|
}
|
530
526
|
},
|
531
527
|
gradientFillBtn: {
|
532
528
|
background: `linear-gradient(112.61deg, #2C63ED 19.3%, #8360FD 88.14%) !important`,
|
533
|
-
textTransform:
|
534
|
-
color:
|
535
|
-
padding:
|
536
|
-
height:
|
537
|
-
borderRadius:
|
538
|
-
fontWeight:
|
539
|
-
fontSize:
|
529
|
+
textTransform: "math-auto !important",
|
530
|
+
color: "#FFFFFF !important",
|
531
|
+
padding: "0px 12px !important",
|
532
|
+
height: "32px",
|
533
|
+
borderRadius: "8px",
|
534
|
+
fontWeight: "500",
|
535
|
+
fontSize: "14px"
|
540
536
|
},
|
541
537
|
emptyThumbBtn: {
|
542
538
|
background: `${theme?.palette?.editor?.sectionSettingIconHover} !important`,
|
543
539
|
color: `${theme?.palette?.editor?.textColor} !important`,
|
544
|
-
fontSize:
|
545
|
-
|
546
|
-
width:
|
547
|
-
height:
|
548
|
-
|
540
|
+
fontSize: "14px !important",
|
541
|
+
"& svg": {
|
542
|
+
width: "20px !important",
|
543
|
+
height: "20px !important",
|
544
|
+
"& path": {
|
549
545
|
stroke: `${theme?.palette?.editor?.closeButtonSvgStroke} !important`
|
550
546
|
}
|
551
547
|
}
|
@@ -90,9 +90,18 @@ const ELEMENT_TAGS = {
|
|
90
90
|
type: "image",
|
91
91
|
url: el.getAttribute("src")
|
92
92
|
}),
|
93
|
-
LI:
|
94
|
-
|
95
|
-
|
93
|
+
LI: el => {
|
94
|
+
const checkListItem = el.querySelector(".check-list-item");
|
95
|
+
if (checkListItem) {
|
96
|
+
return {
|
97
|
+
type: "check-list-item",
|
98
|
+
checked: checkListItem?.dataset?.checked === "true"
|
99
|
+
};
|
100
|
+
}
|
101
|
+
return {
|
102
|
+
type: "list-item"
|
103
|
+
};
|
104
|
+
},
|
96
105
|
UL: () => ({
|
97
106
|
type: "unorderedList"
|
98
107
|
}),
|
@@ -109,7 +118,7 @@ const ELEMENT_TAGS = {
|
|
109
118
|
"GOOGLE-SHEETS-HTML-ORIGIN": paragraphType,
|
110
119
|
TABLE: (el, children = []) => {
|
111
120
|
try {
|
112
|
-
const bodyChild = children || [];
|
121
|
+
const bodyChild = (children || [])?.filter(f => f !== null);
|
113
122
|
const firstRowChildren = bodyChild[0]?.children || [];
|
114
123
|
return {
|
115
124
|
type: "table",
|
@@ -129,7 +138,11 @@ const ELEMENT_TAGS = {
|
|
129
138
|
}),
|
130
139
|
TD: handleTableCell,
|
131
140
|
COLGROUP: paragraphType,
|
132
|
-
COL: paragraphType
|
141
|
+
COL: paragraphType,
|
142
|
+
HR: () => ({
|
143
|
+
type: "divider",
|
144
|
+
borderColor: "#CCC"
|
145
|
+
})
|
133
146
|
};
|
134
147
|
|
135
148
|
// COMPAT: `B` is omitted here because Google Docs uses `<b>` in weird ways.
|
@@ -337,14 +337,14 @@ export const isCarouselSelected = editor => {
|
|
337
337
|
return false;
|
338
338
|
}
|
339
339
|
const [nodeEntry] = Editor.nodes(editor, {
|
340
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type ===
|
340
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "carousel"
|
341
341
|
});
|
342
342
|
if (!nodeEntry) {
|
343
343
|
return false;
|
344
344
|
}
|
345
345
|
const [node] = nodeEntry;
|
346
346
|
const carouselDom = ReactEditor.toDOMNode(editor, node);
|
347
|
-
const isEdit = carouselDom.classList.contains(
|
347
|
+
const isEdit = carouselDom.classList.contains("carousel_slider_edit");
|
348
348
|
return !isEdit;
|
349
349
|
} catch (err) {
|
350
350
|
console.log(err);
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import MarkdownIt from "markdown-it";
|
2
|
+
const md = new MarkdownIt();
|
3
|
+
function markdownItCheckbox(md) {
|
4
|
+
md.core.ruler.push("checkbox_lists", function (state) {
|
5
|
+
const tokens = state.tokens;
|
6
|
+
for (let i = 0; i < tokens.length; i++) {
|
7
|
+
const token = tokens[i];
|
8
|
+
if (token.type === "inline" && token.content) {
|
9
|
+
const taskListRegex = /^\s*(-\s*)?\[\s*([xX\s]?)\s*\]\s+(.*)/;
|
10
|
+
const match = taskListRegex.exec(token.content);
|
11
|
+
if (match) {
|
12
|
+
token.attrJoin("class", "check-list-item");
|
13
|
+
const isChecked = match[2].toLowerCase() === "x"; // Check if checked
|
14
|
+
const content = match[3].trim(); // Extract text after checkbox
|
15
|
+
|
16
|
+
// Create new tokens for the task list item
|
17
|
+
const listItemOpenToken = new state.Token("html_inline", "", 0);
|
18
|
+
listItemOpenToken.content = `<li class="check-list-item" data-checked="${isChecked}">`;
|
19
|
+
const checkboxToken = new state.Token("html_inline", "", 0);
|
20
|
+
checkboxToken.content = `<span class='check-list-item' data-checked="${isChecked}" />`;
|
21
|
+
const textToken = new state.Token("text", "", 0);
|
22
|
+
textToken.content = content;
|
23
|
+
const listItemCloseToken = new state.Token("html_inline", "", 0);
|
24
|
+
listItemCloseToken.content = `</li>`;
|
25
|
+
|
26
|
+
// Replace the original token with the new tokens
|
27
|
+
tokens.splice(i, 1, checkboxToken, textToken);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
// init plugin
|
35
|
+
md.use(markdownItCheckbox);
|
36
|
+
function convertMDToHTML(data) {
|
37
|
+
try {
|
38
|
+
const html = md.render(data);
|
39
|
+
return html;
|
40
|
+
} catch (err) {
|
41
|
+
console.log(err);
|
42
|
+
return data;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
export default convertMDToHTML;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Transforms, Editor, Element, Node, Path } from "slate";
|
2
2
|
import deserialize from "../helper/deserialize";
|
3
3
|
import { decodeAndParseBase64 } from "../utils/helper";
|
4
|
+
import convertMDToHTML from "../helper/markdown";
|
4
5
|
const avoidDefaultInsert = ["table", "grid"];
|
5
6
|
const NON_TEXT_TAGS = ["ol", "ul", "img", "table", "video", "a", "button", "GOOGLE-SHEETS-HTML-ORIGIN"];
|
6
7
|
const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree"];
|
@@ -274,9 +275,15 @@ const withHtml = editor => {
|
|
274
275
|
Transforms.insertFragment(editor, formattedFragment);
|
275
276
|
return;
|
276
277
|
} else {
|
277
|
-
|
278
|
+
const html = convertMDToHTML(data.getData("text/plain"));
|
279
|
+
let parsed = new DOMParser().parseFromString(html, "text/html");
|
280
|
+
parsed = parseCopiedHTML(html);
|
281
|
+
const fragment = deserialize(parsed.body);
|
282
|
+
Transforms.insertFragment(editor, fragment);
|
283
|
+
// insertData(data);
|
278
284
|
}
|
279
285
|
};
|
286
|
+
|
280
287
|
return editor;
|
281
288
|
};
|
282
289
|
export default withHtml;
|
@@ -301,6 +301,30 @@ export const getBlock = props => {
|
|
301
301
|
placeholder: "Heading 3",
|
302
302
|
children: children
|
303
303
|
});
|
304
|
+
case "headingFour":
|
305
|
+
return /*#__PURE__*/_jsx("h4", {
|
306
|
+
...attributes,
|
307
|
+
...element.attr,
|
308
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
309
|
+
placeholder: "Heading 4",
|
310
|
+
children: children
|
311
|
+
});
|
312
|
+
case "headingFive":
|
313
|
+
return /*#__PURE__*/_jsx("h5", {
|
314
|
+
...attributes,
|
315
|
+
...element.attr,
|
316
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
317
|
+
placeholder: "Heading 5",
|
318
|
+
children: children
|
319
|
+
});
|
320
|
+
case "headingSix":
|
321
|
+
return /*#__PURE__*/_jsx("h6", {
|
322
|
+
...attributes,
|
323
|
+
...element.attr,
|
324
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
325
|
+
placeholder: "Heading 6",
|
326
|
+
children: children
|
327
|
+
});
|
304
328
|
case "blockquote":
|
305
329
|
return /*#__PURE__*/_jsx("blockquote", {
|
306
330
|
...attributes,
|
@@ -588,6 +612,13 @@ export const getBlock = props => {
|
|
588
612
|
return /*#__PURE__*/_jsx(ColumnView, {
|
589
613
|
...props
|
590
614
|
});
|
615
|
+
case "code":
|
616
|
+
return /*#__PURE__*/_jsx("code", {
|
617
|
+
...attributes,
|
618
|
+
...element.attr,
|
619
|
+
className: "markcode",
|
620
|
+
children: children
|
621
|
+
});
|
591
622
|
default:
|
592
623
|
return /*#__PURE__*/_jsx(SimpleText, {
|
593
624
|
...props,
|
@@ -82,7 +82,8 @@ const splitInlineStyleRanges = (text, inlineStyleRanges, data) => {
|
|
82
82
|
};
|
83
83
|
export const draftToSlate = props => {
|
84
84
|
const {
|
85
|
-
data
|
85
|
+
data,
|
86
|
+
needLayout
|
86
87
|
} = props;
|
87
88
|
if (data?.blocks && data?.blocks?.length > 0) {
|
88
89
|
const converted = data?.blocks?.reduce((a, b) => {
|
@@ -104,7 +105,7 @@ export const draftToSlate = props => {
|
|
104
105
|
return data;
|
105
106
|
} else {
|
106
107
|
return [{
|
107
|
-
type: "paragraph",
|
108
|
+
type: needLayout ? "title" : "paragraph",
|
108
109
|
children: [{
|
109
110
|
text: ""
|
110
111
|
}]
|
@@ -625,6 +625,10 @@ export const isRestrictedNode = (event, editor) => {
|
|
625
625
|
return isNodeRestricted;
|
626
626
|
}
|
627
627
|
};
|
628
|
+
export function capitalizeFirstLetter(str) {
|
629
|
+
if (!str) return str;
|
630
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
631
|
+
}
|
628
632
|
export const insertLineBreakAtEndOfPath = (editor, path) => {
|
629
633
|
try {
|
630
634
|
const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
|
@@ -643,6 +647,13 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
|
|
643
647
|
console.log(err);
|
644
648
|
}
|
645
649
|
};
|
650
|
+
export function isHavingSelection(editor) {
|
651
|
+
try {
|
652
|
+
return editor?.selection && !Range.isCollapsed(editor.selection);
|
653
|
+
} catch (err) {
|
654
|
+
console.log(err);
|
655
|
+
}
|
656
|
+
}
|
646
657
|
const omitNodes = ["site-settings", "page-settings"];
|
647
658
|
export function getInitialValue(value = [], readOnly) {
|
648
659
|
if (readOnly === "readonly" && value?.length) {
|
@@ -673,20 +684,17 @@ export function getInitialValue(value = [], readOnly) {
|
|
673
684
|
}
|
674
685
|
return value;
|
675
686
|
}
|
676
|
-
export function capitalizeFirstLetter(str) {
|
677
|
-
if (!str) return str;
|
678
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
679
|
-
}
|
680
|
-
export function isHavingSelection(editor) {
|
681
|
-
try {
|
682
|
-
return editor?.selection && !Range.isCollapsed(editor.selection);
|
683
|
-
} catch (err) {
|
684
|
-
console.log(err);
|
685
|
-
}
|
686
|
-
}
|
687
687
|
export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
|
688
688
|
return `${defaultCls} ${selected ? selectedClsName : ""}`;
|
689
689
|
}
|
690
|
+
export function handleNegativeInteger(val) {
|
691
|
+
return val < 0 ? 0 : val;
|
692
|
+
}
|
693
|
+
export const containsSurrogatePair = text => {
|
694
|
+
// Match surrogate pairs (high and low surrogate)
|
695
|
+
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
696
|
+
return surrogatePairRegex.test(text);
|
697
|
+
};
|
690
698
|
export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
691
699
|
try {
|
692
700
|
const options = {
|
@@ -700,11 +708,6 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
|
700
708
|
return [];
|
701
709
|
}
|
702
710
|
};
|
703
|
-
export const containsSurrogatePair = text => {
|
704
|
-
// Match surrogate pairs (high and low surrogate)
|
705
|
-
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
706
|
-
return surrogatePairRegex.test(text);
|
707
|
-
};
|
708
711
|
export const getSlateDom = (editor, range) => {
|
709
712
|
try {
|
710
713
|
const slateDom = ReactEditor.toDOMRange(editor, range);
|
@@ -753,7 +756,4 @@ export const viewSlateSelection = () => {
|
|
753
756
|
export const hideSlateSelection = () => {
|
754
757
|
const root = document.documentElement;
|
755
758
|
root.style.setProperty("--slate-highlight-bg", "none");
|
756
|
-
};
|
757
|
-
export function handleNegativeInteger(val) {
|
758
|
-
return val < 0 ? 0 : val;
|
759
|
-
}
|
759
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "5.8.
|
3
|
+
"version": "5.8.7",
|
4
4
|
"description": "An Editor for flozy app brain",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -30,6 +30,7 @@
|
|
30
30
|
"husky": "^8.0.3",
|
31
31
|
"interweave": "^13.1.0",
|
32
32
|
"lint-staged": "^13.2.3",
|
33
|
+
"markdown-it": "^14.1.0",
|
33
34
|
"prettier": "^3.0.1",
|
34
35
|
"react-best-gradient-color-picker": "^2.2.23",
|
35
36
|
"react-datepicker": "^4.18.0",
|
@@ -68,7 +69,7 @@
|
|
68
69
|
"storybook": "storybook dev -p 6006",
|
69
70
|
"build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
|
70
71
|
"publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
|
71
|
-
"publish:local": "rm -rf /Users/
|
72
|
+
"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"
|
72
73
|
},
|
73
74
|
"eslintConfig": {
|
74
75
|
"extends": [
|