@seafile/sdoc-editor 0.4.15 → 0.4.16
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, Fragment } from 'react';
|
|
2
2
|
import { Editable, ReactEditor, Slate } from '@seafile/slate-react';
|
|
3
|
-
import { Editor } from '@seafile/slate';
|
|
3
|
+
import { Editor, Node, Range } from '@seafile/slate';
|
|
4
4
|
import { renderLeaf, renderElement, ContextToolbar, SideToolbar } from '../extension';
|
|
5
5
|
import { getAboveBlockNode, getNextNode, getPrevNode, isSelectionAtBlockEnd, isSelectionAtBlockStart } from '../extension/core';
|
|
6
6
|
import EventProxy from '../utils/event-handler';
|
|
@@ -139,11 +139,16 @@ const EditableArticle = _ref => {
|
|
|
139
139
|
const {
|
|
140
140
|
selection
|
|
141
141
|
} = editor;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
if (Range.isCollapsed(selection)) {
|
|
143
|
+
// Do not scroll into view, when focus on image
|
|
144
|
+
const [imageNodeEntry] = Editor.nodes(editor, {
|
|
145
|
+
match: n => n.type === IMAGE,
|
|
146
|
+
at: selection
|
|
147
|
+
});
|
|
148
|
+
if (imageNodeEntry) return;
|
|
149
|
+
}
|
|
150
|
+
const focusedNode = Node.get(editor, selection.focus.path);
|
|
151
|
+
const domNode = ReactEditor.toDOMNode(editor, focusedNode);
|
|
147
152
|
if (!domNode) return;
|
|
148
153
|
domNode.scrollIntoView({
|
|
149
154
|
block: 'nearest'
|
|
@@ -75,7 +75,10 @@ const ImageHoverMenu = _ref => {
|
|
|
75
75
|
centerNode = null,
|
|
76
76
|
afterNode = null;
|
|
77
77
|
let p = path[0];
|
|
78
|
-
if (!beforeLeaf.every(item =>
|
|
78
|
+
if (!beforeLeaf.every(item => {
|
|
79
|
+
var _item$text;
|
|
80
|
+
return (item === null || item === void 0 ? void 0 : (_item$text = item.text) === null || _item$text === void 0 ? void 0 : _item$text.length) === 0;
|
|
81
|
+
})) {
|
|
79
82
|
beforeNode = generateEmptyElement(PARAGRAPH);
|
|
80
83
|
beforeNode.children = beforeLeaf;
|
|
81
84
|
Transforms.insertNodes(editor, beforeNode, {
|
|
@@ -90,8 +93,8 @@ const ImageHoverMenu = _ref => {
|
|
|
90
93
|
});
|
|
91
94
|
p = p + 1;
|
|
92
95
|
if (!afterLeaf.every(item => {
|
|
93
|
-
var _item$
|
|
94
|
-
return (item === null || item === void 0 ? void 0 : (_item$
|
|
96
|
+
var _item$text2;
|
|
97
|
+
return (item === null || item === void 0 ? void 0 : (_item$text2 = item.text) === null || _item$text2 === void 0 ? void 0 : _item$text2.length) === 0;
|
|
95
98
|
})) {
|
|
96
99
|
afterNode = generateEmptyElement(PARAGRAPH);
|
|
97
100
|
afterNode.children = afterLeaf;
|