@flozy/editor 2.0.7 → 2.0.9

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.
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle } from "react";
3
- import { createEditor, Editor, Transforms } from "slate";
3
+ import { createEditor, Transforms } from "slate";
4
4
  import { Slate, Editable, ReactEditor } from "slate-react";
5
5
  import { useDebounce } from "use-debounce";
6
6
  import { getMarked, getBlock } from "./utils/SlateUtilityFunctions";
@@ -129,7 +129,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
129
129
  }
130
130
  };
131
131
  const classes = editorStyles({
132
- padHeight: !fullScreen ? otherProps?.padHeight : 120,
132
+ padHeight: !fullScreen ? otherProps?.padHeight : 20,
133
133
  placeHolderColor: invertColor(pageColor || "#FFF"),
134
134
  theme
135
135
  });
@@ -41,9 +41,6 @@ const DialogWrapper = props => {
41
41
  })
42
42
  })
43
43
  }), /*#__PURE__*/_jsx(DialogContent, {
44
- style: {
45
- paddingTop: "12px"
46
- },
47
44
  children: children
48
45
  })]
49
46
  }) : children;
@@ -1102,3 +1102,10 @@ blockquote {
1102
1102
  0 0 #e3aad6;
1103
1103
  }
1104
1104
  }
1105
+
1106
+ .doublequote::before {
1107
+ content: '\201C';
1108
+ }
1109
+ .doublequote::after {
1110
+ content: '\201D';
1111
+ }
@@ -165,7 +165,7 @@ const EditorButton = props => {
165
165
  background: bgColor || "rgb(30, 75, 122)",
166
166
  borderBlockStyle: "solid",
167
167
  borderColor: borderColor || "transparent",
168
- borderWidth: borderWidth || "1px",
168
+ borderWidth: borderWidth !== undefined ? borderWidth : borderColor ? "1px" : "0px",
169
169
  borderRadius: {
170
170
  ...getBreakPointsValue(borderRadius || {}, null, "overrideBorderRadius", true)
171
171
  },
@@ -27,7 +27,8 @@ const Video = ({
27
27
  borderColor,
28
28
  borderStyle,
29
29
  url,
30
- xsHidden
30
+ xsHidden,
31
+ width: oldWidth
31
32
  } = element;
32
33
  const editor = useSlateStatic();
33
34
  const [openSetttings, setOpenSettings] = useState(false);
@@ -40,9 +41,18 @@ const Video = ({
40
41
  horizantal
41
42
  } = alignment || {};
42
43
  const path = ReactEditor.findPath(editor, element);
44
+ const getSize = () => {
45
+ if (element?.size === undefined) {
46
+ return {
47
+ widthInPercent: parseInt(oldWidth)
48
+ };
49
+ } else {
50
+ return element?.size || {};
51
+ }
52
+ };
43
53
  const [size, onMouseDown, resizing, onLoad] = useResize({
44
54
  parentDOM,
45
- size: element?.size,
55
+ size: getSize(),
46
56
  onChange: uSize => {
47
57
  Transforms.setNodes(editor, {
48
58
  size: uSize
@@ -113,10 +123,10 @@ const Video = ({
113
123
  } else {
114
124
  return {
115
125
  width: {
116
- ...getBreakPointsValue(element?.size, null, "overrideReSize", true)
126
+ ...getBreakPointsValue(getSize(), null, "overrideReSize", true)
117
127
  },
118
128
  height: url ? {
119
- ...getBreakPointsValue(element?.size, null, "overrideReSizeH", true)
129
+ ...getBreakPointsValue(getSize(), null, "overrideReSizeH", true)
120
130
  } : "auto"
121
131
  };
122
132
  }
@@ -175,6 +185,8 @@ const Video = ({
175
185
  xs: xsHidden ? "none" : "flex"
176
186
  },
177
187
  flexDirection: "row",
188
+ flexWrap: "wrap",
189
+ // to support oldWidth with link
178
190
  width: `100%`,
179
191
  justifyContent: horizantal,
180
192
  alignContent: vertical
@@ -323,7 +323,7 @@ const Grid = props => {
323
323
  flexWrap: {
324
324
  ...getBreakPointsValue(flexWrap || "wrap")
325
325
  },
326
- height: "fit-content"
326
+ height: "auto"
327
327
  },
328
328
  "data-path": path.join(","),
329
329
  children: children
@@ -51,7 +51,6 @@ const GridItem = props => {
51
51
  const selected = hoverPath === path.join(",");
52
52
  const [showTool] = useEditorSelection(editor);
53
53
  const isEmpty = !readOnly && isEmptyNode(editor, element?.children, path) ? "empty" : "";
54
- console.log(cellGHeight);
55
54
  const GridItemToolbar = () => {
56
55
  return selected && !showTool ? /*#__PURE__*/_jsx("div", {
57
56
  contentEditable: false,
@@ -234,8 +234,11 @@ const editorStyles = ({
234
234
  "& .MuiDialogTitle-root": {
235
235
  position: "absolute",
236
236
  top: 0,
237
- right: "12px",
237
+ right: "0px",
238
238
  zIndex: 100
239
+ },
240
+ "& .MuiDialogContent-root": {
241
+ padding: "0px"
239
242
  }
240
243
  }
241
244
  }
@@ -1,19 +1,27 @@
1
1
  import React from "react";
2
2
  import Icon from "../../common/Icon";
3
3
  import Button from "../../common/Button";
4
- import { toggleBlock, isBlockActive } from "../../utils/SlateUtilityFunctions.js";
4
+ import { toggleBlock, isBlockActive, isMarkActive, toggleMark } from "../../utils/SlateUtilityFunctions.js";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
- const BlockButton = ({
7
- editor,
8
- format,
9
- title
10
- }) => {
6
+ const MARK_TYPES = ["doublequote"];
7
+ const BlockButton = props => {
8
+ const {
9
+ editor,
10
+ format,
11
+ title
12
+ } = props;
13
+ const isMark = MARK_TYPES?.indexOf(format) >= 0;
14
+ const isActive = isMark ? isMarkActive(editor, format) : isBlockActive(editor, format);
11
15
  return /*#__PURE__*/_jsx(Button, {
12
- active: isBlockActive(editor, format),
16
+ active: isActive,
13
17
  format: format,
14
18
  onMouseDown: e => {
15
19
  e.preventDefault();
16
- toggleBlock(editor, format);
20
+ if (isMark) {
21
+ toggleMark(editor, format);
22
+ } else {
23
+ toggleBlock(editor, format);
24
+ }
17
25
  },
18
26
  title: title,
19
27
  children: /*#__PURE__*/_jsx(Icon, {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Grid } from "@mui/material";
2
+ import { Grid, Box } from "@mui/material";
3
3
  import { toolbarGroups } from "../toolbarGroups";
4
4
  import { RenderToolbarIcon } from "../Toolbar";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -17,6 +17,7 @@ const AddElements = props => {
17
17
  const filteredElements = elements.filter(f => (hideTools || []).indexOf(f.type) === -1);
18
18
  return /*#__PURE__*/_jsx(Grid, {
19
19
  container: true,
20
+ className: "elements-wrpr-pp",
20
21
  sx: classes.textFormatWrapper,
21
22
  spacing: 2,
22
23
  style: {
@@ -24,8 +25,11 @@ const AddElements = props => {
24
25
  },
25
26
  children: filteredElements.map(m => {
26
27
  return /*#__PURE__*/_jsx(Grid, {
28
+ className: "ele-item-single",
27
29
  item: true,
28
30
  xs: 6,
31
+ md: 4,
32
+ lg: 4,
29
33
  children: /*#__PURE__*/_jsx(RenderToolbarIcon, {
30
34
  editor: editor,
31
35
  element: m,
@@ -5,6 +5,14 @@ import FullViewCard from "./FullViewCard";
5
5
  import ButtonTemplateCard from "./ButtonTemplatesCard";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ const CATEGORIES_SORT_INDEX = {
9
+ Brief: 1,
10
+ Buttons: 2,
11
+ Banners: 3,
12
+ Tables: 4,
13
+ Contract: 5,
14
+ Proposal: 6
15
+ };
8
16
  const Categories = props => {
9
17
  const {
10
18
  value,
@@ -65,6 +73,9 @@ const AddTemplates = props => {
65
73
  useEffect(() => {
66
74
  getTemplatesList();
67
75
  }, []);
76
+ const sortCategory = (a, b) => {
77
+ return (CATEGORIES_SORT_INDEX[a] || Infinity) - (CATEGORIES_SORT_INDEX[b] || Infinity);
78
+ };
68
79
  const getTemplatesList = async () => {
69
80
  setLoading(true);
70
81
  const result = await services("listTemplates", {});
@@ -74,7 +85,7 @@ const AddTemplates = props => {
74
85
  a.push(b.category);
75
86
  }
76
87
  return a;
77
- }, []);
88
+ }, []).sort(sortCategory);
78
89
  const ft = tempList?.filter(f => f.category === lic[0]);
79
90
  setTemplates(tempList);
80
91
  setCategories(lic);
@@ -50,9 +50,22 @@ const usePopupStyle = theme => ({
50
50
  textFormatWrapper: {
51
51
  padding: "0px 16px 16px 16px",
52
52
  width: "370px",
53
+ maxWidth: "100%",
53
54
  // 30% of window height
54
55
  maxHeight: `${window.innerHeight * 0.45}px`,
55
56
  overflow: "auto",
57
+ "&.elements-wrpr-pp": {
58
+ width: "500px",
59
+ maxWidth: "100%",
60
+ "&.fullscreen": {
61
+ width: "100%",
62
+ maxHeight: "fit-content"
63
+ },
64
+ "& .ele-item-single": {
65
+ paddingLeft: "4px",
66
+ paddingTop: "4px"
67
+ }
68
+ },
56
69
  "&.templates": {
57
70
  width: "500px",
58
71
  maxWidth: "100%",
@@ -8,6 +8,7 @@ import useDrag from "../../hooks/useDrag";
8
8
  import PopperHeader from "./PopperHeader";
9
9
  import { TableUtil } from "../../utils/table";
10
10
  import useWindowResize from "../../hooks/useWindowResize";
11
+ import useEvent from "../../hooks/useKeys";
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
12
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
14
  const PopupTool = props => {
@@ -26,6 +27,7 @@ const PopupTool = props => {
26
27
  const id = open ? "popup-edit-tool" : "";
27
28
  const table = new TableUtil(editor);
28
29
  const [size] = useWindowResize();
30
+ const [eventKey] = useEvent();
29
31
  useEffect(() => {
30
32
  if (event === "end" && anchorEl && !open) {
31
33
  // for table cell selection
@@ -37,6 +39,11 @@ const PopupTool = props => {
37
39
  setOpen(false);
38
40
  }
39
41
  }, [event, anchorEl]);
42
+ useEffect(() => {
43
+ if (eventKey) {
44
+ setOpen(false);
45
+ }
46
+ }, [eventKey]);
40
47
  useEffect(() => {
41
48
  if (!selection || !inFocus || Range.isCollapsed(selection) || Editor.string(editor, selection) === "") {
42
49
  setAnchorEl(null);
@@ -103,9 +103,9 @@ export const toolbarGroups = [[{
103
103
  group: "typography"
104
104
  }, {
105
105
  id: 14,
106
- format: "blockquote",
106
+ format: "doublequote",
107
107
  type: "block",
108
- title: "Block Quote",
108
+ title: "Double Quote",
109
109
  group: "typography"
110
110
  }], [{
111
111
  id: 15,
@@ -8,8 +8,8 @@ import { SiLatex } from "react-icons/si";
8
8
  import { RiDeleteColumn, RiDeleteRow } from "react-icons/ri";
9
9
  import { IoIosImage } from "react-icons/io";
10
10
  import { GridIcon, AccordionIcon, SignatureIcon, ButtonIcon, Carousal, FormIcon, BoldIcon, FontFamilyIcon, FontSizeIcon, ImageIcon, ItalicIcon, LinkIcon, StrikethroughIcon, TableIcon, UnderLineIcon, VideoIcon, CheckboxIcon, AppHeader, MoreHorizontal, UploadImage, DocsUpload, LeftArrow, RightArrow, CheckListButton, CheckListButtonActive, ExcelIcon, CsvIcon, DividerIcon } from "./iconslist";
11
- import ArrowRightIcon from '@mui/icons-material/ArrowRight';
12
- import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
11
+ import ArrowRightIcon from "@mui/icons-material/ArrowRight";
12
+ import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
15
  const iconList = {
@@ -51,6 +51,10 @@ const iconList = {
51
51
  size: 20,
52
52
  fill: "#64748B"
53
53
  }),
54
+ doublequote: /*#__PURE__*/_jsx(MdFormatQuote, {
55
+ size: 20,
56
+ fill: "#64748B"
57
+ }),
54
58
  superscript: /*#__PURE__*/_jsx(FaSuperscript, {
55
59
  size: 15,
56
60
  fill: "#64748B"
@@ -0,0 +1,141 @@
1
+ import { jsx } from "slate-hyperscript";
2
+ const ELEMENT_TAGS = {
3
+ A: el => ({
4
+ type: "link",
5
+ url: el.getAttribute("href")
6
+ }),
7
+ BLOCKQUOTE: () => ({
8
+ type: "quote"
9
+ }),
10
+ H1: () => ({
11
+ type: "headingOne"
12
+ }),
13
+ H2: () => ({
14
+ type: "headingTwo"
15
+ }),
16
+ H3: () => ({
17
+ type: "headingThree"
18
+ }),
19
+ H4: () => ({
20
+ type: "headingFour"
21
+ }),
22
+ H5: () => ({
23
+ type: "headingFive"
24
+ }),
25
+ H6: () => ({
26
+ type: "headingSix"
27
+ }),
28
+ IMG: el => ({
29
+ type: "image",
30
+ url: el.getAttribute("src")
31
+ }),
32
+ LI: () => ({
33
+ type: "list-item"
34
+ }),
35
+ UL: () => ({
36
+ type: "unorderedList"
37
+ }),
38
+ OL: () => ({
39
+ type: "orderedList"
40
+ }),
41
+ P: () => ({
42
+ type: "paragraph"
43
+ }),
44
+ PRE: () => ({
45
+ type: "code"
46
+ }),
47
+ META: () => ({
48
+ type: "paragraph"
49
+ }),
50
+ STYLE: () => ({
51
+ type: "paragraph"
52
+ }),
53
+ "GOOGLE-SHEETS-HTML-ORIGIN": () => ({
54
+ type: "paragraph"
55
+ }),
56
+ TABLE: () => ({
57
+ type: "table"
58
+ }),
59
+ THEAD: () => ({
60
+ type: "table-head"
61
+ }),
62
+ TBODY: () => ({
63
+ type: "table-body"
64
+ }),
65
+ TH: () => ({
66
+ type: "table-cell"
67
+ }),
68
+ TR: () => ({
69
+ type: "table-row"
70
+ }),
71
+ TD: () => ({
72
+ type: "table-cell"
73
+ }),
74
+ COLGROUP: () => ({
75
+ type: "paragraph"
76
+ }),
77
+ COL: () => ({
78
+ type: "paragraph"
79
+ })
80
+ };
81
+
82
+ // COMPAT: `B` is omitted here because Google Docs uses `<b>` in weird ways.
83
+ const TEXT_TAGS = {
84
+ CODE: () => ({
85
+ code: true
86
+ }),
87
+ DEL: () => ({
88
+ strikethrough: true
89
+ }),
90
+ EM: () => ({
91
+ italic: true
92
+ }),
93
+ I: () => ({
94
+ italic: true
95
+ }),
96
+ S: () => ({
97
+ strikethrough: true
98
+ }),
99
+ STRONG: () => ({
100
+ bold: true
101
+ }),
102
+ U: () => ({
103
+ underline: true
104
+ })
105
+ };
106
+ const deserialize = el => {
107
+ if (el.nodeType === 3) {
108
+ return el.textContent;
109
+ } else if (el.nodeType !== 1) {
110
+ return null;
111
+ } else if (el.nodeName === "BR") {
112
+ return "\n";
113
+ }
114
+ const {
115
+ nodeName
116
+ } = el;
117
+ let parent = el;
118
+ console.log(nodeName);
119
+ if (nodeName === "PRE" && el.childNodes[0] && el.childNodes[0].nodeName === "CODE") {
120
+ parent = el.childNodes[0];
121
+ }
122
+ let children = Array.from(parent.childNodes).map(deserialize).flat();
123
+ if (children.length === 0) {
124
+ children = [{
125
+ text: ""
126
+ }];
127
+ }
128
+ if (el.nodeName === "BODY") {
129
+ return jsx("fragment", {}, children);
130
+ }
131
+ if (ELEMENT_TAGS[nodeName]) {
132
+ const attrs = ELEMENT_TAGS[nodeName](el);
133
+ return jsx("element", attrs, children);
134
+ }
135
+ if (TEXT_TAGS[nodeName]) {
136
+ const attrs = TEXT_TAGS[nodeName](el);
137
+ return children.map(child => jsx("text", attrs, child));
138
+ }
139
+ return children;
140
+ };
141
+ export default deserialize;
@@ -0,0 +1,21 @@
1
+ import { useEffect, useState } from "react";
2
+ const useEvent = () => {
3
+ const [event, setEvent] = useState("");
4
+ useEffect(() => {
5
+ addListener();
6
+ return () => {
7
+ removeListener();
8
+ };
9
+ }, []);
10
+ const onKeyUp = e => {
11
+ setEvent(e.keyCode);
12
+ };
13
+ const addListener = () => {
14
+ document.addEventListener("keyup", onKeyUp);
15
+ };
16
+ const removeListener = () => {
17
+ document.removeEventListener("keyup", onKeyUp);
18
+ };
19
+ return [event];
20
+ };
21
+ export default useEvent;
@@ -6,9 +6,8 @@ import withEmbeds from "../plugins/withEmbeds";
6
6
  import withEquation from "../plugins/withEquation";
7
7
  import withMentions from "../plugins/withMentions";
8
8
  import withLayout from "../plugins/withLayout";
9
- // import { withLinkify } from '@mercuriya/slate-linkify';
10
-
9
+ import withHtml from "../plugins/withHTML";
11
10
  const withCommon = (props, rest = {}) => {
12
- return rest.needLayout ? withEquation(withLayout(withHistory(withEmbeds(withTables(withLinks(withMentions(withReact(props)))))))) : withEquation(withHistory(withEmbeds(withTables(withLinks(withMentions(withReact(props)))))));
11
+ return rest.needLayout ? withHtml(withEquation(withLayout(withHistory(withEmbeds(withTables(withLinks(withMentions(withReact(props))))))))) : withHtml(withEquation(withHistory(withEmbeds(withTables(withLinks(withMentions(withReact(props))))))));
13
12
  };
14
13
  export default withCommon;
@@ -40,9 +40,18 @@ const withEmbeds = editor => {
40
40
  select: true // Focus on this node once inserted
41
41
  });
42
42
  } else {
43
- insertBreak(...args);
43
+ // to disable default leafs
44
+ Transforms.insertNodes(editor, {
45
+ type: "paragraph",
46
+ children: [{
47
+ text: ""
48
+ }]
49
+ }, {
50
+ select: true // Focus on this node once inserted
51
+ });
44
52
  }
45
53
  };
54
+
46
55
  return editor;
47
56
  };
48
57
  export default withEmbeds;
@@ -0,0 +1,43 @@
1
+ import { Transforms, Editor, Element } from "slate";
2
+ import deserialize from "../helper/deserialize";
3
+ const withHtml = editor => {
4
+ const {
5
+ insertData,
6
+ isInline,
7
+ isVoid
8
+ } = editor;
9
+ editor.isInline = element => {
10
+ return element.type === "link" ? true : isInline(element);
11
+ };
12
+ editor.isVoid = element => {
13
+ return element.type === "image" ? true : isVoid(element);
14
+ };
15
+ editor.insertData = data => {
16
+ const slateHTML = data?.getData("application/x-slate-fragment");
17
+ const html = data?.getData("text/html");
18
+ console.log(slateHTML, "****", html);
19
+ if (slateHTML) {
20
+ const [tableNode] = Editor.nodes(editor, {
21
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
22
+ });
23
+ // do not paste table cell inside table cell
24
+ // only plain text for internal paste
25
+ if (tableNode && tableNode[0]) {
26
+ const text = data?.getData("text/plain");
27
+ Transforms.insertText(editor, text);
28
+ } else {
29
+ insertData(data);
30
+ }
31
+ } else if (html) {
32
+ const parsed = new DOMParser().parseFromString(html, "text/html");
33
+ console.log(parsed.body);
34
+ const fragment = deserialize(parsed.body);
35
+ Transforms.insertFragment(editor, fragment);
36
+ return;
37
+ } else {
38
+ insertData(data);
39
+ }
40
+ };
41
+ return editor;
42
+ };
43
+ export default withHtml;
@@ -5,15 +5,6 @@ const withTable = editor => {
5
5
  deleteBackward,
6
6
  deleteForward
7
7
  } = editor;
8
- editor.insertData = data => {
9
- try {
10
- const text = data.getData("text/plain");
11
- Transforms.insertText(editor, text);
12
- return;
13
- } catch (err) {
14
- console.log(err);
15
- }
16
- };
17
8
  editor.deleteBackward = unit => {
18
9
  const {
19
10
  selection
@@ -39,6 +39,7 @@ import { getBreakPointsValue } from "../helper/theme";
39
39
  import Variables from "../Elements/Variables/Variable";
40
40
  import insertNewLine from "./insertNewLine";
41
41
  import Divider from "../Elements/Divider/Divider";
42
+ import { getBorderColor } from "./helper";
42
43
  import { jsx as _jsx } from "react/jsx-runtime";
43
44
  const alignment = ["alignLeft", "alignRight", "alignCenter"];
44
45
  const list_types = ["orderedList", "unorderedList"];
@@ -160,6 +161,7 @@ export const activeMark = (editor, format) => {
160
161
  }
161
162
  };
162
163
  export const getMarked = (leaf, children) => {
164
+ const className = leaf?.doublequote ? "doublequote" : "";
163
165
  if (leaf.bold) {
164
166
  children = /*#__PURE__*/_jsx("strong", {
165
167
  children: children
@@ -198,7 +200,9 @@ export const getMarked = (leaf, children) => {
198
200
  children: children
199
201
  });
200
202
  }
201
- if (leaf.color) {
203
+ // cover under single span
204
+ if (leaf.color || leaf.bgColor || leaf.fontSize || leaf.fontFamily || leaf.fontWeight || className) {
205
+ const family = fontFamilyMap[leaf?.fontFamily];
202
206
  const textStyles = leaf?.color?.indexOf("gradient") >= 0 ? {
203
207
  background: leaf?.color?.concat("text"),
204
208
  WebkitBackgroundClip: "text",
@@ -206,45 +210,17 @@ export const getMarked = (leaf, children) => {
206
210
  } : {
207
211
  color: leaf.color
208
212
  };
209
- children = /*#__PURE__*/_jsx("span", {
210
- style: {
211
- ...textStyles
212
- },
213
- children: children
214
- });
215
- }
216
- if (leaf.bgColor) {
217
- children = /*#__PURE__*/_jsx("span", {
218
- style: {
219
- background: leaf.bgColor
220
- },
221
- children: children
222
- });
223
- }
224
- if (leaf.fontSize) {
225
213
  children = /*#__PURE__*/_jsx(Box, {
214
+ className: className,
226
215
  component: "span",
227
216
  sx: {
228
217
  fontSize: {
229
218
  lg: sizeMap[leaf.fontSize] || leaf.fontSize,
230
219
  ...getBreakPointsValue(leaf.fontSize, null, "overrideText")
231
- }
232
- },
233
- children: children
234
- });
235
- }
236
- if (leaf.fontFamily) {
237
- const family = fontFamilyMap[leaf.fontFamily];
238
- children = /*#__PURE__*/_jsx("span", {
239
- style: {
240
- fontFamily: family
241
- },
242
- children: children
243
- });
244
- }
245
- if (leaf.fontWeight) {
246
- children = /*#__PURE__*/_jsx("span", {
247
- style: {
220
+ },
221
+ background: leaf.bgColor,
222
+ ...textStyles,
223
+ fontFamily: family,
248
224
  fontWeight: leaf.fontWeight
249
225
  },
250
226
  children: children
@@ -300,12 +276,14 @@ export const getBlock = props => {
300
276
  ...attributes,
301
277
  ...element.attr,
302
278
  style: {
303
- borderColor: element?.color || "transparent",
279
+ // borderColor: element?.color || "transparent",
280
+ ...getBorderColor(element?.color || "transparent", 3),
304
281
  background: element?.bgColor || "none",
305
282
  padding: `${element?.bgColor ? "16px" : "0px"} 8px`,
306
283
  borderRadius: `${element?.color ? "0px" : "12px"} 12px 12px ${element?.color ? "0px" : "12px"}`,
307
284
  margin: `${element?.bgColor ? "16px" : "0px"} 0px`,
308
- width: element?.bgColor ? "calc(100% - 16px)" : "100%"
285
+ width: element?.bgColor ? "calc(100% - 16px)" : "100%",
286
+ borderWidth: element?.color ? "0px 0px 0px 3px" : "0px"
309
287
  },
310
288
  children: children
311
289
  });
@@ -376,6 +354,14 @@ export const getBlock = props => {
376
354
  return /*#__PURE__*/_jsx(Table, {
377
355
  ...props
378
356
  });
357
+ case "table-head":
358
+ return /*#__PURE__*/_jsx("thead", {
359
+ children: children
360
+ });
361
+ case "table-body":
362
+ return /*#__PURE__*/_jsx("tbody", {
363
+ children: children
364
+ });
379
365
  case "table-row":
380
366
  return /*#__PURE__*/_jsx(TableRow, {
381
367
  ...props
@@ -1,7 +1,9 @@
1
1
  import { Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
+ import { getSelectedText } from "./helper";
3
4
  export const insertAccordion = (editor, path) => {
4
5
  try {
6
+ const selectedText = getSelectedText(editor);
5
7
  const accordion = {
6
8
  type: "accordion",
7
9
  children: [{
@@ -9,7 +11,7 @@ export const insertAccordion = (editor, path) => {
9
11
  children: [{
10
12
  type: "paragraph",
11
13
  children: [{
12
- text: ""
14
+ text: selectedText || ""
13
15
  }]
14
16
  }]
15
17
  }, {
@@ -43,6 +43,19 @@ export const gradientBorder = color => {
43
43
  };
44
44
  }
45
45
  };
46
+ export const getBorderColor = (color, borderWidth = 3) => {
47
+ if (color?.indexOf("linear") > -1) {
48
+ return {
49
+ borderImage: `${color} ${borderWidth}`,
50
+ borderWidth: `0px 0px 0px ${borderWidth}px`,
51
+ borderStyle: "solid"
52
+ };
53
+ } else {
54
+ return {
55
+ borderColor: color || "transparent"
56
+ };
57
+ }
58
+ };
46
59
  export const absoluteLink = url => {
47
60
  try {
48
61
  if (url?.indexOf("://") === -1) {
@@ -390,8 +390,45 @@ export const createTableCell = text => {
390
390
  }]
391
391
  };
392
392
  };
393
+
394
+ // const createHead = (cellText) => {
395
+ // const newHead = Array.from(cellText, (value) => createTableHeadCell(value));
396
+ // return {
397
+ // type: "table-head",
398
+ // children: [
399
+ // {
400
+ // type: "table-row",
401
+ // children: newHead,
402
+ // },
403
+ // ],
404
+ // };
405
+ // };
406
+
407
+ // export const createTableHeadCell = (text) => {
408
+ // return {
409
+ // type: "table-cell",
410
+ // children: [
411
+ // {
412
+ // type: "paragraph",
413
+ // children: [{ text }],
414
+ // },
415
+ // ],
416
+ // };
417
+ // };
418
+
419
+ // const createTbody = (children) => {
420
+ // return [
421
+ // {
422
+ // type: "table-body",
423
+ // children: children,
424
+ // },
425
+ // ];
426
+ // };
427
+
393
428
  const createTableNode = (cellText, rows, columns) => {
429
+ // const tableHead = Array.from([cellText[0]], (value) => createHead(value));
394
430
  const tableChildren = Array.from(cellText, value => createRow(value));
431
+ // const tbodyChildren = createTbody(tableChildren);
395
432
  let tableNode = {
396
433
  type: "table",
397
434
  children: tableChildren,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -41,6 +41,7 @@
41
41
  "react-slick": "^0.29.0",
42
42
  "slate": "^0.94.1",
43
43
  "slate-history": "^0.93.0",
44
+ "slate-hyperscript": "^0.100.0",
44
45
  "slate-react": "^0.98.3",
45
46
  "styled-components": "^5.3.11",
46
47
  "use-debounce": "^10.0.0",