@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
|
@@ -42,8 +42,8 @@ export const getTableWidth = node => {
|
|
|
42
42
|
return getTableWidths(node).reduce((acc, current) => acc + current, 0);
|
|
43
43
|
};
|
|
44
44
|
export const tablesHaveDifferentColumnWidths = (currentTable, previousTable) => {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const currentTableWidths = getTableWidths(currentTable);
|
|
46
|
+
const previousTableWidths = getTableWidths(previousTable);
|
|
47
47
|
if (currentTableWidths.length !== previousTableWidths.length) {
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
@@ -76,7 +76,7 @@ function getTableWidths(node) {
|
|
|
76
76
|
if (!node.content.firstChild) {
|
|
77
77
|
return [];
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
const tableWidths = [];
|
|
80
80
|
node.content.firstChild.content.forEach(cell => {
|
|
81
81
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
82
82
|
const colspan = cell.attrs.colspan || 1;
|
|
@@ -116,8 +116,8 @@ export const copyPreviousRow = schema => insertNewRowIndex => tr => {
|
|
|
116
116
|
const offsetNextLineIndexPosition = insertNewRowIndex * map.width;
|
|
117
117
|
const cellsPositionsInOriginalRow = map.map.slice(offsetIndexPosition, offsetIndexPosition + map.width);
|
|
118
118
|
const cellsPositionsInNextRow = map.map.slice(offsetNextLineIndexPosition, offsetNextLineIndexPosition + map.width);
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
const cells = [];
|
|
120
|
+
const fixRowspans = [];
|
|
121
121
|
for (let i = 0; i < cellsPositionsInOriginalRow.length;) {
|
|
122
122
|
const pos = cellsPositionsInOriginalRow[i];
|
|
123
123
|
const documentCellPos = pos + table.start;
|
|
@@ -42,8 +42,8 @@ export const createPlugin = (api, nodeViewPortalProviderAPI) => {
|
|
|
42
42
|
allTables
|
|
43
43
|
} = pluginState;
|
|
44
44
|
const sortMeta = tr.getMeta('tableSortMeta');
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const hoverTableMeta = tr.getMeta('mouseEnterTable');
|
|
46
|
+
const removeTableMeta = tr.getMeta('removeTable');
|
|
47
47
|
let tableId = '';
|
|
48
48
|
|
|
49
49
|
// Remove the table from the state
|
|
@@ -47,7 +47,7 @@ export const toggleSort = (view, event, pluginState) => {
|
|
|
47
47
|
if (widget !== null && widget !== void 0 && widget.classList.contains(IS_DISABLED_CLASS_NAME) || !widget) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
const dataSortIndex = target === null || target === void 0 ? void 0 : (_target$closest = target.closest('.ProseMirror-widget')) === null || _target$closest === void 0 ? void 0 : _target$closest.getAttribute(SORT_INDEX_DATA_ATTRIBUTE);
|
|
51
51
|
const tr = view.state.tr;
|
|
52
52
|
const tableElement = target.closest('table');
|
|
53
53
|
if (!tableElement || !dataSortIndex) {
|
|
@@ -59,6 +59,9 @@ export const toggleSort = (view, event, pluginState) => {
|
|
|
59
59
|
if (!tableId || !tableNode || (tableNode === null || tableNode === void 0 ? void 0 : (_tableNode$type = tableNode.type) === null || _tableNode$type === void 0 ? void 0 : _tableNode$type.name) !== 'table') {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
// Ignored via go/ees005
|
|
64
|
+
// eslint-disable-next-line prefer-const
|
|
62
65
|
let {
|
|
63
66
|
index,
|
|
64
67
|
direction,
|
|
@@ -245,16 +245,14 @@ const tablesPlugin = ({
|
|
|
245
245
|
fullWidthEnabled,
|
|
246
246
|
tableOptions,
|
|
247
247
|
getEditorFeatureFlags,
|
|
248
|
-
isTableScalingEnabled
|
|
249
|
-
isNewColumnResizingEnabled
|
|
248
|
+
isTableScalingEnabled
|
|
250
249
|
} = options || {};
|
|
251
250
|
const {
|
|
252
|
-
allowColumnResizing
|
|
253
|
-
allowTableAlignment
|
|
251
|
+
allowColumnResizing
|
|
254
252
|
} = pluginConfig(tableOptions);
|
|
255
253
|
return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
|
|
256
254
|
lastColumnResizable: !fullWidthEnabled
|
|
257
|
-
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false,
|
|
255
|
+
}, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled || false, !!(options !== null && options !== void 0 && options.isCommentEditor)) : undefined;
|
|
258
256
|
}
|
|
259
257
|
}, {
|
|
260
258
|
name: 'tableEditing',
|
|
@@ -13,9 +13,9 @@ export const DragPreview = ({
|
|
|
13
13
|
width,
|
|
14
14
|
height
|
|
15
15
|
}) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const marginLeft = direction === 'row' ? -14 : width / 2 - 14;
|
|
17
|
+
const marginTop = direction === 'row' ? height / 2 - 14 : -10;
|
|
18
|
+
const transform = direction === 'row' ? 'rotate(90deg)' : 'none';
|
|
19
19
|
return /*#__PURE__*/React.createElement(Box, {
|
|
20
20
|
xcss: boxStyles,
|
|
21
21
|
style: {
|
|
@@ -30,6 +30,7 @@ export const DragPreview = ({
|
|
|
30
30
|
marginLeft: `${marginLeft}px`,
|
|
31
31
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
32
32
|
marginTop: `${marginTop}px`,
|
|
33
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
33
34
|
transform: transform
|
|
34
35
|
}
|
|
35
36
|
}));
|
|
@@ -54,8 +54,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
57
|
-
|
|
58
|
-
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
57
|
+
const targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
59
58
|
useEffect(() => {
|
|
60
59
|
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
61
60
|
const {
|
|
@@ -98,14 +98,12 @@ export class ContextualMenu extends Component {
|
|
|
98
98
|
var _node$attrs, _node$attrs2;
|
|
99
99
|
const node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
100
100
|
const background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
101
|
-
let selectedRowIndex;
|
|
102
|
-
let selectedColumnIndex;
|
|
103
101
|
const selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(cellBackgroundColorPalette,
|
|
104
102
|
// Ignored via go/ees005
|
|
105
103
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
106
104
|
background, colorPalletteColumns);
|
|
107
|
-
selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
108
|
-
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
105
|
+
const selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
106
|
+
const selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
109
107
|
return {
|
|
110
108
|
content: isDragAndDropEnabled ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
|
|
111
109
|
value: {
|
|
@@ -462,7 +460,7 @@ export class ContextualMenu extends Component {
|
|
|
462
460
|
return null;
|
|
463
461
|
});
|
|
464
462
|
_defineProperty(this, "createOriginalContextMenuItems", () => {
|
|
465
|
-
|
|
463
|
+
const items = [];
|
|
466
464
|
const sortColumnItems = this.createSortColumnItems();
|
|
467
465
|
const backgroundColorItem = this.createBackgroundColorItem();
|
|
468
466
|
const distributeColumnsItem = this.createDistributeColumnsItem();
|
|
@@ -489,7 +487,7 @@ export class ContextualMenu extends Component {
|
|
|
489
487
|
const deleteRowItem = this.createDeleteRowItem();
|
|
490
488
|
|
|
491
489
|
// Group items so when table.menu.group-items FF is enabled, a divider shows under split cell, above add column
|
|
492
|
-
|
|
490
|
+
const items = [{
|
|
493
491
|
items: []
|
|
494
492
|
}, {
|
|
495
493
|
items: []
|
|
@@ -95,7 +95,7 @@ const MapDragMenuOptionIdToMessage = {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
const getGroupedDragMenuConfig = () => {
|
|
98
|
-
|
|
98
|
+
const groupedDragMenuConfig = [['add_row_above', 'add_row_below', 'add_column_left', 'add_column_right', 'distribute_columns', 'clear_cells', 'delete_row', 'delete_column'], ['move_column_left', 'move_column_right', 'move_row_up', 'move_row_down']];
|
|
99
99
|
const sortColumnItems = ['sort_column_asc', 'sort_column_desc'];
|
|
100
100
|
groupedDragMenuConfig.unshift(sortColumnItems);
|
|
101
101
|
return groupedDragMenuConfig;
|
|
@@ -106,8 +106,8 @@ const elementBeforeIconStyles = xcss({
|
|
|
106
106
|
});
|
|
107
107
|
const convertToDropdownItems = (dragMenuConfig, formatMessage, selectionRect) => {
|
|
108
108
|
const groupedDragMenuConfig = getGroupedDragMenuConfig();
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const menuItemsArr = [...Array(groupedDragMenuConfig.length)].map(() => []);
|
|
110
|
+
const menuCallback = {};
|
|
111
111
|
dragMenuConfig.forEach(item => {
|
|
112
112
|
var _MapDragMenuOptionIdT;
|
|
113
113
|
const menuGroupIndex = groupedDragMenuConfig.findIndex(group => group.includes(item.id));
|
|
@@ -391,7 +391,7 @@ const DragMenu = /*#__PURE__*/React.memo(({
|
|
|
391
391
|
* @returns true when the menu should be closed, false otherwise
|
|
392
392
|
*/
|
|
393
393
|
const shouldCloseMenu = state => {
|
|
394
|
-
|
|
394
|
+
const {
|
|
395
395
|
isDragMenuOpen: previousOpenState,
|
|
396
396
|
dragMenuDirection: previousDragMenuDirection,
|
|
397
397
|
dragMenuIndex: previousDragMenuIndex
|
|
@@ -38,8 +38,8 @@ export const DropdownMenu = ({
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
// more offsets calculation as offsets depend on the direction and updated placement here
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const offsetY = direction === 'row' ? popupPlacement[0] === 'bottom' ? -8 : -34 : 0;
|
|
42
|
+
const offsetX = direction === 'column' ? popupPlacement[1] === 'left' ? 0 : -7 : 0;
|
|
43
43
|
const innerMenu = () => {
|
|
44
44
|
return /*#__PURE__*/React.createElement(DropListWithOutsideListeners, {
|
|
45
45
|
isOpen: true,
|
|
@@ -8,6 +8,7 @@ const tableFullWidthLabelWrapperStyles = xcss({
|
|
|
8
8
|
backgroundColor: 'elevation.surface.overlay',
|
|
9
9
|
borderRadius: 'border.radius',
|
|
10
10
|
boxShadow: 'elevation.shadow.overlay',
|
|
11
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
11
12
|
lineHeight: 1,
|
|
12
13
|
boxSizing: 'border-box',
|
|
13
14
|
alignItems: 'center'
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import rafSchedule from 'raf-schd';
|
|
2
2
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
3
4
|
import { browser, closestElement, isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
7
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
9
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
@@ -140,7 +142,16 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
140
142
|
} = view;
|
|
141
143
|
return hoverColumns([startIndex], false)(state, dispatch);
|
|
142
144
|
}
|
|
143
|
-
|
|
145
|
+
const isNestedTable = getParentOfTypeCount(state.schema.nodes.table)(state.selection.$from) > 1;
|
|
146
|
+
if (isNestedTable) {
|
|
147
|
+
// 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
|
|
148
|
+
const nearestTable = closestElement(target, 'table');
|
|
149
|
+
const nestedTable = findParentNodeOfTypeClosestToPos(state.doc.resolve(state.selection.from), [state.schema.nodes.table]);
|
|
150
|
+
const parentTable = findParentNodeOfTypeClosestToPos(state.doc.resolve((nestedTable === null || nestedTable === void 0 ? void 0 : nestedTable.pos) || 0), [state.schema.nodes.table]);
|
|
151
|
+
if ((nearestTable === null || nearestTable === void 0 ? void 0 : nearestTable.dataset.tableLocalId) !== (parentTable === null || parentTable === void 0 ? void 0 : parentTable.node.attrs.localId)) {
|
|
152
|
+
return hideInsertColumnOrRowButton()(state, dispatch);
|
|
153
|
+
}
|
|
154
|
+
} else if ((isCell(target) || isCornerButton(target)) && (typeof insertColumnButtonIndex === 'number' || typeof insertRowButtonIndex === 'number')) {
|
|
144
155
|
return hideInsertColumnOrRowButton()(state, dispatch);
|
|
145
156
|
}
|
|
146
157
|
if (isResizeHandleDecoration(target)) {
|
|
@@ -361,10 +361,7 @@ export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAP
|
|
|
361
361
|
|
|
362
362
|
// We don't want to show floating toolbar while resizing the table
|
|
363
363
|
const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
364
|
-
|
|
365
|
-
// Hide floating toolbar when resizing column and internal column width is on
|
|
366
|
-
const shouldHideToolbarForInternalColumnWidth = Boolean((options === null || options === void 0 ? void 0 : options.isNewColumnResizingEnabled) && resizeState && resizeState.dragging);
|
|
367
|
-
if (tableObject && pluginState.editorHasFocus && !isWidthResizing && !shouldHideToolbarForInternalColumnWidth) {
|
|
364
|
+
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
368
365
|
const nodeType = state.schema.nodes.table;
|
|
369
366
|
const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
|
|
370
367
|
const isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
|
|
@@ -406,6 +406,7 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
406
406
|
}, {
|
|
407
407
|
key: "onTablePluginState",
|
|
408
408
|
value: function onTablePluginState(state) {
|
|
409
|
+
var _parentContainer$pare, _parentContainer$pare2;
|
|
409
410
|
var tableRef = state.tableRef;
|
|
410
411
|
var tree = getTree(this.dom);
|
|
411
412
|
if (!tree) {
|
|
@@ -430,22 +431,31 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
430
431
|
var wrapper = tree.wrapper;
|
|
431
432
|
var tableContainer = wrapper.parentElement;
|
|
432
433
|
var tableContentWrapper = tableContainer === null || tableContainer === void 0 ? void 0 : tableContainer.parentElement;
|
|
433
|
-
var
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
434
|
+
var parentContainer = tableContentWrapper && tableContentWrapper.parentElement;
|
|
435
|
+
var isTableInsideLayout = parentContainer && parentContainer.getAttribute('data-layout-content');
|
|
436
|
+
var isNestedTable = parentContainer && (parentContainer.className === 'pm-table-header-content-wrap' || parentContainer.className === 'pm-table-cell-content-wrap');
|
|
437
|
+
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');
|
|
438
|
+
var isTableInsideTable = isNestedTable || isNestedDataTable;
|
|
439
|
+
if (tableContentWrapper) {
|
|
440
|
+
if (isCurrentTableSelected) {
|
|
441
|
+
this.colControlsOffset = tableControlsSpacing;
|
|
442
|
+
|
|
437
443
|
// move table a little out of the way
|
|
438
444
|
// to provide spacing for table controls
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
445
|
+
if (isTableInsideLayout) {
|
|
446
|
+
tableContentWrapper.style.paddingLeft = '11px';
|
|
447
|
+
} else if (isTableInsideTable) {
|
|
448
|
+
tableContentWrapper.style.paddingLeft = '15px';
|
|
449
|
+
tableContentWrapper.style.paddingRight = '4px';
|
|
450
|
+
}
|
|
451
|
+
} else {
|
|
452
|
+
this.colControlsOffset = 0;
|
|
453
|
+
if (isTableInsideLayout) {
|
|
454
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
455
|
+
} else if (isTableInsideTable) {
|
|
456
|
+
tableContentWrapper.style.removeProperty('padding-left');
|
|
457
|
+
tableContentWrapper.style.removeProperty('padding-right');
|
|
458
|
+
}
|
|
449
459
|
}
|
|
450
460
|
}
|
|
451
461
|
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
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
|
-
import { ACTION_SUBJECT, CHANGE_ALIGNMENT_REASON, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
5
2
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
6
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
7
4
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
@@ -10,17 +7,15 @@ import { updateResizeHandleDecorations } from '../commands/misc';
|
|
|
10
7
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
11
8
|
import { META_KEYS } from '../table-analytics';
|
|
12
9
|
import { updateColumnWidths } from '../transforms/column-width';
|
|
13
|
-
import { ALIGN_CENTER, ALIGN_START, shouldChangeAlignmentToCenterResized } from '../utils/alignment';
|
|
14
|
-
import { isTableNested } from '../utils/nodes';
|
|
15
10
|
import { getSelectedColumnIndexes } from '../utils/selection';
|
|
16
11
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
17
12
|
import { getPluginState } from './plugin-factory';
|
|
18
13
|
import { TABLE_OFFSET_IN_COMMENT_EDITOR } from './utils/consts';
|
|
19
14
|
import { updateControls } from './utils/dom';
|
|
20
15
|
import { currentColWidth, getTableMaxWidth, pointsAtCell, getScalingPercentForTableWithoutWidth, getTableScalingPercent } from './utils/misc';
|
|
21
|
-
import { resizeColumn
|
|
16
|
+
import { resizeColumn } from './utils/resize-column';
|
|
22
17
|
import { getResizeState } from './utils/resize-state';
|
|
23
|
-
export var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, api, nodeViewPortalProviderAPI, editorAnalyticsAPI,
|
|
18
|
+
export var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isCommentEditor
|
|
24
19
|
// Ignored via go/ees005
|
|
25
20
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
26
21
|
) {
|
|
@@ -30,7 +25,6 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
30
25
|
var editorDisabled = !view.editable;
|
|
31
26
|
var domAtPos = view.domAtPos.bind(view);
|
|
32
27
|
var _getEditorContainerWi = getEditorContainerWidth(),
|
|
33
|
-
lineLength = _getEditorContainerWi.lineLength,
|
|
34
28
|
editorWidth = _getEditorContainerWi.width;
|
|
35
29
|
if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
|
|
36
30
|
return false;
|
|
@@ -112,18 +106,6 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
112
106
|
// When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
|
|
113
107
|
// unnecessary tooltips being displayed during drag.
|
|
114
108
|
updateResizeHandleDecorations(nodeViewPortalProviderAPI, undefined, undefined, false)(state, dispatch);
|
|
115
|
-
|
|
116
|
-
// for new column resizing, take the current scaled version of table widths and use those as the basis for resizing
|
|
117
|
-
// implication: the scaled version of the table becomes the source of truth
|
|
118
|
-
if (isNewColumnResizingEnabled && shouldScale) {
|
|
119
|
-
resizeState = scaleResizeState({
|
|
120
|
-
resizeState: resizeState,
|
|
121
|
-
tableRef: dom,
|
|
122
|
-
tableNode: originalTable,
|
|
123
|
-
editorWidth: editorWidth,
|
|
124
|
-
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
109
|
function finish(event) {
|
|
128
110
|
// Ignored via go/ees005
|
|
129
111
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -172,9 +154,8 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
172
154
|
// For example, if a table col is deleted we won't be able to reliably remap the new widths
|
|
173
155
|
// There may be a more elegant solution to this, to avoid a jarring experience.
|
|
174
156
|
if (table.eq(originalTable)) {
|
|
157
|
+
var _table$attrs;
|
|
175
158
|
var map = TableMap.get(table);
|
|
176
|
-
var totalRowCount = map.height;
|
|
177
|
-
var totalColumnCount = map.width;
|
|
178
159
|
var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
|
|
179
160
|
var selectionRect = getSelectionRect(state.selection);
|
|
180
161
|
var selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
|
|
@@ -186,50 +167,9 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
186
167
|
}
|
|
187
168
|
var resizedDelta = clientX - startX;
|
|
188
169
|
var _shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || isTableScalingEnabled && !!isCommentEditor;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
colIndex: colIndex,
|
|
193
|
-
amount: resizedDelta,
|
|
194
|
-
tableRef: dom,
|
|
195
|
-
tableNode: originalTable,
|
|
196
|
-
width: editorWidth,
|
|
197
|
-
lineLength: lineLength,
|
|
198
|
-
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
199
|
-
});
|
|
200
|
-
tr = updateColumnWidths(newResizeState, table, start, api)(tr);
|
|
201
|
-
|
|
202
|
-
// 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
|
|
203
|
-
var shouldChangeAlignment = shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, originalTable, lineLength, newResizeState.maxSize);
|
|
204
|
-
if (shouldChangeAlignment) {
|
|
205
|
-
tr = tr.setNodeMarkup(start - 1, state.schema.nodes.table, _objectSpread(_objectSpread({}, table.attrs), {}, {
|
|
206
|
-
width: newResizeState.maxSize,
|
|
207
|
-
layout: ALIGN_CENTER
|
|
208
|
-
}));
|
|
209
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
210
|
-
action: TABLE_ACTION.CHANGED_ALIGNMENT,
|
|
211
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
212
|
-
actionSubjectId: null,
|
|
213
|
-
attributes: {
|
|
214
|
-
tableWidth: newResizeState.maxSize,
|
|
215
|
-
newAlignment: ALIGN_CENTER,
|
|
216
|
-
previousAlignment: ALIGN_START,
|
|
217
|
-
totalRowCount: totalRowCount,
|
|
218
|
-
totalColumnCount: totalColumnCount,
|
|
219
|
-
inputMethod: INPUT_METHOD.AUTO,
|
|
220
|
-
reason: CHANGE_ALIGNMENT_REASON.TABLE_COLUMN_RESIZED
|
|
221
|
-
},
|
|
222
|
-
eventType: EVENT_TYPE.TRACK
|
|
223
|
-
})(tr);
|
|
224
|
-
} else {
|
|
225
|
-
tr.setNodeAttribute(start - 1, 'width', newResizeState.maxSize);
|
|
226
|
-
}
|
|
227
|
-
} else {
|
|
228
|
-
var _table$attrs;
|
|
229
|
-
var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs = table.attrs) !== null && _table$attrs !== void 0 && _table$attrs.width) ? getScalingPercentForTableWithoutWidth(originalTable, dom) : getTableScalingPercent(originalTable, dom, _shouldUseIncreasedScalingPercent);
|
|
230
|
-
var _newResizeState = resizeColumn(resizeState, colIndex, resizedDelta, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale, scalePercent);
|
|
231
|
-
tr = updateColumnWidths(_newResizeState, table, start, api)(tr);
|
|
232
|
-
}
|
|
170
|
+
var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs = table.attrs) !== null && _table$attrs !== void 0 && _table$attrs.width) ? getScalingPercentForTableWithoutWidth(originalTable, dom) : getTableScalingPercent(originalTable, dom, _shouldUseIncreasedScalingPercent);
|
|
171
|
+
var newResizeState = resizeColumn(resizeState, colIndex, resizedDelta, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, _shouldScale, scalePercent);
|
|
172
|
+
tr = updateColumnWidths(newResizeState, table, start, api)(tr);
|
|
233
173
|
if (colIndex === map.width - 1) {
|
|
234
174
|
var mouseUpTime = event.timeStamp;
|
|
235
175
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
@@ -273,6 +213,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
273
213
|
}
|
|
274
214
|
}
|
|
275
215
|
function move(event) {
|
|
216
|
+
var _table$attrs2;
|
|
276
217
|
var clientX = event.clientX,
|
|
277
218
|
which = event.which;
|
|
278
219
|
var state = view.state;
|
|
@@ -282,12 +223,11 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
282
223
|
var _getTablePluginState3 = getTablePluginState(state),
|
|
283
224
|
isTableHovered = _getTablePluginState3.isTableHovered;
|
|
284
225
|
var tablePos = state.doc.resolve(start).start(-1);
|
|
285
|
-
if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos)) ||
|
|
226
|
+
if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos)) || !isTableHovered) {
|
|
286
227
|
return finish(event);
|
|
287
228
|
}
|
|
288
229
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
289
230
|
var table = $cell.node(-1);
|
|
290
|
-
// const tablePos = state.doc.resolve(start).start(-1);
|
|
291
231
|
var tableDepth = state.doc.resolve(tablePos).depth;
|
|
292
232
|
var map = TableMap.get(table);
|
|
293
233
|
// Ignored via go/ees005
|
|
@@ -299,22 +239,8 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
299
239
|
shouldScale = shouldScale && originalTable.attrs.displayMode !== 'fixed';
|
|
300
240
|
}
|
|
301
241
|
var resizedDelta = clientX - dragging.startX;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
resizeState: resizeState,
|
|
305
|
-
colIndex: colIndex,
|
|
306
|
-
amount: resizedDelta,
|
|
307
|
-
tableRef: dom,
|
|
308
|
-
tableNode: originalTable,
|
|
309
|
-
width: editorWidth,
|
|
310
|
-
lineLength: lineLength,
|
|
311
|
-
isTableAlignmentEnabled: isTableAlignmentEnabled
|
|
312
|
-
});
|
|
313
|
-
} else {
|
|
314
|
-
var _table$attrs2;
|
|
315
|
-
var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs2 = table.attrs) !== null && _table$attrs2 !== void 0 && _table$attrs2.width) ? getScalingPercentForTableWithoutWidth(table, dom) : getTableScalingPercent(originalTable, dom, shouldUseIncreasedScalingPercent);
|
|
316
|
-
resizeColumn(resizeState, colIndex, resizedDelta, dom, table, undefined, shouldScale, scalePercent);
|
|
317
|
-
}
|
|
242
|
+
var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs2 = table.attrs) !== null && _table$attrs2 !== void 0 && _table$attrs2.width) ? getScalingPercentForTableWithoutWidth(table, dom) : getTableScalingPercent(originalTable, dom, shouldUseIncreasedScalingPercent);
|
|
243
|
+
resizeColumn(resizeState, colIndex, resizedDelta, dom, table, undefined, shouldScale, scalePercent);
|
|
318
244
|
updateControls()(state);
|
|
319
245
|
}
|
|
320
246
|
|
|
@@ -11,7 +11,7 @@ import { getResizeCellPos } from './utils/dom';
|
|
|
11
11
|
|
|
12
12
|
// Ignored via go/ees005
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
14
|
-
export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled,
|
|
14
|
+
export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureFlags, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isTableScalingEnabled, isCommentEditor) {
|
|
15
15
|
var _ref$lastColumnResiza = _ref.lastColumnResizable,
|
|
16
16
|
lastColumnResizable = _ref$lastColumnResiza === void 0 ? true : _ref$lastColumnResiza;
|
|
17
17
|
return new SafePlugin({
|
|
@@ -48,7 +48,7 @@ export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorF
|
|
|
48
48
|
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
49
49
|
}
|
|
50
50
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
|
51
|
-
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, api, nodeViewPortalProviderAPI, editorAnalyticsAPI,
|
|
51
|
+
if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, api, nodeViewPortalProviderAPI, editorAnalyticsAPI, isCommentEditor)) {
|
|
52
52
|
var _state = view.state,
|
|
53
53
|
_dispatch = view.dispatch;
|
|
54
54
|
return setResizeHandlePos(resizeHandlePos)(_state, _dispatch);
|