@atlaskit/editor-plugin-table 12.1.14 → 12.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 +25 -0
- package/afm-cc/tsconfig.json +6 -0
- package/afm-dev-agents/tsconfig.json +6 -0
- package/afm-jira/tsconfig.json +6 -0
- package/afm-passionfruit/tsconfig.json +120 -0
- package/afm-post-office/tsconfig.json +6 -0
- package/afm-rovo-extension/tsconfig.json +6 -0
- package/afm-townsquare/tsconfig.json +6 -0
- package/afm-volt/tsconfig.json +13 -4
- package/dist/cjs/nodeviews/TableComponent.js +77 -26
- package/dist/cjs/nodeviews/TableContainer.js +270 -10
- package/dist/cjs/nodeviews/TableResizer.js +9 -2
- package/dist/cjs/nodeviews/TableRow.js +24 -1
- package/dist/cjs/nodeviews/table-node-views.js +1 -1
- package/dist/cjs/nodeviews/table.js +22 -7
- package/dist/cjs/nodeviews/toDOM.js +23 -7
- package/dist/cjs/pm-plugins/main.js +57 -22
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +72 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +70 -1
- package/dist/cjs/tablePlugin.js +17 -3
- package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +2 -7
- package/dist/es2019/nodeviews/TableComponent.js +80 -26
- package/dist/es2019/nodeviews/TableContainer.js +256 -2
- package/dist/es2019/nodeviews/TableResizer.js +9 -2
- package/dist/es2019/nodeviews/TableRow.js +24 -1
- package/dist/es2019/nodeviews/table-node-views.js +1 -1
- package/dist/es2019/nodeviews/table.js +21 -6
- package/dist/es2019/nodeviews/toDOM.js +24 -8
- package/dist/es2019/pm-plugins/main.js +57 -22
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +72 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +70 -1
- package/dist/es2019/tablePlugin.js +17 -3
- package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +5 -14
- package/dist/esm/nodeviews/TableComponent.js +77 -26
- package/dist/esm/nodeviews/TableContainer.js +270 -10
- package/dist/esm/nodeviews/TableResizer.js +9 -2
- package/dist/esm/nodeviews/TableRow.js +24 -1
- package/dist/esm/nodeviews/table-node-views.js +1 -1
- package/dist/esm/nodeviews/table.js +22 -7
- package/dist/esm/nodeviews/toDOM.js +24 -8
- package/dist/esm/pm-plugins/main.js +57 -22
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +74 -3
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +70 -1
- package/dist/esm/tablePlugin.js +17 -3
- package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -6
- package/dist/types/nodeviews/ExternalDropTargets.d.ts +1 -1
- package/dist/types/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types/nodeviews/TableContainer.d.ts +7 -2
- package/dist/types/nodeviews/TableResizer.d.ts +1 -1
- package/dist/types/nodeviews/TableRow.d.ts +3 -1
- package/dist/types/nodeviews/table.d.ts +1 -1
- package/dist/types/nodeviews/toDOM.d.ts +5 -0
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/pm-plugins/analytics/commands.d.ts +2 -2
- package/dist/types/pm-plugins/analytics/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/analytics/utils/moved-event.d.ts +1 -1
- package/dist/types/pm-plugins/commands/column-resize.d.ts +10 -10
- package/dist/types/pm-plugins/commands/commands-with-analytics.d.ts +1 -1
- package/dist/types/pm-plugins/commands/go-to-next-cell.d.ts +1 -1
- package/dist/types/pm-plugins/commands/misc.d.ts +2 -2
- package/dist/types/pm-plugins/commands/selection.d.ts +6 -6
- package/dist/types/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +3 -3
- package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types/pm-plugins/drag-and-drop/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/sticky-headers/plugin-state.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +41 -0
- package/dist/types/pm-plugins/utils/create.d.ts +10 -10
- package/dist/types/pm-plugins/utils/decoration.d.ts +3 -3
- package/dist/types/pm-plugins/utils/dom.d.ts +2 -2
- package/dist/types/pm-plugins/utils/drag-menu.d.ts +3 -3
- package/dist/types/pm-plugins/utils/merged-cells.d.ts +3 -2
- package/dist/types/tablePluginType.d.ts +2 -0
- package/dist/types/ui/DragHandle/index.d.ts +4 -14
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -7
- package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -14
- package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +1 -7
- package/dist/types/ui/global-styles.d.ts +2 -8
- package/dist/types/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/ExternalDropTargets.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +7 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/TableRow.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/toDOM.d.ts +5 -0
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/analytics/commands.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/analytics/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/analytics/utils/moved-event.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/column-resize.d.ts +10 -10
- package/dist/types-ts4.5/pm-plugins/commands/commands-with-analytics.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/go-to-next-cell.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/commands/misc.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/commands/selection.d.ts +6 -6
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin-state.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +41 -0
- package/dist/types-ts4.5/pm-plugins/utils/create.d.ts +10 -10
- package/dist/types-ts4.5/pm-plugins/utils/decoration.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/utils/dom.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/utils/drag-menu.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/utils/merged-cells.d.ts +3 -2
- package/dist/types-ts4.5/tablePluginType.d.ts +2 -0
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +4 -14
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -7
- package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -14
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +1 -7
- package/dist/types-ts4.5/ui/global-styles.d.ts +2 -8
- package/dist/types-ts4.5/ui/hooks/useInternalTablePluginStateSelector.d.ts +1 -1
- package/package.json +10 -11
- package/src/nodeviews/TableComponent.tsx +113 -23
- package/src/nodeviews/TableContainer.tsx +331 -2
- package/src/nodeviews/TableResizer.tsx +10 -5
- package/src/nodeviews/TableRow.ts +38 -1
- package/src/nodeviews/table-node-views.ts +1 -1
- package/src/nodeviews/table.tsx +23 -0
- package/src/nodeviews/toDOM.ts +75 -9
- package/src/nodeviews/types.ts +1 -0
- package/src/pm-plugins/main.ts +41 -18
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +139 -6
- package/src/pm-plugins/table-resizing/utils/misc.ts +87 -0
- package/src/tablePlugin.tsx +21 -0
- package/src/tablePluginType.ts +2 -0
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +5 -14
- package/tsconfig.app.json +6 -0
- package/types/package.json +1 -1
- package/ui/common-styles/package.json +1 -1
|
@@ -3,14 +3,17 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
6
7
|
import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
7
8
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
8
9
|
import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
9
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
|
|
10
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
13
|
import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
|
|
12
14
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
13
15
|
import { TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
|
|
16
|
+
import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
|
|
14
17
|
import { ALIGN_CENTER, ALIGN_START } from '../pm-plugins/utils/alignment';
|
|
15
18
|
import { TableCssClassName as ClassName } from '../types';
|
|
16
19
|
import { getAlignmentStyle } from './table-container-styles';
|
|
@@ -152,7 +155,7 @@ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
|
152
155
|
var getPadding = function getPadding(containerWidth) {
|
|
153
156
|
return containerWidth <= akEditorFullPageNarrowBreakout && expValEquals('platform_editor_preview_panel_responsiveness', 'isEnabled', true) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
|
|
154
157
|
};
|
|
155
|
-
|
|
158
|
+
var ResizableTableContainerLegacy = /*#__PURE__*/React.memo(function (_ref4) {
|
|
156
159
|
var children = _ref4.children,
|
|
157
160
|
className = _ref4.className,
|
|
158
161
|
node = _ref4.node,
|
|
@@ -346,28 +349,283 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
|
|
|
346
349
|
node: node
|
|
347
350
|
}, children)) : null));
|
|
348
351
|
});
|
|
349
|
-
|
|
352
|
+
var ResizableTableContainerNext = /*#__PURE__*/React.memo(function (_ref5) {
|
|
350
353
|
var children = _ref5.children,
|
|
351
|
-
node = _ref5.node,
|
|
352
354
|
className = _ref5.className,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
lineLength = _ref5
|
|
355
|
+
node = _ref5.node,
|
|
356
|
+
containerWidth = _ref5.containerWidth,
|
|
357
|
+
lineLength = _ref5.lineLength,
|
|
356
358
|
editorView = _ref5.editorView,
|
|
357
359
|
getPos = _ref5.getPos,
|
|
358
360
|
tableRef = _ref5.tableRef,
|
|
359
|
-
isNested = _ref5.isNested,
|
|
360
|
-
tableWrapperHeight = _ref5.tableWrapperHeight,
|
|
361
361
|
isResizing = _ref5.isResizing,
|
|
362
|
+
isWindowResized = _ref5.isWindowResized,
|
|
362
363
|
pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
364
|
+
tableWrapperHeight = _ref5.tableWrapperHeight,
|
|
363
365
|
isWholeTableInDanger = _ref5.isWholeTableInDanger,
|
|
364
|
-
isTableResizingEnabled = _ref5.isTableResizingEnabled,
|
|
365
366
|
isTableScalingEnabled = _ref5.isTableScalingEnabled,
|
|
366
367
|
isTableWithFixedColumnWidthsOptionEnabled = _ref5.isTableWithFixedColumnWidthsOptionEnabled,
|
|
367
368
|
isTableAlignmentEnabled = _ref5.isTableAlignmentEnabled,
|
|
368
369
|
shouldUseIncreasedScalingPercent = _ref5.shouldUseIncreasedScalingPercent,
|
|
369
370
|
isCommentEditor = _ref5.isCommentEditor,
|
|
370
371
|
isChromelessEditor = _ref5.isChromelessEditor;
|
|
372
|
+
var tableWidth = getTableContainerWidth(node);
|
|
373
|
+
var containerRef = useRef(null);
|
|
374
|
+
var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
|
|
375
|
+
var _useState3 = useState(false),
|
|
376
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
377
|
+
resizing = _useState4[0],
|
|
378
|
+
setIsResizing = _useState4[1];
|
|
379
|
+
var _useState5 = useState(tableWidth),
|
|
380
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
381
|
+
tableMaxWidthForFullPageOnLoad = _useState6[0],
|
|
382
|
+
setTableMaxWidthForFullPageOnLoad = _useState6[1];
|
|
383
|
+
var _useSharedState2 = useSharedState(pluginInjectionApi),
|
|
384
|
+
tableState = _useSharedState2.tableState,
|
|
385
|
+
editorViewModeState = _useSharedState2.editorViewModeState;
|
|
386
|
+
var isFullWidthModeEnabled = tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
|
|
387
|
+
var mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
|
|
388
|
+
var updateContainerHeight = useCallback(function (height) {
|
|
389
|
+
var _containerRef$current3;
|
|
390
|
+
// current StickyHeader State is not stable to be fetch.
|
|
391
|
+
// we need to update stickyHeader plugin to make sure state can be
|
|
392
|
+
// consistently fetch and refactor below
|
|
393
|
+
var stickyHeaders = (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByClassName('pm-table-sticky');
|
|
394
|
+
if (!stickyHeaders || stickyHeaders.length < 1) {
|
|
395
|
+
// when starting to drag, we need to keep the original space,
|
|
396
|
+
// -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
|
|
397
|
+
// 1px is border width but collapse make it 0.5.
|
|
398
|
+
// -- When sticky header appear, we should add first row height but reduce
|
|
399
|
+
// collapsed border
|
|
400
|
+
return typeof height === 'number' ? "".concat(height + 40.5, "px") : 'auto';
|
|
401
|
+
} else {
|
|
402
|
+
var _containerRef$current4;
|
|
403
|
+
var stickyHeaderHeight = ((_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
|
|
404
|
+
return typeof height === 'number' ? "".concat(height + stickyHeaderHeight + 39.5, "px") : 'auto';
|
|
405
|
+
}
|
|
406
|
+
}, []);
|
|
407
|
+
var onResizeStart = useCallback(function () {
|
|
408
|
+
setIsResizing(true);
|
|
409
|
+
}, []);
|
|
410
|
+
var onResizeStop = useCallback(function () {
|
|
411
|
+
setIsResizing(false);
|
|
412
|
+
}, []);
|
|
413
|
+
var updateWidth = useCallback(function (width) {
|
|
414
|
+
if (!containerRef.current) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// make sure during resizing
|
|
419
|
+
// the pm-table-resizer-container width is the same as its child div resizer-item
|
|
420
|
+
// otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
|
|
421
|
+
// and cause the fabric-editor-popup-scroll-parent to overflow
|
|
422
|
+
if (containerRef.current.style.width !== "".concat(width, "px")) {
|
|
423
|
+
containerRef.current.style.width = "".concat(width, "px");
|
|
424
|
+
}
|
|
425
|
+
}, []);
|
|
426
|
+
var displayGuideline = useCallback(function (guidelines) {
|
|
427
|
+
var _pluginInjectionApi$g3, _pluginInjectionApi$g4;
|
|
428
|
+
return (_pluginInjectionApi$g3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$g4 = pluginInjectionApi.guideline) === null || _pluginInjectionApi$g4 === void 0 || (_pluginInjectionApi$g4 = _pluginInjectionApi$g4.actions) === null || _pluginInjectionApi$g4 === void 0 ? void 0 : _pluginInjectionApi$g4.displayGuideline(editorView)({
|
|
429
|
+
guidelines: guidelines
|
|
430
|
+
})) !== null && _pluginInjectionApi$g3 !== void 0 ? _pluginInjectionApi$g3 : false;
|
|
431
|
+
}, [pluginInjectionApi, editorView]);
|
|
432
|
+
var attachAnalyticsEvent = useCallback(function (payload) {
|
|
433
|
+
var _pluginInjectionApi$a3;
|
|
434
|
+
return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions.attachAnalyticsEvent(payload);
|
|
435
|
+
}, [pluginInjectionApi]);
|
|
436
|
+
var displayGapCursor = useCallback(function (toggle) {
|
|
437
|
+
var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$s2;
|
|
438
|
+
return (_pluginInjectionApi$c3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c4 = pluginInjectionApi.core) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$s2 = pluginInjectionApi.selection) === null || _pluginInjectionApi$s2 === void 0 ? void 0 : _pluginInjectionApi$s2.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c3 !== void 0 ? _pluginInjectionApi$c3 : false;
|
|
439
|
+
}, [pluginInjectionApi]);
|
|
440
|
+
var isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
|
|
441
|
+
var responsiveContainerWidth = 0;
|
|
442
|
+
var resizeHandleSpacing = 12;
|
|
443
|
+
var padding = getPadding(containerWidth);
|
|
444
|
+
// When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
|
|
445
|
+
// updating Settings -> Appearance -> Show scroll bars from "When scrolling" to "Always". It causes
|
|
446
|
+
// issues when viwport width is less than full width Editor's width. To detect avoid them
|
|
447
|
+
// we need to use lineLength to defined responsiveWidth instead of containerWidth
|
|
448
|
+
// (which does not get updated when Mac setting changes) in Full-width editor.
|
|
449
|
+
if (isFullWidthModeEnabled) {
|
|
450
|
+
// When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
|
|
451
|
+
// When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
|
|
452
|
+
// scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
|
|
453
|
+
responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - padding * 2 - resizeHandleSpacing;
|
|
454
|
+
|
|
455
|
+
// platform_editor_table_fw_numcol_overflow_fix:
|
|
456
|
+
// lineLength is undefined on first paint → width: NaN → wrapper expands to page
|
|
457
|
+
// width. rAF col-sizing then runs before the number-column padding and
|
|
458
|
+
// the final shrink, so column widths are locked in wrong.
|
|
459
|
+
// With the flag ON, if the value isn’t finite we fall back to gutterWidth
|
|
460
|
+
// for that first frame—no flash, no premature rAF.
|
|
461
|
+
//
|
|
462
|
+
// Type clean-up comes later:
|
|
463
|
+
// 1) ship this runtime guard (quick fix, no breakage);
|
|
464
|
+
// 2) TODO: widen lineLength to `number|undefined` and remove this block.
|
|
465
|
+
if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
|
|
466
|
+
if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
|
|
467
|
+
responsiveContainerWidth = containerWidth - padding * 2 - resizeHandleSpacing;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
} else if (isCommentEditor) {
|
|
471
|
+
responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
|
|
472
|
+
} else {
|
|
473
|
+
// 76 is currently an accepted padding value considering the spacing for resizer handle
|
|
474
|
+
// containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
|
|
475
|
+
// a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
|
|
476
|
+
// padding left = padding right = akEditorGutterPadding = 32
|
|
477
|
+
responsiveContainerWidth = isTableScalingEnabled ? containerWidth - padding * 2 : containerWidth - padding * 2 - resizeHandleSpacing;
|
|
478
|
+
}
|
|
479
|
+
var width = !node.attrs.width && isCommentEditor ? responsiveContainerWidth : Math.min(tableWidth, responsiveContainerWidth);
|
|
480
|
+
if (!isResizing) {
|
|
481
|
+
tableWidthRef.current = width;
|
|
482
|
+
}
|
|
483
|
+
var maxResizerWidth = isCommentEditor ? responsiveContainerWidth : Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
|
|
484
|
+
|
|
485
|
+
// CSS solution for table resizer item width
|
|
486
|
+
// The `width` is used for .resizer-item in <TableResizer>, and it has to be a number
|
|
487
|
+
// So we can't use min(var(--ak-editor-table-width), ${tableWidth}px) here
|
|
488
|
+
// We get the correct width from CSS value on page load
|
|
489
|
+
// After window resize, we use the width from plugin state
|
|
490
|
+
// After table resize, the table width attribute is used
|
|
491
|
+
var tableResizerItemWidth = useMemo(function () {
|
|
492
|
+
// if not on full page editor, we just rely on the width calculated from plugin state
|
|
493
|
+
// if on full page editor and after window resize, we use the width from plugin state
|
|
494
|
+
if (!isFullPageAppearance || isFullPageAppearance && isWindowResized) {
|
|
495
|
+
return width;
|
|
496
|
+
}
|
|
497
|
+
if (isResizing) {
|
|
498
|
+
return tableWidth;
|
|
499
|
+
}
|
|
500
|
+
// if on full page editor and on page load, we use the computed value from CSS
|
|
501
|
+
return Math.min(tableWidth, tableMaxWidthForFullPageOnLoad);
|
|
502
|
+
}, [isWindowResized, isResizing, isFullPageAppearance, tableMaxWidthForFullPageOnLoad, tableWidth, width]);
|
|
503
|
+
|
|
504
|
+
// CSS Solution for table resizer container width
|
|
505
|
+
var tableResizerContainerWidth = useMemo(function () {
|
|
506
|
+
return getTableResizerContainerForFullPageWidthInCSS(node, isTableScalingEnabled);
|
|
507
|
+
}, [node, isTableScalingEnabled]);
|
|
508
|
+
|
|
509
|
+
// CSS Solution for table resizer max width
|
|
510
|
+
var tableResizerMaxWidth = React.useMemo(function () {
|
|
511
|
+
var isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
|
|
512
|
+
var nonResizingMaxWidth = isFullPageAppearance ? getTableResizerContainerMaxWidthInCSS(isCommentEditor, isChromelessEditor, isTableScalingEnabled) : maxResizerWidth;
|
|
513
|
+
// isResizing is needed, otherwise we can't resize table.
|
|
514
|
+
// when not resizing, maxWidth is calculated based on the container width via CSS
|
|
515
|
+
return !isResizing ? nonResizingMaxWidth : maxResizerWidth;
|
|
516
|
+
}, [isCommentEditor, isChromelessEditor, isTableScalingEnabled, isResizing, maxResizerWidth]);
|
|
517
|
+
|
|
518
|
+
// on SSR, the width would be the default state, which is tableWidth
|
|
519
|
+
// but because we have maxWidth set to the editor container width via CSS
|
|
520
|
+
// So it would work just fine
|
|
521
|
+
useEffect(function () {
|
|
522
|
+
var _containerRef$current5;
|
|
523
|
+
if (!isSSR() && isFullPageAppearance && (_containerRef$current5 = containerRef.current) !== null && _containerRef$current5 !== void 0 && _containerRef$current5.firstElementChild) {
|
|
524
|
+
// get the computed value of max-width from '.resizer-item', because it uses `cqw` unit in CSS
|
|
525
|
+
var computedStyle = window.getComputedStyle(containerRef.current.firstElementChild);
|
|
526
|
+
var _containerWidth = computedStyle.maxWidth ? parseFloat(computedStyle.maxWidth) : tableWidth;
|
|
527
|
+
setTableMaxWidthForFullPageOnLoad(Math.min(_containerWidth, tableWidth));
|
|
528
|
+
}
|
|
529
|
+
}, [tableWidthRef, tableWidth, isFullPageAppearance]);
|
|
530
|
+
var tableResizerProps = {
|
|
531
|
+
width: tableResizerItemWidth,
|
|
532
|
+
maxWidth: tableResizerMaxWidth,
|
|
533
|
+
containerWidth: containerWidth,
|
|
534
|
+
lineLength: lineLength,
|
|
535
|
+
updateWidth: updateWidth,
|
|
536
|
+
editorView: editorView,
|
|
537
|
+
getPos: getPos,
|
|
538
|
+
node: node,
|
|
539
|
+
tableRef: tableRef,
|
|
540
|
+
displayGuideline: displayGuideline,
|
|
541
|
+
attachAnalyticsEvent: attachAnalyticsEvent,
|
|
542
|
+
displayGapCursor: displayGapCursor,
|
|
543
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
544
|
+
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
545
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
546
|
+
isTableWithFixedColumnWidthsOptionEnabled: isTableWithFixedColumnWidthsOptionEnabled,
|
|
547
|
+
isWholeTableInDanger: isWholeTableInDanger,
|
|
548
|
+
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
549
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
550
|
+
onResizeStart: onResizeStart,
|
|
551
|
+
onResizeStop: onResizeStop,
|
|
552
|
+
isCommentEditor: isCommentEditor
|
|
553
|
+
};
|
|
554
|
+
var isLivePageViewMode = mode === 'view';
|
|
555
|
+
return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
|
|
556
|
+
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
557
|
+
node: node,
|
|
558
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
559
|
+
getPos: getPos,
|
|
560
|
+
editorView: editorView
|
|
561
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
562
|
+
style: {
|
|
563
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
564
|
+
'--ak-editor-table-gutter-padding': 'calc(var(--ak-editor--large-gutter-padding) * 2)',
|
|
565
|
+
'--ak-editor-table-width': isFullPageAppearance ? tableResizerContainerWidth : "".concat(tableWidthRef.current, "px"),
|
|
566
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
567
|
+
width: 'var(--ak-editor-table-width)',
|
|
568
|
+
height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto',
|
|
569
|
+
position: isLivePageViewMode ? 'relative' : 'unset'
|
|
570
|
+
}
|
|
571
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
572
|
+
,
|
|
573
|
+
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
574
|
+
ref: containerRef
|
|
575
|
+
}, fg('platform_editor_live_page_prevent_table_recreation') ? null : isLivePageViewMode ? /*#__PURE__*/React.createElement(InnerContainer
|
|
576
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
577
|
+
, {
|
|
578
|
+
className: className,
|
|
579
|
+
node: node
|
|
580
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
581
|
+
,
|
|
582
|
+
style: {
|
|
583
|
+
width: 'inherit'
|
|
584
|
+
}
|
|
585
|
+
}, children) :
|
|
586
|
+
/*#__PURE__*/
|
|
587
|
+
// Ignored via go/ees005
|
|
588
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
589
|
+
React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
590
|
+
className: className,
|
|
591
|
+
node: node
|
|
592
|
+
}, children)), fg('platform_editor_live_page_prevent_table_recreation') ?
|
|
593
|
+
/*#__PURE__*/
|
|
594
|
+
// Ignored via go/ees005
|
|
595
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
596
|
+
React.createElement(TableResizer, _extends({}, tableResizerProps, {
|
|
597
|
+
disabled: isLivePageViewMode
|
|
598
|
+
}), /*#__PURE__*/React.createElement(InnerContainer, {
|
|
599
|
+
className: className,
|
|
600
|
+
node: node
|
|
601
|
+
}, children)) : null));
|
|
602
|
+
});
|
|
603
|
+
export var ResizableTableContainer = componentWithCondition(function () {
|
|
604
|
+
return expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true);
|
|
605
|
+
}, ResizableTableContainerNext, ResizableTableContainerLegacy);
|
|
606
|
+
export var TableContainer = function TableContainer(_ref6) {
|
|
607
|
+
var children = _ref6.children,
|
|
608
|
+
node = _ref6.node,
|
|
609
|
+
className = _ref6.className,
|
|
610
|
+
_ref6$containerWidth = _ref6.containerWidth,
|
|
611
|
+
editorWidth = _ref6$containerWidth.width,
|
|
612
|
+
lineLength = _ref6$containerWidth.lineLength,
|
|
613
|
+
editorView = _ref6.editorView,
|
|
614
|
+
getPos = _ref6.getPos,
|
|
615
|
+
tableRef = _ref6.tableRef,
|
|
616
|
+
isNested = _ref6.isNested,
|
|
617
|
+
tableWrapperHeight = _ref6.tableWrapperHeight,
|
|
618
|
+
isResizing = _ref6.isResizing,
|
|
619
|
+
isWindowResized = _ref6.isWindowResized,
|
|
620
|
+
pluginInjectionApi = _ref6.pluginInjectionApi,
|
|
621
|
+
isWholeTableInDanger = _ref6.isWholeTableInDanger,
|
|
622
|
+
isTableResizingEnabled = _ref6.isTableResizingEnabled,
|
|
623
|
+
isTableScalingEnabled = _ref6.isTableScalingEnabled,
|
|
624
|
+
isTableWithFixedColumnWidthsOptionEnabled = _ref6.isTableWithFixedColumnWidthsOptionEnabled,
|
|
625
|
+
isTableAlignmentEnabled = _ref6.isTableAlignmentEnabled,
|
|
626
|
+
shouldUseIncreasedScalingPercent = _ref6.shouldUseIncreasedScalingPercent,
|
|
627
|
+
isCommentEditor = _ref6.isCommentEditor,
|
|
628
|
+
isChromelessEditor = _ref6.isChromelessEditor;
|
|
371
629
|
if (isTableResizingEnabled && !isNested) {
|
|
372
630
|
return /*#__PURE__*/React.createElement(ResizableTableContainer
|
|
373
631
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -387,13 +645,15 @@ export var TableContainer = function TableContainer(_ref5) {
|
|
|
387
645
|
tableRef: tableRef,
|
|
388
646
|
tableWrapperHeight: tableWrapperHeight,
|
|
389
647
|
isResizing: isResizing,
|
|
648
|
+
isWindowResized: isWindowResized,
|
|
390
649
|
pluginInjectionApi: pluginInjectionApi,
|
|
391
650
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
392
651
|
isTableWithFixedColumnWidthsOptionEnabled: isTableWithFixedColumnWidthsOptionEnabled,
|
|
393
652
|
isWholeTableInDanger: isWholeTableInDanger,
|
|
394
653
|
isTableAlignmentEnabled: isTableAlignmentEnabled,
|
|
395
654
|
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
396
|
-
isCommentEditor: isCommentEditor
|
|
655
|
+
isCommentEditor: isCommentEditor,
|
|
656
|
+
isChromelessEditor: isChromelessEditor
|
|
397
657
|
}, children);
|
|
398
658
|
}
|
|
399
659
|
var _getPluginState = getPluginState(editorView.state),
|
|
@@ -397,8 +397,15 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
397
397
|
}, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, attachAnalyticsEvent, tableRef, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
|
|
398
398
|
var handleTableSizeChangeOnKeypress = useCallback(function (step) {
|
|
399
399
|
var newWidth = width + step;
|
|
400
|
-
if (
|
|
401
|
-
|
|
400
|
+
if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
|
|
401
|
+
if (newWidth < resizerMinWidth) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
} else {
|
|
405
|
+
// maxWidth when platform_editor_tables_scaling_css off is always a number
|
|
406
|
+
if (newWidth > maxWidth || newWidth < resizerMinWidth) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
402
409
|
}
|
|
403
410
|
handleResizeStop({
|
|
404
411
|
width: width,
|
|
@@ -28,10 +28,25 @@ var HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
|
28
28
|
// if too short it would trigger too many dom updates.
|
|
29
29
|
var HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
30
30
|
var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
31
|
-
function TableRow(node, view, getPos, eventDispatcher) {
|
|
31
|
+
function TableRow(node, view, getPos, eventDispatcher, api) {
|
|
32
|
+
var _api$limitedMode;
|
|
32
33
|
var _this;
|
|
33
34
|
_classCallCheck(this, TableRow);
|
|
34
35
|
_this = _callSuper(this, TableRow, [node, view, getPos, eventDispatcher]);
|
|
36
|
+
_defineProperty(_this, "cleanup", function () {
|
|
37
|
+
if (_this.isStickyHeaderEnabled) {
|
|
38
|
+
_this.unsubscribe();
|
|
39
|
+
_this.nodeVisibilityObserverCleanupFn && _this.nodeVisibilityObserverCleanupFn();
|
|
40
|
+
var tree = getTree(_this.dom);
|
|
41
|
+
if (tree) {
|
|
42
|
+
_this.makeRowHeaderNotSticky(tree.table, true);
|
|
43
|
+
}
|
|
44
|
+
_this.emitOff(false);
|
|
45
|
+
}
|
|
46
|
+
if (_this.tableContainerObserver) {
|
|
47
|
+
_this.tableContainerObserver.disconnect();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
35
50
|
_defineProperty(_this, "colControlsOffset", 0);
|
|
36
51
|
_defineProperty(_this, "focused", false);
|
|
37
52
|
_defineProperty(_this, "topPosEditorElement", 0);
|
|
@@ -71,6 +86,11 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
71
86
|
var _getPluginState = getPluginState(view.state),
|
|
72
87
|
pluginConfig = _getPluginState.pluginConfig;
|
|
73
88
|
_this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
89
|
+
if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.limitedModePluginKey.getState(view.state)) !== null && _api$limitedMode !== void 0 && _api$limitedMode.documentSizeBreachesThreshold) {
|
|
90
|
+
_this.isStickyHeaderEnabled = false;
|
|
91
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
92
|
+
document.addEventListener('limited-mode-activated', _this.cleanup);
|
|
93
|
+
}
|
|
74
94
|
var pos = _this.getPos();
|
|
75
95
|
_this.isInNestedTable = false;
|
|
76
96
|
if (pos) {
|
|
@@ -153,6 +173,9 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
153
173
|
}
|
|
154
174
|
this.emitOff(true);
|
|
155
175
|
}
|
|
176
|
+
|
|
177
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
178
|
+
document.removeEventListener('limited-mode-activated', this.cleanup);
|
|
156
179
|
if (this.tableContainerObserver) {
|
|
157
180
|
this.tableContainerObserver.disconnect();
|
|
158
181
|
}
|
|
@@ -21,6 +21,6 @@ export var tableHeaderView = function tableHeaderView(options) {
|
|
|
21
21
|
};
|
|
22
22
|
export var tableRowView = function tableRowView(options) {
|
|
23
23
|
return function (node, view, getPos) {
|
|
24
|
-
return new TableRow(node, view, getPos, options.eventDispatcher);
|
|
24
|
+
return new TableRow(node, view, getPos, options.eventDispatcher, options.pluginInjectionApi);
|
|
25
25
|
};
|
|
26
26
|
};
|
|
@@ -62,7 +62,9 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
62
62
|
function TableView(props) {
|
|
63
63
|
var _this;
|
|
64
64
|
_classCallCheck(this, TableView);
|
|
65
|
-
_this = _callSuper(this, TableView, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props
|
|
65
|
+
_this = _callSuper(this, TableView, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, undefined,
|
|
66
|
+
// @portal-render-immediately
|
|
67
|
+
true]);
|
|
66
68
|
_defineProperty(_this, "getNode", function () {
|
|
67
69
|
return _this.node;
|
|
68
70
|
});
|
|
@@ -80,10 +82,17 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
80
82
|
return _createClass(TableView, [{
|
|
81
83
|
key: "getContentDOM",
|
|
82
84
|
value: function getContentDOM() {
|
|
85
|
+
var _this$reactComponentP, _this$reactComponentP2, _this$reactComponentP3, _this$reactComponentP4;
|
|
86
|
+
var isNested = isTableNested(this.view.state, this.getPos());
|
|
83
87
|
var tableDOMStructure = tableNodeSpecWithFixedToDOM({
|
|
84
88
|
allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
|
|
85
89
|
tableResizingEnabled: !!this.reactComponentProps.allowTableResizing,
|
|
86
|
-
getEditorContainerWidth: this.reactComponentProps.getEditorContainerWidth
|
|
90
|
+
getEditorContainerWidth: this.reactComponentProps.getEditorContainerWidth,
|
|
91
|
+
isTableScalingEnabled: (_this$reactComponentP = this.reactComponentProps.options) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.isTableScalingEnabled,
|
|
92
|
+
shouldUseIncreasedScalingPercent: (_this$reactComponentP2 = this.reactComponentProps.options) === null || _this$reactComponentP2 === void 0 ? void 0 : _this$reactComponentP2.shouldUseIncreasedScalingPercent,
|
|
93
|
+
isCommentEditor: (_this$reactComponentP3 = this.reactComponentProps.options) === null || _this$reactComponentP3 === void 0 ? void 0 : _this$reactComponentP3.isCommentEditor,
|
|
94
|
+
isChromelessEditor: (_this$reactComponentP4 = this.reactComponentProps.options) === null || _this$reactComponentP4 === void 0 ? void 0 : _this$reactComponentP4.isChromelessEditor,
|
|
95
|
+
isNested: isNested
|
|
87
96
|
}).toDOM(this.node);
|
|
88
97
|
var rendered = DOMSerializer.renderSpec(document, tableDOMStructure);
|
|
89
98
|
if (rendered.dom) {
|
|
@@ -197,7 +206,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
197
206
|
}, {
|
|
198
207
|
key: "render",
|
|
199
208
|
value: function render(props, forwardRef) {
|
|
200
|
-
var
|
|
209
|
+
var _props$pluginInjectio,
|
|
210
|
+
_this4 = this;
|
|
201
211
|
if (fg('platform_editor_table_use_shared_state_hook_fg')) {
|
|
202
212
|
return /*#__PURE__*/React.createElement(TableComponentWithSharedState, {
|
|
203
213
|
forwardRef: forwardRef,
|
|
@@ -243,11 +253,12 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
243
253
|
tableWidthPluginState: tableWidthPluginKey,
|
|
244
254
|
widthPlugin: fakePluginKey,
|
|
245
255
|
mediaState: fakeMediaPluginKey,
|
|
246
|
-
tableDragAndDropState: tableDragAndDropPluginKey
|
|
256
|
+
tableDragAndDropState: tableDragAndDropPluginKey,
|
|
257
|
+
limitedModePlugin: (_props$pluginInjectio = props.pluginInjectionApi) === null || _props$pluginInjectio === void 0 || (_props$pluginInjectio = _props$pluginInjectio.limitedMode) === null || _props$pluginInjectio === void 0 || (_props$pluginInjectio = _props$pluginInjectio.sharedState.currentState()) === null || _props$pluginInjectio === void 0 ? void 0 : _props$pluginInjectio.limitedModePluginKey
|
|
247
258
|
},
|
|
248
259
|
editorView: props.view,
|
|
249
260
|
render: function render(pluginStates) {
|
|
250
|
-
var _props$options;
|
|
261
|
+
var _props$options, _pluginStates$limited, _pluginStates$limited2;
|
|
251
262
|
var tableResizingPluginState = pluginStates.tableResizingPluginState,
|
|
252
263
|
tableWidthPluginState = pluginStates.tableWidthPluginState,
|
|
253
264
|
pluginState = pluginStates.pluginState,
|
|
@@ -314,7 +325,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
314
325
|
contentDOM: forwardRef,
|
|
315
326
|
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
316
327
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
317
|
-
pluginInjectionApi: props.pluginInjectionApi
|
|
328
|
+
pluginInjectionApi: props.pluginInjectionApi,
|
|
329
|
+
limitedMode: (_pluginStates$limited = (_pluginStates$limited2 = pluginStates.limitedModePlugin) === null || _pluginStates$limited2 === void 0 ? void 0 : _pluginStates$limited2.documentSizeBreachesThreshold) !== null && _pluginStates$limited !== void 0 ? _pluginStates$limited : false
|
|
318
330
|
});
|
|
319
331
|
}
|
|
320
332
|
});
|
|
@@ -398,6 +410,8 @@ export var createTableView = function createTableView(node, view, getPos, portal
|
|
|
398
410
|
allowControls = _getPluginConfig.allowControls,
|
|
399
411
|
allowTableResizing = _getPluginConfig.allowTableResizing,
|
|
400
412
|
allowTableAlignment = _getPluginConfig.allowTableAlignment;
|
|
413
|
+
var isTableFixedColumnWidthsOptionEnabled = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().tableWithFixedColumnWidthsOption) || false;
|
|
414
|
+
var shouldUseIncreasedScalingPercent = isTableScalingEnabled && (isTableFixedColumnWidthsOptionEnabled || isCommentEditor);
|
|
401
415
|
return new TableView({
|
|
402
416
|
node: node,
|
|
403
417
|
view: view,
|
|
@@ -415,7 +429,8 @@ export var createTableView = function createTableView(node, view, getPos, portal
|
|
|
415
429
|
isTableScalingEnabled: isTableScalingEnabled,
|
|
416
430
|
// same as options.isTableScalingEnabled
|
|
417
431
|
isCommentEditor: isCommentEditor,
|
|
418
|
-
isChromelessEditor: isChromelessEditor
|
|
432
|
+
isChromelessEditor: isChromelessEditor,
|
|
433
|
+
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent
|
|
419
434
|
},
|
|
420
435
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
421
436
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
@@ -8,13 +8,15 @@ import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
|
|
|
8
8
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
9
9
|
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
|
-
import { generateColgroup, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
11
|
+
import { generateColgroup, generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
12
12
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
|
|
13
|
+
import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS, getTableResizerItemWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
|
|
13
14
|
import { getAlignmentStyle } from './table-container-styles';
|
|
14
15
|
export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
|
|
15
16
|
var tableNode = config.isNestingSupported ? tableWithNestedTable : table;
|
|
16
17
|
return _objectSpread(_objectSpread({}, tableNode), {}, {
|
|
17
18
|
toDOM: function toDOM(node) {
|
|
19
|
+
var _node$attrs$width;
|
|
18
20
|
var gutterPadding = function gutterPadding() {
|
|
19
21
|
if (expValEquals('platform_editor_preview_panel_responsiveness', 'isEnabled', true)) {
|
|
20
22
|
return 'calc(var(--ak-editor--large-gutter-padding) * 2)';
|
|
@@ -29,6 +31,8 @@ export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(co
|
|
|
29
31
|
return "".concat(kebabCase(k), ": ").concat(kebabCase(v));
|
|
30
32
|
}).join(';');
|
|
31
33
|
var tableMinWidth = getResizerMinWidth(node);
|
|
34
|
+
var tableWidthAttribute = node.attrs.width ? "".concat(node.attrs.width, "px") : "100%";
|
|
35
|
+
var isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
|
|
32
36
|
var attrs = {
|
|
33
37
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
34
38
|
'data-layout': node.attrs.layout,
|
|
@@ -36,10 +40,20 @@ export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(co
|
|
|
36
40
|
'data-table-local-id': node.attrs.localId,
|
|
37
41
|
'data-table-width': node.attrs.width
|
|
38
42
|
};
|
|
43
|
+
|
|
44
|
+
// This would be used for table scaling in colgroup CSS
|
|
45
|
+
// cqw, or px is well supported
|
|
46
|
+
var resizableTableWidth = expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? isFullPageEditor ? getTableResizerContainerForFullPageWidthInCSS(node, config.isTableScalingEnabled) : "calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2))" : "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2)), ".concat((_node$attrs$width = node.attrs.width) !== null && _node$attrs$width !== void 0 ? _node$attrs$width : '100%', ")");
|
|
39
47
|
var colgroup = '';
|
|
40
48
|
if (config.allowColumnResizing) {
|
|
41
|
-
|
|
49
|
+
if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
|
|
50
|
+
colgroup = ['colgroup', {}].concat(_toConsumableArray(generateColgroupFromNode(node, config.isCommentEditor, config.isChromelessEditor, config.isNested, config.isTableScalingEnabled, config.shouldUseIncreasedScalingPercent)));
|
|
51
|
+
} else {
|
|
52
|
+
colgroup = ['colgroup', {}].concat(_toConsumableArray(generateColgroup(node)));
|
|
53
|
+
}
|
|
42
54
|
}
|
|
55
|
+
|
|
56
|
+
// For Chromeless editor, and nested tables in full page editor
|
|
43
57
|
var tableContainerDiv = ['div', {
|
|
44
58
|
class: 'pm-table-container',
|
|
45
59
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
@@ -66,31 +80,33 @@ export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(co
|
|
|
66
80
|
class: 'pm-table-sticky-sentinel-bottom',
|
|
67
81
|
'data-testid': 'sticky-sentinel-bottom'
|
|
68
82
|
}]];
|
|
69
|
-
if (!config.tableResizingEnabled) {
|
|
83
|
+
if (!config.tableResizingEnabled || expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && config.isNested) {
|
|
70
84
|
return ['div', {
|
|
71
85
|
class: 'tableView-content-wrap',
|
|
72
86
|
'data-prosemirror-initial-toDOM-render': 'true'
|
|
73
87
|
}, tableContainerDiv];
|
|
74
88
|
}
|
|
75
|
-
var tableWidthAttribute = node.attrs.width ? "".concat(node.attrs.width, "px") : "100%";
|
|
76
89
|
var tableResizingDiv = ['div', {
|
|
77
90
|
'data-testid': 'table-alignment-container',
|
|
78
91
|
style: alignmentStyle
|
|
79
92
|
}, ['div', {
|
|
80
93
|
class: 'pm-table-resizer-container',
|
|
81
|
-
style:
|
|
94
|
+
style: convertToInlineCss({
|
|
95
|
+
'--ak-editor-table-gutter-padding': config.isTableScalingEnabled ? 'calc(var(--ak-editor--large-gutter-padding) * 2)' : 'calc(var(--ak-editor--large-gutter-padding) * 2 - var(--ak-editor-resizer-handle-spacing))',
|
|
96
|
+
'--ak-editor-table-width': resizableTableWidth,
|
|
97
|
+
width: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? "var(--ak-editor-table-width)" : "min(calc(100cqw - ".concat(gutterPadding(), "), ").concat(tableWidthAttribute, ")")
|
|
98
|
+
})
|
|
82
99
|
}, ['div', {
|
|
83
100
|
class: 'resizer-item display-handle',
|
|
84
101
|
style: convertToInlineCss({
|
|
85
102
|
position: 'relative',
|
|
86
103
|
userSelect: 'auto',
|
|
87
104
|
boxSizing: 'border-box',
|
|
88
|
-
'--ak-editor-table-gutter-padding': "".concat(gutterPadding()),
|
|
89
105
|
'--ak-editor-table-max-width': "".concat(TABLE_MAX_WIDTH, "px"),
|
|
90
106
|
'--ak-editor-table-min-width': "".concat(tableMinWidth, "px"),
|
|
91
107
|
minWidth: 'var(--ak-editor-table-min-width)',
|
|
92
|
-
maxWidth: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))",
|
|
93
|
-
width: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(tableWidthAttribute, ")")
|
|
108
|
+
maxWidth: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? getTableResizerContainerMaxWidthInCSS(config.isCommentEditor, config.isChromelessEditor, config.isTableScalingEnabled) : "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))",
|
|
109
|
+
width: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? getTableResizerItemWidthInCSS(node, config.isCommentEditor, config.isChromelessEditor) : "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(tableWidthAttribute, ")")
|
|
94
110
|
})
|
|
95
111
|
}, ['span', {
|
|
96
112
|
class: 'resizer-hover-zone'
|