@atlaskit/editor-plugin-table 7.5.5 → 7.5.7
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/CHANGELOG.md +13 -0
- package/dist/cjs/commands/selection.js +23 -1
- package/dist/cjs/event-handlers.js +25 -9
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/cjs/nodeviews/TableCell.js +5 -30
- package/dist/cjs/nodeviews/TableComponent.js +96 -41
- package/dist/cjs/nodeviews/TableContainer.js +19 -17
- package/dist/cjs/nodeviews/TableResizer.js +1 -1
- package/dist/cjs/plugin.js +2 -3
- package/dist/cjs/pm-plugins/main.js +3 -18
- package/dist/cjs/pm-plugins/sticky-headers/types.js +1 -5
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +3 -7
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +11 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +22 -23
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +2 -2
- package/dist/cjs/pm-plugins/table-selection-keymap.js +3 -0
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
- package/dist/cjs/utils/column-controls.js +5 -5
- package/dist/cjs/utils/dom.js +13 -15
- package/dist/es2019/commands/selection.js +22 -0
- package/dist/es2019/event-handlers.js +25 -9
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/es2019/nodeviews/TableCell.js +1 -24
- package/dist/es2019/nodeviews/TableComponent.js +69 -31
- package/dist/es2019/nodeviews/TableContainer.js +16 -18
- package/dist/es2019/nodeviews/TableResizer.js +1 -1
- package/dist/es2019/plugin.js +2 -3
- package/dist/es2019/pm-plugins/main.js +3 -18
- package/dist/es2019/pm-plugins/sticky-headers/types.js +0 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +3 -7
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +10 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +21 -22
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -2
- package/dist/es2019/pm-plugins/table-selection-keymap.js +5 -2
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
- package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
- package/dist/es2019/utils/column-controls.js +6 -6
- package/dist/es2019/utils/dom.js +13 -15
- package/dist/esm/commands/selection.js +22 -0
- package/dist/esm/event-handlers.js +25 -9
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
- package/dist/esm/nodeviews/TableCell.js +5 -30
- package/dist/esm/nodeviews/TableComponent.js +96 -41
- package/dist/esm/nodeviews/TableContainer.js +20 -18
- package/dist/esm/nodeviews/TableResizer.js +1 -1
- package/dist/esm/plugin.js +2 -3
- package/dist/esm/pm-plugins/main.js +3 -18
- package/dist/esm/pm-plugins/sticky-headers/types.js +0 -1
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +3 -7
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +10 -0
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +23 -24
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +2 -2
- package/dist/esm/pm-plugins/table-selection-keymap.js +5 -2
- package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
- package/dist/esm/ui/TableFloatingControls/index.js +113 -224
- package/dist/esm/utils/column-controls.js +6 -6
- package/dist/esm/utils/dom.js +13 -15
- package/dist/types/commands/selection.d.ts +1 -0
- package/dist/types/event-handlers.d.ts +3 -4
- package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types/nodeviews/TableCell.d.ts +1 -5
- package/dist/types/nodeviews/TableComponent.d.ts +4 -0
- package/dist/types/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -0
- package/dist/types/types.d.ts +0 -3
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types/utils/dom.d.ts +10 -2
- package/dist/types-ts4.5/commands/selection.d.ts +1 -0
- package/dist/types-ts4.5/event-handlers.d.ts +3 -4
- package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +4 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +0 -3
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
- package/dist/types-ts4.5/utils/dom.d.ts +10 -2
- package/package.json +8 -6
- package/src/commands/selection.ts +33 -0
- package/src/event-handlers.ts +105 -103
- package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
- package/src/nodeviews/TableCell.ts +0 -26
- package/src/nodeviews/TableComponent.tsx +81 -34
- package/src/nodeviews/TableContainer.tsx +19 -25
- package/src/nodeviews/TableResizer.tsx +1 -4
- package/src/plugin.tsx +5 -4
- package/src/pm-plugins/main.ts +3 -22
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +3 -6
- package/src/pm-plugins/table-resizing/utils/misc.ts +13 -0
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +22 -28
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +3 -10
- package/src/pm-plugins/table-selection-keymap.ts +10 -0
- package/src/types.ts +0 -4
- package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
- package/src/ui/TableFloatingControls/index.tsx +155 -241
- package/src/utils/column-controls.ts +5 -6
- package/src/utils/dom.ts +12 -19
|
@@ -5,240 +5,130 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
|
+
exports.default = exports.TableFloatingControls = void 0;
|
|
16
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
11
|
var _commands = require("../../commands");
|
|
19
12
|
var _types = require("../../types");
|
|
20
|
-
var _utils2 = require("../../utils");
|
|
21
13
|
var _CornerControls = require("./CornerControls");
|
|
22
14
|
var _NumberColumn = _interopRequireDefault(require("./NumberColumn"));
|
|
23
15
|
var _RowControls = require("./RowControls");
|
|
24
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
25
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var editorView = _this.props.editorView;
|
|
50
|
-
var state = editorView.state,
|
|
51
|
-
dispatch = editorView.dispatch;
|
|
52
|
-
// fix for issue ED-4665
|
|
53
|
-
if (_utils.browser.ie_version === 11) {
|
|
54
|
-
editorView.dom.blur();
|
|
55
|
-
}
|
|
56
|
-
(0, _commands.selectRows)(rowIndexes)(state, dispatch);
|
|
57
|
-
});
|
|
58
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hoverRows", function (rows, danger) {
|
|
59
|
-
var _this$props$editorVie = _this.props.editorView,
|
|
60
|
-
state = _this$props$editorVie.state,
|
|
61
|
-
dispatch = _this$props$editorVie.dispatch;
|
|
62
|
-
(0, _commands.hoverRows)(rows, danger)(state, dispatch);
|
|
63
|
-
});
|
|
64
|
-
// re-use across numbered columns and row controls
|
|
65
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateCellHoverLocation", function (rowIndex) {
|
|
66
|
-
var _this$props = _this.props,
|
|
67
|
-
editorView = _this$props.editorView,
|
|
68
|
-
tableActive = _this$props.tableActive;
|
|
69
|
-
var state = editorView.state,
|
|
70
|
-
dispatch = editorView.dispatch;
|
|
71
|
-
if (tableActive) {
|
|
72
|
-
// For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
|
|
73
|
-
// of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
|
|
74
|
-
// also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
|
|
75
|
-
// current column index. We can just force it to 0.
|
|
76
|
-
(0, _commands.hoverCell)(rowIndex, 0)(state, dispatch);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
_this.state = {
|
|
80
|
-
tableWrapperWidth: 0,
|
|
81
|
-
/** Height needs to be tracked to re-render decorations correctly, do not remove */
|
|
82
|
-
tableWrapperHeight: 0
|
|
83
|
-
};
|
|
84
|
-
return _this;
|
|
85
|
-
}
|
|
86
|
-
(0, _createClass2.default)(TableFloatingControls, [{
|
|
87
|
-
key: "componentDidMount",
|
|
88
|
-
value: function componentDidMount() {
|
|
89
|
-
this.tryInitResizeObserver();
|
|
18
|
+
var TableFloatingControls = exports.TableFloatingControls = function TableFloatingControls(_ref) {
|
|
19
|
+
var editorView = _ref.editorView,
|
|
20
|
+
tableRef = _ref.tableRef,
|
|
21
|
+
tableNode = _ref.tableNode,
|
|
22
|
+
isInDanger = _ref.isInDanger,
|
|
23
|
+
isResizing = _ref.isResizing,
|
|
24
|
+
isNumberColumnEnabled = _ref.isNumberColumnEnabled,
|
|
25
|
+
isHeaderRowEnabled = _ref.isHeaderRowEnabled,
|
|
26
|
+
isHeaderColumnEnabled = _ref.isHeaderColumnEnabled,
|
|
27
|
+
tableActive = _ref.tableActive,
|
|
28
|
+
hasHeaderRow = _ref.hasHeaderRow,
|
|
29
|
+
hoveredRows = _ref.hoveredRows,
|
|
30
|
+
stickyHeader = _ref.stickyHeader,
|
|
31
|
+
isDragAndDropEnabled = _ref.isDragAndDropEnabled,
|
|
32
|
+
hoveredCell = _ref.hoveredCell,
|
|
33
|
+
isTableHovered = _ref.isTableHovered,
|
|
34
|
+
tableWrapperWidth = _ref.tableWrapperWidth;
|
|
35
|
+
var _selectRow = (0, _react.useCallback)(function (row, expand) {
|
|
36
|
+
var state = editorView.state,
|
|
37
|
+
dispatch = editorView.dispatch;
|
|
38
|
+
// fix for issue ED-4665
|
|
39
|
+
if (_utils.browser.ie_version === 11) {
|
|
40
|
+
editorView.dom.blur();
|
|
90
41
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
42
|
+
(0, _commands.selectRow)(row, expand)(state, dispatch);
|
|
43
|
+
}, [editorView]);
|
|
44
|
+
var _selectRows = (0, _react.useCallback)(function (rowIndexes) {
|
|
45
|
+
var state = editorView.state,
|
|
46
|
+
dispatch = editorView.dispatch;
|
|
47
|
+
// fix for issue ED-4665
|
|
48
|
+
if (_utils.browser.ie_version === 11) {
|
|
49
|
+
editorView.dom.blur();
|
|
96
50
|
}
|
|
51
|
+
(0, _commands.selectRows)(rowIndexes)(state, dispatch);
|
|
52
|
+
}, [editorView]);
|
|
53
|
+
var _hoverRows = (0, _react.useCallback)(function (rows, danger) {
|
|
54
|
+
var state = editorView.state,
|
|
55
|
+
dispatch = editorView.dispatch;
|
|
56
|
+
(0, _commands.hoverRows)(rows, danger)(state, dispatch);
|
|
57
|
+
}, [editorView]);
|
|
97
58
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var _iterator = _createForOfIteratorHelper(entries),
|
|
109
|
-
_step;
|
|
110
|
-
try {
|
|
111
|
-
var _loop = function _loop() {
|
|
112
|
-
var entry = _step.value;
|
|
113
|
-
_this2.setState(function (prev) {
|
|
114
|
-
return (prev === null || prev === void 0 ? void 0 : prev.tableWrapperWidth) === entry.contentRect.width && prev.tableWrapperHeight === entry.contentRect.height ? prev : {
|
|
115
|
-
tableWrapperWidth: entry.contentRect.width,
|
|
116
|
-
tableWrapperHeight: entry.contentRect.height
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
121
|
-
_loop();
|
|
122
|
-
}
|
|
123
|
-
} catch (err) {
|
|
124
|
-
_iterator.e(err);
|
|
125
|
-
} finally {
|
|
126
|
-
_iterator.f();
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
this.resizeObserver.observe(tableWrapper);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}, {
|
|
133
|
-
key: "shouldComponentUpdate",
|
|
134
|
-
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
135
|
-
var _this$props2 = this.props,
|
|
136
|
-
tableRef = _this$props2.tableRef,
|
|
137
|
-
isInDanger = _this$props2.isInDanger,
|
|
138
|
-
isResizing = _this$props2.isResizing,
|
|
139
|
-
isHeaderRowEnabled = _this$props2.isHeaderRowEnabled,
|
|
140
|
-
isNumberColumnEnabled = _this$props2.isNumberColumnEnabled,
|
|
141
|
-
hoveredRows = _this$props2.hoveredRows,
|
|
142
|
-
selection = _this$props2.selection,
|
|
143
|
-
tableActive = _this$props2.tableActive,
|
|
144
|
-
isHeaderColumnEnabled = _this$props2.isHeaderColumnEnabled,
|
|
145
|
-
ordering = _this$props2.ordering,
|
|
146
|
-
headerRowHeight = _this$props2.headerRowHeight,
|
|
147
|
-
stickyHeader = _this$props2.stickyHeader,
|
|
148
|
-
hoveredCell = _this$props2.hoveredCell,
|
|
149
|
-
isTableHovered = _this$props2.isTableHovered;
|
|
150
|
-
return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || (0, _utils2.isSelectionUpdated)(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell || isTableHovered !== nextProps.isTableHovered;
|
|
59
|
+
// re-use across numbered columns and row controls
|
|
60
|
+
var updateCellHoverLocation = (0, _react.useCallback)(function (rowIndex) {
|
|
61
|
+
var state = editorView.state,
|
|
62
|
+
dispatch = editorView.dispatch;
|
|
63
|
+
if (tableActive) {
|
|
64
|
+
// For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
|
|
65
|
+
// of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
|
|
66
|
+
// also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
|
|
67
|
+
// current column index. We can just force it to 0.
|
|
68
|
+
(0, _commands.hoverCell)(rowIndex, 0)(state, dispatch);
|
|
151
69
|
}
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
editorView = _this$props3.editorView,
|
|
164
|
-
tableRef = _this$props3.tableRef,
|
|
165
|
-
tableNode = _this$props3.tableNode,
|
|
166
|
-
isInDanger = _this$props3.isInDanger,
|
|
167
|
-
isResizing = _this$props3.isResizing,
|
|
168
|
-
isNumberColumnEnabled = _this$props3.isNumberColumnEnabled,
|
|
169
|
-
isHeaderRowEnabled = _this$props3.isHeaderRowEnabled,
|
|
170
|
-
isHeaderColumnEnabled = _this$props3.isHeaderColumnEnabled,
|
|
171
|
-
tableActive = _this$props3.tableActive,
|
|
172
|
-
hasHeaderRow = _this$props3.hasHeaderRow,
|
|
173
|
-
hoveredRows = _this$props3.hoveredRows,
|
|
174
|
-
stickyHeader = _this$props3.stickyHeader,
|
|
175
|
-
isDragAndDropEnabled = _this$props3.isDragAndDropEnabled,
|
|
176
|
-
hoveredCell = _this$props3.hoveredCell,
|
|
177
|
-
isTableHovered = _this$props3.isTableHovered;
|
|
178
|
-
if (!tableRef) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
182
|
-
var wrapperClassName = isDragAndDropEnabled ? _types.TableCssClassName.DRAG_ROW_CONTROLS_WRAPPER : _types.TableCssClassName.ROW_CONTROLS_WRAPPER;
|
|
183
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
184
|
-
className: wrapperClassName
|
|
185
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
186
|
-
onMouseDown: function onMouseDown(e) {
|
|
187
|
-
return !isDragAndDropEnabled && e.preventDefault();
|
|
188
|
-
}
|
|
189
|
-
}, isNumberColumnEnabled ? /*#__PURE__*/_react.default.createElement(_NumberColumn.default, {
|
|
190
|
-
editorView: editorView,
|
|
191
|
-
hoverRows: this.hoverRows,
|
|
192
|
-
tableRef: tableRef,
|
|
193
|
-
tableActive: tableActive,
|
|
194
|
-
hoveredRows: hoveredRows,
|
|
195
|
-
hasHeaderRow: hasHeaderRow,
|
|
196
|
-
isInDanger: isInDanger,
|
|
197
|
-
isResizing: isResizing,
|
|
198
|
-
selectRow: this.selectRow,
|
|
199
|
-
updateCellHoverLocation: this.updateCellHoverLocation,
|
|
200
|
-
stickyTop: stickyTop,
|
|
201
|
-
isDragAndDropEnabled: isDragAndDropEnabled
|
|
202
|
-
}) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.DragCornerControls, {
|
|
203
|
-
editorView: editorView,
|
|
204
|
-
tableRef: tableRef,
|
|
205
|
-
isInDanger: isInDanger,
|
|
206
|
-
isResizing: isResizing
|
|
207
|
-
}), /*#__PURE__*/_react.default.createElement(_RowControls.DragControls, {
|
|
208
|
-
tableRef: tableRef,
|
|
209
|
-
tableNode: tableNode,
|
|
210
|
-
hoveredCell: hoveredCell,
|
|
211
|
-
isTableHovered: isTableHovered,
|
|
212
|
-
editorView: editorView,
|
|
213
|
-
tableActive: tableActive,
|
|
214
|
-
isInDanger: isInDanger,
|
|
215
|
-
isResizing: isResizing,
|
|
216
|
-
tableWidth: this.state.tableWrapperWidth,
|
|
217
|
-
hoverRows: this.hoverRows,
|
|
218
|
-
selectRow: this.selectRow,
|
|
219
|
-
selectRows: this.selectRows,
|
|
220
|
-
updateCellHoverLocation: this.updateCellHoverLocation
|
|
221
|
-
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
|
|
222
|
-
editorView: editorView,
|
|
223
|
-
tableRef: tableRef,
|
|
224
|
-
isInDanger: isInDanger,
|
|
225
|
-
isResizing: isResizing,
|
|
226
|
-
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
227
|
-
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
228
|
-
hoveredRows: hoveredRows,
|
|
229
|
-
stickyTop: tableActive ? stickyTop : undefined
|
|
230
|
-
}), /*#__PURE__*/_react.default.createElement(_RowControls.RowControls, {
|
|
231
|
-
editorView: editorView,
|
|
232
|
-
tableRef: tableRef,
|
|
233
|
-
hoverRows: this.hoverRows,
|
|
234
|
-
hoveredRows: hoveredRows,
|
|
235
|
-
isInDanger: isInDanger,
|
|
236
|
-
isResizing: isResizing,
|
|
237
|
-
selectRow: this.selectRow,
|
|
238
|
-
stickyTop: tableActive ? stickyTop : undefined
|
|
239
|
-
})))));
|
|
70
|
+
}, [editorView, tableActive]);
|
|
71
|
+
if (!tableRef) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
75
|
+
var wrapperClassName = isDragAndDropEnabled ? _types.TableCssClassName.DRAG_ROW_CONTROLS_WRAPPER : _types.TableCssClassName.ROW_CONTROLS_WRAPPER;
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
77
|
+
className: wrapperClassName
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
79
|
+
onMouseDown: function onMouseDown(e) {
|
|
80
|
+
return !isDragAndDropEnabled && e.preventDefault();
|
|
240
81
|
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
82
|
+
}, isNumberColumnEnabled ? /*#__PURE__*/_react.default.createElement(_NumberColumn.default, {
|
|
83
|
+
editorView: editorView,
|
|
84
|
+
hoverRows: _hoverRows,
|
|
85
|
+
tableRef: tableRef,
|
|
86
|
+
tableActive: tableActive,
|
|
87
|
+
hoveredRows: hoveredRows,
|
|
88
|
+
hasHeaderRow: hasHeaderRow,
|
|
89
|
+
isInDanger: isInDanger,
|
|
90
|
+
isResizing: isResizing,
|
|
91
|
+
selectRow: _selectRow,
|
|
92
|
+
updateCellHoverLocation: updateCellHoverLocation,
|
|
93
|
+
stickyTop: stickyTop,
|
|
94
|
+
isDragAndDropEnabled: isDragAndDropEnabled
|
|
95
|
+
}) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.DragCornerControls, {
|
|
96
|
+
editorView: editorView,
|
|
97
|
+
tableRef: tableRef,
|
|
98
|
+
isInDanger: isInDanger,
|
|
99
|
+
isResizing: isResizing
|
|
100
|
+
}), /*#__PURE__*/_react.default.createElement(_RowControls.DragControls, {
|
|
101
|
+
tableRef: tableRef,
|
|
102
|
+
tableNode: tableNode,
|
|
103
|
+
hoveredCell: hoveredCell,
|
|
104
|
+
isTableHovered: isTableHovered,
|
|
105
|
+
editorView: editorView,
|
|
106
|
+
tableActive: tableActive,
|
|
107
|
+
isInDanger: isInDanger,
|
|
108
|
+
isResizing: isResizing,
|
|
109
|
+
tableWidth: tableWrapperWidth,
|
|
110
|
+
hoverRows: _hoverRows,
|
|
111
|
+
selectRow: _selectRow,
|
|
112
|
+
selectRows: _selectRows,
|
|
113
|
+
updateCellHoverLocation: updateCellHoverLocation
|
|
114
|
+
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
|
|
115
|
+
editorView: editorView,
|
|
116
|
+
tableRef: tableRef,
|
|
117
|
+
isInDanger: isInDanger,
|
|
118
|
+
isResizing: isResizing,
|
|
119
|
+
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
120
|
+
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
121
|
+
hoveredRows: hoveredRows,
|
|
122
|
+
stickyTop: tableActive ? stickyTop : undefined
|
|
123
|
+
}), /*#__PURE__*/_react.default.createElement(_RowControls.RowControls, {
|
|
124
|
+
editorView: editorView,
|
|
125
|
+
tableRef: tableRef,
|
|
126
|
+
hoverRows: _hoverRows,
|
|
127
|
+
hoveredRows: hoveredRows,
|
|
128
|
+
isInDanger: isInDanger,
|
|
129
|
+
isResizing: isResizing,
|
|
130
|
+
selectRow: _selectRow,
|
|
131
|
+
stickyTop: tableActive ? stickyTop : undefined
|
|
132
|
+
})))));
|
|
133
|
+
};
|
|
134
|
+
var _default = exports.default = TableFloatingControls;
|
|
@@ -26,13 +26,13 @@ var getColumnsWidths = exports.getColumnsWidths = function getColumnsWidths(view
|
|
|
26
26
|
length: map.width
|
|
27
27
|
});
|
|
28
28
|
for (var i = 0; i < map.width; i++) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var cellRef = (0, _utils2.findDomRefAtPos)(
|
|
29
|
+
if (!map.isCellMergedTopLeft(0, i)) {
|
|
30
|
+
var node = table.node.nodeAt(map.map[i]);
|
|
31
|
+
var pos = map.map[i] + table.start;
|
|
32
|
+
var cellRef = (0, _utils2.findDomRefAtPos)(pos, domAtPos);
|
|
33
33
|
var rect = cellRef.getBoundingClientRect();
|
|
34
34
|
widths[i] = (rect ? rect.width : cellRef.offsetWidth) + 1;
|
|
35
|
-
i +=
|
|
35
|
+
i += node.attrs.colspan - 1;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
package/dist/cjs/utils/dom.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isDragRowFloatingInsertDot = exports.isDragRowControlsButton = exports.isDragCornerButton = exports.isDragColumnFloatingInsertDot = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = exports.findNearestCellIndexToPoint = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
8
|
var _types = require("../types");
|
|
9
|
-
var SELECTOR_TABLE_LEAFS = ".".concat(_types.TableCssClassName.TABLE_CELL, ", .").concat(_types.TableCssClassName.TABLE_HEADER_CELL);
|
|
10
9
|
var isCell = exports.isCell = function isCell(node) {
|
|
11
10
|
return Boolean(node && (['TH', 'TD'].indexOf(node.tagName) > -1 || !!(0, _utils.closestElement)(node, ".".concat(_types.TableCssClassName.TABLE_HEADER_CELL)) || !!(0, _utils.closestElement)(node, ".".concat(_types.TableCssClassName.TABLE_CELL))));
|
|
12
11
|
};
|
|
@@ -102,22 +101,21 @@ var isDragCornerButton = exports.isDragCornerButton = function isDragCornerButto
|
|
|
102
101
|
*
|
|
103
102
|
* the same is valid to the right side.
|
|
104
103
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
/**
|
|
105
|
+
* This can be used with mouse events to determine the left/right side of the target the pointer is closest too.
|
|
106
|
+
*
|
|
107
|
+
* WARNING: This metod reads properties which can trigger a reflow; use this wisely.
|
|
108
|
+
*
|
|
109
|
+
* @param mouseEvent
|
|
110
|
+
* @param gapInPixels
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
var getMousePositionHorizontalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = function getMousePositionHorizontalRelativeByElement(mouseEvent, offsetX, gapInPixels) {
|
|
107
114
|
var element = mouseEvent.target;
|
|
108
115
|
if (element instanceof HTMLElement) {
|
|
109
|
-
var width
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// directly from element that will be .pm-table-drag-columns-floating-insert-dot-wrapper
|
|
113
|
-
width = element.clientWidth;
|
|
114
|
-
} else {
|
|
115
|
-
var _closestCell$id, _elementContentRects$, _elementContentRects$2;
|
|
116
|
-
var closestCell = element.closest(SELECTOR_TABLE_LEAFS);
|
|
117
|
-
var id = (_closestCell$id = closestCell === null || closestCell === void 0 ? void 0 : closestCell.id) !== null && _closestCell$id !== void 0 ? _closestCell$id : '';
|
|
118
|
-
width = (_elementContentRects$ = elementContentRects === null || elementContentRects === void 0 || (_elementContentRects$2 = elementContentRects[id]) === null || _elementContentRects$2 === void 0 ? void 0 : _elementContentRects$2.width) !== null && _elementContentRects$ !== void 0 ? _elementContentRects$ : 0;
|
|
119
|
-
}
|
|
120
|
-
x = mouseEvent.offsetX;
|
|
116
|
+
var width = element.clientWidth; // reflow
|
|
117
|
+
var x = !Number.isNaN(offsetX) ? offsetX : mouseEvent.offsetX; // reflow
|
|
118
|
+
|
|
121
119
|
if (width <= 0) {
|
|
122
120
|
return null;
|
|
123
121
|
}
|
|
@@ -372,4 +372,26 @@ export const shiftArrowUpFromTable = editorSelectionAPI => () => (state, dispatc
|
|
|
372
372
|
})(state, dispatch);
|
|
373
373
|
}
|
|
374
374
|
return false;
|
|
375
|
+
};
|
|
376
|
+
export const modASelectTable = editorSelectionAPI => () => (state, dispatch) => {
|
|
377
|
+
const {
|
|
378
|
+
selection
|
|
379
|
+
} = state;
|
|
380
|
+
const table = findTable(selection);
|
|
381
|
+
if (!table) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
const {
|
|
385
|
+
$from,
|
|
386
|
+
$to
|
|
387
|
+
} = selection;
|
|
388
|
+
const tableSelected = isTableSelected(selection);
|
|
389
|
+
if (!tableSelected && $from.pos > table.start + 1 && $to.pos < table.start + table.node.nodeSize) {
|
|
390
|
+
return selectFullTable(editorSelectionAPI)({
|
|
391
|
+
node: table.node,
|
|
392
|
+
startPos: table.start,
|
|
393
|
+
dir: TableSelectionDirection.BottomToTop
|
|
394
|
+
})(state, dispatch);
|
|
395
|
+
}
|
|
396
|
+
return false;
|
|
375
397
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import rafSchedule from 'raf-schd';
|
|
1
2
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { browser, closestElement, isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
3
4
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -261,7 +262,10 @@ export const handleMouseLeave = (view, event) => {
|
|
|
261
262
|
}
|
|
262
263
|
return false;
|
|
263
264
|
};
|
|
264
|
-
|
|
265
|
+
|
|
266
|
+
// IMPORTANT: The mouse move handler has been setup with RAF schedule to avoid Reflows which will occur as some methods
|
|
267
|
+
// need to access the mouse event offset position and also the target clientWidth vallue.
|
|
268
|
+
const handleMouseMoveDebounce = rafSchedule((view, event, offsetX) => {
|
|
265
269
|
if (!(event.target instanceof HTMLElement)) {
|
|
266
270
|
return false;
|
|
267
271
|
}
|
|
@@ -272,11 +276,10 @@ export const handleMouseMove = (view, event, elementContentRects) => {
|
|
|
272
276
|
dispatch
|
|
273
277
|
} = view;
|
|
274
278
|
const {
|
|
275
|
-
insertColumnButtonIndex
|
|
276
|
-
isDragAndDropEnabled
|
|
279
|
+
insertColumnButtonIndex
|
|
277
280
|
} = getPluginState(state);
|
|
278
281
|
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
279
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(event,
|
|
282
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(event, offsetX, undefined) === 'right' ? endIndex : startIndex;
|
|
280
283
|
if (positionColumn !== insertColumnButtonIndex) {
|
|
281
284
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
282
285
|
}
|
|
@@ -296,7 +299,7 @@ export const handleMouseMove = (view, event, elementContentRects) => {
|
|
|
296
299
|
}
|
|
297
300
|
}
|
|
298
301
|
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
299
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(event,
|
|
302
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(event, offsetX, RESIZE_HANDLE_AREA_DECORATION_GAP);
|
|
300
303
|
if (positionColumn !== null) {
|
|
301
304
|
const {
|
|
302
305
|
state,
|
|
@@ -324,6 +327,19 @@ export const handleMouseMove = (view, event, elementContentRects) => {
|
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
329
|
return false;
|
|
330
|
+
});
|
|
331
|
+
export const handleMouseMove = (view, event) => {
|
|
332
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// NOTE: When accessing offsetX in gecko from a deferred callback, it will return 0. However it will be non-zero if accessed
|
|
337
|
+
// within the scope of it's initial mouse move handler. Also Chrome does return the correct value, however it could trigger
|
|
338
|
+
// a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
|
|
339
|
+
// in the deferred callback handler.
|
|
340
|
+
// Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
|
|
341
|
+
handleMouseMoveDebounce(view, event, browser.gecko ? event.offsetX : NaN);
|
|
342
|
+
return false;
|
|
327
343
|
};
|
|
328
344
|
export function handleTripleClick(view, pos) {
|
|
329
345
|
const {
|
|
@@ -406,11 +422,11 @@ export const isTableInFocus = view => {
|
|
|
406
422
|
var _getPluginState, _getResizePluginState;
|
|
407
423
|
return !!((_getPluginState = getPluginState(view.state)) !== null && _getPluginState !== void 0 && _getPluginState.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
408
424
|
};
|
|
409
|
-
export const whenTableInFocus =
|
|
425
|
+
export const whenTableInFocus = eventHandler => (view, mouseEvent) => {
|
|
410
426
|
if (!isTableInFocus(view)) {
|
|
411
427
|
return false;
|
|
412
428
|
}
|
|
413
|
-
return eventHandler(view, mouseEvent
|
|
429
|
+
return eventHandler(view, mouseEvent);
|
|
414
430
|
};
|
|
415
431
|
const trackCellLocation = (view, mouseEvent) => {
|
|
416
432
|
var _tableElement$dataset;
|
|
@@ -440,9 +456,9 @@ const trackCellLocation = (view, mouseEvent) => {
|
|
|
440
456
|
}
|
|
441
457
|
hoverCell(htmlRowIndex, colIndex)(view.state, view.dispatch);
|
|
442
458
|
};
|
|
443
|
-
export const withCellTracking =
|
|
459
|
+
export const withCellTracking = eventHandler => (view, mouseEvent) => {
|
|
444
460
|
if (getPluginState(view.state).isDragAndDropEnabled && !getDragDropPluginState(view.state).isDragging) {
|
|
445
461
|
trackCellLocation(view, mouseEvent);
|
|
446
462
|
}
|
|
447
|
-
return eventHandler(view, mouseEvent
|
|
463
|
+
return eventHandler(view, mouseEvent);
|
|
448
464
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import rafSchedule from 'raf-schd';
|
|
2
3
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
4
5
|
import { tableInsertColumnButtonSize } from '../ui/consts';
|
|
@@ -36,8 +37,13 @@ export class OverflowShadowsObserver {
|
|
|
36
37
|
});
|
|
37
38
|
_defineProperty(this, "observeShadowSentinels", isSticky => {
|
|
38
39
|
var _this$table, _this$table2;
|
|
40
|
+
if (this.isSticky === isSticky) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
39
43
|
this.isSticky = !!isSticky;
|
|
40
44
|
|
|
45
|
+
// reset height
|
|
46
|
+
this.stickyRowHeight = 0;
|
|
41
47
|
// update sticky shadows
|
|
42
48
|
this.updateStickyShadowsHeightIfChanged();
|
|
43
49
|
this.leftShadowSentinel = (_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.querySelector(`.${ClassName.TABLE_SHADOW_SENTINEL_LEFT}`);
|
|
@@ -54,8 +60,8 @@ export class OverflowShadowsObserver {
|
|
|
54
60
|
* e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
|
|
55
61
|
* reading it from sticky cell
|
|
56
62
|
*/
|
|
57
|
-
_defineProperty(this, "updateStickyShadows", stickyRowHeight => {
|
|
58
|
-
var _this$wrapper
|
|
63
|
+
_defineProperty(this, "updateStickyShadows", rafSchedule(stickyRowHeight => {
|
|
64
|
+
var _this$wrapper;
|
|
59
65
|
if (!this.isSticky) {
|
|
60
66
|
return;
|
|
61
67
|
}
|
|
@@ -63,14 +69,21 @@ export class OverflowShadowsObserver {
|
|
|
63
69
|
if (!stickyCell || !((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement)) {
|
|
64
70
|
return;
|
|
65
71
|
}
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
|
|
73
|
+
// Reflow Warning! - stickyCell.clientHeight
|
|
74
|
+
const newStickyRowHeight = stickyRowHeight || stickyCell.clientHeight + 1;
|
|
75
|
+
if (newStickyRowHeight !== this.stickyRowHeight) {
|
|
76
|
+
var _this$wrapper2, _this$wrapper2$parent, _this$wrapper3, _this$wrapper3$parent;
|
|
77
|
+
this.stickyRowHeight = newStickyRowHeight;
|
|
78
|
+
const heightStyleOrCompute = `${newStickyRowHeight}px`;
|
|
79
|
+
// Use getElementsByClassName here for a live node list to capture
|
|
80
|
+
// sticky shadows
|
|
81
|
+
const liveRightShadows = (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : (_this$wrapper2$parent = _this$wrapper2.parentElement) === null || _this$wrapper2$parent === void 0 ? void 0 : _this$wrapper2$parent.getElementsByClassName(`${ClassName.TABLE_RIGHT_SHADOW}`);
|
|
82
|
+
const liveLeftShadows = (_this$wrapper3 = this.wrapper) === null || _this$wrapper3 === void 0 ? void 0 : (_this$wrapper3$parent = _this$wrapper3.parentElement) === null || _this$wrapper3$parent === void 0 ? void 0 : _this$wrapper3$parent.getElementsByClassName(`${ClassName.TABLE_LEFT_SHADOW}`);
|
|
83
|
+
updateShadowListForStickyStyles(heightStyleOrCompute, liveLeftShadows);
|
|
84
|
+
updateShadowListForStickyStyles(heightStyleOrCompute, liveRightShadows);
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
74
87
|
this.updateShadowState = updateShadowState;
|
|
75
88
|
this.table = _table;
|
|
76
89
|
this.wrapper = wrapper;
|
|
@@ -84,11 +97,7 @@ export class OverflowShadowsObserver {
|
|
|
84
97
|
if (!stickyCell) {
|
|
85
98
|
return;
|
|
86
99
|
}
|
|
87
|
-
|
|
88
|
-
if (newStickyRowHeight === this.stickyRowHeight) {
|
|
89
|
-
this.stickyRowHeight = newStickyRowHeight;
|
|
90
|
-
this.updateStickyShadows(this.stickyRowHeight);
|
|
91
|
-
}
|
|
100
|
+
this.updateStickyShadows();
|
|
92
101
|
}
|
|
93
102
|
getStickyCell() {
|
|
94
103
|
var _this$wrapper4;
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import uuid from 'uuid';
|
|
2
1
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
3
|
-
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
4
2
|
import TableNodeView from './TableNodeViewBase';
|
|
5
3
|
const DEFAULT_COL_SPAN = 1;
|
|
6
4
|
const DEFAULT_ROW_SPAN = 1;
|
|
7
5
|
export default class TableCell extends TableNodeView {
|
|
8
|
-
constructor(node, view, getPos, eventDispatcher
|
|
6
|
+
constructor(node, view, getPos, eventDispatcher) {
|
|
9
7
|
super(node, view, getPos, eventDispatcher);
|
|
10
|
-
this.observer = observer;
|
|
11
|
-
const {
|
|
12
|
-
pluginConfig,
|
|
13
|
-
isDragAndDropEnabled
|
|
14
|
-
} = getPluginState(view.state);
|
|
15
|
-
this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
16
|
-
this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
17
|
-
if (observer) {
|
|
18
|
-
this.contentDOM.id = uuid();
|
|
19
|
-
observer.observe(this.contentDOM);
|
|
20
|
-
}
|
|
21
8
|
}
|
|
22
|
-
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
|
|
27
9
|
update(node) {
|
|
28
10
|
const didUpdate = this.updateNodeView(node);
|
|
29
11
|
if (didUpdate) {
|
|
@@ -31,11 +13,6 @@ export default class TableCell extends TableNodeView {
|
|
|
31
13
|
}
|
|
32
14
|
return didUpdate;
|
|
33
15
|
}
|
|
34
|
-
destroy() {
|
|
35
|
-
if (this.observer) {
|
|
36
|
-
this.observer.unobserve(this.contentDOM);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
16
|
updateNodeView(node) {
|
|
40
17
|
if (this.node.type !== node.type) {
|
|
41
18
|
return false;
|