@seafile/sdoc-editor 3.0.277 → 3.0.279

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.
@@ -50,7 +50,9 @@ var ColorMenu = function ColorMenu(_ref) {
50
50
  defaultColor = _ref.defaultColor,
51
51
  lastUsedColor = _ref.lastUsedColor,
52
52
  updateLastUsedColor = _ref.updateLastUsedColor,
53
- onColorPickerUnmount = _ref.onColorPickerUnmount;
53
+ onColorPickerUnmount = _ref.onColorPickerUnmount,
54
+ _ref$closeOnArrowKey = _ref.closeOnArrowKey,
55
+ closeOnArrowKey = _ref$closeOnArrowKey === void 0 ? false : _ref$closeOnArrowKey;
54
56
  var popoverRef = (0, _react.useRef)(null);
55
57
  var moreColorsPopoverRef = (0, _react.useRef)(null);
56
58
  var pickerDragsRef = (0, _react.useRef)([]);
@@ -80,6 +82,28 @@ var ColorMenu = function ColorMenu(_ref) {
80
82
  });
81
83
  };
82
84
  }, []);
85
+ (0, _react.useEffect)(function () {
86
+ if (!closeOnArrowKey || !isShowMenu) return;
87
+ var handleKeyDown = function handleKeyDown(event) {
88
+ var _event$target, _pickerContainerRef$c, _popoverRef$current;
89
+ if (event.isComposing) return;
90
+ if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) return;
91
+ if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName) === 'INPUT' && (_pickerContainerRef$c = pickerContainerRef.current) !== null && _pickerContainerRef$c !== void 0 && _pickerContainerRef$c.contains(event.target)) {
92
+ return;
93
+ }
94
+ if (isPickerShow) {
95
+ var _moreColorsPopoverRef;
96
+ (_moreColorsPopoverRef = moreColorsPopoverRef.current) === null || _moreColorsPopoverRef === void 0 ? void 0 : _moreColorsPopoverRef.toggle();
97
+ setPickerShow(false);
98
+ }
99
+ (_popoverRef$current = popoverRef.current) === null || _popoverRef$current === void 0 ? void 0 : _popoverRef$current.toggle();
100
+ setMenuShow(false);
101
+ };
102
+ document.addEventListener('keydown', handleKeyDown);
103
+ return function () {
104
+ return document.removeEventListener('keydown', handleKeyDown);
105
+ };
106
+ }, [closeOnArrowKey, isShowMenu, isPickerShow]);
83
107
  var onSetColor = (0, _react.useCallback)(function (color) {
84
108
  var shouldClose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
85
109
  var shouldFocus = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
@@ -162,7 +186,7 @@ var ColorMenu = function ColorMenu(_ref) {
162
186
  (0, _mouseEvent.eventStopPropagation)(event);
163
187
  }, []);
164
188
  var onChange = (0, _react.useCallback)(function (color, event) {
165
- var _event$target;
189
+ var _event$target2;
166
190
  if (disabled) return;
167
191
  var validColor = color.hex;
168
192
  var isDrag = ['mousedown', 'mousemove', 'touchstart', 'touchmove'].includes(event === null || event === void 0 ? void 0 : event.type);
@@ -176,7 +200,7 @@ var ColorMenu = function ColorMenu(_ref) {
176
200
  // A trailing change from an earlier drag must not overwrite a newer selection.
177
201
  if (drag !== drags[drags.length - 1]) return;
178
202
  }
179
- onSetColor(validColor, false, isDrag || (event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName) !== 'INPUT', !isDrag);
203
+ onSetColor(validColor, false, isDrag || (event === null || event === void 0 ? void 0 : (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.tagName) !== 'INPUT', !isDrag);
180
204
  }, [disabled, onSetColor]);
181
205
  var setLastUsedColor = (0, _react.useCallback)(function (event) {
182
206
  (0, _mouseEvent.eventStopPropagation)(event);
@@ -48,7 +48,6 @@
48
48
  width: 16px;
49
49
  height: 16px;
50
50
  font-size: 16px;
51
- scale: calc(0.5);
52
51
  display: inline-flex;
53
52
  align-items: center;
54
53
  justify-content: center;
@@ -93,7 +93,7 @@ var renderHeader = exports.renderHeader = function renderHeader(props, editor) {
93
93
  contentEditable: false,
94
94
  onMouseDown: onToggleCollapsed
95
95
  }, /*#__PURE__*/_react["default"].createElement("span", {
96
- className: (0, _classnames["default"])('sdocfont', collapsed ? 'sdoc-big-caret-up' : 'sdoc-big-drop-down')
96
+ className: (0, _classnames["default"])('sdocfont', collapsed ? 'sdoc-caret-up' : 'sdoc-drop-down')
97
97
  })), /*#__PURE__*/_react["default"].createElement("div", {
98
98
  className: "sdoc-header-content"
99
99
  }, isShowPlaceHolder && /*#__PURE__*/_react["default"].createElement(_placeholder["default"], {
@@ -31,7 +31,8 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
31
31
  className = _ref.className,
32
32
  idPrefix = _ref.idPrefix,
33
33
  readonly = _ref.readonly,
34
- onColorPickerUnmount = _ref.onColorPickerUnmount;
34
+ onColorPickerUnmount = _ref.onColorPickerUnmount,
35
+ closeColorMenuOnArrowKey = _ref.closeColorMenuOnArrowKey;
35
36
  var selectedFontSize = (0, _helpers.getFontSize)(editor);
36
37
  var selectedFontSizeValue = selectedFontSize;
37
38
  var enableSeafileAI = _context["default"].getSetting('enableSeafileAI');
@@ -120,6 +121,7 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
120
121
  };
121
122
  if (item.isColor) {
122
123
  itemProps['onColorPickerUnmount'] = onColorPickerUnmount;
124
+ itemProps['closeOnArrowKey'] = closeColorMenuOnArrowKey;
123
125
  itemProps['setColor'] = function (color, shouldFocus) {
124
126
  return setColor(item.type, color, shouldFocus);
125
127
  };
@@ -133,7 +135,7 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
133
135
  });
134
136
 
135
137
  // eslint-disable-next-line react-hooks/exhaustive-deps
136
- }, [editor, lastUsedFontColor, lastUsedHighlightColor, readonly, onColorPickerUnmount]);
138
+ }, [editor, lastUsedFontColor, lastUsedHighlightColor, readonly, onColorPickerUnmount, closeColorMenuOnArrowKey]);
137
139
  var list = getTextStyleList(_constants2.TEXT_STYLE);
138
140
  var dropdownList = getTextStyleList(_constants2.TEXT_STYLE_MORE);
139
141
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, list.map(function (itemProps, index) {
@@ -156,7 +156,8 @@ var ContextToolbar = function ContextToolbar(_ref) {
156
156
  }, /*#__PURE__*/_react["default"].createElement(_commons.MenuGroup, null, /*#__PURE__*/_react["default"].createElement(_menu["default"], {
157
157
  editor: editor,
158
158
  idPrefix: 'sdoc_context_toolbar',
159
- onColorPickerUnmount: onColorPickerUnmount
159
+ onColorPickerUnmount: onColorPickerUnmount,
160
+ closeColorMenuOnArrowKey: true
160
161
  }))), document.body);
161
162
  };
162
163
  var _default = exports["default"] = ContextToolbar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "3.0.277",
3
+ "version": "3.0.279",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/haiwen/seadoc-editor.git",
@@ -53,7 +53,7 @@
53
53
  "remark-rehype": "11.0.0",
54
54
  "remark-stringify": "11.0.0",
55
55
  "slugid": "3.2.0",
56
- "socket.io-client": "^4.8.3",
56
+ "socket.io-client": "4.8.4",
57
57
  "type-of": "2.0.1",
58
58
  "unified": "11.0.3",
59
59
  "url-join": "4.0.1",