@flozy/editor 2.1.0 → 2.1.1

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.
Files changed (29) hide show
  1. package/dist/Editor/CommonEditor.js +19 -2
  2. package/dist/Editor/Elements/Button/EditorButton.js +2 -1
  3. package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +20 -5
  4. package/dist/Editor/Elements/Form/Workflow/ListWorkflow.js +132 -129
  5. package/dist/Editor/Elements/Form/Workflow/Styles.js +11 -10
  6. package/dist/Editor/Elements/Form/Workflow/UserInputs.js +21 -180
  7. package/dist/Editor/Elements/Form/Workflow/index.js +25 -6
  8. package/dist/Editor/Elements/Grid/Grid.js +9 -3
  9. package/dist/Editor/Elements/{SimpleText.js → SimpleText/index.js} +5 -43
  10. package/dist/Editor/Elements/SimpleText/style.js +40 -0
  11. package/dist/Editor/Elements/Table/TableCell.js +1 -1
  12. package/dist/Editor/Elements/Variables/Style.js +29 -4
  13. package/dist/Editor/Elements/Variables/VariableButton.js +4 -4
  14. package/dist/Editor/Styles/EditorStyles.js +11 -0
  15. package/dist/Editor/Toolbar/Basic/index.js +54 -25
  16. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat.js +419 -0
  17. package/dist/Editor/Toolbar/PopupTool/index.js +2 -1
  18. package/dist/Editor/common/Section/index.js +1 -43
  19. package/dist/Editor/common/Section/styles.js +44 -0
  20. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +3 -1
  21. package/dist/Editor/common/StyleBuilder/gridStyle.js +7 -5
  22. package/dist/Editor/common/StyleBuilder/index.js +8 -0
  23. package/dist/Editor/helper/deserialize/index.js +10 -6
  24. package/dist/Editor/plugins/withEmbeds.js +0 -1
  25. package/dist/Editor/plugins/withHTML.js +36 -4
  26. package/dist/Editor/utils/button.js +3 -1
  27. package/dist/Editor/utils/formfield.js +2 -0
  28. package/dist/Editor/utils/helper.js +40 -1
  29. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { Transforms } from "slate";
2
2
  import insertNewLine from "./insertNewLine";
3
+ import { windowVar } from "./helper";
3
4
  export const insertButton = editor => {
4
5
  const button = {
5
6
  type: "button",
@@ -23,7 +24,8 @@ export const insertButton = editor => {
23
24
  top: 8,
24
25
  right: 16,
25
26
  bottom: 8
26
- }
27
+ },
28
+ ...(windowVar.lastButtonProps || {})
27
29
  };
28
30
  Transforms.insertNodes(editor, button);
29
31
  Transforms.move(editor);
@@ -5,6 +5,8 @@ export const formField = () => {
5
5
  grid: 6,
6
6
  element: "text",
7
7
  name: `field_${new Date().getTime()}`,
8
+ key: `field_${new Date().getTime()}`,
9
+ label: `field_${new Date().getTime()}`,
8
10
  placeholder: "Placeholder...",
9
11
  children: [{
10
12
  text: ""
@@ -1,4 +1,6 @@
1
- import { Editor, Node } from "slate";
1
+ import { Editor, Node, Transforms } from "slate";
2
+ import { ReactEditor } from "slate-react";
3
+ export const windowVar = {};
2
4
  export const formatDate = (date, format = "MM/DD/YYYY") => {
3
5
  if (!date) return "";
4
6
  var d = new Date(date),
@@ -103,4 +105,41 @@ export const isEmptyNode = (editor, children, path) => {
103
105
  console.log(err);
104
106
  return "";
105
107
  }
108
+ };
109
+ export const outsideEditorClickLabel = "handle-outside-editor-click";
110
+ export const handleInsertLastElement = (event, editor) => {
111
+ if (event.target.dataset.info !== outsideEditorClickLabel) {
112
+ return;
113
+ }
114
+ const lastElement = editor.children[editor.children?.length - 1];
115
+ const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => c.type === "grid");
116
+ if (!ReactEditor.isFocused(editor)) {
117
+ if (isLastElementEmpty) {
118
+ // just focus on the last empty element
119
+ const path = [editor.children.length - 1, 0];
120
+ const move = {
121
+ path: path,
122
+ offset: 0
123
+ };
124
+ Transforms.insertNodes(editor, {
125
+ text: ''
126
+ }, {
127
+ at: path
128
+ });
129
+ Transforms.move(editor, move);
130
+ Transforms.select(editor, move);
131
+ } else {
132
+ // insert an new empty element and focus
133
+ Transforms.insertNodes(editor, [{
134
+ type: "paragraph",
135
+ children: [{
136
+ text: ""
137
+ }]
138
+ }], {
139
+ at: [editor.children.length],
140
+ select: true
141
+ });
142
+ }
143
+ ReactEditor.focus(editor);
144
+ }
106
145
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"