@flozy/editor 2.0.9 → 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.
- package/dist/Editor/CommonEditor.js +19 -2
- package/dist/Editor/Elements/Button/EditorButton.js +2 -1
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +20 -5
- package/dist/Editor/Elements/Form/Workflow/ListWorkflow.js +132 -129
- package/dist/Editor/Elements/Form/Workflow/Styles.js +11 -10
- package/dist/Editor/Elements/Form/Workflow/UserInputs.js +21 -180
- package/dist/Editor/Elements/Form/Workflow/index.js +25 -6
- package/dist/Editor/Elements/Grid/Grid.js +9 -3
- package/dist/Editor/Elements/{SimpleText.js → SimpleText/index.js} +5 -43
- package/dist/Editor/Elements/SimpleText/style.js +40 -0
- package/dist/Editor/Elements/Table/TableCell.js +1 -1
- package/dist/Editor/Elements/Variables/Style.js +29 -4
- package/dist/Editor/Elements/Variables/VariableButton.js +4 -4
- package/dist/Editor/Styles/EditorStyles.js +11 -0
- package/dist/Editor/Toolbar/Basic/index.js +54 -25
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat.js +419 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +2 -1
- package/dist/Editor/common/Section/index.js +1 -43
- package/dist/Editor/common/Section/styles.js +44 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +3 -1
- package/dist/Editor/common/StyleBuilder/gridStyle.js +7 -5
- package/dist/Editor/common/StyleBuilder/index.js +8 -0
- package/dist/Editor/helper/deserialize/index.js +10 -6
- package/dist/Editor/plugins/withEmbeds.js +1 -10
- package/dist/Editor/plugins/withHTML.js +36 -4
- package/dist/Editor/utils/button.js +3 -1
- package/dist/Editor/utils/formfield.js +2 -0
- package/dist/Editor/utils/helper.js +40 -1
- package/package.json +1 -1
|
@@ -1,5 +1,36 @@
|
|
|
1
|
-
import { Transforms, Editor, Element } from "slate";
|
|
1
|
+
import { Transforms, Editor, Element, Node } from "slate";
|
|
2
2
|
import deserialize from "../helper/deserialize";
|
|
3
|
+
const getCurrentElement = editor => {
|
|
4
|
+
try {
|
|
5
|
+
if (editor.selection) {
|
|
6
|
+
return Node.parent(editor, editor?.selection?.anchor?.path);
|
|
7
|
+
} else {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
} catch (err) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const formatFragment = {
|
|
15
|
+
"list-item": fragment => {
|
|
16
|
+
let refactorFragment = [];
|
|
17
|
+
fragment.forEach(a => {
|
|
18
|
+
if (a.type === "orderedList") {
|
|
19
|
+
refactorFragment = [...refactorFragment, ...(a.children || [])];
|
|
20
|
+
} else {
|
|
21
|
+
a.type = "list-item";
|
|
22
|
+
refactorFragment.push(a);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return refactorFragment;
|
|
26
|
+
},
|
|
27
|
+
"check-list-item": fragment => {
|
|
28
|
+
return fragment.map(a => {
|
|
29
|
+
a.type = "check-list-item";
|
|
30
|
+
return a;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
3
34
|
const withHtml = editor => {
|
|
4
35
|
const {
|
|
5
36
|
insertData,
|
|
@@ -15,7 +46,7 @@ const withHtml = editor => {
|
|
|
15
46
|
editor.insertData = data => {
|
|
16
47
|
const slateHTML = data?.getData("application/x-slate-fragment");
|
|
17
48
|
const html = data?.getData("text/html");
|
|
18
|
-
|
|
49
|
+
const currentEl = getCurrentElement(editor);
|
|
19
50
|
if (slateHTML) {
|
|
20
51
|
const [tableNode] = Editor.nodes(editor, {
|
|
21
52
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table"
|
|
@@ -30,9 +61,10 @@ const withHtml = editor => {
|
|
|
30
61
|
}
|
|
31
62
|
} else if (html) {
|
|
32
63
|
const parsed = new DOMParser().parseFromString(html, "text/html");
|
|
33
|
-
console.log(parsed.body);
|
|
34
64
|
const fragment = deserialize(parsed.body);
|
|
35
|
-
|
|
65
|
+
const eltype = currentEl?.type;
|
|
66
|
+
const formattedFragment = formatFragment[eltype] ? formatFragment[eltype](fragment) : fragment;
|
|
67
|
+
Transforms.insertFragment(editor, formattedFragment);
|
|
36
68
|
return;
|
|
37
69
|
} else {
|
|
38
70
|
insertData(data);
|
|
@@ -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);
|
|
@@ -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
|
};
|