@flozy/editor 1.7.5 → 1.7.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +30 -12
- package/dist/Editor/DialogWrapper.js +2 -10
- package/dist/Editor/Editor.css +105 -0
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +14 -4
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +9 -6
- package/dist/Editor/Elements/Color Picker/LogoIcon.js +15 -49
- package/dist/Editor/Elements/Color Picker/Styles.js +25 -4
- package/dist/Editor/Elements/Color Picker/defaultColors.js +1 -1
- package/dist/Editor/Elements/Embed/Image.js +25 -31
- package/dist/Editor/Elements/Embed/Video.js +49 -40
- package/dist/Editor/Elements/Form/Workflow/Styles.js +3 -2
- package/dist/Editor/Elements/Grid/Grid.js +67 -114
- package/dist/Editor/Elements/Grid/GridItem.js +9 -23
- package/dist/Editor/Elements/Grid/templates/default_grid.js +0 -23
- package/dist/Editor/Elements/Link/Link.js +58 -20
- package/dist/Editor/Elements/Link/LinkButton.js +37 -97
- package/dist/Editor/Elements/Link/LinkPopup.js +106 -0
- package/dist/Editor/Elements/List/CheckList.js +28 -22
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +11 -5
- package/dist/Editor/Elements/Signature/SignaturePopup.js +15 -4
- package/dist/Editor/Elements/SimpleText.js +30 -26
- package/dist/Editor/MiniEditor.js +4 -6
- package/dist/Editor/Styles/EditorStyles.js +72 -1
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +2 -1
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +5 -1
- package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +3 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +4 -0
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +96 -19
- package/dist/Editor/Toolbar/toolbarGroups.js +1 -1
- package/dist/Editor/common/Section/index.js +118 -0
- package/dist/Editor/common/Shorthands/elements.js +1 -1
- package/dist/Editor/common/StyleBuilder/appHeaderStyle.js +5 -1
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +44 -51
- package/dist/Editor/common/StyleBuilder/embedImageStyle.js +2 -24
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -3
- package/dist/Editor/common/StyleBuilder/fieldStyle.js +0 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/alignment.js +52 -62
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +2 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +100 -74
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +41 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +3 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +27 -77
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +7 -5
- package/dist/Editor/common/StyleBuilder/fieldTypes/gridSize.js +19 -15
- package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +2 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/menusArray.js +2 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +67 -8
- package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +2 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/text.js +21 -32
- package/dist/Editor/common/StyleBuilder/fieldTypes/textAlign.js +37 -41
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +26 -24
- package/dist/Editor/common/StyleBuilder/formStyle.js +0 -6
- package/dist/Editor/common/StyleBuilder/gridItemStyle.js +38 -54
- package/dist/Editor/common/StyleBuilder/gridStyle.js +20 -26
- package/dist/Editor/common/StyleBuilder/index.js +14 -58
- package/dist/Editor/common/StyleBuilder/sectionStyle.js +16 -0
- package/dist/Editor/helper/index.js +63 -1
- package/dist/Editor/utils/Decorators/index.js +5 -0
- package/dist/Editor/utils/Decorators/link.js +26 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +36 -8
- package/dist/Editor/utils/accordion.js +17 -4
- package/dist/Editor/utils/button.js +15 -1
- package/dist/Editor/utils/customHooks/useElement.js +28 -0
- package/dist/Editor/utils/embed.js +1 -7
- package/dist/Editor/utils/events.js +92 -43
- package/dist/Editor/utils/gridItem.js +1 -1
- package/dist/Editor/utils/link.js +10 -9
- 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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
event.
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
};
|
@@ -1,29 +1,30 @@
|
|
1
|
-
import { Editor, Transforms, Path, Range, Element } from
|
1
|
+
import { Editor, Transforms, Path, Range, Element } from "slate";
|
2
2
|
export const createLinkNode = (href, showInNewTab, text) => ({
|
3
|
-
type:
|
3
|
+
type: "link",
|
4
4
|
href,
|
5
|
-
target: showInNewTab ?
|
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,
|
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 ===
|
22
|
+
if (parent.type === "link") {
|
22
23
|
removeLink(editor);
|
23
24
|
}
|
24
25
|
if (editor.isVoid(parent)) {
|
25
26
|
Transforms.insertNodes(editor, {
|
26
|
-
type:
|
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:
|
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 ===
|
51
|
+
match: n => !Editor.isEditor(n) && Element.isElement(n) && n.type === "link"
|
51
52
|
});
|
52
53
|
};
|