@seafile/sdoc-editor 0.5.72 → 0.5.73
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,10 +1,11 @@
|
|
|
1
1
|
import { Transforms, Path, Editor, Element, Range } from '@seafile/slate';
|
|
2
|
-
import { focusEditor, isBlockAboveEmpty } from '../../core';
|
|
3
|
-
import { SEATABLE_VIEW } from '../../constants/element-type';
|
|
2
|
+
import { focusEditor, generateEmptyElement, getNodeType, isBlockAboveEmpty, isLastNode } from '../../core';
|
|
3
|
+
import { PARAGRAPH, SEATABLE_VIEW } from '../../constants/element-type';
|
|
4
4
|
const withSeaTableView = editor => {
|
|
5
5
|
const {
|
|
6
6
|
isVoid,
|
|
7
|
-
deleteBackward
|
|
7
|
+
deleteBackward,
|
|
8
|
+
normalizeNode
|
|
8
9
|
} = editor;
|
|
9
10
|
const newEditor = editor;
|
|
10
11
|
|
|
@@ -47,6 +48,24 @@ const withSeaTableView = editor => {
|
|
|
47
48
|
}
|
|
48
49
|
deleteBackward(unit);
|
|
49
50
|
};
|
|
51
|
+
|
|
52
|
+
// Rewrite normalizeNode
|
|
53
|
+
newEditor.normalizeNode = _ref => {
|
|
54
|
+
let [node, path] = _ref;
|
|
55
|
+
const type = getNodeType(node);
|
|
56
|
+
if (type !== SEATABLE_VIEW) {
|
|
57
|
+
return normalizeNode([node, path]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// insert empty node,continue editor
|
|
61
|
+
const isLast = isLastNode(newEditor, node);
|
|
62
|
+
if (isLast) {
|
|
63
|
+
const p = generateEmptyElement(PARAGRAPH);
|
|
64
|
+
Transforms.insertNodes(newEditor, p, {
|
|
65
|
+
at: [path[0] + 1]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
50
69
|
return newEditor;
|
|
51
70
|
};
|
|
52
71
|
export default withSeaTableView;
|