@flozy/editor 10.3.0 → 10.3.1
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 +16 -17
- package/dist/Editor/CommonEditor.js +14 -128
- package/dist/Editor/DialogWrapper.js +25 -31
- package/dist/Editor/Editor.css +8 -46
- package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -11
- package/dist/Editor/Elements/Accordion/Accordion.js +7 -30
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +23 -1
- package/dist/Editor/Elements/AppHeader/AppHeader.js +5 -10
- package/dist/Editor/Elements/Button/EditorButton.js +9 -27
- package/dist/Editor/Elements/Carousel/CarouselItem.js +1 -2
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -61
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +7 -10
- package/dist/Editor/Elements/Color Picker/Styles.js +13 -15
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +2 -4
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +28 -30
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +7 -9
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +1 -0
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +4 -8
- package/dist/Editor/Elements/Embed/Video.js +1 -1
- package/dist/Editor/Elements/Form/Form.js +3 -1
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -0
- package/dist/Editor/Elements/Form/FormField.js +2 -3
- package/dist/Editor/Elements/Form/Workflow/Styles.js +22 -24
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +30 -31
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +4 -7
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -7
- package/dist/Editor/Elements/FreeGrid/styles.js +0 -14
- package/dist/Editor/Elements/Grid/Grid.js +2 -14
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/Signature/Signature.css +1 -2
- package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +5 -18
- package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +3 -16
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/DragButton.js +1 -0
- package/dist/Editor/Elements/Table/Draggable.js +2 -6
- package/dist/Editor/Elements/Table/Styles.js +0 -7
- package/dist/Editor/Elements/Table/Table.js +3 -3
- package/dist/Editor/Elements/Table/TableCell.js +5 -24
- package/dist/Editor/Elements/Title/title.js +6 -6
- package/dist/Editor/Elements/Variables/VariableButton.js +1 -10
- package/dist/Editor/MiniEditor.js +1 -2
- package/dist/Editor/Styles/EditorStyles.js +5 -5
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +13 -10
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +2 -4
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +42 -167
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -7
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +12 -72
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +10 -58
- package/dist/Editor/Toolbar/PopupTool/index.js +1 -1
- package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
- package/dist/Editor/common/ColorPickerButton.js +16 -41
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +0 -3
- package/dist/Editor/common/Icon.js +0 -28
- package/dist/Editor/common/ImageSelector/ImageSelector.js +2 -2
- package/dist/Editor/common/ImageSelector/Styles.js +9 -3
- package/dist/Editor/common/LinkSettings/NavComponents.js +65 -45
- package/dist/Editor/common/LinkSettings/index.js +26 -13
- package/dist/Editor/common/LinkSettings/navOptions.js +2 -2
- package/dist/Editor/common/LinkSettings/style.js +244 -164
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +5 -4
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +3 -4
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +1 -3
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
- package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
- package/dist/Editor/common/RnD/OptionsPopup/style.js +1 -0
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -11
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +19 -28
- package/dist/Editor/common/RnD/Utils/index.js +1 -3
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +58 -42
- package/dist/Editor/common/RnD/VirtualElement/helper.js +131 -321
- package/dist/Editor/common/RnD/VirtualElement/styles.js +0 -16
- package/dist/Editor/common/RnD/index.js +11 -25
- package/dist/Editor/common/Select/index.js +7 -44
- package/dist/Editor/common/Select/styles.js +2 -30
- package/dist/Editor/common/Shorthands/elements.js +0 -54
- package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +2 -2
- package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +9 -12
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +8 -16
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +10 -36
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -16
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
- package/dist/Editor/common/SwipeableDrawer/style.js +12 -14
- package/dist/Editor/common/Uploader.js +0 -16
- package/dist/Editor/common/iconListV2.js +0 -76
- package/dist/Editor/common/iconslist.js +0 -21
- package/dist/Editor/commonStyle.js +61 -116
- package/dist/Editor/helper/index.js +0 -4
- package/dist/Editor/helper/theme.js +2 -203
- package/dist/Editor/hooks/useMouseMove.js +3 -9
- package/dist/Editor/hooks/useTable.js +4 -5
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +1 -3
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/theme/ThemeList.js +173 -50
- package/dist/Editor/utils/SlateUtilityFunctions.js +36 -158
- package/dist/Editor/utils/accordion.js +4 -14
- package/dist/Editor/utils/button.js +17 -1
- package/dist/Editor/utils/customHooks/useTableResize.js +9 -49
- package/dist/Editor/utils/draftToSlate.js +2 -3
- package/dist/Editor/utils/events.js +6 -50
- package/dist/Editor/utils/font.js +37 -40
- package/dist/Editor/utils/helper.js +30 -143
- package/dist/Editor/utils/insertAppHeader.js +1 -1
- package/dist/Editor/utils/signature.js +9 -2
- package/package.json +4 -4
- package/dist/Editor/Elements/FreeGrid/helper.js +0 -113
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -439
- package/dist/Editor/assets/svg/BackIcon.js +0 -18
- package/dist/Editor/assets/svg/ThemeIcons.js +0 -293
- package/dist/Editor/common/Checkbox/index.js +0 -46
- package/dist/Editor/common/Checkbox/styles.js +0 -45
- package/dist/Editor/common/CustomColorPicker/index.js +0 -130
- package/dist/Editor/common/CustomColorPicker/style.js +0 -53
- package/dist/Editor/common/CustomDialog2/index.js +0 -94
- package/dist/Editor/common/CustomDialog2/style.js +0 -67
- package/dist/Editor/common/CustomSelect.js +0 -43
- package/dist/Editor/common/RadioGroup/index.js +0 -48
- package/dist/Editor/common/RadioGroup/styles.js +0 -29
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
- package/dist/Editor/common/StyleBuilder/fieldTypes/embedUpload.js +0 -115
- package/dist/Editor/helper/textIndeces.js +0 -58
- package/dist/Editor/hooks/useEditorTheme.js +0 -153
- package/dist/Editor/hooks/useThemeValues.js +0 -63
- package/dist/Editor/theme/index.js +0 -149
- package/dist/Editor/themeSettings/ActiveTheme.js +0 -82
- package/dist/Editor/themeSettings/buttons/index.js +0 -300
- package/dist/Editor/themeSettings/buttons/style.js +0 -23
- package/dist/Editor/themeSettings/colorTheme/index.js +0 -310
- package/dist/Editor/themeSettings/colorTheme/style.js +0 -81
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
- package/dist/Editor/themeSettings/fonts/index.js +0 -240
- package/dist/Editor/themeSettings/fonts/style.js +0 -62
- package/dist/Editor/themeSettings/icons.js +0 -60
- package/dist/Editor/themeSettings/index.js +0 -380
- package/dist/Editor/themeSettings/style.js +0 -299
- package/dist/Editor/themeSettingsAI/icons.js +0 -96
- package/dist/Editor/themeSettingsAI/index.js +0 -355
- package/dist/Editor/themeSettingsAI/saveTheme.js +0 -202
- package/dist/Editor/themeSettingsAI/style.js +0 -332
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Path, Transforms } from "slate";
|
2
2
|
import insertNewLine from "./insertNewLine";
|
3
|
+
import { windowVar } from "./helper";
|
3
4
|
import { getCurrentElementText } from "../plugins/withHTML";
|
4
5
|
export const insertButton = editor => {
|
5
6
|
const button = {
|
@@ -10,7 +11,22 @@ export const insertButton = editor => {
|
|
10
11
|
buttonLink: {
|
11
12
|
linkType: "webAddress"
|
12
13
|
},
|
13
|
-
iconPosition: "start"
|
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 || {})
|
14
30
|
};
|
15
31
|
const hasText = getCurrentElementText(editor);
|
16
32
|
const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor?.selection.focus.path;
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import {
|
1
|
+
import { useState } from "react";
|
2
2
|
const useTableResize = ({
|
3
3
|
parentDOM,
|
4
4
|
size: defaultSize,
|
5
5
|
onDone,
|
6
|
-
minMaxProps = {}
|
7
|
-
isMobile
|
6
|
+
minMaxProps = {}
|
8
7
|
}) => {
|
9
8
|
const {
|
10
9
|
width
|
@@ -19,10 +18,6 @@ const useTableResize = ({
|
|
19
18
|
});
|
20
19
|
const [resizing, setResizing] = useState(false);
|
21
20
|
const [isDone, setIsDone] = useState(0);
|
22
|
-
const lastTouch = useRef({
|
23
|
-
x: 0,
|
24
|
-
y: 0
|
25
|
-
});
|
26
21
|
const onLoad = defaultSize => {
|
27
22
|
setSize({
|
28
23
|
widthInPercent: 100,
|
@@ -30,64 +25,29 @@ const useTableResize = ({
|
|
30
25
|
...defaultSize
|
31
26
|
});
|
32
27
|
};
|
33
|
-
const handleEventListeners = type => {
|
34
|
-
const listener = type === "add" ? document.addEventListener : document.removeEventListener;
|
35
|
-
const onMoveListener = isMobile ? "touchmove" : "pointermove";
|
36
|
-
const onEndListener = isMobile ? "touchend" : "pointerup";
|
37
|
-
listener(onMoveListener, onMouseMove);
|
38
|
-
listener(onEndListener, onMouseUp);
|
39
|
-
};
|
40
|
-
const updateLastTouch = ({
|
41
|
-
clientX,
|
42
|
-
clientY
|
43
|
-
}) => {
|
44
|
-
lastTouch.current.x = clientX;
|
45
|
-
lastTouch.current.y = clientY;
|
46
|
-
};
|
47
28
|
const onMouseDown = e => {
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
e.preventDefault();
|
52
|
-
}
|
53
|
-
handleEventListeners("add");
|
29
|
+
e.preventDefault();
|
30
|
+
document.addEventListener("pointermove", onMouseMove);
|
31
|
+
document.addEventListener("pointerup", onMouseUp);
|
54
32
|
setResizing(true);
|
55
33
|
setIsDone(0);
|
56
34
|
};
|
57
35
|
const onMouseUp = () => {
|
58
|
-
|
36
|
+
document.removeEventListener("pointermove", onMouseMove);
|
37
|
+
document.removeEventListener("pointerup", onMouseUp);
|
59
38
|
setResizing(false);
|
60
39
|
setIsDone(1);
|
61
40
|
};
|
62
41
|
const onMouseMove = e => {
|
63
|
-
let {
|
64
|
-
movementX,
|
65
|
-
movementY
|
66
|
-
} = e || {};
|
67
|
-
if (e.type === "touchmove") {
|
68
|
-
// for mobile
|
69
|
-
const {
|
70
|
-
x,
|
71
|
-
y
|
72
|
-
} = lastTouch.current || {};
|
73
|
-
const touches = e.touches[0];
|
74
|
-
const {
|
75
|
-
clientX,
|
76
|
-
clientY
|
77
|
-
} = touches;
|
78
|
-
movementX = clientX - x;
|
79
|
-
movementY = clientY - y;
|
80
|
-
updateLastTouch(touches);
|
81
|
-
}
|
82
42
|
const {
|
83
43
|
minWidth
|
84
44
|
} = minMaxProps || {};
|
85
45
|
setSize(currentSize => {
|
86
46
|
const width = currentSize?.width || parentDOM?.clientWidth;
|
87
|
-
const calcWidth = width + movementX;
|
47
|
+
const calcWidth = width + e.movementX;
|
88
48
|
return {
|
89
49
|
width: minWidth && calcWidth < minWidth ? minWidth : calcWidth,
|
90
|
-
height: currentSize.height + movementY,
|
50
|
+
height: currentSize.height + e.movementY,
|
91
51
|
widthInPercent: calcWidth / width * 100
|
92
52
|
};
|
93
53
|
});
|
@@ -82,8 +82,7 @@ const splitInlineStyleRanges = (text, inlineStyleRanges, data) => {
|
|
82
82
|
};
|
83
83
|
export const draftToSlate = props => {
|
84
84
|
const {
|
85
|
-
data
|
86
|
-
needLayout
|
85
|
+
data
|
87
86
|
} = props;
|
88
87
|
if (data?.blocks && data?.blocks?.length > 0) {
|
89
88
|
const converted = data?.blocks?.reduce((a, b) => {
|
@@ -105,7 +104,7 @@ export const draftToSlate = props => {
|
|
105
104
|
return data;
|
106
105
|
} else {
|
107
106
|
return [{
|
108
|
-
type:
|
107
|
+
type: "paragraph",
|
109
108
|
children: [{
|
110
109
|
text: ""
|
111
110
|
}]
|
@@ -1,11 +1,10 @@
|
|
1
|
-
import { Editor, Transforms, Element, Node, Path, Range
|
1
|
+
import { Editor, Transforms, Element, Node, Path, Range } from "slate";
|
2
2
|
import { toggleBlock } from "./SlateUtilityFunctions";
|
3
3
|
import insertNewLine from "./insertNewLine";
|
4
4
|
import { insertAccordion } from "./accordion";
|
5
|
-
import {
|
5
|
+
import { isListItem } from "./helper";
|
6
6
|
import RnDCtrlCmds from "./RnD/RnDCtrlCmds";
|
7
7
|
import EDITORCMDS from "../common/EditorCmds";
|
8
|
-
import { ReactEditor } from "slate-react";
|
9
8
|
const HOTKEYS = {
|
10
9
|
b: "bold",
|
11
10
|
i: "italic",
|
@@ -184,20 +183,6 @@ const checkListEnterEvent = (editor, type) => {
|
|
184
183
|
insertNewLine(editor);
|
185
184
|
}
|
186
185
|
};
|
187
|
-
const removeAccordion = (editor, accordionPath) => {
|
188
|
-
Transforms.removeNodes(editor, {
|
189
|
-
at: accordionPath
|
190
|
-
});
|
191
|
-
Transforms.insertNodes(editor, {
|
192
|
-
type: "paragraph",
|
193
|
-
children: [{
|
194
|
-
text: ""
|
195
|
-
}]
|
196
|
-
}, {
|
197
|
-
at: accordionPath,
|
198
|
-
select: true
|
199
|
-
});
|
200
|
-
};
|
201
186
|
export const enterEvent = (e, editor, isMobile) => {
|
202
187
|
try {
|
203
188
|
const ele = isListItem(editor);
|
@@ -240,7 +225,9 @@ export const enterEvent = (e, editor, isMobile) => {
|
|
240
225
|
e.preventDefault();
|
241
226
|
if (!text) {
|
242
227
|
const accordionIndex = ele[1].slice(0, Math.max(ele[1].length - 1));
|
243
|
-
|
228
|
+
Transforms.removeNodes(editor, {
|
229
|
+
at: accordionIndex
|
230
|
+
});
|
244
231
|
} else {
|
245
232
|
const nextPath = Path.next(Path.parent(ele[1]));
|
246
233
|
insertAccordion(editor, nextPath);
|
@@ -342,37 +329,6 @@ export const enterEvent = (e, editor, isMobile) => {
|
|
342
329
|
console.log(err);
|
343
330
|
}
|
344
331
|
};
|
345
|
-
export const handleAccordionOnBackspace = (e, editor) => {
|
346
|
-
try {
|
347
|
-
let isAccordion = false;
|
348
|
-
const [accordionDetails] = getNodeWithType(editor, "accordion-details");
|
349
|
-
const [accordionDetailsNode] = accordionDetails || [];
|
350
|
-
if (accordionDetailsNode) {
|
351
|
-
const dom = ReactEditor.toDOMNode(editor, accordionDetailsNode);
|
352
|
-
if (dom?.parentElement) {
|
353
|
-
dom.parentElement.style.display = "block";
|
354
|
-
}
|
355
|
-
}
|
356
|
-
const [accordionSummary] = getNodeWithType(editor, "accordion-summary");
|
357
|
-
const [accordionTitle, accordionTitlePath] = accordionSummary || [];
|
358
|
-
if (accordionTitle) {
|
359
|
-
// no selection
|
360
|
-
if (Range.isCollapsed(editor.selection)) {
|
361
|
-
const start = Editor.start(editor, accordionTitlePath);
|
362
|
-
const isCursorAtStart = Point.equals(editor.selection.focus, start);
|
363
|
-
if (isCursorAtStart) {
|
364
|
-
e.preventDefault();
|
365
|
-
const parentPath = Path.parent(accordionTitlePath);
|
366
|
-
removeAccordion(editor, parentPath);
|
367
|
-
isAccordion = true;
|
368
|
-
}
|
369
|
-
}
|
370
|
-
}
|
371
|
-
return isAccordion;
|
372
|
-
} catch (err) {
|
373
|
-
console.log(err);
|
374
|
-
}
|
375
|
-
};
|
376
332
|
export const upDownArrowKeyEvents = (e, editor) => {
|
377
333
|
try {
|
378
334
|
const {
|
@@ -392,7 +348,7 @@ export const upDownArrowKeyEvents = (e, editor) => {
|
|
392
348
|
}
|
393
349
|
Transforms.move(editor, {
|
394
350
|
distance: 0,
|
395
|
-
unit:
|
351
|
+
unit: 'offset',
|
396
352
|
reverse: false
|
397
353
|
});
|
398
354
|
Transforms.select(editor, {
|
@@ -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,10 +62,7 @@ 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
|
};
|
70
67
|
export const fontWeightOptions = [{
|
71
68
|
text: "Bold",
|
@@ -2,8 +2,6 @@ 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";
|
6
|
-
import { getCurrentElementText } from "../plugins/withHTML";
|
7
5
|
export const windowVar = {};
|
8
6
|
let ST_TIMEOUT = null;
|
9
7
|
const BLOCKS = ["grid", "dataView"];
|
@@ -306,20 +304,15 @@ const getScrollElement = () => {
|
|
306
304
|
const scrollFrom = isSlateWrapperScroll ? slateWrapper : window;
|
307
305
|
return scrollFrom;
|
308
306
|
};
|
309
|
-
const handleLinkBtnClick = (e, props, isMobilePreview
|
307
|
+
const handleLinkBtnClick = (e, props, isMobilePreview) => {
|
310
308
|
if (e) {
|
311
309
|
e.preventDefault();
|
312
310
|
e.stopPropagation();
|
313
311
|
}
|
314
|
-
const mobileAppRedirect = metadata?.buttonLink?.inAppRedirection;
|
315
312
|
if (props.target) {
|
316
313
|
window.open(props.href);
|
317
314
|
} else {
|
318
|
-
|
319
|
-
mobileAppRedirect(props.href);
|
320
|
-
} else {
|
321
|
-
window.location.href = props.href;
|
322
|
-
}
|
315
|
+
window.location.href = props.href;
|
323
316
|
if (isMobilePreview) {
|
324
317
|
// on iframe - mobile preview, window.location.href is not scrolling to the element correctly
|
325
318
|
const [, elementId] = props.href?.split("#");
|
@@ -335,8 +328,7 @@ const handleLinkBtnClick = (e, props, isMobilePreview, metadata) => {
|
|
335
328
|
}
|
336
329
|
}
|
337
330
|
};
|
338
|
-
export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}
|
339
|
-
) => {
|
331
|
+
export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick = () => {}) => {
|
340
332
|
const props = {};
|
341
333
|
if (!readOnly) {
|
342
334
|
return {
|
@@ -368,9 +360,6 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
|
|
368
360
|
case "page":
|
369
361
|
const [page = "", section] = url?.split("#") || [];
|
370
362
|
const sec = section ? `#${section}` : "";
|
371
|
-
if (isEditMode) {
|
372
|
-
break;
|
373
|
-
}
|
374
363
|
if (page === "_currentPage") {
|
375
364
|
props.component = "button";
|
376
365
|
props.onClick = () => {
|
@@ -391,12 +380,11 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
|
|
391
380
|
const currentUserPage = getCurrentUserPage();
|
392
381
|
props.href = isCurrentPage(page) ? `./${currentUserPage}${sec}` : `./${url}`;
|
393
382
|
if (openInNewTab) {
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
props.target = "_blank";
|
383
|
+
if (isCurrentPage(page)) {
|
384
|
+
// temp fix, if user is presented in current page, open in new tab option is restricted, we will scroll to the element in current page
|
385
|
+
} else {
|
386
|
+
props.target = "_blank";
|
387
|
+
}
|
400
388
|
}
|
401
389
|
}
|
402
390
|
break;
|
@@ -431,7 +419,7 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
|
|
431
419
|
|
432
420
|
// for iphone fix
|
433
421
|
if (props.component === "a" && props.href) {
|
434
|
-
const isMobile =
|
422
|
+
const isMobile = getDevice(window.innerWidth) === "xs";
|
435
423
|
if (isMobile) {
|
436
424
|
props.component = "button"; // iphone is opening two tabs, on open in new tab because of a tag.
|
437
425
|
}
|
@@ -439,13 +427,13 @@ export const handleLinkType = (url, linkType, readOnly, openInNewTab, onClick =
|
|
439
427
|
let touchEndClicked = false;
|
440
428
|
props.onTouchEnd = e => {
|
441
429
|
touchEndClicked = true;
|
442
|
-
handleLinkBtnClick(e, props
|
430
|
+
handleLinkBtnClick(e, props);
|
443
431
|
};
|
444
432
|
props.onClick = e => {
|
445
433
|
// This condition is used for mobile preview in the page editor.
|
446
434
|
// 'touchEnd' will not work in the mobile page preview.
|
447
435
|
if (!touchEndClicked && isMobile) {
|
448
|
-
handleLinkBtnClick(e, props, true
|
436
|
+
handleLinkBtnClick(e, props, true);
|
449
437
|
}
|
450
438
|
return false;
|
451
439
|
};
|
@@ -492,34 +480,6 @@ export const decodeString = str => {
|
|
492
480
|
console.log(err);
|
493
481
|
}
|
494
482
|
};
|
495
|
-
export const getContrastColor = color => {
|
496
|
-
let r, g, b;
|
497
|
-
|
498
|
-
// Check if the color is in hex format
|
499
|
-
if (color.startsWith("#")) {
|
500
|
-
r = parseInt(color.substring(1, 3), 16);
|
501
|
-
g = parseInt(color.substring(3, 5), 16);
|
502
|
-
b = parseInt(color.substring(5, 7), 16);
|
503
|
-
}
|
504
|
-
// Check if the color is in RGB/RGBA format
|
505
|
-
else if (color.startsWith("rgb")) {
|
506
|
-
const rgbValues = color.replace(/^rgba?\(|\s+|\)$/g, "") // Remove the rgb/rgba and spaces
|
507
|
-
.split(","); // Split the values into an array
|
508
|
-
|
509
|
-
r = parseInt(rgbValues[0]);
|
510
|
-
g = parseInt(rgbValues[1]);
|
511
|
-
b = parseInt(rgbValues[2]);
|
512
|
-
} else {
|
513
|
-
// If the format is not recognized, default to black text
|
514
|
-
return "#000000";
|
515
|
-
}
|
516
|
-
|
517
|
-
// Calculate relative luminance
|
518
|
-
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
519
|
-
|
520
|
-
// Return black for light colors, white for dark colors
|
521
|
-
return luminance > 0.5 ? "#000000" : "#FFFFFF";
|
522
|
-
};
|
523
483
|
export const onDeleteKey = (event, {
|
524
484
|
editor
|
525
485
|
}) => {
|
@@ -737,10 +697,6 @@ export const isRestrictedNode = (event, editor) => {
|
|
737
697
|
return isNodeRestricted;
|
738
698
|
}
|
739
699
|
};
|
740
|
-
export function capitalizeFirstLetter(str) {
|
741
|
-
if (!str) return str;
|
742
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
743
|
-
}
|
744
700
|
export const insertLineBreakAtEndOfPath = (editor, path) => {
|
745
701
|
try {
|
746
702
|
const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
|
@@ -759,13 +715,6 @@ export const insertLineBreakAtEndOfPath = (editor, path) => {
|
|
759
715
|
console.log(err);
|
760
716
|
}
|
761
717
|
};
|
762
|
-
export function isHavingSelection(editor) {
|
763
|
-
try {
|
764
|
-
return editor?.selection && !Range.isCollapsed(editor.selection);
|
765
|
-
} catch (err) {
|
766
|
-
console.log(err);
|
767
|
-
}
|
768
|
-
}
|
769
718
|
const omitNodes = ["site-settings", "page-settings"];
|
770
719
|
export function getInitialValue(value = [], readOnly) {
|
771
720
|
if (readOnly === "readonly" && value?.length) {
|
@@ -796,17 +745,20 @@ export function getInitialValue(value = [], readOnly) {
|
|
796
745
|
}
|
797
746
|
return value;
|
798
747
|
}
|
748
|
+
export function capitalizeFirstLetter(str) {
|
749
|
+
if (!str) return str;
|
750
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
751
|
+
}
|
752
|
+
export function isHavingSelection(editor) {
|
753
|
+
try {
|
754
|
+
return editor?.selection && !Range.isCollapsed(editor.selection);
|
755
|
+
} catch (err) {
|
756
|
+
console.log(err);
|
757
|
+
}
|
758
|
+
}
|
799
759
|
export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
|
800
760
|
return `${defaultCls} ${selected ? selectedClsName : ""}`;
|
801
761
|
}
|
802
|
-
export function handleNegativeInteger(val) {
|
803
|
-
return val < 0 ? 0 : val;
|
804
|
-
}
|
805
|
-
export const containsSurrogatePair = text => {
|
806
|
-
// Match surrogate pairs (high and low surrogate)
|
807
|
-
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
808
|
-
return surrogatePairRegex.test(text);
|
809
|
-
};
|
810
762
|
export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
811
763
|
try {
|
812
764
|
const options = {
|
@@ -820,6 +772,11 @@ export const getNodeWithType = (editor, nodeType = "", otherOptions) => {
|
|
820
772
|
return [];
|
821
773
|
}
|
822
774
|
};
|
775
|
+
export const containsSurrogatePair = text => {
|
776
|
+
// Match surrogate pairs (high and low surrogate)
|
777
|
+
const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
778
|
+
return surrogatePairRegex.test(text);
|
779
|
+
};
|
823
780
|
export const getSlateDom = (editor, range) => {
|
824
781
|
try {
|
825
782
|
const slateDom = ReactEditor.toDOMRange(editor, range);
|
@@ -869,24 +826,9 @@ export const hideSlateSelection = () => {
|
|
869
826
|
const root = document.documentElement;
|
870
827
|
root.style.setProperty("--slate-highlight-bg", "none");
|
871
828
|
};
|
872
|
-
export
|
873
|
-
|
874
|
-
|
875
|
-
editor.deleteFragment();
|
876
|
-
const currentText = getCurrentElementText(editor);
|
877
|
-
const currentPath = editor?.selection?.anchor?.path;
|
878
|
-
let insertAt = currentPath;
|
879
|
-
if (currentText?.trim()) {
|
880
|
-
const parentPath = Path.parent(currentPath);
|
881
|
-
insertAt = Path.next(parentPath);
|
882
|
-
}
|
883
|
-
Transforms.insertNodes(editor, insertNode, {
|
884
|
-
at: insertAt
|
885
|
-
});
|
886
|
-
} catch (err) {
|
887
|
-
console.log(err);
|
888
|
-
}
|
889
|
-
};
|
829
|
+
export function handleNegativeInteger(val) {
|
830
|
+
return val < 0 ? 0 : val;
|
831
|
+
}
|
890
832
|
export const isEverythingSelected = editor => {
|
891
833
|
const {
|
892
834
|
selection
|
@@ -916,59 +858,4 @@ export const getCurrentNodeText = editor => {
|
|
916
858
|
} catch (error) {
|
917
859
|
console.log("Error:", error);
|
918
860
|
}
|
919
|
-
};
|
920
|
-
function convertColorToRgb(color) {
|
921
|
-
if (color?.startsWith("#")) {
|
922
|
-
// HEX to RGB
|
923
|
-
let hex = color.replace("#", "");
|
924
|
-
let r, g, b;
|
925
|
-
if (hex.length === 3) {
|
926
|
-
hex = hex.split("").map(x => x + x).join("");
|
927
|
-
}
|
928
|
-
if (hex.length === 6) {
|
929
|
-
[r, g, b] = [hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)].map(val => parseInt(val, 16));
|
930
|
-
return `rgb(${r}, ${g}, ${b})`;
|
931
|
-
}
|
932
|
-
} else {
|
933
|
-
return color;
|
934
|
-
}
|
935
|
-
}
|
936
|
-
export const getSelectedColor = (selectedColor, theme, hideThemeColors) => {
|
937
|
-
const colorVars = hideThemeColors ? null : theme?.vars?.colors;
|
938
|
-
let selectedValue = selectedColor;
|
939
|
-
if (colorVars) {
|
940
|
-
const convertedColor = convertColorToRgb(selectedColor);
|
941
|
-
Object.entries(theme.colors).forEach(([key, value]) => {
|
942
|
-
const convertedThemeColor = convertColorToRgb(value);
|
943
|
-
if (convertedThemeColor === convertedColor) {
|
944
|
-
selectedValue = colorVars[key];
|
945
|
-
}
|
946
|
-
});
|
947
|
-
}
|
948
|
-
return selectedValue;
|
949
|
-
};
|
950
|
-
const themeTextFormats = ["headingOne", "headingTwo", "headingThree", "headingFour", "headingFive", "headingSix", "paragraphOne", "paragraphTwo", "paragraphThree"];
|
951
|
-
export const getSelectedElementColor = (editor, format, theme) => {
|
952
|
-
const [isThemeText] = Editor.nodes(editor, {
|
953
|
-
at: editor.selection,
|
954
|
-
match: n => themeTextFormats.includes(n?.type)
|
955
|
-
});
|
956
|
-
if (!isThemeText) {
|
957
|
-
return activeMark(editor, "color") || "#000000";
|
958
|
-
}
|
959
|
-
const color = getSelectedElementStyle(format, editor, format);
|
960
|
-
return getSelectedColor(color, theme);
|
961
|
-
};
|
962
|
-
export const isHavingColor = color => {
|
963
|
-
if (!color) {
|
964
|
-
return false;
|
965
|
-
}
|
966
|
-
if (color.includes("rgba")) {
|
967
|
-
const match = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*(\d*\.?\d+)?\)/);
|
968
|
-
if (!match) return false; // Invalid format
|
969
|
-
|
970
|
-
const alpha = match[4] !== undefined ? parseFloat(match[4]) : 1; // Default alpha = 1
|
971
|
-
return alpha !== 0;
|
972
|
-
}
|
973
|
-
return true;
|
974
861
|
};
|
@@ -1,5 +1,9 @@
|
|
1
|
-
import {
|
1
|
+
import { Path, Transforms } from "slate";
|
2
|
+
import insertNewLine from "./insertNewLine";
|
3
|
+
import { getCurrentElementText } from "../plugins/withHTML";
|
2
4
|
export const insertSignature = editor => {
|
5
|
+
const hasText = getCurrentElementText(editor);
|
6
|
+
const insertPath = hasText ? Path.next(Path.parent(editor?.selection.focus.path)) : editor.selection.anchor.path;
|
3
7
|
const signature = {
|
4
8
|
type: "signature",
|
5
9
|
alignment: "center",
|
@@ -13,5 +17,8 @@ export const insertSignature = editor => {
|
|
13
17
|
text: " "
|
14
18
|
}]
|
15
19
|
};
|
16
|
-
|
20
|
+
Transforms.insertNodes(editor, signature, {
|
21
|
+
at: insertPath
|
22
|
+
});
|
23
|
+
insertNewLine(editor);
|
17
24
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "10.3.
|
3
|
+
"version": "10.3.1",
|
4
4
|
"description": "An Editor for flozy app brain",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -38,6 +38,7 @@
|
|
38
38
|
"react-icons": "^4.10.1",
|
39
39
|
"react-katex": "^3.0.1",
|
40
40
|
"react-rnd": "^10.4.11",
|
41
|
+
"react-scripts": "5.0.1",
|
41
42
|
"react-signature-canvas": "^1.0.6",
|
42
43
|
"react-slick": "^0.29.0",
|
43
44
|
"sanitize-html": "^2.13.0",
|
@@ -68,7 +69,7 @@
|
|
68
69
|
"storybook": "storybook dev -p 6006",
|
69
70
|
"build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
|
70
71
|
"publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
|
71
|
-
"publish:local": "rm -rf /Users/
|
72
|
+
"publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files",
|
72
73
|
"publish:flozy": "./publish-flozy.sh",
|
73
74
|
"publish:flozy2": "./publish-flozy2.sh",
|
74
75
|
"publish:permission": "chmod +x publish-flozy.sh && chmod +x publish-flozy2.sh"
|
@@ -121,8 +122,7 @@
|
|
121
122
|
"prop-types": "^15.8.1",
|
122
123
|
"source-map-explorer": "^2.5.3",
|
123
124
|
"storybook": "^7.4.0",
|
124
|
-
"webpack": "^5.88.2"
|
125
|
-
"react-scripts": "5.0.1"
|
125
|
+
"webpack": "^5.88.2"
|
126
126
|
},
|
127
127
|
"overrides": {
|
128
128
|
"react-refresh": "0.11.0"
|