@atlaskit/editor-plugin-table 7.12.4 → 7.12.6
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 +18 -0
- package/dist/cjs/commands-with-analytics.js +42 -1
- package/dist/cjs/nodeviews/TableComponent.js +4 -3
- package/dist/cjs/toolbar.js +21 -3
- package/dist/es2019/commands-with-analytics.js +39 -1
- package/dist/es2019/nodeviews/TableComponent.js +4 -3
- package/dist/es2019/toolbar.js +22 -4
- package/dist/esm/commands-with-analytics.js +42 -1
- package/dist/esm/nodeviews/TableComponent.js +4 -3
- 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 +3 -3
- package/src/commands-with-analytics.ts +47 -0
- package/src/nodeviews/TableComponent.tsx +9 -3
- package/src/toolbar.tsx +26 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.12.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#98646](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98646)
|
|
8
|
+
[`b96ae2cfbd99`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b96ae2cfbd99) -
|
|
9
|
+
[ux] Fixes an issue where when the table is in overflow and is scaled due to a narrow screen
|
|
10
|
+
size and a column is inserted or deleted the oveflow is lost.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 7.12.5
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#96056](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/96056)
|
|
18
|
+
[`5ee939049a08`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5ee939049a08) -
|
|
19
|
+
Add analytics for lock columns button in floating toolbar.
|
|
20
|
+
|
|
3
21
|
## 7.12.4
|
|
4
22
|
|
|
5
23
|
### 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
|
|
@@ -475,7 +475,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
475
475
|
var isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
476
476
|
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
477
477
|
var isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
478
|
-
var
|
|
478
|
+
var isNumberOfColumnsChanged = (0, _utils5.tablesHaveDifferentNoOfColumns)(tableNode, this.node);
|
|
479
|
+
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
479
480
|
if (force || maybeScale) {
|
|
480
481
|
var _this$containerWidth;
|
|
481
482
|
var containerWidthValue = containerWidth.width;
|
|
@@ -484,7 +485,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
484
485
|
var isTableResized = (0, _colgroup.hasTableBeenResized)(tableNode);
|
|
485
486
|
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
486
487
|
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
487
|
-
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged;
|
|
488
|
+
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
488
489
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
489
490
|
var _this$props$options, _this$props$options2;
|
|
490
491
|
var resizeState = (0, _utils4.getResizeState)({
|
|
@@ -493,7 +494,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
493
494
|
table: tableNode,
|
|
494
495
|
tableRef: this.table,
|
|
495
496
|
start: start,
|
|
496
|
-
domAtPos: view.domAtPos,
|
|
497
|
+
domAtPos: view.domAtPos.bind(view),
|
|
497
498
|
isTableScalingEnabled: true
|
|
498
499
|
});
|
|
499
500
|
var shouldScaleOnColgroupUpdate = false;
|
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
|
|
@@ -458,7 +458,8 @@ class TableComponent extends React.Component {
|
|
|
458
458
|
const isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
459
459
|
const isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
460
460
|
const isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
461
|
-
const
|
|
461
|
+
const isNumberOfColumnsChanged = tablesHaveDifferentNoOfColumns(tableNode, this.node);
|
|
462
|
+
const maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
462
463
|
if (force || maybeScale) {
|
|
463
464
|
var _this$containerWidth;
|
|
464
465
|
const {
|
|
@@ -469,7 +470,7 @@ class TableComponent extends React.Component {
|
|
|
469
470
|
const isTableResized = hasTableBeenResized(tableNode);
|
|
470
471
|
const isColumnsDistributed = wasTableResized && !isTableResized;
|
|
471
472
|
const isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
472
|
-
const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged;
|
|
473
|
+
const shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
473
474
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
474
475
|
var _this$props$options, _this$props$options2;
|
|
475
476
|
const resizeState = getResizeState({
|
|
@@ -478,7 +479,7 @@ class TableComponent extends React.Component {
|
|
|
478
479
|
table: tableNode,
|
|
479
480
|
tableRef: this.table,
|
|
480
481
|
start,
|
|
481
|
-
domAtPos: view.domAtPos,
|
|
482
|
+
domAtPos: view.domAtPos.bind(view),
|
|
482
483
|
isTableScalingEnabled: true
|
|
483
484
|
});
|
|
484
485
|
let shouldScaleOnColgroupUpdate = false;
|
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
|
|
@@ -468,7 +468,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
468
468
|
var isTableWidthChanged = tableNodeWidth !== this.tableNodeWidth;
|
|
469
469
|
var isTableSquashed = tableRenderWidth < tableNodeWidth;
|
|
470
470
|
var isNumberColumnChanged = tableNode.attrs.isNumberColumnEnabled !== this.node.attrs.isNumberColumnEnabled;
|
|
471
|
-
var
|
|
471
|
+
var isNumberOfColumnsChanged = tablesHaveDifferentNoOfColumns(tableNode, this.node);
|
|
472
|
+
var maybeScale = isTableSquashed || isTableWidthChanged || isTableResizedFullWidth || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
472
473
|
if (force || maybeScale) {
|
|
473
474
|
var _this$containerWidth;
|
|
474
475
|
var containerWidthValue = containerWidth.width;
|
|
@@ -477,7 +478,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
477
478
|
var isTableResized = hasTableBeenResized(tableNode);
|
|
478
479
|
var isColumnsDistributed = wasTableResized && !isTableResized;
|
|
479
480
|
var isTableDisplayModeChanged = this.node.attrs.displayMode !== tableNode.attrs.displayMode;
|
|
480
|
-
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged;
|
|
481
|
+
var shouldUpdateColgroup = isWidthChanged || isColumnsDistributed || isTableResizedFullWidth || isTableWidthChanged || isTableDisplayModeChanged || isNumberColumnChanged || isNumberOfColumnsChanged;
|
|
481
482
|
if (force || !isResizing && shouldUpdateColgroup) {
|
|
482
483
|
var _this$props$options, _this$props$options2;
|
|
483
484
|
var resizeState = getResizeState({
|
|
@@ -486,7 +487,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
486
487
|
table: tableNode,
|
|
487
488
|
tableRef: this.table,
|
|
488
489
|
start: start,
|
|
489
|
-
domAtPos: view.domAtPos,
|
|
490
|
+
domAtPos: view.domAtPos.bind(view),
|
|
490
491
|
isTableScalingEnabled: true
|
|
491
492
|
});
|
|
492
493
|
var shouldScaleOnColgroupUpdate = false;
|
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.6",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.3.0",
|
|
50
50
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
51
51
|
"@atlaskit/primitives": "^6.1.0",
|
|
52
|
-
"@atlaskit/theme": "^12.
|
|
52
|
+
"@atlaskit/theme": "^12.8.0",
|
|
53
53
|
"@atlaskit/toggle": "^13.1.0",
|
|
54
|
-
"@atlaskit/tokens": "^1.
|
|
54
|
+
"@atlaskit/tokens": "^1.46.0",
|
|
55
55
|
"@atlaskit/tooltip": "^18.3.0",
|
|
56
56
|
"@babel/runtime": "^7.0.0",
|
|
57
57
|
"@emotion/react": "^11.7.1",
|
|
@@ -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
|
|
@@ -387,12 +387,17 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
387
387
|
const isNumberColumnChanged =
|
|
388
388
|
tableNode.attrs.isNumberColumnEnabled !==
|
|
389
389
|
this.node.attrs.isNumberColumnEnabled;
|
|
390
|
+
const isNumberOfColumnsChanged = tablesHaveDifferentNoOfColumns(
|
|
391
|
+
tableNode,
|
|
392
|
+
this.node,
|
|
393
|
+
);
|
|
390
394
|
|
|
391
395
|
const maybeScale =
|
|
392
396
|
isTableSquashed ||
|
|
393
397
|
isTableWidthChanged ||
|
|
394
398
|
isTableResizedFullWidth ||
|
|
395
|
-
isNumberColumnChanged
|
|
399
|
+
isNumberColumnChanged ||
|
|
400
|
+
isNumberOfColumnsChanged;
|
|
396
401
|
|
|
397
402
|
if (force || maybeScale) {
|
|
398
403
|
const { width: containerWidthValue } = containerWidth;
|
|
@@ -409,7 +414,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
409
414
|
isTableResizedFullWidth ||
|
|
410
415
|
isTableWidthChanged ||
|
|
411
416
|
isTableDisplayModeChanged ||
|
|
412
|
-
isNumberColumnChanged
|
|
417
|
+
isNumberColumnChanged ||
|
|
418
|
+
isNumberOfColumnsChanged;
|
|
413
419
|
|
|
414
420
|
if (force || (!isResizing && shouldUpdateColgroup)) {
|
|
415
421
|
const resizeState = getResizeState({
|
|
@@ -418,7 +424,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
418
424
|
table: tableNode,
|
|
419
425
|
tableRef: this.table,
|
|
420
426
|
start,
|
|
421
|
-
domAtPos: view.domAtPos,
|
|
427
|
+
domAtPos: view.domAtPos.bind(view),
|
|
422
428
|
isTableScalingEnabled: true,
|
|
423
429
|
});
|
|
424
430
|
|
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
|
});
|