@flozy/editor 3.9.9 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +28 -17
- package/dist/Editor/CommonEditor.js +109 -177
- package/dist/Editor/Editor.css +12 -8
- package/dist/Editor/Elements/AI/AIInput.js +24 -18
- package/dist/Editor/Elements/AI/CustomSelect.js +12 -19
- package/dist/Editor/Elements/AI/PopoverAIInput.js +89 -66
- package/dist/Editor/Elements/AI/Styles.js +1 -2
- package/dist/Editor/Elements/AI/helper.js +3 -5
- package/dist/Editor/Elements/Accordion/Accordion.js +1 -1
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +21 -5
- package/dist/Editor/Elements/AppHeader/AppHeader.js +4 -26
- package/dist/Editor/Elements/Button/EditorButton.js +16 -28
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +17 -60
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
- package/dist/Editor/Elements/Color Picker/Styles.js +1 -2
- package/dist/Editor/Elements/Emoji/EmojiPicker.js +4 -2
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +3 -12
- package/dist/Editor/Elements/Form/Workflow/UserInputs.js +1 -2
- package/dist/Editor/Elements/Grid/Grid.js +3 -27
- package/dist/Editor/Elements/Grid/GridItem.js +1 -3
- package/dist/Editor/Elements/Link/Link.js +1 -6
- package/dist/Editor/Elements/Link/LinkButton.js +2 -4
- package/dist/Editor/Elements/Link/LinkPopup.js +3 -10
- package/dist/Editor/Elements/List/CheckList.js +2 -1
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +3 -3
- package/dist/Editor/Elements/Signature/SignaturePopup.js +5 -20
- package/dist/Editor/Elements/Table/Styles.js +1 -23
- package/dist/Editor/Elements/Table/Table.js +1 -2
- package/dist/Editor/Elements/Table/TableCell.js +7 -69
- package/dist/Editor/Elements/TableContextMenu/TableContextMenu.js +0 -1
- package/dist/Editor/MiniEditor.js +1 -3
- package/dist/Editor/Styles/EditorStyles.js +1 -1
- package/dist/Editor/Toolbar/Basic/index.js +2 -4
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +2 -26
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +18 -29
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -4
- package/dist/Editor/Toolbar/Mini/Options/Options.js +0 -10
- package/dist/Editor/Toolbar/Mini/Styles.js +0 -7
- package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +13 -12
- package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +13 -12
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +11 -4
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +86 -213
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +33 -40
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +7 -52
- package/dist/Editor/Toolbar/PopupTool/index.js +5 -4
- package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
- package/dist/Editor/assets/svg/AIIcons.js +1 -153
- package/dist/Editor/assets/svg/AddTemplateIcon.js +10 -13
- package/dist/Editor/assets/svg/TextIcon.js +5 -8
- package/dist/Editor/common/ColorPickerButton.js +18 -26
- package/dist/Editor/common/DnD/DragHandleButton.js +47 -56
- package/dist/Editor/common/Icon.js +3 -43
- package/dist/Editor/common/LinkSettings/NavComponents.js +2 -5
- package/dist/Editor/common/LinkSettings/index.js +2 -4
- package/dist/Editor/common/LinkSettings/navOptions.js +2 -7
- package/dist/Editor/common/LinkSettings/style.js +8 -11
- package/dist/Editor/common/Section/index.js +7 -57
- package/dist/Editor/common/Section/styles.js +0 -11
- package/dist/Editor/common/Shorthands/elements.js +0 -54
- package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +2 -1
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +29 -33
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +25 -31
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +1 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +7 -29
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +4 -13
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +4 -14
- package/dist/Editor/common/StyleBuilder/index.js +1 -1
- package/dist/Editor/common/iconslist.js +31 -0
- package/dist/Editor/helper/index.js +22 -0
- package/dist/Editor/helper/theme.js +4 -189
- package/dist/Editor/hooks/useMouseMove.js +1 -4
- package/dist/Editor/hooks/useWindowMessage.js +7 -10
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +1 -1
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/theme/ThemeList.js +173 -50
- package/dist/Editor/utils/SlateUtilityFunctions.js +27 -169
- package/dist/Editor/utils/button.js +17 -1
- package/dist/Editor/utils/events.js +2 -54
- package/dist/Editor/utils/font.js +37 -40
- package/dist/Editor/utils/helper.js +2 -31
- package/dist/Editor/utils/table.js +43 -51
- package/package.json +3 -4
- package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +0 -73
- package/dist/Editor/Elements/AI/VoiceToText/index.js +0 -184
- package/dist/Editor/Elements/AI/VoiceToText/style.js +0 -40
- package/dist/Editor/Elements/Link/LinkPopupStyles.js +0 -28
- package/dist/Editor/Elements/Redo/RedoButton.js +0 -14
- package/dist/Editor/Elements/Undo/UndoButton.js +0 -14
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -438
- package/dist/Editor/assets/svg/RedoIcon.js +0 -27
- package/dist/Editor/assets/svg/SettingsIcon.js +0 -28
- package/dist/Editor/assets/svg/ThemeIcons.js +0 -291
- package/dist/Editor/assets/svg/UndoIcon.js +0 -27
- package/dist/Editor/common/CustomColorPicker/index.js +0 -106
- package/dist/Editor/common/CustomColorPicker/style.js +0 -53
- package/dist/Editor/common/CustomDialog/index.js +0 -94
- package/dist/Editor/common/CustomDialog/style.js +0 -67
- package/dist/Editor/common/CustomSelect.js +0 -33
- package/dist/Editor/hooks/useEditorTheme.js +0 -139
- package/dist/Editor/theme/index.js +0 -144
- package/dist/Editor/themeSettings/ActiveTheme.js +0 -72
- package/dist/Editor/themeSettings/buttons/index.js +0 -290
- package/dist/Editor/themeSettings/buttons/style.js +0 -21
- package/dist/Editor/themeSettings/colorTheme/index.js +0 -290
- package/dist/Editor/themeSettings/colorTheme/style.js +0 -77
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -123
- package/dist/Editor/themeSettings/fonts/index.js +0 -213
- package/dist/Editor/themeSettings/fonts/style.js +0 -44
- package/dist/Editor/themeSettings/icons.js +0 -60
- package/dist/Editor/themeSettings/index.js +0 -320
- package/dist/Editor/themeSettings/style.js +0 -152
- package/dist/Editor/themeSettingsAI/icons.js +0 -96
- package/dist/Editor/themeSettingsAI/index.js +0 -356
- package/dist/Editor/themeSettingsAI/saveTheme.js +0 -190
- package/dist/Editor/themeSettingsAI/style.js +0 -247
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, Transforms, Element as SlateElement
|
1
|
+
import { Editor, Transforms, Element as SlateElement } from "slate";
|
2
2
|
import { Box } from "@mui/material";
|
3
3
|
import { fontFamilyMap, sizeMap } from "./font";
|
4
4
|
import Link from "../Elements/Link/Link";
|
@@ -32,14 +32,14 @@ import FormField from "../Elements/Form/FormField";
|
|
32
32
|
import InlineIcon from "../Elements/InlineIcon/InlineIcon";
|
33
33
|
import SimpleText from "../Elements/SimpleText";
|
34
34
|
import CheckList from "../Elements/List/CheckList";
|
35
|
-
import { isEmptyTextNode } from "../helper";
|
35
|
+
import { getTextColor, isEmptyTextNode } from "../helper";
|
36
36
|
import Attachments from "../Elements/Attachments/Attachments";
|
37
|
-
import { getBreakPointsValue
|
37
|
+
import { getBreakPointsValue } from "../helper/theme";
|
38
38
|
import Variables from "../Elements/Variables/Variable";
|
39
|
+
import insertNewLine from "./insertNewLine";
|
39
40
|
import Divider from "../Elements/Divider/Divider";
|
40
41
|
import { getBorderColor } from "./helper";
|
41
42
|
import Code from "../Elements/EmbedScript/Code";
|
42
|
-
import { ReactEditor } from "slate-react";
|
43
43
|
import { jsx as _jsx } from "react/jsx-runtime";
|
44
44
|
const alignment = ["alignLeft", "alignRight", "alignCenter"];
|
45
45
|
const list_types = ["orderedList", "unorderedList"];
|
@@ -47,17 +47,7 @@ const LIST_FORMAT_TYPE = {
|
|
47
47
|
orderedList: "list-item",
|
48
48
|
unorderedList: "list-item"
|
49
49
|
};
|
50
|
-
|
51
|
-
// const NEWLINESAFTER = [
|
52
|
-
// "headingOne",
|
53
|
-
// "headingTwo",
|
54
|
-
// "headingThree",
|
55
|
-
// "headingFour",
|
56
|
-
// "headingFive",
|
57
|
-
// "headingSix",
|
58
|
-
// ];
|
59
|
-
|
60
|
-
const THEME_BLOCK_FIELDS = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
50
|
+
const NEWLINESAFTER = ["headingOne", "headingTwo", "headingThree"];
|
61
51
|
export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
62
52
|
const isActive = isBlockActive(editor, format);
|
63
53
|
const isList = list_types.includes(format);
|
@@ -90,9 +80,8 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
90
80
|
if (!selection) {
|
91
81
|
Transforms.insertText(editor, "");
|
92
82
|
}
|
93
|
-
const forActiveType = THEME_BLOCK_FIELDS.some(f => f === format) ? format : "paragraph";
|
94
83
|
Transforms.setNodes(editor, {
|
95
|
-
type: isActive ?
|
84
|
+
type: isActive ? "paragraph" : isList ? LIST_FORMAT_TYPE[format] : format,
|
96
85
|
...attr
|
97
86
|
});
|
98
87
|
if (isList && !isActive) {
|
@@ -101,12 +90,10 @@ export const toggleBlock = (editor, format, selection = true, attr = {}) => {
|
|
101
90
|
children: []
|
102
91
|
});
|
103
92
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
// }
|
93
|
+
if (NEWLINESAFTER.indexOf(format) > -1) {
|
94
|
+
insertNewLine(editor);
|
95
|
+
}
|
108
96
|
};
|
109
|
-
|
110
97
|
export const addMarkData = (editor, data) => {
|
111
98
|
try {
|
112
99
|
Editor.addMark(editor, data.format, data.value);
|
@@ -115,14 +102,9 @@ export const addMarkData = (editor, data) => {
|
|
115
102
|
}
|
116
103
|
};
|
117
104
|
export const toggleMark = (editor, format) => {
|
118
|
-
const isActive =
|
105
|
+
const isActive = isMarkActive(editor, format);
|
119
106
|
if (isActive) {
|
120
|
-
|
121
|
-
if (isThemeSupportedMark) {
|
122
|
-
Editor.addMark(editor, format, false);
|
123
|
-
} else {
|
124
|
-
Editor.removeMark(editor, format);
|
125
|
-
}
|
107
|
+
Editor.removeMark(editor, format);
|
126
108
|
} else {
|
127
109
|
Editor.addMark(editor, format, true);
|
128
110
|
}
|
@@ -136,53 +118,6 @@ export const isMarkActive = (editor, format) => {
|
|
136
118
|
return null;
|
137
119
|
}
|
138
120
|
};
|
139
|
-
export const isMarkBtnActive = (editor, format) => {
|
140
|
-
switch (format) {
|
141
|
-
case "bold":
|
142
|
-
{
|
143
|
-
const style = getSelectedElementStyle("font-weight", editor);
|
144
|
-
return style === "700";
|
145
|
-
}
|
146
|
-
case "italic":
|
147
|
-
{
|
148
|
-
const style = getSelectedElementStyle("font-style", editor);
|
149
|
-
return style === format;
|
150
|
-
}
|
151
|
-
// case "underline": {
|
152
|
-
// const style = getSelectedElementStyle("text-decoration");
|
153
|
-
|
154
|
-
// return style?.includes(format);
|
155
|
-
// }
|
156
|
-
// case "strikethrough": {
|
157
|
-
// const style = getSelectedElementStyle("text-decoration");
|
158
|
-
|
159
|
-
// return style?.includes("line-through");
|
160
|
-
// }
|
161
|
-
default:
|
162
|
-
return isMarkActive(editor, format);
|
163
|
-
}
|
164
|
-
};
|
165
|
-
export const getSelectedElementStyle = (styleProperty, editor) => {
|
166
|
-
try {
|
167
|
-
if (!editor.selection) {
|
168
|
-
return "";
|
169
|
-
}
|
170
|
-
if (Range.isCollapsed(editor.selection)) {
|
171
|
-
return "";
|
172
|
-
}
|
173
|
-
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
174
|
-
const selectedDomNode = domRange.commonAncestorContainer;
|
175
|
-
|
176
|
-
// If it's a text node, get its parent element
|
177
|
-
const selectedElement = selectedDomNode.nodeType === 3 ? selectedDomNode.parentElement : selectedDomNode;
|
178
|
-
if (selectedElement) {
|
179
|
-
const computedStyle = window.getComputedStyle(selectedElement);
|
180
|
-
return computedStyle.getPropertyValue(styleProperty) || "";
|
181
|
-
}
|
182
|
-
} catch (err) {
|
183
|
-
console.log(err);
|
184
|
-
}
|
185
|
-
};
|
186
121
|
export const isBlockActive = (editor, format) => {
|
187
122
|
const [match] = Editor.nodes(editor, {
|
188
123
|
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === format
|
@@ -225,31 +160,6 @@ export const activeMark = (editor, format) => {
|
|
225
160
|
return null;
|
226
161
|
}
|
227
162
|
};
|
228
|
-
|
229
|
-
// to avoid the styles, that automatically assign from themes
|
230
|
-
const getThemeMarkedLeaf = (leaf, children) => {
|
231
|
-
const {
|
232
|
-
italic,
|
233
|
-
bold
|
234
|
-
} = leaf || {};
|
235
|
-
const style = {};
|
236
|
-
if (italic === false) {
|
237
|
-
style.fontStyle = "normal";
|
238
|
-
}
|
239
|
-
if (bold === false) {
|
240
|
-
style.fontWeight = "normal";
|
241
|
-
}
|
242
|
-
if (Object.keys(style).length) {
|
243
|
-
children = /*#__PURE__*/_jsx(Box, {
|
244
|
-
component: "span",
|
245
|
-
sx: {
|
246
|
-
"& span": style
|
247
|
-
},
|
248
|
-
children: children
|
249
|
-
});
|
250
|
-
}
|
251
|
-
return children;
|
252
|
-
};
|
253
163
|
export const getMarked = (leaf, children) => {
|
254
164
|
const className = leaf?.doublequote ? "doublequote" : "";
|
255
165
|
if (leaf.bold) {
|
@@ -267,7 +177,6 @@ export const getMarked = (leaf, children) => {
|
|
267
177
|
children: children
|
268
178
|
});
|
269
179
|
}
|
270
|
-
children = getThemeMarkedLeaf(leaf, children);
|
271
180
|
if (leaf.strikethrough) {
|
272
181
|
children = /*#__PURE__*/_jsx("span", {
|
273
182
|
style: {
|
@@ -294,29 +203,18 @@ export const getMarked = (leaf, children) => {
|
|
294
203
|
// cover under single span
|
295
204
|
if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || className) {
|
296
205
|
const family = fontFamilyMap[leaf?.fontFamily];
|
297
|
-
const textStyles = leaf?.color
|
298
|
-
background: leaf?.color?.concat("text"),
|
299
|
-
WebkitBackgroundClip: "text",
|
300
|
-
WebkitTextFillColor: "transparent"
|
301
|
-
} : {
|
302
|
-
color: leaf.color
|
303
|
-
};
|
304
|
-
const fontSize = {
|
305
|
-
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
306
|
-
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
307
|
-
};
|
308
|
-
const fontSizesImportant = {};
|
309
|
-
Object.entries(fontSize).forEach(([key, value]) => {
|
310
|
-
fontSizesImportant[key] = `${value} !important`;
|
311
|
-
});
|
206
|
+
const textStyles = getTextColor(leaf?.color);
|
312
207
|
children = /*#__PURE__*/_jsx("span", {
|
208
|
+
style: {
|
209
|
+
background: leaf.bgColor
|
210
|
+
},
|
313
211
|
children: /*#__PURE__*/_jsx(Box, {
|
314
212
|
className: className,
|
315
213
|
component: "span",
|
316
214
|
sx: {
|
317
|
-
|
318
|
-
|
319
|
-
|
215
|
+
fontSize: {
|
216
|
+
lg: sizeMap[leaf.fontSize] || leaf.fontSize,
|
217
|
+
...getBreakPointsValue(leaf.fontSize, null, "overrideText")
|
320
218
|
},
|
321
219
|
...textStyles,
|
322
220
|
fontFamily: family,
|
@@ -346,71 +244,31 @@ export const getBlock = props => {
|
|
346
244
|
} = props;
|
347
245
|
const attributes = props.attributes ?? {};
|
348
246
|
const isEmpty = isEmptyTextNode(element);
|
349
|
-
const commonHeadingProps = () => ({
|
350
|
-
...attributes,
|
351
|
-
...element.attr,
|
352
|
-
className: `content-editable ${isEmpty ? "empty" : ""} theme-element`
|
353
|
-
});
|
354
|
-
const commonParaProps = paraType => ({
|
355
|
-
...attributes,
|
356
|
-
...element.attr,
|
357
|
-
className: `content-editable ${isEmpty ? "empty" : ""} theme-element ${paraType}`
|
358
|
-
});
|
359
247
|
switch (element.type) {
|
360
248
|
case "headingOne":
|
361
249
|
return /*#__PURE__*/_jsx("h1", {
|
362
|
-
...
|
250
|
+
...attributes,
|
251
|
+
...element.attr,
|
252
|
+
className: `content-editable ${isEmpty ? "empty" : ""}`,
|
363
253
|
placeholder: "Heading 1",
|
364
254
|
children: children
|
365
255
|
});
|
366
256
|
case "headingTwo":
|
367
257
|
return /*#__PURE__*/_jsx("h2", {
|
368
|
-
...
|
258
|
+
...attributes,
|
259
|
+
...element.attr,
|
260
|
+
className: `content-editable ${isEmpty ? "empty" : ""}`,
|
369
261
|
placeholder: "Heading 2",
|
370
262
|
children: children
|
371
263
|
});
|
372
264
|
case "headingThree":
|
373
265
|
return /*#__PURE__*/_jsx("h3", {
|
374
|
-
...
|
266
|
+
...attributes,
|
267
|
+
...element.attr,
|
268
|
+
className: `content-editable ${isEmpty ? "empty" : ""}`,
|
375
269
|
placeholder: "Heading 3",
|
376
270
|
children: children
|
377
271
|
});
|
378
|
-
case "headingFour":
|
379
|
-
return /*#__PURE__*/_jsx("h4", {
|
380
|
-
...commonHeadingProps(),
|
381
|
-
placeholder: "Heading 4",
|
382
|
-
children: children
|
383
|
-
});
|
384
|
-
case "headingFive":
|
385
|
-
return /*#__PURE__*/_jsx("h5", {
|
386
|
-
...commonHeadingProps(),
|
387
|
-
placeholder: "Heading 5",
|
388
|
-
children: children
|
389
|
-
});
|
390
|
-
case "headingSix":
|
391
|
-
return /*#__PURE__*/_jsx("h6", {
|
392
|
-
...commonHeadingProps(),
|
393
|
-
placeholder: "Heading 6",
|
394
|
-
children: children
|
395
|
-
});
|
396
|
-
case "paragraphOne":
|
397
|
-
return /*#__PURE__*/_jsx("p", {
|
398
|
-
...commonParaProps("para1"),
|
399
|
-
placeholder: "Paragraph 1",
|
400
|
-
children: children
|
401
|
-
});
|
402
|
-
case "paragraphTwo":
|
403
|
-
return /*#__PURE__*/_jsx("p", {
|
404
|
-
...commonParaProps("para2"),
|
405
|
-
placeholder: "Paragraph 2",
|
406
|
-
children: children
|
407
|
-
});
|
408
|
-
case "paragraphThree":
|
409
|
-
return /*#__PURE__*/_jsx("p", {
|
410
|
-
...commonParaProps("para3"),
|
411
|
-
placeholder: "Paragraph 3",
|
412
|
-
children: children
|
413
|
-
});
|
414
272
|
case "blockquote":
|
415
273
|
return /*#__PURE__*/_jsx("blockquote", {
|
416
274
|
...attributes,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Transforms } from "slate";
|
2
2
|
import insertNewLine from "./insertNewLine";
|
3
|
+
import { windowVar } from "./helper";
|
3
4
|
export const insertButton = editor => {
|
4
5
|
const button = {
|
5
6
|
type: "button",
|
@@ -9,7 +10,22 @@ export const insertButton = editor => {
|
|
9
10
|
buttonLink: {
|
10
11
|
linkType: "webAddress"
|
11
12
|
},
|
12
|
-
iconPosition: "start"
|
13
|
+
iconPosition: "start",
|
14
|
+
bgColor: "#2563EB",
|
15
|
+
textColor: "#FFF",
|
16
|
+
borderRadius: {
|
17
|
+
topLeft: 30,
|
18
|
+
topRight: 30,
|
19
|
+
bottomLeft: 30,
|
20
|
+
bottomRight: 30
|
21
|
+
},
|
22
|
+
bannerSpacing: {
|
23
|
+
left: 16,
|
24
|
+
top: 8,
|
25
|
+
right: 16,
|
26
|
+
bottom: 8
|
27
|
+
},
|
28
|
+
...(windowVar.lastButtonProps || {})
|
13
29
|
};
|
14
30
|
Transforms.insertNodes(editor, button);
|
15
31
|
Transforms.move(editor);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, Transforms, Element, Node, Path
|
1
|
+
import { Editor, Transforms, Element, Node, Path } from "slate";
|
2
2
|
import { toggleBlock } from "./SlateUtilityFunctions";
|
3
3
|
import insertNewLine from "./insertNewLine";
|
4
4
|
import { insertAccordion } from "./accordion";
|
@@ -179,6 +179,7 @@ const checkListEnterEvent = (editor, type) => {
|
|
179
179
|
export const enterEvent = (e, editor, isMobile) => {
|
180
180
|
try {
|
181
181
|
const ele = isListItem(editor);
|
182
|
+
|
182
183
|
// on shift enter break line in same node
|
183
184
|
if (e.shiftKey && !isMobile) {
|
184
185
|
e.preventDefault();
|
@@ -187,7 +188,6 @@ export const enterEvent = (e, editor, isMobile) => {
|
|
187
188
|
const {
|
188
189
|
type
|
189
190
|
} = ele[0];
|
190
|
-
const path = ele[1];
|
191
191
|
const text = Node.string(ele[0]);
|
192
192
|
switch (type) {
|
193
193
|
case "list-item":
|
@@ -219,58 +219,6 @@ export const enterEvent = (e, editor, isMobile) => {
|
|
219
219
|
insertAccordion(editor, nextPath);
|
220
220
|
}
|
221
221
|
break;
|
222
|
-
case "headingOne":
|
223
|
-
case "headingTwo":
|
224
|
-
case "headingThree":
|
225
|
-
const {
|
226
|
-
selection
|
227
|
-
} = editor;
|
228
|
-
if (selection && Range.isCollapsed(selection)) {
|
229
|
-
const isAtEnd = Editor.isEnd(editor, selection.anchor, path);
|
230
|
-
const isAtStart = Editor.isStart(editor, selection.anchor, path);
|
231
|
-
if (isAtEnd) {
|
232
|
-
e.preventDefault();
|
233
|
-
Transforms.insertNodes(editor, {
|
234
|
-
type: 'paragraph',
|
235
|
-
children: [{
|
236
|
-
text: ''
|
237
|
-
}]
|
238
|
-
});
|
239
|
-
const newLocation = Editor.after(editor, selection);
|
240
|
-
if (newLocation) {
|
241
|
-
Transforms.select(editor, newLocation);
|
242
|
-
}
|
243
|
-
} else if (!isAtStart) {
|
244
|
-
e.preventDefault();
|
245
|
-
Transforms.splitNodes(editor);
|
246
|
-
Transforms.setNodes(editor, {
|
247
|
-
type: 'paragraph'
|
248
|
-
}, {
|
249
|
-
at: Editor.after(editor, selection)
|
250
|
-
});
|
251
|
-
const newLocation = Editor.after(editor, selection);
|
252
|
-
if (newLocation) {
|
253
|
-
Transforms.select(editor, newLocation);
|
254
|
-
}
|
255
|
-
} else if (isAtStart) {
|
256
|
-
e.preventDefault();
|
257
|
-
Transforms.insertNodes(editor, {
|
258
|
-
type: 'paragraph',
|
259
|
-
children: [{
|
260
|
-
text: ''
|
261
|
-
}]
|
262
|
-
}, {
|
263
|
-
at: Editor.before(editor, selection)
|
264
|
-
});
|
265
|
-
Transforms.select(editor, Editor.before(editor, selection));
|
266
|
-
const newLocation = Editor.before(editor, selection);
|
267
|
-
if (newLocation) {
|
268
|
-
Transforms.select(editor, newLocation);
|
269
|
-
}
|
270
|
-
}
|
271
|
-
return;
|
272
|
-
}
|
273
|
-
break;
|
274
222
|
default:
|
275
223
|
}
|
276
224
|
}
|
@@ -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: "Roboto, sans-serif",
|
14
|
-
qwitcher: '
|
15
|
-
garamond: '
|
16
|
-
anton: "Anton, sans-serif",
|
17
|
-
dmserif: '
|
18
|
-
inter: "Inter, sans-serif",
|
19
|
-
libre: '
|
20
|
-
montserrat: "Montserrat, sans-serif",
|
21
|
-
opensans: '
|
22
|
-
publicsans: '
|
23
|
-
raleway: "Raleway, sans-serif",
|
24
|
-
spacemono: '
|
25
|
-
bulgarian: '
|
26
|
-
impact: "Impact, serif",
|
27
|
-
redacted: '
|
28
|
-
greatVibes: '
|
29
|
-
zeyada: "Zeyada, cursive",
|
30
|
-
allura: "Allura, cursive",
|
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: "Engagement, cursive",
|
38
|
-
gaegu: "Gaegu, cursive",
|
39
|
-
ingridDarling: '
|
40
|
-
kitaOne: "
|
41
|
-
laBelleAurore: '
|
42
|
-
lobster: "Lobster, cursive",
|
43
|
-
meaCulpa: '
|
44
|
-
meddon: "Meddon, cursive",
|
45
|
-
merriWeather: "Merriweather, serif",
|
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: "'Kite One', sans - serif",
|
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,8 +62,5 @@ 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"
|
66
|
-
"headingFour": "16px",
|
67
|
-
"headingFive": "13px",
|
68
|
-
"headingSix": "11px"
|
65
|
+
"headingThree": "19px"
|
69
66
|
};
|
@@ -146,7 +146,7 @@ export const handleInsertLastElement = (event, editor) => {
|
|
146
146
|
}
|
147
147
|
};
|
148
148
|
export const isListItem = editor => {
|
149
|
-
const format = ["list-item", "check-list-item", "accordion-summary"
|
149
|
+
const format = ["list-item", "check-list-item", "accordion-summary"];
|
150
150
|
const [node] = Editor.nodes(editor, {
|
151
151
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && format.indexOf(n.type) > -1
|
152
152
|
});
|
@@ -246,8 +246,7 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
|
|
246
246
|
props.target = "_blank";
|
247
247
|
}
|
248
248
|
break;
|
249
|
-
case "
|
250
|
-
case "prevTrigger":
|
249
|
+
case "actionTrigger":
|
251
250
|
if (!readOnly) {
|
252
251
|
props.component = "button";
|
253
252
|
props.onClick = () => {};
|
@@ -379,34 +378,6 @@ export const decodeString = str => {
|
|
379
378
|
console.log(err);
|
380
379
|
}
|
381
380
|
};
|
382
|
-
export const getContrastColor = color => {
|
383
|
-
let r, g, b;
|
384
|
-
|
385
|
-
// Check if the color is in hex format
|
386
|
-
if (color.startsWith("#")) {
|
387
|
-
r = parseInt(color.substring(1, 3), 16);
|
388
|
-
g = parseInt(color.substring(3, 5), 16);
|
389
|
-
b = parseInt(color.substring(5, 7), 16);
|
390
|
-
}
|
391
|
-
// Check if the color is in RGB/RGBA format
|
392
|
-
else if (color.startsWith("rgb")) {
|
393
|
-
const rgbValues = color.replace(/^rgba?\(|\s+|\)$/g, "") // Remove the rgb/rgba and spaces
|
394
|
-
.split(","); // Split the values into an array
|
395
|
-
|
396
|
-
r = parseInt(rgbValues[0]);
|
397
|
-
g = parseInt(rgbValues[1]);
|
398
|
-
b = parseInt(rgbValues[2]);
|
399
|
-
} else {
|
400
|
-
// If the format is not recognized, default to black text
|
401
|
-
return "#000000";
|
402
|
-
}
|
403
|
-
|
404
|
-
// Calculate relative luminance
|
405
|
-
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
406
|
-
|
407
|
-
// Return black for light colors, white for dark colors
|
408
|
-
return luminance > 0.5 ? "#000000" : "#FFFFFF";
|
409
|
-
};
|
410
381
|
export const onDeleteKey = (event, {
|
411
382
|
editor
|
412
383
|
}) => {
|
@@ -95,32 +95,28 @@ export class TableUtil {
|
|
95
95
|
}
|
96
96
|
};
|
97
97
|
deleteRow = () => {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
98
|
+
const {
|
99
|
+
selection
|
100
|
+
} = this.editor;
|
101
|
+
if (!!selection && Range.isCollapsed(selection)) {
|
102
|
+
const [tableNode] = Editor.nodes(this.editor, {
|
103
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-row"
|
104
|
+
});
|
105
|
+
if (tableNode) {
|
106
|
+
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
107
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
108
|
+
});
|
109
|
+
const [, currentRow] = tableNode;
|
110
|
+
const path = currentRow;
|
111
|
+
Transforms.removeNodes(this.editor, {
|
112
|
+
at: path
|
113
|
+
});
|
114
|
+
Transforms.setNodes(this.editor, {
|
115
|
+
rows: table.rows - 1
|
116
|
+
}, {
|
117
|
+
at: tablePath
|
105
118
|
});
|
106
|
-
if (tableNode) {
|
107
|
-
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
108
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
109
|
-
});
|
110
|
-
const [, currentRow] = tableNode;
|
111
|
-
const path = currentRow;
|
112
|
-
Transforms.removeNodes(this.editor, {
|
113
|
-
at: path
|
114
|
-
});
|
115
|
-
Transforms.setNodes(this.editor, {
|
116
|
-
rows: table.rows - 1
|
117
|
-
}, {
|
118
|
-
at: tablePath
|
119
|
-
});
|
120
|
-
}
|
121
119
|
}
|
122
|
-
} catch (error) {
|
123
|
-
console.log("Error", error);
|
124
120
|
}
|
125
121
|
};
|
126
122
|
insertColumn = action => {
|
@@ -155,38 +151,34 @@ export class TableUtil {
|
|
155
151
|
}
|
156
152
|
};
|
157
153
|
deleteColumn = () => {
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
154
|
+
const {
|
155
|
+
selection
|
156
|
+
} = this.editor;
|
157
|
+
if (!!selection && Range.isCollapsed(selection)) {
|
158
|
+
const [tableNode] = Editor.nodes(this.editor, {
|
159
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
|
160
|
+
});
|
161
|
+
if (tableNode) {
|
162
|
+
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
163
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
165
164
|
});
|
166
|
-
|
167
|
-
|
168
|
-
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
169
|
-
});
|
170
|
-
const [, currentCell] = tableNode;
|
171
|
-
const startPath = currentCell;
|
165
|
+
const [, currentCell] = tableNode;
|
166
|
+
const startPath = currentCell;
|
172
167
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
});
|
179
|
-
startPath[startPath.length - 2]++;
|
180
|
-
}
|
181
|
-
Transforms.setNodes(this.editor, {
|
182
|
-
columns: table.columns - 1
|
183
|
-
}, {
|
184
|
-
at: tablePath
|
168
|
+
// The last two indices of the path represents the row and column. We need to add one cell to each row starting from the first row
|
169
|
+
startPath[startPath.length - 2] = 0;
|
170
|
+
for (let row = 0; row < table.rows; row++) {
|
171
|
+
Transforms.removeNodes(this.editor, {
|
172
|
+
at: startPath
|
185
173
|
});
|
174
|
+
startPath[startPath.length - 2]++;
|
186
175
|
}
|
176
|
+
Transforms.setNodes(this.editor, {
|
177
|
+
columns: table.columns - 1
|
178
|
+
}, {
|
179
|
+
at: tablePath
|
180
|
+
});
|
187
181
|
}
|
188
|
-
} catch (error) {
|
189
|
-
console.log("Error ", error);
|
190
182
|
}
|
191
183
|
};
|
192
184
|
updateTableStyle = (styleProps, paths) => {
|