@atlaskit/editor-plugin-table 15.2.1 → 15.2.3

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/nodeviews/TableComponentLegacy.js +23 -35
  3. package/dist/cjs/nodeviews/TableComponentNext.js +24 -36
  4. package/dist/cjs/nodeviews/TableContainer.js +31 -215
  5. package/dist/cjs/nodeviews/TableResizer.js +7 -12
  6. package/dist/cjs/nodeviews/table.js +1 -2
  7. package/dist/cjs/nodeviews/toDOM.js +9 -27
  8. package/dist/cjs/pm-plugins/drag-and-drop/utils/getDragBehaviour.js +3 -1
  9. package/dist/cjs/pm-plugins/main.js +3 -31
  10. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +1 -2
  11. package/dist/cjs/tablePlugin.js +2 -1
  12. package/dist/cjs/ui/DragHandle/index.js +4 -2
  13. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +5 -8
  14. package/dist/cjs/ui/TableFloatingControls/index.js +5 -2
  15. package/dist/cjs/ui/common-styles.js +2 -1
  16. package/dist/es2019/nodeviews/TableComponentLegacy.js +15 -27
  17. package/dist/es2019/nodeviews/TableComponentNext.js +16 -28
  18. package/dist/es2019/nodeviews/TableContainer.js +9 -190
  19. package/dist/es2019/nodeviews/TableResizer.js +6 -11
  20. package/dist/es2019/nodeviews/table.js +1 -2
  21. package/dist/es2019/nodeviews/toDOM.js +9 -28
  22. package/dist/es2019/pm-plugins/drag-and-drop/utils/getDragBehaviour.js +3 -1
  23. package/dist/es2019/pm-plugins/main.js +4 -32
  24. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +1 -2
  25. package/dist/es2019/tablePlugin.js +2 -1
  26. package/dist/es2019/ui/DragHandle/index.js +3 -1
  27. package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +2 -5
  28. package/dist/es2019/ui/TableFloatingControls/index.js +4 -1
  29. package/dist/es2019/ui/common-styles.js +2 -1
  30. package/dist/esm/nodeviews/TableComponentLegacy.js +24 -36
  31. package/dist/esm/nodeviews/TableComponentNext.js +25 -37
  32. package/dist/esm/nodeviews/TableContainer.js +31 -215
  33. package/dist/esm/nodeviews/TableResizer.js +6 -11
  34. package/dist/esm/nodeviews/table.js +1 -2
  35. package/dist/esm/nodeviews/toDOM.js +10 -28
  36. package/dist/esm/pm-plugins/drag-and-drop/utils/getDragBehaviour.js +3 -1
  37. package/dist/esm/pm-plugins/main.js +4 -32
  38. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +1 -2
  39. package/dist/esm/tablePlugin.js +2 -1
  40. package/dist/esm/ui/DragHandle/index.js +3 -1
  41. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +5 -8
  42. package/dist/esm/ui/TableFloatingControls/index.js +4 -1
  43. package/dist/esm/ui/common-styles.js +2 -1
  44. package/dist/types/nodeviews/TableContainer.d.ts +1 -3
  45. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +1 -3
  46. package/package.json +4 -4
@@ -6,8 +6,6 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
6
6
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
7
7
  import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
- import { componentWithCondition } from '@atlaskit/platform-feature-flags-react';
10
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
10
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
13
11
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -79,8 +77,8 @@ const AlignmentTableContainer = ({
79
77
  }, [alignment]);
80
78
  return /*#__PURE__*/React.createElement("div", {
81
79
  "data-testid": "table-alignment-container",
82
- "data-ssr-placeholder": expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? `table-${node.attrs.localId}` : undefined,
83
- "data-ssr-placeholder-replace": expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? `table-${node.attrs.localId}` : undefined
80
+ "data-ssr-placeholder": `table-${node.attrs.localId}`,
81
+ "data-ssr-placeholder-replace": `table-${node.attrs.localId}`
84
82
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
85
83
  ,
86
84
  style: style
@@ -97,8 +95,8 @@ const AlignmentTableContainerWrapper = ({
97
95
  if (!isTableAlignmentEnabled) {
98
96
  return /*#__PURE__*/React.createElement("div", {
99
97
  "data-testid": "table-alignment-container",
100
- "data-ssr-placeholder": expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? `table-${node.attrs.localId}` : undefined,
101
- "data-ssr-placeholder-replace": expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? `table-${node.attrs.localId}` : undefined,
98
+ "data-ssr-placeholder": `table-${node.attrs.localId}`,
99
+ "data-ssr-placeholder-replace": `table-${node.attrs.localId}`,
102
100
  style: {
103
101
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
104
102
  display: 'flex',
@@ -123,7 +121,7 @@ const getPadding = containerWidth => {
123
121
  exposure: true
124
122
  }) ? akEditorGutterPaddingReduced : akEditorGutterPaddingDynamic();
125
123
  };
126
- const ResizableTableContainerLegacy = /*#__PURE__*/React.memo(({
124
+ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
127
125
  children,
128
126
  className,
129
127
  node,
@@ -140,8 +138,10 @@ const ResizableTableContainerLegacy = /*#__PURE__*/React.memo(({
140
138
  isTableWithFixedColumnWidthsOptionEnabled,
141
139
  isTableAlignmentEnabled,
142
140
  shouldUseIncreasedScalingPercent,
143
- isCommentEditor
141
+ isCommentEditor,
142
+ isChromelessEditor
144
143
  }) => {
144
+ const tableWidth = getTableContainerWidth(node);
145
145
  const containerRef = useRef(null);
146
146
  const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
147
147
  const [resizing, setIsResizing] = useState(false);
@@ -203,185 +203,6 @@ const ResizableTableContainerLegacy = /*#__PURE__*/React.memo(({
203
203
  var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$s;
204
204
  return (_pluginInjectionApi$c = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c2 = pluginInjectionApi.core) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$s = pluginInjectionApi.selection) === null || _pluginInjectionApi$s === void 0 ? void 0 : _pluginInjectionApi$s.commands.displayGapCursor(toggle))) !== null && _pluginInjectionApi$c !== void 0 ? _pluginInjectionApi$c : false;
205
205
  }, [pluginInjectionApi]);
206
- const tableWidth = getTableContainerWidth(node);
207
- let responsiveContainerWidth = 0;
208
- const resizeHandleSpacing = 12;
209
- const padding = getPadding(containerWidth);
210
- // When Full width editor enabled, a Mac OS user can change "ak-editor-content-area" width by
211
- // updating Settings -> Appearance -> Show scroll bars from "When scrolling" to "Always". It causes
212
- // issues when viwport width is less than full width Editor's width. To detect avoid them
213
- // we need to use lineLength to defined responsiveWidth instead of containerWidth
214
- // (which does not get updated when Mac setting changes) in Full-width editor.
215
- if (isFullWidthModeEnabled) {
216
- // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
217
- // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
218
- // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
219
- responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - padding * 2 - resizeHandleSpacing;
220
-
221
- // platform_editor_table_fw_numcol_overflow_fix:
222
- // lineLength is undefined on first paint → width: NaN → wrapper expands to page
223
- // width. rAF col-sizing then runs before the number-column padding and
224
- // the final shrink, so column widths are locked in wrong.
225
- // With the flag ON, if the value isn’t finite we fall back to gutterWidth
226
- // for that first frame—no flash, no premature rAF.
227
- //
228
- // Type clean-up comes later:
229
- // 1) ship this runtime guard (quick fix, no breakage);
230
- // 2) TODO: widen lineLength to `number|undefined` and remove this block.
231
- if (fg('platform_editor_table_fw_numcol_overflow_fix')) {
232
- if (isTableScalingEnabled && !Number.isFinite(responsiveContainerWidth)) {
233
- responsiveContainerWidth = containerWidth - padding * 2 - resizeHandleSpacing;
234
- }
235
- }
236
- } else if (isCommentEditor) {
237
- responsiveContainerWidth = containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR;
238
- } else {
239
- // 76 is currently an accepted padding value considering the spacing for resizer handle
240
- // containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
241
- // a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
242
- // padding left = padding right = akEditorGutterPadding = 32
243
- responsiveContainerWidth = isTableScalingEnabled ? containerWidth - padding * 2 : containerWidth - padding * 2 - resizeHandleSpacing;
244
- }
245
- // Fix for HOT-119925: Ensure table width is properly constrained and responsive
246
- // For wide tables, ensure they don't exceed container width and can be scrolled
247
- const calculatedWidth = !node.attrs.width && isCommentEditor ? responsiveContainerWidth : Math.min(tableWidth, responsiveContainerWidth);
248
-
249
- // Ensure minimum width for usability while respecting container constraints
250
- const width = Math.max(calculatedWidth, Math.min(responsiveContainerWidth * 0.5, 300));
251
- if (!isResizing) {
252
- tableWidthRef.current = width;
253
- }
254
- const maxResizerWidth = isCommentEditor ? responsiveContainerWidth : Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
255
- const tableResizerProps = {
256
- width,
257
- maxWidth: maxResizerWidth,
258
- containerWidth,
259
- lineLength,
260
- updateWidth,
261
- editorView,
262
- getPos,
263
- node,
264
- tableRef,
265
- displayGuideline,
266
- attachAnalyticsEvent,
267
- displayGapCursor,
268
- isTableAlignmentEnabled,
269
- isFullWidthModeEnabled,
270
- isTableScalingEnabled,
271
- isTableWithFixedColumnWidthsOptionEnabled,
272
- isWholeTableInDanger,
273
- shouldUseIncreasedScalingPercent,
274
- pluginInjectionApi,
275
- onResizeStart,
276
- onResizeStop,
277
- isCommentEditor
278
- };
279
- const isLivePageViewMode = mode === 'view';
280
- return /*#__PURE__*/React.createElement(AlignmentTableContainerWrapper, {
281
- isTableAlignmentEnabled: isTableAlignmentEnabled,
282
- node: node,
283
- pluginInjectionApi: pluginInjectionApi,
284
- getPos: getPos,
285
- editorView: editorView
286
- }, /*#__PURE__*/React.createElement("div", {
287
- style: {
288
- width: tableWidthRef.current,
289
- height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto',
290
- position: isLivePageViewMode ? 'relative' : 'unset'
291
- }
292
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
293
- ,
294
- className: ClassName.TABLE_RESIZER_CONTAINER,
295
- ref: containerRef
296
- }, /*#__PURE__*/React.createElement(TableResizer, _extends({}, tableResizerProps, {
297
- disabled: isLivePageViewMode
298
- }), /*#__PURE__*/React.createElement(InnerContainer, {
299
- className: className,
300
- node: node
301
- }, children))));
302
- });
303
- const ResizableTableContainerNext = /*#__PURE__*/React.memo(({
304
- children,
305
- className,
306
- node,
307
- containerWidth,
308
- lineLength,
309
- editorView,
310
- getPos,
311
- tableRef,
312
- isResizing,
313
- pluginInjectionApi,
314
- tableWrapperHeight,
315
- isWholeTableInDanger,
316
- isTableScalingEnabled,
317
- isTableWithFixedColumnWidthsOptionEnabled,
318
- isTableAlignmentEnabled,
319
- shouldUseIncreasedScalingPercent,
320
- isCommentEditor,
321
- isChromelessEditor
322
- }) => {
323
- const tableWidth = getTableContainerWidth(node);
324
- const containerRef = useRef(null);
325
- const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
326
- const [resizing, setIsResizing] = useState(false);
327
- const {
328
- tableState,
329
- editorViewModeState
330
- } = useSharedPluginStateWithSelector(pluginInjectionApi, ['table', 'editorViewMode'], selector);
331
- const isFullWidthModeEnabled = tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled;
332
- const mode = editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode;
333
- const updateContainerHeight = useCallback(height => {
334
- var _containerRef$current3;
335
- // current StickyHeader State is not stable to be fetch.
336
- // we need to update stickyHeader plugin to make sure state can be
337
- // consistently fetch and refactor below
338
- const stickyHeaders = (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByClassName('pm-table-sticky');
339
- if (!stickyHeaders || stickyHeaders.length < 1) {
340
- // when starting to drag, we need to keep the original space,
341
- // -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
342
- // 1px is border width but collapse make it 0.5.
343
- // -- When sticky header appear, we should add first row height but reduce
344
- // collapsed border
345
- return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
346
- } else {
347
- var _containerRef$current4;
348
- const stickyHeaderHeight = ((_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
349
- return typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto';
350
- }
351
- }, []);
352
- const onResizeStart = useCallback(() => {
353
- setIsResizing(true);
354
- }, []);
355
- const onResizeStop = useCallback(() => {
356
- setIsResizing(false);
357
- }, []);
358
- const updateWidth = useCallback(width => {
359
- if (!containerRef.current) {
360
- return;
361
- }
362
-
363
- // make sure during resizing
364
- // the pm-table-resizer-container width is the same as its child div resizer-item
365
- // otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
366
- // and cause the fabric-editor-popup-scroll-parent to overflow
367
- if (containerRef.current.style.width !== `${width}px`) {
368
- containerRef.current.style.width = `${width}px`;
369
- }
370
- }, []);
371
- const displayGuideline = useCallback(guidelines => {
372
- var _pluginInjectionApi$g4, _pluginInjectionApi$g5, _pluginInjectionApi$g6;
373
- return (_pluginInjectionApi$g4 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$g5 = pluginInjectionApi.guideline) === null || _pluginInjectionApi$g5 === void 0 ? void 0 : (_pluginInjectionApi$g6 = _pluginInjectionApi$g5.actions) === null || _pluginInjectionApi$g6 === void 0 ? void 0 : _pluginInjectionApi$g6.displayGuideline(editorView)({
374
- guidelines
375
- })) !== null && _pluginInjectionApi$g4 !== void 0 ? _pluginInjectionApi$g4 : false;
376
- }, [pluginInjectionApi, editorView]);
377
- const attachAnalyticsEvent = useCallback(payload => {
378
- var _pluginInjectionApi$a3;
379
- return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions.attachAnalyticsEvent(payload);
380
- }, [pluginInjectionApi]);
381
- const displayGapCursor = useCallback(toggle => {
382
- var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$s2;
383
- return (_pluginInjectionApi$c3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c4 = pluginInjectionApi.core) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? 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;
384
- }, [pluginInjectionApi]);
385
206
  const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
386
207
  const {
387
208
  width,
@@ -512,7 +333,6 @@ const ResizableTableContainerNext = /*#__PURE__*/React.memo(({
512
333
  node: node
513
334
  }, children))));
514
335
  });
515
- export const ResizableTableContainer = componentWithCondition(() => expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true), ResizableTableContainerNext, ResizableTableContainerLegacy);
516
336
  export const TableContainer = ({
517
337
  children,
518
338
  node,
@@ -537,7 +357,6 @@ export const TableContainer = ({
537
357
  isCommentEditor,
538
358
  isChromelessEditor
539
359
  }) => {
540
- var _node$attrs$width;
541
360
  if (isTableResizingEnabled && !isNested) {
542
361
  return /*#__PURE__*/React.createElement(ResizableTableContainer
543
362
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -571,7 +390,7 @@ export const TableContainer = ({
571
390
  isDragAndDropEnabled
572
391
  } = getPluginState(editorView.state);
573
392
  const isFullPageAppearance = !isCommentEditor && !isChromelessEditor;
574
- const resizableTableWidth = expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? isFullPageAppearance ? getTableResizerContainerForFullPageWidthInCSS(node, isTableScalingEnabled) : `calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2))` : `min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2)), ${(_node$attrs$width = node.attrs.width) !== null && _node$attrs$width !== void 0 ? _node$attrs$width : '100%'})`;
393
+ const resizableTableWidth = isFullPageAppearance ? getTableResizerContainerForFullPageWidthInCSS(node, isTableScalingEnabled) : `calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2))`;
575
394
  return /*#__PURE__*/React.createElement(InnerContainer, {
576
395
  node: node
577
396
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useSta
2
2
  import rafSchd from 'raf-schd';
3
3
  import { useIntl } from 'react-intl-next';
4
4
  import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
5
- import { browser } from '@atlaskit/editor-common/browser';
5
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
6
6
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
7
7
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
8
  import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
@@ -414,15 +414,8 @@ export const TableResizer = ({
414
414
  }, [editorView, getPos, node, isCommentEditor, widthToWidest, isToolbarAIFCEnabled, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, pluginInjectionApi, attachAnalyticsEvent, tableRef, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
415
415
  const handleTableSizeChangeOnKeypress = useCallback(step => {
416
416
  const newWidth = width + step;
417
- if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
418
- if (newWidth < resizerMinWidth) {
419
- return;
420
- }
421
- } else {
422
- // maxWidth when platform_editor_tables_scaling_css off is always a number
423
- if (newWidth > maxWidth || newWidth < resizerMinWidth) {
424
- return;
425
- }
417
+ if (newWidth < resizerMinWidth) {
418
+ return;
426
419
  }
427
420
  handleResizeStop({
428
421
  width: width,
@@ -433,12 +426,13 @@ export const TableResizer = ({
433
426
  width: step,
434
427
  height: 0
435
428
  });
436
- }, [width, handleResizeStop, maxWidth, resizerMinWidth]);
429
+ }, [width, handleResizeStop, resizerMinWidth]);
437
430
  const handleEscape = useCallback(() => {
438
431
  editorView === null || editorView === void 0 ? void 0 : editorView.focus();
439
432
  }, [editorView]);
440
433
  const handleKeyDown = useCallback(event => {
441
434
  const isBracketKey = event.code === 'BracketRight' || event.code === 'BracketLeft';
435
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
442
436
  const metaKey = browser.mac ? event.metaKey : event.ctrlKey;
443
437
  if (event.altKey || metaKey || event.shiftKey) {
444
438
  areResizeMetaKeysPressed.current = true;
@@ -464,6 +458,7 @@ export const TableResizer = ({
464
458
  }
465
459
  const resizeHandleThumbEl = resizerRef.current.getResizerThumbEl();
466
460
  const globalKeyDownHandler = event => {
461
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
467
462
  const metaKey = browser.mac ? event.metaKey : event.ctrlKey;
468
463
  if (!isTableSelected) {
469
464
  return;
@@ -6,7 +6,6 @@ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
7
  import { TableMap } from '@atlaskit/editor-tables/table-map';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
9
  import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
11
10
  import { getPluginState } from '../pm-plugins/plugin-factory';
12
11
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
@@ -121,7 +120,7 @@ export default class TableView extends ReactNodeView {
121
120
  if (this.view.state.selection.visible) {
122
121
  selectionBookmark = this.view.state.selection.getBookmark();
123
122
  }
124
- if (this.dom && expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
123
+ if (this.dom) {
125
124
  this.dom.setAttribute('data-ssr-placeholder', `table-nodeview-${this.node.attrs.localId}`);
126
125
  this.dom.setAttribute('data-ssr-placeholder-replace', `table-nodeview-${this.node.attrs.localId}`);
127
126
  }
@@ -1,10 +1,8 @@
1
1
  import kebabCase from 'lodash/kebabCase';
2
2
  import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
3
3
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
4
- import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
5
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
- import { generateColgroup, generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
5
+ import { generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
8
6
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
9
7
  import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS, getTableResizerItemWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
10
8
  import { getAlignmentStyle } from './table-container-styles';
@@ -13,19 +11,8 @@ export const tableNodeSpecWithFixedToDOM = config => {
13
11
  return {
14
12
  ...tableNode,
15
13
  toDOM: node => {
16
- var _node$attrs$width;
17
- const gutterPadding = () => {
18
- if (editorExperiment('platform_editor_preview_panel_responsiveness', true, {
19
- exposure: true
20
- })) {
21
- return 'calc(var(--ak-editor--large-gutter-padding) * 2)';
22
- } else {
23
- return `${akEditorGutterPaddingDynamic() * 2}px`;
24
- }
25
- };
26
14
  const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`).join(';');
27
15
  const tableMinWidth = getResizerMinWidth(node);
28
- const tableWidthAttribute = node.attrs.width ? `${node.attrs.width}px` : `100%`;
29
16
  const isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
30
17
  const attrs = {
31
18
  'data-number-column': node.attrs.isNumberColumnEnabled,
@@ -33,22 +20,16 @@ export const tableNodeSpecWithFixedToDOM = config => {
33
20
  'data-autosize': node.attrs.__autoSize,
34
21
  'data-table-local-id': node.attrs.localId,
35
22
  'data-table-width': node.attrs.width,
36
- ...(expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && {
37
- 'data-ssr-placeholder': `table-${node.attrs.localId}`,
38
- 'data-ssr-placeholder-replace': `table-${node.attrs.localId}`
39
- })
23
+ 'data-ssr-placeholder': `table-${node.attrs.localId}`,
24
+ 'data-ssr-placeholder-replace': `table-${node.attrs.localId}`
40
25
  };
41
26
 
42
27
  // This would be used for table scaling in colgroup CSS
43
28
  // cqw, or px is well supported
44
- const 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)), ${(_node$attrs$width = node.attrs.width) !== null && _node$attrs$width !== void 0 ? _node$attrs$width : '100%'})`;
29
+ const resizableTableWidth = isFullPageEditor ? getTableResizerContainerForFullPageWidthInCSS(node, config.isTableScalingEnabled) : `calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2))`;
45
30
  let colgroup = '';
46
31
  if (config.allowColumnResizing) {
47
- if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
48
- colgroup = ['colgroup', {}, ...generateColgroupFromNode(node, config.isCommentEditor, config.isChromelessEditor, config.isNested, config.isTableScalingEnabled, config.shouldUseIncreasedScalingPercent)];
49
- } else {
50
- colgroup = ['colgroup', {}, ...generateColgroup(node)];
51
- }
32
+ colgroup = ['colgroup', {}, ...generateColgroupFromNode(node, config.isCommentEditor, config.isChromelessEditor, config.isNested, config.isTableScalingEnabled, config.shouldUseIncreasedScalingPercent)];
52
33
  }
53
34
 
54
35
  // For Chromeless editor, and nested tables in full page editor
@@ -97,7 +78,7 @@ export const tableNodeSpecWithFixedToDOM = config => {
97
78
  'data-testid': 'sticky-sentinel-bottom'
98
79
  }]];
99
80
  const tableContainerDiv = expValEquals('platform_editor_disable_table_overflow_shadows', 'cohort', 'variant1') || expValEquals('platform_editor_disable_table_overflow_shadows', 'cohort', 'variant2') || expValEquals('platform_editor_disable_table_overflow_shadows', 'cohort', 'variant3') ? tableContainerDivNext : tableContainerDivLegacy;
100
- if (!config.tableResizingEnabled || expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && config.isNested) {
81
+ if (!config.tableResizingEnabled || config.isNested) {
101
82
  return ['div', {
102
83
  class: 'tableView-content-wrap',
103
84
  'data-prosemirror-initial-toDOM-render': 'true',
@@ -114,7 +95,7 @@ export const tableNodeSpecWithFixedToDOM = config => {
114
95
  style: convertToInlineCss({
115
96
  '--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))',
116
97
  '--ak-editor-table-width': resizableTableWidth,
117
- width: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? `var(--ak-editor-table-width)` : `min(calc(100cqw - ${gutterPadding()}), ${tableWidthAttribute})`
98
+ width: `var(--ak-editor-table-width)`
118
99
  })
119
100
  }, ['div', {
120
101
  class: 'resizer-item display-handle',
@@ -125,8 +106,8 @@ export const tableNodeSpecWithFixedToDOM = config => {
125
106
  '--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
126
107
  '--ak-editor-table-min-width': `${tableMinWidth}px`,
127
108
  minWidth: 'var(--ak-editor-table-min-width)',
128
- 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))`,
129
- width: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? getTableResizerItemWidthInCSS(node, config.isCommentEditor, config.isChromelessEditor) : `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${tableWidthAttribute})`
109
+ maxWidth: getTableResizerContainerMaxWidthInCSS(config.isCommentEditor, config.isChromelessEditor, config.isTableScalingEnabled),
110
+ width: getTableResizerItemWidthInCSS(node, config.isCommentEditor, config.isChromelessEditor)
130
111
  })
131
112
  }, ['span', {
132
113
  class: 'resizer-hover-zone'
@@ -1,8 +1,10 @@
1
- import { browser } from '@atlaskit/editor-common/browser';
1
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  export const getDragBehaviour = ({
3
4
  altKey,
4
5
  ctrlKey
5
6
  }) => {
7
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
6
8
  const isCloneModifierKeyPressed = browser.mac ? altKey : ctrlKey;
7
9
  return isCloneModifierKeyPressed ? 'clone' : 'move';
8
10
  };
@@ -1,8 +1,9 @@
1
1
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- import { insideTable, isSSR } from '@atlaskit/editor-common/core-utils';
2
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
3
+ import { insideTable } from '@atlaskit/editor-common/core-utils';
3
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
5
  import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenLayoutNodes, transformSliceToRemoveOpenMultiBodiedExtension, transformSliceToRemoveOpenNestedExpand } from '@atlaskit/editor-common/transforms';
5
- import { browser, closestElement } from '@atlaskit/editor-common/utils';
6
+ import { closestElement } from '@atlaskit/editor-common/utils';
6
7
  import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
8
  import { TableMap } from '@atlaskit/editor-tables';
8
9
  import { findTable } from '@atlaskit/editor-tables/utils';
@@ -52,36 +53,6 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
52
53
  return editorView.state;
53
54
  };
54
55
  const getNodeView = () => {
55
- // Because the layout shift issues has been fixed under experiment platform_editor_tables_scaling_css, so still want to load nodeview on SSR if experiment is enabled
56
- if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
57
- return {
58
- table: tableView({
59
- portalProviderAPI,
60
- eventDispatcher,
61
- getEditorContainerWidth,
62
- getEditorFeatureFlags,
63
- dispatchAnalyticsEvent,
64
- pluginInjectionApi,
65
- isCommentEditor,
66
- isChromelessEditor
67
- }),
68
- tableRow: tableRowView({
69
- eventDispatcher,
70
- pluginInjectionApi
71
- }),
72
- tableCell: tableCellView({
73
- eventDispatcher,
74
- pluginInjectionApi
75
- }),
76
- tableHeader: tableHeaderView({
77
- eventDispatcher,
78
- pluginInjectionApi
79
- })
80
- };
81
- }
82
- if (isSSR()) {
83
- return undefined;
84
- }
85
56
  return {
86
57
  table: tableView({
87
58
  portalProviderAPI,
@@ -276,6 +247,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
276
247
  dispatch
277
248
  }, _pos, event) => {
278
249
  const decorationSet = decorationsPluginKey.getState(state);
250
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
279
251
  if (findControlsHoverDecoration(decorationSet).length) {
280
252
  clearHoverSelection()(state, dispatch);
281
253
  }
@@ -1,7 +1,6 @@
1
1
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
2
2
  import { tableCellMinWidth, tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
4
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
4
  import { getSelectedTableInfo } from '../../utils/analytics';
6
5
  import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
7
6
  import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
@@ -80,7 +79,7 @@ export const getResizeState = ({
80
79
 
81
80
  // updates Colgroup DOM node with new widths
82
81
  export const updateColgroup = (state, tableRef, tableNode, isTableScalingEnabled, scalePercent) => {
83
- const cols = expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? tableRef === null || tableRef === void 0 ? void 0 : tableRef.querySelectorAll(':scope > colgroup > col') : tableRef === null || tableRef === void 0 ? void 0 : tableRef.querySelectorAll('col');
82
+ const cols = tableRef === null || tableRef === void 0 ? void 0 : tableRef.querySelectorAll(':scope > colgroup > col');
84
83
  const columnsCount = cols === null || cols === void 0 ? void 0 : cols.length;
85
84
  /**
86
85
  updateColgroup will update whole table scale when click the column resize handle, this behavior will affect when table overflowed, when now resize handle been dragged and extend to make table overflowed, table will show overflow. This need to be confirmed because it conflict with how isTableScalingEnabled work.
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { tableCell, tableCellWithNestedTable, tableHeader, tableHeaderWithLocalId, tableHeaderWithNestedTable, tableRow, tableRowWithNestedTable, tableRowWithLocalId, tableCellWithLocalId, tableCellWithNestedTableWithLocalId, tableRowWithNestedTableWithLocalId, tableHeaderWithNestedTableWithLocalId } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
4
- import { browser } from '@atlaskit/editor-common/browser';
4
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
5
5
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
6
  import { IconTable } from '@atlaskit/editor-common/icons';
7
7
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
@@ -457,6 +457,7 @@ const tablePlugin = ({
457
457
  dispatch
458
458
  }) => isTableSelectorEnabled ? createSizeSelectorPlugin(dispatch) : undefined
459
459
  }];
460
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
460
461
 
461
462
  // Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
462
463
  // https://github.com/ProseMirror/prosemirror/issues/934
@@ -4,7 +4,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import ReactDOM from 'react-dom';
6
6
  import { injectIntl } from 'react-intl-next';
7
- import { browser } from '@atlaskit/editor-common/browser';
7
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
8
8
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
9
9
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -106,6 +106,7 @@ const DragHandleComponent = ({
106
106
  };
107
107
  useEffect(() => {
108
108
  const dragHandleDivRefCurrent = dragHandleDivRef.current;
109
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
109
110
  if (dragHandleDivRefCurrent) {
110
111
  return draggable({
111
112
  element: dragHandleDivRefCurrent,
@@ -161,6 +162,7 @@ const DragHandleComponent = ({
161
162
  }
162
163
  }, [tableLocalId, direction, indexes, isRow, editorView.state.selection, hasMergedCells]);
163
164
  const showDragMenuAnchorId = isRow ? 'drag-handle-button-row' : 'drag-handle-button-column';
165
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
164
166
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
165
167
  type: "button"
166
168
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -4,7 +4,6 @@ import classnames from 'classnames';
4
4
  import { isSSR } from '@atlaskit/editor-common/core-utils';
5
5
  import { Selection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { isRowSelected } from '@atlaskit/editor-tables/utils';
7
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
7
  import { clearHoverSelection } from '../../../pm-plugins/commands';
9
8
  import { getRowHeights } from '../../../pm-plugins/utils/row-controls';
10
9
  import { TableCssClassName as ClassName } from '../../../types';
@@ -96,7 +95,7 @@ export default class NumberColumn extends Component {
96
95
  updateCellHoverLocation
97
96
  } = this.props;
98
97
  const rowHeights = getRowHeights(tableRef);
99
- if (isSSR() && expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
98
+ if (isSSR()) {
100
99
  return /*#__PURE__*/React.createElement("div", {
101
100
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
102
101
  className: ClassName.NUMBERED_COLUMN,
@@ -122,9 +121,7 @@ export default class NumberColumn extends Component {
122
121
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
123
122
  isDragAndDropEnabled && tableActive ? `1px solid ${tableBorderColor}` : undefined,
124
123
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
125
- ...(expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) ? {
126
- visibility: 'visible'
127
- } : {})
124
+ visibility: 'visible'
128
125
  },
129
126
  contentEditable: false
130
127
  }, rowHeights.map((rowHeight, index) => isDragAndDropEnabled ?
@@ -1,7 +1,8 @@
1
1
  import React, { useCallback } from 'react';
2
- import { browser } from '@atlaskit/editor-common/browser';
2
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
3
3
  import { findTable } from '@atlaskit/editor-tables/utils';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
6
  import { hoverCell, hoverRows, selectRow, selectRows } from '../../pm-plugins/commands';
6
7
  import { isTableNested } from '../../pm-plugins/utils/nodes';
7
8
  import { TableCssClassName as ClassName } from '../../types';
@@ -36,6 +37,7 @@ export const TableFloatingControls = ({
36
37
  state,
37
38
  dispatch
38
39
  } = editorView;
40
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
39
41
  if (browser.ie_version === 11) {
40
42
  // Ignored via go/ees005
41
43
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -48,6 +50,7 @@ export const TableFloatingControls = ({
48
50
  state,
49
51
  dispatch
50
52
  } = editorView;
53
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
51
54
  if (browser.ie_version === 11) {
52
55
  // Ignored via go/ees005
53
56
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
@@ -5,7 +5,7 @@
5
5
 
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css } from '@emotion/react';
8
- import { browser } from '@atlaskit/editor-common/browser';
8
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
9
9
  import { tableMarginTop, tableSharedStyle } from '@atlaskit/editor-common/styles';
10
10
  import { SORTABLE_COLUMN_ICON_CLASSNAME } from '@atlaskit/editor-common/table';
11
11
  import { akEditorSelectedNodeClassName, akEditorSmallZIndex, akEditorStickyHeaderZIndex, akEditorTableCellOnStickyHeaderZIndex, akEditorTableNumberColumnWidth, akEditorTableToolbarSize, akEditorUnitZIndex, getSelectionStyles, MAX_BROWSER_SCROLLBAR_HEIGHT, SelectionStyle, relativeSizeToBaseFontSize, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
@@ -189,6 +189,7 @@ const tableStickyHeaderColumnControlsDecorationsStyle = () => {
189
189
  `;
190
190
  };
191
191
  const tableStickyHeaderFirefoxFixStyle = () => {
192
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
192
193
  /*
193
194
  This is MAGIC!
194
195
  This fixes a bug which occurs in firefox when the first row becomes sticky.