@atlaskit/editor-plugin-table 8.4.14 → 9.0.1
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 +23 -0
- package/dist/cjs/nodeviews/TableRow.js +24 -14
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +9 -84
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -144
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +1 -2
- package/dist/cjs/pm-plugins/view-mode-sort/utils.js +3 -0
- package/dist/cjs/tablePlugin.js +3 -5
- package/dist/cjs/ui/DragPreview/index.js +1 -0
- package/dist/cjs/ui/FloatingContextualButton/index.js +1 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +2 -4
- package/dist/cjs/ui/TableFullWidthLabel/index.js +1 -0
- package/dist/cjs/ui/event-handlers.js +18 -7
- package/dist/cjs/ui/toolbar.js +1 -4
- package/dist/es2019/nodeviews/TableContainer.js +1 -1
- package/dist/es2019/nodeviews/TableRow.js +24 -14
- package/dist/es2019/pm-plugins/commands/column-resize.js +1 -1
- package/dist/es2019/pm-plugins/commands/insert.js +3 -3
- package/dist/es2019/pm-plugins/commands/misc.js +1 -1
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +1 -1
- package/dist/es2019/pm-plugins/table-analytics.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +12 -84
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +2 -139
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +1 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +1 -1
- package/dist/es2019/pm-plugins/transforms/delete-columns.js +1 -1
- package/dist/es2019/pm-plugins/transforms/fix-tables.js +1 -1
- package/dist/es2019/pm-plugins/transforms/replace-table.js +1 -1
- package/dist/es2019/pm-plugins/transforms/split.js +2 -2
- package/dist/es2019/pm-plugins/utils/analytics.js +4 -4
- package/dist/es2019/pm-plugins/utils/column-controls.js +1 -1
- package/dist/es2019/pm-plugins/utils/drag-menu.js +1 -1
- package/dist/es2019/pm-plugins/utils/merged-cells.js +4 -4
- package/dist/es2019/pm-plugins/utils/nodes.js +3 -3
- package/dist/es2019/pm-plugins/utils/row-controls.js +2 -2
- package/dist/es2019/pm-plugins/view-mode-sort/index.js +2 -2
- package/dist/es2019/pm-plugins/view-mode-sort/utils.js +4 -1
- package/dist/es2019/tablePlugin.js +3 -5
- package/dist/es2019/ui/DragPreview/index.js +4 -3
- package/dist/es2019/ui/FloatingContextualButton/index.js +1 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +4 -4
- package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +2 -2
- package/dist/es2019/ui/TableFullWidthLabel/index.js +1 -0
- package/dist/es2019/ui/event-handlers.js +12 -1
- package/dist/es2019/ui/toolbar.js +1 -4
- package/dist/esm/nodeviews/TableRow.js +24 -14
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +11 -85
- package/dist/esm/pm-plugins/table-resizing/plugin.js +2 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +2 -143
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +1 -2
- package/dist/esm/pm-plugins/view-mode-sort/utils.js +3 -0
- package/dist/esm/tablePlugin.js +3 -5
- package/dist/esm/ui/DragPreview/index.js +1 -0
- package/dist/esm/ui/FloatingContextualButton/index.js +1 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +2 -4
- package/dist/esm/ui/TableFullWidthLabel/index.js +1 -0
- package/dist/esm/ui/event-handlers.js +12 -1
- package/dist/esm/ui/toolbar.js +1 -4
- package/dist/types/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/plugin.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +0 -24
- package/dist/types/tablePluginType.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/plugin.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +0 -24
- package/dist/types-ts4.5/tablePluginType.d.ts +0 -1
- package/package.json +5 -5
- package/src/nodeviews/TableComponent.tsx +1 -1
- package/src/nodeviews/TableContainer.tsx +1 -1
- package/src/nodeviews/TableRow.ts +34 -14
- package/src/pm-plugins/commands/column-resize.ts +1 -1
- package/src/pm-plugins/commands/hover.ts +2 -2
- package/src/pm-plugins/commands/insert.ts +3 -3
- package/src/pm-plugins/commands/misc.ts +1 -1
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +1 -1
- package/src/pm-plugins/drag-and-drop/commands.ts +6 -2
- package/src/pm-plugins/table-analytics.ts +1 -1
- package/src/pm-plugins/table-resizing/event-handlers.ts +35 -121
- package/src/pm-plugins/table-resizing/plugin.ts +0 -4
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +1 -219
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +1 -1
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +1 -3
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +1 -1
- package/src/pm-plugins/transforms/column-width.ts +1 -1
- package/src/pm-plugins/transforms/delete-columns.ts +1 -1
- package/src/pm-plugins/transforms/fix-tables.ts +1 -1
- package/src/pm-plugins/transforms/replace-table.ts +1 -1
- package/src/pm-plugins/transforms/split.ts +2 -2
- package/src/pm-plugins/utils/analytics.ts +4 -4
- package/src/pm-plugins/utils/column-controls.ts +1 -1
- package/src/pm-plugins/utils/drag-menu.ts +1 -1
- package/src/pm-plugins/utils/merged-cells.ts +4 -4
- package/src/pm-plugins/utils/nodes.ts +3 -3
- package/src/pm-plugins/utils/row-controls.ts +2 -2
- package/src/pm-plugins/view-mode-sort/index.ts +2 -2
- package/src/pm-plugins/view-mode-sort/utils.ts +3 -1
- package/src/tablePlugin.tsx +3 -10
- package/src/tablePluginType.ts +0 -1
- package/src/ui/DragPreview/index.tsx +4 -3
- package/src/ui/FloatingContextualButton/index.tsx +1 -2
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +4 -6
- package/src/ui/FloatingDragMenu/DragMenu.tsx +4 -4
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -1
- package/src/ui/TableFloatingColumnControls/index.tsx +1 -1
- package/src/ui/TableFullWidthLabel/index.tsx +1 -0
- package/src/ui/event-handlers.ts +19 -1
- package/src/ui/toolbar.tsx +1 -11
- package/tsconfig.app.json +0 -1
- package/tsconfig.dev.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 9.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#98104](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98104)
|
|
8
|
+
[`7c7c2dc094742`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7c7c2dc094742) -
|
|
9
|
+
[ux] [ED-25529] This change adds padding to nested tables when active, to allow space for the row
|
|
10
|
+
and column controls. It also prevents the Insert Row/ Insert Column buttons from being hidden too
|
|
11
|
+
early.
|
|
12
|
+
|
|
13
|
+
## 9.0.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- [#98966](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98966)
|
|
18
|
+
[`5c8e4c2ce26bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c8e4c2ce26bf) -
|
|
19
|
+
Remove platform_editor_table_new_column_resizing experiment, remove options and all logic inside
|
|
20
|
+
editor-plugin-table and remove it from feature flag plugin config.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 8.4.14
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -413,6 +413,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
413
413
|
}, {
|
|
414
414
|
key: "onTablePluginState",
|
|
415
415
|
value: function onTablePluginState(state) {
|
|
416
|
+
var _parentContainer$pare, _parentContainer$pare2;
|
|
416
417
|
var tableRef = state.tableRef;
|
|
417
418
|
var tree = (0, _dom2.getTree)(this.dom);
|
|
418
419
|
if (!tree) {
|
|
@@ -437,22 +438,31 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
437
438
|
var wrapper = tree.wrapper;
|
|
438
439
|
var tableContainer = wrapper.parentElement;
|
|
439
440
|
var tableContentWrapper = tableContainer === null || tableContainer === void 0 ? void 0 : tableContainer.parentElement;
|
|
440
|
-
var
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
441
|
+
var parentContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
442
|
+
var isTableInsideLayout = parentContainer && parentContainer.getAttribute('data-layout-content');
|
|
443
|
+
var isNestedTable = parentContainer && (parentContainer.className === 'pm-table-header-content-wrap' || parentContainer.className === 'pm-table-cell-content-wrap');
|
|
444
|
+
var isNestedDataTable = parentContainer && parentContainer.getAttribute('data-mark-type') === 'fragment' && (((_parentContainer$pare = parentContainer.parentElement) === null || _parentContainer$pare === void 0 ? void 0 : _parentContainer$pare.className) === 'pm-table-header-content-wrap' || ((_parentContainer$pare2 = parentContainer.parentElement) === null || _parentContainer$pare2 === void 0 ? void 0 : _parentContainer$pare2.className) === 'pm-table-cell-content-wrap');
|
|
445
|
+
var isTableInsideTable = isNestedTable || isNestedDataTable;
|
|
446
|
+
if (tableContentWrapper) {
|
|
447
|
+
if (isCurrentTableSelected) {
|
|
448
|
+
this.colControlsOffset = _consts.tableControlsSpacing;
|
|
449
|
+
|
|
444
450
|
// move table a little out of the way
|
|
445
451
|
// to provide spacing for table controls
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
452
|
+
if (isTableInsideLayout) {
|
|
453
|
+
tableContentWrapper.style.paddingLeft = '11px';
|
|
454
|
+
} else if (isTableInsideTable) {
|
|
455
|
+
tableContentWrapper.style.paddingLeft = '15px';
|
|
456
|
+
tableContentWrapper.style.paddingRight = '4px';
|
|
457
|
+
}
|
|
458
|
+
} else {
|
|
459
|
+
this.colControlsOffset = 0;
|
|
460
|
+
if (isTableInsideLayout) {
|
|
461
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
462
|
+
} else if (isTableInsideTable) {
|
|
463
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
464
|
+
tableContentWrapper.style.removeProperty('padding-right');
|
|
465
|
+
}
|
|
456
466
|
}
|
|
457
467
|
}
|
|
458
468
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.handleMouseDown = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
8
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
@@ -15,8 +13,6 @@ var _misc = require("../commands/misc");
|
|
|
15
13
|
var _pluginFactory = require("../plugin-factory");
|
|
16
14
|
var _tableAnalytics = require("../table-analytics");
|
|
17
15
|
var _columnWidth = require("../transforms/column-width");
|
|
18
|
-
var _alignment = require("../utils/alignment");
|
|
19
|
-
var _nodes = require("../utils/nodes");
|
|
20
16
|
var _selection = require("../utils/selection");
|
|
21
17
|
var _commands = require("./commands");
|
|
22
18
|
var _pluginFactory2 = require("./plugin-factory");
|
|
@@ -25,9 +21,7 @@ var _dom = require("./utils/dom");
|
|
|
25
21
|
var _misc2 = require("./utils/misc");
|
|
26
22
|
var _resizeColumn = require("./utils/resize-column");
|
|
27
23
|
var _resizeState = require("./utils/resize-state");
|
|
28
|
-
|
|
29
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
-
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isNewColumnResizingEnabled, isTableAlignmentEnabled, isCommentEditor
|
|
24
|
+
var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isCommentEditor
|
|
31
25
|
// Ignored via go/ees005
|
|
32
26
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
33
27
|
) {
|
|
@@ -37,7 +31,6 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
37
31
|
var editorDisabled = !view.editable;
|
|
38
32
|
var domAtPos = view.domAtPos.bind(view);
|
|
39
33
|
var _getEditorContainerWi = getEditorContainerWidth(),
|
|
40
|
-
lineLength = _getEditorContainerWi.lineLength,
|
|
41
34
|
editorWidth = _getEditorContainerWi.width;
|
|
42
35
|
if (editorDisabled || localResizeHandlePos === null || !(0, _misc2.pointsAtCell)(state.doc.resolve(localResizeHandlePos))) {
|
|
43
36
|
return false;
|
|
@@ -119,18 +112,6 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
119
112
|
// When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
|
|
120
113
|
// unnecessary tooltips being displayed during drag.
|
|
121
114
|
(0, _misc.updateResizeHandleDecorations)(nodeViewPortalProviderAPI, undefined, undefined, false)(state, dispatch);
|
|
122
|
-
|
|
123
|
-
// for new column resizing, take the current scaled version of table widths and use those as the basis for resizing
|
|
124
|
-
// implication: the scaled version of the table becomes the source of truth
|
|
125
|
-
if (isNewColumnResizingEnabled && shouldScale) {
|
|
126
|
-
resizeState = (0, _resizeColumn.scaleResizeState)({
|
|
127
|
-
resizeState: resizeState,
|
|
128
|
-
tableRef: dom,
|
|
129
|
-
tableNode: originalTable,
|
|
130
|
-
editorWidth: editorWidth,
|
|
131
|
-
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
115
|
function finish(event) {
|
|
135
116
|
// Ignored via go/ees005
|
|
136
117
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -179,9 +160,8 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
179
160
|
// For example, if a table col is deleted we won't be able to reliably remap the new widths
|
|
180
161
|
// There may be a more elegant solution to this, to avoid a jarring experience.
|
|
181
162
|
if (table.eq(originalTable)) {
|
|
163
|
+
var _table$attrs;
|
|
182
164
|
var map = _tableMap.TableMap.get(table);
|
|
183
|
-
var totalRowCount = map.height;
|
|
184
|
-
var totalColumnCount = map.width;
|
|
185
165
|
var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
186
166
|
var selectionRect = (0, _utils.getSelectionRect)(state.selection);
|
|
187
167
|
var selectedColumns = selectionRect ? (0, _selection.getSelectedColumnIndexes)(selectionRect) : [];
|
|
@@ -193,50 +173,9 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
193
173
|
}
|
|
194
174
|
var resizedDelta = clientX - startX;
|
|
195
175
|
var _shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || isTableScalingEnabled && !!isCommentEditor;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
colIndex: colIndex,
|
|
200
|
-
amount: resizedDelta,
|
|
201
|
-
tableRef: dom,
|
|
202
|
-
tableNode: originalTable,
|
|
203
|
-
width: editorWidth,
|
|
204
|
-
lineLength: lineLength,
|
|
205
|
-
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
206
|
-
});
|
|
207
|
-
tr = (0, _columnWidth.updateColumnWidths)(newResizeState, table, start, api)(tr);
|
|
208
|
-
|
|
209
|
-
// If the table is aligned to the start and the table width is greater than the line length, we should change the alignment to center
|
|
210
|
-
var shouldChangeAlignment = (0, _alignment.shouldChangeAlignmentToCenterResized)(isTableAlignmentEnabled, originalTable, lineLength, newResizeState.maxSize);
|
|
211
|
-
if (shouldChangeAlignment) {
|
|
212
|
-
tr = tr.setNodeMarkup(start - 1, state.schema.nodes.table, _objectSpread(_objectSpread({}, table.attrs), {}, {
|
|
213
|
-
width: newResizeState.maxSize,
|
|
214
|
-
layout: _alignment.ALIGN_CENTER
|
|
215
|
-
}));
|
|
216
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
217
|
-
action: _analytics.TABLE_ACTION.CHANGED_ALIGNMENT,
|
|
218
|
-
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
219
|
-
actionSubjectId: null,
|
|
220
|
-
attributes: {
|
|
221
|
-
tableWidth: newResizeState.maxSize,
|
|
222
|
-
newAlignment: _alignment.ALIGN_CENTER,
|
|
223
|
-
previousAlignment: _alignment.ALIGN_START,
|
|
224
|
-
totalRowCount: totalRowCount,
|
|
225
|
-
totalColumnCount: totalColumnCount,
|
|
226
|
-
inputMethod: _analytics.INPUT_METHOD.AUTO,
|
|
227
|
-
reason: _analytics.CHANGE_ALIGNMENT_REASON.TABLE_COLUMN_RESIZED
|
|
228
|
-
},
|
|
229
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
230
|
-
})(tr);
|
|
231
|
-
} else {
|
|
232
|
-
tr.setNodeAttribute(start - 1, 'width', newResizeState.maxSize);
|
|
233
|
-
}
|
|
234
|
-
} else {
|
|
235
|
-
var _table$attrs;
|
|
236
|
-
var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs = table.attrs) !== null && _table$attrs !== void 0 && _table$attrs.width) ? (0, _misc2.getScalingPercentForTableWithoutWidth)(originalTable, dom) : (0, _misc2.getTableScalingPercent)(originalTable, dom, _shouldUseIncreasedScalingPercent);
|
|
237
|
-
var _newResizeState = (0, _resizeColumn.resizeColumn)(resizeState, colIndex, resizedDelta, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale, scalePercent);
|
|
238
|
-
tr = (0, _columnWidth.updateColumnWidths)(_newResizeState, table, start, api)(tr);
|
|
239
|
-
}
|
|
176
|
+
var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs = table.attrs) !== null && _table$attrs !== void 0 && _table$attrs.width) ? (0, _misc2.getScalingPercentForTableWithoutWidth)(originalTable, dom) : (0, _misc2.getTableScalingPercent)(originalTable, dom, _shouldUseIncreasedScalingPercent);
|
|
177
|
+
var newResizeState = (0, _resizeColumn.resizeColumn)(resizeState, colIndex, resizedDelta, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale, scalePercent);
|
|
178
|
+
tr = (0, _columnWidth.updateColumnWidths)(newResizeState, table, start, api)(tr);
|
|
240
179
|
if (colIndex === map.width - 1) {
|
|
241
180
|
var mouseUpTime = event.timeStamp;
|
|
242
181
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -280,6 +219,7 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
280
219
|
}
|
|
281
220
|
}
|
|
282
221
|
function move(event) {
|
|
222
|
+
var _table$attrs2;
|
|
283
223
|
var clientX = event.clientX,
|
|
284
224
|
which = event.which;
|
|
285
225
|
var state = view.state;
|
|
@@ -289,12 +229,11 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
289
229
|
var _getTablePluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
290
230
|
isTableHovered = _getTablePluginState3.isTableHovered;
|
|
291
231
|
var tablePos = state.doc.resolve(start).start(-1);
|
|
292
|
-
if (!which || !dragging || resizeHandlePos === null || !(0, _misc2.pointsAtCell)(state.doc.resolve(resizeHandlePos)) ||
|
|
232
|
+
if (!which || !dragging || resizeHandlePos === null || !(0, _misc2.pointsAtCell)(state.doc.resolve(resizeHandlePos)) || !isTableHovered) {
|
|
293
233
|
return finish(event);
|
|
294
234
|
}
|
|
295
235
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
296
236
|
var table = $cell.node(-1);
|
|
297
|
-
// const tablePos = state.doc.resolve(start).start(-1);
|
|
298
237
|
var tableDepth = state.doc.resolve(tablePos).depth;
|
|
299
238
|
var map = _tableMap.TableMap.get(table);
|
|
300
239
|
// Ignored via go/ees005
|
|
@@ -306,22 +245,8 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
306
245
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
307
246
|
}
|
|
308
247
|
var resizedDelta = clientX - dragging.startX;
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
resizeState: resizeState,
|
|
312
|
-
colIndex: colIndex,
|
|
313
|
-
amount: resizedDelta,
|
|
314
|
-
tableRef: dom,
|
|
315
|
-
tableNode: originalTable,
|
|
316
|
-
width: editorWidth,
|
|
317
|
-
lineLength: lineLength,
|
|
318
|
-
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
319
|
-
});
|
|
320
|
-
} else {
|
|
321
|
-
var _table$attrs2;
|
|
322
|
-
var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs2 = table.attrs) !== null && _table$attrs2 !== void 0 && _table$attrs2.width) ? (0, _misc2.getScalingPercentForTableWithoutWidth)(table, dom) : (0, _misc2.getTableScalingPercent)(originalTable, dom, shouldUseIncreasedScalingPercent);
|
|
323
|
-
(0, _resizeColumn.resizeColumn)(resizeState, colIndex, resizedDelta, dom, table, undefined, shouldScale, scalePercent);
|
|
324
|
-
}
|
|
248
|
+
var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs2 = table.attrs) !== null && _table$attrs2 !== void 0 && _table$attrs2.width) ? (0, _misc2.getScalingPercentForTableWithoutWidth)(table, dom) : (0, _misc2.getTableScalingPercent)(originalTable, dom, shouldUseIncreasedScalingPercent);
|
|
249
|
+
(0, _resizeColumn.resizeColumn)(resizeState, colIndex, resizedDelta, dom, table, undefined, shouldScale, scalePercent);
|
|
325
250
|
(0, _dom.updateControls)()(state);
|
|
326
251
|
}
|
|
327
252
|
|
|
@@ -17,7 +17,7 @@ var _pluginKey = require("./plugin-key");
|
|
|
17
17
|
var _dom = require("./utils/dom");
|
|
18
18
|
// Ignored via go/ees005
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
20
|
-
function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled,
|
|
20
|
+
function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled, isCommentEditor) {
|
|
21
21
|
var _ref$lastColumnResiza = _ref.lastColumnResizable,
|
|
22
22
|
lastColumnResizable = _ref$lastColumnResiza === void 0 ? true : _ref$lastColumnResiza;
|
|
23
23
|
return new _safePlugin.SafePlugin({
|
|
@@ -54,7 +54,7 @@ function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureF
|
|
|
54
54
|
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
55
55
|
}
|
|
56
56
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
|
57
|
-
if ((0, _eventHandlers.handleMouseDown)(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, api, nodeViewPortalProviderAPI, editorAnalyticsAPI,
|
|
57
|
+
if ((0, _eventHandlers.handleMouseDown)(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isCommentEditor)) {
|
|
58
58
|
var _state = view.state,
|
|
59
59
|
_dispatch = view.dispatch;
|
|
60
60
|
return (0, _commands.setResizeHandlePos)(resizeHandlePos)(_state, _dispatch);
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
|
-
var _types = require("../../../types");
|
|
12
|
-
var _alignment = require("../../utils/alignment");
|
|
13
|
-
var _misc = require("./misc");
|
|
6
|
+
exports.resizeColumn = void 0;
|
|
14
7
|
var _resizeLogic = require("./resize-logic");
|
|
15
8
|
var _resizeState = require("./resize-state");
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
// Resize a given column by an amount from the current state
|
|
10
|
+
|
|
18
11
|
var resizeColumn = exports.resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
|
|
19
12
|
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
20
13
|
var scalePercent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1;
|
|
@@ -25,138 +18,4 @@ var resizeColumn = exports.resizeColumn = function resizeColumn(resizeState, col
|
|
|
25
18
|
var newState = resizeAmount > 0 ? (0, _resizeLogic.growColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? (0, _resizeLogic.shrinkColumn)(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
26
19
|
(0, _resizeState.updateColgroup)(newState, tableRef, tableNode, isTableScalingEnabled, scalePercent);
|
|
27
20
|
return newState;
|
|
28
|
-
};
|
|
29
|
-
var resizeColumnAndTable = exports.resizeColumnAndTable = function resizeColumnAndTable(_ref) {
|
|
30
|
-
var resizeState = _ref.resizeState,
|
|
31
|
-
colIndex = _ref.colIndex,
|
|
32
|
-
amount = _ref.amount,
|
|
33
|
-
tableRef = _ref.tableRef,
|
|
34
|
-
tableNode = _ref.tableNode,
|
|
35
|
-
lineLength = _ref.lineLength,
|
|
36
|
-
editorWidth = _ref.width,
|
|
37
|
-
isTableAlignmentEnabled = _ref.isTableAlignmentEnabled;
|
|
38
|
-
var editorContainerWidth = getEditorContainerWidth(editorWidth);
|
|
39
|
-
var isTableLeftAligned = tableNode.attrs.layout === _alignment.ALIGN_START;
|
|
40
|
-
var isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
41
|
-
var isOverflow = resizeState.tableWidth > resizeState.maxSize;
|
|
42
|
-
var resizeAmount = isTableLeftAligned ? amount : amount * 2;
|
|
43
|
-
var willTableHitEditorEdge = resizeState.maxSize + resizeAmount > editorContainerWidth;
|
|
44
|
-
var willResizedTableStayInOverflow = isOverflow && resizeState.tableWidth + resizeAmount / 2 > resizeState.maxSize;
|
|
45
|
-
|
|
46
|
-
// STEP 1: Update col width
|
|
47
|
-
if (willTableHitEditorEdge || willResizedTableStayInOverflow) {
|
|
48
|
-
var _tableRef$closest;
|
|
49
|
-
var tableContainerWidth = (_tableRef$closest = tableRef.closest('.pm-table-container')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
50
|
-
resizeAmount = amount < 0 ? amount :
|
|
51
|
-
// Ignored via go/ees005
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
|
-
resizeAmount - (resizeState.maxSize + resizeAmount - tableContainerWidth) / 2;
|
|
54
|
-
} else {
|
|
55
|
-
var diff = -(resizeState.tableWidth - resizeState.maxSize);
|
|
56
|
-
var rest = amount - diff;
|
|
57
|
-
var final = isTableLeftAligned ? diff + rest : diff + rest * 2;
|
|
58
|
-
resizeAmount = final;
|
|
59
|
-
}
|
|
60
|
-
var newState = (0, _resizeLogic.updateAffectedColumn)(resizeState, colIndex, resizeAmount);
|
|
61
|
-
|
|
62
|
-
// STEP 2: Update table container width
|
|
63
|
-
// columns have a min width, so delta !== resizeAmount when this is reached, use this for calculations
|
|
64
|
-
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
65
|
-
newState.maxSize = Math.round(isOverflow ? willResizedTableStayInOverflow ?
|
|
66
|
-
// CASE 1A: table will stay in overflow
|
|
67
|
-
// do not grow the table because resize is happening in the overflow region
|
|
68
|
-
// and the overall table container needs to be retained
|
|
69
|
-
isNumberColumnEnabled ? resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth : resizeState.maxSize :
|
|
70
|
-
// CASE 1B: table will no longer be in overflow, so adjust container width
|
|
71
|
-
// ensure the table is resized without any 'big jumps' by working out
|
|
72
|
-
// the difference between the new table width and the max size and adding the resize
|
|
73
|
-
isNumberColumnEnabled ? resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth + (resizeState.tableWidth - resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth + delta) : resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta) : willTableHitEditorEdge ?
|
|
74
|
-
// CASE 2: table will hit editor edge
|
|
75
|
-
editorContainerWidth :
|
|
76
|
-
// CASE 3: table is being resized from a non-overflow state
|
|
77
|
-
isNumberColumnEnabled ? resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth + delta : resizeState.maxSize + delta);
|
|
78
|
-
|
|
79
|
-
// do not apply scaling logic because resize state is already scaled
|
|
80
|
-
(0, _resizeState.updateColgroup)(newState, tableRef, tableNode, false, 1);
|
|
81
|
-
updateTablePreview(tableRef, newState.maxSize, (0, _alignment.shouldChangeAlignmentToCenterResized)(isTableAlignmentEnabled, tableNode, lineLength, newState.maxSize));
|
|
82
|
-
return newState;
|
|
83
|
-
};
|
|
84
|
-
var updateTablePreview = function updateTablePreview(tableRef, newTableWidth, shouldChangeAlignment) {
|
|
85
|
-
var resizingContainer = tableRef.closest(".".concat(_types.TableCssClassName.TABLE_RESIZER_CONTAINER));
|
|
86
|
-
var resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
87
|
-
var alignmentContainer = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.parentElement;
|
|
88
|
-
if (resizingItem) {
|
|
89
|
-
var newWidth = "".concat(newTableWidth, "px");
|
|
90
|
-
// Ignored via go/ees005
|
|
91
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
92
|
-
resizingContainer.style.width = newWidth;
|
|
93
|
-
// Ignored via go/ees005
|
|
94
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
95
|
-
resizingItem.style.width = newWidth;
|
|
96
|
-
if (shouldChangeAlignment && alignmentContainer) {
|
|
97
|
-
alignmentContainer.style.justifyContent = _alignment.ALIGN_CENTER;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var getEditorContainerWidth = function getEditorContainerWidth(editorWidth) {
|
|
102
|
-
return Math.min(editorWidth - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2, _editorSharedStyles.akEditorFullWidthLayoutWidth);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Apply a scaling factor to resize state
|
|
107
|
-
*/
|
|
108
|
-
var scaleResizeState = exports.scaleResizeState = function scaleResizeState(_ref2) {
|
|
109
|
-
var resizeState = _ref2.resizeState,
|
|
110
|
-
tableRef = _ref2.tableRef,
|
|
111
|
-
tableNode = _ref2.tableNode,
|
|
112
|
-
editorWidth = _ref2.editorWidth,
|
|
113
|
-
shouldUseIncreasedScalingPercent = _ref2.shouldUseIncreasedScalingPercent;
|
|
114
|
-
var isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
115
|
-
var isTableScaled = isNumberColumnEnabled || resizeState.maxSize > getEditorContainerWidth(editorWidth);
|
|
116
|
-
|
|
117
|
-
// Tables with number column can cause the table to be in two different states:
|
|
118
|
-
// 1. The table sum of col widths will be smaller than the max size, which is incorrect. For this
|
|
119
|
-
// avoid scaling and take the document width
|
|
120
|
-
// 2. The table sum of col widths will be the same size as max width, which happens when the table
|
|
121
|
-
// is scaled using preserve table width logic, for this apply a scaled width
|
|
122
|
-
// return early if table isn't scaled
|
|
123
|
-
if (!isTableScaled || isNumberColumnEnabled && resizeState.maxSize > resizeState.tableWidth) {
|
|
124
|
-
return resizeState;
|
|
125
|
-
}
|
|
126
|
-
var scalePercent = (0, _misc.getTableScalingPercent)(tableNode, tableRef, shouldUseIncreasedScalingPercent);
|
|
127
|
-
var scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
|
|
128
|
-
var cols = resizeState.cols.map(function (col) {
|
|
129
|
-
return _objectSpread(_objectSpread({}, col), {}, {
|
|
130
|
-
minWidth: _styles.tableCellMinWidth,
|
|
131
|
-
width: Math.max(Math.round(col.width * scalePercent), _styles.tableCellMinWidth)
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
var calculatedTableWidth = cols.reduce(function (prev, curr) {
|
|
135
|
-
return prev + curr.width;
|
|
136
|
-
}, 0);
|
|
137
|
-
|
|
138
|
-
// using Math.round can cause the sum of col widths to be larger than the table width
|
|
139
|
-
// distribute the difference to the first column
|
|
140
|
-
if (calculatedTableWidth > scaledTableWidth) {
|
|
141
|
-
var diff = calculatedTableWidth - scaledTableWidth;
|
|
142
|
-
var hasDiffBeenDistributed = false;
|
|
143
|
-
cols = cols.map(function (col) {
|
|
144
|
-
if (!hasDiffBeenDistributed && col.width - diff >= col.minWidth) {
|
|
145
|
-
hasDiffBeenDistributed = true;
|
|
146
|
-
return _objectSpread(_objectSpread({}, col), {}, {
|
|
147
|
-
width: col.width - diff
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return col;
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
var maxSize = isNumberColumnEnabled ? Math.round((resizeState.maxSize + _editorSharedStyles.akEditorTableNumberColumnWidth) * scalePercent) : Math.round(resizeState.maxSize * scalePercent);
|
|
154
|
-
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
155
|
-
widths: cols.map(function (col) {
|
|
156
|
-
return col.width;
|
|
157
|
-
}),
|
|
158
|
-
tableWidth: scaledTableWidth,
|
|
159
|
-
maxSize: maxSize,
|
|
160
|
-
cols: cols
|
|
161
|
-
});
|
|
162
21
|
};
|
|
@@ -339,7 +339,6 @@ var getNewResizeStateFromSelectedColumns = exports.getNewResizeStateFromSelected
|
|
|
339
339
|
layout: layout,
|
|
340
340
|
getEditorContainerWidth: getEditorContainerWidth
|
|
341
341
|
});
|
|
342
|
-
var resizeState;
|
|
343
342
|
var isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
344
343
|
var isTableScalingWithFixedColumnWidthsOptionEnabled = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled;
|
|
345
344
|
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
@@ -350,7 +349,7 @@ var getNewResizeStateFromSelectedColumns = exports.getNewResizeStateFromSelected
|
|
|
350
349
|
isTableScalingEnabledOnCurrentTable = true;
|
|
351
350
|
shouldUseIncreasedScalingPercent = true;
|
|
352
351
|
}
|
|
353
|
-
resizeState = getResizeState({
|
|
352
|
+
var resizeState = getResizeState({
|
|
354
353
|
minWidth: _styles.tableCellMinWidth,
|
|
355
354
|
maxSize: maxSize,
|
|
356
355
|
table: table.node,
|
|
@@ -74,6 +74,9 @@ var toggleSort = exports.toggleSort = function toggleSort(view, event, pluginSta
|
|
|
74
74
|
if (!tableId || !tableNode || (tableNode === null || tableNode === void 0 || (_tableNode$type = tableNode.type) === null || _tableNode$type === void 0 ? void 0 : _tableNode$type.name) !== 'table') {
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
// Ignored via go/ees005
|
|
79
|
+
// eslint-disable-next-line prefer-const
|
|
77
80
|
var _ref = (pluginState === null || pluginState === void 0 ? void 0 : pluginState[tableId]) || {},
|
|
78
81
|
index = _ref.index,
|
|
79
82
|
direction = _ref.direction,
|
package/dist/cjs/tablePlugin.js
CHANGED
|
@@ -253,14 +253,12 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
253
253
|
fullWidthEnabled = _ref5.fullWidthEnabled,
|
|
254
254
|
tableOptions = _ref5.tableOptions,
|
|
255
255
|
getEditorFeatureFlags = _ref5.getEditorFeatureFlags,
|
|
256
|
-
isTableScalingEnabled = _ref5.isTableScalingEnabled
|
|
257
|
-
isNewColumnResizingEnabled = _ref5.isNewColumnResizingEnabled;
|
|
256
|
+
isTableScalingEnabled = _ref5.isTableScalingEnabled;
|
|
258
257
|
var _pluginConfig2 = (0, _createPluginConfig.pluginConfig)(tableOptions),
|
|
259
|
-
allowColumnResizing = _pluginConfig2.allowColumnResizing
|
|
260
|
-
allowTableAlignment = _pluginConfig2.allowTableAlignment;
|
|
258
|
+
allowColumnResizing = _pluginConfig2.allowColumnResizing;
|
|
261
259
|
return allowColumnResizing ? (0, _plugin5.createPlugin)(dispatch, {
|
|
262
260
|
lastColumnResizable: !fullWidthEnabled
|
|
263
|
-
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false,
|
|
261
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false, !!(options !== null && options !== void 0 && options.isCommentEditor)) : undefined;
|
|
264
262
|
}
|
|
265
263
|
}, {
|
|
266
264
|
name: 'tableEditing',
|
|
@@ -36,6 +36,7 @@ var DragPreview = exports.DragPreview = function DragPreview(_ref) {
|
|
|
36
36
|
marginLeft: "".concat(marginLeft, "px"),
|
|
37
37
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
38
38
|
marginTop: "".concat(marginTop, "px"),
|
|
39
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
39
40
|
transform: transform
|
|
40
41
|
}
|
|
41
42
|
}));
|
|
@@ -59,8 +59,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
62
|
-
var targetCellRef;
|
|
63
|
-
targetCellRef = (0, _utils.findDomRefAtPos)(targetCellPosition, domAtPos);
|
|
62
|
+
var targetCellRef = (0, _utils.findDomRefAtPos)(targetCellPosition, domAtPos);
|
|
64
63
|
(0, _react.useEffect)(function () {
|
|
65
64
|
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
66
65
|
var state = editorView.state,
|
|
@@ -112,14 +112,12 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
112
112
|
var _node$attrs, _node$attrs2;
|
|
113
113
|
var node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
114
114
|
var background = (0, _editorPalette.hexToEditorBackgroundPaletteColor)((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
115
|
-
var selectedRowIndex;
|
|
116
|
-
var selectedColumnIndex;
|
|
117
115
|
var selectedRowAndColumnFromPalette = (0, _uiColor.getSelectedRowAndColumnFromPalette)(_uiColor.cellBackgroundColorPalette,
|
|
118
116
|
// Ignored via go/ees005
|
|
119
117
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
120
118
|
background, _consts.colorPalletteColumns);
|
|
121
|
-
selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
122
|
-
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
119
|
+
var selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
120
|
+
var selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
123
121
|
return {
|
|
124
122
|
content: isDragAndDropEnabled ? formatMessage(_messages.tableMessages.backgroundColor) : formatMessage(_messages.tableMessages.cellBackground),
|
|
125
123
|
value: {
|
|
@@ -15,6 +15,7 @@ var tableFullWidthLabelWrapperStyles = (0, _primitives.xcss)({
|
|
|
15
15
|
backgroundColor: 'elevation.surface.overlay',
|
|
16
16
|
borderRadius: 'border.radius',
|
|
17
17
|
boxShadow: 'elevation.shadow.overlay',
|
|
18
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
18
19
|
lineHeight: 1,
|
|
19
20
|
boxSizing: 'border-box',
|
|
20
21
|
alignItems: 'center'
|
|
@@ -10,11 +10,13 @@ exports.withCellTracking = exports.whenTableInFocus = exports.isTableInFocus = v
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
13
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
15
|
var _state5 = require("@atlaskit/editor-prosemirror/state");
|
|
16
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
17
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
16
18
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
17
|
-
var
|
|
19
|
+
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
18
20
|
var _commands = require("../pm-plugins/commands");
|
|
19
21
|
var _pluginFactory = require("../pm-plugins/drag-and-drop/plugin-factory");
|
|
20
22
|
var _pluginFactory2 = require("../pm-plugins/plugin-factory");
|
|
@@ -66,7 +68,7 @@ var handleClick = exports.handleClick = function handleClick(view, event) {
|
|
|
66
68
|
var element = event.target;
|
|
67
69
|
// Ignored via go/ees005
|
|
68
70
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
|
-
var table = (0,
|
|
71
|
+
var table = (0, _utils3.findTable)(view.state.selection);
|
|
70
72
|
|
|
71
73
|
// Ignored via go/ees005
|
|
72
74
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -149,7 +151,16 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, m
|
|
|
149
151
|
_dispatch2 = view.dispatch;
|
|
150
152
|
return (0, _commands.hoverColumns)([_startIndex], false)(_state, _dispatch2);
|
|
151
153
|
}
|
|
152
|
-
|
|
154
|
+
var isNestedTable = (0, _nesting.getParentOfTypeCount)(state.schema.nodes.table)(state.selection.$from) > 1;
|
|
155
|
+
if (isNestedTable) {
|
|
156
|
+
// if the table is nested inside a table, we only call hideInsertColumnOrRowButton if the table nearest to the mouse target is NOT the parent table
|
|
157
|
+
var nearestTable = (0, _utils.closestElement)(target, 'table');
|
|
158
|
+
var nestedTable = (0, _utils2.findParentNodeOfTypeClosestToPos)(state.doc.resolve(state.selection.from), [state.schema.nodes.table]);
|
|
159
|
+
var parentTable = (0, _utils2.findParentNodeOfTypeClosestToPos)(state.doc.resolve((nestedTable === null || nestedTable === void 0 ? void 0 : nestedTable.pos) || 0), [state.schema.nodes.table]);
|
|
160
|
+
if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
|
|
161
|
+
return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
|
|
162
|
+
}
|
|
163
|
+
} else if (((0, _dom.isCell)(target) || (0, _dom.isCornerButton)(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
|
|
153
164
|
return (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch);
|
|
154
165
|
}
|
|
155
166
|
if ((0, _dom.isResizeHandleDecoration)(target)) {
|
|
@@ -319,7 +330,7 @@ var handleMouseMoveDebounce = function handleMouseMoveDebounce(nodeViewPortalPro
|
|
|
319
330
|
var isKeyboardResize = (0, _pluginFactory2.getPluginState)(_state4).isKeyboardResize;
|
|
320
331
|
var tableCell = (0, _utils.closestElement)(element, 'td, th');
|
|
321
332
|
var cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
322
|
-
var rect = (0,
|
|
333
|
+
var rect = (0, _utils3.findCellRectClosestToPos)(_state4.doc.resolve(cellStartPosition));
|
|
323
334
|
if (rect) {
|
|
324
335
|
var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
|
|
325
336
|
var rowIndexTarget = rect.top;
|
|
@@ -354,7 +365,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(nodeVie
|
|
|
354
365
|
function handleTripleClick(view, pos) {
|
|
355
366
|
var state = view.state,
|
|
356
367
|
dispatch = view.dispatch;
|
|
357
|
-
var $cellPos = (0,
|
|
368
|
+
var $cellPos = (0, _utils3.cellAround)(state.doc.resolve(pos));
|
|
358
369
|
if (!$cellPos) {
|
|
359
370
|
return false;
|
|
360
371
|
}
|
|
@@ -381,7 +392,7 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
|
|
|
381
392
|
var cellSelection = new _cellSelection.CellSelection($anchorCell, $headCell);
|
|
382
393
|
tr.setSelection(cellSelection);
|
|
383
394
|
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
384
|
-
var rect = (0,
|
|
395
|
+
var rect = (0, _utils3.getSelectionRect)(cellSelection);
|
|
385
396
|
if (rect) {
|
|
386
397
|
var _getSelectedCellInfo = (0, _analytics2.getSelectedCellInfo)(tr.selection),
|
|
387
398
|
verticalCells = _getSelectedCellInfo.verticalCells,
|
|
@@ -409,7 +420,7 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
|
|
|
409
420
|
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
410
421
|
var isTableSelected = tr.selection.isRowSelection() && tr.selection.isColSelection();
|
|
411
422
|
if (isTableSelected) {
|
|
412
|
-
tr = (0,
|
|
423
|
+
tr = (0, _utils3.removeTable)(tr);
|
|
413
424
|
} else if (tr.selection.isRowSelection()) {
|
|
414
425
|
var _getPluginState9 = (0, _pluginFactory2.getPluginState)(newState),
|
|
415
426
|
isHeaderRowRequired = _getPluginState9.pluginConfig.isHeaderRowRequired;
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -373,10 +373,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
373
373
|
|
|
374
374
|
// We don't want to show floating toolbar while resizing the table
|
|
375
375
|
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
376
|
-
|
|
377
|
-
// Hide floating toolbar when resizing column and internal column width is on
|
|
378
|
-
var shouldHideToolbarForInternalColumnWidth = Boolean((options === null || options === void 0 ? void 0 : options.isNewColumnResizingEnabled) && resizeState && resizeState.dragging);
|
|
379
|
-
if (tableObject && pluginState.editorHasFocus && !isWidthResizing && !shouldHideToolbarForInternalColumnWidth) {
|
|
376
|
+
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
380
377
|
var nodeType = state.schema.nodes.table;
|
|
381
378
|
var isNested = pluginState.tablePos && (0, _nodes.isTableNested)(state, pluginState.tablePos);
|
|
382
379
|
var isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
|
|
@@ -208,7 +208,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
208
208
|
// padding left = padding right = akEditorGutterPadding = 32
|
|
209
209
|
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPaddingDynamic() * 2 : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
const width = !node.attrs.width && isCommentEditor ? responsiveContainerWidth : Math.min(tableWidth, responsiveContainerWidth);
|
|
212
212
|
if (!isResizing) {
|
|
213
213
|
tableWidthRef.current = width;
|
|
214
214
|
}
|