@atlaskit/editor-plugin-table 7.12.3 → 7.12.5
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 +17 -0
- package/dist/cjs/commands-with-analytics.js +42 -1
- package/dist/cjs/nodeviews/TableComponent.js +3 -2
- package/dist/cjs/toolbar.js +21 -3
- package/dist/es2019/commands-with-analytics.js +39 -1
- package/dist/es2019/nodeviews/TableComponent.js +3 -2
- package/dist/es2019/toolbar.js +22 -4
- package/dist/esm/commands-with-analytics.js +42 -1
- package/dist/esm/nodeviews/TableComponent.js +3 -2
- package/dist/esm/toolbar.js +22 -4
- package/dist/types/commands-with-analytics.d.ts +2 -1
- package/dist/types/toolbar.d.ts +1 -0
- package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -1
- package/dist/types-ts4.5/toolbar.d.ts +1 -0
- package/package.json +2 -2
- package/src/commands-with-analytics.ts +47 -0
- package/src/nodeviews/TableComponent.tsx +11 -3
- package/src/toolbar.tsx +26 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.12.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#96056](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/96056)
|
|
8
|
+
[`5ee939049a08`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5ee939049a08) -
|
|
9
|
+
Add analytics for lock columns button in floating toolbar.
|
|
10
|
+
|
|
11
|
+
## 7.12.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#98128](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98128)
|
|
16
|
+
[`befad90f2a13`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/befad90f2a13) -
|
|
17
|
+
Visually scale table when number column is enabled
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 7.12.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -4,16 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.wrapTableInExpandWithAnalytics = exports.toggleTableLayoutWithAnalytics = exports.toggleNumberColumnWithAnalytics = exports.toggleHeaderRowWithAnalytics = exports.toggleHeaderColumnWithAnalytics = exports.splitCellWithAnalytics = exports.sortColumnWithAnalytics = exports.setColorWithAnalytics = exports.mergeCellsWithAnalytics = exports.insertRowWithAnalytics = exports.insertColumnWithAnalytics = exports.emptyMultipleCellsWithAnalytics = exports.distributeColumnsWidthsWithAnalytics = exports.deleteTableWithAnalytics = exports.deleteTableIfSelectedWithAnalytics = exports.deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = exports.deleteRowsWithAnalytics = exports.deleteColumnsWithAnalytics = exports.changeColumnWidthByStepWithAnalytics = exports.addRowAroundSelection = void 0;
|
|
7
|
+
exports.wrapTableInExpandWithAnalytics = exports.toggleTableLockWithAnalytics = exports.toggleTableLayoutWithAnalytics = exports.toggleNumberColumnWithAnalytics = exports.toggleHeaderRowWithAnalytics = exports.toggleHeaderColumnWithAnalytics = exports.splitCellWithAnalytics = exports.sortColumnWithAnalytics = exports.setColorWithAnalytics = exports.mergeCellsWithAnalytics = exports.insertRowWithAnalytics = exports.insertColumnWithAnalytics = exports.emptyMultipleCellsWithAnalytics = exports.distributeColumnsWidthsWithAnalytics = exports.deleteTableWithAnalytics = exports.deleteTableIfSelectedWithAnalytics = exports.deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut = exports.deleteRowsWithAnalytics = exports.deleteColumnsWithAnalytics = exports.changeColumnWidthByStepWithAnalytics = exports.addRowAroundSelection = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _preset = require("@atlaskit/editor-common/preset");
|
|
11
12
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
12
13
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
13
14
|
var _clear = require("./commands/clear");
|
|
14
15
|
var _collapse = require("./commands/collapse");
|
|
15
16
|
var _columnResize = require("./commands/column-resize");
|
|
16
17
|
var _delete = require("./commands/delete");
|
|
18
|
+
var _displayMode = require("./commands/display-mode");
|
|
17
19
|
var _insert = require("./commands/insert");
|
|
18
20
|
var _misc = require("./commands/misc");
|
|
19
21
|
var _sort = require("./commands/sort");
|
|
@@ -494,4 +496,43 @@ var wrapTableInExpandWithAnalytics = exports.wrapTableInExpandWithAnalytics = fu
|
|
|
494
496
|
};
|
|
495
497
|
})(editorAnalyticsAPI)(_collapse.wrapTableInExpand);
|
|
496
498
|
};
|
|
499
|
+
var toggleTableLockWithAnalytics = exports.toggleTableLockWithAnalytics = function toggleTableLockWithAnalytics(editorAnalyticsAPI) {
|
|
500
|
+
return function (displayMode, inputMethod) {
|
|
501
|
+
return (0, _analytics2.withEditorAnalyticsAPI)(function (state) {
|
|
502
|
+
var _getSelectedTableInfo13 = (0, _utils2.getSelectedTableInfo)(state.selection),
|
|
503
|
+
table = _getSelectedTableInfo13.table,
|
|
504
|
+
totalRowCount = _getSelectedTableInfo13.totalRowCount,
|
|
505
|
+
totalColumnCount = _getSelectedTableInfo13.totalColumnCount;
|
|
506
|
+
var previousDisplayMode;
|
|
507
|
+
var newDisplayMode;
|
|
508
|
+
switch (displayMode) {
|
|
509
|
+
case 'fixed':
|
|
510
|
+
previousDisplayMode = _analytics.TABLE_DISPLAY_MODE.FIXED;
|
|
511
|
+
newDisplayMode = _analytics.TABLE_DISPLAY_MODE.DEFAULT;
|
|
512
|
+
break;
|
|
513
|
+
case 'default':
|
|
514
|
+
previousDisplayMode = _analytics.TABLE_DISPLAY_MODE.DEFAULT;
|
|
515
|
+
newDisplayMode = _analytics.TABLE_DISPLAY_MODE.FIXED;
|
|
516
|
+
break;
|
|
517
|
+
case null:
|
|
518
|
+
default:
|
|
519
|
+
previousDisplayMode = _analytics.TABLE_DISPLAY_MODE.INITIAL;
|
|
520
|
+
newDisplayMode = _analytics.TABLE_DISPLAY_MODE.FIXED;
|
|
521
|
+
}
|
|
522
|
+
return {
|
|
523
|
+
action: _analytics.TABLE_ACTION.CHANGED_DISPLAY_MODE,
|
|
524
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
525
|
+
attributes: {
|
|
526
|
+
inputMethod: inputMethod,
|
|
527
|
+
previousDisplayMode: previousDisplayMode,
|
|
528
|
+
newDisplayMode: newDisplayMode,
|
|
529
|
+
tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
|
|
530
|
+
totalRowCount: totalRowCount,
|
|
531
|
+
totalColumnCount: totalColumnCount
|
|
532
|
+
},
|
|
533
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
534
|
+
};
|
|
535
|
+
})(editorAnalyticsAPI)((0, _preset.editorCommandToPMCommand)(_displayMode.setTableDisplayMode));
|
|
536
|
+
};
|
|
537
|
+
};
|
|
497
538
|
// #endregion
|
|
@@ -474,7 +474,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
474
474
|
// Needed for undo / redo
|
|
475
475
|
var isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
476
476
|
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
477
|
-
var
|
|
477
|
+
var isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
478
|
+
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth || isNumberColumnChanged;
|
|
478
479
|
if (force || maybeScale) {
|
|
479
480
|
var _this$containerWidth;
|
|
480
481
|
var containerWidthValue = containerWidth.width;
|
|
@@ -483,7 +484,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
483
484
|
var isTableResized = (0, _colgroup.hasTableBeenResized)(tableNode);
|
|
484
485
|
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
485
486
|
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
486
|
-
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged;
|
|
487
|
+
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged;
|
|
487
488
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
488
489
|
var _this$props$options, _this$props$options2;
|
|
489
490
|
var resizeState = (0, _utils4.getResizeState)({
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -5,14 +5,13 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getDistributeConfig = exports.getClosestSelectionRect = exports.getClosestSelectionOrTableRect = void 0;
|
|
8
|
+
exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getLockBtnConfig = exports.getDistributeConfig = exports.getClosestSelectionRect = exports.getClosestSelectionOrTableRect = void 0;
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _react = require("@emotion/react");
|
|
11
11
|
var _customSteps = require("@atlaskit/custom-steps");
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
13
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
14
14
|
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
15
|
-
var _preset = require("@atlaskit/editor-common/preset");
|
|
16
15
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
17
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
17
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
@@ -437,6 +436,23 @@ var getCellItems = function getCellItems(state, view, _ref3, getEditorContainerW
|
|
|
437
436
|
}
|
|
438
437
|
return [];
|
|
439
438
|
};
|
|
439
|
+
var getLockBtnConfig = exports.getLockBtnConfig = function getLockBtnConfig(editorAnalyticsAPI) {
|
|
440
|
+
return function (state, dispatch, editorView) {
|
|
441
|
+
var selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
442
|
+
if (!editorView || !selectionOrTableRect) {
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
var tr = state.tr;
|
|
446
|
+
var table = (0, _utils3.findTable)(tr.selection);
|
|
447
|
+
if (!table) {
|
|
448
|
+
return false;
|
|
449
|
+
} else {
|
|
450
|
+
var displayMode = table.node.attrs.displayMode;
|
|
451
|
+
(0, _commandsWithAnalytics.toggleTableLockWithAnalytics)(editorAnalyticsAPI)(displayMode, _analytics.INPUT_METHOD.FLOATING_TB)(state, dispatch);
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
};
|
|
440
456
|
var getDistributeConfig = exports.getDistributeConfig = function getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
441
457
|
var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
442
458
|
return function (state, dispatch, editorView) {
|
|
@@ -483,7 +499,9 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
|
|
|
483
499
|
label: title
|
|
484
500
|
});
|
|
485
501
|
},
|
|
486
|
-
onClick: (
|
|
502
|
+
onClick: function onClick(state, dispatch, view) {
|
|
503
|
+
return getLockBtnConfig(editorAnalyticsAPI)(state, dispatch, view);
|
|
504
|
+
},
|
|
487
505
|
selected: areColumnWidthsLocked,
|
|
488
506
|
testId: 'table-lock-column-widths-btn'
|
|
489
507
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
|
|
2
|
-
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_BREAKOUT } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_BREAKOUT, TABLE_DISPLAY_MODE } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
3
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
5
|
import { findCellClosestToPos, findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
6
|
import { clearMultipleCells } from './commands/clear';
|
|
6
7
|
import { wrapTableInExpand } from './commands/collapse';
|
|
7
8
|
import { changeColumnWidthByStep } from './commands/column-resize';
|
|
8
9
|
import { deleteColumnsCommand } from './commands/delete';
|
|
10
|
+
import { setTableDisplayMode } from './commands/display-mode';
|
|
9
11
|
import { insertColumn, insertRow } from './commands/insert';
|
|
10
12
|
import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs } from './commands/misc';
|
|
11
13
|
import { sortByColumn } from './commands/sort';
|
|
@@ -452,4 +454,40 @@ export const wrapTableInExpandWithAnalytics = editorAnalyticsAPI => withEditorAn
|
|
|
452
454
|
eventType: EVENT_TYPE.TRACK
|
|
453
455
|
};
|
|
454
456
|
})(editorAnalyticsAPI)(wrapTableInExpand);
|
|
457
|
+
export const toggleTableLockWithAnalytics = editorAnalyticsAPI => (displayMode, inputMethod) => withEditorAnalyticsAPI(state => {
|
|
458
|
+
const {
|
|
459
|
+
table,
|
|
460
|
+
totalRowCount,
|
|
461
|
+
totalColumnCount
|
|
462
|
+
} = getSelectedTableInfo(state.selection);
|
|
463
|
+
let previousDisplayMode;
|
|
464
|
+
let newDisplayMode;
|
|
465
|
+
switch (displayMode) {
|
|
466
|
+
case 'fixed':
|
|
467
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
468
|
+
newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
|
|
469
|
+
break;
|
|
470
|
+
case 'default':
|
|
471
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
|
|
472
|
+
newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
473
|
+
break;
|
|
474
|
+
case null:
|
|
475
|
+
default:
|
|
476
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.INITIAL;
|
|
477
|
+
newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
action: TABLE_ACTION.CHANGED_DISPLAY_MODE,
|
|
481
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
482
|
+
attributes: {
|
|
483
|
+
inputMethod,
|
|
484
|
+
previousDisplayMode,
|
|
485
|
+
newDisplayMode,
|
|
486
|
+
tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
|
|
487
|
+
totalRowCount,
|
|
488
|
+
totalColumnCount
|
|
489
|
+
},
|
|
490
|
+
eventType: EVENT_TYPE.TRACK
|
|
491
|
+
};
|
|
492
|
+
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
|
|
455
493
|
// #endregion
|
|
@@ -457,7 +457,8 @@ class TableComponent extends React.Component {
|
|
|
457
457
|
// Needed for undo / redo
|
|
458
458
|
const isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
459
459
|
const isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
460
|
-
const
|
|
460
|
+
const isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
461
|
+
const maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth || isNumberColumnChanged;
|
|
461
462
|
if (force || maybeScale) {
|
|
462
463
|
var _this$containerWidth;
|
|
463
464
|
const {
|
|
@@ -468,7 +469,7 @@ class TableComponent extends React.Component {
|
|
|
468
469
|
const isTableResized = hasTableBeenResized(tableNode);
|
|
469
470
|
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
470
471
|
const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
471
|
-
const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged;
|
|
472
|
+
const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged;
|
|
472
473
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
473
474
|
var _this$props$options, _this$props$options2;
|
|
474
475
|
const resizeState = getResizeState({
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -4,7 +4,6 @@ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
|
4
4
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
6
6
|
import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
8
7
|
import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
9
8
|
import { closestElement, getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
|
|
10
9
|
import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -16,8 +15,8 @@ import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal
|
|
|
16
15
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
17
16
|
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
18
17
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
19
|
-
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes
|
|
20
|
-
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
18
|
+
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
|
|
19
|
+
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, toggleTableLockWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
21
20
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
22
21
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
23
22
|
import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
|
|
@@ -415,6 +414,25 @@ const getCellItems = (state, view, {
|
|
|
415
414
|
}
|
|
416
415
|
return [];
|
|
417
416
|
};
|
|
417
|
+
export const getLockBtnConfig = editorAnalyticsAPI => (state, dispatch, editorView) => {
|
|
418
|
+
const selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
419
|
+
if (!editorView || !selectionOrTableRect) {
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
const {
|
|
423
|
+
tr
|
|
424
|
+
} = state;
|
|
425
|
+
const table = findTable(tr.selection);
|
|
426
|
+
if (!table) {
|
|
427
|
+
return false;
|
|
428
|
+
} else {
|
|
429
|
+
const {
|
|
430
|
+
displayMode
|
|
431
|
+
} = table.node.attrs;
|
|
432
|
+
toggleTableLockWithAnalytics(editorAnalyticsAPI)(displayMode, INPUT_METHOD.FLOATING_TB)(state, dispatch);
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
};
|
|
418
436
|
export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => (state, dispatch, editorView) => {
|
|
419
437
|
const selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
420
438
|
if (!editorView || !selectionOrTableRect) {
|
|
@@ -456,7 +474,7 @@ const getColumnSettingItems = (editorState, editorView, {
|
|
|
456
474
|
size: "medium",
|
|
457
475
|
label: title
|
|
458
476
|
}),
|
|
459
|
-
onClick:
|
|
477
|
+
onClick: (state, dispatch, view) => getLockBtnConfig(editorAnalyticsAPI)(state, dispatch, view),
|
|
460
478
|
selected: areColumnWidthsLocked,
|
|
461
479
|
testId: 'table-lock-column-widths-btn'
|
|
462
480
|
});
|
|
@@ -2,13 +2,15 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
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) { _defineProperty(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; }
|
|
4
4
|
import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
|
|
5
|
-
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_BREAKOUT } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_BREAKOUT, TABLE_DISPLAY_MODE } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
6
7
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
8
|
import { findCellClosestToPos, findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
8
9
|
import { clearMultipleCells } from './commands/clear';
|
|
9
10
|
import { wrapTableInExpand } from './commands/collapse';
|
|
10
11
|
import { changeColumnWidthByStep } from './commands/column-resize';
|
|
11
12
|
import { deleteColumnsCommand } from './commands/delete';
|
|
13
|
+
import { setTableDisplayMode } from './commands/display-mode';
|
|
12
14
|
import { insertColumn, insertRow } from './commands/insert';
|
|
13
15
|
import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs } from './commands/misc';
|
|
14
16
|
import { sortByColumn } from './commands/sort';
|
|
@@ -487,4 +489,43 @@ export var wrapTableInExpandWithAnalytics = function wrapTableInExpandWithAnalyt
|
|
|
487
489
|
};
|
|
488
490
|
})(editorAnalyticsAPI)(wrapTableInExpand);
|
|
489
491
|
};
|
|
492
|
+
export var toggleTableLockWithAnalytics = function toggleTableLockWithAnalytics(editorAnalyticsAPI) {
|
|
493
|
+
return function (displayMode, inputMethod) {
|
|
494
|
+
return withEditorAnalyticsAPI(function (state) {
|
|
495
|
+
var _getSelectedTableInfo13 = getSelectedTableInfo(state.selection),
|
|
496
|
+
table = _getSelectedTableInfo13.table,
|
|
497
|
+
totalRowCount = _getSelectedTableInfo13.totalRowCount,
|
|
498
|
+
totalColumnCount = _getSelectedTableInfo13.totalColumnCount;
|
|
499
|
+
var previousDisplayMode;
|
|
500
|
+
var newDisplayMode;
|
|
501
|
+
switch (displayMode) {
|
|
502
|
+
case 'fixed':
|
|
503
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
504
|
+
newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
|
|
505
|
+
break;
|
|
506
|
+
case 'default':
|
|
507
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
|
|
508
|
+
newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
509
|
+
break;
|
|
510
|
+
case null:
|
|
511
|
+
default:
|
|
512
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.INITIAL;
|
|
513
|
+
newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
action: TABLE_ACTION.CHANGED_DISPLAY_MODE,
|
|
517
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
518
|
+
attributes: {
|
|
519
|
+
inputMethod: inputMethod,
|
|
520
|
+
previousDisplayMode: previousDisplayMode,
|
|
521
|
+
newDisplayMode: newDisplayMode,
|
|
522
|
+
tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
|
|
523
|
+
totalRowCount: totalRowCount,
|
|
524
|
+
totalColumnCount: totalColumnCount
|
|
525
|
+
},
|
|
526
|
+
eventType: EVENT_TYPE.TRACK
|
|
527
|
+
};
|
|
528
|
+
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
|
|
529
|
+
};
|
|
530
|
+
};
|
|
490
531
|
// #endregion
|
|
@@ -467,7 +467,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
467
467
|
// Needed for undo / redo
|
|
468
468
|
var isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
469
469
|
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
470
|
-
var
|
|
470
|
+
var isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
471
|
+
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth || isNumberColumnChanged;
|
|
471
472
|
if (force || maybeScale) {
|
|
472
473
|
var _this$containerWidth;
|
|
473
474
|
var containerWidthValue = containerWidth.width;
|
|
@@ -476,7 +477,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
476
477
|
var isTableResized = hasTableBeenResized(tableNode);
|
|
477
478
|
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
478
479
|
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
479
|
-
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged;
|
|
480
|
+
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged;
|
|
480
481
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
481
482
|
var _this$props$options, _this$props$options2;
|
|
482
483
|
var resizeState = getResizeState({
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -5,7 +5,6 @@ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
|
5
5
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
7
7
|
import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
8
|
-
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
9
8
|
import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
10
9
|
import { closestElement, getChildrenInfo as _getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
|
|
11
10
|
import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -17,8 +16,8 @@ import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal
|
|
|
17
16
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
18
17
|
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
19
18
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
20
|
-
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes
|
|
21
|
-
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
19
|
+
import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
|
|
20
|
+
import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, toggleTableLockWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
22
21
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
23
22
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
24
23
|
import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
|
|
@@ -426,6 +425,23 @@ var getCellItems = function getCellItems(state, view, _ref3, getEditorContainerW
|
|
|
426
425
|
}
|
|
427
426
|
return [];
|
|
428
427
|
};
|
|
428
|
+
export var getLockBtnConfig = function getLockBtnConfig(editorAnalyticsAPI) {
|
|
429
|
+
return function (state, dispatch, editorView) {
|
|
430
|
+
var selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
431
|
+
if (!editorView || !selectionOrTableRect) {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
var tr = state.tr;
|
|
435
|
+
var table = findTable(tr.selection);
|
|
436
|
+
if (!table) {
|
|
437
|
+
return false;
|
|
438
|
+
} else {
|
|
439
|
+
var displayMode = table.node.attrs.displayMode;
|
|
440
|
+
toggleTableLockWithAnalytics(editorAnalyticsAPI)(displayMode, INPUT_METHOD.FLOATING_TB)(state, dispatch);
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
};
|
|
429
445
|
export var getDistributeConfig = function getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
430
446
|
var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
431
447
|
return function (state, dispatch, editorView) {
|
|
@@ -472,7 +488,9 @@ var getColumnSettingItems = function getColumnSettingItems(editorState, editorVi
|
|
|
472
488
|
label: title
|
|
473
489
|
});
|
|
474
490
|
},
|
|
475
|
-
onClick:
|
|
491
|
+
onClick: function onClick(state, dispatch, view) {
|
|
492
|
+
return getLockBtnConfig(editorAnalyticsAPI)(state, dispatch, view);
|
|
493
|
+
},
|
|
476
494
|
selected: areColumnWidthsLocked,
|
|
477
495
|
testId: 'table-lock-column-widths-btn'
|
|
478
496
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
2
|
import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
3
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { INPUT_METHOD, TABLE_DISPLAY_MODE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
6
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
@@ -27,3 +27,4 @@ export declare const toggleTableLayoutWithAnalytics: (editorAnalyticsAPI: Editor
|
|
|
27
27
|
export declare const sortColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex: number, sortOrder: SortOrder) => Command;
|
|
28
28
|
export declare const distributeColumnsWidthsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, { resizeState, table, attributes }: ResizeStateWithAnalytics) => Command;
|
|
29
29
|
export declare const wrapTableInExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
30
|
+
export declare const toggleTableLockWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (displayMode: TABLE_DISPLAY_MODE | null, inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
|
package/dist/types/toolbar.d.ts
CHANGED
|
@@ -10,4 +10,5 @@ export declare const getToolbarCellOptionsConfig: (editorState: EditorState, edi
|
|
|
10
10
|
export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
|
|
11
11
|
export declare const getClosestSelectionOrTableRect: (state: EditorState) => Rect | undefined;
|
|
12
12
|
export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions) => (config: PluginConfig) => FloatingToolbarHandler;
|
|
13
|
+
export declare const getLockBtnConfig: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
13
14
|
export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
2
|
import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
3
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { INPUT_METHOD, TABLE_DISPLAY_MODE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
6
6
|
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
@@ -27,3 +27,4 @@ export declare const toggleTableLayoutWithAnalytics: (editorAnalyticsAPI: Editor
|
|
|
27
27
|
export declare const sortColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, columnIndex: number, sortOrder: SortOrder) => Command;
|
|
28
28
|
export declare const distributeColumnsWidthsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, { resizeState, table, attributes }: ResizeStateWithAnalytics) => Command;
|
|
29
29
|
export declare const wrapTableInExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
30
|
+
export declare const toggleTableLockWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (displayMode: TABLE_DISPLAY_MODE | null, inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) => Command;
|
|
@@ -10,4 +10,5 @@ export declare const getToolbarCellOptionsConfig: (editorState: EditorState, edi
|
|
|
10
10
|
export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
|
|
11
11
|
export declare const getClosestSelectionOrTableRect: (state: EditorState) => Rect | undefined;
|
|
12
12
|
export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions) => (config: PluginConfig) => FloatingToolbarHandler;
|
|
13
|
+
export declare const getLockBtnConfig: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
13
14
|
export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.12.
|
|
3
|
+
"version": "7.12.5",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^35.12.2",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.1.0",
|
|
33
|
-
"@atlaskit/editor-common": "^79.
|
|
33
|
+
"@atlaskit/editor-common": "^79.2.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.6.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.1.0",
|
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
INPUT_METHOD,
|
|
9
9
|
TABLE_ACTION,
|
|
10
10
|
TABLE_BREAKOUT,
|
|
11
|
+
TABLE_DISPLAY_MODE,
|
|
11
12
|
} from '@atlaskit/editor-common/analytics';
|
|
12
13
|
import type {
|
|
13
14
|
AnalyticsEventPayload,
|
|
14
15
|
EditorAnalyticsAPI,
|
|
15
16
|
} from '@atlaskit/editor-common/analytics';
|
|
17
|
+
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
16
18
|
import type {
|
|
17
19
|
Command,
|
|
18
20
|
GetEditorContainerWidth,
|
|
@@ -31,6 +33,7 @@ import { clearMultipleCells } from './commands/clear';
|
|
|
31
33
|
import { wrapTableInExpand } from './commands/collapse';
|
|
32
34
|
import { changeColumnWidthByStep } from './commands/column-resize';
|
|
33
35
|
import { deleteColumnsCommand } from './commands/delete';
|
|
36
|
+
import { setTableDisplayMode } from './commands/display-mode';
|
|
34
37
|
import { insertColumn, insertRow } from './commands/insert';
|
|
35
38
|
import {
|
|
36
39
|
deleteTable,
|
|
@@ -634,4 +637,48 @@ export const wrapTableInExpandWithAnalytics = (
|
|
|
634
637
|
eventType: EVENT_TYPE.TRACK,
|
|
635
638
|
};
|
|
636
639
|
})(editorAnalyticsAPI)(wrapTableInExpand);
|
|
640
|
+
|
|
641
|
+
export const toggleTableLockWithAnalytics =
|
|
642
|
+
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
|
|
643
|
+
(
|
|
644
|
+
displayMode: TABLE_DISPLAY_MODE | null,
|
|
645
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB,
|
|
646
|
+
) =>
|
|
647
|
+
withEditorAnalyticsAPI((state) => {
|
|
648
|
+
const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(
|
|
649
|
+
state.selection,
|
|
650
|
+
);
|
|
651
|
+
|
|
652
|
+
let previousDisplayMode: TABLE_DISPLAY_MODE;
|
|
653
|
+
let newDisplayMode: TABLE_DISPLAY_MODE;
|
|
654
|
+
|
|
655
|
+
switch (displayMode) {
|
|
656
|
+
case 'fixed':
|
|
657
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
658
|
+
newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
|
|
659
|
+
break;
|
|
660
|
+
case 'default':
|
|
661
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
|
|
662
|
+
newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
663
|
+
break;
|
|
664
|
+
case null:
|
|
665
|
+
default:
|
|
666
|
+
previousDisplayMode = TABLE_DISPLAY_MODE.INITIAL;
|
|
667
|
+
newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
return {
|
|
671
|
+
action: TABLE_ACTION.CHANGED_DISPLAY_MODE,
|
|
672
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
673
|
+
attributes: {
|
|
674
|
+
inputMethod,
|
|
675
|
+
previousDisplayMode,
|
|
676
|
+
newDisplayMode,
|
|
677
|
+
tableWidth: table?.node.attrs.width,
|
|
678
|
+
totalRowCount,
|
|
679
|
+
totalColumnCount,
|
|
680
|
+
},
|
|
681
|
+
eventType: EVENT_TYPE.TRACK,
|
|
682
|
+
};
|
|
683
|
+
})(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
|
|
637
684
|
// #endregion
|
|
@@ -384,9 +384,16 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
384
384
|
// Needed for undo / redo
|
|
385
385
|
const isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
386
386
|
const isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
387
|
+
const isNumberColumnChanged =
|
|
388
|
+
tableNode.attrs.isNumberColumnEnabled !==
|
|
389
|
+
this.node.attrs.isNumberColumnEnabled;
|
|
387
390
|
|
|
388
391
|
const maybeScale =
|
|
389
|
-
isTableSquashed ||
|
|
392
|
+
isTableSquashed ||
|
|
393
|
+
isTableWidthChanged ||
|
|
394
|
+
isTableResizedFullWidth ||
|
|
395
|
+
isNumberColumnChanged;
|
|
396
|
+
|
|
390
397
|
if (force || maybeScale) {
|
|
391
398
|
const { width: containerWidthValue } = containerWidth;
|
|
392
399
|
const isWidthChanged = this.containerWidth?.width !== containerWidthValue;
|
|
@@ -401,7 +408,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
401
408
|
isColumnsDistributed ||
|
|
402
409
|
isTableResizedFullWidth ||
|
|
403
410
|
isTableWidthChanged ||
|
|
404
|
-
isTableDisplayModeChanged
|
|
411
|
+
isTableDisplayModeChanged ||
|
|
412
|
+
isNumberColumnChanged;
|
|
405
413
|
|
|
406
414
|
if (force || (!isResizing && shouldUpdateColgroup)) {
|
|
407
415
|
const resizeState = getResizeState({
|
|
@@ -758,7 +766,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
758
766
|
|
|
759
767
|
const shadowStyle = memoizeOne(
|
|
760
768
|
(visible) =>
|
|
761
|
-
({ visibility: visible ? 'visible' : 'hidden' } as CSSProperties
|
|
769
|
+
({ visibility: visible ? 'visible' : 'hidden' }) as CSSProperties,
|
|
762
770
|
);
|
|
763
771
|
|
|
764
772
|
/**
|
package/src/toolbar.tsx
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import commonMessages, {
|
|
14
14
|
tableMessages as messages,
|
|
15
15
|
} from '@atlaskit/editor-common/messages';
|
|
16
|
-
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
17
16
|
import type { typeOption } from '@atlaskit/editor-common/src/types/floating-toolbar';
|
|
18
17
|
import type {
|
|
19
18
|
Command,
|
|
@@ -62,7 +61,6 @@ import {
|
|
|
62
61
|
hoverRows,
|
|
63
62
|
hoverTable,
|
|
64
63
|
removeDescendantNodes,
|
|
65
|
-
setTableDisplayMode,
|
|
66
64
|
} from './commands';
|
|
67
65
|
import {
|
|
68
66
|
deleteColumnsWithAnalytics,
|
|
@@ -79,6 +77,7 @@ import {
|
|
|
79
77
|
toggleHeaderColumnWithAnalytics,
|
|
80
78
|
toggleHeaderRowWithAnalytics,
|
|
81
79
|
toggleNumberColumnWithAnalytics,
|
|
80
|
+
toggleTableLockWithAnalytics,
|
|
82
81
|
wrapTableInExpandWithAnalytics,
|
|
83
82
|
} from './commands-with-analytics';
|
|
84
83
|
import type { TablePluginOptions } from './plugin';
|
|
@@ -644,6 +643,29 @@ const getCellItems = (
|
|
|
644
643
|
return [];
|
|
645
644
|
};
|
|
646
645
|
|
|
646
|
+
export const getLockBtnConfig =
|
|
647
|
+
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null): Command =>
|
|
648
|
+
(state, dispatch, editorView) => {
|
|
649
|
+
const selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
650
|
+
if (!editorView || !selectionOrTableRect) {
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const { tr } = state;
|
|
655
|
+
const table = findTable(tr.selection);
|
|
656
|
+
|
|
657
|
+
if (!table) {
|
|
658
|
+
return false;
|
|
659
|
+
} else {
|
|
660
|
+
const { displayMode } = table.node.attrs;
|
|
661
|
+
toggleTableLockWithAnalytics(editorAnalyticsAPI)(
|
|
662
|
+
displayMode,
|
|
663
|
+
INPUT_METHOD.FLOATING_TB,
|
|
664
|
+
)(state, dispatch);
|
|
665
|
+
return true;
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
|
|
647
669
|
export const getDistributeConfig =
|
|
648
670
|
(
|
|
649
671
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
@@ -723,7 +745,8 @@ const getColumnSettingItems = (
|
|
|
723
745
|
type: 'button',
|
|
724
746
|
title,
|
|
725
747
|
icon: () => <DisplayModeIcon size="medium" label={title} />,
|
|
726
|
-
onClick:
|
|
748
|
+
onClick: (state, dispatch, view) =>
|
|
749
|
+
getLockBtnConfig(editorAnalyticsAPI)(state, dispatch, view),
|
|
727
750
|
selected: areColumnWidthsLocked,
|
|
728
751
|
testId: 'table-lock-column-widths-btn',
|
|
729
752
|
});
|