@seafile/seafile-editor 2.0.7 → 2.0.8
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.
|
@@ -45,6 +45,10 @@ const InlineEditor = _ref => {
|
|
|
45
45
|
const decorate = (0, _extension.useHighlight)(editor);
|
|
46
46
|
const onChange = (0, _react.useCallback)(value => {
|
|
47
47
|
setSlateValue(value);
|
|
48
|
+
if (!editor.hasMovedSelection && editor.selection && _slate.Range.isCollapsed(editor.selection)) {
|
|
49
|
+
const isAtStart = _slate.Editor.isStart(editor, editor.selection.anchor, _slate.Editor.start(editor, []));
|
|
50
|
+
if (!isAtStart) editor.hasMovedSelection = true;
|
|
51
|
+
}
|
|
48
52
|
if (editor.forceNormalize) return;
|
|
49
53
|
const operations = editor.operations;
|
|
50
54
|
const modifyOps = operations.filter(o => o.type !== 'set_selection');
|
|
@@ -97,7 +101,10 @@ const InlineEditor = _ref => {
|
|
|
97
101
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
102
|
}, []);
|
|
99
103
|
(0, _react.useEffect)(() => {
|
|
100
|
-
if (!enableEdit)
|
|
104
|
+
if (!enableEdit) {
|
|
105
|
+
editor.hasMovedSelection = false;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
101
108
|
focusNode(editor, focusRangeRef.current);
|
|
102
109
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
110
|
}, [enableEdit]);
|
|
@@ -184,6 +184,7 @@ const withCodeBlock = editor => {
|
|
|
184
184
|
return true;
|
|
185
185
|
}
|
|
186
186
|
if ((0, _isHotkey.default)('tab', event)) {
|
|
187
|
+
if (newEditor.hasMovedSelection) event.stopPropagation();
|
|
187
188
|
event.preventDefault();
|
|
188
189
|
const nodeEntries = _slate.Editor.nodes(newEditor, {
|
|
189
190
|
mode: 'lowest',
|
|
@@ -207,6 +208,7 @@ const withCodeBlock = editor => {
|
|
|
207
208
|
return true;
|
|
208
209
|
}
|
|
209
210
|
if ((0, _isHotkey.default)('shift+tab', event)) {
|
|
211
|
+
if (newEditor.hasMovedSelection) event.stopPropagation();
|
|
210
212
|
event.preventDefault();
|
|
211
213
|
// Match the beginning of the line space, delete up to 4 spaces at a time
|
|
212
214
|
const originSelection = newEditor.selection;
|
|
@@ -12,9 +12,11 @@ var _elementTypes = require("../../../constants/element-types");
|
|
|
12
12
|
var _transforms = require("../transforms");
|
|
13
13
|
const handleTab = (editor, event) => {
|
|
14
14
|
const {
|
|
15
|
-
selection
|
|
15
|
+
selection,
|
|
16
|
+
hasMovedSelection
|
|
16
17
|
} = editor;
|
|
17
18
|
if (!selection) return;
|
|
19
|
+
if (hasMovedSelection) event.stopPropagation();
|
|
18
20
|
const selectedList = (0, _core.findNode)(editor, {
|
|
19
21
|
type: [_elementTypes.LIST_ITEM]
|
|
20
22
|
});
|
|
@@ -181,6 +181,7 @@ const withTable = editor => {
|
|
|
181
181
|
newEditor.onHotKeyDown = event => {
|
|
182
182
|
if (!(0, _helper.isInTable)(newEditor)) return onHotKeyDown && onHotKeyDown(event);
|
|
183
183
|
if ((0, _isHotkey.default)('tab', event)) {
|
|
184
|
+
if (newEditor.hasMovedSelection) event.stopPropagation();
|
|
184
185
|
event.preventDefault();
|
|
185
186
|
const {
|
|
186
187
|
tableEntry: [tableNode],
|
|
@@ -205,6 +206,7 @@ const withTable = editor => {
|
|
|
205
206
|
return true;
|
|
206
207
|
}
|
|
207
208
|
if ((0, _isHotkey.default)('shift+tab', event)) {
|
|
209
|
+
if (newEditor.hasMovedSelection) event.stopPropagation();
|
|
208
210
|
event.preventDefault();
|
|
209
211
|
const {
|
|
210
212
|
rowEntry: [rowNode],
|