@flozy/editor 11.0.6 → 11.0.8
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/ChatEditor.js +17 -16
- package/dist/Editor/CommonEditor.js +141 -28
- package/dist/Editor/DialogWrapper.js +31 -25
- package/dist/Editor/Editor.css +39 -11
- package/dist/Editor/Elements/AI/PopoverAIInput.js +11 -3
- package/dist/Editor/Elements/AI/Styles.js +1 -0
- package/dist/Editor/Elements/Accordion/Accordion.js +28 -22
- package/dist/Editor/Elements/Accordion/AccordionButton.js +12 -3
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/Attachments/AttachmentStyles.js +16 -0
- package/dist/Editor/Elements/Attachments/Attachments.js +153 -11
- package/dist/Editor/Elements/Attachments/AttachmentsButton.js +8 -3
- package/dist/Editor/Elements/Button/EditorButton.js +23 -7
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +61 -14
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +10 -7
- package/dist/Editor/Elements/Color Picker/Styles.js +15 -13
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +134 -55
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SelectV1.js +7 -8
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +8 -3
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +1 -1
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +1 -1
- package/dist/Editor/Elements/Embed/Embed.js +36 -43
- package/dist/Editor/Elements/Embed/Image.js +236 -23
- package/dist/Editor/Elements/Embed/Video.js +245 -15
- package/dist/Editor/Elements/Form/Form.js +35 -10
- package/dist/Editor/Elements/Form/FormField.js +1 -1
- package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
- package/dist/Editor/Elements/Form/Workflow/constant.js +25 -1
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +31 -74
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +9 -5
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +3 -1
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
- package/dist/Editor/Elements/FreeGrid/helper.js +194 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +15 -0
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +2 -1
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +3 -2
- package/dist/Editor/Elements/Signature/SignaturePopup.js +24 -6
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +5 -4
- package/dist/Editor/Elements/Table/TableCell.js +10 -3
- package/dist/Editor/Elements/Title/title.js +10 -11
- package/dist/Editor/Elements/TopBanner/TopBanner.js +4 -2
- package/dist/Editor/Elements/TopBanner/TopBannerButton.js +5 -3
- package/dist/Editor/Elements/Variables/VariableButton.js +10 -1
- package/dist/Editor/MiniEditor.js +2 -1
- package/dist/Editor/Styles/EditorStyles.js +23 -5
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +33 -29
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +4 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +25 -23
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectList.js +25 -7
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +167 -42
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +24 -8
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +70 -10
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +73 -14
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +439 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +7 -4
- package/dist/Editor/Toolbar/toolbarGroups.js +56 -10
- package/dist/Editor/assets/svg/BackIcon.js +18 -0
- package/dist/Editor/assets/svg/ThemeIcons.js +293 -0
- package/dist/Editor/common/ColorPickerButton.js +38 -16
- package/dist/Editor/common/CustomColorPicker/index.js +130 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog2/index.js +94 -0
- package/dist/Editor/common/CustomDialog2/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +43 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -0
- package/dist/Editor/common/Icon.js +28 -0
- package/dist/Editor/common/ImageSelector/ImageSelector.js +45 -7
- package/dist/Editor/common/ImageSelector/Options/Upload.js +26 -11
- package/dist/Editor/common/ImageSelector/Styles.js +3 -9
- package/dist/Editor/common/LinkSettings/NavComponents.js +6 -2
- package/dist/Editor/common/MentionsPopup/index.js +9 -1
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +4 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +20 -7
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +9 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +20 -7
- package/dist/Editor/common/RnD/GuideLines/styles.js +1 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +11 -2
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +28 -11
- package/dist/Editor/common/RnD/Utils/index.js +3 -1
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +52 -63
- package/dist/Editor/common/RnD/VirtualElement/helper.js +320 -130
- package/dist/Editor/common/RnD/VirtualElement/styles.js +22 -0
- package/dist/Editor/common/RnD/index.js +61 -14
- package/dist/Editor/common/Shorthands/elements.js +62 -4
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +4 -0
- package/dist/Editor/common/StyleBuilder/fieldStyle.js +1 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +15 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +16 -8
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +36 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +115 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +16 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +2 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +1 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
- package/dist/Editor/common/StyleBuilder/formStyle.js +19 -13
- package/dist/Editor/common/StyleBuilder/index.js +8 -4
- package/dist/Editor/common/Uploader.js +125 -17
- package/dist/Editor/common/UploaderWithProgress.js +183 -0
- package/dist/Editor/common/iconslist.js +21 -0
- package/dist/Editor/commonStyle.js +136 -63
- package/dist/Editor/helper/index.js +10 -2
- package/dist/Editor/helper/textIndeces.js +58 -0
- package/dist/Editor/helper/theme.js +203 -2
- package/dist/Editor/hooks/useEditorTheme.js +153 -0
- package/dist/Editor/hooks/useMouseMove.js +9 -3
- package/dist/Editor/hooks/useTable.js +62 -1
- package/dist/Editor/hooks/useThemeValues.js +63 -0
- package/dist/Editor/plugins/withEmbeds.js +12 -1
- package/dist/Editor/plugins/withHTML.js +58 -3
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/service/fileupload.js +70 -0
- package/dist/Editor/theme/ThemeList.js +50 -173
- package/dist/Editor/theme/index.js +149 -0
- package/dist/Editor/themeSettings/ActiveTheme.js +82 -0
- package/dist/Editor/themeSettings/buttons/index.js +300 -0
- package/dist/Editor/themeSettings/buttons/style.js +23 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +310 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +81 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
- package/dist/Editor/themeSettings/fonts/index.js +240 -0
- package/dist/Editor/themeSettings/fonts/style.js +62 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +380 -0
- package/dist/Editor/themeSettings/style.js +299 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +355 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +202 -0
- package/dist/Editor/themeSettingsAI/style.js +332 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +192 -40
- package/dist/Editor/utils/accordion.js +67 -39
- package/dist/Editor/utils/button.js +1 -17
- package/dist/Editor/utils/draftToSlate.js +3 -2
- package/dist/Editor/utils/events.js +94 -89
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/formfield.js +2 -2
- package/dist/Editor/utils/helper.js +100 -23
- package/dist/Editor/utils/insertAppHeader.js +8 -4
- package/package.json +4 -4
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +0 -454
@@ -34,12 +34,12 @@ import SimpleText from "../Elements/SimpleText";
|
|
34
34
|
import CheckList from "../Elements/List/CheckList";
|
35
35
|
import { getTextColor, isEmptyTextNode } from "../helper";
|
36
36
|
import Attachments from "../Elements/Attachments/Attachments";
|
37
|
-
import { getBreakpointLineSpacing, getBreakPointsValue, getDevice,
|
37
|
+
import { getBreakpointLineSpacing, getBreakPointsValue, getDevice, getElementProperty, textThemeFields } from "../helper/theme";
|
38
38
|
import Variables from "../Elements/Variables/Variable";
|
39
|
-
import insertNewLine from "./insertNewLine";
|
40
39
|
import Divider from "../Elements/Divider/Divider";
|
41
40
|
import { getBorderColor, getSlateDom } from "./helper";
|
42
41
|
import Code from "../Elements/EmbedScript/Code";
|
42
|
+
import { ReactEditor } from "slate-react";
|
43
43
|
import FreeGrid from "../Elements/FreeGrid/FreeGrid";
|
44
44
|
import FreeGridItem from "../Elements/FreeGrid/FreeGridItem";
|
45
45
|
import FreeGridBox from "../Elements/FreeGrid/FreeGridBox";
|
@@ -47,17 +47,27 @@ import DataView from "../Elements/DataView/DataView";
|
|
47
47
|
import ViewData from "../Elements/DataView/Layouts/ViewData";
|
48
48
|
import ColumnView from "../Elements/DataView/Layouts/ColumnView";
|
49
49
|
import SearchAttachment from "../Elements/Search/SearchAttachment";
|
50
|
-
|
50
|
+
import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
|
51
51
|
import { jsx as _jsx } from "react/jsx-runtime";
|
52
52
|
const alignment = ["alignLeft", "alignRight", "alignCenter", "alignJustify"];
|
53
|
-
const list_types = ["orderedList", "unorderedList"];
|
53
|
+
export const list_types = ["orderedList", "unorderedList"];
|
54
54
|
const LIST_FORMAT_TYPE = {
|
55
55
|
orderedList: "list-item",
|
56
56
|
unorderedList: "list-item"
|
57
57
|
};
|
58
|
-
|
58
|
+
|
59
|
+
// const NEWLINESAFTER = [
|
60
|
+
// "headingOne",
|
61
|
+
// "headingTwo",
|
62
|
+
// "headingThree",
|
63
|
+
// "headingFour",
|
64
|
+
// "headingFive",
|
65
|
+
// "headingSix",
|
66
|
+
// ];
|
67
|
+
|
68
|
+
const THEME_BLOCK_FIELDS = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
59
69
|
export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
60
|
-
|
70
|
+
let isActive = isBlockActive(editor, format);
|
61
71
|
const isList = list_types.includes(format);
|
62
72
|
const isIndent = alignment.includes(format);
|
63
73
|
const isAligned = alignment.some(alignmentType => isBlockActive(editor, alignmentType));
|
@@ -88,8 +98,9 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
88
98
|
if (!selection) {
|
89
99
|
Transforms.insertText(editor, "");
|
90
100
|
}
|
101
|
+
const forActiveType = THEME_BLOCK_FIELDS.some(f => f === format) ? format : "paragraph";
|
91
102
|
Transforms.setNodes(editor, {
|
92
|
-
type: isActive ?
|
103
|
+
type: isActive ? forActiveType : isList ? LIST_FORMAT_TYPE[format] : format,
|
93
104
|
...attr
|
94
105
|
});
|
95
106
|
if (isList && !isActive) {
|
@@ -98,10 +109,12 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
98
109
|
children: []
|
99
110
|
});
|
100
111
|
}
|
101
|
-
|
102
|
-
|
103
|
-
|
112
|
+
|
113
|
+
// if (NEWLINESAFTER.indexOf(format) > -1) {
|
114
|
+
// insertNewLine(editor);
|
115
|
+
// }
|
104
116
|
};
|
117
|
+
|
105
118
|
export const addMarkData = (editor, data) => {
|
106
119
|
try {
|
107
120
|
Editor.addMark(editor, data.format, data.value);
|
@@ -110,9 +123,14 @@ export const addMarkData = (editor, data) => {
|
|
110
123
|
}
|
111
124
|
};
|
112
125
|
export const toggleMark = (editor, format) => {
|
113
|
-
const isActive =
|
126
|
+
const isActive = isMarkBtnActive(editor, format);
|
114
127
|
if (isActive) {
|
115
|
-
|
128
|
+
const isThemeSupportedMark = textThemeFields.some(f => f === format);
|
129
|
+
if (isThemeSupportedMark) {
|
130
|
+
Editor.addMark(editor, format, false);
|
131
|
+
} else {
|
132
|
+
Editor.removeMark(editor, format);
|
133
|
+
}
|
116
134
|
} else {
|
117
135
|
Editor.addMark(editor, format, true);
|
118
136
|
}
|
@@ -126,12 +144,91 @@ export const isMarkActive = (editor, format) => {
|
|
126
144
|
return null;
|
127
145
|
}
|
128
146
|
};
|
147
|
+
export const isMarkBtnActive = (editor, format) => {
|
148
|
+
switch (format) {
|
149
|
+
case "bold":
|
150
|
+
{
|
151
|
+
const style = getSelectedElementStyle("font-weight", editor);
|
152
|
+
return style === "700";
|
153
|
+
}
|
154
|
+
case "italic":
|
155
|
+
{
|
156
|
+
const style = getSelectedElementStyle("font-style", editor);
|
157
|
+
return style === format;
|
158
|
+
}
|
159
|
+
// case "underline": {
|
160
|
+
// const style = getSelectedElementStyle("text-decoration");
|
161
|
+
|
162
|
+
// return style?.includes(format);
|
163
|
+
// }
|
164
|
+
// case "strikethrough": {
|
165
|
+
// const style = getSelectedElementStyle("text-decoration");
|
166
|
+
|
167
|
+
// return style?.includes("line-through");
|
168
|
+
// }
|
169
|
+
default:
|
170
|
+
return isMarkActive(editor, format);
|
171
|
+
}
|
172
|
+
};
|
173
|
+
export const getSelectedElementStyle = (styleProperty, editor, format) => {
|
174
|
+
try {
|
175
|
+
if (!editor.selection) {
|
176
|
+
return "";
|
177
|
+
}
|
178
|
+
if (Range.isCollapsed(editor.selection)) {
|
179
|
+
return "";
|
180
|
+
}
|
181
|
+
if (format) {
|
182
|
+
const value = activeMark(editor, format, true);
|
183
|
+
if (value) {
|
184
|
+
return value;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
188
|
+
const selectedDomNode = domRange.commonAncestorContainer;
|
189
|
+
|
190
|
+
// If it's a text node, get its parent element
|
191
|
+
const selectedElement = selectedDomNode.nodeType === 3 ? selectedDomNode.parentElement : selectedDomNode;
|
192
|
+
if (selectedElement) {
|
193
|
+
return getElementProperty(selectedElement, styleProperty);
|
194
|
+
}
|
195
|
+
} catch (err) {
|
196
|
+
console.log(err);
|
197
|
+
}
|
198
|
+
};
|
129
199
|
export const isBlockActive = (editor, format) => {
|
130
200
|
const [match] = Editor.nodes(editor, {
|
131
201
|
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
|
132
202
|
});
|
133
203
|
return !!match;
|
134
204
|
};
|
205
|
+
export const isListActive = editor => {
|
206
|
+
const list_types = ["orderedList", "unorderedList", "check-list-item", "accordion"];
|
207
|
+
const [match] = Editor.nodes(editor, {
|
208
|
+
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && list_types.includes(n.type),
|
209
|
+
mode: "lowest" // To ensure it's the closest parent
|
210
|
+
});
|
211
|
+
|
212
|
+
if (match) {
|
213
|
+
const [matchNode] = match;
|
214
|
+
return matchNode.type;
|
215
|
+
}
|
216
|
+
};
|
217
|
+
export const getListType = editor => {
|
218
|
+
const [accordionSummary] = Editor.nodes(editor, {
|
219
|
+
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === "accordion-summary"
|
220
|
+
});
|
221
|
+
if (accordionSummary) {
|
222
|
+
return "accordion-summary";
|
223
|
+
}
|
224
|
+
const listItems = ["list-item", "check-list-item"];
|
225
|
+
const [listItem] = Editor.nodes(editor, {
|
226
|
+
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && listItems.includes(n.type)
|
227
|
+
});
|
228
|
+
if (listItem) {
|
229
|
+
return "list-item";
|
230
|
+
}
|
231
|
+
};
|
135
232
|
export const getBlockActive = (editor, format) => {
|
136
233
|
const [match] = Editor.nodes(editor, {
|
137
234
|
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
|
@@ -151,7 +248,7 @@ export const upateBlockActive = (editor, format, attr = {}) => {
|
|
151
248
|
});
|
152
249
|
}
|
153
250
|
};
|
154
|
-
export const activeMark = (editor, format) => {
|
251
|
+
export const activeMark = (editor, format, noDefaultValue) => {
|
155
252
|
const defaultMarkData = {
|
156
253
|
color: "#000000",
|
157
254
|
bgColor: "#FFFFFF",
|
@@ -161,7 +258,7 @@ export const activeMark = (editor, format) => {
|
|
161
258
|
};
|
162
259
|
try {
|
163
260
|
const marks = Editor.marks(editor);
|
164
|
-
let defaultValue = defaultMarkData[format];
|
261
|
+
let defaultValue = noDefaultValue ? "" : defaultMarkData[format];
|
165
262
|
const {
|
166
263
|
selection
|
167
264
|
} = editor || {};
|
@@ -178,6 +275,31 @@ export const activeMark = (editor, format) => {
|
|
178
275
|
return null;
|
179
276
|
}
|
180
277
|
};
|
278
|
+
|
279
|
+
// to avoid the styles, that automatically assign from themes
|
280
|
+
const getThemeMarkedLeaf = (leaf, children) => {
|
281
|
+
const {
|
282
|
+
italic,
|
283
|
+
bold
|
284
|
+
} = leaf || {};
|
285
|
+
const style = {};
|
286
|
+
if (italic === false) {
|
287
|
+
style.fontStyle = "normal";
|
288
|
+
}
|
289
|
+
if (bold === false) {
|
290
|
+
style.fontWeight = "normal";
|
291
|
+
}
|
292
|
+
if (Object.keys(style).length) {
|
293
|
+
children = /*#__PURE__*/_jsx(Box, {
|
294
|
+
component: "span",
|
295
|
+
sx: {
|
296
|
+
"& span": style
|
297
|
+
},
|
298
|
+
children: children
|
299
|
+
});
|
300
|
+
}
|
301
|
+
return children;
|
302
|
+
};
|
181
303
|
export const getMarked = (leaf, children, theme) => {
|
182
304
|
const className = leaf?.doublequote ? "doublequote" : "";
|
183
305
|
const lineH = leaf?.lineHeight;
|
@@ -207,6 +329,7 @@ export const getMarked = (leaf, children, theme) => {
|
|
207
329
|
children: children
|
208
330
|
});
|
209
331
|
}
|
332
|
+
children = getThemeMarkedLeaf(leaf, children);
|
210
333
|
if (leaf.strikethrough) {
|
211
334
|
children = /*#__PURE__*/_jsx("span", {
|
212
335
|
style: {
|
@@ -234,6 +357,15 @@ export const getMarked = (leaf, children, theme) => {
|
|
234
357
|
if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || lineHeight || className) {
|
235
358
|
const family = leaf?.fontFamily;
|
236
359
|
const textStyles = getTextColor(leaf?.color);
|
360
|
+
const fontSize = {
|
361
|
+
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
362
|
+
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
363
|
+
};
|
364
|
+
const fontSizesImportant = {};
|
365
|
+
Object.entries(fontSize).forEach(([key, value]) => {
|
366
|
+
fontSizesImportant[key] = `${value} !important`;
|
367
|
+
});
|
368
|
+
const fontSizeWithBreakpoints = wrapThemeBreakpoints(fontSizesImportant, "fontSize", theme);
|
237
369
|
children = /*#__PURE__*/_jsx("span", {
|
238
370
|
style: {
|
239
371
|
background: leaf.bgColor
|
@@ -242,12 +374,13 @@ export const getMarked = (leaf, children, theme) => {
|
|
242
374
|
className: `${className} leaf-item`,
|
243
375
|
component: "span",
|
244
376
|
sx: {
|
245
|
-
|
246
|
-
fontSize:
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
},
|
377
|
+
"& span": {
|
378
|
+
// fontSize: fontSizesImportant,
|
379
|
+
// ...groupByBreakpoint(fontSizesImportant, theme),
|
380
|
+
background: leaf.bgColor,
|
381
|
+
...fontSizeWithBreakpoints
|
382
|
+
},
|
383
|
+
...fontSizeWithBreakpoints,
|
251
384
|
// ...wrapThemeBreakpoints(
|
252
385
|
// {
|
253
386
|
// lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
@@ -268,7 +401,8 @@ export const getMarked = (leaf, children, theme) => {
|
|
268
401
|
WebkitTextFillColor: "unset !important"
|
269
402
|
},
|
270
403
|
style: {
|
271
|
-
"--fontSize_xs": leaf?.fontSize?.xs || "auto"
|
404
|
+
"--fontSize_xs": leaf?.fontSize?.xs || "auto",
|
405
|
+
"--fontSize_lg": leaf?.fontSize?.lg || "auto"
|
272
406
|
},
|
273
407
|
children: children
|
274
408
|
})
|
@@ -299,62 +433,79 @@ export const getBlock = props => {
|
|
299
433
|
const {
|
300
434
|
translation
|
301
435
|
} = customProps;
|
436
|
+
const commonHeadingProps = () => ({
|
437
|
+
...attributes,
|
438
|
+
...element.attr,
|
439
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent`
|
440
|
+
});
|
441
|
+
const commonParaProps = paraType => ({
|
442
|
+
...attributes,
|
443
|
+
...element.attr,
|
444
|
+
className: `edt-paragraphs content-editable ${isEmpty ? "empty" : ""} theme-element disablePointerEvent ${paraType}`
|
445
|
+
});
|
302
446
|
const breakpoint = getDevice(window.innerWidth);
|
303
447
|
const lineH = element?.children[0]?.lineHeight;
|
304
448
|
const selectedLineHeight = getBreakpointLineSpacing(lineH, breakpoint);
|
305
449
|
switch (element.type) {
|
306
450
|
case "headingOne":
|
307
451
|
return /*#__PURE__*/_jsx("h1", {
|
308
|
-
...
|
309
|
-
...element.attr,
|
310
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
452
|
+
...commonHeadingProps(),
|
311
453
|
placeholder: translation("Heading 1"),
|
312
454
|
children: children
|
313
455
|
});
|
314
456
|
case "headingTwo":
|
315
457
|
return /*#__PURE__*/_jsx("h2", {
|
316
|
-
...
|
317
|
-
...element.attr,
|
318
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
458
|
+
...commonHeadingProps(),
|
319
459
|
placeholder: translation("Heading 2"),
|
320
460
|
children: children
|
321
461
|
});
|
322
462
|
case "headingThree":
|
323
463
|
return /*#__PURE__*/_jsx("h3", {
|
324
|
-
...
|
325
|
-
...element.attr,
|
326
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
464
|
+
...commonHeadingProps(),
|
327
465
|
placeholder: translation("Heading 3"),
|
328
466
|
children: children
|
329
467
|
});
|
330
468
|
case "headingFour":
|
331
469
|
return /*#__PURE__*/_jsx("h4", {
|
332
|
-
...
|
333
|
-
...element.attr,
|
334
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
470
|
+
...commonHeadingProps(),
|
335
471
|
placeholder: translation("Heading 4"),
|
336
472
|
children: children
|
337
473
|
});
|
338
474
|
case "headingFive":
|
339
475
|
return /*#__PURE__*/_jsx("h5", {
|
340
|
-
...
|
341
|
-
...element.attr,
|
342
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
476
|
+
...commonHeadingProps(),
|
343
477
|
placeholder: translation("Heading 5"),
|
344
478
|
children: children
|
345
479
|
});
|
346
480
|
case "headingSix":
|
347
481
|
return /*#__PURE__*/_jsx("h6", {
|
348
|
-
...
|
349
|
-
...element.attr,
|
350
|
-
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
482
|
+
...commonHeadingProps(),
|
351
483
|
placeholder: translation("Heading 6"),
|
352
484
|
children: children
|
353
485
|
});
|
486
|
+
case "paragraphOne":
|
487
|
+
return /*#__PURE__*/_jsx("p", {
|
488
|
+
...commonParaProps("para1"),
|
489
|
+
placeholder: "Paragraph 1",
|
490
|
+
children: children
|
491
|
+
});
|
492
|
+
case "paragraphTwo":
|
493
|
+
return /*#__PURE__*/_jsx("p", {
|
494
|
+
...commonParaProps("para2"),
|
495
|
+
placeholder: "Paragraph 2",
|
496
|
+
children: children
|
497
|
+
});
|
498
|
+
case "paragraphThree":
|
499
|
+
return /*#__PURE__*/_jsx("p", {
|
500
|
+
...commonParaProps("para3"),
|
501
|
+
placeholder: "Paragraph 3",
|
502
|
+
children: children
|
503
|
+
});
|
354
504
|
case "blockquote":
|
355
505
|
return /*#__PURE__*/_jsx("blockquote", {
|
356
506
|
...attributes,
|
357
507
|
...element.attr,
|
508
|
+
className: "blockQuoteComp",
|
358
509
|
style: {
|
359
510
|
// borderColor: element?.color || "transparent",
|
360
511
|
...getBorderColor(element?.color || "transparent", 3),
|
@@ -584,7 +735,8 @@ export const getBlock = props => {
|
|
584
735
|
case "docs":
|
585
736
|
case "pdf":
|
586
737
|
case "xls":
|
587
|
-
case "
|
738
|
+
case "doc":
|
739
|
+
case "ppt":
|
588
740
|
return /*#__PURE__*/_jsx(Attachments, {
|
589
741
|
...props
|
590
742
|
});
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import { Editor, Element, Path, Transforms } from "slate";
|
2
|
-
import insertNewLine from "./insertNewLine";
|
3
2
|
import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType, getSelectedText } from "./helper";
|
4
|
-
import { isMobileWindow } from "../helper";
|
5
3
|
import { removeAccordion } from "./events";
|
6
4
|
import { ReactEditor } from "slate-react";
|
7
5
|
const focusAccordion = (editor, upPath) => {
|
@@ -9,51 +7,74 @@ const focusAccordion = (editor, upPath) => {
|
|
9
7
|
path: upPath,
|
10
8
|
offset: 0
|
11
9
|
});
|
10
|
+
ReactEditor.focus(editor);
|
12
11
|
};
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
type: "accordion",
|
12
|
+
const getAccordionNode = summaryNode => {
|
13
|
+
return {
|
14
|
+
type: "accordion",
|
15
|
+
children: [{
|
16
|
+
type: "accordion-summary",
|
17
|
+
children: summaryNode
|
18
|
+
}, {
|
19
|
+
type: "accordion-details",
|
18
20
|
children: [{
|
19
|
-
type: "
|
21
|
+
type: "paragraph",
|
20
22
|
children: [{
|
21
|
-
|
22
|
-
children: [{
|
23
|
-
text: selectedText || ""
|
24
|
-
}]
|
23
|
+
text: ""
|
25
24
|
}]
|
26
|
-
}
|
27
|
-
|
25
|
+
}]
|
26
|
+
}]
|
27
|
+
};
|
28
|
+
};
|
29
|
+
export const insertAccordion = (editor, path) => {
|
30
|
+
try {
|
31
|
+
const {
|
32
|
+
selection
|
33
|
+
} = editor;
|
34
|
+
let accordionPath;
|
35
|
+
if (path) {
|
36
|
+
const summaryNode = {
|
37
|
+
type: "paragraph",
|
28
38
|
children: [{
|
29
|
-
|
30
|
-
children: [{
|
31
|
-
text: ""
|
32
|
-
}]
|
39
|
+
text: ""
|
33
40
|
}]
|
34
|
-
}
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
// get title index
|
46
|
-
const summaryIndex = upPath.length - 3;
|
47
|
-
upPath[summaryIndex] = upPath[summaryIndex] === 0 ? 0 : upPath[summaryIndex] - 1;
|
41
|
+
};
|
42
|
+
const accordion = getAccordionNode([summaryNode]);
|
43
|
+
Transforms.insertNodes(editor, accordion, {
|
44
|
+
at: path
|
45
|
+
});
|
46
|
+
accordionPath = path;
|
47
|
+
} else if (selection) {
|
48
|
+
const selectedNodes = Array.from(Editor.nodes(editor, {
|
49
|
+
match: n => Element.isElement(n),
|
50
|
+
mode: "lowest" // use 'lowest' to get individual blocks
|
51
|
+
}));
|
48
52
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
for (const [node, path] of selectedNodes) {
|
54
|
+
let currNode = node;
|
55
|
+
// const isListItem = node.type === "list-item";
|
56
|
+
// if (isListItem) {
|
57
|
+
// currNode = {
|
58
|
+
// type: "paragraph",
|
59
|
+
// children: node.children,
|
60
|
+
// };
|
61
|
+
// }
|
62
|
+
|
63
|
+
let accordion = getAccordionNode([currNode]);
|
64
|
+
Transforms.removeNodes(editor, {
|
65
|
+
at: path
|
66
|
+
});
|
67
|
+
Transforms.insertNodes(editor, accordion, {
|
68
|
+
at: path
|
69
|
+
});
|
70
|
+
accordionPath = path;
|
71
|
+
}
|
72
|
+
const lastNode = selectedNodes[selectedNodes.length - 1];
|
73
|
+
const lastNodePath = lastNode[1];
|
74
|
+
accordionPath = lastNodePath;
|
55
75
|
}
|
56
|
-
|
76
|
+
const focusPath = [...accordionPath, 0, 0, 0];
|
77
|
+
focusAccordion(editor, focusPath);
|
57
78
|
} catch (err) {
|
58
79
|
console.log(err);
|
59
80
|
}
|
@@ -133,4 +154,11 @@ export const onDeleteBackwardAccordion = editor => {
|
|
133
154
|
} catch (err) {
|
134
155
|
console.log(err);
|
135
156
|
}
|
157
|
+
};
|
158
|
+
export const toggleAccordion = editor => {
|
159
|
+
const parentAccordion = Editor.above(editor, {
|
160
|
+
match: node => Element.isElement(node) && node.type === "accordion"
|
161
|
+
});
|
162
|
+
const [, accordionPath] = parentAccordion;
|
163
|
+
removeAccordion(editor, accordionPath);
|
136
164
|
};
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { Path, Transforms } from "slate";
|
2
2
|
import insertNewLine from "./insertNewLine";
|
3
|
-
import { windowVar } from "./helper";
|
4
3
|
import { getCurrentElementText } from "../plugins/withHTML";
|
5
4
|
export const insertButton = editor => {
|
6
5
|
const button = {
|
@@ -11,22 +10,7 @@ export const insertButton = editor => {
|
|
11
10
|
buttonLink: {
|
12
11
|
linkType: "webAddress"
|
13
12
|
},
|
14
|
-
iconPosition: "start"
|
15
|
-
bgColor: "#2563EB",
|
16
|
-
textColor: "#FFF",
|
17
|
-
borderRadius: {
|
18
|
-
topLeft: 30,
|
19
|
-
topRight: 30,
|
20
|
-
bottomLeft: 30,
|
21
|
-
bottomRight: 30
|
22
|
-
},
|
23
|
-
bannerSpacing: {
|
24
|
-
left: 16,
|
25
|
-
top: 8,
|
26
|
-
right: 16,
|
27
|
-
bottom: 8
|
28
|
-
},
|
29
|
-
...(windowVar.lastButtonProps || {})
|
13
|
+
iconPosition: "start"
|
30
14
|
};
|
31
15
|
const hasText = getCurrentElementText(editor);
|
32
16
|
const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor?.selection.focus.path;
|
@@ -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
|
}]
|