@atlaskit/editor-plugin-table 8.4.14 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/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/toolbar.js +1 -4
- package/dist/es2019/nodeviews/TableContainer.js +1 -1
- 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/toolbar.js +1 -4
- 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/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 +4 -4
- package/src/nodeviews/TableContainer.tsx +1 -1
- package/src/pm-plugins/commands/column-resize.ts +1 -1
- 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.ts +1 -1
- 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/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/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/toolbar.tsx +1 -11
- package/tsconfig.app.json +0 -1
- package/tsconfig.dev.json +0 -1
|
@@ -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,
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
1
|
// Resize a given column by an amount from the current state
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import { TableCssClassName as ClassName } from '../../../types';
|
|
8
|
-
import { ALIGN_CENTER, ALIGN_START, shouldChangeAlignmentToCenterResized } from '../../utils/alignment';
|
|
9
|
-
import { getTableScalingPercent } from './misc';
|
|
10
|
-
import { growColumn, shrinkColumn, updateAffectedColumn } from './resize-logic';
|
|
2
|
+
|
|
3
|
+
import { growColumn, shrinkColumn } from './resize-logic';
|
|
11
4
|
import { updateColgroup } from './resize-state';
|
|
12
5
|
export var resizeColumn = function resizeColumn(resizeState, colIndex, amount, tableRef, tableNode, selectedColumns) {
|
|
13
6
|
var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
@@ -19,138 +12,4 @@ export var resizeColumn = function resizeColumn(resizeState, colIndex, amount, t
|
|
|
19
12
|
var newState = resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
|
|
20
13
|
updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled, scalePercent);
|
|
21
14
|
return newState;
|
|
22
|
-
};
|
|
23
|
-
export var resizeColumnAndTable = function resizeColumnAndTable(_ref) {
|
|
24
|
-
var resizeState = _ref.resizeState,
|
|
25
|
-
colIndex = _ref.colIndex,
|
|
26
|
-
amount = _ref.amount,
|
|
27
|
-
tableRef = _ref.tableRef,
|
|
28
|
-
tableNode = _ref.tableNode,
|
|
29
|
-
lineLength = _ref.lineLength,
|
|
30
|
-
editorWidth = _ref.width,
|
|
31
|
-
isTableAlignmentEnabled = _ref.isTableAlignmentEnabled;
|
|
32
|
-
var editorContainerWidth = getEditorContainerWidth(editorWidth);
|
|
33
|
-
var isTableLeftAligned = tableNode.attrs.layout === ALIGN_START;
|
|
34
|
-
var isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
35
|
-
var isOverflow = resizeState.tableWidth > resizeState.maxSize;
|
|
36
|
-
var resizeAmount = isTableLeftAligned ? amount : amount * 2;
|
|
37
|
-
var willTableHitEditorEdge = resizeState.maxSize + resizeAmount > editorContainerWidth;
|
|
38
|
-
var willResizedTableStayInOverflow = isOverflow && resizeState.tableWidth + resizeAmount / 2 > resizeState.maxSize;
|
|
39
|
-
|
|
40
|
-
// STEP 1: Update col width
|
|
41
|
-
if (willTableHitEditorEdge || willResizedTableStayInOverflow) {
|
|
42
|
-
var _tableRef$closest;
|
|
43
|
-
var tableContainerWidth = (_tableRef$closest = tableRef.closest('.pm-table-container')) === null || _tableRef$closest === void 0 ? void 0 : _tableRef$closest.clientWidth;
|
|
44
|
-
resizeAmount = amount < 0 ? amount :
|
|
45
|
-
// Ignored via go/ees005
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
47
|
-
resizeAmount - (resizeState.maxSize + resizeAmount - tableContainerWidth) / 2;
|
|
48
|
-
} else {
|
|
49
|
-
var diff = -(resizeState.tableWidth - resizeState.maxSize);
|
|
50
|
-
var rest = amount - diff;
|
|
51
|
-
var final = isTableLeftAligned ? diff + rest : diff + rest * 2;
|
|
52
|
-
resizeAmount = final;
|
|
53
|
-
}
|
|
54
|
-
var newState = updateAffectedColumn(resizeState, colIndex, resizeAmount);
|
|
55
|
-
|
|
56
|
-
// STEP 2: Update table container width
|
|
57
|
-
// columns have a min width, so delta !== resizeAmount when this is reached, use this for calculations
|
|
58
|
-
var delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
|
|
59
|
-
newState.maxSize = Math.round(isOverflow ? willResizedTableStayInOverflow ?
|
|
60
|
-
// CASE 1A: table will stay in overflow
|
|
61
|
-
// do not grow the table because resize is happening in the overflow region
|
|
62
|
-
// and the overall table container needs to be retained
|
|
63
|
-
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth : resizeState.maxSize :
|
|
64
|
-
// CASE 1B: table will no longer be in overflow, so adjust container width
|
|
65
|
-
// ensure the table is resized without any 'big jumps' by working out
|
|
66
|
-
// the difference between the new table width and the max size and adding the resize
|
|
67
|
-
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth + (resizeState.tableWidth - resizeState.maxSize + akEditorTableNumberColumnWidth + delta) : resizeState.maxSize + (resizeState.tableWidth - resizeState.maxSize + delta) : willTableHitEditorEdge ?
|
|
68
|
-
// CASE 2: table will hit editor edge
|
|
69
|
-
editorContainerWidth :
|
|
70
|
-
// CASE 3: table is being resized from a non-overflow state
|
|
71
|
-
isNumberColumnEnabled ? resizeState.maxSize + akEditorTableNumberColumnWidth + delta : resizeState.maxSize + delta);
|
|
72
|
-
|
|
73
|
-
// do not apply scaling logic because resize state is already scaled
|
|
74
|
-
updateColgroup(newState, tableRef, tableNode, false, 1);
|
|
75
|
-
updateTablePreview(tableRef, newState.maxSize, shouldChangeAlignmentToCenterResized(isTableAlignmentEnabled, tableNode, lineLength, newState.maxSize));
|
|
76
|
-
return newState;
|
|
77
|
-
};
|
|
78
|
-
var updateTablePreview = function updateTablePreview(tableRef, newTableWidth, shouldChangeAlignment) {
|
|
79
|
-
var resizingContainer = tableRef.closest(".".concat(ClassName.TABLE_RESIZER_CONTAINER));
|
|
80
|
-
var resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
|
|
81
|
-
var alignmentContainer = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.parentElement;
|
|
82
|
-
if (resizingItem) {
|
|
83
|
-
var newWidth = "".concat(newTableWidth, "px");
|
|
84
|
-
// Ignored via go/ees005
|
|
85
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
86
|
-
resizingContainer.style.width = newWidth;
|
|
87
|
-
// Ignored via go/ees005
|
|
88
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
89
|
-
resizingItem.style.width = newWidth;
|
|
90
|
-
if (shouldChangeAlignment && alignmentContainer) {
|
|
91
|
-
alignmentContainer.style.justifyContent = ALIGN_CENTER;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var getEditorContainerWidth = function getEditorContainerWidth(editorWidth) {
|
|
96
|
-
return Math.min(editorWidth - akEditorGutterPaddingDynamic() * 2, akEditorFullWidthLayoutWidth);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Apply a scaling factor to resize state
|
|
101
|
-
*/
|
|
102
|
-
export var scaleResizeState = function scaleResizeState(_ref2) {
|
|
103
|
-
var resizeState = _ref2.resizeState,
|
|
104
|
-
tableRef = _ref2.tableRef,
|
|
105
|
-
tableNode = _ref2.tableNode,
|
|
106
|
-
editorWidth = _ref2.editorWidth,
|
|
107
|
-
shouldUseIncreasedScalingPercent = _ref2.shouldUseIncreasedScalingPercent;
|
|
108
|
-
var isNumberColumnEnabled = tableNode.attrs.isNumberColumnEnabled;
|
|
109
|
-
var isTableScaled = isNumberColumnEnabled || resizeState.maxSize > getEditorContainerWidth(editorWidth);
|
|
110
|
-
|
|
111
|
-
// Tables with number column can cause the table to be in two different states:
|
|
112
|
-
// 1. The table sum of col widths will be smaller than the max size, which is incorrect. For this
|
|
113
|
-
// avoid scaling and take the document width
|
|
114
|
-
// 2. The table sum of col widths will be the same size as max width, which happens when the table
|
|
115
|
-
// is scaled using preserve table width logic, for this apply a scaled width
|
|
116
|
-
// return early if table isn't scaled
|
|
117
|
-
if (!isTableScaled || isNumberColumnEnabled && resizeState.maxSize > resizeState.tableWidth) {
|
|
118
|
-
return resizeState;
|
|
119
|
-
}
|
|
120
|
-
var scalePercent = getTableScalingPercent(tableNode, tableRef, shouldUseIncreasedScalingPercent);
|
|
121
|
-
var scaledTableWidth = Math.round(resizeState.tableWidth * scalePercent);
|
|
122
|
-
var cols = resizeState.cols.map(function (col) {
|
|
123
|
-
return _objectSpread(_objectSpread({}, col), {}, {
|
|
124
|
-
minWidth: tableCellMinWidth,
|
|
125
|
-
width: Math.max(Math.round(col.width * scalePercent), tableCellMinWidth)
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
var calculatedTableWidth = cols.reduce(function (prev, curr) {
|
|
129
|
-
return prev + curr.width;
|
|
130
|
-
}, 0);
|
|
131
|
-
|
|
132
|
-
// using Math.round can cause the sum of col widths to be larger than the table width
|
|
133
|
-
// distribute the difference to the first column
|
|
134
|
-
if (calculatedTableWidth > scaledTableWidth) {
|
|
135
|
-
var diff = calculatedTableWidth - scaledTableWidth;
|
|
136
|
-
var hasDiffBeenDistributed = false;
|
|
137
|
-
cols = cols.map(function (col) {
|
|
138
|
-
if (!hasDiffBeenDistributed && col.width - diff >= col.minWidth) {
|
|
139
|
-
hasDiffBeenDistributed = true;
|
|
140
|
-
return _objectSpread(_objectSpread({}, col), {}, {
|
|
141
|
-
width: col.width - diff
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return col;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
var maxSize = isNumberColumnEnabled ? Math.round((resizeState.maxSize + akEditorTableNumberColumnWidth) * scalePercent) : Math.round(resizeState.maxSize * scalePercent);
|
|
148
|
-
return _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
149
|
-
widths: cols.map(function (col) {
|
|
150
|
-
return col.width;
|
|
151
|
-
}),
|
|
152
|
-
tableWidth: scaledTableWidth,
|
|
153
|
-
maxSize: maxSize,
|
|
154
|
-
cols: cols
|
|
155
|
-
});
|
|
156
15
|
};
|
|
@@ -332,7 +332,6 @@ export var getNewResizeStateFromSelectedColumns = function getNewResizeStateFrom
|
|
|
332
332
|
layout: layout,
|
|
333
333
|
getEditorContainerWidth: getEditorContainerWidth
|
|
334
334
|
});
|
|
335
|
-
var resizeState;
|
|
336
335
|
var isTableScalingEnabledOnCurrentTable = isTableScalingEnabled;
|
|
337
336
|
var isTableScalingWithFixedColumnWidthsOptionEnabled = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled;
|
|
338
337
|
if (isTableScalingWithFixedColumnWidthsOptionEnabled) {
|
|
@@ -343,7 +342,7 @@ export var getNewResizeStateFromSelectedColumns = function getNewResizeStateFrom
|
|
|
343
342
|
isTableScalingEnabledOnCurrentTable = true;
|
|
344
343
|
shouldUseIncreasedScalingPercent = true;
|
|
345
344
|
}
|
|
346
|
-
resizeState = getResizeState({
|
|
345
|
+
var resizeState = getResizeState({
|
|
347
346
|
minWidth: tableCellMinWidth,
|
|
348
347
|
maxSize: maxSize,
|
|
349
348
|
table: table.node,
|
|
@@ -67,6 +67,9 @@ export var toggleSort = function toggleSort(view, event, pluginState) {
|
|
|
67
67
|
if (!tableId || !tableNode || (tableNode === null || tableNode === void 0 || (_tableNode$type = tableNode.type) === null || _tableNode$type === void 0 ? void 0 : _tableNode$type.name) !== 'table') {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
+
|
|
71
|
+
// Ignored via go/ees005
|
|
72
|
+
// eslint-disable-next-line prefer-const
|
|
70
73
|
var _ref = (pluginState === null || pluginState === void 0 ? void 0 : pluginState[tableId]) || {},
|
|
71
74
|
index = _ref.index,
|
|
72
75
|
direction = _ref.direction,
|
package/dist/esm/tablePlugin.js
CHANGED
|
@@ -247,14 +247,12 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
247
247
|
fullWidthEnabled = _ref5.fullWidthEnabled,
|
|
248
248
|
tableOptions = _ref5.tableOptions,
|
|
249
249
|
getEditorFeatureFlags = _ref5.getEditorFeatureFlags,
|
|
250
|
-
isTableScalingEnabled = _ref5.isTableScalingEnabled
|
|
251
|
-
isNewColumnResizingEnabled = _ref5.isNewColumnResizingEnabled;
|
|
250
|
+
isTableScalingEnabled = _ref5.isTableScalingEnabled;
|
|
252
251
|
var _pluginConfig2 = pluginConfig(tableOptions),
|
|
253
|
-
allowColumnResizing = _pluginConfig2.allowColumnResizing
|
|
254
|
-
allowTableAlignment = _pluginConfig2.allowTableAlignment;
|
|
252
|
+
allowColumnResizing = _pluginConfig2.allowColumnResizing;
|
|
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',
|
|
@@ -29,6 +29,7 @@ export var DragPreview = function DragPreview(_ref) {
|
|
|
29
29
|
marginLeft: "".concat(marginLeft, "px"),
|
|
30
30
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
31
31
|
marginTop: "".concat(marginTop, "px"),
|
|
32
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
32
33
|
transform: transform
|
|
33
34
|
}
|
|
34
35
|
}));
|
|
@@ -48,8 +48,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
51
|
-
var targetCellRef;
|
|
52
|
-
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
51
|
+
var targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
53
52
|
useEffect(function () {
|
|
54
53
|
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
55
54
|
var state = editorView.state,
|
|
@@ -105,14 +105,12 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
105
105
|
var _node$attrs, _node$attrs2;
|
|
106
106
|
var node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
107
107
|
var background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
108
|
-
var selectedRowIndex;
|
|
109
|
-
var selectedColumnIndex;
|
|
110
108
|
var selectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette(cellBackgroundColorPalette,
|
|
111
109
|
// Ignored via go/ees005
|
|
112
110
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
113
111
|
background, colorPalletteColumns);
|
|
114
|
-
selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
115
|
-
selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
112
|
+
var selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
113
|
+
var selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
116
114
|
return {
|
|
117
115
|
content: isDragAndDropEnabled ? formatMessage(messages.backgroundColor) : formatMessage(messages.cellBackground),
|
|
118
116
|
value: {
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -365,10 +365,7 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
365
365
|
|
|
366
366
|
// We don't want to show floating toolbar while resizing the table
|
|
367
367
|
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
368
|
-
|
|
369
|
-
// Hide floating toolbar when resizing column and internal column width is on
|
|
370
|
-
var shouldHideToolbarForInternalColumnWidth = Boolean((options === null || options === void 0 ? void 0 : options.isNewColumnResizingEnabled) && resizeState && resizeState.dragging);
|
|
371
|
-
if (tableObject && pluginState.editorHasFocus && !isWidthResizing && !shouldHideToolbarForInternalColumnWidth) {
|
|
368
|
+
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
372
369
|
var nodeType = state.schema.nodes.table;
|
|
373
370
|
var isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
|
|
374
371
|
var isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingEnabled && isTableFixedColumnWidthsOptionEnabled && !isNested;
|
|
@@ -3,4 +3,4 @@ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
|
3
3
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { PluginInjectionAPI } from '../../types';
|
|
6
|
-
export declare const handleMouseDown: (view: EditorView, event: MouseEvent, localResizeHandlePos: number, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, isTableScalingEnabled: boolean, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
6
|
+
export declare const handleMouseDown: (view: EditorView, event: MouseEvent, localResizeHandlePos: number, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, isTableScalingEnabled: boolean, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI, isCommentEditor?: boolean) => boolean;
|
|
@@ -4,4 +4,4 @@ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
6
6
|
import type { ColumnResizingPluginState, PluginInjectionAPI } from '../../types';
|
|
7
|
-
export declare function createPlugin(dispatch: Dispatch<ColumnResizingPluginState>, { lastColumnResizable }: ColumnResizingPluginState, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI, isTableScalingEnabled?: boolean,
|
|
7
|
+
export declare function createPlugin(dispatch: Dispatch<ColumnResizingPluginState>, { lastColumnResizable }: ColumnResizingPluginState, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI, isTableScalingEnabled?: boolean, isCommentEditor?: boolean): SafePlugin<ColumnResizingPluginState>;
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
import { type EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
2
1
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
2
|
import type { ResizeState } from './types';
|
|
4
3
|
export declare const resizeColumn: (resizeState: ResizeState, colIndex: number, amount: number, tableRef: HTMLElement | null, tableNode: PmNode, selectedColumns?: number[], isTableScalingEnabled?: boolean, scalePercent?: number) => ResizeState;
|
|
5
|
-
type ResizeInformation = {
|
|
6
|
-
resizeState: ResizeState;
|
|
7
|
-
colIndex: number;
|
|
8
|
-
amount: number;
|
|
9
|
-
};
|
|
10
|
-
type TableReferences = {
|
|
11
|
-
tableRef: HTMLElement;
|
|
12
|
-
tableNode: PmNode;
|
|
13
|
-
};
|
|
14
|
-
type TableResizingPluginOptions = {
|
|
15
|
-
isTableAlignmentEnabled?: boolean;
|
|
16
|
-
};
|
|
17
|
-
type ResizeColumnAndTable = ResizeInformation & TableResizingPluginOptions & TableReferences & EditorContainerWidth;
|
|
18
|
-
export declare const resizeColumnAndTable: ({ resizeState, colIndex, amount, tableRef, tableNode, lineLength, width: editorWidth, isTableAlignmentEnabled, }: ResizeColumnAndTable) => ResizeState;
|
|
19
|
-
/**
|
|
20
|
-
* Apply a scaling factor to resize state
|
|
21
|
-
*/
|
|
22
|
-
export declare const scaleResizeState: ({ resizeState, tableRef, tableNode, editorWidth, shouldUseIncreasedScalingPercent, }: TableReferences & {
|
|
23
|
-
resizeState: ResizeState;
|
|
24
|
-
editorWidth: number;
|
|
25
|
-
shouldUseIncreasedScalingPercent: boolean;
|
|
26
|
-
}) => ResizeState;
|
|
27
|
-
export {};
|
|
@@ -3,4 +3,4 @@ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
|
3
3
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { PluginInjectionAPI } from '../../types';
|
|
6
|
-
export declare const handleMouseDown: (view: EditorView, event: MouseEvent, localResizeHandlePos: number, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, isTableScalingEnabled: boolean, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI,
|
|
6
|
+
export declare const handleMouseDown: (view: EditorView, event: MouseEvent, localResizeHandlePos: number, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, isTableScalingEnabled: boolean, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI, isCommentEditor?: boolean) => boolean;
|
|
@@ -4,4 +4,4 @@ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
6
6
|
import type { ColumnResizingPluginState, PluginInjectionAPI } from '../../types';
|
|
7
|
-
export declare function createPlugin(dispatch: Dispatch<ColumnResizingPluginState>, { lastColumnResizable }: ColumnResizingPluginState, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI, isTableScalingEnabled?: boolean,
|
|
7
|
+
export declare function createPlugin(dispatch: Dispatch<ColumnResizingPluginState>, { lastColumnResizable }: ColumnResizingPluginState, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI, isTableScalingEnabled?: boolean, isCommentEditor?: boolean): SafePlugin<ColumnResizingPluginState>;
|