@flozy/editor 3.9.0 → 3.9.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +177 -109
- package/dist/Editor/Editor.css +8 -12
- package/dist/Editor/Elements/AI/AIInput.js +17 -18
- package/dist/Editor/Elements/AI/CustomSelect.js +19 -12
- package/dist/Editor/Elements/AI/PopoverAIInput.js +23 -28
- package/dist/Editor/Elements/AI/Styles.js +2 -1
- package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +73 -0
- package/dist/Editor/Elements/AI/VoiceToText/index.js +177 -0
- package/dist/Editor/Elements/AI/VoiceToText/style.js +40 -0
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +4 -15
- package/dist/Editor/Elements/AppHeader/AppHeader.js +26 -4
- package/dist/Editor/Elements/Button/EditorButton.js +28 -16
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +60 -17
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
- package/dist/Editor/Elements/Color Picker/Styles.js +2 -1
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +12 -3
- package/dist/Editor/Elements/Form/Workflow/UserInputs.js +2 -1
- package/dist/Editor/Elements/Grid/Grid.js +27 -3
- package/dist/Editor/Elements/Grid/GridItem.js +3 -1
- package/dist/Editor/Elements/Link/Link.js +6 -1
- package/dist/Editor/Elements/Link/LinkButton.js +4 -2
- package/dist/Editor/Elements/Link/LinkPopup.js +10 -3
- package/dist/Editor/Elements/Link/LinkPopupStyles.js +28 -0
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +3 -3
- package/dist/Editor/Elements/Redo/RedoButton.js +14 -0
- package/dist/Editor/Elements/Signature/SignaturePopup.js +14 -3
- package/dist/Editor/Elements/Table/Styles.js +23 -1
- package/dist/Editor/Elements/Table/Table.js +2 -1
- package/dist/Editor/Elements/Table/TableCell.js +69 -7
- package/dist/Editor/Elements/TableContextMenu/TableContextMenu.js +1 -0
- package/dist/Editor/Elements/Undo/UndoButton.js +14 -0
- package/dist/Editor/MiniEditor.js +3 -1
- package/dist/Editor/Styles/EditorStyles.js +1 -1
- package/dist/Editor/Toolbar/Basic/index.js +4 -2
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +26 -2
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +29 -18
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +4 -2
- package/dist/Editor/Toolbar/Mini/Options/Options.js +10 -0
- package/dist/Editor/Toolbar/Mini/Styles.js +7 -0
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +4 -11
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +213 -86
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +22 -16
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +52 -7
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +438 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +7 -17
- package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
- package/dist/Editor/assets/svg/AIIcons.js +153 -1
- package/dist/Editor/assets/svg/AddTemplateIcon.js +13 -10
- package/dist/Editor/assets/svg/RedoIcon.js +27 -0
- package/dist/Editor/assets/svg/SettingsIcon.js +28 -0
- package/dist/Editor/assets/svg/TextIcon.js +8 -5
- package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
- package/dist/Editor/assets/svg/UndoIcon.js +27 -0
- package/dist/Editor/common/ColorPickerButton.js +25 -9
- package/dist/Editor/common/CustomColorPicker/index.js +106 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog/index.js +94 -0
- package/dist/Editor/common/CustomDialog/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +33 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +56 -47
- package/dist/Editor/common/Icon.js +43 -3
- package/dist/Editor/common/LinkSettings/NavComponents.js +5 -2
- package/dist/Editor/common/LinkSettings/index.js +4 -2
- package/dist/Editor/common/LinkSettings/navOptions.js +7 -2
- package/dist/Editor/common/LinkSettings/style.js +11 -8
- package/dist/Editor/common/Section/index.js +57 -7
- package/dist/Editor/common/Section/styles.js +11 -0
- package/dist/Editor/common/Shorthands/elements.js +54 -0
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +33 -29
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +31 -25
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +1 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +31 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +14 -4
- package/dist/Editor/common/StyleBuilder/index.js +1 -1
- package/dist/Editor/common/iconslist.js +0 -31
- package/dist/Editor/helper/theme.js +189 -4
- package/dist/Editor/hooks/useEditorTheme.js +139 -0
- package/dist/Editor/hooks/useMouseMove.js +4 -1
- package/dist/Editor/hooks/useWindowMessage.js +10 -7
- 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 +50 -173
- package/dist/Editor/theme/index.js +144 -0
- package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
- package/dist/Editor/themeSettings/buttons/index.js +290 -0
- package/dist/Editor/themeSettings/buttons/style.js +21 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +290 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +77 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +123 -0
- package/dist/Editor/themeSettings/fonts/index.js +213 -0
- package/dist/Editor/themeSettings/fonts/style.js +44 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +320 -0
- package/dist/Editor/themeSettings/style.js +152 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +356 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +190 -0
- package/dist/Editor/themeSettingsAI/style.js +247 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +161 -25
- package/dist/Editor/utils/button.js +1 -17
- package/dist/Editor/utils/events.js +54 -2
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/helper.js +31 -2
- package/dist/Editor/utils/table.js +51 -43
- package/package.json +4 -3
@@ -1,5 +1,5 @@
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
2
|
-
import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle } from "react";
|
2
|
+
import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle, createContext } from "react";
|
3
3
|
import { createEditor, Transforms } from "slate";
|
4
4
|
import { Slate, Editable, ReactEditor } from "slate-react";
|
5
5
|
import { useDebounce, useDebouncedCallback } from "use-debounce";
|
@@ -18,7 +18,7 @@ import { getThumbnailImage, invertColor } from "./helper";
|
|
18
18
|
import PopupTool from "./Toolbar/PopupTool";
|
19
19
|
import "./font.css";
|
20
20
|
import "./Editor.css";
|
21
|
-
import { Box,
|
21
|
+
import { Box, IconButton, Typography } from "@mui/material";
|
22
22
|
import Shorthands from "./common/Shorthands";
|
23
23
|
import MiniToolbar from "./Toolbar/Mini/MiniToolbar";
|
24
24
|
import { EditorProvider } from "./hooks/useMouseMove";
|
@@ -28,12 +28,19 @@ import DragAndDrop from "./common/DnD";
|
|
28
28
|
import Section from "./common/Section";
|
29
29
|
import "animate.css";
|
30
30
|
import decorators from "./utils/Decorators";
|
31
|
-
import { getTRBLBreakPoints } from "./helper/theme";
|
31
|
+
import { getTRBLBreakPoints, getVariableValue } from "./helper/theme";
|
32
32
|
import { handleInsertLastElement, onDeleteKey, outsideEditorClickLabel } from "./utils/helper";
|
33
33
|
import useWindowResize from "./hooks/useWindowResize";
|
34
|
+
import { getTheme } from "./theme";
|
35
|
+
import { useTheme } from "@emotion/react";
|
36
|
+
import ThemeSettings from "./themeSettings";
|
37
|
+
import ThemeSettingsAI from "./themeSettingsAI";
|
38
|
+
import { Experimental_CssVarsProvider as CssVarsProvider, experimental_extendTheme as extendTheme } from "@mui/material/styles";
|
34
39
|
import PopoverAIInput from "./Elements/AI/PopoverAIInput";
|
40
|
+
import { ThemeAIIcon, ThemePaintIcon } from "./assets/svg/ThemeIcons";
|
35
41
|
import { jsx as _jsx } from "react/jsx-runtime";
|
36
42
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
43
|
+
export const ThemeContext = /*#__PURE__*/createContext(null);
|
37
44
|
const Item = /*#__PURE__*/forwardRef(({
|
38
45
|
children,
|
39
46
|
...props
|
@@ -60,7 +67,8 @@ const Leaf = ({
|
|
60
67
|
children,
|
61
68
|
leaf
|
62
69
|
}) => {
|
63
|
-
|
70
|
+
const theme = useTheme();
|
71
|
+
children = getMarked(leaf, children, theme);
|
64
72
|
return /*#__PURE__*/_jsx("span", {
|
65
73
|
...attributes,
|
66
74
|
children: children
|
@@ -79,7 +87,8 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
79
87
|
toolbarOptions,
|
80
88
|
otherProps,
|
81
89
|
isIframe,
|
82
|
-
theme
|
90
|
+
theme,
|
91
|
+
showThemeButtons
|
83
92
|
} = props;
|
84
93
|
const editorWrapper = useRef();
|
85
94
|
const mentionsRef = useRef();
|
@@ -123,10 +132,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
123
132
|
const {
|
124
133
|
bannerSpacing,
|
125
134
|
pageBgImage,
|
126
|
-
pageColor,
|
135
|
+
pageColor = "",
|
127
136
|
color: pageTextColor,
|
128
137
|
pageWidth,
|
129
|
-
maxWidth: pageMaxWidth
|
138
|
+
maxWidth: pageMaxWidth,
|
139
|
+
theme: selectedTheme
|
130
140
|
} = pageSt?.pageProps || {
|
131
141
|
bannerSpacing: {
|
132
142
|
left: 0,
|
@@ -137,9 +147,11 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
137
147
|
};
|
138
148
|
const classes = editorStyles({
|
139
149
|
padHeight: !fullScreen ? otherProps?.padHeight : 20,
|
140
|
-
placeHolderColor: invertColor(pageColor || "#FFF"),
|
150
|
+
placeHolderColor: invertColor(pageColor.startsWith("var") ? getVariableValue(pageColor) : pageColor || "#FFF"),
|
141
151
|
theme
|
142
152
|
});
|
153
|
+
const [openTheme, setOpenTheme] = useState(false);
|
154
|
+
const [openAITheme, setOpenAITheme] = useState(false);
|
143
155
|
useEffect(() => {
|
144
156
|
setValue(draftToSlate({
|
145
157
|
data: content
|
@@ -239,6 +251,12 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
239
251
|
redo() {
|
240
252
|
editor?.redo();
|
241
253
|
},
|
254
|
+
toggleTheme() {
|
255
|
+
setOpenTheme(!openTheme);
|
256
|
+
},
|
257
|
+
toggleAITheme() {
|
258
|
+
setOpenAITheme(!openAITheme);
|
259
|
+
},
|
242
260
|
getPageSettings: {
|
243
261
|
background: pageBgImage && pageBgImage !== "none" ? `url(${pageBgImage})` : pageColor || ""
|
244
262
|
}
|
@@ -386,113 +404,163 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
386
404
|
}
|
387
405
|
return style;
|
388
406
|
}, [pageBgImage, pageColor]);
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
407
|
+
const themeProps = getTheme(selectedTheme);
|
408
|
+
const handleCursorScroll = container => {
|
409
|
+
const cursorPosition = window.getSelection()?.getRangeAt(0).getBoundingClientRect();
|
410
|
+
const containerBottom = container.getBoundingClientRect().bottom;
|
411
|
+
if (cursorPosition?.bottom > containerBottom - 250) {
|
412
|
+
container.scrollBy({
|
413
|
+
top: 200,
|
414
|
+
behavior: 'smooth'
|
415
|
+
});
|
416
|
+
}
|
417
|
+
};
|
418
|
+
return /*#__PURE__*/_jsx(ThemeContext.Provider, {
|
419
|
+
value: {
|
420
|
+
openTheme,
|
421
|
+
setOpenTheme
|
422
|
+
},
|
423
|
+
children: /*#__PURE__*/_jsx(CssVarsProvider, {
|
424
|
+
theme: extendTheme(selectedTheme?.theme?.cssVars || {}),
|
425
|
+
children: /*#__PURE__*/_jsxs(EditorProvider, {
|
426
|
+
theme: theme,
|
427
|
+
editor: editor,
|
428
|
+
children: [showThemeButtons ? /*#__PURE__*/_jsxs("div", {
|
429
|
+
style: {
|
430
|
+
display: "flex",
|
431
|
+
justifyContent: "end",
|
432
|
+
alignItems: "center",
|
433
|
+
gap: "8px",
|
434
|
+
width: "70vw",
|
435
|
+
margin: "auto"
|
436
|
+
},
|
437
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
438
|
+
onClick: () => setOpenTheme(true),
|
439
|
+
children: /*#__PURE__*/_jsx(ThemePaintIcon, {})
|
440
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
441
|
+
onClick: () => setOpenAITheme(true),
|
442
|
+
style: {
|
443
|
+
marginTop: "4px"
|
444
|
+
},
|
445
|
+
children: /*#__PURE__*/_jsx(ThemeAIIcon, {})
|
446
|
+
})]
|
447
|
+
}) : null, /*#__PURE__*/_jsx(DialogWrapper, {
|
448
|
+
classes: classes,
|
449
|
+
...props,
|
450
|
+
fullScreen: fullScreen,
|
451
|
+
footer: footer || "",
|
452
|
+
children: /*#__PURE__*/_jsx(Box, {
|
453
|
+
component: "div",
|
454
|
+
className: `${editorClass || ""} ${isIframe ? "iframe-editor" : ""}`,
|
455
|
+
sx: classes.root,
|
456
|
+
style: {
|
457
|
+
...dotBg
|
458
|
+
},
|
459
|
+
children: /*#__PURE__*/_jsxs(Slate, {
|
460
|
+
editor: editor,
|
461
|
+
initialValue: value,
|
462
|
+
onChange: handleEditorChange,
|
463
|
+
children: [/*#__PURE__*/_jsx(DragAndDrop, {
|
464
|
+
children: /*#__PURE__*/_jsxs(Overlay, {
|
465
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
466
|
+
className: `${hasTopBanner() ? "has-topbanner" : ""} ${!pageColor ? "no-color" : ""} ${isScrolling ? "" : "hideScroll"} scrollable-content scrollSmooth`,
|
467
|
+
sx: classes.slateWrapper,
|
468
|
+
id: "slate-wrapper-scroll-container"
|
469
|
+
// style={editorWrapperStyle}
|
470
|
+
,
|
471
|
+
ref: editorWrapper,
|
472
|
+
onClick: e => {
|
473
|
+
handleInsertLastElement(e, editor);
|
474
|
+
},
|
475
|
+
onScroll: handleScroll,
|
476
|
+
style: editorWrapperStyle,
|
429
477
|
children: /*#__PURE__*/_jsxs(Box, {
|
430
478
|
component: "div",
|
431
|
-
className:
|
432
|
-
sx: {
|
433
|
-
backgroundColor: "transparent",
|
434
|
-
padding: {
|
435
|
-
...getTRBLBreakPoints(bannerSpacing)
|
436
|
-
},
|
437
|
-
width: !pageWidth || pageWidth === "fixed" ? fixedWidth : fullWidth,
|
438
|
-
height: viewport.h ? `${viewport.h}px` : `100%`,
|
439
|
-
alignSelf: "center",
|
440
|
-
transformOrigin: "left top",
|
441
|
-
transition: "all 0.3s",
|
442
|
-
minHeight: "87%",
|
443
|
-
maxWidth: pageMaxWidth ? `${parseInt(pageMaxWidth)}px !important` : "auto"
|
444
|
-
},
|
479
|
+
className: "max-content",
|
480
|
+
sx: themeProps?.sxProps || {},
|
445
481
|
"data-info": outsideEditorClickLabel,
|
446
|
-
children: [/*#__PURE__*/_jsx(
|
447
|
-
className: "
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
482
|
+
children: [renderTopBanner(), /*#__PURE__*/_jsx("div", {
|
483
|
+
className: "scroll-area",
|
484
|
+
"data-info": outsideEditorClickLabel,
|
485
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
486
|
+
component: "div",
|
487
|
+
className: `editor-wrapper ${pageWidth === "fixed" ? "fixed" : "full"}`,
|
488
|
+
sx: {
|
489
|
+
backgroundColor: "transparent",
|
490
|
+
padding: {
|
491
|
+
...getTRBLBreakPoints(bannerSpacing)
|
492
|
+
},
|
493
|
+
width: !pageWidth || pageWidth === "fixed" ? fixedWidth : fullWidth,
|
494
|
+
height: viewport.h ? `${viewport.h}px` : `100%`,
|
495
|
+
alignSelf: "center",
|
496
|
+
transformOrigin: "left top",
|
497
|
+
transition: "all 0.3s",
|
498
|
+
minHeight: "87%",
|
499
|
+
maxWidth: pageMaxWidth ? `${parseInt(pageMaxWidth)}px !important` : "auto"
|
500
|
+
},
|
501
|
+
"data-info": outsideEditorClickLabel,
|
502
|
+
children: [/*#__PURE__*/_jsx(Editable, {
|
503
|
+
className: "innert-editor-textbox",
|
504
|
+
readOnly: isReadOnly,
|
505
|
+
renderElement: renderElement,
|
506
|
+
renderLeaf: renderLeaf,
|
507
|
+
decorate: decorators,
|
508
|
+
onKeyDown: onKeyDown,
|
509
|
+
onSelect: () => handleCursorScroll(editorWrapper.current)
|
510
|
+
}), !readOnly ? /*#__PURE__*/_jsx(MentionsPopup, {
|
511
|
+
ref: mentionsRef,
|
512
|
+
mentions: mentions,
|
513
|
+
setMentions: setMentions,
|
514
|
+
editor: editor,
|
515
|
+
target: target,
|
516
|
+
index: index,
|
517
|
+
chars: chars,
|
518
|
+
type: type,
|
519
|
+
theme: theme
|
520
|
+
}) : null]
|
521
|
+
})
|
522
|
+
}), !hideMiniToolBar ? /*#__PURE__*/_jsx(MiniToolbar, {
|
523
|
+
customProps: customProps,
|
524
|
+
toolbarOptions: toolbarOptions,
|
462
525
|
theme: theme
|
463
|
-
}) : null
|
526
|
+
}) : null, /*#__PURE__*/_jsx(PopoverAIInput, {
|
527
|
+
otherProps: otherProps || {}
|
528
|
+
}), footer && (fullScreen || readOnly) && /*#__PURE__*/_jsx(Typography, {
|
529
|
+
sx: {
|
530
|
+
color: "rgb(100, 116, 139)",
|
531
|
+
fontSize: "13px",
|
532
|
+
paddingBottom: hideMiniToolBar ? "0px" : "12px",
|
533
|
+
cursor: "pointer"
|
534
|
+
},
|
535
|
+
align: "center",
|
536
|
+
"data-info": outsideEditorClickLabel,
|
537
|
+
onClick: handleFooterClick,
|
538
|
+
children: footer
|
539
|
+
}), openTheme ? /*#__PURE__*/_jsx(ThemeSettings, {
|
540
|
+
open: openTheme,
|
541
|
+
setOpen: setOpenTheme,
|
542
|
+
editor: editor,
|
543
|
+
services: otherProps?.services
|
544
|
+
}) : null, /*#__PURE__*/_jsx(ThemeSettingsAI, {
|
545
|
+
openAITheme: openAITheme,
|
546
|
+
setOpenAITheme: setOpenAITheme,
|
547
|
+
onSaveTheme: otherProps?.onSaveTheme
|
548
|
+
})]
|
464
549
|
})
|
465
|
-
}), !
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
}), footer && (fullScreen || readOnly) && /*#__PURE__*/_jsx(Typography, {
|
472
|
-
sx: {
|
473
|
-
color: "rgb(100, 116, 139)",
|
474
|
-
fontSize: "13px",
|
475
|
-
paddingBottom: hideMiniToolBar ? "0px" : "12px",
|
476
|
-
cursor: "pointer"
|
477
|
-
},
|
478
|
-
align: "center",
|
479
|
-
"data-info": outsideEditorClickLabel,
|
480
|
-
onClick: handleFooterClick,
|
481
|
-
children: footer
|
482
|
-
})]
|
550
|
+
}), !readOnly ? /*#__PURE__*/_jsx(PopupTool, {
|
551
|
+
onDrawerOpen: onDrawerOpen,
|
552
|
+
theme: theme,
|
553
|
+
setIsTextSelected: setIsTextSelected,
|
554
|
+
customProps: customProps
|
555
|
+
}) : null]
|
483
556
|
})
|
484
|
-
}),
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
}), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
|
492
|
-
...htmlAction,
|
493
|
-
handleCodeToText: handleCodeToText
|
494
|
-
})]
|
495
|
-
}, id)
|
557
|
+
}), htmlAction.showInput && /*#__PURE__*/_jsx(CodeToText, {
|
558
|
+
...htmlAction,
|
559
|
+
handleCodeToText: handleCodeToText
|
560
|
+
})]
|
561
|
+
}, id)
|
562
|
+
})
|
563
|
+
})]
|
496
564
|
})
|
497
565
|
})
|
498
566
|
});
|
package/dist/Editor/Editor.css
CHANGED
@@ -245,6 +245,13 @@ blockquote {
|
|
245
245
|
width: 17px !important;
|
246
246
|
}
|
247
247
|
|
248
|
+
.react-datepicker__input-container input {
|
249
|
+
height: 40px !important;
|
250
|
+
border: 1px solid #ccc;
|
251
|
+
border-radius: 5px;
|
252
|
+
width: 100%;
|
253
|
+
}
|
254
|
+
|
248
255
|
.close-popupbtn {
|
249
256
|
border-radius: 4px !important;
|
250
257
|
width: 24px;
|
@@ -830,17 +837,6 @@ blockquote {
|
|
830
837
|
text-align: center;
|
831
838
|
}
|
832
839
|
|
833
|
-
.removeScroll::-webkit-outer-spin-button,
|
834
|
-
.removeScroll::-webkit-inner-spin-button {
|
835
|
-
-webkit-appearance: none;
|
836
|
-
margin: 0;
|
837
|
-
}
|
838
|
-
|
839
|
-
/* For Firefox */
|
840
|
-
.removeScroll {
|
841
|
-
-moz-appearance: textfield;
|
842
|
-
}
|
843
|
-
|
844
840
|
.borderInput:focus-visible {
|
845
841
|
outline: none !important;
|
846
842
|
}
|
@@ -890,7 +886,7 @@ blockquote {
|
|
890
886
|
}
|
891
887
|
|
892
888
|
.sliderInput {
|
893
|
-
width:
|
889
|
+
width: 66px;
|
894
890
|
padding: 2px 10px;
|
895
891
|
margin-left: 18px;
|
896
892
|
box-shadow: 0px 4px 16px 0px #0000000d;
|
@@ -6,11 +6,11 @@ import Icon from "../../common/Icon";
|
|
6
6
|
import { IoSend } from "react-icons/io5";
|
7
7
|
import React, { forwardRef, useEffect, useRef } from "react";
|
8
8
|
import WaveLoading from "../../common/WaveLoading";
|
9
|
-
import useWindowResize from "../../hooks/useWindowResize";
|
10
9
|
import CustomSelect from "./CustomSelect";
|
11
10
|
import { editContentOptions, newContentOptions, generatedContentOptions } from "./helper";
|
12
11
|
import useClickOutside from "../../hooks/useClickOutside";
|
13
12
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
13
|
+
import { ChatMicIcon } from "../../assets/svg/AIIcons";
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
15
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
16
16
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
@@ -36,19 +36,19 @@ function getProps(openAI, generatedText) {
|
|
36
36
|
}
|
37
37
|
function AIInput({
|
38
38
|
onSend,
|
39
|
-
loading,
|
40
39
|
generatedText,
|
41
40
|
openAI,
|
42
41
|
inputValue,
|
43
42
|
onInputChange,
|
44
|
-
onClickOutside
|
43
|
+
onClickOutside,
|
44
|
+
startRecording,
|
45
|
+
...rest
|
45
46
|
}, ref) {
|
46
47
|
const {
|
47
48
|
theme
|
48
49
|
} = useEditorContext();
|
49
50
|
const classes = Styles(theme);
|
50
51
|
const inputRef = useRef();
|
51
|
-
const [size] = useWindowResize();
|
52
52
|
const inputWrapperRef = useRef();
|
53
53
|
const refs = useClickOutside({
|
54
54
|
onClickOutside,
|
@@ -67,6 +67,7 @@ function AIInput({
|
|
67
67
|
clearTimeout(timeoutId);
|
68
68
|
};
|
69
69
|
}, [openAI]);
|
70
|
+
const loading = rest?.loading || rest?.isAILoading;
|
70
71
|
const isSendBtnDisabled = !inputValue || loading;
|
71
72
|
const props = getProps(openAI, generatedText) || {};
|
72
73
|
const fromToolBar = openAI === "fromToolBar";
|
@@ -80,16 +81,7 @@ function AIInput({
|
|
80
81
|
});
|
81
82
|
};
|
82
83
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
83
|
-
children: [
|
84
|
-
component: "div",
|
85
|
-
ref: refs[1],
|
86
|
-
sx: classes.customSelectWrapper,
|
87
|
-
children: /*#__PURE__*/_jsx(CustomSelect, {
|
88
|
-
...props,
|
89
|
-
onSend: onSend,
|
90
|
-
classes: classes
|
91
|
-
})
|
92
|
-
}) : null, /*#__PURE__*/_jsxs(Box, {
|
84
|
+
children: [/*#__PURE__*/_jsxs(Box, {
|
93
85
|
component: "div",
|
94
86
|
sx: classes.aiContainer,
|
95
87
|
children: [generatedText ? /*#__PURE__*/_jsx(Typography, {
|
@@ -132,21 +124,28 @@ function AIInput({
|
|
132
124
|
handleSendBtnClick();
|
133
125
|
}
|
134
126
|
}
|
135
|
-
}), fromToolBar ? null : /*#__PURE__*/
|
127
|
+
}), fromToolBar ? null : /*#__PURE__*/_jsxs(Box, {
|
136
128
|
component: "div",
|
137
129
|
style: classes.sendIconContainer,
|
138
130
|
className: "icons-elements",
|
139
|
-
children: /*#__PURE__*/_jsx(IconButton
|
131
|
+
children: [/*#__PURE__*/_jsx(IconButton
|
132
|
+
// sx={
|
133
|
+
// isSendBtnDisabled ? classes.sendBtnDisabled : classes.sendBtn
|
134
|
+
// }
|
135
|
+
, {
|
136
|
+
onClick: () => startRecording(),
|
137
|
+
children: /*#__PURE__*/_jsx(ChatMicIcon, {})
|
138
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
140
139
|
sx: isSendBtnDisabled ? classes.sendBtnDisabled : classes.sendBtn,
|
141
140
|
onClick: () => handleSendBtnClick(),
|
142
141
|
children: /*#__PURE__*/_jsx(IoSend, {
|
143
142
|
color: "#fff",
|
144
143
|
size: 14
|
145
144
|
})
|
146
|
-
})
|
145
|
+
})]
|
147
146
|
})]
|
148
147
|
})]
|
149
|
-
}),
|
148
|
+
}), /*#__PURE__*/_jsx(Box, {
|
150
149
|
component: "div",
|
151
150
|
ref: refs[1],
|
152
151
|
sx: classes.customSelectWrapper,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Box, Button, IconButton,
|
1
|
+
import { Box, Button, IconButton, Popper, Typography } from "@mui/material";
|
2
2
|
import React, { useRef, useState } from "react";
|
3
3
|
import { FaChevronRight } from "react-icons/fa";
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -49,9 +49,17 @@ function DisplayOption({
|
|
49
49
|
} = option;
|
50
50
|
const [open, setOpen] = useState(false);
|
51
51
|
const optionRef = useRef();
|
52
|
+
const openOptions = e => {
|
53
|
+
if (option.options?.length && !open) {
|
54
|
+
setOpen(e.currentTarget);
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
};
|
52
58
|
return /*#__PURE__*/_jsxs(Box, {
|
53
59
|
sx: classes.optionWrapper,
|
54
60
|
ref: optionRef,
|
61
|
+
onMouseEnter: openOptions,
|
62
|
+
onMouseLeave: () => setOpen(null),
|
55
63
|
children: [/*#__PURE__*/_jsxs(Button, {
|
56
64
|
sx: classes.optionBtn,
|
57
65
|
onClick: e => {
|
@@ -59,7 +67,7 @@ function DisplayOption({
|
|
59
67
|
|
60
68
|
// is having child options
|
61
69
|
if (option.options?.length) {
|
62
|
-
|
70
|
+
openOptions(e);
|
63
71
|
return;
|
64
72
|
}
|
65
73
|
setOpen(null);
|
@@ -77,25 +85,24 @@ function DisplayOption({
|
|
77
85
|
size: 12
|
78
86
|
})
|
79
87
|
})]
|
80
|
-
}), /*#__PURE__*/_jsx(
|
88
|
+
}), /*#__PURE__*/_jsx(Popper, {
|
81
89
|
open: open && option.options,
|
82
90
|
anchorEl: open,
|
83
91
|
sx: {
|
84
92
|
zIndex: 9001,
|
85
93
|
background: "transparent"
|
86
94
|
},
|
87
|
-
anchorOrigin: {
|
88
|
-
vertical: "top",
|
89
|
-
horizontal: "right"
|
90
|
-
},
|
91
95
|
onClose: () => {
|
92
96
|
setOpen(null);
|
93
97
|
},
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
98
|
+
placement: "right-start",
|
99
|
+
children: /*#__PURE__*/_jsx(Box, {
|
100
|
+
children: /*#__PURE__*/_jsx(CustomSelect, {
|
101
|
+
options: option.options,
|
102
|
+
onSend: onSend,
|
103
|
+
classes: classes,
|
104
|
+
show: open
|
105
|
+
})
|
99
106
|
})
|
100
107
|
})]
|
101
108
|
});
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
2
2
|
import { useEditorContext } from "../../hooks/useMouseMove";
|
3
3
|
import Styles from "./Styles";
|
4
|
-
import {
|
4
|
+
import { Fade, Paper, Popper } from "@mui/material";
|
5
5
|
import AIInput from "./AIInput";
|
6
6
|
import { ReactEditor, useSlate } from "slate-react";
|
7
7
|
import { Editor, Node, Path, Transforms } from "slate";
|
8
|
-
import useWindowResize from "../../hooks/useWindowResize";
|
9
8
|
import { MODES } from "./helper";
|
10
9
|
import { getSelectedText } from "../../utils/helper";
|
10
|
+
import { VoiceToText } from "./VoiceToText";
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
12
12
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
13
13
|
const scrollToAIInput = () => {
|
@@ -101,7 +101,8 @@ const updateAnchorEl = (setAnchorEl, editor) => {
|
|
101
101
|
// selected text as caret
|
102
102
|
caret = selection.getRangeAt(0);
|
103
103
|
} else {
|
104
|
-
|
104
|
+
const domElement = ReactEditor.toDOMRange(editor, getNextLine(editor).at);
|
105
|
+
caret = domElement?.commonAncestorContainer?.parentElement;
|
105
106
|
}
|
106
107
|
const getBoundingClientRect = () => {
|
107
108
|
const editorContainer = document.querySelector("#slate-wrapper-scroll-container")?.getBoundingClientRect();
|
@@ -147,7 +148,6 @@ function PopoverAIInput({
|
|
147
148
|
const targetRef = useRef();
|
148
149
|
const classes = Styles();
|
149
150
|
const editor = useSlate();
|
150
|
-
const [size] = useWindowResize();
|
151
151
|
const onClickOutside = () => {
|
152
152
|
setAnchorEl(null);
|
153
153
|
setOpenAI("");
|
@@ -178,6 +178,11 @@ function PopoverAIInput({
|
|
178
178
|
onClickOutside();
|
179
179
|
return;
|
180
180
|
}
|
181
|
+
if (type === "speech_to_text") {
|
182
|
+
Transforms.insertText(editor, option.text);
|
183
|
+
onClickOutside();
|
184
|
+
return;
|
185
|
+
}
|
181
186
|
if (type === "try_again") {
|
182
187
|
// resetting the previous option and try again
|
183
188
|
option = selectedOption;
|
@@ -188,7 +193,7 @@ function PopoverAIInput({
|
|
188
193
|
setLoading(true);
|
189
194
|
const payload = {
|
190
195
|
mode: option.mode || 0,
|
191
|
-
query: inputValue
|
196
|
+
query: option?.inputValue || inputValue
|
192
197
|
};
|
193
198
|
if (option.mode === MODES.translate || option.mode === MODES.rephraseTone) {
|
194
199
|
payload.textOptionInput = type;
|
@@ -263,21 +268,7 @@ function PopoverAIInput({
|
|
263
268
|
setInputValue(e.target.value);
|
264
269
|
};
|
265
270
|
return /*#__PURE__*/_jsxs("div", {
|
266
|
-
children: [
|
267
|
-
component: "div",
|
268
|
-
sx: classes.mobileAIInputWrapper,
|
269
|
-
ref: targetRef,
|
270
|
-
children: /*#__PURE__*/_jsx(AIInput, {
|
271
|
-
loading: loading,
|
272
|
-
onSend: onSend,
|
273
|
-
generatedText: generatedText,
|
274
|
-
anchorEl: anchorEl,
|
275
|
-
openAI: openAI,
|
276
|
-
inputValue: inputValue,
|
277
|
-
onInputChange: onInputChange,
|
278
|
-
onClickOutside: onClickOutside
|
279
|
-
})
|
280
|
-
}) : /*#__PURE__*/_jsx(Popper, {
|
271
|
+
children: [/*#__PURE__*/_jsx(Popper, {
|
281
272
|
open: Boolean(openAI),
|
282
273
|
anchorEl: anchorEl,
|
283
274
|
transition: true,
|
@@ -296,15 +287,19 @@ function PopoverAIInput({
|
|
296
287
|
sx: getSelectedText(editor) ? {
|
297
288
|
marginTop: "6px"
|
298
289
|
} : {},
|
299
|
-
children: /*#__PURE__*/_jsx(
|
300
|
-
|
290
|
+
children: /*#__PURE__*/_jsx(VoiceToText, {
|
291
|
+
otherProps: otherProps,
|
301
292
|
onSend: onSend,
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
293
|
+
children: /*#__PURE__*/_jsx(AIInput, {
|
294
|
+
loading: loading,
|
295
|
+
onSend: onSend,
|
296
|
+
generatedText: generatedText,
|
297
|
+
anchorEl: anchorEl,
|
298
|
+
openAI: openAI,
|
299
|
+
inputValue: inputValue,
|
300
|
+
onInputChange: onInputChange,
|
301
|
+
onClickOutside: onClickOutside
|
302
|
+
})
|
308
303
|
})
|
309
304
|
})
|
310
305
|
})
|