@seafile/seafile-editor 1.0.37 → 1.0.38
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.
|
@@ -49,6 +49,7 @@ function SimpleSlateEditor(_ref) {
|
|
|
49
49
|
}, [editor, onContentChanged]);
|
|
50
50
|
const focusFirstNode = (0, _react.useCallback)(editor => {
|
|
51
51
|
const [firstNode] = editor.children;
|
|
52
|
+
if (!firstNode) return;
|
|
52
53
|
const [firstNodeFirstChild] = firstNode.children;
|
|
53
54
|
if (firstNodeFirstChild) {
|
|
54
55
|
const endOfFirstNode = _slate.Editor.end(editor, [0, 0]);
|
|
@@ -54,6 +54,7 @@ function SlateEditor(_ref) {
|
|
|
54
54
|
}, [editor.forceNormalize, editor.operations, onContentChanged]);
|
|
55
55
|
const focusFirstNode = (0, _react.useCallback)(editor => {
|
|
56
56
|
const [firstNode] = editor.children;
|
|
57
|
+
if (!firstNode) return;
|
|
57
58
|
const [firstNodeFirstChild] = firstNode.children;
|
|
58
59
|
if (firstNodeFirstChild) {
|
|
59
60
|
const endOfFirstNode = _slate.Editor.end(editor, [0, 0]);
|
|
@@ -35,6 +35,11 @@ const mdStringToSlate = mdString => {
|
|
|
35
35
|
// md string --> md ast
|
|
36
36
|
const root = getProcessor().parse(content);
|
|
37
37
|
|
|
38
|
+
// the mdString is '\r\n'
|
|
39
|
+
if (root.children.length === 0) {
|
|
40
|
+
return [(0, _core.generateDefaultParagraph)()];
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
// md ast --> slate ast
|
|
39
44
|
const slateNodes = (0, _transform.formatMdToSlate)(root.children);
|
|
40
45
|
|