@flozy/editor 5.0.3 → 5.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,7 @@ import { useGrid, getChildCount } from "./Providers/GridProvider";
17
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
18
  import { Fragment as _Fragment } from "react/jsx-runtime";
19
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ let TT = null;
20
21
  const Resizer = ({
21
22
  classes,
22
23
  onMouseDown,
@@ -136,13 +137,20 @@ const GridItem = props => {
136
137
  const minWidthInPercent = isRightCol ? `${widths?.right}%` : cmWidth;
137
138
  useEffect(() => {
138
139
  try {
139
- if (columnRef?.current && (!parentDOM?.parentDOM || !minWidth)) {
140
- initDoms();
140
+ if (columnRef?.current && (!parentDOM?.parentDOM || !minWidth || lastChild)) {
141
+ initDoms(lastChild);
142
+ if (lastChild && childCount <= 2) {
143
+ Transforms.setNodes(editor, {
144
+ minWidth: null
145
+ }, {
146
+ at: path
147
+ });
148
+ }
141
149
  }
142
150
  } catch (err) {
143
151
  console.log(err);
144
152
  }
145
- }, [columnRef?.current, minWidth, childCount]);
153
+ }, [columnRef?.current, minWidth, childCount, lastChild]);
146
154
  useEffect(() => {
147
155
  if (isDone || isRightCol) {
148
156
  initDoms();
@@ -23,15 +23,6 @@ const GridStyles = (theme, appTheme) => ({
23
23
  flexWrap: "wrap"
24
24
  }
25
25
  },
26
- "&.cc-1": {
27
- "& .grid-item": {
28
- "&:last-child": {
29
- "& .col-width-resizer": {
30
- display: "block !important"
31
- }
32
- }
33
- }
34
- },
35
26
  "& .grid-item": {
36
27
  minWidth: "var(--minWidth)",
37
28
  maxWidth: "var(--minWidth)",
@@ -41,13 +41,14 @@ const SearchAttachment = props => {
41
41
  justifyContent: "flex-start",
42
42
  alignItems: "flex-end",
43
43
  width: "fit-content",
44
- maxWidth: '194px',
44
+ maxWidth: '250px',
45
45
  padding: "0px 10px",
46
46
  boxShadow: "none",
47
47
  border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
48
48
  borderRadius: "7px !important",
49
49
  background: theme?.palette?.containers?.slashBrainCardBg,
50
50
  cursor: 'pointer',
51
+ margin: '4px 0px',
51
52
  "&.MuiPaper-root.MuiPaper-rounded": {
52
53
  borderRadius: "7px !important",
53
54
  paddingTop: '0px !important'
@@ -91,7 +92,7 @@ const SearchAttachment = props => {
91
92
  whiteSpace: 'nowrap',
92
93
  overflow: 'hidden',
93
94
  wordBreak: "break-word",
94
- maxWidth: '150px',
95
+ maxWidth: '210px',
95
96
  lineHeight: 1.43,
96
97
  "&::selection": {
97
98
  WebkitTextFillColor: "#000"
@@ -113,7 +113,7 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
113
113
  sx: {
114
114
  width: '100%',
115
115
  background: theme?.palette?.editor?.miniToolBarBackground,
116
- borderColor: theme?.palette?.type === 'dark' ? theme?.palette?.editor?.popUpBorderColor : 'transparent'
116
+ boxShadow: 'none'
117
117
  },
118
118
  children: /*#__PURE__*/_jsx(SearchAndDocList, {
119
119
  mapData: mapData,
@@ -149,8 +149,13 @@ const SearchButton = /*#__PURE__*/forwardRef((props, ref) => {
149
149
  border: '1px solid',
150
150
  borderColor: theme?.palette?.type === 'dark' ? theme?.palette?.editor?.popUpBorderColor : 'transparent',
151
151
  borderRadius: '12px',
152
+ boxShadow: theme?.palette?.type === 'dark' ? 'transparent' : '0px 4px 10px 0px #00000029',
152
153
  '&.MuiPaper-root-MuiPopover-paper': {
153
- borderRadius: '12px !important'
154
+ borderRadius: '12px !important',
155
+ boxShadow: theme?.palette?.type === 'dark' ? 'transparent' : '0px 4px 10px 0px #00000029'
156
+ },
157
+ '@media only screen and (min-width: 350px) and (max-width: 599px)': {
158
+ width: '100%'
154
159
  }
155
160
  },
156
161
  children: /*#__PURE__*/_jsx(SearchAndDocList, {
@@ -13,6 +13,7 @@ const SearchAndDocList = ({
13
13
  theme,
14
14
  handleClose
15
15
  }) => {
16
+ const isMobile = window.matchMedia("(max-width: 899px)")?.matches || false;
16
17
  return /*#__PURE__*/_jsxs(_Fragment, {
17
18
  children: [/*#__PURE__*/_jsxs(Box, {
18
19
  display: "flex",
@@ -28,25 +29,29 @@ const SearchAndDocList = ({
28
29
  color: theme?.palette?.primary?.main
29
30
  },
30
31
  children: "Brains"
31
- }), /*#__PURE__*/_jsx(IconButton, {
32
+ }), !isMobile ? /*#__PURE__*/_jsx(IconButton, {
32
33
  onClick: e => {
33
34
  e.stopPropagation();
34
35
  handleClose();
35
36
  },
36
37
  sx: {
37
38
  borderRadius: "6px",
38
- backgroundColor: theme?.palette?.editor?.miniToolBarBackground,
39
- border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
40
- padding: "5px",
39
+ backgroundColor: theme?.palette.type === 'dark' ? theme?.palette?.editor?.sectionSettingIconHover : theme?.palette?.editor?.sectionSettingIconHover,
40
+ padding: "3px",
41
41
  "&:hover": {
42
42
  backgroundColor: theme?.palette?.editor?.sectionSettingIconHover,
43
43
  background: theme?.palette?.editor?.sectionSettingIconHover
44
+ },
45
+ '& svg': {
46
+ '& path': {
47
+ stroke: theme?.palette?.editor?.closeButtonSvgStroke
48
+ }
44
49
  }
45
50
  },
46
51
  children: /*#__PURE__*/_jsx(Icon, {
47
52
  icon: "closeIcon"
48
53
  })
49
- })]
54
+ }) : null]
50
55
  }), /*#__PURE__*/_jsx(Box, {
51
56
  sx: {
52
57
  padding: '0px 16px'
@@ -70,34 +75,48 @@ const SearchAndDocList = ({
70
75
  startAdornment: /*#__PURE__*/_jsx(InputAdornment, {
71
76
  position: "start",
72
77
  children: /*#__PURE__*/_jsx(SearchIcon, {})
73
- })
78
+ }),
79
+ sx: {
80
+ color: theme?.palette?.text?.secondary2,
81
+ fontSize: '14px'
82
+ }
74
83
  },
75
84
  sx: {
76
85
  borderRadius: "8px",
86
+ fontSize: '14px',
87
+ color: theme?.palette?.text?.secondary2,
77
88
  "& .MuiOutlinedInput-root": {
78
- color: theme?.palette?.primary?.main,
89
+ color: `${theme?.palette?.text?.secondary2} !important`,
79
90
  boxShadow: theme?.palette?.shadows?.shadow12,
80
- backgroundColor: theme?.palette?.editor?.miniToolBarBackground,
91
+ backgroundColor: theme?.palette?.editor?.inputFieldBgColor,
92
+ fontSize: '14px',
81
93
  "&:hover .MuiOutlinedInput-notchedOutline": {
82
94
  borderRadius: "8px",
83
95
  border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
84
96
  borderColor: theme?.palette?.primary?.slashBrainBorder
85
97
  },
86
98
  "&.Mui-focused .MuiOutlinedInput-notchedOutline": {
99
+ color: theme?.palette?.text?.secondary2,
87
100
  borderRadius: "8px",
88
101
  border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
89
102
  borderColor: `${theme?.palette?.primary?.slashBrainBorder} !important`
90
103
  }
91
104
  },
92
105
  '& .MuiOutlinedInput-notchedOutline': {
106
+ color: theme?.palette?.text?.secondary2,
93
107
  borderRadius: "8px",
94
108
  border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
95
- borderColor: theme?.palette?.primary?.slashBrainBorder
109
+ borderColor: theme?.palette?.primary?.slashBrainBorder,
110
+ fontSize: '14px'
96
111
  },
97
112
  '& .MuiInputBase-root': {
98
- borderRadius: '8px'
113
+ color: theme?.palette?.text?.secondary2,
114
+ borderRadius: '8px',
115
+ fontSize: '14px'
99
116
  },
100
117
  "& svg": {
118
+ width: '16px',
119
+ height: '16px',
101
120
  "& path": {
102
121
  stroke: theme?.palette?.text?.text6
103
122
  }
@@ -116,23 +135,25 @@ const SearchAndDocList = ({
116
135
  padding: '0px 16px 8px',
117
136
  marginBottom: '20px',
118
137
  scrollbarWidth: "thin",
119
- scrollbarColor: `${theme?.palette?.primary?.slashBrainBorder} transparent`,
138
+ scrollbarColor: `${theme?.palette?.editor?.brainPopupScroll} transparent`,
120
139
  "&::-webkit-scrollbar": {
121
- width: "3px",
140
+ width: "3px !important",
122
141
  height: "3px !important",
123
142
  borderRadius: "10px !important"
124
143
  },
125
144
  "&::-webkit-scrollbar-thumb": {
126
- backgroundColor: theme?.palette?.primary?.slashBrainBorder,
145
+ backgroundColor: theme?.palette?.editor?.brainPopupScroll,
127
146
  borderRadius: "10px !important",
128
147
  width: "3px !important"
129
148
  },
130
149
  "&::-webkit-scrollbar-thumb:hover": {
131
- backgroundColor: theme?.palette?.primary?.slashBrainBorder
150
+ backgroundColor: theme?.palette?.editor?.brainPopupScroll,
151
+ width: "3px !important"
132
152
  },
133
153
  "&::-webkit-scrollbar-track": {
134
154
  background: "transparent",
135
- borderRadius: "10px !important"
155
+ borderRadius: "10px !important",
156
+ width: "3px !important"
136
157
  }
137
158
  },
138
159
  children: [mapData?.map((doc, index) => {
@@ -145,19 +166,29 @@ const SearchAndDocList = ({
145
166
  border: `1px solid ${theme?.palette?.primary?.slashBrainBorder}`,
146
167
  borderRadius: '8px',
147
168
  padding: '6px 10px',
148
- cursor: 'pointer'
169
+ cursor: 'pointer',
170
+ backgroundColor: theme?.palette?.editor?.inputFieldBgColor,
171
+ '@media only screen and (min-width: 350px) and (max-width: 599px)': {
172
+ overflow: 'hidden'
173
+ }
149
174
  },
150
175
  onClick: () => handleClick(doc),
151
176
  children: /*#__PURE__*/_jsxs(Grid, {
152
177
  container: true,
153
178
  alignItems: "center",
154
179
  justifyContent: 'space-between',
180
+ sx: {
181
+ flexWrap: 'nowrap'
182
+ },
155
183
  gap: 1,
156
184
  children: [/*#__PURE__*/_jsx(Grid, {
157
185
  item: true,
158
186
  children: /*#__PURE__*/_jsxs(Grid, {
159
187
  container: true,
160
188
  alignItems: "center",
189
+ sx: {
190
+ flexWrap: 'nowrap'
191
+ },
161
192
  gap: 1,
162
193
  children: [/*#__PURE__*/_jsx(Grid, {
163
194
  item: true,
@@ -184,7 +215,10 @@ const SearchAndDocList = ({
184
215
  overflow: 'hidden',
185
216
  wordBreak: "break-word",
186
217
  maxWidth: '230px',
187
- textAlign: 'left'
218
+ textAlign: 'left',
219
+ '@media only screen and (min-width: 350px) and (max-width: 899px)': {
220
+ maxWidth: '100%'
221
+ }
188
222
  },
189
223
  children: title
190
224
  })
@@ -15,7 +15,7 @@ const FontLoader = props => {
15
15
  let retryCount = 0;
16
16
  function loadNextBatch() {
17
17
  if (currentIndex >= families?.length) {
18
- console.log("All fonts have been loaded");
18
+ // console.log("All fonts have been loaded");
19
19
  return;
20
20
  }
21
21
  const batch = families?.slice(currentIndex, currentIndex + batchSize);
@@ -1,6 +1,7 @@
1
- import { Autocomplete, Checkbox, FormControlLabel, MenuItem, Select, TextField, Typography, createFilterOptions } from "@mui/material";
1
+ import { Autocomplete, Checkbox, FormControlLabel, MenuItem, TextField, Typography, createFilterOptions } from "@mui/material";
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { useSlate } from "slate-react";
4
+ import Select from "../Select";
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  import { Fragment as _Fragment } from "react/jsx-runtime";
6
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -5,13 +5,14 @@ import DialogContent from "@mui/material/DialogContent";
5
5
  import DialogActions from "@mui/material/DialogActions";
6
6
  import IconButton from "@mui/material/IconButton";
7
7
  import CloseIcon from "@mui/icons-material/Close";
8
- import { Box, FormControl, FormControlLabel, Grid, MenuItem, Radio, RadioGroup, Select, Typography } from "@mui/material";
8
+ import { Box, FormControl, FormControlLabel, Grid, MenuItem, Radio, RadioGroup, Typography } from "@mui/material";
9
9
  import { useState } from "react";
10
10
  import LinkSettingsStyles from "./style";
11
11
  import { getNavOptions } from "./navOptions";
12
12
  import { ScrollTopBottom, SelectPage, TextInput, Trigger } from "./NavComponents";
13
13
  import SwipeableDrawer from "../SwipeableDrawer";
14
14
  import { useEditorContext } from "../../hooks/useMouseMove";
15
+ import Select from "../Select";
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
16
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
18
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -13,13 +13,21 @@ const usePopupStyles = theme => ({
13
13
  "& .MuiBox-root": {
14
14
  "& .renderComp": {
15
15
  padding: "2px 0px 2px 1px",
16
- background: "transparent !important"
16
+ background: "transparent !important",
17
+ "&:hover": {
18
+ borderRadius: "10px",
19
+ background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
20
+ }
17
21
  },
18
22
  "& button": {
19
- padding: "0px 0px 0px 6px",
23
+ padding: "0px 0px 0px 4px !important",
20
24
  "& svg": {
21
- // width: "19px !important",
22
- paddingRight: "6px"
25
+ width: "18px !important",
26
+ margin: "5px 12px 6px 6px !important"
27
+ },
28
+ "&:hover": {
29
+ borderRadius: "10px",
30
+ background: `${theme?.palette?.editor?.menuOptionHoverBackground} !important`
23
31
  }
24
32
  },
25
33
  "& .active": {
@@ -0,0 +1,20 @@
1
+ import { Select as Core } from "@mui/material";
2
+ import SelectStyles from "./styles";
3
+ import { useEditorContext } from "../../hooks/useMouseMove";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ function Select(props) {
6
+ const {
7
+ children,
8
+ ...rest
9
+ } = props;
10
+ const {
11
+ theme
12
+ } = useEditorContext();
13
+ const classes = SelectStyles(theme);
14
+ return /*#__PURE__*/_jsx(Core, {
15
+ MenuProps: classes.MenuProps,
16
+ ...rest,
17
+ children: children
18
+ });
19
+ }
20
+ export default Select;
@@ -0,0 +1,17 @@
1
+ const SelectStyles = (theme = {}) => {
2
+ const {
3
+ textColor,
4
+ background
5
+ } = theme?.palette?.editor || {};
6
+ return {
7
+ MenuProps: {
8
+ PaperProps: {
9
+ sx: {
10
+ color: textColor,
11
+ background
12
+ }
13
+ }
14
+ }
15
+ };
16
+ };
17
+ export default SelectStyles;
@@ -6,7 +6,7 @@ const Styles = theme => ({
6
6
  "& .MuiDrawer-paper": {
7
7
  borderTopLeftRadius: 8,
8
8
  borderTopRightRadius: 8,
9
- backgroundColor: theme.palette.containers.card
9
+ backgroundColor: theme?.palette?.editor?.miniToolBarBackground
10
10
  }
11
11
  },
12
12
  childContainer: {
@@ -329,14 +329,14 @@ export const isCarouselSelected = editor => {
329
329
  return false;
330
330
  }
331
331
  const [nodeEntry] = Editor.nodes(editor, {
332
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === 'carousel'
332
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "carousel"
333
333
  });
334
334
  if (!nodeEntry) {
335
335
  return false;
336
336
  }
337
337
  const [node] = nodeEntry;
338
338
  const carouselDom = ReactEditor.toDOMNode(editor, node);
339
- const isEdit = carouselDom.classList.contains('carousel_slider_edit');
339
+ const isEdit = carouselDom.classList.contains("carousel_slider_edit");
340
340
  return !isEdit;
341
341
  } catch (err) {
342
342
  console.log(err);
@@ -22,8 +22,7 @@ const withEmbeds = editor => {
22
22
  const parentNode = Node.get(editor, parentPath);
23
23
  const previousPath = Path.previous(parentPath);
24
24
  const previousNode = Node.get(editor, previousPath);
25
- if (BlockTypes.includes(previousNode?.children[0]?.type) && parentNode?.type?.indexOf("heading") >= 0) {
26
- console.log("grid is in previous", parentPath, previousPath, [...args]);
25
+ if (BlockTypes.includes(previousNode?.children[0]?.type) && parentNode?.type?.indexOf("heading") >= 0 && editor.selection.focus.offset === 0) {
27
26
  insertNodes(...[{
28
27
  type: "paragraph",
29
28
  children: [{
@@ -56,8 +56,55 @@ const withLayout = editor => {
56
56
  }]
57
57
  };
58
58
  Transforms.insertNodes(editor, paragraph, {
59
- at: path.concat(1)
59
+ at: [0]
60
60
  });
61
+ return;
62
+ }
63
+ const extractFirstText = node => {
64
+ if (node.text) {
65
+ return node.text;
66
+ }
67
+ if (node.children) {
68
+ for (const child of node.children) {
69
+ const text = extractFirstText(child);
70
+ if (text) {
71
+ return text;
72
+ }
73
+ }
74
+ }
75
+ return "";
76
+ };
77
+ const extractRemainingNodes = node => {
78
+ if (!node.children) {
79
+ return [];
80
+ }
81
+ const [, ...remainingChildren] = node.children;
82
+ return remainingChildren.map(child => ({
83
+ ...child
84
+ }));
85
+ };
86
+ const firstNode = editor.children[0];
87
+ const firstContent = extractFirstText(firstNode);
88
+ if (firstNode.type !== "title") {
89
+ const titleNode = {
90
+ type: "title",
91
+ children: [{
92
+ text: firstContent
93
+ }]
94
+ };
95
+ Transforms.removeNodes(editor, {
96
+ at: [0]
97
+ });
98
+ Transforms.insertNodes(editor, titleNode, {
99
+ at: [0],
100
+ select: true
101
+ });
102
+ const remainingNodes = extractRemainingNodes(firstNode);
103
+ if (remainingNodes.length > 0) {
104
+ Transforms.insertNodes(editor, remainingNodes, {
105
+ at: [1]
106
+ });
107
+ }
61
108
  }
62
109
  ORDERS_LAYOUT.forEach((enforce, index) => {
63
110
  if (index < editor.children.length) {
@@ -1,4 +1,4 @@
1
- import { Editor, Node, Transforms, Element, Path, Range } from "slate";
1
+ 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";
@@ -110,11 +110,34 @@ export const isEmptyNode = (editor, children, path) => {
110
110
  }
111
111
  };
112
112
  export const outsideEditorClickLabel = "handle-outside-editor-click";
113
+ function isLastChildParagraphWithText(node) {
114
+ try {
115
+ if (!node || !Array.isArray(node.children)) {
116
+ return false;
117
+ }
118
+
119
+ // Get the last child node
120
+ const lastChild = node.children[node.children.length - 1];
121
+
122
+ // Check if the last child exists and is of type 'paragraph'
123
+ if (lastChild && lastChild.type === "paragraph") {
124
+ // Ensure all children of the paragraph node are text nodes
125
+ const hasOnlyTextChildren = lastChild.children.every(child => Text.isText(child));
126
+ console.log(hasOnlyTextChildren);
127
+ return hasOnlyTextChildren;
128
+ }
129
+ return false;
130
+ } catch (err) {
131
+ console.log(err);
132
+ return false;
133
+ }
134
+ }
113
135
  const insertNewLineOnColumn = (editor, pathStr) => {
114
136
  try {
115
137
  const path = pathStr.split(",").map(m => parseInt(m));
116
138
  const colNode = Node.get(editor, path);
117
- if (colNode?.type === "grid-item") {
139
+ const isValid = isLastChildParagraphWithText(colNode);
140
+ if (colNode?.type === "grid-item" && !isValid) {
118
141
  const newPath = [...path, colNode?.children.length];
119
142
  Transforms.insertNodes(editor, [{
120
143
  type: "paragraph",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"