@atlaskit/editor-plugin-table 22.2.5 → 22.2.7
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 +15 -0
- package/dist/cjs/nodeviews/TableContainer.js +16 -7
- package/dist/cjs/nodeviews/TableResizer.js +30 -16
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +6 -6
- package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +3 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +4 -4
- package/dist/es2019/nodeviews/TableContainer.js +17 -8
- package/dist/es2019/nodeviews/TableResizer.js +31 -17
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +6 -6
- package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +2 -1
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -4
- package/dist/esm/nodeviews/TableContainer.js +17 -8
- package/dist/esm/nodeviews/TableResizer.js +31 -17
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +6 -6
- package/dist/esm/pm-plugins/table-resizing/utils/consts.js +2 -1
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +4 -4
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types/pm-plugins/drag-and-drop/utils/autoscrollers.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +2 -2
- package/dist/types/types/index.d.ts +26 -26
- package/dist/types/ui/ColumnResizeWidget/index.d.ts +1 -1
- package/dist/types/ui/consts.d.ts +17 -17
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/autoscrollers.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +2 -2
- package/dist/types-ts4.5/types/index.d.ts +26 -26
- package/dist/types-ts4.5/ui/ColumnResizeWidget/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/consts.d.ts +17 -17
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 22.2.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`aaa61a61efb94`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aaa61a61efb94) -
|
|
8
|
+
Add support for table resize in chromeless editor, behind platform_editor_table_resize_chromeless
|
|
9
|
+
experiment
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 22.2.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 22.2.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -217,7 +217,6 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
217
217
|
var isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
|
|
218
218
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
219
219
|
var responsiveContainerWidth = 0;
|
|
220
|
-
var resizeHandleSpacing = 12;
|
|
221
220
|
var padding = getPadding(containerWidth);
|
|
222
221
|
// When Full width or Max width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
|
|
223
222
|
// updating Settings -> Appearance -> Show scroll bars from "When scrolling" to "Always". It causes
|
|
@@ -235,30 +234,39 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
235
234
|
if (isTableScalingEnabled && Number.isFinite(lineLength) && lineLength !== undefined) {
|
|
236
235
|
responsiveContainerWidth = lineLength;
|
|
237
236
|
} else {
|
|
238
|
-
responsiveContainerWidth = containerWidth - padding * 2 -
|
|
237
|
+
responsiveContainerWidth = containerWidth - padding * 2 - _consts.RESIZE_HANDLE_SPACING;
|
|
239
238
|
}
|
|
240
239
|
} else if (isCommentEditor) {
|
|
241
240
|
responsiveContainerWidth = containerWidth - _consts.TABLE_OFFSET_IN_COMMENT_EDITOR;
|
|
241
|
+
} else if (isChromelessEditor && (0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true)) {
|
|
242
|
+
// there's no padding included in chromeless appearance, so we need to reduce table
|
|
243
|
+
// width to ensure all controls are visible.
|
|
244
|
+
// use lineLength as the value is updated by scrollbar visibility changes
|
|
245
|
+
responsiveContainerWidth = Number.isFinite(lineLength) && lineLength !== undefined ? lineLength : containerWidth - _consts.RESIZE_HANDLE_SPACING;
|
|
242
246
|
} else {
|
|
243
247
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
244
248
|
// containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
|
|
245
249
|
// a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
|
|
246
250
|
// padding left = padding right = akEditorGutterPadding = 32
|
|
247
|
-
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - padding * 2 : containerWidth - padding * 2 -
|
|
251
|
+
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - padding * 2 : containerWidth - padding * 2 - _consts.RESIZE_HANDLE_SPACING;
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
// Fix for HOT-119925: Ensure table width is properly constrained and responsive
|
|
251
255
|
// For wide tables, ensure they don't exceed container width and can be scrolled
|
|
252
|
-
var calculatedWidth =
|
|
256
|
+
var calculatedWidth =
|
|
257
|
+
// remove isCommentEditor check if platform_editor_table_resize_chromeless is cleaned up
|
|
258
|
+
!node.attrs.width && ((0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor) ? responsiveContainerWidth : Math.min(tableWidth, responsiveContainerWidth);
|
|
253
259
|
|
|
254
260
|
// Ensure minimum width for usability while respecting container constraints
|
|
255
261
|
var width = Math.max(calculatedWidth, Math.min(responsiveContainerWidth * 0.5, 300));
|
|
256
|
-
|
|
262
|
+
|
|
263
|
+
// remove isCommentEditor check if platform_editor_table_resize_chromeless is cleaned up
|
|
264
|
+
var maxResizerWidth = (0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor ? responsiveContainerWidth : Math.min(responsiveContainerWidth, (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? _consts.TABLE_MAX_WIDTH : _consts.TABLE_FULL_WIDTH);
|
|
257
265
|
return {
|
|
258
266
|
width: width,
|
|
259
267
|
maxResizerWidth: maxResizerWidth
|
|
260
268
|
};
|
|
261
|
-
}, [containerWidth, isCommentEditor, isFullWidthModeEnabled, isMaxWidthModeEnabled, isTableScalingEnabled, lineLength, node.attrs.width, tableWidth]),
|
|
269
|
+
}, [containerWidth, isCommentEditor, isChromelessEditor, isFullWidthModeEnabled, isMaxWidthModeEnabled, isFullPageAppearance, isTableScalingEnabled, lineLength, node.attrs.width, tableWidth]),
|
|
262
270
|
width = _useMemo.width,
|
|
263
271
|
maxResizerWidth = _useMemo.maxResizerWidth;
|
|
264
272
|
(0, _react.useEffect)(function () {
|
|
@@ -308,7 +316,8 @@ var ResizableTableContainer = exports.ResizableTableContainer = /*#__PURE__*/_re
|
|
|
308
316
|
pluginInjectionApi: pluginInjectionApi,
|
|
309
317
|
onResizeStart: onResizeStart,
|
|
310
318
|
onResizeStop: onResizeStop,
|
|
311
|
-
isCommentEditor: isCommentEditor
|
|
319
|
+
isCommentEditor: isCommentEditor,
|
|
320
|
+
isChromelessEditor: isChromelessEditor
|
|
312
321
|
};
|
|
313
322
|
var isLivePageViewMode = mode === 'view';
|
|
314
323
|
return /*#__PURE__*/_react.default.createElement(AlignmentTableContainerWrapper, {
|
|
@@ -56,12 +56,12 @@ var getResizerHandleHeight = function getResizerHandleHeight(tableRef) {
|
|
|
56
56
|
var _tableRef$clientHeigh;
|
|
57
57
|
var tableHeight = (_tableRef$clientHeigh = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight) !== null && _tableRef$clientHeigh !== void 0 ? _tableRef$clientHeigh : 0;
|
|
58
58
|
/*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
- One row table height (minimum possible table height) ~ 45px
|
|
60
|
+
- Two row table height ~ 90px
|
|
61
|
+
- Three row table height ~ 134px
|
|
62
|
+
In the if below we need to use:
|
|
63
|
+
- > 46 because the height of the table can be a float number like 45.44.
|
|
64
|
+
- < 96 is the height of large resize handle.
|
|
65
65
|
*/
|
|
66
66
|
if (tableHeight >= 96) {
|
|
67
67
|
return 'large';
|
|
@@ -83,6 +83,15 @@ var getPadding = function getPadding(containerWidth) {
|
|
|
83
83
|
exposure: true
|
|
84
84
|
}) ? _editorSharedStyles.akEditorGutterPaddingReduced : (0, _editorSharedStyles.akEditorGutterPaddingDynamic)();
|
|
85
85
|
};
|
|
86
|
+
var getTableMaxWidth = function getTableMaxWidth(containerWidth, lineLength, isCommentEditor, isChromelessEditor) {
|
|
87
|
+
if (isCommentEditor) {
|
|
88
|
+
return Math.floor(containerWidth - _consts.TABLE_OFFSET_IN_COMMENT_EDITOR);
|
|
89
|
+
} else if (isChromelessEditor) {
|
|
90
|
+
return Number.isFinite(lineLength) && lineLength !== undefined ? lineLength : Math.floor(containerWidth - _consts.RESIZE_HANDLE_SPACING);
|
|
91
|
+
} else {
|
|
92
|
+
return (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? _consts.TABLE_MAX_WIDTH : _consts.TABLE_FULL_WIDTH;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
86
95
|
|
|
87
96
|
/**
|
|
88
97
|
* When guidelines are outside the viewport, filter them out, do not show
|
|
@@ -143,6 +152,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
143
152
|
pluginInjectionApi = _ref.pluginInjectionApi,
|
|
144
153
|
isFullWidthModeEnabled = _ref.isFullWidthModeEnabled,
|
|
145
154
|
isCommentEditor = _ref.isCommentEditor,
|
|
155
|
+
isChromelessEditor = _ref.isChromelessEditor,
|
|
146
156
|
disabled = _ref.disabled;
|
|
147
157
|
var currentGap = (0, _react.useRef)(0);
|
|
148
158
|
// track resizing state - use ref over state to avoid re-render
|
|
@@ -161,6 +171,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
161
171
|
setSnappingEnabled = _useState2[1];
|
|
162
172
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
163
173
|
formatMessage = _useIntl.formatMessage;
|
|
174
|
+
var isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
|
|
164
175
|
var currentSelection = (_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection;
|
|
165
176
|
var tableFromSelection = (0, _react.useMemo)(function () {
|
|
166
177
|
return (0, _utils.findTable)(currentSelection);
|
|
@@ -292,7 +303,9 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
292
303
|
return;
|
|
293
304
|
}
|
|
294
305
|
var editorContainerWidth = isFullWidthModeEnabled ? lineLength + 2 * getPadding(containerWidth) : containerWidth;
|
|
295
|
-
var closestSnap =
|
|
306
|
+
var closestSnap =
|
|
307
|
+
// remove isCommentEditor check if platform_editor_table_resize_chromeless is cleaned up
|
|
308
|
+
((0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) && isFullPageAppearance || !isCommentEditor) && (0, _snapping.findClosestSnap)(newWidth, isTableScalingEnabled ? (0, _snapping.defaultTablePreserveSnappingWidths)(_snapping.PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : _snapping.defaultSnappingWidths, isTableScalingEnabled ? (0, _guidelines.defaultGuidelinesForPreserveTable)(_guidelines.PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : _guidelines.defaultGuidelines, _consts2.TABLE_HIGHLIGHT_GAP, _consts2.TABLE_HIGHLIGHT_TOLERANCE);
|
|
296
309
|
closestSnap && updateActiveGuidelines(closestSnap);
|
|
297
310
|
|
|
298
311
|
// When snapping to the full width guideline, resize the table to be 1800px
|
|
@@ -303,21 +316,21 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
303
316
|
return guideline.isFullWidth;
|
|
304
317
|
})[0];
|
|
305
318
|
var isFullWidthGuidelineActive = (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? closestSnap && fullWidthGuideline && closestSnap.keys.includes(fullWidthGuideline.key) : closestSnap && closestSnap.keys.includes(fullWidthGuideline.key);
|
|
306
|
-
var tableMaxWidth = isCommentEditor ? Math.floor(containerWidth - _consts.TABLE_OFFSET_IN_COMMENT_EDITOR) : (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? _consts.TABLE_MAX_WIDTH : _consts.TABLE_FULL_WIDTH;
|
|
307
|
-
var shouldUpdateWidthToWidest = isCommentEditor ? tableMaxWidth <= newWidth : !!isTableScalingEnabled && isFullWidthGuidelineActive;
|
|
308
|
-
var previewParentWidth = isCommentEditor && shouldUpdateWidthToWidest ? tableMaxWidth : newWidth;
|
|
319
|
+
var tableMaxWidth = (0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) ? getTableMaxWidth(containerWidth, lineLength, isCommentEditor, isChromelessEditor) : isCommentEditor ? Math.floor(containerWidth - _consts.TABLE_OFFSET_IN_COMMENT_EDITOR) : (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? _consts.TABLE_MAX_WIDTH : _consts.TABLE_FULL_WIDTH;
|
|
320
|
+
var shouldUpdateWidthToWidest = (0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor ? tableMaxWidth <= newWidth : !!isTableScalingEnabled && isFullWidthGuidelineActive;
|
|
321
|
+
var previewParentWidth = ((0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor) && shouldUpdateWidthToWidest ? tableMaxWidth : newWidth;
|
|
309
322
|
(0, _scaleTable.previewScaleTable)(tableRef, {
|
|
310
323
|
node: node,
|
|
311
324
|
prevNode: node,
|
|
312
325
|
start: pos + 1,
|
|
313
326
|
parentWidth: previewParentWidth
|
|
314
|
-
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled, allowFixedColumnWidthOption, isCommentEditor);
|
|
327
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled, allowFixedColumnWidthOption, (0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) ? !isFullPageAppearance : isCommentEditor);
|
|
315
328
|
(0, _commands.chainCommands)(function (state, dispatch) {
|
|
316
329
|
return switchToCenterAlignment(pos, node, newWidth, state, dispatch);
|
|
317
330
|
}, (0, _misc.updateWidthToWidest)((0, _defineProperty2.default)({}, currentTableNodeLocalId, shouldUpdateWidthToWidest)))(state, dispatch);
|
|
318
331
|
updateWidth(shouldUpdateWidthToWidest ? tableMaxWidth : newWidth);
|
|
319
332
|
return newWidth;
|
|
320
|
-
}, [countFrames, isCommentEditor, isTableScalingEnabled, allowFixedColumnWidthOption, isFullWidthModeEnabled, excludeGuidelineConfig, tableRef, node, editorView, updateActiveGuidelines, containerWidth, lineLength, updateWidth, getPos, switchToCenterAlignment]);
|
|
333
|
+
}, [countFrames, isCommentEditor, isChromelessEditor, isFullPageAppearance, isTableScalingEnabled, allowFixedColumnWidthOption, isFullWidthModeEnabled, excludeGuidelineConfig, tableRef, node, editorView, updateActiveGuidelines, containerWidth, lineLength, updateWidth, getPos, switchToCenterAlignment]);
|
|
321
334
|
var scheduleResize = (0, _react.useMemo)(function () {
|
|
322
335
|
return (0, _rafSchd.default)(handleResize);
|
|
323
336
|
}, [handleResize]);
|
|
@@ -330,7 +343,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
330
343
|
dispatch = editorView.dispatch;
|
|
331
344
|
var pos = getPos();
|
|
332
345
|
var currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
|
|
333
|
-
var tableMaxWidth = isCommentEditor ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
|
|
346
|
+
var tableMaxWidth = (0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
|
|
334
347
|
: (0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true) ? _consts.TABLE_MAX_WIDTH : _consts.TABLE_FULL_WIDTH;
|
|
335
348
|
newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? tableMaxWidth : newWidth;
|
|
336
349
|
var tr = state.tr.setMeta(_tableWidth.pluginKey, {
|
|
@@ -371,8 +384,9 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
371
384
|
// We use originalNewWidth in comment editor, because in comment editor
|
|
372
385
|
// newWidth can be underined when table is resized to 'full-width'
|
|
373
386
|
// scaleTable function needs number value to work correctly.
|
|
374
|
-
|
|
375
|
-
|
|
387
|
+
// remove isCommentEditor check when platform_editor_table_resize_chromeless is removed
|
|
388
|
+
parentWidth: (0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor ? originalNewWidth : newWidth
|
|
389
|
+
}, editorView.domAtPos.bind(editorView), pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent || false, (0, _expValEquals.expValEquals)('platform_editor_table_resize_chromeless', 'isEnabled', true) ? !isFullPageAppearance : isCommentEditor)(tr);
|
|
376
390
|
|
|
377
391
|
// Ignored via go/ees005
|
|
378
392
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -408,7 +422,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
408
422
|
(_insm$session2 = _insm.insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('tableResize');
|
|
409
423
|
}
|
|
410
424
|
return newWidth;
|
|
411
|
-
}, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
|
|
425
|
+
}, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage, isFullPageAppearance]);
|
|
412
426
|
var handleTableSizeChangeOnKeypress = (0, _react.useCallback)(function (step) {
|
|
413
427
|
var newWidth = width + step;
|
|
414
428
|
if (newWidth < resizerMinWidth) {
|
|
@@ -101,7 +101,7 @@ var generateColgroupFromNode = exports.generateColgroupFromNode = function gener
|
|
|
101
101
|
});
|
|
102
102
|
return cols;
|
|
103
103
|
};
|
|
104
|
-
var generateColgroup = exports.generateColgroup = function generateColgroup(table, tableRef, shouldUseIncreasedScalingPercent,
|
|
104
|
+
var generateColgroup = exports.generateColgroup = function generateColgroup(table, tableRef, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor) {
|
|
105
105
|
var cols = [];
|
|
106
106
|
var map = _tableMap.TableMap.get(table);
|
|
107
107
|
|
|
@@ -116,7 +116,7 @@ var generateColgroup = exports.generateColgroup = function generateColgroup(tabl
|
|
|
116
116
|
var _table$attrs;
|
|
117
117
|
// if we have tableRef here, isTableScalingEnabled is true
|
|
118
118
|
var scalePercent = 1;
|
|
119
|
-
if (
|
|
119
|
+
if (isCommentOrChromelessEditor && !((_table$attrs = table.attrs) !== null && _table$attrs !== void 0 && _table$attrs.width)) {
|
|
120
120
|
scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(table, tableRef);
|
|
121
121
|
} else {
|
|
122
122
|
scalePercent = (0, _misc.getTableScalingPercent)(table, tableRef, shouldUseIncreasedScalingPercent);
|
|
@@ -156,14 +156,14 @@ var insertColgroupFromNode = exports.insertColgroupFromNode = function insertCol
|
|
|
156
156
|
var isTableScalingEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
157
157
|
var shouldRemove = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
158
158
|
var shouldUseIncreasedScalingPercent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
159
|
-
var
|
|
159
|
+
var isCommentOrChromelessEditor = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
160
160
|
// Ignored via go/ees005
|
|
161
161
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
162
162
|
var colgroup = tableRef === null || tableRef === void 0 ? void 0 : tableRef.querySelector('colgroup');
|
|
163
163
|
if (colgroup && shouldRemove) {
|
|
164
164
|
tableRef === null || tableRef === void 0 || tableRef.removeChild(colgroup);
|
|
165
165
|
}
|
|
166
|
-
colgroup = renderColgroupFromNode(table, isTableScalingEnabled ? tableRef !== null && tableRef !== void 0 ? tableRef : undefined : undefined, shouldUseIncreasedScalingPercent,
|
|
166
|
+
colgroup = renderColgroupFromNode(table, isTableScalingEnabled ? tableRef !== null && tableRef !== void 0 ? tableRef : undefined : undefined, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor);
|
|
167
167
|
if (shouldRemove) {
|
|
168
168
|
tableRef === null || tableRef === void 0 || tableRef.insertBefore(colgroup, tableRef === null || tableRef === void 0 ? void 0 : tableRef.firstChild);
|
|
169
169
|
}
|
|
@@ -193,8 +193,8 @@ var isMinCellWidthTable = exports.isMinCellWidthTable = function isMinCellWidthT
|
|
|
193
193
|
});
|
|
194
194
|
return isTableMinCellWidth;
|
|
195
195
|
};
|
|
196
|
-
function renderColgroupFromNode(table, maybeTableRef, shouldUseIncreasedScalingPercent,
|
|
197
|
-
var rendered = _model.DOMSerializer.renderSpec(document, ['colgroup', {}].concat((0, _toConsumableArray2.default)(generateColgroup(table, maybeTableRef, shouldUseIncreasedScalingPercent,
|
|
196
|
+
function renderColgroupFromNode(table, maybeTableRef, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor) {
|
|
197
|
+
var rendered = _model.DOMSerializer.renderSpec(document, ['colgroup', {}].concat((0, _toConsumableArray2.default)(generateColgroup(table, maybeTableRef, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor))));
|
|
198
198
|
|
|
199
199
|
// Ignored via go/ees005
|
|
200
200
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TABLE_OFFSET_IN_COMMENT_EDITOR = exports.TABLE_MAX_WIDTH = exports.TABLE_FULL_WIDTH = exports.TABLE_EDITOR_MARGIN = exports.MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION = exports.MAX_SCALING_PERCENT = exports.FULL_WIDTH_EDITOR_CONTENT_WIDTH = exports.COLUMN_MIN_WIDTH = void 0;
|
|
6
|
+
exports.TABLE_OFFSET_IN_COMMENT_EDITOR = exports.TABLE_MAX_WIDTH = exports.TABLE_FULL_WIDTH = exports.TABLE_EDITOR_MARGIN = exports.RESIZE_HANDLE_SPACING = exports.MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION = exports.MAX_SCALING_PERCENT = exports.FULL_WIDTH_EDITOR_CONTENT_WIDTH = exports.COLUMN_MIN_WIDTH = void 0;
|
|
7
7
|
var COLUMN_MIN_WIDTH = exports.COLUMN_MIN_WIDTH = 48;
|
|
8
8
|
var TABLE_FULL_WIDTH = exports.TABLE_FULL_WIDTH = 1800;
|
|
9
9
|
var TABLE_MAX_WIDTH = exports.TABLE_MAX_WIDTH = 4000;
|
|
@@ -14,4 +14,5 @@ var MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION = exports.MAX_SCA
|
|
|
14
14
|
var TABLE_EDITOR_MARGIN = exports.TABLE_EDITOR_MARGIN = 76;
|
|
15
15
|
var COMMENT_AK_EDITOR_CONTENT_AREA_PADDING = 20;
|
|
16
16
|
var COMMENT_PM_TABLE_RESIZING_PLUGIN_MARGIN = 12;
|
|
17
|
-
var TABLE_OFFSET_IN_COMMENT_EDITOR = exports.TABLE_OFFSET_IN_COMMENT_EDITOR = 2 * (COMMENT_AK_EDITOR_CONTENT_AREA_PADDING + COMMENT_PM_TABLE_RESIZING_PLUGIN_MARGIN);
|
|
17
|
+
var TABLE_OFFSET_IN_COMMENT_EDITOR = exports.TABLE_OFFSET_IN_COMMENT_EDITOR = 2 * (COMMENT_AK_EDITOR_CONTENT_AREA_PADDING + COMMENT_PM_TABLE_RESIZING_PLUGIN_MARGIN);
|
|
18
|
+
var RESIZE_HANDLE_SPACING = exports.RESIZE_HANDLE_SPACING = 12;
|
|
@@ -115,7 +115,7 @@ function scaleTableTo(state, maxSize) {
|
|
|
115
115
|
var previewScaleTable = exports.previewScaleTable = function previewScaleTable(tableRef, options, domAtPos) {
|
|
116
116
|
var isTableScalingEnabled = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
117
117
|
var allowFixedColumnWidthOption = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
118
|
-
var
|
|
118
|
+
var isCommentOrChromelessEditor = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
119
119
|
var node = options.node,
|
|
120
120
|
start = options.start,
|
|
121
121
|
parentWidth = options.parentWidth;
|
|
@@ -138,7 +138,7 @@ var previewScaleTable = exports.previewScaleTable = function previewScaleTable(t
|
|
|
138
138
|
(0, _dom.syncStickyRowToTable)(tableRef);
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
|
-
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || isTableScalingEnabled &&
|
|
141
|
+
var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || isTableScalingEnabled && isCommentOrChromelessEditor;
|
|
142
142
|
var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false,
|
|
143
143
|
// Here isTableScalingEnabled = false
|
|
144
144
|
shouldUseIncreasedScalingPercent) : scale(tableRef, options, domAtPos, false, shouldUseIncreasedScalingPercent);
|
|
@@ -151,7 +151,7 @@ var previewScaleTable = exports.previewScaleTable = function previewScaleTable(t
|
|
|
151
151
|
var scaleTable = exports.scaleTable = function scaleTable(tableRef, options, domAtPos, api) {
|
|
152
152
|
var isTableScalingEnabledOnCurrentTable = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
153
153
|
var shouldUseIncreasedScalingPercent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
154
|
-
var
|
|
154
|
+
var isCommentOrChromelessEditor = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
155
155
|
return function (tr) {
|
|
156
156
|
if (!tableRef) {
|
|
157
157
|
return tr;
|
|
@@ -166,7 +166,7 @@ var scaleTable = exports.scaleTable = function scaleTable(tableRef, options, dom
|
|
|
166
166
|
// To force reflow of columns upon delete.
|
|
167
167
|
if (!isTableScalingEnabledOnCurrentTable) {
|
|
168
168
|
var isTableScalingEnabled = false;
|
|
169
|
-
(0, _colgroup.insertColgroupFromNode)(tableRef, node, isTableScalingEnabled, undefined, shouldUseIncreasedScalingPercent,
|
|
169
|
+
(0, _colgroup.insertColgroupFromNode)(tableRef, node, isTableScalingEnabled, undefined, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor);
|
|
170
170
|
}
|
|
171
171
|
tr.setMeta('scrollIntoView', false);
|
|
172
172
|
return tr;
|
|
@@ -10,7 +10,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
10
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
11
|
import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
|
|
12
12
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
13
|
-
import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
|
|
13
|
+
import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR, RESIZE_HANDLE_SPACING } from '../pm-plugins/table-resizing/utils/consts';
|
|
14
14
|
import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
|
|
15
15
|
import { ALIGN_CENTER, ALIGN_START } from '../pm-plugins/utils/alignment';
|
|
16
16
|
import { TableCssClassName as ClassName } from '../types';
|
|
@@ -213,7 +213,6 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
213
213
|
maxResizerWidth
|
|
214
214
|
} = useMemo(() => {
|
|
215
215
|
let responsiveContainerWidth = 0;
|
|
216
|
-
const resizeHandleSpacing = 12;
|
|
217
216
|
const padding = getPadding(containerWidth);
|
|
218
217
|
// When Full width or Max width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
|
|
219
218
|
// updating Settings -> Appearance -> Show scroll bars from "When scrolling" to "Always". It causes
|
|
@@ -231,30 +230,39 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
231
230
|
if (isTableScalingEnabled && Number.isFinite(lineLength) && lineLength !== undefined) {
|
|
232
231
|
responsiveContainerWidth = lineLength;
|
|
233
232
|
} else {
|
|
234
|
-
responsiveContainerWidth = containerWidth - padding * 2 -
|
|
233
|
+
responsiveContainerWidth = containerWidth - padding * 2 - RESIZE_HANDLE_SPACING;
|
|
235
234
|
}
|
|
236
235
|
} else if (isCommentEditor) {
|
|
237
236
|
responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
|
|
237
|
+
} else if (isChromelessEditor && expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true)) {
|
|
238
|
+
// there's no padding included in chromeless appearance, so we need to reduce table
|
|
239
|
+
// width to ensure all controls are visible.
|
|
240
|
+
// use lineLength as the value is updated by scrollbar visibility changes
|
|
241
|
+
responsiveContainerWidth = Number.isFinite(lineLength) && lineLength !== undefined ? lineLength : containerWidth - RESIZE_HANDLE_SPACING;
|
|
238
242
|
} else {
|
|
239
243
|
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
240
244
|
// containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
|
|
241
245
|
// a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
|
|
242
246
|
// padding left = padding right = akEditorGutterPadding = 32
|
|
243
|
-
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - padding * 2 : containerWidth - padding * 2 -
|
|
247
|
+
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - padding * 2 : containerWidth - padding * 2 - RESIZE_HANDLE_SPACING;
|
|
244
248
|
}
|
|
245
249
|
|
|
246
250
|
// Fix for HOT-119925: Ensure table width is properly constrained and responsive
|
|
247
251
|
// For wide tables, ensure they don't exceed container width and can be scrolled
|
|
248
|
-
const calculatedWidth =
|
|
252
|
+
const calculatedWidth =
|
|
253
|
+
// remove isCommentEditor check if platform_editor_table_resize_chromeless is cleaned up
|
|
254
|
+
!node.attrs.width && (expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor) ? responsiveContainerWidth : Math.min(tableWidth, responsiveContainerWidth);
|
|
249
255
|
|
|
250
256
|
// Ensure minimum width for usability while respecting container constraints
|
|
251
257
|
const width = Math.max(calculatedWidth, Math.min(responsiveContainerWidth * 0.5, 300));
|
|
252
|
-
|
|
258
|
+
|
|
259
|
+
// remove isCommentEditor check if platform_editor_table_resize_chromeless is cleaned up
|
|
260
|
+
const maxResizerWidth = expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor ? responsiveContainerWidth : Math.min(responsiveContainerWidth, expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? TABLE_MAX_WIDTH : TABLE_FULL_WIDTH);
|
|
253
261
|
return {
|
|
254
262
|
width,
|
|
255
263
|
maxResizerWidth
|
|
256
264
|
};
|
|
257
|
-
}, [containerWidth, isCommentEditor, isFullWidthModeEnabled, isMaxWidthModeEnabled, isTableScalingEnabled, lineLength, node.attrs.width, tableWidth]);
|
|
265
|
+
}, [containerWidth, isCommentEditor, isChromelessEditor, isFullWidthModeEnabled, isMaxWidthModeEnabled, isFullPageAppearance, isTableScalingEnabled, lineLength, node.attrs.width, tableWidth]);
|
|
258
266
|
useEffect(() => {
|
|
259
267
|
if (!isResizing) {
|
|
260
268
|
tableWidthRef.current = width;
|
|
@@ -302,7 +310,8 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
|
|
|
302
310
|
pluginInjectionApi,
|
|
303
311
|
onResizeStart,
|
|
304
312
|
onResizeStop,
|
|
305
|
-
isCommentEditor
|
|
313
|
+
isCommentEditor,
|
|
314
|
+
isChromelessEditor
|
|
306
315
|
};
|
|
307
316
|
const isLivePageViewMode = mode === 'view';
|
|
308
317
|
return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
|
|
@@ -20,7 +20,7 @@ import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plu
|
|
|
20
20
|
import { updateWidthToWidest } from '../pm-plugins/commands/misc';
|
|
21
21
|
import { META_KEYS } from '../pm-plugins/table-analytics';
|
|
22
22
|
import { getColgroupChildrenLength } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
23
|
-
import { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH, TABLE_FULL_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
|
|
23
|
+
import { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH, TABLE_FULL_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR, RESIZE_HANDLE_SPACING } from '../pm-plugins/table-resizing/utils/consts';
|
|
24
24
|
import { previewScaleTable, scaleTable } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
25
25
|
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
26
26
|
import { ALIGN_CENTER, ALIGN_START, normaliseAlignment, shouldChangeAlignmentToCenterResized } from '../pm-plugins/utils/alignment';
|
|
@@ -43,12 +43,12 @@ const getResizerHandleHeight = tableRef => {
|
|
|
43
43
|
var _tableRef$clientHeigh;
|
|
44
44
|
const tableHeight = (_tableRef$clientHeigh = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight) !== null && _tableRef$clientHeigh !== void 0 ? _tableRef$clientHeigh : 0;
|
|
45
45
|
/*
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
- One row table height (minimum possible table height) ~ 45px
|
|
47
|
+
- Two row table height ~ 90px
|
|
48
|
+
- Three row table height ~ 134px
|
|
49
|
+
In the if below we need to use:
|
|
50
|
+
- > 46 because the height of the table can be a float number like 45.44.
|
|
51
|
+
- < 96 is the height of large resize handle.
|
|
52
52
|
*/
|
|
53
53
|
if (tableHeight >= 96) {
|
|
54
54
|
return 'large';
|
|
@@ -70,6 +70,15 @@ const getPadding = containerWidth => {
|
|
|
70
70
|
exposure: true
|
|
71
71
|
}) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
|
|
72
72
|
};
|
|
73
|
+
const getTableMaxWidth = (containerWidth, lineLength, isCommentEditor, isChromelessEditor) => {
|
|
74
|
+
if (isCommentEditor) {
|
|
75
|
+
return Math.floor(containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR);
|
|
76
|
+
} else if (isChromelessEditor) {
|
|
77
|
+
return Number.isFinite(lineLength) && lineLength !== undefined ? lineLength : Math.floor(containerWidth - RESIZE_HANDLE_SPACING);
|
|
78
|
+
} else {
|
|
79
|
+
return expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? TABLE_MAX_WIDTH : TABLE_FULL_WIDTH;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
73
82
|
|
|
74
83
|
/**
|
|
75
84
|
* When guidelines are outside the viewport, filter them out, do not show
|
|
@@ -129,6 +138,7 @@ export const TableResizer = ({
|
|
|
129
138
|
pluginInjectionApi,
|
|
130
139
|
isFullWidthModeEnabled,
|
|
131
140
|
isCommentEditor,
|
|
141
|
+
isChromelessEditor,
|
|
132
142
|
disabled
|
|
133
143
|
}) => {
|
|
134
144
|
var _editorView$state, _pluginInjectionApi$a2, _pluginInjectionApi$u2;
|
|
@@ -148,6 +158,7 @@ export const TableResizer = ({
|
|
|
148
158
|
const {
|
|
149
159
|
formatMessage
|
|
150
160
|
} = useIntl();
|
|
161
|
+
const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
|
|
151
162
|
const currentSelection = (_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection;
|
|
152
163
|
const tableFromSelection = useMemo(() => {
|
|
153
164
|
return findTable(currentSelection);
|
|
@@ -285,7 +296,9 @@ export const TableResizer = ({
|
|
|
285
296
|
return;
|
|
286
297
|
}
|
|
287
298
|
const editorContainerWidth = isFullWidthModeEnabled ? lineLength + 2 * getPadding(containerWidth) : containerWidth;
|
|
288
|
-
const closestSnap =
|
|
299
|
+
const closestSnap =
|
|
300
|
+
// remove isCommentEditor check if platform_editor_table_resize_chromeless is cleaned up
|
|
301
|
+
(expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) && isFullPageAppearance || !isCommentEditor) && findClosestSnap(newWidth, isTableScalingEnabled ? defaultTablePreserveSnappingWidths(PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : defaultSnappingWidths, isTableScalingEnabled ? defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE);
|
|
289
302
|
closestSnap && updateActiveGuidelines(closestSnap);
|
|
290
303
|
|
|
291
304
|
// When snapping to the full width guideline, resize the table to be 1800px
|
|
@@ -296,15 +309,15 @@ export const TableResizer = ({
|
|
|
296
309
|
const currentTableNodeLocalId = (_node$attrs$localId = node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) !== null && _node$attrs$localId !== void 0 ? _node$attrs$localId : '';
|
|
297
310
|
const fullWidthGuideline = defaultGuidelinesForPreserveTable(PRESERVE_TABLE_GUIDELINES_LENGTH_OFFSET, editorContainerWidth, excludeGuidelineConfig).filter(guideline => guideline.isFullWidth)[0];
|
|
298
311
|
const isFullWidthGuidelineActive = expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? closestSnap && fullWidthGuideline && closestSnap.keys.includes(fullWidthGuideline.key) : closestSnap && closestSnap.keys.includes(fullWidthGuideline.key);
|
|
299
|
-
const tableMaxWidth = isCommentEditor ? Math.floor(containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR) : expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? TABLE_MAX_WIDTH : TABLE_FULL_WIDTH;
|
|
300
|
-
const shouldUpdateWidthToWidest = isCommentEditor ? tableMaxWidth <= newWidth : !!isTableScalingEnabled && isFullWidthGuidelineActive;
|
|
301
|
-
const previewParentWidth = isCommentEditor && shouldUpdateWidthToWidest ? tableMaxWidth : newWidth;
|
|
312
|
+
const tableMaxWidth = expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) ? getTableMaxWidth(containerWidth, lineLength, isCommentEditor, isChromelessEditor) : isCommentEditor ? Math.floor(containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR) : expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? TABLE_MAX_WIDTH : TABLE_FULL_WIDTH;
|
|
313
|
+
const shouldUpdateWidthToWidest = expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor ? tableMaxWidth <= newWidth : !!isTableScalingEnabled && isFullWidthGuidelineActive;
|
|
314
|
+
const previewParentWidth = (expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor) && shouldUpdateWidthToWidest ? tableMaxWidth : newWidth;
|
|
302
315
|
previewScaleTable(tableRef, {
|
|
303
316
|
node,
|
|
304
317
|
prevNode: node,
|
|
305
318
|
start: pos + 1,
|
|
306
319
|
parentWidth: previewParentWidth
|
|
307
|
-
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled, allowFixedColumnWidthOption, isCommentEditor);
|
|
320
|
+
}, editorView.domAtPos.bind(editorView), isTableScalingEnabled, allowFixedColumnWidthOption, expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) ? !isFullPageAppearance : isCommentEditor);
|
|
308
321
|
chainCommands((state, dispatch) => {
|
|
309
322
|
return switchToCenterAlignment(pos, node, newWidth, state, dispatch);
|
|
310
323
|
}, updateWidthToWidest({
|
|
@@ -312,7 +325,7 @@ export const TableResizer = ({
|
|
|
312
325
|
}))(state, dispatch);
|
|
313
326
|
updateWidth(shouldUpdateWidthToWidest ? tableMaxWidth : newWidth);
|
|
314
327
|
return newWidth;
|
|
315
|
-
}, [countFrames, isCommentEditor, isTableScalingEnabled, allowFixedColumnWidthOption, isFullWidthModeEnabled, excludeGuidelineConfig, tableRef, node, editorView, updateActiveGuidelines, containerWidth, lineLength, updateWidth, getPos, switchToCenterAlignment]);
|
|
328
|
+
}, [countFrames, isCommentEditor, isChromelessEditor, isFullPageAppearance, isTableScalingEnabled, allowFixedColumnWidthOption, isFullWidthModeEnabled, excludeGuidelineConfig, tableRef, node, editorView, updateActiveGuidelines, containerWidth, lineLength, updateWidth, getPos, switchToCenterAlignment]);
|
|
316
329
|
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
317
330
|
const handleResizeStop = useCallback((originalState, delta) => {
|
|
318
331
|
var _node$attrs$localId2, _node$attrs2, _pluginInjectionApi$u3;
|
|
@@ -325,7 +338,7 @@ export const TableResizer = ({
|
|
|
325
338
|
} = editorView;
|
|
326
339
|
const pos = getPos();
|
|
327
340
|
const currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
|
|
328
|
-
const tableMaxWidth = isCommentEditor ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
|
|
341
|
+
const tableMaxWidth = expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
|
|
329
342
|
: expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true) ? TABLE_MAX_WIDTH : TABLE_FULL_WIDTH;
|
|
330
343
|
newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? tableMaxWidth : newWidth;
|
|
331
344
|
let tr = state.tr.setMeta(tableWidthPluginKey, {
|
|
@@ -367,8 +380,9 @@ export const TableResizer = ({
|
|
|
367
380
|
// We use originalNewWidth in comment editor, because in comment editor
|
|
368
381
|
// newWidth can be underined when table is resized to 'full-width'
|
|
369
382
|
// scaleTable function needs number value to work correctly.
|
|
370
|
-
|
|
371
|
-
|
|
383
|
+
// remove isCommentEditor check when platform_editor_table_resize_chromeless is removed
|
|
384
|
+
parentWidth: expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) && !isFullPageAppearance || isCommentEditor ? originalNewWidth : newWidth
|
|
385
|
+
}, editorView.domAtPos.bind(editorView), pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent || false, expValEquals('platform_editor_table_resize_chromeless', 'isEnabled', true) ? !isFullPageAppearance : isCommentEditor)(tr);
|
|
372
386
|
|
|
373
387
|
// Ignored via go/ees005
|
|
374
388
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -404,7 +418,7 @@ export const TableResizer = ({
|
|
|
404
418
|
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('tableResize');
|
|
405
419
|
}
|
|
406
420
|
return newWidth;
|
|
407
|
-
}, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
|
|
421
|
+
}, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage, isFullPageAppearance]);
|
|
408
422
|
const handleTableSizeChangeOnKeypress = useCallback(step => {
|
|
409
423
|
const newWidth = width + step;
|
|
410
424
|
if (newWidth < resizerMinWidth) {
|
|
@@ -87,7 +87,7 @@ export const generateColgroupFromNode = (table, isCommentEditor, isChromelessEdi
|
|
|
87
87
|
});
|
|
88
88
|
return cols;
|
|
89
89
|
};
|
|
90
|
-
export const generateColgroup = (table, tableRef, shouldUseIncreasedScalingPercent,
|
|
90
|
+
export const generateColgroup = (table, tableRef, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor) => {
|
|
91
91
|
const cols = [];
|
|
92
92
|
const map = TableMap.get(table);
|
|
93
93
|
|
|
@@ -102,7 +102,7 @@ export const generateColgroup = (table, tableRef, shouldUseIncreasedScalingPerce
|
|
|
102
102
|
var _table$attrs;
|
|
103
103
|
// if we have tableRef here, isTableScalingEnabled is true
|
|
104
104
|
let scalePercent = 1;
|
|
105
|
-
if (
|
|
105
|
+
if (isCommentOrChromelessEditor && !((_table$attrs = table.attrs) !== null && _table$attrs !== void 0 && _table$attrs.width)) {
|
|
106
106
|
scalePercent = getScalingPercentForTableWithoutWidth(table, tableRef);
|
|
107
107
|
} else {
|
|
108
108
|
scalePercent = getTableScalingPercent(table, tableRef, shouldUseIncreasedScalingPercent);
|
|
@@ -136,14 +136,14 @@ export const generateColgroup = (table, tableRef, shouldUseIncreasedScalingPerce
|
|
|
136
136
|
});
|
|
137
137
|
return cols;
|
|
138
138
|
};
|
|
139
|
-
export const insertColgroupFromNode = (tableRef, table, isTableScalingEnabled = false, shouldRemove = true, shouldUseIncreasedScalingPercent = false,
|
|
139
|
+
export const insertColgroupFromNode = (tableRef, table, isTableScalingEnabled = false, shouldRemove = true, shouldUseIncreasedScalingPercent = false, isCommentOrChromelessEditor = false) => {
|
|
140
140
|
// Ignored via go/ees005
|
|
141
141
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
142
142
|
let colgroup = tableRef === null || tableRef === void 0 ? void 0 : tableRef.querySelector('colgroup');
|
|
143
143
|
if (colgroup && shouldRemove) {
|
|
144
144
|
tableRef === null || tableRef === void 0 ? void 0 : tableRef.removeChild(colgroup);
|
|
145
145
|
}
|
|
146
|
-
colgroup = renderColgroupFromNode(table, isTableScalingEnabled ? tableRef !== null && tableRef !== void 0 ? tableRef : undefined : undefined, shouldUseIncreasedScalingPercent,
|
|
146
|
+
colgroup = renderColgroupFromNode(table, isTableScalingEnabled ? tableRef !== null && tableRef !== void 0 ? tableRef : undefined : undefined, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor);
|
|
147
147
|
if (shouldRemove) {
|
|
148
148
|
tableRef === null || tableRef === void 0 ? void 0 : tableRef.insertBefore(colgroup, tableRef === null || tableRef === void 0 ? void 0 : tableRef.firstChild);
|
|
149
149
|
}
|
|
@@ -171,8 +171,8 @@ export const isMinCellWidthTable = table => {
|
|
|
171
171
|
});
|
|
172
172
|
return isTableMinCellWidth;
|
|
173
173
|
};
|
|
174
|
-
function renderColgroupFromNode(table, maybeTableRef, shouldUseIncreasedScalingPercent,
|
|
175
|
-
const rendered = DOMSerializer.renderSpec(document, ['colgroup', {}, ...generateColgroup(table, maybeTableRef, shouldUseIncreasedScalingPercent,
|
|
174
|
+
function renderColgroupFromNode(table, maybeTableRef, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor) {
|
|
175
|
+
const rendered = DOMSerializer.renderSpec(document, ['colgroup', {}, ...generateColgroup(table, maybeTableRef, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor)]);
|
|
176
176
|
|
|
177
177
|
// Ignored via go/ees005
|
|
178
178
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -8,4 +8,5 @@ export const MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION = 0.4;
|
|
|
8
8
|
export const TABLE_EDITOR_MARGIN = 76;
|
|
9
9
|
const COMMENT_AK_EDITOR_CONTENT_AREA_PADDING = 20;
|
|
10
10
|
const COMMENT_PM_TABLE_RESIZING_PLUGIN_MARGIN = 12;
|
|
11
|
-
export const TABLE_OFFSET_IN_COMMENT_EDITOR = 2 * (COMMENT_AK_EDITOR_CONTENT_AREA_PADDING + COMMENT_PM_TABLE_RESIZING_PLUGIN_MARGIN);
|
|
11
|
+
export const TABLE_OFFSET_IN_COMMENT_EDITOR = 2 * (COMMENT_AK_EDITOR_CONTENT_AREA_PADDING + COMMENT_PM_TABLE_RESIZING_PLUGIN_MARGIN);
|
|
12
|
+
export const RESIZE_HANDLE_SPACING = 12;
|
|
@@ -101,7 +101,7 @@ export function scaleTableTo(state, maxSize) {
|
|
|
101
101
|
}
|
|
102
102
|
return adjustColumnsWidths(newState, maxSize);
|
|
103
103
|
}
|
|
104
|
-
export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEnabled = false, allowFixedColumnWidthOption = false,
|
|
104
|
+
export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEnabled = false, allowFixedColumnWidthOption = false, isCommentOrChromelessEditor = false) => {
|
|
105
105
|
const {
|
|
106
106
|
node,
|
|
107
107
|
start,
|
|
@@ -126,7 +126,7 @@ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEna
|
|
|
126
126
|
syncStickyRowToTable(tableRef);
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
-
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || isTableScalingEnabled &&
|
|
129
|
+
const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled || isTableScalingEnabled && isCommentOrChromelessEditor;
|
|
130
130
|
const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, false,
|
|
131
131
|
// Here isTableScalingEnabled = false
|
|
132
132
|
shouldUseIncreasedScalingPercent) : scale(tableRef, options, domAtPos, false, shouldUseIncreasedScalingPercent);
|
|
@@ -136,7 +136,7 @@ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEna
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
// Scale the table to meet new requirements (col, layout change etc)
|
|
139
|
-
export const scaleTable = (tableRef, options, domAtPos, api, isTableScalingEnabledOnCurrentTable = false, shouldUseIncreasedScalingPercent = false,
|
|
139
|
+
export const scaleTable = (tableRef, options, domAtPos, api, isTableScalingEnabledOnCurrentTable = false, shouldUseIncreasedScalingPercent = false, isCommentOrChromelessEditor = false) => tr => {
|
|
140
140
|
if (!tableRef) {
|
|
141
141
|
return tr;
|
|
142
142
|
}
|
|
@@ -152,7 +152,7 @@ export const scaleTable = (tableRef, options, domAtPos, api, isTableScalingEnabl
|
|
|
152
152
|
// To force reflow of columns upon delete.
|
|
153
153
|
if (!isTableScalingEnabledOnCurrentTable) {
|
|
154
154
|
const isTableScalingEnabled = false;
|
|
155
|
-
insertColgroupFromNode(tableRef, node, isTableScalingEnabled, undefined, shouldUseIncreasedScalingPercent,
|
|
155
|
+
insertColgroupFromNode(tableRef, node, isTableScalingEnabled, undefined, shouldUseIncreasedScalingPercent, isCommentOrChromelessEditor);
|
|
156
156
|
}
|
|
157
157
|
tr.setMeta('scrollIntoView', false);
|
|
158
158
|
return tr;
|