@seafile/seafile-editor 1.0.92 → 1.0.93-alpha1
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.
- package/dist/constants/index.js +8 -0
- package/dist/constants/key-codes.js +104 -0
- package/dist/editors/inline-editor/index.js +5 -4
- package/dist/pages/longtext-inline-editor/index.js +3 -2
- package/dist/pages/longtext-inline-editor/normal-editor.js +4 -2
- package/dist/utils/get-preview-content.js +2 -0
- package/dist/utils/inline-event-handel.js +51 -0
- package/package.json +1 -1
package/dist/constants/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "KeyCodes", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _keyCodes.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
6
13
|
exports.TRANSLATE_NAMESPACE = void 0;
|
|
14
|
+
var _keyCodes = _interopRequireDefault(require("./key-codes"));
|
|
7
15
|
const TRANSLATE_NAMESPACE = exports.TRANSLATE_NAMESPACE = 'seafile-editor';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
Backspace: 8,
|
|
5
|
+
Tab: 9,
|
|
6
|
+
Enter: 13,
|
|
7
|
+
Shift: 16,
|
|
8
|
+
Ctrl: 17,
|
|
9
|
+
Alt: 18,
|
|
10
|
+
PauseBreak: 19,
|
|
11
|
+
CapsLock: 20,
|
|
12
|
+
Escape: 27,
|
|
13
|
+
Esc: 27,
|
|
14
|
+
Space: 32,
|
|
15
|
+
PageUp: 33,
|
|
16
|
+
PageDown: 34,
|
|
17
|
+
End: 35,
|
|
18
|
+
Home: 36,
|
|
19
|
+
LeftArrow: 37,
|
|
20
|
+
UpArrow: 38,
|
|
21
|
+
RightArrow: 39,
|
|
22
|
+
DownArrow: 40,
|
|
23
|
+
Insert: 45,
|
|
24
|
+
Delete: 46,
|
|
25
|
+
0: 48,
|
|
26
|
+
1: 49,
|
|
27
|
+
2: 50,
|
|
28
|
+
3: 51,
|
|
29
|
+
4: 52,
|
|
30
|
+
5: 53,
|
|
31
|
+
6: 54,
|
|
32
|
+
7: 55,
|
|
33
|
+
8: 56,
|
|
34
|
+
9: 57,
|
|
35
|
+
a: 65,
|
|
36
|
+
b: 66,
|
|
37
|
+
c: 67,
|
|
38
|
+
d: 68,
|
|
39
|
+
e: 69,
|
|
40
|
+
f: 70,
|
|
41
|
+
g: 71,
|
|
42
|
+
h: 72,
|
|
43
|
+
i: 73,
|
|
44
|
+
j: 74,
|
|
45
|
+
k: 75,
|
|
46
|
+
l: 76,
|
|
47
|
+
m: 77,
|
|
48
|
+
n: 78,
|
|
49
|
+
o: 79,
|
|
50
|
+
p: 80,
|
|
51
|
+
q: 81,
|
|
52
|
+
r: 82,
|
|
53
|
+
s: 83,
|
|
54
|
+
t: 84,
|
|
55
|
+
u: 85,
|
|
56
|
+
v: 86,
|
|
57
|
+
w: 87,
|
|
58
|
+
x: 88,
|
|
59
|
+
y: 89,
|
|
60
|
+
z: 90,
|
|
61
|
+
LeftWindowKey: 91,
|
|
62
|
+
RightWindowKey: 92,
|
|
63
|
+
SelectKey: 93,
|
|
64
|
+
NumPad0: 96,
|
|
65
|
+
NumPad1: 97,
|
|
66
|
+
NumPad2: 98,
|
|
67
|
+
NumPad3: 99,
|
|
68
|
+
NumPad4: 100,
|
|
69
|
+
NumPad5: 101,
|
|
70
|
+
NumPad6: 102,
|
|
71
|
+
NumPad7: 103,
|
|
72
|
+
NumPad8: 104,
|
|
73
|
+
NumPad9: 105,
|
|
74
|
+
Multiply: 106,
|
|
75
|
+
Add: 107,
|
|
76
|
+
Subtract: 109,
|
|
77
|
+
DecimalPoint: 110,
|
|
78
|
+
Divide: 111,
|
|
79
|
+
F1: 112,
|
|
80
|
+
F2: 113,
|
|
81
|
+
F3: 114,
|
|
82
|
+
F4: 115,
|
|
83
|
+
F5: 116,
|
|
84
|
+
F6: 117,
|
|
85
|
+
F7: 118,
|
|
86
|
+
F8: 119,
|
|
87
|
+
F9: 120,
|
|
88
|
+
F10: 121,
|
|
89
|
+
F12: 123,
|
|
90
|
+
NumLock: 144,
|
|
91
|
+
ScrollLock: 145,
|
|
92
|
+
SemiColon: 186,
|
|
93
|
+
EqualSign: 187,
|
|
94
|
+
Comma: 188,
|
|
95
|
+
Dash: 189,
|
|
96
|
+
Period: 190,
|
|
97
|
+
ForwardSlash: 191,
|
|
98
|
+
GraveAccent: 192,
|
|
99
|
+
OpenBracket: 219,
|
|
100
|
+
BackSlash: 220,
|
|
101
|
+
CloseBracket: 221,
|
|
102
|
+
SingleQuote: 222,
|
|
103
|
+
ChineseInputMethod: 229
|
|
104
|
+
};
|
|
@@ -11,7 +11,7 @@ var _slateReact = require("slate-react");
|
|
|
11
11
|
var _slate = require("slate");
|
|
12
12
|
var _extension = require("../../extension");
|
|
13
13
|
var _eventBus = _interopRequireDefault(require("../../utils/event-bus"));
|
|
14
|
-
var
|
|
14
|
+
var _inlineEventHandel = _interopRequireDefault(require("../../utils/inline-event-handel"));
|
|
15
15
|
var _withPropsEditor = _interopRequireDefault(require("./with-props-editor"));
|
|
16
16
|
var _core = require("../../extension/core");
|
|
17
17
|
var _common = require("../../utils/common");
|
|
@@ -27,7 +27,8 @@ const InlineEditor = _ref => {
|
|
|
27
27
|
onContentChanged,
|
|
28
28
|
isSupportFormula,
|
|
29
29
|
onExpandEditorToggle,
|
|
30
|
-
handelEnableEdit
|
|
30
|
+
handelEnableEdit,
|
|
31
|
+
closeEditor
|
|
31
32
|
} = _ref;
|
|
32
33
|
const [slateValue, setSlateValue] = (0, _react.useState)(value);
|
|
33
34
|
const focusRangeRef = (0, _react.useRef)(null);
|
|
@@ -40,8 +41,8 @@ const InlineEditor = _ref => {
|
|
|
40
41
|
});
|
|
41
42
|
}, [columns, editorApi, onSave]);
|
|
42
43
|
const eventProxy = (0, _react.useMemo)(() => {
|
|
43
|
-
return new
|
|
44
|
-
}, [editor]);
|
|
44
|
+
return new _inlineEventHandel.default(editor, closeEditor);
|
|
45
|
+
}, [editor, closeEditor]);
|
|
45
46
|
const decorate = (0, _extension.useHighlight)(editor);
|
|
46
47
|
const onChange = (0, _react.useCallback)(value => {
|
|
47
48
|
setSlateValue(value);
|
|
@@ -80,7 +80,6 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
80
80
|
closeEditor: closeEditor
|
|
81
81
|
}) : /*#__PURE__*/_react.default.createElement(_normalEditor.default, {
|
|
82
82
|
enableEdit: enableEdit,
|
|
83
|
-
handelEnableEdit: handelEnableEdit,
|
|
84
83
|
lang: lang,
|
|
85
84
|
headerName: headerName,
|
|
86
85
|
value: valueRef.current.text,
|
|
@@ -89,7 +88,9 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
89
88
|
isCheckBrowser: isCheckBrowser,
|
|
90
89
|
editorApi: editorApi,
|
|
91
90
|
onSaveEditorValue: onSaveEditorValue,
|
|
92
|
-
onEditorValueChanged: onEditorValueChanged
|
|
91
|
+
onEditorValueChanged: onEditorValueChanged,
|
|
92
|
+
handelEnableEdit: handelEnableEdit,
|
|
93
|
+
closeEditor: closeEditor
|
|
93
94
|
})));
|
|
94
95
|
});
|
|
95
96
|
var _default = exports.default = LongTextInlineEditor;
|
|
@@ -15,7 +15,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
15
15
|
const NormalEditor = _ref => {
|
|
16
16
|
let {
|
|
17
17
|
enableEdit,
|
|
18
|
-
handelEnableEdit,
|
|
19
18
|
lang,
|
|
20
19
|
headerName,
|
|
21
20
|
value: propsValue,
|
|
@@ -24,7 +23,9 @@ const NormalEditor = _ref => {
|
|
|
24
23
|
isCheckBrowser = false,
|
|
25
24
|
editorApi,
|
|
26
25
|
onSaveEditorValue,
|
|
27
|
-
onEditorValueChanged
|
|
26
|
+
onEditorValueChanged,
|
|
27
|
+
closeEditor,
|
|
28
|
+
handelEnableEdit
|
|
28
29
|
} = _ref;
|
|
29
30
|
const editorContainerRef = (0, _react.useRef)(null);
|
|
30
31
|
const editorRef = (0, _react.useRef)(null);
|
|
@@ -118,6 +119,7 @@ const NormalEditor = _ref => {
|
|
|
118
119
|
isInline: true,
|
|
119
120
|
value: valueRef.current.text,
|
|
120
121
|
handelEnableEdit: handelEnableEdit,
|
|
122
|
+
closeEditor: closeEditor,
|
|
121
123
|
onSave: handelAutoSave,
|
|
122
124
|
editorApi: editorApi,
|
|
123
125
|
onContentChanged: onContentChanged,
|
|
@@ -35,6 +35,8 @@ const getPreviewInfo = (nodes, previewContent) => {
|
|
|
35
35
|
if (currentNode.checked) {
|
|
36
36
|
previewContent.checklist.completed++;
|
|
37
37
|
}
|
|
38
|
+
// recalculate child elements
|
|
39
|
+
getPreviewInfo(currentNode.children, previewContent);
|
|
38
40
|
} else {
|
|
39
41
|
getPreviewInfo(currentNode.children, previewContent);
|
|
40
42
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
9
|
+
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
10
|
+
class EventProxy {
|
|
11
|
+
constructor(_editor, closeEditor) {
|
|
12
|
+
(0, _defineProperty2.default)(this, "onKeyDown", event => {
|
|
13
|
+
const editor = this.editor;
|
|
14
|
+
if (editor.onHotKeyDown) {
|
|
15
|
+
const isHandled = editor.onHotKeyDown(event);
|
|
16
|
+
if (isHandled) return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Disable the default 'save page'
|
|
20
|
+
if ((0, _isHotkey.default)('mod+s', event)) {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
const {
|
|
23
|
+
onSave
|
|
24
|
+
} = this.editor;
|
|
25
|
+
onSave && onSave();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if ((0, _isHotkey.default)('esc', event)) {
|
|
29
|
+
this.closeEditor && this.closeEditor();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Disable default 'tab' behavior
|
|
33
|
+
if ((0, _isHotkey.default)('tab', event)) {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
} else {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
(0, _defineProperty2.default)(this, "onCopy", event => {
|
|
40
|
+
const editor = this.editor;
|
|
41
|
+
if (editor.onCopy) {
|
|
42
|
+
const isHandled = editor.onCopy(event);
|
|
43
|
+
if (isHandled) return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
});
|
|
47
|
+
this.editor = _editor;
|
|
48
|
+
this.closeEditor = closeEditor;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
var _default = exports.default = EventProxy;
|