@seafile/sdoc-editor 0.4.23 → 0.4.26
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/basic-sdk/assets/css/dropdown-menu.css +1 -1
- package/dist/basic-sdk/extension/plugins/table/helpers.js +23 -2
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +6 -16
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +1 -1
- package/package.json +1 -1
|
@@ -1257,8 +1257,12 @@ export const getRowDomHeight = (editor, row) => {
|
|
|
1257
1257
|
rowspan = 1
|
|
1258
1258
|
} = cell;
|
|
1259
1259
|
if (is_combined || rowspan > 1) continue;
|
|
1260
|
-
|
|
1261
|
-
|
|
1260
|
+
let cellDom = null;
|
|
1261
|
+
try {
|
|
1262
|
+
cellDom = ReactEditor.toDOMNode(editor, cell);
|
|
1263
|
+
} catch (error) {
|
|
1264
|
+
if (!cellDom) break;
|
|
1265
|
+
}
|
|
1262
1266
|
height = cellDom.getBoundingClientRect().height;
|
|
1263
1267
|
break;
|
|
1264
1268
|
}
|
|
@@ -1491,4 +1495,21 @@ export const getResizeMaskCellInfo = (editor, table, rowIndex, cellIndex) => {
|
|
|
1491
1495
|
cell,
|
|
1492
1496
|
focusCellIndex
|
|
1493
1497
|
};
|
|
1498
|
+
};
|
|
1499
|
+
|
|
1500
|
+
// Table alternate highlight
|
|
1501
|
+
export const getHighlightClass = (editor, cellPath) => {
|
|
1502
|
+
var _tableEntry$;
|
|
1503
|
+
const [tableEntry] = Editor.nodes(editor, {
|
|
1504
|
+
at: cellPath,
|
|
1505
|
+
match: n => n.type === ELEMENT_TYPE.TABLE
|
|
1506
|
+
});
|
|
1507
|
+
const {
|
|
1508
|
+
alternate_highlight,
|
|
1509
|
+
alternate_highlight_color
|
|
1510
|
+
} = ((_tableEntry$ = tableEntry[0]) === null || _tableEntry$ === void 0 ? void 0 : _tableEntry$.ui) || {};
|
|
1511
|
+
if (!alternate_highlight) return '';
|
|
1512
|
+
const rowIndex = cellPath[cellPath.length - 2];
|
|
1513
|
+
const className = getCellHighlightClassName(alternate_highlight_color, rowIndex);
|
|
1514
|
+
return className;
|
|
1494
1515
|
};
|
|
@@ -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,
|
|
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/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js
CHANGED
|
@@ -18,7 +18,7 @@ const RowHeader = _ref => {
|
|
|
18
18
|
tableSize
|
|
19
19
|
} = _ref;
|
|
20
20
|
const editor = useSlateStatic();
|
|
21
|
-
|
|
21
|
+
useEffect(() => {
|
|
22
22
|
setRowHeight(getRowDomHeight(editor, row));
|
|
23
23
|
}, [editor, row, tableSize]);
|
|
24
24
|
const oldRowHeight = getRowDomHeight(editor, row);
|