@flozy/editor 4.6.1 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Editor/CommonEditor.js +17 -17
- package/dist/Editor/Editor.css +1 -32
- 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/Divider/Divider.js +8 -107
- 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 +7 -9
- package/dist/Editor/Elements/Emoji/EmojiButton.js +23 -1
- 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 +3 -56
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +0 -2
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +3 -7
- package/dist/Editor/Elements/FreeGrid/Options/AddElement.js +2 -16
- package/dist/Editor/Elements/FreeGrid/Options/sectionItemOptions.js +2 -8
- package/dist/Editor/Elements/FreeGrid/styles.js +1 -82
- 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 -7
- 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/LinkSettings/index.js +3 -3
- package/dist/Editor/common/LinkSettings/navOptions.js +1 -4
- package/dist/Editor/common/RnD/DragOver/index.js +1 -0
- package/dist/Editor/common/RnD/ElementOptions/Actions.js +2 -15
- 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/Settings/index.js +1 -3
- package/dist/Editor/common/RnD/ElementSettings/settingsConstants.js +2 -5
- package/dist/Editor/common/RnD/RnDCopy.js +0 -2
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +3 -5
- package/dist/Editor/common/RnD/VirtualElement/index.js +1 -1
- package/dist/Editor/common/RnD/index.js +37 -67
- package/dist/Editor/common/Section/index.js +1 -11
- package/dist/Editor/common/Section/styles.js +0 -16
- package/dist/Editor/common/StyleBuilder/embedVideoStyle.js +0 -19
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +4 -19
- package/dist/Editor/common/SwipeableDrawer/index.js +15 -4
- package/dist/Editor/common/SwipeableDrawer/style.js +11 -3
- package/dist/Editor/common/iconslist.js +0 -23
- package/dist/Editor/helper/index.js +2 -5
- package/dist/Editor/helper/theme.js +2 -2
- package/dist/Editor/hooks/useBreakpoints.js +1 -1
- package/dist/Editor/hooks/useMouseMove.js +4 -5
- package/dist/Editor/hooks/withCommon.js +0 -1
- package/dist/Editor/utils/Decorators/index.js +2 -3
- package/dist/Editor/utils/RnD/RnDCtrlCmds.js +1 -16
- package/dist/Editor/utils/SlateUtilityFunctions.js +5 -33
- package/dist/Editor/utils/customHooks/useResize.js +5 -4
- package/dist/Editor/utils/events.js +0 -71
- package/dist/Editor/utils/helper.js +0 -16
- package/package.json +1 -1
- package/dist/Editor/Elements/Divider/DividerPopup.js +0 -24
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Signature.js +0 -53
- package/dist/Editor/common/RnD/ElementSettings/Settings/DividerSettings.js +0 -49
- package/dist/Editor/common/StyleBuilder/dividerStyles.js +0 -56
- 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
|
@@ -282,77 +282,6 @@ export const enterEvent = (e, editor, isMobile) => {
|
|
|
282
282
|
default:
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
// Handle blockquote splitting
|
|
286
|
-
const [blockquote] = Editor.nodes(editor, {
|
|
287
|
-
match: n => Element.isElement(n) && n.type === "blockquote"
|
|
288
|
-
});
|
|
289
|
-
if (blockquote) {
|
|
290
|
-
e.preventDefault();
|
|
291
|
-
const {
|
|
292
|
-
selection
|
|
293
|
-
} = editor;
|
|
294
|
-
if (selection && Range.isCollapsed(selection)) {
|
|
295
|
-
const isAtEnd = Editor.isEnd(editor, selection.anchor, blockquote[1]);
|
|
296
|
-
if (isAtEnd) {
|
|
297
|
-
Transforms.insertNodes(editor, {
|
|
298
|
-
type: "paragraph",
|
|
299
|
-
children: [{
|
|
300
|
-
text: ""
|
|
301
|
-
}]
|
|
302
|
-
});
|
|
303
|
-
const newLocation = Editor.after(editor, selection);
|
|
304
|
-
if (newLocation) {
|
|
305
|
-
Transforms.select(editor, newLocation);
|
|
306
|
-
}
|
|
307
|
-
} else {
|
|
308
|
-
Transforms.splitNodes(editor, {
|
|
309
|
-
always: true
|
|
310
|
-
});
|
|
311
|
-
Transforms.setNodes(editor, {
|
|
312
|
-
type: "paragraph"
|
|
313
|
-
}, {
|
|
314
|
-
at: editor.selection
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
} catch (err) {
|
|
321
|
-
console.log(err);
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
export const upDownArrowKeyEvents = (e, editor) => {
|
|
325
|
-
try {
|
|
326
|
-
const {
|
|
327
|
-
selection
|
|
328
|
-
} = editor;
|
|
329
|
-
if (!selection || Range.isCollapsed(selection)) {
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
const parentPath = selection.anchor.path.slice(0, -1);
|
|
333
|
-
const nextNodePath = [...parentPath];
|
|
334
|
-
const index = parentPath[parentPath.length - 1];
|
|
335
|
-
const parentNode = Editor.parent(editor, parentPath);
|
|
336
|
-
if (parentNode.children[index + 1]) {
|
|
337
|
-
nextNodePath[parentPath.length - 1] += 1;
|
|
338
|
-
} else {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
Transforms.move(editor, {
|
|
342
|
-
distance: 0,
|
|
343
|
-
unit: 'offset',
|
|
344
|
-
reverse: false
|
|
345
|
-
});
|
|
346
|
-
Transforms.select(editor, {
|
|
347
|
-
anchor: {
|
|
348
|
-
path: nextNodePath,
|
|
349
|
-
offset: 0
|
|
350
|
-
},
|
|
351
|
-
focus: {
|
|
352
|
-
path: nextNodePath,
|
|
353
|
-
offset: 0
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
285
|
} catch (err) {
|
|
357
286
|
console.log(err);
|
|
358
287
|
}
|
|
@@ -471,22 +471,6 @@ export const editorThemeStyle = {
|
|
|
471
471
|
export const getEditorTheme = (themeType = "light") => {
|
|
472
472
|
return editorThemeStyle[themeType] || {};
|
|
473
473
|
};
|
|
474
|
-
export const isFreeGrid = (nodes, types = ["freegrid", "freegridItem", "freegridBox"]) => {
|
|
475
|
-
try {
|
|
476
|
-
for (const node of nodes) {
|
|
477
|
-
if (types.includes(node.type)) {
|
|
478
|
-
return true;
|
|
479
|
-
}
|
|
480
|
-
if (node.children && isFreeGrid(node.children, types)) {
|
|
481
|
-
return true;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
return false;
|
|
485
|
-
} catch (err) {
|
|
486
|
-
console.log("isFreeGrid error:", err);
|
|
487
|
-
return false;
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
474
|
export const getPreviousNode = editor => {
|
|
491
475
|
try {
|
|
492
476
|
const parentPath = Path.parent(editor?.selection?.anchor?.path);
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import StyleBuilder from "../../common/StyleBuilder";
|
|
3
|
-
import dividerStyle from "../../common/StyleBuilder/dividerStyles";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const DividerPopup = props => {
|
|
6
|
-
const {
|
|
7
|
-
element,
|
|
8
|
-
onSave,
|
|
9
|
-
onClose,
|
|
10
|
-
onDelete,
|
|
11
|
-
customProps
|
|
12
|
-
} = props;
|
|
13
|
-
return /*#__PURE__*/_jsx(StyleBuilder, {
|
|
14
|
-
title: "Divider",
|
|
15
|
-
type: "dividerStyle",
|
|
16
|
-
element: element,
|
|
17
|
-
onSave: onSave,
|
|
18
|
-
onClose: onClose,
|
|
19
|
-
renderTabs: dividerStyle,
|
|
20
|
-
onDelete: onDelete,
|
|
21
|
-
customProps: customProps
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
export default DividerPopup;
|
|
@@ -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,49 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Transforms, Node } from "slate";
|
|
3
|
-
import { Box } from "@mui/material";
|
|
4
|
-
import { StyleContent } from "../../../StyleBuilder";
|
|
5
|
-
import dividerStyle from "../../../StyleBuilder/dividerStyles";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const DividerSettings = props => {
|
|
8
|
-
const {
|
|
9
|
-
editor,
|
|
10
|
-
path,
|
|
11
|
-
customProps
|
|
12
|
-
} = props;
|
|
13
|
-
const item_path = path?.split("|").map(m => parseInt(m));
|
|
14
|
-
const element_path = [...item_path, 0];
|
|
15
|
-
const element = Node.get(editor, element_path);
|
|
16
|
-
const onChange = data => {
|
|
17
|
-
console.log("🚀 ~ onChange ~ data:", data);
|
|
18
|
-
console.log("🚀 ~ onChange ~ element:", element);
|
|
19
|
-
const updated_props = {
|
|
20
|
-
...element,
|
|
21
|
-
...data,
|
|
22
|
-
field_type: data?.element
|
|
23
|
-
};
|
|
24
|
-
delete updated_props.children;
|
|
25
|
-
Transforms.setNodes(editor, {
|
|
26
|
-
...updated_props
|
|
27
|
-
}, {
|
|
28
|
-
at: element_path
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const handleClose = () => {
|
|
32
|
-
console.log("close");
|
|
33
|
-
};
|
|
34
|
-
return /*#__PURE__*/_jsx(Box, {
|
|
35
|
-
component: "div",
|
|
36
|
-
className: "item-w",
|
|
37
|
-
children: dividerStyle?.map((m, i) => {
|
|
38
|
-
return /*#__PURE__*/_jsx(StyleContent, {
|
|
39
|
-
renderTabs: dividerStyle,
|
|
40
|
-
value: m.value,
|
|
41
|
-
element: element,
|
|
42
|
-
onChange: onChange,
|
|
43
|
-
customProps: customProps,
|
|
44
|
-
handleClose: handleClose
|
|
45
|
-
}, `tab_${m.value}_$${i}`);
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
export default DividerSettings;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import Icon from "../Icon";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
const dividerStyle = [{
|
|
4
|
-
tab: "Border",
|
|
5
|
-
value: "sectionBorderRadius",
|
|
6
|
-
fields: [{
|
|
7
|
-
label: "Divider Color",
|
|
8
|
-
key: "borderColor",
|
|
9
|
-
type: "color",
|
|
10
|
-
infoIcon: /*#__PURE__*/_jsx(Icon, {
|
|
11
|
-
icon: "info"
|
|
12
|
-
})
|
|
13
|
-
}, {
|
|
14
|
-
label: "Divider Width",
|
|
15
|
-
key: "borderWidth",
|
|
16
|
-
type: "text",
|
|
17
|
-
placeholder: "1px",
|
|
18
|
-
width: 6
|
|
19
|
-
}, {
|
|
20
|
-
label: "Divider Style",
|
|
21
|
-
key: "borderStyle",
|
|
22
|
-
type: "textOptions",
|
|
23
|
-
width: 6,
|
|
24
|
-
options: [{
|
|
25
|
-
text: "Solid",
|
|
26
|
-
value: "solid"
|
|
27
|
-
}, {
|
|
28
|
-
text: "Dotted",
|
|
29
|
-
value: "dotted"
|
|
30
|
-
}, {
|
|
31
|
-
text: "Dashed",
|
|
32
|
-
value: "dashed"
|
|
33
|
-
}, {
|
|
34
|
-
text: "Double",
|
|
35
|
-
value: "double"
|
|
36
|
-
}, {
|
|
37
|
-
text: "Groove",
|
|
38
|
-
value: "groove"
|
|
39
|
-
}, {
|
|
40
|
-
text: "Ridge",
|
|
41
|
-
value: "ridge"
|
|
42
|
-
}, {
|
|
43
|
-
text: "Inset",
|
|
44
|
-
value: "inset"
|
|
45
|
-
}, {
|
|
46
|
-
text: "Outset",
|
|
47
|
-
value: "outset"
|
|
48
|
-
}],
|
|
49
|
-
renderOption: option => {
|
|
50
|
-
return /*#__PURE__*/_jsx("span", {
|
|
51
|
-
children: option.text
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}]
|
|
55
|
-
}];
|
|
56
|
-
export default dividerStyle;
|
|
@@ -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;
|