@flozy/editor 2.1.9 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/CommonEditor.js +14 -5
- package/dist/Editor/Editor.css +4 -0
- package/dist/Editor/Elements/Button/ButtonNavSettings/NavComponents.js +219 -0
- package/dist/Editor/Elements/Button/ButtonNavSettings/index.js +138 -0
- package/dist/Editor/Elements/Button/ButtonNavSettings/navOptions.js +32 -0
- package/dist/Editor/Elements/Button/ButtonNavSettings/style.js +55 -0
- package/dist/Editor/Elements/Button/EditorButton.js +114 -30
- package/dist/Editor/Elements/Color Picker/defaultColors.js +4 -1
- package/dist/Editor/Elements/Embed/EmbedPopup.js +1 -1
- package/dist/Editor/Elements/Form/Form.js +6 -2
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +4 -1
- package/dist/Editor/Toolbar/Mini/Options/Options.js +1 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +2 -0
- package/dist/Editor/Toolbar/toolbarGroups.js +8 -6
- package/dist/Editor/common/ColorPickerButton.js +7 -3
- package/dist/Editor/common/Section/index.js +2 -1
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +13 -9
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +25 -2
- package/dist/Editor/common/ToolbarIcon.js +2 -2
- package/dist/Editor/common/iconslist.js +21 -17
- package/dist/Editor/commonStyle.js +16 -1
- package/dist/Editor/plugins/withHTML.js +25 -4
- package/dist/Editor/plugins/withTable.js +26 -1
- package/dist/Editor/service/formSubmit.js +1 -1
- package/dist/Editor/utils/embed.js +1 -1
- package/dist/Editor/utils/grid.js +2 -4
- package/dist/Editor/utils/helper.js +53 -0
- package/dist/Editor/utils/table.js +4 -8
- package/package.json +1 -1
@@ -1,10 +1,35 @@
|
|
1
1
|
import { Editor, Range, Point, Element, Transforms, Node } from "slate";
|
2
|
+
import { TableUtil, createTableCell } from "../utils/table";
|
2
3
|
const NON_DELETABLE_BLOCKS = ["table-cell", "carousel-item"];
|
3
4
|
const withTable = editor => {
|
4
5
|
const {
|
5
6
|
deleteBackward,
|
6
|
-
deleteForward
|
7
|
+
deleteForward,
|
8
|
+
delete: slateDelete
|
7
9
|
} = editor;
|
10
|
+
editor.delete = arg => {
|
11
|
+
if (arg.reverse) {
|
12
|
+
const table = new TableUtil(editor);
|
13
|
+
const cellsSelected = table.isCellSelected(editor.selection);
|
14
|
+
if (cellsSelected) {
|
15
|
+
cellsSelected.forEach(cellPath => {
|
16
|
+
Transforms.removeNodes(editor, {
|
17
|
+
at: cellPath
|
18
|
+
});
|
19
|
+
Transforms.insertNodes(editor, createTableCell(""), {
|
20
|
+
at: cellPath
|
21
|
+
});
|
22
|
+
});
|
23
|
+
Transforms.deselect(editor, {
|
24
|
+
at: editor.selection
|
25
|
+
});
|
26
|
+
} else {
|
27
|
+
slateDelete(arg);
|
28
|
+
}
|
29
|
+
} else {
|
30
|
+
slateDelete(arg);
|
31
|
+
}
|
32
|
+
};
|
8
33
|
editor.deleteBackward = unit => {
|
9
34
|
const {
|
10
35
|
selection
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import { Transforms } from "slate";
|
2
1
|
import default_grid from "../Elements/Grid/templates/default_grid";
|
3
|
-
import insertNewLine from "./insertNewLine";
|
4
2
|
import { gridItem } from "./gridItem";
|
3
|
+
import { customInsertNode } from "./helper";
|
5
4
|
export const insertPlainGrid = count => {
|
6
5
|
const size = 12 / count;
|
7
6
|
const items = Array.from(Array(count).keys()).map(() => gridItem({
|
@@ -38,11 +37,10 @@ export const insertGrid = (editor, item, path) => {
|
|
38
37
|
const {
|
39
38
|
selection
|
40
39
|
} = editor;
|
41
|
-
|
40
|
+
customInsertNode(editor, grid, {
|
42
41
|
at: path || selection.focus.path,
|
43
42
|
select: true
|
44
43
|
});
|
45
|
-
insertNewLine(editor);
|
46
44
|
} catch (err) {
|
47
45
|
console.log(err);
|
48
46
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Editor, Node, Transforms, Element } from "slate";
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
|
+
import insertNewLine from "./insertNewLine";
|
3
4
|
export const windowVar = {};
|
4
5
|
export const formatDate = (date, format = "MM/DD/YYYY") => {
|
5
6
|
if (!date) return "";
|
@@ -149,4 +150,56 @@ export const isListItem = editor => {
|
|
149
150
|
match: n => !Editor.isEditor(n) && Element.isElement(n) && format.indexOf(n.type) > -1
|
150
151
|
});
|
151
152
|
return node;
|
153
|
+
};
|
154
|
+
const getNode = (editor, path) => {
|
155
|
+
try {
|
156
|
+
return Node.get(editor, path);
|
157
|
+
} catch (err) {
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
};
|
161
|
+
export const customInsertNode = (editor, insertNode, defaultInsertOptions = {}) => {
|
162
|
+
const [parent, parentPath] = Editor.parent(editor, editor.selection.focus.path);
|
163
|
+
const isListItem = parent?.type === "list-item" || parent?.type === "check-list-item";
|
164
|
+
let newParentPath;
|
165
|
+
if (isListItem) {
|
166
|
+
const lastPathIndex = parentPath.length - 1;
|
167
|
+
const otherPaths = parentPath.slice(0, lastPathIndex);
|
168
|
+
const nextChildrenPath = parentPath[lastPathIndex] + 1;
|
169
|
+
newParentPath = [...otherPaths, nextChildrenPath];
|
170
|
+
const haveElem = getNode(editor, newParentPath);
|
171
|
+
if (haveElem) {
|
172
|
+
Transforms.splitNodes(editor, {
|
173
|
+
at: newParentPath
|
174
|
+
});
|
175
|
+
}
|
176
|
+
const {
|
177
|
+
anchor,
|
178
|
+
focus
|
179
|
+
} = editor.selection;
|
180
|
+
|
181
|
+
// if editor has selection, e.g /table, /grid is selected, delete that selection
|
182
|
+
if (focus.offset > anchor.offset) {
|
183
|
+
Transforms.delete(editor, {
|
184
|
+
at: editor.selection
|
185
|
+
});
|
186
|
+
}
|
187
|
+
}
|
188
|
+
const insertOptions = {
|
189
|
+
...defaultInsertOptions
|
190
|
+
};
|
191
|
+
if (isListItem) {
|
192
|
+
insertOptions.at = editor.selection.focus;
|
193
|
+
}
|
194
|
+
Transforms.insertNodes(editor, insertNode, insertOptions);
|
195
|
+
insertNewLine(editor);
|
196
|
+
};
|
197
|
+
export const decodeAndParseBase64 = encodedString => {
|
198
|
+
// Decode the Base64-encoded string
|
199
|
+
const decodedString = atob(encodedString);
|
200
|
+
|
201
|
+
// URL-decode the decoded string
|
202
|
+
const decodedURLString = decodeURIComponent(decodedString);
|
203
|
+
const jsonData = JSON.parse(decodedURLString);
|
204
|
+
return jsonData;
|
152
205
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Transforms, Editor, Range, Element, Path, Node } from "slate";
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
|
-
import
|
3
|
+
import { customInsertNode } from "./helper";
|
4
4
|
const prefixKey = (obj, pk = "") => {
|
5
5
|
return Object.keys(obj).reduce((a, b) => {
|
6
6
|
a[`${pk}${b}`] = obj[b];
|
@@ -36,11 +36,7 @@ export class TableUtil {
|
|
36
36
|
length: columns
|
37
37
|
}, () => ""));
|
38
38
|
const newTable = createTableNode(cellText, rows, columns);
|
39
|
-
|
40
|
-
// to insert in current line
|
41
|
-
// at: this.editor.selection.anchor.path,
|
42
|
-
});
|
43
|
-
insertNewLine(this.editor);
|
39
|
+
customInsertNode(this.editor, newTable);
|
44
40
|
};
|
45
41
|
removeTable = () => {
|
46
42
|
Transforms.removeNodes(this.editor, {
|
@@ -318,7 +314,7 @@ export class TableUtil {
|
|
318
314
|
};
|
319
315
|
isCellSelected = selection => {
|
320
316
|
try {
|
321
|
-
if (!selection
|
317
|
+
if (!selection) {
|
322
318
|
return false;
|
323
319
|
}
|
324
320
|
const [tableNode] = Editor.nodes(this.editor, {
|
@@ -332,7 +328,7 @@ export class TableUtil {
|
|
332
328
|
anchor,
|
333
329
|
focus
|
334
330
|
} = this.editor.selection || {};
|
335
|
-
if (tableNode && tableNode[0] &&
|
331
|
+
if (tableNode && tableNode[0] && focus?.path) {
|
336
332
|
let startCell = anchor?.path;
|
337
333
|
let endCell = focus?.path;
|
338
334
|
|