@seafile/seafile-editor 1.0.92 → 1.0.93-alpha

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,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
+ };
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _isHotkey = _interopRequireDefault(require("is-hotkey"));
11
+ var _constants = require("../../constants");
11
12
  var _clickOutside = _interopRequireDefault(require("./click-outside"));
12
13
  var _fallbackEditor = _interopRequireDefault(require("./fallback-editor"));
13
14
  var _normalEditor = _interopRequireDefault(require("./normal-editor"));
@@ -35,29 +36,38 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
35
36
  } = (0, _react.useMemo)(() => {
36
37
  return (0, _getBrowserInfo.default)(isCheckBrowser);
37
38
  }, [isCheckBrowser]);
39
+ const onHotKey = (0, _react.useCallback)(event => {
40
+ const keyCode = event.keyCode;
41
+ if ((0, _isHotkey.default)('space') || (0, _isHotkey.default)('enter') || [_constants.KeyCodes.PageUp, _constants.KeyCodes.PageDown, _constants.KeyCodes.LeftArrow, _constants.KeyCodes.UpArrow, _constants.KeyCodes.RightArrow, _constants.KeyCodes.DownArrow].includes(keyCode)) {
42
+ event.stopPropagation();
43
+ return;
44
+ }
45
+ const isModP = (0, _isHotkey.default)('mod+p', event);
46
+ if (keyCode === _constants.KeyCodes.Esc || isModP) {
47
+ event.preventDefault();
48
+ !isModP && event.stopPropagation();
49
+ if (longTextValueChangedRef.current) {
50
+ onSaveEditorValue(valueRef.current);
51
+ }
52
+ setEnableEdit(false);
53
+ return;
54
+ }
55
+ }, [onSaveEditorValue]);
38
56
  const openEditor = (0, _react.useCallback)(() => {
39
57
  setEnableEdit(true);
40
- }, []);
58
+ document.addEventListener('keydown', onHotKey);
59
+ }, [onHotKey]);
41
60
  const closeEditor = (0, _react.useCallback)(() => {
42
61
  if (longTextValueChangedRef.current) {
43
62
  onSaveEditorValue(valueRef.current);
44
63
  }
45
64
  setEnableEdit(false);
46
- }, [longTextValueChangedRef, valueRef, onSaveEditorValue]);
65
+ document.removeEventListener('keydown', onHotKey);
66
+ }, [longTextValueChangedRef, valueRef, onSaveEditorValue, onHotKey]);
47
67
  const onEditorValueChanged = (0, _react.useCallback)(value => {
48
68
  valueRef.current = value;
49
69
  longTextValueChangedRef.current = true;
50
70
  }, []);
51
- const onHotKey = (0, _react.useCallback)(event => {
52
- const keyCode = event.keyCode;
53
- const isModP = (0, _isHotkey.default)('mod+p', event);
54
- if (keyCode === 27 || isModP) {
55
- event.preventDefault();
56
- !isModP && event.stopPropagation();
57
- closeEditor();
58
- return;
59
- }
60
- }, [closeEditor]);
61
71
  (0, _react.useImperativeHandle)(ref, () => {
62
72
  return {
63
73
  openEditor: openEditor,
@@ -71,8 +81,7 @@ const LongTextInlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
71
81
  return /*#__PURE__*/_react.default.createElement(_clickOutside.default, {
72
82
  onClickOutside: closeEditor
73
83
  }, /*#__PURE__*/_react.default.createElement("div", {
74
- className: "w-100",
75
- onKeyDown: onHotKey
84
+ className: "w-100"
76
85
  }, isWindowsWechat ? /*#__PURE__*/_react.default.createElement(_fallbackEditor.default, {
77
86
  enableEdit: enableEdit,
78
87
  value: valueRef.current.text,
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "1.0.92",
3
+ "version": "1.0.93-alpha",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {