@flozy/editor 1.1.1 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. package/dist/Editor/CollaborativeEditor.js +7 -2
  2. package/dist/Editor/CommonEditor.js +59 -37
  3. package/dist/Editor/Editor.css +209 -12
  4. package/dist/Editor/Elements/Accordion/Accordion.js +100 -0
  5. package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +20 -0
  6. package/dist/Editor/Elements/Accordion/AccordionButton.js +22 -0
  7. package/dist/Editor/Elements/Accordion/AccordionDetails.js +18 -0
  8. package/dist/Editor/Elements/Accordion/AccordionSummary.js +69 -0
  9. package/dist/Editor/Elements/Accordion/AccordionTitlePopup.js +20 -0
  10. package/dist/Editor/Elements/Button/ButtonPopup.js +20 -0
  11. package/dist/Editor/Elements/Button/ButtonToolIcon.js +19 -0
  12. package/dist/Editor/Elements/Button/EditorButton.js +124 -0
  13. package/dist/Editor/Elements/Carousel/Arrows.js +39 -0
  14. package/dist/Editor/Elements/Carousel/Carousel.js +82 -0
  15. package/dist/Editor/Elements/Carousel/CarouselButton.js +19 -0
  16. package/dist/Editor/Elements/Carousel/CarouselItem.js +13 -0
  17. package/dist/Editor/Elements/Carousel/slick-theme.min.css +143 -0
  18. package/dist/Editor/Elements/Carousel/slick.min.css +83 -0
  19. package/dist/Editor/Elements/Color Picker/ColorPicker.js +1 -1
  20. package/dist/Editor/Elements/Embed/Embed.css +22 -2
  21. package/dist/Editor/Elements/Embed/Embed.js +89 -74
  22. package/dist/Editor/Elements/Embed/EmbedPopup.js +23 -0
  23. package/dist/Editor/Elements/Embed/Image.js +92 -10
  24. package/dist/Editor/Elements/Embed/Video.js +31 -5
  25. package/dist/Editor/Elements/Equation/EquationButton.js +12 -12
  26. package/dist/Editor/Elements/Grid/Grid.js +64 -8
  27. package/dist/Editor/Elements/Grid/GridButton.js +2 -4
  28. package/dist/Editor/Elements/Grid/GridItem.js +59 -5
  29. package/dist/Editor/Elements/Grid/GridItemPopup.js +20 -0
  30. package/dist/Editor/Elements/Grid/GridPopup.js +22 -0
  31. package/dist/Editor/Elements/ID/Id.js +1 -1
  32. package/dist/Editor/Elements/ImageText/ImageText.js +14 -0
  33. package/dist/Editor/Elements/ImageText/ImageTextWrapper.js +14 -0
  34. package/dist/Editor/Elements/Link/LinkButton.js +1 -1
  35. package/dist/Editor/Elements/NewLine/NewLineButton.js +2 -1
  36. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +88 -0
  37. package/dist/Editor/Elements/PageSettings/PageSettingsPopup.js +22 -0
  38. package/dist/Editor/Elements/Signature/Signature.js +50 -0
  39. package/dist/Editor/Elements/Signature/SignatureButton.js +19 -0
  40. package/dist/Editor/Elements/Signature/SignatureOptions/DrawSignature.js +39 -0
  41. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +84 -0
  42. package/dist/Editor/Elements/Signature/SignatureOptions/UploadSignature.js +50 -0
  43. package/dist/Editor/Elements/Signature/SignatureOptions/index.js +5 -0
  44. package/dist/Editor/Elements/Signature/SignaturePopup.js +243 -0
  45. package/dist/Editor/Elements/Signature/Signed.js +80 -0
  46. package/dist/Editor/Elements/Table/DeleteCellIcon.js +24 -0
  47. package/dist/Editor/Elements/Table/DeleteRowIcon.js +24 -0
  48. package/dist/Editor/Elements/Table/Table.js +9 -1
  49. package/dist/Editor/Elements/Table/TableCell.js +181 -0
  50. package/dist/Editor/Elements/Table/TablePopup.js +22 -0
  51. package/dist/Editor/Elements/Table/TableRow.js +31 -0
  52. package/dist/Editor/Elements/Table/TableSelector.js +62 -68
  53. package/dist/Editor/Toolbar/Toolbar.js +47 -10
  54. package/dist/Editor/Toolbar/styles.css +20 -11
  55. package/dist/Editor/Toolbar/toolbarGroups.js +17 -19
  56. package/dist/Editor/common/Button.js +4 -8
  57. package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +23 -0
  58. package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +35 -0
  59. package/dist/Editor/common/StyleBuilder/buttonStyle.js +47 -0
  60. package/dist/Editor/common/StyleBuilder/embedImageStyle.js +63 -0
  61. package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +88 -0
  62. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +87 -0
  63. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +136 -0
  64. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +126 -0
  65. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +89 -0
  66. package/dist/Editor/common/StyleBuilder/fieldTypes/elementSize.js +110 -0
  67. package/dist/Editor/common/StyleBuilder/fieldTypes/gridSize.js +42 -0
  68. package/dist/Editor/common/StyleBuilder/fieldTypes/imageTexts.js +75 -0
  69. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +21 -0
  70. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +46 -0
  71. package/dist/Editor/common/StyleBuilder/gridItemStyle.js +51 -0
  72. package/dist/Editor/common/StyleBuilder/gridStyle.js +51 -0
  73. package/dist/Editor/common/StyleBuilder/index.js +114 -0
  74. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +10 -0
  75. package/dist/Editor/common/StyleBuilder/tableStyle.js +38 -0
  76. package/dist/Editor/common/Uploader.js +87 -0
  77. package/dist/Editor/plugins/withEmbeds.js +12 -5
  78. package/dist/Editor/plugins/withTable.js +5 -4
  79. package/dist/Editor/service/fileupload.js +17 -0
  80. package/dist/Editor/utils/SlateUtilityFunctions.js +72 -23
  81. package/dist/Editor/utils/accordion.js +25 -0
  82. package/dist/Editor/utils/button.js +11 -0
  83. package/dist/Editor/utils/carousel.js +13 -0
  84. package/dist/Editor/utils/carouselItem.js +19 -0
  85. package/dist/Editor/utils/customHooks/useContextMenu.js +8 -8
  86. package/dist/Editor/utils/customHooks/useResize.js +1 -1
  87. package/dist/Editor/utils/font.js +59 -0
  88. package/dist/Editor/utils/helper.js +32 -0
  89. package/dist/Editor/utils/imageText.js +19 -0
  90. package/dist/Editor/utils/signature.js +23 -0
  91. package/dist/Editor/utils/table.js +172 -0
  92. package/package.json +11 -3
@@ -0,0 +1,19 @@
1
+ import { Transforms } from "slate";
2
+ export const carouselItem = () => {
3
+ return {
4
+ type: "carousel-item",
5
+ image: null,
6
+ children: [{
7
+ type: "paragraph",
8
+ children: [{
9
+ text: `Carousel Item Text - ${new Date().getTime()}`
10
+ }]
11
+ }]
12
+ };
13
+ };
14
+ export const insertCarouselItem = editor => {
15
+ Transforms.insertNodes(editor, {
16
+ ...carouselItem()
17
+ });
18
+ Transforms.move(editor);
19
+ };
@@ -1,13 +1,13 @@
1
- import { useState, useEffect } from 'react';
2
- import useFormat from './useFormat.js';
1
+ import { useState, useEffect } from "react";
2
+ import useFormat from "./useFormat.js";
3
3
 
4
4
  //This hook returns should we show the custom context menu and where to show it.
5
5
  const useContextMenu = (editor, format, setSelection) => {
6
6
  const isFormat = useFormat(editor, format);
7
7
  const [showMenu, setShowMenu] = useState(false);
8
8
  const [menuLocation, setMenuLocation] = useState({
9
- top: '0px',
10
- left: '0px'
9
+ top: "0px",
10
+ left: "0px"
11
11
  });
12
12
  const handleClick = () => {
13
13
  setShowMenu(false);
@@ -25,11 +25,11 @@ const useContextMenu = (editor, format, setSelection) => {
25
25
  });
26
26
  };
27
27
  useEffect(() => {
28
- document.addEventListener('click', handleClick);
29
- document.addEventListener('contextmenu', handleContextMenu);
28
+ document.addEventListener("click", handleClick);
29
+ document.addEventListener("contextmenu", handleContextMenu);
30
30
  return () => {
31
- document.removeEventListener('click', handleClick);
32
- document.removeEventListener('contextmenu', handleContextMenu);
31
+ document.removeEventListener("click", handleClick);
32
+ document.removeEventListener("contextmenu", handleContextMenu);
33
33
  };
34
34
  }, [isFormat]);
35
35
  return [showMenu, menuLocation];
@@ -14,7 +14,7 @@ const useResize = ({
14
14
  ...defaultSize
15
15
  });
16
16
  const [resizing, setResizing] = useState(false);
17
- const onLoad = dom => {
17
+ const onLoad = defaultSize => {
18
18
  setSize({
19
19
  widthInPercent: 100,
20
20
  height: 300,
@@ -0,0 +1,59 @@
1
+ export const sizeMap = {
2
+ small: "12px",
3
+ normal: "16px",
4
+ medium: "28px",
5
+ huge: "40px"
6
+ };
7
+ export const fontFamilyMap = {
8
+ sans: "Helvetica,Arial, sans serif",
9
+ serif: "Georgia, Times New Roaman,serif",
10
+ monospace: "Monaco, Courier New,monospace",
11
+ roboto: "'Roboto', sans-serif",
12
+ qwitcher: "'Qwitcher Grypen', cursive",
13
+ garamond: "'EB Garamond', serif",
14
+ anton: "'Anton', sans-serif",
15
+ dmserif: "'DM Serif Text', serif",
16
+ inter: "'Inter', sans-serif",
17
+ libre: "'Libre Baskerville', serif",
18
+ montserrat: "'Montserrat', sans-serif",
19
+ opensans: "'Open Sans', sans-serif",
20
+ publicsans: "'Public Sans', sans-serif",
21
+ raleway: "'Raleway', sans-serif",
22
+ spacemono: "'Space Mono', sans-serif",
23
+ bulgarian: "'Bulgarian Garamond', monospace",
24
+ impact: "'Impact', serif",
25
+ redacted: "'Redacted Script', cursive",
26
+ greatVibes: "'Great Vibes', cursive",
27
+ zeyada: "'Zeyada', cursive",
28
+ allura: "'Allura', cursive",
29
+ pinyon: "'Pinyon Script', cursive",
30
+ muellerhoff: "'Herr Von Muellerhoff', cursive",
31
+ dawning: "'Dawning of a New Day', cursive",
32
+ //New Font Added for Type Signature
33
+ comingsoon: "'Coming Soon', cursive",
34
+ dancingScript: "'Dancing Script', cursive",
35
+ engagement: "'Engagement', cursive",
36
+ gaegu: "'Gaegu', cursive",
37
+ ingridDarling: "'Ingrid Darling', cursive",
38
+ kitaOne: "'Kite One', sans - serif",
39
+ laBelleAurore: "'La Belle Aurore', cursive",
40
+ lobster: "'Lobster', cursive",
41
+ meaCulpa: "'Mea Culpa', cursive",
42
+ meddon: "'Meddon', cursive",
43
+ merriWeather: "'Merriweather', serif",
44
+ theGirlNextDoor: "'The Girl Next Door', cursive"
45
+ };
46
+ export const fontOptions = Object.keys(fontFamilyMap).map(m => {
47
+ return {
48
+ text: fontFamilyMap[m],
49
+ value: m
50
+ };
51
+ });
52
+
53
+ // get last 12 fonts for signature text fonts
54
+ export const signedTextFonts = Object.keys(fontFamilyMap).slice(-12).map(m => {
55
+ return {
56
+ text: fontFamilyMap[m],
57
+ value: m
58
+ };
59
+ });
@@ -0,0 +1,32 @@
1
+ export const formatDate = (date, format = "MM/DD/YYYY") => {
2
+ var d = new Date(date),
3
+ month = "" + (d.getMonth() + 1),
4
+ day = "" + d.getDate(),
5
+ year = d.getFullYear();
6
+ if (month.length < 2) month = "0" + month;
7
+ if (day.length < 2) day = "0" + day;
8
+ switch (format) {
9
+ case "MM/DD/YYYY":
10
+ return [month, day, year].join("/");
11
+ case "YYYY-MM-DD":
12
+ return [year, month, day].join("-");
13
+ default:
14
+ return [year, month, day].join("-");
15
+ }
16
+ };
17
+ export const convertBase64 = file => {
18
+ return new Promise((resolve, reject) => {
19
+ if (file) {
20
+ const fileReader = new FileReader();
21
+ fileReader.readAsDataURL(file);
22
+ fileReader.onload = () => {
23
+ resolve(fileReader.result);
24
+ };
25
+ fileReader.onerror = error => {
26
+ reject(error);
27
+ };
28
+ } else {
29
+ resolve("");
30
+ }
31
+ });
32
+ };
@@ -0,0 +1,19 @@
1
+ import { Transforms } from "slate";
2
+ export const insertImageText = (editor, path) => {
3
+ const imageText = {
4
+ type: "image-text",
5
+ grid: "container",
6
+ children: [{
7
+ type: "paragraph",
8
+ children: [{
9
+ text: "sample text"
10
+ }]
11
+ }]
12
+ };
13
+ if (path) {
14
+ Transforms.insertNodes(editor, imageText, {
15
+ at: path
16
+ });
17
+ }
18
+ return imageText;
19
+ };
@@ -0,0 +1,23 @@
1
+ import { Transforms } from "slate";
2
+ export const insertSignature = editor => {
3
+ const signature = {
4
+ type: "signature",
5
+ alignment: "center",
6
+ data: {
7
+ name: "",
8
+ email: "",
9
+ date: "" // YYYY-MM-DD
10
+ },
11
+
12
+ size: {
13
+ height: 535,
14
+ widthInPercent: 99.75490196078437,
15
+ width: 1628.000000000001
16
+ },
17
+ children: [{
18
+ text: ""
19
+ }]
20
+ };
21
+ Transforms.insertNodes(editor, signature);
22
+ Transforms.move(editor);
23
+ };
@@ -1,4 +1,19 @@
1
1
  import { Transforms, Editor, Range, Element, Path } from "slate";
2
+ const prefixKey = (obj, pk = "") => {
3
+ return Object.keys(obj).reduce((a, b) => {
4
+ a[`${pk}${b}`] = obj[b];
5
+ return a;
6
+ }, {});
7
+ };
8
+ const parseByPrefixKey = (obj, pk = "") => {
9
+ return Object.keys(obj).reduce((a, b) => {
10
+ if (b.indexOf(pk) !== -1 && pk) {
11
+ const key = b.split(pk)[1];
12
+ a[key] = obj[b];
13
+ }
14
+ return a;
15
+ }, {});
16
+ };
2
17
  export class TableUtil {
3
18
  constructor(editor) {
4
19
  this.editor = editor;
@@ -64,6 +79,31 @@ export class TableUtil {
64
79
  }
65
80
  }
66
81
  };
82
+ deleteRow = () => {
83
+ const {
84
+ selection
85
+ } = this.editor;
86
+ if (!!selection && Range.isCollapsed(selection)) {
87
+ const [tableNode] = Editor.nodes(this.editor, {
88
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-row"
89
+ });
90
+ if (tableNode) {
91
+ const [[table, tablePath]] = Editor.nodes(this.editor, {
92
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
93
+ });
94
+ const [, currentRow] = tableNode;
95
+ const path = currentRow;
96
+ Transforms.removeNodes(this.editor, {
97
+ at: path
98
+ });
99
+ Transforms.setNodes(this.editor, {
100
+ rows: table.rows - 1
101
+ }, {
102
+ at: tablePath
103
+ });
104
+ }
105
+ }
106
+ };
67
107
  insertColumn = action => {
68
108
  const {
69
109
  selection
@@ -95,6 +135,138 @@ export class TableUtil {
95
135
  }
96
136
  }
97
137
  };
138
+ deleteColumn = () => {
139
+ const {
140
+ selection
141
+ } = this.editor;
142
+ if (!!selection && Range.isCollapsed(selection)) {
143
+ const [tableNode] = Editor.nodes(this.editor, {
144
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
145
+ });
146
+ if (tableNode) {
147
+ const [[table, tablePath]] = Editor.nodes(this.editor, {
148
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
149
+ });
150
+ const [, currentCell] = tableNode;
151
+ const startPath = currentCell;
152
+
153
+ // The last two indices of the path represents the row and column. We need to add one cell to each row starting from the first row
154
+ startPath[startPath.length - 2] = 0;
155
+ for (let row = 0; row < table.rows; row++) {
156
+ Transforms.removeNodes(this.editor, {
157
+ at: startPath
158
+ });
159
+ startPath[startPath.length - 2]++;
160
+ }
161
+ Transforms.setNodes(this.editor, {
162
+ columns: table.columns - 1
163
+ }, {
164
+ at: tablePath
165
+ });
166
+ }
167
+ }
168
+ };
169
+ updateTableStyle = (styleProps, paths) => {
170
+ try {
171
+ const {
172
+ selection
173
+ } = this.editor;
174
+ if (!!selection && Range.isCollapsed(selection)) {
175
+ console.log("styleProps", styleProps);
176
+ const tableProps = parseByPrefixKey(styleProps, "table.");
177
+ const rowProps = parseByPrefixKey(styleProps, "row.");
178
+ const cellProps = parseByPrefixKey(styleProps, "col.");
179
+ const {
180
+ currentCellPath,
181
+ currentRowPath,
182
+ currentTablePath
183
+ } = paths;
184
+ console.log(tableProps, rowProps, cellProps);
185
+ Transforms.setNodes(this.editor, {
186
+ ...tableProps
187
+ }, {
188
+ at: currentTablePath
189
+ });
190
+ Transforms.setNodes(this.editor, {
191
+ ...rowProps,
192
+ tableBorder: tableProps?.borderColor
193
+ }, {
194
+ at: currentRowPath
195
+ });
196
+ Transforms.setNodes(this.editor, {
197
+ ...cellProps,
198
+ rowBorder: rowProps?.borderColor,
199
+ tableBorder: tableProps?.borderColor
200
+ }, {
201
+ at: currentCellPath
202
+ });
203
+ }
204
+ } catch (err) {
205
+ console.log(err);
206
+ }
207
+ };
208
+ getTableProps = () => {
209
+ const {
210
+ selection
211
+ } = this.editor;
212
+ if (!!selection && Range.isCollapsed(selection)) {
213
+ const [tableNode] = Editor.nodes(this.editor, {
214
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
215
+ });
216
+ const [tableCellNode] = Editor.nodes(this.editor, {
217
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell"
218
+ });
219
+ const [tableRowNode] = Editor.nodes(this.editor, {
220
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-row"
221
+ });
222
+ if (tableNode && tableCellNode && tableRowNode) {
223
+ const [currentTable, currentTablePath] = tableNode;
224
+ const [currentCell, currentCellPath] = tableCellNode;
225
+ const [currentRow, currentRowPath] = tableRowNode;
226
+ const startPath = currentCell;
227
+ Transforms.setNodes(this.editor, {
228
+ cellBgColor: "#FFFFFF"
229
+ }, {
230
+ at: startPath
231
+ });
232
+ if (currentTable && currentCell && currentRow) {
233
+ const currentTableProps = {
234
+ ...currentTable
235
+ };
236
+ delete currentTableProps.children;
237
+ delete currentTableProps.type;
238
+ const currentCellProps = {
239
+ ...currentCell
240
+ };
241
+ delete currentCellProps.children;
242
+ delete currentCellProps.type;
243
+ const currentRowProps = {
244
+ ...currentRow
245
+ };
246
+ delete currentRowProps.children;
247
+ delete currentRowProps.type;
248
+ return {
249
+ styleProps: {
250
+ ...prefixKey({
251
+ ...currentTableProps
252
+ }, "table."),
253
+ ...prefixKey({
254
+ ...currentRowProps
255
+ }, "row."),
256
+ ...prefixKey({
257
+ ...currentCellProps
258
+ }, "col.")
259
+ },
260
+ currentCellPath,
261
+ currentRowPath,
262
+ currentTablePath
263
+ };
264
+ }
265
+ return null;
266
+ }
267
+ return null;
268
+ }
269
+ };
98
270
  }
99
271
  const createRow = cellText => {
100
272
  const newRow = Array.from(cellText, value => createTableCell(value));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -22,9 +22,12 @@
22
22
  "interweave": "^13.1.0",
23
23
  "lint-staged": "^13.2.3",
24
24
  "prettier": "^3.0.1",
25
+ "react-datepicker": "^4.18.0",
25
26
  "react-icons": "^4.10.1",
26
27
  "react-katex": "^3.0.1",
27
28
  "react-scripts": "5.0.1",
29
+ "react-signature-canvas": "^1.0.6",
30
+ "react-slick": "^0.29.0",
28
31
  "slate": "^0.94.1",
29
32
  "slate-history": "^0.93.0",
30
33
  "slate-react": "^0.98.3",
@@ -39,7 +42,7 @@
39
42
  },
40
43
  "scripts": {
41
44
  "prepare": "husky install .husky",
42
- "lint": "./node_modules/.bin/eslint --ignore-path .gitignore . --fix",
45
+ "lint": "./node_modules/.bin/eslint --ignore-path .gitignore .",
43
46
  "start": "craco start",
44
47
  "build": "craco build",
45
48
  "test": "craco test --passWithNoTests",
@@ -115,7 +118,12 @@
115
118
  },
116
119
  "babel": {
117
120
  "presets": [
118
- ["@babel/preset-react", {"runtime": "automatic"}]
121
+ [
122
+ "@babel/preset-react",
123
+ {
124
+ "runtime": "automatic"
125
+ }
126
+ ]
119
127
  ]
120
128
  }
121
129
  }