@flozy/editor 10.8.9 → 10.9.0
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 +138 -27
- 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 +240 -23
- package/dist/Editor/Elements/Embed/Video.js +246 -15
- 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 +39 -33
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +7 -4
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -0
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
- package/dist/Editor/Elements/FreeGrid/helper.js +115 -0
- package/dist/Editor/Elements/FreeGrid/styles.js +9 -0
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +2 -1
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +3 -3
- package/dist/Editor/Elements/Title/title.js +6 -6
- 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 +20 -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 +23 -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 +5 -2
- 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 -18
- package/dist/Editor/common/RnD/Utils/index.js +3 -1
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +45 -58
- 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 +48 -13
- 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/textOptions.js +15 -7
- 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 +107 -64
- 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/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 +53 -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 +183 -21
- package/dist/Editor/utils/accordion.js +68 -40
- 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/helper.js +97 -21
- 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
@@ -1,7 +1,5 @@
|
|
1
1
|
import { Editor, Element, Path, Transforms } from "slate";
|
2
|
-
import
|
3
|
-
import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType, getSelectedText } from "./helper";
|
4
|
-
import { isMobileWindow } from "../helper";
|
2
|
+
import { ALLOWED_TEXT_NODES, getNode, getNodeText, getNodeWithType } 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
|
}]
|
@@ -197,9 +197,102 @@ export const removeAccordion = (editor, accordionPath) => {
|
|
197
197
|
select: true
|
198
198
|
});
|
199
199
|
};
|
200
|
+
export const customizeEnterEvent = (editor, ele, e) => {
|
201
|
+
const {
|
202
|
+
type
|
203
|
+
} = ele[0];
|
204
|
+
const path = ele[1];
|
205
|
+
const text = Node.string(ele[0]);
|
206
|
+
let breakNext = false;
|
207
|
+
switch (type) {
|
208
|
+
case "list-item":
|
209
|
+
if (!text) {
|
210
|
+
e?.preventDefault();
|
211
|
+
escapeEvent({
|
212
|
+
editor
|
213
|
+
});
|
214
|
+
}
|
215
|
+
break;
|
216
|
+
case "check-list-item":
|
217
|
+
const selectionPath = editor?.selection?.anchor?.path;
|
218
|
+
const currEle = Node.parent(editor, selectionPath);
|
219
|
+
const currEleText = Node.string(currEle);
|
220
|
+
if (!currEleText) {
|
221
|
+
e?.preventDefault();
|
222
|
+
checkListEnterEvent(editor, type);
|
223
|
+
}
|
224
|
+
break;
|
225
|
+
case "accordion-summary":
|
226
|
+
e?.preventDefault();
|
227
|
+
breakNext = true;
|
228
|
+
if (!text) {
|
229
|
+
const accordionIndex = ele[1].slice(0, Math.max(ele[1].length - 1));
|
230
|
+
removeAccordion(editor, accordionIndex);
|
231
|
+
} else {
|
232
|
+
const nextPath = Path.next(Path.parent(ele[1]));
|
233
|
+
insertAccordion(editor, nextPath);
|
234
|
+
}
|
235
|
+
break;
|
236
|
+
case "headingOne":
|
237
|
+
case "headingTwo":
|
238
|
+
case "headingThree":
|
239
|
+
const {
|
240
|
+
selection
|
241
|
+
} = editor;
|
242
|
+
if (selection && Range.isCollapsed(selection)) {
|
243
|
+
const isAtEnd = Editor.isEnd(editor, selection.anchor, path);
|
244
|
+
const isAtStart = Editor.isStart(editor, selection.anchor, path);
|
245
|
+
if (isAtEnd) {
|
246
|
+
e?.preventDefault();
|
247
|
+
Transforms.insertNodes(editor, {
|
248
|
+
type: "paragraph",
|
249
|
+
children: [{
|
250
|
+
text: ""
|
251
|
+
}]
|
252
|
+
});
|
253
|
+
const newLocation = Editor.after(editor, selection);
|
254
|
+
if (newLocation) {
|
255
|
+
Transforms.select(editor, newLocation);
|
256
|
+
}
|
257
|
+
} else if (!isAtStart) {
|
258
|
+
e?.preventDefault();
|
259
|
+
Transforms.splitNodes(editor);
|
260
|
+
Transforms.setNodes(editor, {
|
261
|
+
type: "paragraph"
|
262
|
+
}, {
|
263
|
+
at: Editor.after(editor, selection)
|
264
|
+
});
|
265
|
+
const newLocation = Editor.after(editor, selection);
|
266
|
+
if (newLocation) {
|
267
|
+
Transforms.select(editor, newLocation);
|
268
|
+
}
|
269
|
+
} else if (isAtStart) {
|
270
|
+
e?.preventDefault();
|
271
|
+
Transforms.insertNodes(editor, {
|
272
|
+
type: "paragraph",
|
273
|
+
children: [{
|
274
|
+
text: ""
|
275
|
+
}]
|
276
|
+
}, {
|
277
|
+
at: Editor.before(editor, selection)
|
278
|
+
});
|
279
|
+
Transforms.select(editor, Editor.before(editor, selection));
|
280
|
+
const newLocation = Editor.before(editor, selection);
|
281
|
+
if (newLocation) {
|
282
|
+
Transforms.select(editor, newLocation);
|
283
|
+
}
|
284
|
+
}
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
break;
|
288
|
+
default:
|
289
|
+
}
|
290
|
+
return {
|
291
|
+
breakNext
|
292
|
+
};
|
293
|
+
};
|
200
294
|
export const enterEvent = (e, editor, isMobile) => {
|
201
295
|
try {
|
202
|
-
const ele = isListItem(editor);
|
203
296
|
// on shift enter break line in same node
|
204
297
|
if (e.shiftKey && !isMobile) {
|
205
298
|
e.preventDefault();
|
@@ -211,94 +304,6 @@ export const enterEvent = (e, editor, isMobile) => {
|
|
211
304
|
} else {
|
212
305
|
Transforms.insertText(editor, "\n");
|
213
306
|
}
|
214
|
-
} else if (ele && ele[0]) {
|
215
|
-
const {
|
216
|
-
type
|
217
|
-
} = ele[0];
|
218
|
-
const path = ele[1];
|
219
|
-
const text = Node.string(ele[0]);
|
220
|
-
switch (type) {
|
221
|
-
case "list-item":
|
222
|
-
if (!text) {
|
223
|
-
e.preventDefault();
|
224
|
-
escapeEvent({
|
225
|
-
editor
|
226
|
-
});
|
227
|
-
}
|
228
|
-
break;
|
229
|
-
case "check-list-item":
|
230
|
-
const selectionPath = editor?.selection?.anchor?.path;
|
231
|
-
const currEle = Node.parent(editor, selectionPath);
|
232
|
-
const currEleText = Node.string(currEle);
|
233
|
-
if (!currEleText) {
|
234
|
-
e.preventDefault();
|
235
|
-
checkListEnterEvent(editor, type);
|
236
|
-
}
|
237
|
-
break;
|
238
|
-
case "accordion-summary":
|
239
|
-
e.preventDefault();
|
240
|
-
if (!text) {
|
241
|
-
const accordionIndex = ele[1].slice(0, Math.max(ele[1].length - 1));
|
242
|
-
removeAccordion(editor, accordionIndex);
|
243
|
-
} else {
|
244
|
-
const nextPath = Path.next(Path.parent(ele[1]));
|
245
|
-
insertAccordion(editor, nextPath);
|
246
|
-
}
|
247
|
-
break;
|
248
|
-
case "headingOne":
|
249
|
-
case "headingTwo":
|
250
|
-
case "headingThree":
|
251
|
-
const {
|
252
|
-
selection
|
253
|
-
} = editor;
|
254
|
-
if (selection && Range.isCollapsed(selection)) {
|
255
|
-
const isAtEnd = Editor.isEnd(editor, selection.anchor, path);
|
256
|
-
const isAtStart = Editor.isStart(editor, selection.anchor, path);
|
257
|
-
if (isAtEnd) {
|
258
|
-
e.preventDefault();
|
259
|
-
Transforms.insertNodes(editor, {
|
260
|
-
type: "paragraph",
|
261
|
-
children: [{
|
262
|
-
text: ""
|
263
|
-
}]
|
264
|
-
});
|
265
|
-
const newLocation = Editor.after(editor, selection);
|
266
|
-
if (newLocation) {
|
267
|
-
Transforms.select(editor, newLocation);
|
268
|
-
}
|
269
|
-
} else if (!isAtStart) {
|
270
|
-
e.preventDefault();
|
271
|
-
Transforms.splitNodes(editor);
|
272
|
-
Transforms.setNodes(editor, {
|
273
|
-
type: "paragraph"
|
274
|
-
}, {
|
275
|
-
at: Editor.after(editor, selection)
|
276
|
-
});
|
277
|
-
const newLocation = Editor.after(editor, selection);
|
278
|
-
if (newLocation) {
|
279
|
-
Transforms.select(editor, newLocation);
|
280
|
-
}
|
281
|
-
} else if (isAtStart) {
|
282
|
-
e.preventDefault();
|
283
|
-
Transforms.insertNodes(editor, {
|
284
|
-
type: "paragraph",
|
285
|
-
children: [{
|
286
|
-
text: ""
|
287
|
-
}]
|
288
|
-
}, {
|
289
|
-
at: Editor.before(editor, selection)
|
290
|
-
});
|
291
|
-
Transforms.select(editor, Editor.before(editor, selection));
|
292
|
-
const newLocation = Editor.before(editor, selection);
|
293
|
-
if (newLocation) {
|
294
|
-
Transforms.select(editor, newLocation);
|
295
|
-
}
|
296
|
-
}
|
297
|
-
return;
|
298
|
-
}
|
299
|
-
break;
|
300
|
-
default:
|
301
|
-
}
|
302
307
|
}
|
303
308
|
// Handle blockquote splitting
|
304
309
|
if (!e.shiftKey) {
|
@@ -7,43 +7,43 @@ export const sizeMap = {
|
|
7
7
|
export const fontFamilyMap = {
|
8
8
|
PoppinsRegular: "PoppinsRegular",
|
9
9
|
PoppinsBold: "PoppinsBold",
|
10
|
-
sans:
|
11
|
-
serif:
|
12
|
-
monospace:
|
13
|
-
roboto: "
|
14
|
-
qwitcher: "
|
15
|
-
garamond: "
|
16
|
-
anton: "
|
17
|
-
dmserif: "
|
18
|
-
inter: "
|
19
|
-
libre: "
|
20
|
-
montserrat: "
|
21
|
-
opensans: "
|
22
|
-
publicsans: "
|
23
|
-
raleway: "
|
24
|
-
spacemono: "
|
25
|
-
bulgarian: "
|
26
|
-
impact: "
|
27
|
-
redacted: "
|
28
|
-
greatVibes: "
|
29
|
-
zeyada: "
|
30
|
-
allura: "
|
31
|
-
pinyon: "
|
32
|
-
muellerhoff: "
|
33
|
-
dawning: "
|
10
|
+
sans: 'Helvetica, Arial, "sans serif"',
|
11
|
+
serif: 'Georgia, "Times New Roaman", serif',
|
12
|
+
monospace: 'Monaco, "Courier New", monospace',
|
13
|
+
roboto: "Roboto, sans-serif",
|
14
|
+
qwitcher: '"Qwitcher Grypen", cursive',
|
15
|
+
garamond: '"EB Garamond", serif',
|
16
|
+
anton: "Anton, sans-serif",
|
17
|
+
dmserif: '"DM Serif Text", serif',
|
18
|
+
inter: "Inter, sans-serif",
|
19
|
+
libre: '"Libre Baskerville", serif',
|
20
|
+
montserrat: "Montserrat, sans-serif",
|
21
|
+
opensans: '"Open Sans", sans-serif',
|
22
|
+
publicsans: '"Public Sans", sans-serif',
|
23
|
+
raleway: "Raleway, sans-serif",
|
24
|
+
spacemono: '"Space Mono", sans-serif',
|
25
|
+
bulgarian: '"Bulgarian Garamond", monospace',
|
26
|
+
impact: "Impact, serif",
|
27
|
+
redacted: '"Redacted Script", cursive',
|
28
|
+
greatVibes: '"Great Vibes", cursive',
|
29
|
+
zeyada: "Zeyada, cursive",
|
30
|
+
allura: "Allura, cursive",
|
31
|
+
pinyon: '"Pinyon Script", cursive',
|
32
|
+
muellerhoff: '"Herr Von Muellerhoff", cursive',
|
33
|
+
dawning: '"Dawning of a New Day", cursive',
|
34
34
|
// New Font Added for Type Signature
|
35
|
-
comingsoon: "
|
36
|
-
dancingScript: "
|
37
|
-
engagement: "
|
38
|
-
gaegu: "
|
39
|
-
ingridDarling: "
|
40
|
-
kitaOne: "
|
41
|
-
laBelleAurore: "
|
42
|
-
lobster: "
|
43
|
-
meaCulpa: "
|
44
|
-
meddon: "
|
45
|
-
merriWeather: "
|
46
|
-
theGirlNextDoor: "
|
35
|
+
comingsoon: '"Coming Soon", cursive',
|
36
|
+
dancingScript: '"Dancing Script", cursive',
|
37
|
+
engagement: "Engagement, cursive",
|
38
|
+
gaegu: "Gaegu, cursive",
|
39
|
+
ingridDarling: '"Ingrid Darling", cursive',
|
40
|
+
kitaOne: "Times",
|
41
|
+
laBelleAurore: '"La Belle Aurore", cursive',
|
42
|
+
lobster: "Lobster, cursive",
|
43
|
+
meaCulpa: '"Mea Culpa", cursive',
|
44
|
+
meddon: "Meddon, cursive",
|
45
|
+
merriWeather: "Merriweather, serif",
|
46
|
+
theGirlNextDoor: '"The Girl Next Door", cursive'
|
47
47
|
};
|
48
48
|
export const fontOptions = Object.keys(fontFamilyMap).map(m => {
|
49
49
|
return {
|
@@ -62,7 +62,10 @@ export const signedTextFonts = Object.keys(fontFamilyMap).slice(-12).map(m => {
|
|
62
62
|
export const headingMap = {
|
63
63
|
headingOne: "32px",
|
64
64
|
headingTwo: "24px",
|
65
|
-
headingThree: "19px"
|
65
|
+
headingThree: "19px",
|
66
|
+
headingFour: "16px",
|
67
|
+
headingFive: "13px",
|
68
|
+
headingSix: "11px"
|
66
69
|
};
|
67
70
|
export const fontWeightOptions = [{
|
68
71
|
text: "Bold",
|
@@ -2,6 +2,7 @@ import { Editor, Node, Transforms, Element, Path, Range, Text } from "slate";
|
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
3
|
import insertNewLine from "./insertNewLine";
|
4
4
|
import { getDevice } from "../helper/theme";
|
5
|
+
import { activeMark, getSelectedElementStyle } from "./SlateUtilityFunctions";
|
5
6
|
import { getCurrentElementText } from "../plugins/withHTML";
|
6
7
|
export const windowVar = {};
|
7
8
|
let ST_TIMEOUT = null;
|
@@ -217,9 +218,13 @@ export const handleInsertLastElement = (event, editor) => {
|
|
217
218
|
};
|
218
219
|
export const isListItem = editor => {
|
219
220
|
const format = ["list-item", "check-list-item", "accordion-summary", "headingOne", "headingTwo", "headingThree"];
|
220
|
-
const [
|
221
|
+
const [node1, node2] = Editor.nodes(editor, {
|
221
222
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && format.indexOf(n.type) > -1
|
222
223
|
});
|
224
|
+
let node = node1;
|
225
|
+
if (node2 && node2[0] && node2[0].type === "accordion-summary") {
|
226
|
+
node = node2;
|
227
|
+
}
|
223
228
|
return node;
|
224
229
|
};
|
225
230
|
export const getNode = (editor, path) => {
|
@@ -492,6 +497,34 @@ export const decodeString = str => {
|
|
492
497
|
console.log(err);
|
493
498
|
}
|
494
499
|
};
|
500
|
+
export const getContrastColor = color => {
|
501
|
+
let r, g, b;
|
502
|
+
|
503
|
+
// Check if the color is in hex format
|
504
|
+
if (color.startsWith("#")) {
|
505
|
+
r = parseInt(color.substring(1, 3), 16);
|
506
|
+
g = parseInt(color.substring(3, 5), 16);
|
507
|
+
b = parseInt(color.substring(5, 7), 16);
|
508
|
+
}
|
509
|
+
// Check if the color is in RGB/RGBA format
|
510
|
+
else if (color.startsWith("rgb")) {
|
511
|
+
const rgbValues = color.replace(/^rgba?\(|\s+|\)$/g, "") // Remove the rgb/rgba and spaces
|
512
|
+
.split(","); // Split the values into an array
|
513
|
+
|
514
|
+
r = parseInt(rgbValues[0]);
|
515
|
+
g = parseInt(rgbValues[1]);
|
516
|
+
b = parseInt(rgbValues[2]);
|
517
|
+
} else {
|
518
|
+
// If the format is not recognized, default to black text
|
519
|
+
return "#000000";
|
520
|
+
}
|
521
|
+
|
522
|
+
// Calculate relative luminance
|
523
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
524
|
+
|
525
|
+
// Return black for light colors, white for dark colors
|
526
|
+
return luminance > 0.5 ? "#000000" : "#FFFFFF";
|
527
|
+
};
|
495
528
|
export const onDeleteKey = (event, {
|
496
529
|
editor
|
497
530
|
}) => {
|
@@ -709,6 +742,10 @@ export const isRestrictedNode = (event, editor) => {
|
|
709
742
|
return isNodeRestricted;
|
710
743
|
}
|
711
744
|
};
|
745
|
+
export function capitalizeFirstLetter(str) {
|
746
|
+
if (!str) return str;
|
747
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
748
|
+
}
|
712
749
|
export const insertLineBreakAtEndOfPath = (editor, path) => {
|
713
750
|
try {
|
714
751
|
const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
|
@@ -727,6 +764,13 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
|
|
727
764
|
console.log(err);
|
728
765
|
}
|
729
766
|
};
|
767
|
+
export function isHavingSelection(editor) {
|
768
|
+
try {
|
769
|
+
return editor?.selection && !Range.isCollapsed(editor.selection);
|
770
|
+
} catch (err) {
|
771
|
+
console.log(err);
|
772
|
+
}
|
773
|
+
}
|
730
774
|
const omitNodes = ["site-settings", "page-settings"];
|
731
775
|
export function getInitialValue(value = [], readOnly) {
|
732
776
|
if (readOnly === "readonly" && value?.length) {
|
@@ -757,20 +801,17 @@ export function getInitialValue(value = [], readOnly) {
|
|
757
801
|
}
|
758
802
|
return value;
|
759
803
|
}
|
760
|
-
export function capitalizeFirstLetter(str) {
|
761
|
-
if (!str) return str;
|
762
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
763
|
-
}
|
764
|
-
export function isHavingSelection(editor) {
|
765
|
-
try {
|
766
|
-
return editor?.selection && !Range.isCollapsed(editor.selection);
|
767
|
-
} catch (err) {
|
768
|
-
console.log(err);
|
769
|
-
}
|
770
|
-
}
|
771
804
|
export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
|
772
805
|
return `${defaultCls} ${selected ? selectedClsName : ""}`;
|
773
806
|
}
|
807
|
+
export function handleNegativeInteger(val) {
|
808
|
+
return val < 0 ? 0 : val;
|
809
|
+
}
|
810
|
+
export const containsSurrogatePair = text => {
|
811
|
+
// Match surrogate pairs (high and low surrogate)
|
812
|
+
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
813
|
+
return surrogatePairRegex.test(text);
|
814
|
+
};
|
774
815
|
export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
775
816
|
try {
|
776
817
|
const options = {
|
@@ -784,11 +825,6 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
|
784
825
|
return [];
|
785
826
|
}
|
786
827
|
};
|
787
|
-
export const containsSurrogatePair = text => {
|
788
|
-
// Match surrogate pairs (high and low surrogate)
|
789
|
-
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
790
|
-
return surrogatePairRegex.test(text);
|
791
|
-
};
|
792
828
|
export const getSlateDom = (editor, range) => {
|
793
829
|
try {
|
794
830
|
const slateDom = ReactEditor.toDOMRange(editor, range);
|
@@ -829,7 +865,8 @@ export const clearWindowSelection = () => {
|
|
829
865
|
|
830
866
|
export const viewSlateSelection = () => {
|
831
867
|
// if ai is opened, remove the window selection class and open then slate selection, To resolve: focussing on the ai input removes window selection automatically
|
832
|
-
clearWindowSelection();
|
868
|
+
// clearWindowSelection();
|
869
|
+
|
833
870
|
const selectionBg = "rgba(35, 131, 226, 0.35)";
|
834
871
|
const root = document.documentElement;
|
835
872
|
root.style.setProperty("--slate-highlight-bg", selectionBg);
|
@@ -838,9 +875,6 @@ export const hideSlateSelection = () => {
|
|
838
875
|
const root = document.documentElement;
|
839
876
|
root.style.setProperty("--slate-highlight-bg", "none");
|
840
877
|
};
|
841
|
-
export function handleNegativeInteger(val) {
|
842
|
-
return val < 0 ? 0 : val;
|
843
|
-
}
|
844
878
|
export const insertSlashNode = (editor, insertNode) => {
|
845
879
|
try {
|
846
880
|
// Delete the currently selected text
|
@@ -889,6 +923,48 @@ export const getCurrentNodeText = editor => {
|
|
889
923
|
console.log("Error:", error);
|
890
924
|
}
|
891
925
|
};
|
926
|
+
function convertColorToRgb(color) {
|
927
|
+
if (color?.startsWith("#")) {
|
928
|
+
// HEX to RGB
|
929
|
+
let hex = color.replace("#", "");
|
930
|
+
let r, g, b;
|
931
|
+
if (hex.length === 3) {
|
932
|
+
hex = hex.split("").map(x => x + x).join("");
|
933
|
+
}
|
934
|
+
if (hex.length === 6) {
|
935
|
+
[r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
|
936
|
+
return `rgb(${r}, ${g}, ${b})`;
|
937
|
+
}
|
938
|
+
} else {
|
939
|
+
return color;
|
940
|
+
}
|
941
|
+
}
|
942
|
+
export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
|
943
|
+
const colorVars = hideThemeColors ? null : theme?.vars?.colors;
|
944
|
+
let selectedValue = selectedColor;
|
945
|
+
if (colorVars) {
|
946
|
+
const convertedColor = convertColorToRgb(selectedColor);
|
947
|
+
Object.entries(theme.colors).forEach(([key, value]) => {
|
948
|
+
const convertedThemeColor = convertColorToRgb(value);
|
949
|
+
if (convertedThemeColor === convertedColor) {
|
950
|
+
selectedValue = colorVars[key];
|
951
|
+
}
|
952
|
+
});
|
953
|
+
}
|
954
|
+
return selectedValue;
|
955
|
+
};
|
956
|
+
const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
957
|
+
export const getSelectedElementColor = (editor, format, theme) => {
|
958
|
+
const [isThemeText] = Editor.nodes(editor, {
|
959
|
+
at: editor.selection,
|
960
|
+
match: n => themeTextFormats.includes(n?.type)
|
961
|
+
});
|
962
|
+
if (!isThemeText) {
|
963
|
+
return activeMark(editor, "color") || "#000000";
|
964
|
+
}
|
965
|
+
const color = getSelectedElementStyle(format, editor, format);
|
966
|
+
return getSelectedColor(color, theme);
|
967
|
+
};
|
892
968
|
export const isHavingColor = color => {
|
893
969
|
if (!color) {
|
894
970
|
return false;
|