@seafile/sdoc-editor 0.1.40 → 0.1.42
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,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import { Editor, Transforms } from '@seafile/slate';
|
|
3
3
|
import { BLOCKQUOTE } from '../../constants';
|
|
4
|
-
import { getNodeType } from '../../core';
|
|
4
|
+
import { focusEditor, getNodeType } from '../../core';
|
|
5
5
|
export var isMenuDisabled = function isMenuDisabled(editor) {
|
|
6
6
|
if (editor.selection == null) return true;
|
|
7
7
|
var _Editor$nodes = Editor.nodes(editor, {
|
|
@@ -46,4 +46,5 @@ export var setBlockQuoteType = function setBlockQuoteType(editor, type) {
|
|
|
46
46
|
}, {
|
|
47
47
|
mode: 'highest'
|
|
48
48
|
});
|
|
49
|
+
focusEditor(editor);
|
|
49
50
|
};
|
|
@@ -25,7 +25,7 @@ var QuoteMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
25
25
|
var editor = _this.props.editor;
|
|
26
26
|
return isMenuDisabled(editor);
|
|
27
27
|
};
|
|
28
|
-
_this.onMouseDown = function () {
|
|
28
|
+
_this.onMouseDown = function (e) {
|
|
29
29
|
var editor = _this.props.editor;
|
|
30
30
|
var active = _this.isActive(editor);
|
|
31
31
|
var newType = active ? PARAGRAPH : BLOCKQUOTE;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import { Editor, Element, Point, Transforms, Node } from '@seafile/slate';
|
|
3
3
|
import { ReactEditor } from '@seafile/slate-react';
|
|
4
|
-
import { generateEmptyElement } from '../../core';
|
|
4
|
+
import { generateEmptyElement, getSelectedNodeByType, isSelectionAtBlockStart } from '../../core';
|
|
5
5
|
import { BLOCKQUOTE, PARAGRAPH } from '../../constants';
|
|
6
|
+
import { setBlockQuoteType } from './helpers';
|
|
6
7
|
var withBlockquote = function withBlockquote(editor) {
|
|
7
8
|
var insertBreak = editor.insertBreak,
|
|
8
|
-
insertText = editor.insertText
|
|
9
|
+
insertText = editor.insertText,
|
|
10
|
+
deleteBackward = editor.deleteBackward;
|
|
9
11
|
var newEditor = editor;
|
|
10
12
|
newEditor.insertBreak = function () {
|
|
11
13
|
var selection = editor.selection;
|
|
@@ -41,6 +43,21 @@ var withBlockquote = function withBlockquote(editor) {
|
|
|
41
43
|
// In other cases, insert a newline
|
|
42
44
|
insertText('\n');
|
|
43
45
|
};
|
|
46
|
+
newEditor.deleteBackward = function (unit) {
|
|
47
|
+
var selection = newEditor.selection;
|
|
48
|
+
if (selection === null) {
|
|
49
|
+
deleteBackward(unit);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
var node = getSelectedNodeByType(editor, BLOCKQUOTE);
|
|
53
|
+
if (node) {
|
|
54
|
+
if (isSelectionAtBlockStart(editor)) {
|
|
55
|
+
setBlockQuoteType(editor, PARAGRAPH);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
deleteBackward(unit);
|
|
60
|
+
};
|
|
44
61
|
return newEditor;
|
|
45
62
|
};
|
|
46
63
|
export default withBlockquote;
|