@seafile/sdoc-editor 3.0.254 → 3.0.255

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.
@@ -66,9 +66,10 @@ var ColorMenu = function ColorMenu(_ref) {
66
66
  setPickerShow = _useState6[1];
67
67
  var onSetColor = (0, _react.useCallback)(function (color) {
68
68
  var shouldClose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
69
+ var shouldFocus = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
69
70
  if (disabled) return;
70
71
  var validColor = color || '';
71
- setColor(validColor);
72
+ setColor(validColor, shouldFocus);
72
73
  if (validColor !== '' && recentUsedColors[0] !== validColor) {
73
74
  var newRecentUsedColors = recentUsedColors.slice(0, 9);
74
75
  newRecentUsedColors.unshift(validColor);
@@ -101,12 +102,17 @@ var ColorMenu = function ColorMenu(_ref) {
101
102
  setPickerShow(!isPickerShow);
102
103
  // eslint-disable-next-line react-hooks/exhaustive-deps
103
104
  }, [moreColorsPopoverRef, isPickerShow]);
105
+ var onPickerMouseDown = (0, _react.useCallback)(function (event) {
106
+ var _event$currentTarget$;
107
+ if (event.target.tagName === 'INPUT') (0, _mouseEvent.eventStopPropagation)(event);else (_event$currentTarget$ = event.currentTarget.querySelector('input:focus')) === null || _event$currentTarget$ === void 0 ? void 0 : _event$currentTarget$.blur();
108
+ }, []);
104
109
  var onClick = (0, _react.useCallback)(function (event) {
105
110
  (0, _mouseEvent.eventStopPropagation)(event);
106
111
  }, []);
107
- var onChange = (0, _react.useCallback)(function (color) {
112
+ var onChange = (0, _react.useCallback)(function (color, event) {
113
+ var _event$target;
108
114
  var validColor = color.hex;
109
- onSetColor(validColor, false);
115
+ onSetColor(validColor, false, (event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName) !== 'INPUT');
110
116
  // eslint-disable-next-line react-hooks/exhaustive-deps
111
117
  }, [disabled]);
112
118
  var setLastUsedColor = (0, _react.useCallback)(function (event) {
@@ -227,6 +233,7 @@ var ColorMenu = function ColorMenu(_ref) {
227
233
  offset: [0, 0]
228
234
  }, /*#__PURE__*/_react["default"].createElement("div", {
229
235
  className: "sdoc-more-colors-container",
236
+ onMouseDown: onPickerMouseDown,
230
237
  onClick: onClick
231
238
  }, /*#__PURE__*/_react["default"].createElement(_reactColor.ChromePicker, {
232
239
  disableAlpha: true,
@@ -82,8 +82,9 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
82
82
  // eslint-disable-next-line react-hooks/exhaustive-deps
83
83
  }, [editor]);
84
84
  var setColor = (0, _react.useCallback)(function (type, color) {
85
+ var shouldFocus = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
85
86
  _slate.Editor.addMark(editor, type, color);
86
- (0, _core.focusEditor)(editor);
87
+ if (shouldFocus) (0, _core.focusEditor)(editor);
87
88
 
88
89
  // eslint-disable-next-line react-hooks/exhaustive-deps
89
90
  }, [editor]);
@@ -117,8 +118,8 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
117
118
  onMouseDown: item.isColor ? function () {} : onMouseDown
118
119
  };
119
120
  if (item.isColor) {
120
- itemProps['setColor'] = function (color) {
121
- return setColor(item.type, color);
121
+ itemProps['setColor'] = function (color, shouldFocus) {
122
+ return setColor(item.type, color, shouldFocus);
122
123
  };
123
124
  itemProps['defaultColorTip'] = item.type === _constants2.TEXT_STYLE_MAP.COLOR ? t('Default') : '';
124
125
  itemProps['lastUsedColor'] = item.type === _constants2.TEXT_STYLE_MAP.COLOR ? lastUsedFontColor : lastUsedHighlightColor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "3.0.254",
3
+ "version": "3.0.255",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "e5d88a3c1423f08871e0b5c28c56d47043047238"
73
+ "gitHead": "23e458f8e50ab0eded01a781c9add9240400af3e"
74
74
  }