@atlaskit/editor-plugin-table 22.1.3 → 22.2.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 +20 -0
- package/dist/cjs/nodeviews/TableComponent.js +6 -5
- package/dist/cjs/nodeviews/table-node-views.js +1 -2
- package/dist/cjs/pm-plugins/commands/column-resize.js +2 -3
- package/dist/cjs/pm-plugins/commands/hover.js +6 -14
- package/dist/cjs/pm-plugins/commands/misc.js +13 -17
- package/dist/cjs/pm-plugins/decorations/plugin.js +2 -10
- package/dist/cjs/pm-plugins/decorations/utils/column-controls.js +9 -26
- package/dist/cjs/pm-plugins/utils/decoration.js +6 -10
- package/dist/cjs/pm-plugins/utils/sticky-header.js +2 -2
- package/dist/cjs/pm-plugins/utils/tableMode.js +52 -20
- package/dist/cjs/tablePlugin.js +1 -2
- package/dist/cjs/ui/FloatingContextualButton/index.js +1 -2
- package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -15
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/es2019/nodeviews/TableComponent.js +6 -5
- package/dist/es2019/nodeviews/table-node-views.js +1 -2
- package/dist/es2019/pm-plugins/commands/column-resize.js +2 -3
- package/dist/es2019/pm-plugins/commands/hover.js +4 -16
- package/dist/es2019/pm-plugins/commands/misc.js +1 -6
- package/dist/es2019/pm-plugins/decorations/plugin.js +2 -9
- package/dist/es2019/pm-plugins/decorations/utils/column-controls.js +3 -21
- package/dist/es2019/pm-plugins/utils/decoration.js +6 -10
- package/dist/es2019/pm-plugins/utils/sticky-header.js +2 -2
- package/dist/es2019/pm-plugins/utils/tableMode.js +46 -18
- package/dist/es2019/tablePlugin.js +1 -2
- package/dist/es2019/ui/FloatingContextualButton/index.js +1 -2
- package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -15
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +6 -5
- package/dist/esm/nodeviews/table-node-views.js +1 -2
- package/dist/esm/pm-plugins/commands/column-resize.js +2 -3
- package/dist/esm/pm-plugins/commands/hover.js +6 -14
- package/dist/esm/pm-plugins/commands/misc.js +14 -18
- package/dist/esm/pm-plugins/decorations/plugin.js +2 -10
- package/dist/esm/pm-plugins/decorations/utils/column-controls.js +10 -27
- package/dist/esm/pm-plugins/utils/decoration.js +6 -10
- package/dist/esm/pm-plugins/utils/sticky-header.js +2 -2
- package/dist/esm/pm-plugins/utils/tableMode.js +51 -19
- package/dist/esm/tablePlugin.js +1 -2
- package/dist/esm/ui/FloatingContextualButton/index.js +1 -2
- package/dist/esm/ui/FloatingContextualMenu/index.js +2 -15
- package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/types/pm-plugins/decorations/utils/column-controls.d.ts +2 -2
- package/dist/types/pm-plugins/decorations/utils/types.d.ts +1 -7
- package/dist/types/pm-plugins/utils/decoration.d.ts +2 -2
- package/dist/types/pm-plugins/utils/sticky-header.d.ts +1 -1
- package/dist/types/pm-plugins/utils/tableMode.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/decorations/utils/column-controls.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/decorations/utils/types.d.ts +1 -7
- package/dist/types-ts4.5/pm-plugins/utils/decoration.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/utils/sticky-header.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/tableMode.d.ts +7 -0
- package/package.json +5 -5
|
@@ -16,8 +16,6 @@ export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr
|
|
|
16
16
|
var isResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
17
17
|
var wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
|
|
18
18
|
var _ref = tablePluginKey.getState(newState) || {},
|
|
19
|
-
_ref$isDragAndDropEna = _ref.isDragAndDropEnabled,
|
|
20
|
-
isDragAndDropEnabled = _ref$isDragAndDropEna === void 0 ? false : _ref$isDragAndDropEna,
|
|
21
19
|
isInDanger = _ref.isInDanger,
|
|
22
20
|
isTableHovered = _ref.isTableHovered;
|
|
23
21
|
var changedResizing = isResizing !== wasResizing;
|
|
@@ -28,10 +26,7 @@ export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr
|
|
|
28
26
|
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing) {
|
|
29
27
|
return buildColumnControlsDecorations({
|
|
30
28
|
decorationSet: decorationSet,
|
|
31
|
-
tr: tr
|
|
32
|
-
options: {
|
|
33
|
-
isDragAndDropEnabled: isDragAndDropEnabled
|
|
34
|
-
}
|
|
29
|
+
tr: tr
|
|
35
30
|
});
|
|
36
31
|
} else if (tr.selectionSet) {
|
|
37
32
|
var _findTable, _findTable2;
|
|
@@ -46,10 +41,7 @@ export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr
|
|
|
46
41
|
if ((isInDanger || isTableHovered) && (!insideTable(newState) || ((_findTable = findTable(newState.selection)) === null || _findTable === void 0 ? void 0 : _findTable.node) !== ((_findTable2 = findTable(oldState.selection)) === null || _findTable2 === void 0 ? void 0 : _findTable2.node))) {
|
|
47
42
|
return buildColumnControlsDecorations({
|
|
48
43
|
decorationSet: decorationSet,
|
|
49
|
-
tr: tr
|
|
50
|
-
options: {
|
|
51
|
-
isDragAndDropEnabled: isDragAndDropEnabled
|
|
52
|
-
}
|
|
44
|
+
tr: tr
|
|
53
45
|
});
|
|
54
46
|
}
|
|
55
47
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
2
2
|
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
4
|
import { TableDecorations } from '../../../types';
|
|
6
|
-
import {
|
|
5
|
+
import { createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../utils/decoration';
|
|
7
6
|
import { composeDecorations } from './compose-decorations';
|
|
8
7
|
var isColumnSelected = function isColumnSelected(tr) {
|
|
9
8
|
return tr.selection instanceof CellSelection && tr.selection.isColSelection();
|
|
@@ -22,27 +21,18 @@ var maybeUpdateColumnSelectedDecoration = function maybeUpdateColumnSelectedDeco
|
|
|
22
21
|
}
|
|
23
22
|
return updateDecorations(tr.doc, decorationSet, createColumnSelectedDecoration(tr), TableDecorations.COLUMN_SELECTED);
|
|
24
23
|
};
|
|
25
|
-
var maybeUpdateColumnControlsDecoration = function maybeUpdateColumnControlsDecoration(_ref3) {
|
|
26
|
-
var decorationSet = _ref3.decorationSet,
|
|
27
|
-
tr = _ref3.tr;
|
|
28
|
-
var table = findTable(tr.selection);
|
|
29
|
-
if (!table) {
|
|
30
|
-
return decorationSet;
|
|
31
|
-
}
|
|
32
|
-
return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
|
|
33
|
-
};
|
|
34
24
|
|
|
35
25
|
// @see: https://product-fabric.atlassian.net/browse/ED-7304
|
|
36
|
-
var removeColumnControlsSelectedDecoration = function removeColumnControlsSelectedDecoration(
|
|
37
|
-
var decorationSet =
|
|
26
|
+
var removeColumnControlsSelectedDecoration = function removeColumnControlsSelectedDecoration(_ref3) {
|
|
27
|
+
var decorationSet = _ref3.decorationSet;
|
|
38
28
|
return decorationSet.remove(findColumnControlSelectedDecoration(decorationSet));
|
|
39
29
|
};
|
|
40
30
|
var hasColumnSelectedDecorations = function hasColumnSelectedDecorations(decorationSet) {
|
|
41
31
|
return !!findColumnControlSelectedDecoration(decorationSet).length;
|
|
42
32
|
};
|
|
43
|
-
export var maybeUpdateColumnControlsSelectedDecoration = function maybeUpdateColumnControlsSelectedDecoration(
|
|
44
|
-
var decorationSet =
|
|
45
|
-
tr =
|
|
33
|
+
export var maybeUpdateColumnControlsSelectedDecoration = function maybeUpdateColumnControlsSelectedDecoration(_ref4) {
|
|
34
|
+
var decorationSet = _ref4.decorationSet,
|
|
35
|
+
tr = _ref4.tr;
|
|
46
36
|
if (!hasColumnSelectedDecorations(decorationSet)) {
|
|
47
37
|
return decorationSet;
|
|
48
38
|
}
|
|
@@ -51,17 +41,10 @@ export var maybeUpdateColumnControlsSelectedDecoration = function maybeUpdateCol
|
|
|
51
41
|
tr: tr
|
|
52
42
|
});
|
|
53
43
|
};
|
|
54
|
-
export var buildColumnControlsDecorations = function buildColumnControlsDecorations(
|
|
55
|
-
var decorationSet =
|
|
56
|
-
tr =
|
|
57
|
-
|
|
58
|
-
if (options.isDragAndDropEnabled) {
|
|
59
|
-
return composeDecorations([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration])({
|
|
60
|
-
decorationSet: decorationSet,
|
|
61
|
-
tr: tr
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return composeDecorations([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration, maybeUpdateColumnControlsDecoration])({
|
|
44
|
+
export var buildColumnControlsDecorations = function buildColumnControlsDecorations(_ref5) {
|
|
45
|
+
var decorationSet = _ref5.decorationSet,
|
|
46
|
+
tr = _ref5.tr;
|
|
47
|
+
return composeDecorations([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration])({
|
|
65
48
|
decorationSet: decorationSet,
|
|
66
49
|
tr: tr
|
|
67
50
|
});
|
|
@@ -33,7 +33,7 @@ export var createCellHoverDecoration = function createCellHoverDecoration(cells)
|
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
|
-
export var createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr,
|
|
36
|
+
export var createControlsHoverDecoration = function createControlsHoverDecoration(cells, type, tr, hoveredIndexes, danger, selected) {
|
|
37
37
|
var table = findTable(tr.selection);
|
|
38
38
|
if (!table) {
|
|
39
39
|
return [];
|
|
@@ -85,13 +85,9 @@ export var createControlsHoverDecoration = function createControlsHoverDecoratio
|
|
|
85
85
|
if (selected) {
|
|
86
86
|
classes.push(ClassName.SELECTED_CELL);
|
|
87
87
|
}
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
classes.push(ClassName.HOVERED_NO_HIGHLIGHT);
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
|
|
88
|
+
if (type === 'column' || type === 'row') {
|
|
89
|
+
classes.pop();
|
|
90
|
+
classes.push(ClassName.HOVERED_NO_HIGHLIGHT);
|
|
95
91
|
}
|
|
96
92
|
var key;
|
|
97
93
|
switch (type) {
|
|
@@ -392,7 +388,7 @@ export var createResizeHandleDecoration = function createResizeHandleDecoration(
|
|
|
392
388
|
* this function will return two decorations applying a new class `ClassName.WITH_RESIZE_LINE`
|
|
393
389
|
* only on the cells: `C1` and `D1`.
|
|
394
390
|
*/
|
|
395
|
-
export var createColumnLineResize = function createColumnLineResize(selection, cellColumnPositioning
|
|
391
|
+
export var createColumnLineResize = function createColumnLineResize(selection, cellColumnPositioning) {
|
|
396
392
|
var table = findTable(selection);
|
|
397
393
|
if (!table || cellColumnPositioning.right === null) {
|
|
398
394
|
return [];
|
|
@@ -403,7 +399,7 @@ export var createColumnLineResize = function createColumnLineResize(selection, c
|
|
|
403
399
|
if (isLastColumn) {
|
|
404
400
|
columnIndex -= 1;
|
|
405
401
|
}
|
|
406
|
-
var decorationClassName =
|
|
402
|
+
var decorationClassName = isLastColumn ? ClassName.WITH_DRAG_RESIZE_LINE_LAST_COLUMN : ClassName.WITH_DRAG_RESIZE_LINE;
|
|
407
403
|
var cellPositions = makeArray(map.height).map(function (rowIndex) {
|
|
408
404
|
return map.map[map.width * rowIndex + columnIndex];
|
|
409
405
|
}).filter(function (cellPosition, rowIndex) {
|
|
@@ -6,11 +6,11 @@ export var isAnchorSupported = memorizeOne(function () {
|
|
|
6
6
|
}
|
|
7
7
|
return false;
|
|
8
8
|
});
|
|
9
|
-
export var isNativeStickySupported = function isNativeStickySupported(
|
|
9
|
+
export var isNativeStickySupported = function isNativeStickySupported() {
|
|
10
10
|
var safariVersion = getBrowserInfo().safari_version;
|
|
11
11
|
var isBrowserSafari = !Number.isNaN(safariVersion);
|
|
12
12
|
return (
|
|
13
13
|
// Safari has a bug with position: sticky and content editable, so we don't support it
|
|
14
|
-
!isBrowserSafari && isAnchorSupported()
|
|
14
|
+
!isBrowserSafari && isAnchorSupported()
|
|
15
15
|
);
|
|
16
16
|
};
|
|
@@ -72,42 +72,74 @@ export var applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTable
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
76
|
+
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
77
|
+
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
76
78
|
*/
|
|
77
|
-
export var
|
|
78
|
-
var _api$analytics, _api$width$sharedStat, _api$width;
|
|
79
|
-
var tableObject = findTable(view.state.selection);
|
|
80
|
-
if (!tableObject) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
var node = tableObject.node,
|
|
84
|
-
pos = tableObject.pos;
|
|
85
|
-
var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
86
|
-
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
var tableRef = tableState.tableRef;
|
|
90
|
-
|
|
91
|
-
// Instead of dispatching a transaction to "strip widths" and then waiting
|
|
92
|
-
// for a rAF to measure natural column widths, instea directly update the DOM elements and
|
|
93
|
-
// take a measurement.
|
|
79
|
+
export var measureTableWithAutoLayout = function measureTableWithAutoLayout(tableRef) {
|
|
94
80
|
var cols = Array.from(tableRef.querySelectorAll(':scope > colgroup > col'));
|
|
95
81
|
var contentWrap = tableRef.closest(".".concat(TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP));
|
|
96
82
|
var resizerContainer = contentWrap === null || contentWrap === void 0 ? void 0 : contentWrap.querySelector(".".concat(TableSharedCssClassName.TABLE_RESIZER_CONTAINER));
|
|
97
83
|
var resizerItem = resizerContainer === null || resizerContainer === void 0 ? void 0 : resizerContainer.querySelector('.resizer-item.display-handle');
|
|
84
|
+
|
|
85
|
+
// Capture current inline styles so we can restore them after measurement
|
|
86
|
+
var prevTableWidth = tableRef.style.width;
|
|
87
|
+
var prevTableLayout = tableRef.style.tableLayout;
|
|
88
|
+
var prevColWidths = cols.map(function (col) {
|
|
89
|
+
return col.style.width;
|
|
90
|
+
});
|
|
91
|
+
var prevResizerItemWidth = resizerItem === null || resizerItem === void 0 ? void 0 : resizerItem.style.width;
|
|
92
|
+
|
|
93
|
+
// Apply temporary styles for content-based measurement
|
|
98
94
|
tableRef.style.width = '';
|
|
99
95
|
tableRef.style.tableLayout = 'auto';
|
|
100
96
|
cols.forEach(function (col) {
|
|
101
97
|
return col.style.width = '';
|
|
102
98
|
});
|
|
103
99
|
if (resizerContainer) {
|
|
104
|
-
|
|
100
|
+
// favour CSS var to align with the table first render state, which gets reset
|
|
101
|
+
// once resized by user. By doing this we avoid the need to any 'reset' work after
|
|
102
|
+
// measurement and ensures it works if the table has been resized or not in the session.
|
|
103
|
+
resizerContainer.style.width = 'var(--ak-editor-table-width)';
|
|
105
104
|
resizerContainer.style.setProperty('--ak-editor-table-width', 'max-content');
|
|
106
105
|
}
|
|
107
106
|
if (resizerItem) {
|
|
108
107
|
resizerItem.style.width = 'max-content';
|
|
109
108
|
}
|
|
110
109
|
var measurement = getTableMeasurement(tableRef);
|
|
110
|
+
|
|
111
|
+
// Reset all inline styles back to their previous values
|
|
112
|
+
tableRef.style.width = prevTableWidth;
|
|
113
|
+
tableRef.style.tableLayout = prevTableLayout;
|
|
114
|
+
cols.forEach(function (col, i) {
|
|
115
|
+
return col.style.width = prevColWidths[i];
|
|
116
|
+
});
|
|
117
|
+
if (resizerItem) {
|
|
118
|
+
resizerItem.style.width = prevResizerItemWidth !== null && prevResizerItemWidth !== void 0 ? prevResizerItemWidth : '';
|
|
119
|
+
}
|
|
120
|
+
return measurement;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
125
|
+
*/
|
|
126
|
+
export var applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
|
|
127
|
+
var _api$analytics, _api$width$sharedStat, _api$width;
|
|
128
|
+
var tableObject = findTable(view.state.selection);
|
|
129
|
+
if (!tableObject) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
var node = tableObject.node,
|
|
133
|
+
pos = tableObject.pos;
|
|
134
|
+
var tableState = api === null || api === void 0 ? void 0 : api.table.sharedState.currentState();
|
|
135
|
+
if (!(tableState !== null && tableState !== void 0 && tableState.tableRef)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Instead of dispatching a transaction to "strip widths" and then waiting
|
|
140
|
+
// for a rAF to measure natural column widths, directly update the DOM elements,
|
|
141
|
+
// take a measurement, and reset styles so no temporary overrides persist.
|
|
142
|
+
var measurement = measureTableWithAutoLayout(tableState.tableRef);
|
|
111
143
|
var tr = applyTableMeasurement(view.state.tr, node, measurement, pos);
|
|
112
144
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent({
|
|
113
145
|
action: TABLE_ACTION.FIT_TO_CONTENT_ON_DEMAND,
|
package/dist/esm/tablePlugin.js
CHANGED
|
@@ -41,7 +41,6 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
41
41
|
tableWrapper = props.tableWrapper,
|
|
42
42
|
targetCellPosition = props.targetCellPosition,
|
|
43
43
|
isCellMenuOpenByKeyboard = props.isCellMenuOpenByKeyboard,
|
|
44
|
-
isDragAndDropEnabled = props.isDragAndDropEnabled,
|
|
45
44
|
formatMessage = props.intl.formatMessage; // : Props & WrappedComponentProps
|
|
46
45
|
|
|
47
46
|
var handleClick = function handleClick() {
|
|
@@ -94,7 +93,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
|
|
|
94
93
|
}));
|
|
95
94
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
96
95
|
var parentStickyNative = targetCellRef.parentElement && (fg('platform_editor_table_sticky_header_patch_4') ? tableWrapper === null || tableWrapper === void 0 ? void 0 : tableWrapper.classList.contains(ClassName.TABLE_NODE_WRAPPER_NO_OVERFLOW) : targetCellRef.parentElement.classList.contains(ClassName.NATIVE_STICKY));
|
|
97
|
-
if (parentStickyNative && targetCellRef.nodeName === 'TH' && isNativeStickySupported(
|
|
96
|
+
if (parentStickyNative && targetCellRef.nodeName === 'TH' && isNativeStickySupported() && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
98
97
|
var _targetCellRef$parent;
|
|
99
98
|
/* We need to default to checking the anchor style because there may be a conflict with the block controls
|
|
100
99
|
plugin not using the data attribute value and setting the `anchor-name` style property independently of the data attribute.
|
|
@@ -8,7 +8,6 @@ import { Popup } from '@atlaskit/editor-common/ui';
|
|
|
8
8
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
11
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
11
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
13
12
|
import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD, contextualMenuTriggerSize, tablePopupMenuFitHeight } from '../consts';
|
|
14
13
|
|
|
@@ -30,24 +29,17 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
30
29
|
isCommentEditor = _ref.isCommentEditor,
|
|
31
30
|
api = _ref.api,
|
|
32
31
|
isDragMenuOpen = _ref.isDragMenuOpen;
|
|
33
|
-
if (
|
|
32
|
+
if (!editorView) {
|
|
34
33
|
return null;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
38
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
40
37
|
var _getPluginState = getPluginState(editorView.state),
|
|
41
38
|
targetCellPosition = _getPluginState.targetCellPosition,
|
|
42
39
|
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
43
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
40
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
46
41
|
return null;
|
|
47
42
|
}
|
|
48
|
-
|
|
49
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
51
43
|
var selection = editorView.state.selection;
|
|
52
44
|
var selectionRect = isSelectionType(selection, 'cell') ?
|
|
53
45
|
// Ignored via go/ees005
|
|
@@ -56,8 +48,6 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
56
48
|
if (!selectionRect) {
|
|
57
49
|
return null;
|
|
58
50
|
}
|
|
59
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
51
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
62
52
|
var targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
63
53
|
if (!targetCellRef) {
|
|
@@ -87,10 +77,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
87
77
|
stick: true
|
|
88
78
|
}, jsx("div", {
|
|
89
79
|
css: tablePopupStyles(isDragAndDropEnabled)
|
|
90
|
-
}, jsx(ContextualMenu
|
|
91
|
-
// Remove ! during platform_editor_hydratable_ui cleanup
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
93
|
-
, {
|
|
80
|
+
}, jsx(ContextualMenu, {
|
|
94
81
|
editorView: editorView
|
|
95
82
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
96
83
|
,
|
|
@@ -75,7 +75,7 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
|
|
|
75
75
|
containerRef === null || containerRef === void 0 || (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 || _containerRef$current2.style.removeProperty('top');
|
|
76
76
|
}
|
|
77
77
|
var anchorStyles = {};
|
|
78
|
-
if (isNativeStickySupported(
|
|
78
|
+
if (isNativeStickySupported() && expValEquals('platform_editor_table_sticky_header_improvements', 'cohort', 'test_with_overflow')) {
|
|
79
79
|
var _tableRef$querySelect, _tableRef$querySelect2;
|
|
80
80
|
var rowAnchorName = (_tableRef$querySelect = tableRef.querySelector('tr')) === null || _tableRef$querySelect === void 0 ? void 0 : _tableRef$querySelect.style.getPropertyValue('anchor-name');
|
|
81
81
|
// cast here is due to CSSProperties missing valid positionAnchor property
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DecorationTransformer, DecorationTransformerParams } from './types';
|
|
3
3
|
export declare const maybeUpdateColumnControlsSelectedDecoration: DecorationTransformer;
|
|
4
|
-
export declare const buildColumnControlsDecorations: ({ decorationSet, tr,
|
|
4
|
+
export declare const buildColumnControlsDecorations: ({ decorationSet, tr, }: DecorationTransformerParams) => DecorationSet;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
export type DecorationTransformer = (params: DecorationTransformerParams) => DecorationSet;
|
|
4
|
-
type DecorationTransformerParams = {
|
|
4
|
+
export type DecorationTransformerParams = {
|
|
5
5
|
decorationSet: DecorationSet;
|
|
6
6
|
tr: Transaction | ReadonlyTransaction;
|
|
7
7
|
};
|
|
8
|
-
export type BuildDecorationTransformerParams = DecorationTransformerParams & {
|
|
9
|
-
options: {
|
|
10
|
-
isDragAndDropEnabled: boolean;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export {};
|
|
@@ -9,11 +9,11 @@ import { TableDecorations } from '../../types';
|
|
|
9
9
|
export declare const findColumnControlSelectedDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
10
10
|
export declare const findControlsHoverDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
11
11
|
export declare const createCellHoverDecoration: (cells: Cell[]) => Decoration[];
|
|
12
|
-
export declare const createControlsHoverDecoration: (cells: Cell[], type: "row" | "column" | "table", tr: Transaction | ReadonlyTransaction,
|
|
12
|
+
export declare const createControlsHoverDecoration: (cells: Cell[], type: "row" | "column" | "table", tr: Transaction | ReadonlyTransaction, hoveredIndexes: number[], danger?: boolean, selected?: boolean) => Decoration[];
|
|
13
13
|
export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
|
|
14
14
|
export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
|
|
15
15
|
export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
|
|
16
16
|
export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, "left">, includeTooltip: boolean | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => [Decoration[], Decoration[]];
|
|
17
|
-
export declare const createColumnLineResize: (selection: Selection, cellColumnPositioning: Omit<CellColumnPositioning, "left"
|
|
17
|
+
export declare const createColumnLineResize: (selection: Selection, cellColumnPositioning: Omit<CellColumnPositioning, "left">) => Decoration[];
|
|
18
18
|
export declare const createColumnInsertLine: (columnIndex: number, selection: Selection, hasMergedCells: boolean) => Decoration[];
|
|
19
19
|
export declare const createRowInsertLine: (rowIndex: number, selection: Selection, hasMergedCells: boolean) => Decoration[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const isAnchorSupported: import("memoize-one").MemoizedFn<() => boolean>;
|
|
2
|
-
export declare const isNativeStickySupported: (
|
|
2
|
+
export declare const isNativeStickySupported: () => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
import type { PluginInjectionAPI } from '../../types';
|
|
3
|
+
import { type TableMeasurement } from '../transforms/content-mode';
|
|
3
4
|
type ContentModePluginOptions = {
|
|
4
5
|
allowColumnResizing: boolean;
|
|
5
6
|
allowTableResizing: boolean;
|
|
@@ -12,6 +13,12 @@ export declare const isContentModeSupported: ({ allowColumnResizing, allowTableR
|
|
|
12
13
|
* in a single batched transaction.
|
|
13
14
|
*/
|
|
14
15
|
export declare const applyMeasuredWidthToAllTables: (view: EditorView, pluginInjectionApi?: PluginInjectionAPI) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
18
|
+
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
19
|
+
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
20
|
+
*/
|
|
21
|
+
export declare const measureTableWithAutoLayout: (tableRef: HTMLTableElement) => TableMeasurement;
|
|
15
22
|
/**
|
|
16
23
|
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
17
24
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DecorationTransformer, DecorationTransformerParams } from './types';
|
|
3
3
|
export declare const maybeUpdateColumnControlsSelectedDecoration: DecorationTransformer;
|
|
4
|
-
export declare const buildColumnControlsDecorations: ({ decorationSet, tr,
|
|
4
|
+
export declare const buildColumnControlsDecorations: ({ decorationSet, tr, }: DecorationTransformerParams) => DecorationSet;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
export type DecorationTransformer = (params: DecorationTransformerParams) => DecorationSet;
|
|
4
|
-
type DecorationTransformerParams = {
|
|
4
|
+
export type DecorationTransformerParams = {
|
|
5
5
|
decorationSet: DecorationSet;
|
|
6
6
|
tr: Transaction | ReadonlyTransaction;
|
|
7
7
|
};
|
|
8
|
-
export type BuildDecorationTransformerParams = DecorationTransformerParams & {
|
|
9
|
-
options: {
|
|
10
|
-
isDragAndDropEnabled: boolean;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export {};
|
|
@@ -9,7 +9,7 @@ import { TableDecorations } from '../../types';
|
|
|
9
9
|
export declare const findColumnControlSelectedDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
10
10
|
export declare const findControlsHoverDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
11
11
|
export declare const createCellHoverDecoration: (cells: Cell[]) => Decoration[];
|
|
12
|
-
export declare const createControlsHoverDecoration: (cells: Cell[], type: "row" | "column" | "table", tr: Transaction | ReadonlyTransaction,
|
|
12
|
+
export declare const createControlsHoverDecoration: (cells: Cell[], type: "row" | "column" | "table", tr: Transaction | ReadonlyTransaction, hoveredIndexes: number[], danger?: boolean, selected?: boolean) => Decoration[];
|
|
13
13
|
export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
|
|
14
14
|
export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
|
|
15
15
|
export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
|
|
@@ -17,6 +17,6 @@ export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTr
|
|
|
17
17
|
Decoration[],
|
|
18
18
|
Decoration[]
|
|
19
19
|
];
|
|
20
|
-
export declare const createColumnLineResize: (selection: Selection, cellColumnPositioning: Omit<CellColumnPositioning, "left"
|
|
20
|
+
export declare const createColumnLineResize: (selection: Selection, cellColumnPositioning: Omit<CellColumnPositioning, "left">) => Decoration[];
|
|
21
21
|
export declare const createColumnInsertLine: (columnIndex: number, selection: Selection, hasMergedCells: boolean) => Decoration[];
|
|
22
22
|
export declare const createRowInsertLine: (rowIndex: number, selection: Selection, hasMergedCells: boolean) => Decoration[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const isAnchorSupported: import("memoize-one").MemoizedFn<() => boolean>;
|
|
2
|
-
export declare const isNativeStickySupported: (
|
|
2
|
+
export declare const isNativeStickySupported: () => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
import type { PluginInjectionAPI } from '../../types';
|
|
3
|
+
import { type TableMeasurement } from '../transforms/content-mode';
|
|
3
4
|
type ContentModePluginOptions = {
|
|
4
5
|
allowColumnResizing: boolean;
|
|
5
6
|
allowTableResizing: boolean;
|
|
@@ -12,6 +13,12 @@ export declare const isContentModeSupported: ({ allowColumnResizing, allowTableR
|
|
|
12
13
|
* in a single batched transaction.
|
|
13
14
|
*/
|
|
14
15
|
export declare const applyMeasuredWidthToAllTables: (view: EditorView, pluginInjectionApi?: PluginInjectionAPI) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Temporarily overrides inline styles on the table and its surrounding containers so the browser
|
|
18
|
+
* lays columns out with `table-layout: auto`, takes a content-width measurement, and then
|
|
19
|
+
* **resets every modified style** so no temporary overrides leak into the rendered output.
|
|
20
|
+
*/
|
|
21
|
+
export declare const measureTableWithAutoLayout: (tableRef: HTMLTableElement) => TableMeasurement;
|
|
15
22
|
/**
|
|
16
23
|
* Used to measure a selected table width with it's content being laid out natively by the browser
|
|
17
24
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.2.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@atlaskit/button": "^23.11.0",
|
|
33
33
|
"@atlaskit/custom-steps": "^0.16.0",
|
|
34
34
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
35
|
-
"@atlaskit/editor-plugin-accessibility-utils": "^10.
|
|
35
|
+
"@atlaskit/editor-plugin-accessibility-utils": "^10.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^10.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^10.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-content-insertion": "^10.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^12.0.0",
|
|
40
|
-
"@atlaskit/editor-plugin-extension": "13.0.
|
|
40
|
+
"@atlaskit/editor-plugin-extension": "13.0.3",
|
|
41
41
|
"@atlaskit/editor-plugin-guideline": "^10.0.0",
|
|
42
42
|
"@atlaskit/editor-plugin-interaction": "^19.0.0",
|
|
43
43
|
"@atlaskit/editor-plugin-limited-mode": "^7.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
57
57
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
|
58
58
|
"@atlaskit/primitives": "^19.0.0",
|
|
59
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
59
|
+
"@atlaskit/tmp-editor-statsig": "^65.0.0",
|
|
60
60
|
"@atlaskit/toggle": "^15.6.0",
|
|
61
61
|
"@atlaskit/tokens": "^13.0.0",
|
|
62
62
|
"@atlaskit/tooltip": "^21.1.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"uuid": "^3.1.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@atlaskit/editor-common": "^114.
|
|
73
|
+
"@atlaskit/editor-common": "^114.6.0",
|
|
74
74
|
"react": "^18.2.0",
|
|
75
75
|
"react-dom": "^18.2.0",
|
|
76
76
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|