@flozy/editor 1.7.4 → 1.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. package/dist/Editor/CommonEditor.js +30 -12
  2. package/dist/Editor/DialogWrapper.js +2 -10
  3. package/dist/Editor/Editor.css +105 -0
  4. package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -4
  5. package/dist/Editor/Elements/Color Picker/ColorPicker.js +9 -6
  6. package/dist/Editor/Elements/Color Picker/LogoIcon.js +15 -49
  7. package/dist/Editor/Elements/Color Picker/Styles.js +25 -4
  8. package/dist/Editor/Elements/Color Picker/defaultColors.js +1 -1
  9. package/dist/Editor/Elements/Embed/Image.js +25 -31
  10. package/dist/Editor/Elements/Embed/Video.js +49 -40
  11. package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +49 -3
  12. package/dist/Editor/Elements/Form/Workflow/ListWorkflow.js +92 -75
  13. package/dist/Editor/Elements/Form/Workflow/MoreOptions.js +0 -1
  14. package/dist/Editor/Elements/Form/Workflow/Styles.js +19 -5
  15. package/dist/Editor/Elements/Form/Workflow/UserInputs.js +2 -4
  16. package/dist/Editor/Elements/Grid/Grid.js +67 -114
  17. package/dist/Editor/Elements/Grid/GridItem.js +9 -23
  18. package/dist/Editor/Elements/Grid/templates/default_grid.js +0 -23
  19. package/dist/Editor/Elements/Link/Link.js +58 -20
  20. package/dist/Editor/Elements/Link/LinkButton.js +37 -97
  21. package/dist/Editor/Elements/Link/LinkPopup.js +106 -0
  22. package/dist/Editor/Elements/List/CheckList.js +28 -22
  23. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +11 -5
  24. package/dist/Editor/Elements/Signature/SignaturePopup.js +15 -4
  25. package/dist/Editor/Elements/SimpleText.js +30 -26
  26. package/dist/Editor/MiniEditor.js +4 -6
  27. package/dist/Editor/Styles/EditorStyles.js +72 -1
  28. package/dist/Editor/Toolbar/FormatTools/TextSize.js +2 -1
  29. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +5 -1
  30. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +3 -1
  31. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +4 -0
  32. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +96 -19
  33. package/dist/Editor/Toolbar/toolbarGroups.js +1 -1
  34. package/dist/Editor/common/Section/index.js +118 -0
  35. package/dist/Editor/common/Shorthands/elements.js +1 -1
  36. package/dist/Editor/common/StyleBuilder/appHeaderStyle.js +5 -1
  37. package/dist/Editor/common/StyleBuilder/buttonStyle.js +44 -51
  38. package/dist/Editor/common/StyleBuilder/embedImageStyle.js +2 -24
  39. package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -3
  40. package/dist/Editor/common/StyleBuilder/fieldStyle.js +0 -3
  41. package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +52 -62
  42. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +2 -1
  43. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +100 -74
  44. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +41 -10
  45. package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +3 -3
  46. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +27 -77
  47. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -5
  48. package/dist/Editor/common/StyleBuilder/fieldTypes/gridSize.js +19 -15
  49. package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +2 -2
  50. package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +2 -2
  51. package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +67 -8
  52. package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +2 -3
  53. package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +21 -32
  54. package/dist/Editor/common/StyleBuilder/fieldTypes/textAlign.js +37 -41
  55. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +26 -24
  56. package/dist/Editor/common/StyleBuilder/formStyle.js +0 -6
  57. package/dist/Editor/common/StyleBuilder/gridItemStyle.js +38 -54
  58. package/dist/Editor/common/StyleBuilder/gridStyle.js +20 -26
  59. package/dist/Editor/common/StyleBuilder/index.js +14 -58
  60. package/dist/Editor/common/StyleBuilder/sectionStyle.js +16 -0
  61. package/dist/Editor/common/Uploader.js +0 -4
  62. package/dist/Editor/helper/index.js +63 -1
  63. package/dist/Editor/utils/Decorators/index.js +5 -0
  64. package/dist/Editor/utils/Decorators/link.js +26 -0
  65. package/dist/Editor/utils/SlateUtilityFunctions.js +36 -8
  66. package/dist/Editor/utils/accordion.js +17 -4
  67. package/dist/Editor/utils/button.js +15 -1
  68. package/dist/Editor/utils/customHooks/useElement.js +28 -0
  69. package/dist/Editor/utils/embed.js +1 -7
  70. package/dist/Editor/utils/events.js +92 -43
  71. package/dist/Editor/utils/gridItem.js +1 -1
  72. package/dist/Editor/utils/link.js +10 -9
  73. package/package.json +1 -1
@@ -1,5 +1,7 @@
1
1
  import { Editor, Transforms, Element, Node, Path } from "slate";
2
2
  import { toggleBlock } from "./SlateUtilityFunctions";
3
+ import insertNewLine from "./insertNewLine";
4
+ import { insertAccordion } from "./accordion";
3
5
  const HOTKEYS = {
4
6
  b: "bold",
5
7
  i: "italic",
@@ -57,57 +59,104 @@ const isMarkActive = (editor, format) => {
57
59
  return marks ? marks[format] === true : false;
58
60
  };
59
61
  export const commands = props => {
60
- const {
61
- event,
62
- editor
63
- } = props;
64
- if (HOTKEYS[event.key]) {
65
- event.preventDefault();
66
- const isActive = isMarkActive(editor, HOTKEYS[event.key]);
67
- if (isActive) {
68
- Editor.removeMark(editor, HOTKEYS[event.key]);
69
- } else {
70
- Editor.addMark(editor, HOTKEYS[event.key], true);
62
+ try {
63
+ const {
64
+ event,
65
+ editor
66
+ } = props;
67
+ if (HOTKEYS[event.key]) {
68
+ event.preventDefault();
69
+ const isActive = isMarkActive(editor, HOTKEYS[event.key]);
70
+ if (isActive) {
71
+ Editor.removeMark(editor, HOTKEYS[event.key]);
72
+ } else {
73
+ Editor.addMark(editor, HOTKEYS[event.key], true);
74
+ }
71
75
  }
76
+ } catch (err) {
77
+ console.log(err);
72
78
  }
73
79
  };
74
80
  export const indentation = props => {
75
- const {
76
- editor
77
- } = props;
78
- const {
79
- selection
80
- } = editor;
81
- if (selection) {
82
- const [listItemNode] = Editor.nodes(editor, {
83
- match: n => n.type === "list-item"
84
- });
85
- if (listItemNode) {
86
- const [, listItemPath] = listItemNode;
87
- const [parentNode] = Editor.parent(editor, listItemPath);
88
- const type = parentNode.type;
89
- Transforms.wrapNodes(editor, {
90
- type,
91
- children: []
92
- }, {
93
- at: listItemPath
81
+ try {
82
+ const {
83
+ editor
84
+ } = props;
85
+ const {
86
+ selection
87
+ } = editor;
88
+ if (selection) {
89
+ const [listItemNode] = Editor.nodes(editor, {
90
+ match: n => n.type === "list-item"
94
91
  });
92
+ if (listItemNode) {
93
+ const [, listItemPath] = listItemNode;
94
+ const [parentNode] = Editor.parent(editor, listItemPath);
95
+ const type = parentNode.type;
96
+ Transforms.wrapNodes(editor, {
97
+ type,
98
+ children: []
99
+ }, {
100
+ at: listItemPath
101
+ });
102
+ }
95
103
  }
104
+ } catch (err) {
105
+ console.log(err);
96
106
  }
97
107
  };
98
108
  export const escapeEvent = props => {
99
- const {
100
- editor
101
- } = props;
102
- const list_types = ["orderedList", "unorderedList", "checkList"];
103
- const parentPath = Path.ancestors(editor.selection.anchor.path);
104
- const parentNodes = parentPath.filter(m => m.length).map(m => Node.get(editor, m));
105
- if (parentNodes.length === 2 && parentNodes[1]?.type === "list-item") {
106
- toggleBlock(editor, "list-item", editor.selection);
107
- } else {
108
- Transforms.unwrapNodes(editor, {
109
- match: n => list_types.includes(!Editor.isEditor(n) && Element.isElement(n) && n.type),
110
- split: true
111
- });
109
+ try {
110
+ const {
111
+ editor
112
+ } = props;
113
+ const list_types = ["orderedList", "unorderedList", "checkList"];
114
+ const parentPath = Path.ancestors(editor.selection.anchor.path);
115
+ const parentNodes = parentPath.filter(m => m.length).map(m => Node.get(editor, m));
116
+ if (parentNodes.length === 2 && parentNodes[1]?.type === "list-item") {
117
+ toggleBlock(editor, "list-item", editor.selection);
118
+ } else {
119
+ Transforms.unwrapNodes(editor, {
120
+ match: n => list_types.includes(!Editor.isEditor(n) && Element.isElement(n) && n.type),
121
+ split: true
122
+ });
123
+ }
124
+ } catch (err) {
125
+ console.log(err);
126
+ }
127
+ };
128
+ export const enterEvent = (e, editor, ele) => {
129
+ try {
130
+ if (ele && ele[0]) {
131
+ const {
132
+ type
133
+ } = ele[0];
134
+ const text = Node.string(ele[0]);
135
+ switch (type) {
136
+ case "list-item":
137
+ case "check-list-item":
138
+ if (!text) {
139
+ e.preventDefault();
140
+ toggleBlock(editor, type);
141
+ insertNewLine(editor);
142
+ }
143
+ break;
144
+ case "accordion-summary":
145
+ e.preventDefault();
146
+ if (!text) {
147
+ const accordionIndex = ele[1].slice(0, Math.max(ele[1].length - 1));
148
+ Transforms.removeNodes(editor, {
149
+ at: accordionIndex
150
+ });
151
+ } else {
152
+ const nextPath = Path.next(Path.parent(ele[1]));
153
+ insertAccordion(editor, nextPath);
154
+ }
155
+ break;
156
+ default:
157
+ }
158
+ }
159
+ } catch (err) {
160
+ console.log(err);
112
161
  }
113
162
  };
@@ -6,7 +6,7 @@ export const gridItem = (props = {}) => {
6
6
  children: [{
7
7
  type: "paragraph",
8
8
  children: [{
9
- text: " "
9
+ text: ""
10
10
  }]
11
11
  }],
12
12
  bgColor: "rgba(255, 255, 255, 0)",
@@ -1,29 +1,30 @@
1
- import { Editor, Transforms, Path, Range, Element } from 'slate';
1
+ import { Editor, Transforms, Path, Range, Element } from "slate";
2
2
  export const createLinkNode = (href, showInNewTab, text) => ({
3
- type: 'link',
3
+ type: "link",
4
4
  href,
5
- target: showInNewTab ? '_blank' : '_self',
5
+ target: showInNewTab ? "_blank" : "_self",
6
6
  children: [{
7
7
  text
8
8
  }]
9
9
  });
10
10
  export const insertLink = (editor, {
11
11
  url,
12
- showInNewTab
12
+ showInNewTab,
13
+ name
13
14
  }) => {
14
15
  if (!url) return;
15
16
  const {
16
17
  selection
17
18
  } = editor;
18
- const link = createLinkNode(url, showInNewTab, 'Link');
19
+ const link = createLinkNode(url, showInNewTab, name || "Link");
19
20
  if (!!selection) {
20
21
  const [parent, parentPath] = Editor.parent(editor, selection.focus.path);
21
- if (parent.type === 'link') {
22
+ if (parent.type === "link") {
22
23
  removeLink(editor);
23
24
  }
24
25
  if (editor.isVoid(parent)) {
25
26
  Transforms.insertNodes(editor, {
26
- type: 'paragraph',
27
+ type: "paragraph",
27
28
  children: [link]
28
29
  }, {
29
30
  at: Path.next(parentPath),
@@ -40,13 +41,13 @@ export const insertLink = (editor, {
40
41
  }
41
42
  } else {
42
43
  Transforms.insertNodes(editor, {
43
- type: 'paragraph',
44
+ type: "paragraph",
44
45
  children: [link]
45
46
  });
46
47
  }
47
48
  };
48
49
  export const removeLink = editor => {
49
50
  Transforms.unwrapNodes(editor, {
50
- match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === 'link'
51
+ match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "link"
51
52
  });
52
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"