@flozy/editor 4.4.8 → 4.4.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +2 -14
- package/dist/Editor/CommonEditor.js +13 -30
- package/dist/Editor/Editor.css +7 -1
- package/dist/Editor/Elements/AI/AIInput.js +4 -5
- package/dist/Editor/Elements/AI/PopoverAIInput.js +40 -29
- package/dist/Editor/Elements/AI/Styles.js +1 -1
- package/dist/Editor/Elements/Button/EditorButton.js +8 -4
- package/dist/Editor/Elements/Embed/Embed.css +1 -1
- package/dist/Editor/Elements/Embed/Image.js +4 -3
- package/dist/Editor/Elements/Embed/Video.js +4 -4
- package/dist/Editor/Elements/Form/Form.js +0 -1
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +3 -12
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +25 -0
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +3 -1
- package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +4 -0
- package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +5 -1
- package/dist/Editor/Elements/FreeGrid/styles.js +37 -0
- package/dist/Editor/Elements/Mentions/Mentions.js +2 -3
- package/dist/Editor/Elements/Signature/SignaturePopup.js +7 -3
- package/dist/Editor/Elements/Signature/Signed.js +1 -1
- package/dist/Editor/Elements/SimpleText/index.js +3 -2
- package/dist/Editor/Elements/Table/TableRow.js +1 -1
- package/dist/Editor/Styles/EditorStyles.js +2 -2
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -2
- package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +35 -29
- package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +35 -30
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -4
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +22 -38
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +0 -1
- package/dist/Editor/Toolbar/PopupTool/index.js +5 -5
- package/dist/Editor/common/FontLoader/FontLoader.js +6 -6
- package/dist/Editor/common/Icon.js +1 -1
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +14 -1
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +53 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +32 -2
- package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +2 -1
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +5 -3
- package/dist/Editor/common/RnD/index.js +17 -17
- package/dist/Editor/common/Section/index.js +11 -1
- package/dist/Editor/common/Section/styles.js +14 -0
- package/dist/Editor/common/Shorthands/mentions.js +1 -1
- package/dist/Editor/helper/RnD/focusNode.js +70 -0
- package/dist/Editor/helper/index.js +4 -2
- package/dist/Editor/hooks/useBreakpoints.js +1 -1
- package/dist/Editor/hooks/useMentions.js +13 -39
- package/dist/Editor/hooks/withCommon.js +2 -7
- package/dist/Editor/plugins/withHTML.js +0 -29
- package/dist/Editor/utils/Decorators/highlightSelection.js +16 -0
- package/dist/Editor/utils/Decorators/index.js +3 -2
- package/dist/Editor/utils/SlateUtilityFunctions.js +18 -0
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +24 -1
- package/dist/Editor/utils/customHooks/useResize.js +4 -5
- package/dist/Editor/utils/events.js +36 -0
- package/dist/Editor/utils/helper.js +1 -8
- package/package.json +1 -1
@@ -17,6 +17,7 @@ import VirtualElement from "./VirtualElement";
|
|
17
17
|
import { ItemTypes } from "./ElementSettings/settingsConstants";
|
18
18
|
import { focusSelection, clearSelection } from "../../helper";
|
19
19
|
import { selectText } from "../../utils/helper";
|
20
|
+
import { removeSign } from "./ElementSettings/OtherSettings";
|
20
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
21
22
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
22
23
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
@@ -155,6 +156,7 @@ const RnD = props => {
|
|
155
156
|
switch (e.detail) {
|
156
157
|
case 1:
|
157
158
|
if (!enable) {
|
159
|
+
// focusSelection(editor, { path });
|
158
160
|
setSelectedElement({
|
159
161
|
path: str_path,
|
160
162
|
enable: 1,
|
@@ -162,7 +164,6 @@ const RnD = props => {
|
|
162
164
|
anchorEl: rndRef?.current
|
163
165
|
});
|
164
166
|
}
|
165
|
-
// ReactEditor.focus(editor);
|
166
167
|
break;
|
167
168
|
case 2:
|
168
169
|
focusSelection(editor, {
|
@@ -225,6 +226,13 @@ const RnD = props => {
|
|
225
226
|
selectedActionPath: path
|
226
227
|
});
|
227
228
|
break;
|
229
|
+
case "signatureSettings":
|
230
|
+
setSelectedElement({
|
231
|
+
...selectedElementProps,
|
232
|
+
selectedAction: actionType,
|
233
|
+
selectedActionPath: path
|
234
|
+
});
|
235
|
+
break;
|
228
236
|
case "imageFrame":
|
229
237
|
setSelectedElement({
|
230
238
|
...selectedElementProps,
|
@@ -233,6 +241,9 @@ const RnD = props => {
|
|
233
241
|
selectedActionPath: path
|
234
242
|
});
|
235
243
|
break;
|
244
|
+
case "removeSign":
|
245
|
+
removeSign(editor, sp);
|
246
|
+
break;
|
236
247
|
case "saveAsTemplate":
|
237
248
|
const curPath = type === "parent" ? Path.parent(path) : path;
|
238
249
|
const currentNode = Node.get(editor, curPath);
|
@@ -270,7 +281,9 @@ const RnD = props => {
|
|
270
281
|
dragOver: null
|
271
282
|
}, null);
|
272
283
|
}
|
284
|
+
// focusSelection(editor, { path: updated_at });
|
273
285
|
};
|
286
|
+
|
274
287
|
const onDragStart = e => {
|
275
288
|
e.preventDefault();
|
276
289
|
if (e?.target?.dataset?.path?.split(",").join("|") === sp) {
|
@@ -299,7 +312,7 @@ const RnD = props => {
|
|
299
312
|
width,
|
300
313
|
height
|
301
314
|
},
|
302
|
-
isDragging:
|
315
|
+
isDragging: true,
|
303
316
|
parentPath: getParentSectionPath({
|
304
317
|
ref
|
305
318
|
}, ".freegrid-container-parent")
|
@@ -311,15 +324,13 @@ const RnD = props => {
|
|
311
324
|
};
|
312
325
|
const onDrag = (e, d) => {
|
313
326
|
e.preventDefault();
|
314
|
-
e.stopPropagation();
|
315
327
|
const lines = getClosestDraggable(e.clientX, e.clientY, `.freegrid-section_${parentSectionPath} .freegrid-container .freegrid-item.inactive-drag`.replace(/\|/g, "\\|"), ".freegrid-item.active-drag:not(.exclude-virtual)");
|
316
|
-
console.log(lines);
|
317
328
|
setAbsPosition({
|
318
329
|
...absPosition,
|
319
330
|
"--zIndex": 2000
|
320
331
|
});
|
321
332
|
updateDragging({
|
322
|
-
isDragging:
|
333
|
+
isDragging: true,
|
323
334
|
position: {
|
324
335
|
...dragging.position,
|
325
336
|
x: e.clientX,
|
@@ -337,7 +348,7 @@ const RnD = props => {
|
|
337
348
|
const onDragStop = (e, d) => {
|
338
349
|
e.preventDefault();
|
339
350
|
e.stopPropagation();
|
340
|
-
if (dragging?.isDragging
|
351
|
+
if (dragging?.isDragging && dragging?.position?.strXY) {
|
341
352
|
d.x = e.x;
|
342
353
|
d.y = e.y;
|
343
354
|
d.offsetX = e.offsetX;
|
@@ -370,17 +381,6 @@ const RnD = props => {
|
|
370
381
|
setAbsPosition({
|
371
382
|
...ud
|
372
383
|
});
|
373
|
-
} else {
|
374
|
-
// invalid drags
|
375
|
-
// found in dev mode and in safari browser
|
376
|
-
updateDragging({
|
377
|
-
isDragging: 0,
|
378
|
-
position: {},
|
379
|
-
lines: [],
|
380
|
-
active: false,
|
381
|
-
id: null
|
382
|
-
});
|
383
|
-
setPosition({});
|
384
384
|
}
|
385
385
|
};
|
386
386
|
const onResizeStop = (e, direction, ref, d, position) => {
|
@@ -104,6 +104,13 @@ const Section = props => {
|
|
104
104
|
};
|
105
105
|
const isFreeGrid = element?.children?.find(f => f.type === "freegrid");
|
106
106
|
const needHover = element?.children?.find(f => f.type === "grid" && !list_types.includes(element.type)) ? "needHover" : "";
|
107
|
+
let tempProps = {};
|
108
|
+
if (element?.type === "temp") {
|
109
|
+
tempProps = {
|
110
|
+
"--left": `${element?.left}px`,
|
111
|
+
"--top": `${element?.top}px`
|
112
|
+
};
|
113
|
+
}
|
107
114
|
const sectionBgImage = sectionBackgroundImage && sectionBackgroundImage !== "none" ? {
|
108
115
|
backgroundImage: `url(${sectionBackgroundImage})`
|
109
116
|
} : {};
|
@@ -122,7 +129,10 @@ const Section = props => {
|
|
122
129
|
}, theme);
|
123
130
|
return path.length === 1 && !isFreeGrid ? /*#__PURE__*/_jsxs(Box, {
|
124
131
|
component: "div",
|
125
|
-
className: `ed-section-wrapper ${readOnly ? "" : "hselect"} ${needHover}`,
|
132
|
+
className: `ed-section-wrapper ${readOnly ? "" : "hselect"} ${needHover} is-${element?.type}`,
|
133
|
+
style: {
|
134
|
+
...tempProps
|
135
|
+
},
|
126
136
|
sx: {
|
127
137
|
...classes.root,
|
128
138
|
background: sectionBgColor,
|
@@ -52,6 +52,20 @@ const SectionStyle = theme => ({
|
|
52
52
|
[theme.breakpoints.between("xs", "md")]: {
|
53
53
|
maxWidth: `320px !important`
|
54
54
|
}
|
55
|
+
},
|
56
|
+
"&.is-temp": {
|
57
|
+
position: "fixed",
|
58
|
+
background: "red",
|
59
|
+
padding: "12px",
|
60
|
+
width: "10px",
|
61
|
+
height: "10px",
|
62
|
+
// left: 0,
|
63
|
+
// top: 0,
|
64
|
+
margin: "auto",
|
65
|
+
left: "var(--left)",
|
66
|
+
top: "var(--top)",
|
67
|
+
zIndex: 1000,
|
68
|
+
pointerEvents: "none"
|
55
69
|
}
|
56
70
|
}
|
57
71
|
});
|
@@ -3,6 +3,6 @@ const mentions = props => {
|
|
3
3
|
CHARACTERS,
|
4
4
|
search
|
5
5
|
} = props;
|
6
|
-
return CHARACTERS.filter(c => c
|
6
|
+
return CHARACTERS.filter(c => c.name.toLowerCase().startsWith(search?.toLowerCase())).slice(0, 10);
|
7
7
|
};
|
8
8
|
export default mentions;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import { Editor, Transforms } from "slate";
|
2
|
+
import { ReactEditor } from "slate-react";
|
3
|
+
const TEMP_NODE_ID = "temp-focus-node";
|
4
|
+
const ensureTemporaryFocusNode = (editor, selectedDOM) => {
|
5
|
+
// Check if the temporary focus node already exists
|
6
|
+
const {
|
7
|
+
left,
|
8
|
+
top
|
9
|
+
} = selectedDOM?.getBoundingClientRect();
|
10
|
+
const [tempNodeEntry] = Editor.nodes(editor, {
|
11
|
+
at: [],
|
12
|
+
match: n => n.temp === TEMP_NODE_ID
|
13
|
+
});
|
14
|
+
if (!tempNodeEntry) {
|
15
|
+
// If not, insert the temporary focus node at the start of the editor
|
16
|
+
Transforms.insertNodes(editor, {
|
17
|
+
type: "temp",
|
18
|
+
temp: TEMP_NODE_ID,
|
19
|
+
children: [{
|
20
|
+
text: ""
|
21
|
+
}],
|
22
|
+
left,
|
23
|
+
top
|
24
|
+
}, {
|
25
|
+
at: [editor.children.length]
|
26
|
+
});
|
27
|
+
} else {
|
28
|
+
Transforms.setNodes(editor, {
|
29
|
+
type: "temp",
|
30
|
+
temp: TEMP_NODE_ID,
|
31
|
+
children: [{
|
32
|
+
text: ""
|
33
|
+
}],
|
34
|
+
left,
|
35
|
+
top
|
36
|
+
}, {
|
37
|
+
at: tempNodeEntry[1]
|
38
|
+
});
|
39
|
+
}
|
40
|
+
};
|
41
|
+
export const focusUsingTemporaryNode = (editor, selectedDOM) => {
|
42
|
+
// de-select and select
|
43
|
+
Transforms.deselect(editor);
|
44
|
+
|
45
|
+
// Ensure the temporary node exists
|
46
|
+
ensureTemporaryFocusNode(editor, selectedDOM);
|
47
|
+
|
48
|
+
// Select the temporary node without causing scroll
|
49
|
+
const [tempNodeEntry] = Editor.nodes(editor, {
|
50
|
+
at: [],
|
51
|
+
match: n => n.temp === TEMP_NODE_ID
|
52
|
+
});
|
53
|
+
if (tempNodeEntry) {
|
54
|
+
const [, path] = tempNodeEntry;
|
55
|
+
Transforms.select(editor, path); // Move selection to the temp node
|
56
|
+
}
|
57
|
+
|
58
|
+
ReactEditor.focus(editor);
|
59
|
+
};
|
60
|
+
export const cleanupTemporaryFocusNode = editor => {
|
61
|
+
// Remove the temporary focus node if it exists
|
62
|
+
for (const [, path] of Editor.nodes(editor, {
|
63
|
+
at: [],
|
64
|
+
match: n => n.temp === TEMP_NODE_ID
|
65
|
+
})) {
|
66
|
+
Transforms.removeNodes(editor, {
|
67
|
+
at: path
|
68
|
+
});
|
69
|
+
}
|
70
|
+
};
|
@@ -4,6 +4,7 @@ import html2canvas from "html2canvas";
|
|
4
4
|
import { rectIntersection, closestCenter } from "@dnd-kit/core";
|
5
5
|
import { getQueryStrings } from "../utils/SlateUtilityFunctions";
|
6
6
|
import { Node } from "slate";
|
7
|
+
// import { focusUsingTemporaryNode } from "./RnD/focusNode";
|
7
8
|
const HIDE_PLACHOLDERS = ["grid", "grid-item", "table"];
|
8
9
|
const PREVIEW_IMAGE_HIDE_CLASS = ["grid-container-toolbar", "grid-item-toolbar", "element-toolbar", "mini-tool-wrpr-ei", "element-selector", "element-selector-ctrl"];
|
9
10
|
const RND_ITEMS = ["freegridItem", "freegridBox"];
|
@@ -254,8 +255,9 @@ export const focusSelection = (editor, {
|
|
254
255
|
const selectedDOM = ReactEditor.toDOMNode(editor, selectedNode);
|
255
256
|
selectedDOM.scrollIntoView({
|
256
257
|
behavior: "smooth",
|
257
|
-
block: "
|
258
|
+
block: "nearest"
|
258
259
|
});
|
260
|
+
// focusUsingTemporaryNode(editor, selectedDOM);
|
259
261
|
} catch (err) {
|
260
262
|
console.log(err);
|
261
263
|
}
|
@@ -302,7 +304,7 @@ export const getTextColor = (color = "") => {
|
|
302
304
|
WebkitTextFillColor: "transparent !important",
|
303
305
|
color: "transparent !important",
|
304
306
|
caretColor: "black",
|
305
|
-
|
307
|
+
"& span": {
|
306
308
|
color: "transparent !important"
|
307
309
|
}
|
308
310
|
} : {
|
@@ -13,7 +13,7 @@ const getStartEnd = ({
|
|
13
13
|
// Get start and end, modify it as we move along.
|
14
14
|
let [start, end] = Range.edges(selection);
|
15
15
|
|
16
|
-
// Move backwards
|
16
|
+
// Move backwards
|
17
17
|
while (true) {
|
18
18
|
const before = Editor.before(editor, start, {
|
19
19
|
unit: "character"
|
@@ -22,15 +22,16 @@ const getStartEnd = ({
|
|
22
22
|
anchor: before,
|
23
23
|
focus: start
|
24
24
|
});
|
25
|
-
if (before) {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
start = before;
|
30
|
-
} else {
|
31
|
-
start = before;
|
25
|
+
if (before && wordBefore && SHORTHAND_CMDS.indexOf(wordBefore) < 0) {
|
26
|
+
start = before;
|
27
|
+
if (start.offset === 0) {
|
28
|
+
// Means we've wrapped to beginning of another block
|
32
29
|
break;
|
33
30
|
}
|
31
|
+
} else if (SHORTHAND_CMDS.indexOf(wordBefore) >= 0) {
|
32
|
+
// reached the character end
|
33
|
+
start = before;
|
34
|
+
break;
|
34
35
|
} else {
|
35
36
|
break;
|
36
37
|
}
|
@@ -40,38 +41,11 @@ const getStartEnd = ({
|
|
40
41
|
focus: end
|
41
42
|
};
|
42
43
|
const word = Editor.string(editor, wordRange);
|
43
|
-
const firstChar = word[0];
|
44
|
-
|
45
|
-
// Handle the commands
|
46
|
-
if (firstChar === '@') {
|
47
|
-
// Only trigger @ if preceded by a space
|
48
|
-
const isPrecededBySpace = Editor.string(editor, {
|
49
|
-
anchor: {
|
50
|
-
path: start.path,
|
51
|
-
offset: start.offset - 1
|
52
|
-
},
|
53
|
-
focus: start
|
54
|
-
}).trim() === "";
|
55
|
-
if (isPrecededBySpace) {
|
56
|
-
return {
|
57
|
-
word,
|
58
|
-
search: word.substring(1),
|
59
|
-
target: wordRange,
|
60
|
-
type: TYPES[firstChar]
|
61
|
-
};
|
62
|
-
}
|
63
|
-
} else if (firstChar === '/') {
|
64
|
-
return {
|
65
|
-
word,
|
66
|
-
search: word.substring(1),
|
67
|
-
target: wordRange,
|
68
|
-
type: TYPES[firstChar]
|
69
|
-
};
|
70
|
-
}
|
71
44
|
return {
|
72
|
-
word
|
73
|
-
|
74
|
-
|
45
|
+
word,
|
46
|
+
search: word?.substring(1, word.length),
|
47
|
+
target: wordRange,
|
48
|
+
type: TYPES[word[0]]
|
75
49
|
};
|
76
50
|
} catch (err) {
|
77
51
|
return {
|
@@ -9,12 +9,7 @@ import withLayout from "../plugins/withLayout";
|
|
9
9
|
import withHtml from "../plugins/withHTML";
|
10
10
|
import withErrorHandling from "./withErrorHandling";
|
11
11
|
import withCustomDeleteBackward from "../plugins/withCustomDeleteBackward";
|
12
|
-
const withCommon = (props, {
|
13
|
-
needLayout
|
14
|
-
isChatEditor = false
|
15
|
-
}) => {
|
16
|
-
const editor = needLayout ? withErrorHandling(withHtml(withEquation(withLayout(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))))) : withErrorHandling(withHtml(withEquation(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))));
|
17
|
-
editor.isChatEditor = isChatEditor;
|
18
|
-
return editor;
|
12
|
+
const withCommon = (props, rest = {}) => {
|
13
|
+
return rest.needLayout ? withErrorHandling(withHtml(withEquation(withLayout(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))))) : withErrorHandling(withHtml(withEquation(withHistory(withEmbeds(withTables(withLinks(withMentions(withCustomDeleteBackward(withReact(props))))))))));
|
19
14
|
};
|
20
15
|
export default withCommon;
|
@@ -114,23 +114,6 @@ const withHtml = editor => {
|
|
114
114
|
const defaultInsert = loopChildren(decoded, true);
|
115
115
|
if (defaultInsert) {
|
116
116
|
insertData(data);
|
117
|
-
// } else if (editor.isChatEditor) {
|
118
|
-
// // Only convert table to paragraphs if in chat editor mode
|
119
|
-
// const paragraphs = decoded.map(row =>
|
120
|
-
// row.children.map(cell =>
|
121
|
-
// cell.children.map(paragraph =>
|
122
|
-
// paragraph.children.map(textNode => textNode.text).join('')
|
123
|
-
// ).join(' ')
|
124
|
-
// ).join(' ')
|
125
|
-
// ).join('\n'); // Joining with a newline for separate paragraphs
|
126
|
-
|
127
|
-
// // Insert text as paragraphs
|
128
|
-
// const textNodes = paragraphs.split('\n').map(text => ({
|
129
|
-
// type: 'paragraph',
|
130
|
-
// children: [{ text }]
|
131
|
-
// }));
|
132
|
-
|
133
|
-
// Transforms.insertNodes(editor, textNodes);
|
134
117
|
} else {
|
135
118
|
// do not paste table, grid inside table cell
|
136
119
|
// only plain text for internal paste
|
@@ -144,9 +127,6 @@ const withHtml = editor => {
|
|
144
127
|
const parsed = new DOMParser().parseFromString(html, "text/html");
|
145
128
|
const isGoogleSheet = parsed.body.querySelector("google-sheets-html-origin");
|
146
129
|
if (isGoogleSheet) {
|
147
|
-
if (editor.isChatEditor) {
|
148
|
-
return;
|
149
|
-
}
|
150
130
|
const table = parsed.body.querySelector("table");
|
151
131
|
const colGrp = table.querySelector("colgroup");
|
152
132
|
if (colGrp) {
|
@@ -158,15 +138,6 @@ const withHtml = editor => {
|
|
158
138
|
}
|
159
139
|
const fragment = deserialize(parsed.body);
|
160
140
|
const formattedFragment = formatFragment[eltype] ? formatFragment[eltype](fragment) : fragment;
|
161
|
-
let is_img_table = false;
|
162
|
-
formattedFragment.map(f => {
|
163
|
-
if (f.type === 'image' || f?.type?.includes('table')) {
|
164
|
-
is_img_table = true;
|
165
|
-
}
|
166
|
-
});
|
167
|
-
if (editor.isChatEditor && is_img_table) {
|
168
|
-
return;
|
169
|
-
}
|
170
141
|
handleInsert(editor, () => Transforms.insertFragment(editor, formattedFragment), formattedFragment);
|
171
142
|
return;
|
172
143
|
} else {
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { Editor, Range, Text } from "slate";
|
2
|
+
const highlightSelection = ([node, path], editor) => {
|
3
|
+
if (Text.isText(node) && editor.selection) {
|
4
|
+
const intersection = Range.intersection(editor.selection, Editor.range(editor, path));
|
5
|
+
if (intersection == null) {
|
6
|
+
return [];
|
7
|
+
}
|
8
|
+
const range = {
|
9
|
+
highlight: true,
|
10
|
+
...intersection
|
11
|
+
};
|
12
|
+
return [range];
|
13
|
+
}
|
14
|
+
return [];
|
15
|
+
};
|
16
|
+
export default highlightSelection;
|
@@ -1,5 +1,6 @@
|
|
1
|
+
import highlightSelection from "./highlightSelection";
|
1
2
|
import link from "./link";
|
2
|
-
const decorators = d => {
|
3
|
-
return [...link(d)];
|
3
|
+
const decorators = (d, editor) => {
|
4
|
+
return [...link(d, editor), ...highlightSelection(d, editor)];
|
4
5
|
};
|
5
6
|
export default decorators;
|
@@ -232,6 +232,15 @@ export const getMarked = (leaf, children, theme) => {
|
|
232
232
|
})
|
233
233
|
});
|
234
234
|
}
|
235
|
+
if (leaf.highlight) {
|
236
|
+
children = /*#__PURE__*/_jsx("span", {
|
237
|
+
style: {
|
238
|
+
background: "#EAEBFE",
|
239
|
+
color: "inherit"
|
240
|
+
},
|
241
|
+
children: children
|
242
|
+
});
|
243
|
+
}
|
235
244
|
if (leaf.decoration === "link") {
|
236
245
|
children = /*#__PURE__*/_jsx("a", {
|
237
246
|
style: {
|
@@ -529,6 +538,15 @@ export const getBlock = props => {
|
|
529
538
|
return /*#__PURE__*/_jsx(Code, {
|
530
539
|
...props
|
531
540
|
});
|
541
|
+
// RnD Focus Node
|
542
|
+
case "temp":
|
543
|
+
return /*#__PURE__*/_jsx("span", {
|
544
|
+
...attributes,
|
545
|
+
...element.attr,
|
546
|
+
contentEditable: false,
|
547
|
+
className: "temp-focus-node",
|
548
|
+
children: children
|
549
|
+
});
|
532
550
|
default:
|
533
551
|
return /*#__PURE__*/_jsx(SimpleText, {
|
534
552
|
...props,
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { Editor, Transforms, Element as SlateElement } from "slate";
|
2
2
|
import { Box } from "@mui/material";
|
3
3
|
import { fontFamilyMap, sizeMap } from "../font";
|
4
|
+
import Table from "../../Elements/Table/Table";
|
5
|
+
import TableRow from "../../Elements/Table/TableRow";
|
6
|
+
import TableCell from "../../Elements/Table/TableCell";
|
4
7
|
import Mentions from "../../Elements/Mentions/Mentions";
|
5
8
|
import CheckList from "../../Elements/List/CheckList";
|
6
9
|
import { isEmptyTextNode } from "../../helper";
|
@@ -337,11 +340,31 @@ export const getBlock = props => {
|
|
337
340
|
...props,
|
338
341
|
isEmpty: isEmpty
|
339
342
|
});
|
343
|
+
case "table":
|
344
|
+
return /*#__PURE__*/_jsx(Table, {
|
345
|
+
...props
|
346
|
+
});
|
347
|
+
case "table-head":
|
348
|
+
return /*#__PURE__*/_jsx("thead", {
|
349
|
+
children: children
|
350
|
+
});
|
351
|
+
case "table-body":
|
352
|
+
return /*#__PURE__*/_jsx("tbody", {
|
353
|
+
children: children
|
354
|
+
});
|
355
|
+
case "table-row":
|
356
|
+
return /*#__PURE__*/_jsx(TableRow, {
|
357
|
+
...props
|
358
|
+
});
|
359
|
+
case "table-cell":
|
360
|
+
return /*#__PURE__*/_jsx(TableCell, {
|
361
|
+
...props
|
362
|
+
});
|
340
363
|
case "mention":
|
341
364
|
return /*#__PURE__*/_jsx(Mentions, {
|
342
365
|
...props
|
343
366
|
});
|
344
367
|
default:
|
345
|
-
return
|
368
|
+
return;
|
346
369
|
}
|
347
370
|
};
|
@@ -10,7 +10,7 @@ const useResize = ({
|
|
10
10
|
const defaultSize = getBreakPointsValue(allSize);
|
11
11
|
const {
|
12
12
|
width,
|
13
|
-
height
|
13
|
+
height
|
14
14
|
} = parentDOM?.getBoundingClientRect() || {
|
15
15
|
...defaultSize
|
16
16
|
};
|
@@ -50,11 +50,10 @@ const useResize = ({
|
|
50
50
|
setSize(currentSize => {
|
51
51
|
const calcWidth = (currentSize.width || width) + e.movementX;
|
52
52
|
const cWP = calcWidth / width * 100;
|
53
|
-
const calcHeight = (parseInt(currentSize.height) || height) + e.movementY;
|
54
53
|
const calc = {
|
55
|
-
width:
|
56
|
-
height:
|
57
|
-
widthInPercent: cWP > 100 ? 100 :
|
54
|
+
width: calcWidth,
|
55
|
+
height: (parseInt(currentSize.height) || height) + e.movementY,
|
56
|
+
widthInPercent: cWP > 100 ? 100 : cWP
|
58
57
|
};
|
59
58
|
latest = calc;
|
60
59
|
return calc;
|
@@ -285,4 +285,40 @@ export const enterEvent = (e, editor, isMobile) => {
|
|
285
285
|
} catch (err) {
|
286
286
|
console.log(err);
|
287
287
|
}
|
288
|
+
};
|
289
|
+
export const upDownArrowKeyEvents = (e, editor) => {
|
290
|
+
try {
|
291
|
+
const {
|
292
|
+
selection
|
293
|
+
} = editor;
|
294
|
+
if (!selection || Range.isCollapsed(selection)) {
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
const parentPath = selection.anchor.path.slice(0, -1);
|
298
|
+
const nextNodePath = [...parentPath];
|
299
|
+
const index = parentPath[parentPath.length - 1];
|
300
|
+
const parentNode = Editor.parent(editor, parentPath);
|
301
|
+
if (parentNode.children[index + 1]) {
|
302
|
+
nextNodePath[parentPath.length - 1] += 1;
|
303
|
+
} else {
|
304
|
+
return;
|
305
|
+
}
|
306
|
+
Transforms.move(editor, {
|
307
|
+
distance: 0,
|
308
|
+
unit: 'offset',
|
309
|
+
reverse: false
|
310
|
+
});
|
311
|
+
Transforms.select(editor, {
|
312
|
+
anchor: {
|
313
|
+
path: nextNodePath,
|
314
|
+
offset: 0
|
315
|
+
},
|
316
|
+
focus: {
|
317
|
+
path: nextNodePath,
|
318
|
+
offset: 0
|
319
|
+
}
|
320
|
+
});
|
321
|
+
} catch (err) {
|
322
|
+
console.log(err);
|
323
|
+
}
|
288
324
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, Node, Transforms, Element
|
1
|
+
import { Editor, Node, Transforms, Element } from "slate";
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
3
|
import insertNewLine from "./insertNewLine";
|
4
4
|
import { getDevice } from "../helper/theme";
|
@@ -470,11 +470,4 @@ export const editorThemeStyle = {
|
|
470
470
|
};
|
471
471
|
export const getEditorTheme = (themeType = "light") => {
|
472
472
|
return editorThemeStyle[themeType] || {};
|
473
|
-
};
|
474
|
-
export const getPreviousNode = editor => {
|
475
|
-
try {
|
476
|
-
const parentPath = Path.parent(editor?.selection?.anchor?.path);
|
477
|
-
const prevPath = Path.previous(parentPath);
|
478
|
-
return getNode(editor, prevPath);
|
479
|
-
} catch (err) {}
|
480
473
|
};
|