@flozy/editor 3.3.0 → 3.3.2

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.
@@ -0,0 +1,145 @@
1
+ import { ActionItemsIcon, BookIcon, CheckIcon,
2
+ // ClarifyIcon,
3
+ CloseIcon, DeleteIcon,
4
+ // EditIcon,
5
+ MakeShorterIcon, SummarizeIcon, TextAlignLeftIcon, ToneIcon, TranslateIcon, TryAgainIcon } from "../../assets/svg/AIIcons";
6
+ export const MODES = {
7
+ default: 0,
8
+ translate: 1,
9
+ summarize: 2,
10
+ actionItems: 3,
11
+ grammatical: 4,
12
+ rephraseTone: 5,
13
+ longer: 6,
14
+ shorter: 7
15
+ };
16
+
17
+ // const improveWriting = {
18
+ // label: "Improve writing",
19
+ // value: "improve_writing",
20
+ // Icon: EditIcon,
21
+ // replace: true,
22
+ // };
23
+
24
+ const commonOptions = [{
25
+ label: "Make longer",
26
+ value: "make_longer",
27
+ Icon: TextAlignLeftIcon,
28
+ replace: false,
29
+ mode: MODES.longer
30
+ }, {
31
+ label: "Make shorter",
32
+ value: "make_shorter",
33
+ Icon: MakeShorterIcon,
34
+ replace: false,
35
+ mode: MODES.shorter
36
+ }
37
+ // {
38
+ // label: "Continue writing",
39
+ // value: "continue_writing",
40
+ // Icon: EditIcon,
41
+ // replace: false,
42
+ // },
43
+ ];
44
+
45
+ export const newContentOptions = [{
46
+ group: "",
47
+ groupLabel: "",
48
+ options: [
49
+ // improveWriting,
50
+ ...commonOptions.map(o => ({
51
+ ...o,
52
+ replace: true
53
+ })), {
54
+ label: "Close",
55
+ value: "close",
56
+ Icon: CloseIcon,
57
+ replace: true
58
+ }]
59
+ }];
60
+ const languages = ["English", "Korean", "Chinese", "Japanese", "Russian", "French", "Portuguese", "German", "Italian", "Dutch", "Indonesian"];
61
+ const translateOptions = [{
62
+ options: languages.map(l => ({
63
+ label: l,
64
+ value: l,
65
+ replace: false,
66
+ mode: MODES.translate
67
+ }))
68
+ }];
69
+ const tones = ["Professional", "Casual", "Straightforward", "Friendly"];
70
+ const toneOptions = [{
71
+ options: tones.map(t => ({
72
+ label: t,
73
+ value: t,
74
+ replace: false,
75
+ mode: MODES.rephraseTone
76
+ }))
77
+ }];
78
+ export const editContentOptions = [{
79
+ group: "",
80
+ groupLabel: "Regenerate page",
81
+ options: [{
82
+ label: "Translate",
83
+ value: "translate",
84
+ Icon: TranslateIcon,
85
+ options: translateOptions,
86
+ replace: false
87
+ }, {
88
+ label: "Summarize",
89
+ value: "summarize",
90
+ Icon: SummarizeIcon,
91
+ replace: false,
92
+ mode: MODES.summarize
93
+ },
94
+ // {
95
+ // label: "Clarify this",
96
+ // value: "clarify",
97
+ // Icon: ClarifyIcon,
98
+ // replace: false,
99
+ // },
100
+ {
101
+ label: "Find action items",
102
+ value: "action_items",
103
+ Icon: ActionItemsIcon,
104
+ replace: false,
105
+ mode: MODES.actionItems
106
+ }]
107
+ }, {
108
+ group: "",
109
+ groupLabel: "Edit or review page",
110
+ options: [{
111
+ label: "Fix spelling & grammar",
112
+ value: "spelling_&_grammar",
113
+ Icon: BookIcon,
114
+ replace: false,
115
+ mode: MODES.grammatical
116
+ },
117
+ // { ...improveWriting, replace: false },
118
+ ...commonOptions, {
119
+ label: "Change tone",
120
+ value: "change_tone",
121
+ Icon: ToneIcon,
122
+ options: toneOptions,
123
+ replace: false
124
+ }]
125
+ }];
126
+ export const generatedContentOptions = [{
127
+ group: "",
128
+ groupLabel: "",
129
+ options: [{
130
+ label: "Replace selection",
131
+ value: "replace_selection",
132
+ Icon: CheckIcon,
133
+ replace: true
134
+ }, ...commonOptions, {
135
+ label: "Try again",
136
+ value: "try_again",
137
+ Icon: TryAgainIcon,
138
+ replace: false
139
+ }, {
140
+ label: "Delete",
141
+ value: "close",
142
+ Icon: DeleteIcon,
143
+ replace: false
144
+ }]
145
+ }];
@@ -1,16 +1,9 @@
1
1
  export const validationMethods = {
2
2
  isEmail: value => {
3
- const regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; //eslint-disable-line
4
- const result = regex.test(String(value).toLowerCase());
5
- if (result) {
6
- let domain = String(value).toLowerCase().split('@')[1];
7
- let validExtensions = ['com', 'net', 'org', 'edu'];
8
- let extension = domain.split('.').pop();
9
- if (validExtensions.includes(extension)) {
10
- return "";
11
- } else {
12
- return "Enter valid email address";
13
- }
3
+ const regex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
4
+ const isValidEmail = regex.test(String(value).toLowerCase());
5
+ if (isValidEmail) {
6
+ return "";
14
7
  } else {
15
8
  return "Enter valid email address";
16
9
  }
@@ -0,0 +1,24 @@
1
+ import { Box, IconButton } from "@mui/material";
2
+ import Icon from "../../../common/Icon";
3
+ import { useEditorContext } from "../../../hooks/useMouseMove";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ function InfinityAITool() {
6
+ const {
7
+ setOpenAI
8
+ } = useEditorContext();
9
+ return /*#__PURE__*/_jsx(Box, {
10
+ component: "div",
11
+ children: /*#__PURE__*/_jsx(IconButton, {
12
+ onClick: () => {
13
+ const text = window.getSelection().toString().trim();
14
+ if (text) {
15
+ setOpenAI("fromToolBar");
16
+ }
17
+ },
18
+ children: /*#__PURE__*/_jsx(Icon, {
19
+ icon: "infinityIcon"
20
+ })
21
+ })
22
+ });
23
+ }
24
+ export default InfinityAITool;
@@ -13,6 +13,7 @@ import PopperHeader from "../PopperHeader";
13
13
  import MiniColorPicker from "./MiniColorPicker";
14
14
  import SelectAlignment from "./SelectAlignment";
15
15
  import SelectFontSize from "./SelectFontSize";
16
+ import InfinityAITool from "./InfinityAITool";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
19
  const DEFAULT_COLOR = {
@@ -26,7 +27,8 @@ const MiniTextFormat = props => {
26
27
  const {
27
28
  classes,
28
29
  editor,
29
- closeMainPopup
30
+ closeMainPopup,
31
+ customProps
30
32
  } = props;
31
33
  const [anchorEl, setAnchorEl] = useState(null);
32
34
  const open = Boolean(anchorEl);
@@ -48,7 +50,7 @@ const MiniTextFormat = props => {
48
50
  xs: 12,
49
51
  children: /*#__PURE__*/_jsxs("div", {
50
52
  className: "toolWrapper",
51
- children: [/*#__PURE__*/_jsx(SelectTypography, {
53
+ children: [customProps?.hideTools?.includes("infinityAI") ? null : /*#__PURE__*/_jsx(InfinityAITool, {}), /*#__PURE__*/_jsx(SelectTypography, {
52
54
  classes: classes,
53
55
  editor: editor,
54
56
  closeMainPopup: closeMainPopup
@@ -2,22 +2,24 @@ import React, { useEffect, useState } from "react";
2
2
  import { Popper, Fade, Paper } from "@mui/material";
3
3
  import { Editor, Range } from "slate";
4
4
  import { useSlate, useFocused } from "slate-react";
5
- import usePopupStyle from "./PopupToolStyle";
6
5
  import useDrag from "../../hooks/useDrag";
7
6
  import { TableUtil } from "../../utils/table";
8
7
  import useWindowResize from "../../hooks/useWindowResize";
9
8
  import MiniTextFormat from "./MiniTextFormat";
10
9
  import { useEditorContext } from "../../hooks/useMouseMove";
10
+ import usePopupStyles from "../PopupTool/PopupToolStyle";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { Fragment as _Fragment } from "react/jsx-runtime";
13
13
  const PopupTool = props => {
14
14
  const {
15
15
  theme,
16
- setIsTextSelected
16
+ setIsTextSelected,
17
+ customProps
17
18
  } = props;
18
- const classes = usePopupStyle(theme);
19
+ const classes = usePopupStyles(theme);
19
20
  const {
20
- setPopupType
21
+ setPopupType,
22
+ openAI
21
23
  } = useEditorContext();
22
24
  const [anchorEl, setAnchorEl] = useState(null);
23
25
  const [open, setOpen] = useState(false);
@@ -77,13 +79,14 @@ const PopupTool = props => {
77
79
  setOpen(false);
78
80
  setPopupType("");
79
81
  };
80
- return open ? /*#__PURE__*/_jsx(_Fragment, {
82
+ return open && !openAI ? /*#__PURE__*/_jsx(_Fragment, {
81
83
  children: size.device === "xs" ? /*#__PURE__*/_jsx("div", {
82
84
  className: "mobileMiniTextWrapper",
83
85
  children: /*#__PURE__*/_jsx(MiniTextFormat, {
84
86
  editor: editor,
85
87
  classes: classes,
86
- closeMainPopup: handleClose
88
+ closeMainPopup: handleClose,
89
+ customProps: customProps
87
90
  })
88
91
  }) : /*#__PURE__*/_jsx(Popper, {
89
92
  id: id,
@@ -104,7 +107,8 @@ const PopupTool = props => {
104
107
  children: /*#__PURE__*/_jsx(MiniTextFormat, {
105
108
  editor: editor,
106
109
  classes: classes,
107
- closeMainPopup: handleClose
110
+ closeMainPopup: handleClose,
111
+ customProps: customProps
108
112
  })
109
113
  })
110
114
  })