@flozy/editor 4.5.4 → 4.5.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
2
2
|
import React, { useRef, useCallback, useEffect, useMemo, useState, forwardRef, useImperativeHandle } from "react";
|
3
3
|
import PropTypes from "prop-types";
|
4
|
-
import { createEditor, Transforms } from "slate";
|
4
|
+
import { createEditor, Range, Transforms } from "slate";
|
5
5
|
import { Slate, Editable, ReactEditor } from "slate-react";
|
6
6
|
import { useDebounce, useDebouncedCallback } from "use-debounce";
|
7
7
|
import { getMarked, getBlock } from "./utils/SlateUtilityFunctions";
|
@@ -114,7 +114,7 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
114
114
|
editorClass,
|
115
115
|
fixedWidth = "60%",
|
116
116
|
fullWidth = "80%",
|
117
|
-
hideTools
|
117
|
+
hideTools = []
|
118
118
|
} = otherProps || {};
|
119
119
|
const editor = useMemo(() => {
|
120
120
|
if (collaborativeEditor) return collaborativeEditor;
|
@@ -365,10 +365,24 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
365
365
|
});
|
366
366
|
} else if (event.key === "Enter") {
|
367
367
|
enterEvent(event, editor, customProps?.isMobile);
|
368
|
-
} else if (event.key === "ArrowUp" && otherProps?.tagName !==
|
368
|
+
} else if (event.key === "ArrowUp" && otherProps?.tagName !== "Pages") {
|
369
369
|
upDownArrowKeyEvents(event, editor);
|
370
|
-
} else if (event.key === "ArrowDown" && otherProps?.tagName !==
|
370
|
+
} else if (event.key === "ArrowDown" && otherProps?.tagName !== "Pages") {
|
371
371
|
upDownArrowKeyEvents(event, editor);
|
372
|
+
} else if (event.key === "Backspace") {
|
373
|
+
const {
|
374
|
+
selection
|
375
|
+
} = editor;
|
376
|
+
event.preventDefault();
|
377
|
+
if (selection) {
|
378
|
+
if (!Range.isCollapsed(selection)) {
|
379
|
+
editor.deleteFragment();
|
380
|
+
} else {
|
381
|
+
editor.deleteBackward({
|
382
|
+
unit: "character"
|
383
|
+
});
|
384
|
+
}
|
385
|
+
}
|
372
386
|
}
|
373
387
|
}, [chars, target, mentions, setMentions, search, type, mentionsRef]);
|
374
388
|
const Overlay = collaborativeEditor && !isReadOnly ? RemoteCursorOverlay : React.Fragment;
|
@@ -215,7 +215,7 @@ const editorStyles = ({
|
|
215
215
|
},
|
216
216
|
"& .content-editable.empty": {
|
217
217
|
"&:after": {
|
218
|
-
color: theme
|
218
|
+
color: theme?.palette?.type === "dark" ? "#99A5B6" : placeHolderColor
|
219
219
|
}
|
220
220
|
},
|
221
221
|
"& .checkbox-edit": {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Editor, Range, Text } from "slate";
|
2
|
-
const highlightSelection = ([node, path], editor) => {
|
3
|
-
if (Text.isText(node) && editor
|
2
|
+
const highlightSelection = ([node, path], editor = {}) => {
|
3
|
+
if (Text.isText(node) && editor?.selection) {
|
4
4
|
const intersection = Range.intersection(editor.selection, Editor.range(editor, path));
|
5
5
|
if (intersection == null) {
|
6
6
|
return [];
|