@flozy/editor 1.9.1 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -137,6 +137,10 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
137
137
  setValue(draftToSlate({
138
138
  data: content
139
139
  }));
140
+ Transforms.select(editor, {
141
+ path: [0, 0],
142
+ offset: 0
143
+ });
140
144
  }, [id, content]);
141
145
  useEffect(() => {
142
146
  if (editorWrapper && editorWrapper?.current && JSON.stringify(loadedValue) !== JSON.stringify(deboundedValue) && isInteracted && onSave) {
@@ -1,3 +1,11 @@
1
+ .editor-wrapper {
2
+ font-family: "Inter", sans-serif;
3
+ color: #0f172a;
4
+ line-height: 1.43;
5
+ font-weight: 400;
6
+ letter-spacing: 0.01071em;
7
+ }
8
+
1
9
  .editor-t-wrapper {
2
10
  font-family: "PoppinsRegular", "Helvetica", "Arial", sans-serif;
3
11
  position: relative;
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { jsxs as _jsxs } from "react/jsx-runtime";
4
+ const Divider = props => {
5
+ const {
6
+ attributes,
7
+ children
8
+ } = props;
9
+ return /*#__PURE__*/_jsxs("div", {
10
+ ...attributes,
11
+ className: "dividerComponent",
12
+ contentEditable: "false",
13
+ style: {
14
+ userSelect: "none"
15
+ },
16
+ children: [/*#__PURE__*/_jsx("hr", {
17
+ contentEditable: "false",
18
+ className: "editorDivider",
19
+ style: {
20
+ userSelect: "none"
21
+ }
22
+ }), /*#__PURE__*/_jsx("span", {
23
+ style: {
24
+ display: "none"
25
+ },
26
+ children: children
27
+ })]
28
+ });
29
+ };
30
+ export default Divider;
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ import { insertDivider } from "../../utils/divider";
3
+ import ToolbarIcon from "../../common/ToolbarIcon";
4
+ import Icon from "../../common/Icon";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const DividerButton = props => {
7
+ const {
8
+ editor,
9
+ icoBtnType
10
+ } = props;
11
+ const handleClick = () => {
12
+ insertDivider(editor);
13
+ };
14
+ return /*#__PURE__*/_jsx(ToolbarIcon, {
15
+ title: "Divider",
16
+ onClick: handleClick,
17
+ icon: /*#__PURE__*/_jsx(Icon, {
18
+ icon: "divider"
19
+ }),
20
+ icoBtnType: icoBtnType
21
+ });
22
+ };
23
+ export default DividerButton;
@@ -6,7 +6,7 @@
6
6
 
7
7
  .embed img {
8
8
  width: 100%;
9
- height: 100%
9
+ height: auto
10
10
  }
11
11
  .embed iframe {
12
12
  width: 100%;
@@ -83,3 +83,8 @@
83
83
  .link-embed-wrapper-hover-container:hover .link-embed-wrapper {
84
84
  padding-top: 24px;
85
85
  }
86
+
87
+ .editorDivider {
88
+ border-width: 1px 0 0;
89
+ border-color: rgba(55, 53, 47, .1607843137254902);
90
+ }
@@ -25,7 +25,8 @@ const Image = ({
25
25
  bgColor,
26
26
  borderColor,
27
27
  borderRadius,
28
- boxShadow
28
+ boxShadow,
29
+ width: oldWidth
29
30
  } = element;
30
31
  const {
31
32
  readOnly
@@ -39,14 +40,26 @@ const Image = ({
39
40
  const {
40
41
  vertical,
41
42
  horizantal
42
- } = alignment || {};
43
+ } = typeof alignment === "object" ? alignment : {
44
+ horizantal: alignment,
45
+ vertical: "center"
46
+ };
43
47
  const editor = useSlateStatic();
44
48
  const [parentDOM, setParentDOM] = useState(null);
45
49
  const [openSetttings, setOpenSettings] = useState(false);
46
50
  const path = ReactEditor.findPath(editor, element);
51
+ const getSize = () => {
52
+ if (element?.size === undefined) {
53
+ return {
54
+ widthInPercent: parseInt(oldWidth)
55
+ };
56
+ } else {
57
+ return element?.size || {};
58
+ }
59
+ };
47
60
  const [size, onMouseDown, resizing, onLoad] = useResize({
48
61
  parentDOM,
49
- size: element?.size,
62
+ size: getSize(),
50
63
  onChange: uSize => {
51
64
  Transforms.setNodes(editor, {
52
65
  size: uSize
@@ -65,7 +78,7 @@ const Image = ({
65
78
  if (editor && ele && ele[1] !== undefined) {
66
79
  const dom = ReactEditor.toDOMNode(editor, element);
67
80
  setParentDOM(dom);
68
- onLoad(element?.size || {});
81
+ onLoad(getSize());
69
82
  }
70
83
  }, []);
71
84
  const handleImageClick = () => {
@@ -176,9 +176,7 @@ const Table = props => {
176
176
  style: {
177
177
  minWidth: "100%",
178
178
  maxWidth: "100%",
179
- position: "relative",
180
- overflowX: "auto",
181
- overflowY: "hidden"
179
+ position: "relative"
182
180
  },
183
181
  children: [/*#__PURE__*/_jsx(TableComp, {
184
182
  sx: classes.table,
@@ -97,7 +97,6 @@ const editorStyles = ({
97
97
  justifyContent: "center",
98
98
  alignItems: "center",
99
99
  position: "relative",
100
- padding: "0px 12px",
101
100
  "&:hover": {
102
101
  "& .ed-section-inner": {
103
102
  "& .element-toolbar.ss": {
@@ -29,6 +29,7 @@ import "./styles.css";
29
29
  import TopBannerButton from "../Elements/TopBanner/TopBannerButton.js";
30
30
  import AttachmentsButton from "../Elements/Attachments/AttachmentsButton";
31
31
  import ColorboxButton from "../Elements/Colorbox/ColorboxButton.js";
32
+ import DividerButton from "../Elements/Divider/DividerButton.js";
32
33
  import { jsx as _jsx } from "react/jsx-runtime";
33
34
  import { jsxs as _jsxs } from "react/jsx-runtime";
34
35
  export const RenderToolbarIcon = props => {
@@ -199,6 +200,12 @@ export const RenderToolbarIcon = props => {
199
200
  customProps: customProps,
200
201
  icoBtnType: icoBtnType
201
202
  }, element.id);
203
+ case "divider":
204
+ return /*#__PURE__*/_jsx(DividerButton, {
205
+ editor: editor,
206
+ customProps: customProps,
207
+ icoBtnType: icoBtnType
208
+ }, element.id);
202
209
  default:
203
210
  return null;
204
211
  }
@@ -180,6 +180,11 @@ export const toolbarGroups = [[{
180
180
  id: 42,
181
181
  type: "table",
182
182
  group: "elements"
183
+ }, {
184
+ id: 48,
185
+ format: "divider",
186
+ type: "divider",
187
+ group: "elements"
183
188
  }], [{
184
189
  id: 28,
185
190
  format: "grid",
@@ -7,7 +7,7 @@ import { AiFillEdit, AiOutlineInsertRowBelow, AiOutlineInsertRowRight, AiOutline
7
7
  import { SiLatex } from "react-icons/si";
8
8
  import { RiDeleteColumn, RiDeleteRow } from "react-icons/ri";
9
9
  import { IoIosImage, IoMdArrowDroprightCircle, IoMdArrowDropdownCircle } from "react-icons/io";
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 } from "./iconslist";
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
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
13
  const iconList = {
@@ -195,7 +195,8 @@ const iconList = {
195
195
  checkListButton: /*#__PURE__*/_jsx(CheckListButton, {}),
196
196
  checkListButtonActive: /*#__PURE__*/_jsx(CheckListButtonActive, {}),
197
197
  excelIcon: /*#__PURE__*/_jsx(ExcelIcon, {}),
198
- csvIcon: /*#__PURE__*/_jsx(CsvIcon, {})
198
+ csvIcon: /*#__PURE__*/_jsx(CsvIcon, {}),
199
+ divider: /*#__PURE__*/_jsx(DividerIcon, {})
199
200
  };
200
201
  const Icon = props => {
201
202
  const {
@@ -9,6 +9,8 @@ import { toggleBlock } from "../../utils/SlateUtilityFunctions";
9
9
  import { TableUtil } from "../../utils/table";
10
10
  import Icon from "../Icon";
11
11
  import EmojiButton from "../../Elements/Emoji/EmojiButton";
12
+ import DividerButton from "../../Elements/Divider/DividerButton";
13
+ import { insertDivider } from "../../utils/divider";
12
14
  import { jsx as _jsx } from "react/jsx-runtime";
13
15
  const ELEMENTS_LIST = [{
14
16
  name: "Heading 1",
@@ -134,6 +136,17 @@ const ELEMENTS_LIST = [{
134
136
  const table = new TableUtil(editor);
135
137
  table.insertTable(3, 3);
136
138
  }
139
+ }, {
140
+ name: "Divider",
141
+ group: "Elements",
142
+ desc: "",
143
+ type: "divider",
144
+ icon: /*#__PURE__*/_jsx(Icon, {
145
+ icon: "divider"
146
+ }),
147
+ onInsert: editor => {
148
+ insertDivider(editor);
149
+ }
137
150
  }, {
138
151
  name: "Grid",
139
152
  group: "Elements",
@@ -38,6 +38,7 @@ import Attachments from "../Elements/Attachments/Attachments";
38
38
  import { getBreakPointsValue } from "../helper/theme";
39
39
  import Variables from "../Elements/Variables/Variable";
40
40
  import insertNewLine from "./insertNewLine";
41
+ import Divider from "../Elements/Divider/Divider";
41
42
  import { jsx as _jsx } from "react/jsx-runtime";
42
43
  const alignment = ["alignLeft", "alignRight", "alignCenter"];
43
44
  const list_types = ["orderedList", "unorderedList"];
@@ -507,6 +508,10 @@ export const getBlock = props => {
507
508
  },
508
509
  children: children
509
510
  });
511
+ case "divider":
512
+ return /*#__PURE__*/_jsx(Divider, {
513
+ ...props
514
+ });
510
515
  default:
511
516
  return /*#__PURE__*/_jsx(SimpleText, {
512
517
  ...props,
@@ -0,0 +1,12 @@
1
+ import { Transforms } from "slate";
2
+ import insertNewLine from "./insertNewLine";
3
+ export const insertDivider = editor => {
4
+ const divider = {
5
+ type: "divider",
6
+ children: [{
7
+ text: ""
8
+ }]
9
+ };
10
+ Transforms.insertNodes(editor, divider);
11
+ insertNewLine(editor);
12
+ };
@@ -75,7 +75,6 @@ export const isTextSelected = selection => {
75
75
  };
76
76
  export const getSelectedText = editor => {
77
77
  try {
78
- console.log("Q1", Editor.string(editor, editor?.selection));
79
78
  return Editor.string(editor, editor?.selection);
80
79
  } catch (err) {
81
80
  console.log(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -22,7 +22,9 @@
22
22
  "@testing-library/jest-dom": "^5.16.5",
23
23
  "@testing-library/react": "^13.4.0",
24
24
  "@testing-library/user-event": "^13.5.0",
25
+ "analytics": "^0.8.11",
25
26
  "animate.css": "^4.1.1",
27
+ "countries-and-timezones": "^3.6.0",
26
28
  "emoji-mart": "^5.5.2",
27
29
  "html2canvas": "^1.4.1",
28
30
  "husky": "^8.0.3",