@seafile/sdoc-editor 0.4.23 → 0.4.24

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.
@@ -13,7 +13,7 @@
13
13
  }
14
14
 
15
15
  .sdoc-dropdown-menu .sdoc-dropdown-menu-item {
16
- height: 28px;
16
+ height: 30px;
17
17
  width: 100%;
18
18
  padding: 4px 24px;
19
19
  user-select: none;
@@ -1491,4 +1491,21 @@ export const getResizeMaskCellInfo = (editor, table, rowIndex, cellIndex) => {
1491
1491
  cell,
1492
1492
  focusCellIndex
1493
1493
  };
1494
+ };
1495
+
1496
+ // Table alternate highlight
1497
+ export const getHighlightClass = (editor, cellPath) => {
1498
+ var _tableEntry$;
1499
+ const [tableEntry] = Editor.nodes(editor, {
1500
+ at: cellPath,
1501
+ match: n => n.type === ELEMENT_TYPE.TABLE
1502
+ });
1503
+ const {
1504
+ alternate_highlight,
1505
+ alternate_highlight_color
1506
+ } = ((_tableEntry$ = tableEntry[0]) === null || _tableEntry$ === void 0 ? void 0 : _tableEntry$.ui) || {};
1507
+ if (!alternate_highlight) return '';
1508
+ const rowIndex = cellPath[cellPath.length - 2];
1509
+ const className = getCellHighlightClassName(alternate_highlight_color, rowIndex);
1510
+ return className;
1494
1511
  };
@@ -7,8 +7,7 @@ import ObjectUtils from '../../../../utils/object-utils';
7
7
  import { findPath, focusEditor } from '../../../core';
8
8
  import { useResizeHandlersContext, useTableSelectedRangeContext } from './hooks';
9
9
  import { EMPTY_SELECTED_RANGE, SELECTED_TABLE_CELL_BACKGROUND_COLOR, TABLE_CELL_STYLE } from '../constants';
10
- import { getTableColumns, colorBlend, getCellHighlightClassName } from '../helpers';
11
- import { ELEMENT_TYPE } from '../../../constants';
10
+ import { getTableColumns, colorBlend, getHighlightClass } from '../helpers';
12
11
  import EventBus from '../../../../utils/event-bus';
13
12
  import { INTERNAL_EVENT } from '../../../../constants';
14
13
  const TableCell = _ref => {
@@ -75,19 +74,6 @@ const TableCell = _ref => {
75
74
  if (element.style) {
76
75
  style = _objectSpread(_objectSpread({}, element.style), style);
77
76
  }
78
-
79
- // Table alternate highlight
80
- const highlightClass = useMemo(() => {
81
- var _tableEntry$;
82
- const {
83
- alternate_highlight,
84
- alternate_highlight_color
85
- } = ((_tableEntry$ = tableEntry[0]) === null || _tableEntry$ === void 0 ? void 0 : _tableEntry$.ui) || {};
86
- if (!alternate_highlight) return '';
87
- const className = getCellHighlightClassName(alternate_highlight_color, rowIndex);
88
- return className;
89
- // eslint-disable-next-line react-hooks/exhaustive-deps
90
- }, [editor, rowIndex]);
91
77
  const onMouseMove = mouseDownEvent => {
92
78
  const eventBus = EventBus.getInstance();
93
79
  const tableId = tableEntry[0].id;
@@ -99,6 +85,7 @@ const TableCell = _ref => {
99
85
  tableId
100
86
  });
101
87
  };
88
+ const highlightClass = useMemo(() => getHighlightClass(editor, cellPath), [cellPath, editor]);
102
89
  return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
103
90
  style: _objectSpread(_objectSpread({}, element.style), style),
104
91
  className: classnames('table-cell', attributes.className, highlightClass, {
@@ -133,6 +120,9 @@ function renderTableCell(props) {
133
120
  const rowIndex = cellPath[pathLength - 2];
134
121
  const cellIndex = cellPath[pathLength - 1];
135
122
 
123
+ // eslint-disable-next-line react-hooks/rules-of-hooks
124
+ const highlightClass = useMemo(() => getHighlightClass(editor, cellPath), [cellPath, editor]);
125
+
136
126
  // const cellValue = element;
137
127
  let style = attributes.style || {};
138
128
  if (ObjectUtils.hasProperty(element.style, TABLE_CELL_STYLE.TEXT_ALIGN)) {
@@ -157,7 +147,7 @@ function renderTableCell(props) {
157
147
  style.gridArea = "".concat(rowIndex + 1, " / ").concat(cellIndex + 1, " / span ").concat(rowspan, " / span ").concat(colspan);
158
148
  return /*#__PURE__*/React.createElement("div", Object.assign({}, attributes, {
159
149
  style: _objectSpread(_objectSpread({}, element.style), style),
160
- className: classnames('table-cell', attributes.className),
150
+ className: classnames('table-cell', highlightClass, attributes.className),
161
151
  "data-id": element.id
162
152
  }), children);
163
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.4.23",
3
+ "version": "0.4.24",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",