@flozy/editor 4.9.3 → 4.9.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/Editor.css +21 -11
- package/dist/Editor/Elements/AI/PopoverAIInput.js +3 -3
- package/dist/Editor/Elements/AI/Styles.js +7 -7
- package/dist/Editor/Elements/Carousel/Carousel.js +3 -0
- package/dist/Editor/Elements/Divider/Divider.js +4 -2
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- package/dist/Editor/Elements/Search/SearchAttachment.js +6 -9
- package/dist/Editor/Elements/Search/SearchButton.js +4 -4
- package/dist/Editor/Elements/Search/SearchList.js +7 -5
- package/dist/Editor/Elements/Signature/SignaturePopup.js +2 -1
- package/dist/Editor/Elements/Table/AddRowCol.js +3 -2
- package/dist/Editor/Elements/Table/DragButton.js +6 -2
- package/dist/Editor/Elements/Table/DragStyles.js +62 -36
- package/dist/Editor/Elements/Table/Styles.js +1 -1
- package/dist/Editor/Elements/Table/Table.js +8 -3
- package/dist/Editor/Elements/Table/TableCell.js +24 -10
- package/dist/Editor/Elements/Table/tableHelper.js +83 -0
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -3
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +26 -22
- package/dist/Editor/Toolbar/PopupTool/index.js +13 -11
- package/dist/Editor/common/MentionsPopup/Styles.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +10 -35
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
- package/dist/Editor/common/StyleBuilder/formStyle.js +101 -69
- package/dist/Editor/common/StyleBuilder/index.js +8 -34
- package/dist/Editor/common/Uploader.js +8 -0
- package/dist/Editor/common/iconListV2.js +2 -0
- package/dist/Editor/common/iconslist.js +1 -0
- package/dist/Editor/helper/deserialize/index.js +5 -11
- package/dist/Editor/hooks/useEditorScroll.js +1 -1
- package/dist/Editor/hooks/useTable.js +37 -30
- package/dist/Editor/utils/helper.js +11 -0
- package/package.json +1 -1
@@ -1,8 +1,11 @@
|
|
1
1
|
import { ClickAwayListener } from "@mui/material";
|
2
2
|
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
3
3
|
import { clearCellText } from "../utils/table";
|
4
|
-
import { Editor, Element, Transforms } from "slate";
|
4
|
+
import { Editor, Element, Transforms, Range } from "slate";
|
5
5
|
import { DndContext, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
6
|
+
import { encodeToBase64 } from "../utils/helper";
|
7
|
+
import { serializeToText } from "../utils/serializeToText";
|
8
|
+
import { createCopiedTableStructure, getRectangleBounds, tableNodeToDom } from "../Elements/Table/tableHelper";
|
6
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
10
|
const handleDragEnd = (dragData, editor, resetAll) => {
|
8
11
|
const {
|
@@ -47,29 +50,6 @@ const handleDragEnd = (dragData, editor, resetAll) => {
|
|
47
50
|
}
|
48
51
|
}
|
49
52
|
};
|
50
|
-
const getRectangleBounds = tableSelection => {
|
51
|
-
const {
|
52
|
-
startCellPath,
|
53
|
-
endCellPath
|
54
|
-
} = tableSelection;
|
55
|
-
if (!startCellPath?.length) return [];
|
56
|
-
const startPath = startCellPath.slice(0, -2);
|
57
|
-
const startCell = startCellPath.slice(-2);
|
58
|
-
const endCell = endCellPath.slice(-2);
|
59
|
-
const [startRow, startCol] = startCell;
|
60
|
-
const [endRow, endCol] = endCell?.length ? endCell : startCell;
|
61
|
-
const minRow = Math.min(startRow, endRow);
|
62
|
-
const maxRow = Math.max(startRow, endRow);
|
63
|
-
const minCol = Math.min(startCol, endCol);
|
64
|
-
const maxCol = Math.max(startCol, endCol);
|
65
|
-
const selectedPaths = [];
|
66
|
-
for (let row = minRow; row <= maxRow; row++) {
|
67
|
-
for (let col = minCol; col <= maxCol; col++) {
|
68
|
-
selectedPaths.push([...startPath, row, col]);
|
69
|
-
}
|
70
|
-
}
|
71
|
-
return selectedPaths;
|
72
|
-
};
|
73
53
|
const TableContext = /*#__PURE__*/createContext();
|
74
54
|
export function getDefaultTableSelection() {
|
75
55
|
return {
|
@@ -135,22 +115,49 @@ export const TableProvider = ({
|
|
135
115
|
}
|
136
116
|
}
|
137
117
|
};
|
118
|
+
const handleCopy = event => {
|
119
|
+
try {
|
120
|
+
const isTextSelected = editor?.selection && !Range.isCollapsed(editor.selection);
|
121
|
+
const customCopy = tableSelection?.startCellPath?.length;
|
122
|
+
if (customCopy) {
|
123
|
+
event.preventDefault(); // Prevent default copy behavior
|
124
|
+
|
125
|
+
const {
|
126
|
+
tablePath
|
127
|
+
} = otherProps;
|
128
|
+
const [node] = Editor.node(editor, tablePath);
|
129
|
+
const selectedText = isTextSelected ? Editor.string(editor, editor.selection) : "";
|
130
|
+
const copiedTableNode = createCopiedTableStructure(editor, tableSelection, node, tablePath, selectedText);
|
131
|
+
const tableNode = [copiedTableNode];
|
132
|
+
const encodedTableNode = encodeToBase64(tableNode);
|
133
|
+
event.clipboardData.setData("application/x-slate-fragment", encodedTableNode);
|
134
|
+
const textData = selectedText || serializeToText(tableNode);
|
135
|
+
event.clipboardData.setData("text/plain", textData);
|
136
|
+
const tableDom = tableNodeToDom(copiedTableNode, selectedText);
|
137
|
+
event.clipboardData.setData("text/html", tableDom?.outerHTML);
|
138
|
+
}
|
139
|
+
} catch (err) {
|
140
|
+
console.log(err);
|
141
|
+
}
|
142
|
+
};
|
138
143
|
window.addEventListener("keydown", handleKeyDown);
|
144
|
+
window.addEventListener("copy", handleCopy);
|
139
145
|
return () => {
|
140
146
|
window.removeEventListener("keydown", handleKeyDown);
|
147
|
+
window.removeEventListener("copy", handleCopy);
|
141
148
|
};
|
142
|
-
}, [tableSelection]);
|
149
|
+
}, [tableSelection, editor, tableSelection]);
|
143
150
|
useEffect(() => {
|
144
151
|
// on deselect table on insert
|
145
152
|
Transforms.deselect(editor);
|
146
153
|
}, []);
|
147
154
|
return /*#__PURE__*/_jsx(TableContext.Provider, {
|
148
155
|
value: values,
|
149
|
-
children: /*#__PURE__*/_jsx(
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
156
|
+
children: /*#__PURE__*/_jsx(DndContext, {
|
157
|
+
sensors: sensors,
|
158
|
+
onDragEnd: data => handleDragEnd(data, editor, resetAll),
|
159
|
+
children: /*#__PURE__*/_jsx(ClickAwayListener, {
|
160
|
+
onClickAway: () => setTableSelection(getDefaultTableSelection()),
|
154
161
|
children: /*#__PURE__*/_jsx("div", {
|
155
162
|
children: children
|
156
163
|
})
|
@@ -209,6 +209,17 @@ export const decodeAndParseBase64 = encodedString => {
|
|
209
209
|
const jsonData = JSON.parse(decodedURLString);
|
210
210
|
return jsonData;
|
211
211
|
};
|
212
|
+
export const encodeToBase64 = data => {
|
213
|
+
// Convert the data to a JSON string
|
214
|
+
const jsonString = JSON.stringify(data);
|
215
|
+
|
216
|
+
// URL-encode the JSON string
|
217
|
+
const encodedURLString = encodeURIComponent(jsonString);
|
218
|
+
|
219
|
+
// Base64-encode the URL-encoded string
|
220
|
+
const base64EncodedString = btoa(encodedURLString);
|
221
|
+
return base64EncodedString;
|
222
|
+
};
|
212
223
|
export const hasVerticalScrollbar = (element = {}) => {
|
213
224
|
return element.scrollHeight > element.clientHeight;
|
214
225
|
};
|