@flozy/editor 4.5.7 → 4.5.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +14 -2
- package/dist/Editor/CommonEditor.js +19 -16
- package/dist/Editor/Editor.css +1 -19
- package/dist/Editor/Elements/AI/AIInput.js +5 -4
- package/dist/Editor/Elements/AI/PopoverAIInput.js +29 -40
- package/dist/Editor/Elements/AI/Styles.js +1 -1
- package/dist/Editor/Elements/Button/EditorButton.js +4 -8
- package/dist/Editor/Elements/Embed/Embed.css +1 -1
- package/dist/Editor/Elements/Embed/Image.js +3 -4
- package/dist/Editor/Elements/Embed/Video.js +4 -4
- package/dist/Editor/Elements/Form/Form.js +1 -0
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +12 -3
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +0 -30
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +0 -2
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -3
- package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +0 -4
- package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +1 -5
- package/dist/Editor/Elements/FreeGrid/styles.js +1 -82
- package/dist/Editor/Elements/Mentions/Mentions.js +3 -2
- package/dist/Editor/Elements/Signature/SignaturePopup.js +7 -24
- package/dist/Editor/Elements/Signature/Signed.js +1 -1
- package/dist/Editor/Elements/SimpleText/index.js +8 -6
- package/dist/Editor/Elements/Table/TableRow.js +1 -1
- package/dist/Editor/Styles/EditorStyles.js +2 -2
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +29 -35
- package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +30 -35
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +4 -4
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +38 -22
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +1 -0
- 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/DragOver/index.js +1 -0
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +1 -14
- package/dist/Editor/common/RnD/ElementOptions/styles.js +0 -5
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/index.js +2 -32
- package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +1 -2
- package/dist/Editor/common/RnD/RnDCopy.js +0 -2
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +3 -5
- package/dist/Editor/common/RnD/index.js +30 -64
- package/dist/Editor/common/Section/index.js +1 -11
- package/dist/Editor/common/Section/styles.js +0 -16
- package/dist/Editor/common/Shorthands/mentions.js +1 -1
- package/dist/Editor/common/iconslist.js +0 -23
- package/dist/Editor/helper/index.js +2 -4
- package/dist/Editor/hooks/useBreakpoints.js +1 -1
- package/dist/Editor/hooks/useMentions.js +39 -13
- package/dist/Editor/hooks/useMouseMove.js +4 -5
- package/dist/Editor/hooks/withCommon.js +7 -3
- package/dist/Editor/plugins/withHTML.js +29 -0
- package/dist/Editor/utils/Decorators/index.js +2 -3
- package/dist/Editor/utils/RnD/RnDCtrlCmds.js +1 -16
- package/dist/Editor/utils/SlateUtilityFunctions.js +0 -18
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +1 -24
- package/dist/Editor/utils/customHooks/useResize.js +5 -4
- package/dist/Editor/utils/events.js +0 -36
- package/dist/Editor/utils/helper.js +39 -11
- package/package.json +1 -1
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +0 -53
- package/dist/Editor/helper/RnD/focusNode.js +0 -74
- package/dist/Editor/hooks/useDragging.js +0 -51
- package/dist/Editor/hooks/withRestrictedNodes.js +0 -48
- package/dist/Editor/utils/Decorators/highlightSelection.js +0 -16
@@ -1,7 +1,6 @@
|
|
1
1
|
import { Editor, Transforms, Node, Path } from "slate";
|
2
2
|
import { isSelectionInNodeType, getCaretPosition, onPasteRnDNode, bringItemToFB } from "../../helper";
|
3
3
|
import focusOnNewItem from "../../helper/RnD/focusOnNewItem";
|
4
|
-
import { ReactEditor } from "slate-react";
|
5
4
|
const RND_ITEM_TYPES = ["freegrid", "freegridItem", "freegridBox"];
|
6
5
|
const parsePath = path => path?.split("|").map(m => parseInt(m));
|
7
6
|
const selectAll = (event, {
|
@@ -158,7 +157,7 @@ const onBringBack = (event, {
|
|
158
157
|
console.log(err);
|
159
158
|
}
|
160
159
|
};
|
161
|
-
export const onInsertFragment = ({
|
160
|
+
export const onInsertFragment = async ({
|
162
161
|
editor,
|
163
162
|
slateNodes
|
164
163
|
}) => {
|
@@ -182,20 +181,6 @@ export const onInsertFragment = ({
|
|
182
181
|
setSelectedElement: window.updateSelectedItem
|
183
182
|
});
|
184
183
|
}
|
185
|
-
} else {
|
186
|
-
ReactEditor.focus(editor);
|
187
|
-
if (editor.children.length === 0) {
|
188
|
-
Transforms.insertNodes(editor, {
|
189
|
-
text: ""
|
190
|
-
}, {
|
191
|
-
at: [0]
|
192
|
-
});
|
193
|
-
}
|
194
|
-
Transforms.insertNodes(editor, [{
|
195
|
-
...slateNodes
|
196
|
-
}], {
|
197
|
-
at: [editor.children.length - 1]
|
198
|
-
});
|
199
184
|
}
|
200
185
|
} catch (err) {
|
201
186
|
console.log(err);
|
@@ -232,15 +232,6 @@ 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
|
-
}
|
244
235
|
if (leaf.decoration === "link") {
|
245
236
|
children = /*#__PURE__*/_jsx("a", {
|
246
237
|
style: {
|
@@ -538,15 +529,6 @@ export const getBlock = props => {
|
|
538
529
|
return /*#__PURE__*/_jsx(Code, {
|
539
530
|
...props
|
540
531
|
});
|
541
|
-
// RnD Focus Node
|
542
|
-
case "temp":
|
543
|
-
return /*#__PURE__*/_jsx("span", {
|
544
|
-
...attributes,
|
545
|
-
...element.attr,
|
546
|
-
className: "temp-focus-node",
|
547
|
-
contentEditable: false,
|
548
|
-
children: children
|
549
|
-
});
|
550
532
|
default:
|
551
533
|
return /*#__PURE__*/_jsx(SimpleText, {
|
552
534
|
...props,
|
@@ -1,9 +1,6 @@
|
|
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";
|
7
4
|
import Mentions from "../../Elements/Mentions/Mentions";
|
8
5
|
import CheckList from "../../Elements/List/CheckList";
|
9
6
|
import { isEmptyTextNode } from "../../helper";
|
@@ -340,31 +337,11 @@ export const getBlock = props => {
|
|
340
337
|
...props,
|
341
338
|
isEmpty: isEmpty
|
342
339
|
});
|
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
|
-
});
|
363
340
|
case "mention":
|
364
341
|
return /*#__PURE__*/_jsx(Mentions, {
|
365
342
|
...props
|
366
343
|
});
|
367
344
|
default:
|
368
|
-
return;
|
345
|
+
return null;
|
369
346
|
}
|
370
347
|
};
|
@@ -10,7 +10,7 @@ const useResize = ({
|
|
10
10
|
const defaultSize = getBreakPointsValue(allSize);
|
11
11
|
const {
|
12
12
|
width,
|
13
|
-
height
|
13
|
+
height = 370
|
14
14
|
} = parentDOM?.getBoundingClientRect() || {
|
15
15
|
...defaultSize
|
16
16
|
};
|
@@ -50,10 +50,11 @@ 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;
|
53
54
|
const calc = {
|
54
|
-
width: calcWidth,
|
55
|
-
height: (
|
56
|
-
widthInPercent: cWP > 100 ? 100 : cWP
|
55
|
+
width: Math.max(calcWidth, 140),
|
56
|
+
height: Math.max(calcHeight, 50),
|
57
|
+
widthInPercent: cWP > 100 ? 100 : Math.max(cWP, 15)
|
57
58
|
};
|
58
59
|
latest = calc;
|
59
60
|
return calc;
|
@@ -285,40 +285,4 @@ 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
|
-
}
|
324
288
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Editor, Node, Transforms, Element, Path } from "slate";
|
1
|
+
import { Editor, Node, Transforms, Element, Path, Range } from "slate";
|
2
2
|
import { ReactEditor } from "slate-react";
|
3
3
|
import insertNewLine from "./insertNewLine";
|
4
4
|
import { getDevice } from "../helper/theme";
|
@@ -471,19 +471,47 @@ export const editorThemeStyle = {
|
|
471
471
|
export const getEditorTheme = (themeType = "light") => {
|
472
472
|
return editorThemeStyle[themeType] || {};
|
473
473
|
};
|
474
|
-
export const
|
474
|
+
export const getPreviousNode = editor => {
|
475
475
|
try {
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
476
|
+
const parentPath = Path.parent(editor?.selection?.anchor?.path);
|
477
|
+
const previousPath = Path.previous(parentPath);
|
478
|
+
const previousNode = Node.get(editor, previousPath);
|
479
|
+
return {
|
480
|
+
previousNode,
|
481
|
+
previousPath
|
482
|
+
};
|
483
|
+
} catch (err) {
|
484
|
+
return;
|
485
|
+
}
|
486
|
+
};
|
487
|
+
export const isPageSettings = (event, editor) => {
|
488
|
+
let isPageSettingsNode = false;
|
489
|
+
try {
|
490
|
+
const {
|
491
|
+
selection
|
492
|
+
} = editor;
|
493
|
+
const cursorAtStartingPosition = !selection?.focus?.offset;
|
494
|
+
const textSelection = selection && !Range.isCollapsed(selection);
|
495
|
+
if (cursorAtStartingPosition && !textSelection) {
|
496
|
+
// on backspace, the node gonna delete will be the previous node from current position, that why getting the previous node
|
497
|
+
const {
|
498
|
+
previousNode,
|
499
|
+
previousPath
|
500
|
+
} = getPreviousNode(editor);
|
501
|
+
if (previousNode?.type === "page-settings") {
|
502
|
+
event.preventDefault(); // stops deleting backward
|
503
|
+
|
504
|
+
// move the cursor to node which is before page-settings node
|
505
|
+
const pathBeforePageSettings = Path.previous(previousPath);
|
506
|
+
const endPath = Editor.end(editor, pathBeforePageSettings);
|
507
|
+
Transforms.select(editor, endPath);
|
508
|
+
isPageSettingsNode = true;
|
482
509
|
}
|
483
510
|
}
|
484
|
-
return
|
511
|
+
return isPageSettingsNode;
|
485
512
|
} catch (err) {
|
486
|
-
|
487
|
-
|
513
|
+
// if there is no previous node error throws, user reached the starting node and startting position
|
514
|
+
isPageSettingsNode = true;
|
515
|
+
return isPageSettingsNode;
|
488
516
|
}
|
489
517
|
};
|
package/package.json
CHANGED
@@ -1,53 +0,0 @@
|
|
1
|
-
import SignaturePopup from "../../../../Elements/Signature/SignaturePopup";
|
2
|
-
import { Path, Transforms } from "slate";
|
3
|
-
import { formatDate } from "../../../../utils/helper";
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
6
|
-
const Signature = props => {
|
7
|
-
const {
|
8
|
-
onClose,
|
9
|
-
customProps,
|
10
|
-
editor,
|
11
|
-
path
|
12
|
-
} = props;
|
13
|
-
const pPath = path?.split("|")?.map(m => parseInt(m));
|
14
|
-
const element_path = [...pPath, 0];
|
15
|
-
const onSave = (data = {}) => {
|
16
|
-
onClear();
|
17
|
-
Transforms.insertNodes(editor, [{
|
18
|
-
type: "sign",
|
19
|
-
signature: null,
|
20
|
-
fontFamily: "",
|
21
|
-
signedBy: "",
|
22
|
-
signedOn: formatDate(new Date(), "MM/DD/YYYY"),
|
23
|
-
signedText: "",
|
24
|
-
children: [{
|
25
|
-
text: ""
|
26
|
-
}],
|
27
|
-
...data
|
28
|
-
}], {
|
29
|
-
at: element_path
|
30
|
-
});
|
31
|
-
const parentPath = Path.parent(element_path);
|
32
|
-
Transforms.setNodes(editor, {
|
33
|
-
childType: "sign"
|
34
|
-
}, {
|
35
|
-
at: parentPath
|
36
|
-
});
|
37
|
-
};
|
38
|
-
const onClear = () => {
|
39
|
-
Transforms.removeNodes(editor, {
|
40
|
-
at: element_path
|
41
|
-
});
|
42
|
-
};
|
43
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
44
|
-
children: /*#__PURE__*/_jsx(SignaturePopup, {
|
45
|
-
onSave: onSave,
|
46
|
-
onClear: onClear,
|
47
|
-
handleClose: onClose,
|
48
|
-
customProps: customProps,
|
49
|
-
onlyPopup: true
|
50
|
-
})
|
51
|
-
});
|
52
|
-
};
|
53
|
-
export default Signature;
|
@@ -1,74 +0,0 @@
|
|
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
|
-
type: "restrictedType",
|
21
|
-
text: ""
|
22
|
-
}],
|
23
|
-
left,
|
24
|
-
top
|
25
|
-
}, {
|
26
|
-
at: [editor.children.length]
|
27
|
-
});
|
28
|
-
}
|
29
|
-
};
|
30
|
-
export const focusUsingTemporaryNode = (editor, selectedDOM) => {
|
31
|
-
Transforms.deselect(editor);
|
32
|
-
|
33
|
-
// Ensure the temporary node exists
|
34
|
-
ensureTemporaryFocusNode(editor, selectedDOM);
|
35
|
-
|
36
|
-
// Select the temporary node without causing scroll
|
37
|
-
const [tempNodeEntry] = Editor.nodes(editor, {
|
38
|
-
at: [],
|
39
|
-
match: n => n.temp === TEMP_NODE_ID
|
40
|
-
});
|
41
|
-
if (tempNodeEntry) {
|
42
|
-
const [, path] = tempNodeEntry;
|
43
|
-
Transforms.select(editor, path);
|
44
|
-
}
|
45
|
-
ReactEditor.focus(editor);
|
46
|
-
};
|
47
|
-
export const cleanupTemporaryFocusNode = editor => {
|
48
|
-
// Remove the temporary focus node if it exists
|
49
|
-
for (const [, path] of Editor.nodes(editor, {
|
50
|
-
at: [],
|
51
|
-
match: n => n.temp === TEMP_NODE_ID
|
52
|
-
})) {
|
53
|
-
Transforms.removeNodes(editor, {
|
54
|
-
at: path
|
55
|
-
});
|
56
|
-
}
|
57
|
-
};
|
58
|
-
export const dragOverOn = (previousPath, currentPath) => {
|
59
|
-
try {
|
60
|
-
const previousElement = document.querySelector(`[data-dragoverid="${previousPath}"]`);
|
61
|
-
const currentElement = document.querySelector(`[data-dragoverid="${currentPath}"]`);
|
62
|
-
// Remove 'dragOver' class from the current element, if it exists
|
63
|
-
if (previousElement && previousElement.classList.contains("rnd-dragOver")) {
|
64
|
-
previousElement.classList.remove("rnd-dragOver");
|
65
|
-
}
|
66
|
-
|
67
|
-
// Add 'dragOver' class to the new element
|
68
|
-
if (currentElement) {
|
69
|
-
currentElement.classList.add("rnd-dragOver");
|
70
|
-
}
|
71
|
-
} catch (err) {
|
72
|
-
console.log(err);
|
73
|
-
}
|
74
|
-
};
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { useState, useCallback, useRef } from "react";
|
2
|
-
const initialState = {
|
3
|
-
id: null,
|
4
|
-
active: false,
|
5
|
-
isDragging: 0,
|
6
|
-
dragOver: false,
|
7
|
-
dragOverType: null
|
8
|
-
};
|
9
|
-
const useDragging = () => {
|
10
|
-
const [dragging, setDragging] = useState({
|
11
|
-
...initialState
|
12
|
-
});
|
13
|
-
|
14
|
-
// Ref to keep the latest draggingStatus
|
15
|
-
const draggingRef = useRef(dragging);
|
16
|
-
const updateDragging = newStatus => {
|
17
|
-
setDragging(prevStatus => {
|
18
|
-
const updatedStatus = {
|
19
|
-
...prevStatus,
|
20
|
-
...newStatus
|
21
|
-
};
|
22
|
-
draggingRef.current = updatedStatus; // Update the ref to hold latest status
|
23
|
-
return updatedStatus;
|
24
|
-
});
|
25
|
-
};
|
26
|
-
const startDragging = useCallback(data => {
|
27
|
-
// console.log("dragissue", "startDragging");
|
28
|
-
updateDragging({
|
29
|
-
...data
|
30
|
-
});
|
31
|
-
}, []);
|
32
|
-
const stopDragging = useCallback(() => {
|
33
|
-
// console.log("dragissue", "stopDragging");
|
34
|
-
updateDragging({
|
35
|
-
...initialState
|
36
|
-
});
|
37
|
-
}, []);
|
38
|
-
const setDragOver = useCallback(isOver => {
|
39
|
-
updateDragging({
|
40
|
-
dragOver: isOver
|
41
|
-
});
|
42
|
-
}, []);
|
43
|
-
return {
|
44
|
-
dragging,
|
45
|
-
draggingRef,
|
46
|
-
startDragging,
|
47
|
-
stopDragging,
|
48
|
-
setDragOver
|
49
|
-
};
|
50
|
-
};
|
51
|
-
export default useDragging;
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import { Editor } from "slate";
|
2
|
-
|
3
|
-
// Custom insertText that prevents updates in specific node types
|
4
|
-
const withRestrictedNodes = editor => {
|
5
|
-
const {
|
6
|
-
insertText,
|
7
|
-
deleteBackward
|
8
|
-
} = editor;
|
9
|
-
|
10
|
-
// Override insertText
|
11
|
-
editor.insertText = text => {
|
12
|
-
const {
|
13
|
-
selection
|
14
|
-
} = editor;
|
15
|
-
if (selection) {
|
16
|
-
const [node] = Editor.node(editor, selection);
|
17
|
-
console.log(node);
|
18
|
-
|
19
|
-
// Prevent insertText if node type matches
|
20
|
-
if (node && node.type === "restrictedType") {
|
21
|
-
return; // Skip inserting text
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
// Call the original insertText if node type does not match
|
26
|
-
insertText(text);
|
27
|
-
};
|
28
|
-
|
29
|
-
// Similarly override deleteBackward if needed
|
30
|
-
editor.deleteBackward = (...args) => {
|
31
|
-
const {
|
32
|
-
selection
|
33
|
-
} = editor;
|
34
|
-
if (selection) {
|
35
|
-
const [node] = Editor.node(editor, selection);
|
36
|
-
|
37
|
-
// Prevent deletion if node type matches
|
38
|
-
if (node && node.type === "restrictedType") {
|
39
|
-
return; // Skip deleting text
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
// Call the original deleteBackward if node type does not match
|
44
|
-
deleteBackward(...args);
|
45
|
-
};
|
46
|
-
return editor;
|
47
|
-
};
|
48
|
-
export default withRestrictedNodes;
|
@@ -1,16 +0,0 @@
|
|
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;
|