@atlaskit/editor-plugin-table 8.2.0 → 8.2.1

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 8.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#169304](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169304)
8
+ [`305b55f6ac586`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/305b55f6ac586) -
9
+ Set alignment to center for tables during resizing, this fixes issues with tables in comment
10
+ editor where the width attribute defaults to inherit even if a table has been resized
11
+
3
12
  ## 8.2.0
4
13
 
5
14
  ### Minor Changes
@@ -22,6 +22,7 @@ var _resizer = require("@atlaskit/editor-common/resizer");
22
22
  var _commands = require("@atlaskit/editor-prosemirror/commands");
23
23
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
24
24
  var _utils = require("@atlaskit/editor-tables/utils");
25
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
26
  var _commandsWithAnalytics = require("../commands-with-analytics");
26
27
  var _misc = require("../commands/misc");
27
28
  var _tableAnalytics = require("../pm-plugins/table-analytics");
@@ -322,9 +323,16 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
322
323
  }
323
324
  if (typeof pos === 'number') {
324
325
  var _attachAnalyticsEvent2;
325
- tr = tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
326
- width: newWidth
327
- }));
326
+ if ((0, _platformFeatureFlags.fg)('platform_editor_set_alignment_when_resized')) {
327
+ tr = tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
328
+ width: newWidth,
329
+ layout: node.attrs.layout !== _alignment.ALIGN_START && node.attrs.layout !== _alignment.ALIGN_CENTER ? _alignment.ALIGN_CENTER : node.attrs.layout
330
+ }));
331
+ } else {
332
+ tr = tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
333
+ width: newWidth
334
+ }));
335
+ }
328
336
  var newNode = tr.doc.nodeAt(pos);
329
337
  tr = (0, _utils2.scaleTable)(tableRef, {
330
338
  node: newNode,
@@ -363,7 +371,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
363
371
  onResizeStop();
364
372
  }
365
373
  return newWidth;
366
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
374
+ }, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, attachAnalyticsEvent, tableRef, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
367
375
  var handleTableSizeChangeOnKeypress = (0, _react.useCallback)(function (step) {
368
376
  var newWidth = width + step;
369
377
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -12,6 +12,7 @@ import { ResizerNext } from '@atlaskit/editor-common/resizer';
12
12
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
13
13
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
14
14
  import { findTable } from '@atlaskit/editor-tables/utils';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
15
16
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
16
17
  import { updateWidthToWidest } from '../commands/misc';
17
18
  import { META_KEYS } from '../pm-plugins/table-analytics';
@@ -317,10 +318,18 @@ export const TableResizer = ({
317
318
  }
318
319
  if (typeof pos === 'number') {
319
320
  var _attachAnalyticsEvent2;
320
- tr = tr.setNodeMarkup(pos, undefined, {
321
- ...node.attrs,
322
- width: newWidth
323
- });
321
+ if (fg('platform_editor_set_alignment_when_resized')) {
322
+ tr = tr.setNodeMarkup(pos, undefined, {
323
+ ...node.attrs,
324
+ width: newWidth,
325
+ layout: node.attrs.layout !== ALIGN_START && node.attrs.layout !== ALIGN_CENTER ? ALIGN_CENTER : node.attrs.layout
326
+ });
327
+ } else {
328
+ tr = tr.setNodeMarkup(pos, undefined, {
329
+ ...node.attrs,
330
+ width: newWidth
331
+ });
332
+ }
324
333
  const newNode = tr.doc.nodeAt(pos);
325
334
  tr = scaleTable(tableRef, {
326
335
  node: newNode,
@@ -359,7 +368,7 @@ export const TableResizer = ({
359
368
  onResizeStop();
360
369
  }
361
370
  return newWidth;
362
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
371
+ }, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, attachAnalyticsEvent, tableRef, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
363
372
  const handleTableSizeChangeOnKeypress = useCallback(step => {
364
373
  const newWidth = width + step;
365
374
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -16,6 +16,7 @@ import { ResizerNext } from '@atlaskit/editor-common/resizer';
16
16
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
17
17
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
18
18
  import { findTable } from '@atlaskit/editor-tables/utils';
19
+ import { fg } from '@atlaskit/platform-feature-flags';
19
20
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
20
21
  import { updateWidthToWidest } from '../commands/misc';
21
22
  import { META_KEYS } from '../pm-plugins/table-analytics';
@@ -312,9 +313,16 @@ export var TableResizer = function TableResizer(_ref) {
312
313
  }
313
314
  if (typeof pos === 'number') {
314
315
  var _attachAnalyticsEvent2;
315
- tr = tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
316
- width: newWidth
317
- }));
316
+ if (fg('platform_editor_set_alignment_when_resized')) {
317
+ tr = tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
318
+ width: newWidth,
319
+ layout: node.attrs.layout !== ALIGN_START && node.attrs.layout !== ALIGN_CENTER ? ALIGN_CENTER : node.attrs.layout
320
+ }));
321
+ } else {
322
+ tr = tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
323
+ width: newWidth
324
+ }));
325
+ }
318
326
  var newNode = tr.doc.nodeAt(pos);
319
327
  tr = scaleTable(tableRef, {
320
328
  node: newNode,
@@ -353,7 +361,7 @@ export var TableResizer = function TableResizer(_ref) {
353
361
  onResizeStop();
354
362
  }
355
363
  return newWidth;
356
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
364
+ }, [editorView, getPos, node, isCommentEditor, widthToWidest, endMeasure, displayGapCursor, displayGuideline, updateWidth, scheduleResize, onResizeStop, attachAnalyticsEvent, tableRef, pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent, formatMessage]);
357
365
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {
358
366
  var newWidth = width + step;
359
367
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "8.2.0",
3
+ "version": "8.2.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "@atlaskit/adf-schema": "^46.1.0",
31
31
  "@atlaskit/button": "^20.3.0",
32
32
  "@atlaskit/custom-steps": "^0.9.0",
33
- "@atlaskit/editor-common": "^95.8.0",
33
+ "@atlaskit/editor-common": "^95.10.0",
34
34
  "@atlaskit/editor-palette": "1.6.3",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
@@ -40,10 +40,10 @@
40
40
  "@atlaskit/editor-plugin-guideline": "^1.2.0",
41
41
  "@atlaskit/editor-plugin-selection": "^1.5.0",
42
42
  "@atlaskit/editor-plugin-width": "^1.3.0",
43
- "@atlaskit/editor-prosemirror": "6.0.0",
43
+ "@atlaskit/editor-prosemirror": "6.2.1",
44
44
  "@atlaskit/editor-shared-styles": "^3.2.0",
45
45
  "@atlaskit/editor-tables": "^2.8.0",
46
- "@atlaskit/icon": "^22.26.0",
46
+ "@atlaskit/icon": "^22.28.0",
47
47
  "@atlaskit/menu": "^2.13.0",
48
48
  "@atlaskit/platform-feature-flags": "^0.3.0",
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
@@ -53,7 +53,7 @@
53
53
  "@atlaskit/theme": "^14.0.0",
54
54
  "@atlaskit/tmp-editor-statsig": "^2.21.0",
55
55
  "@atlaskit/toggle": "^13.4.0",
56
- "@atlaskit/tokens": "^2.3.0",
56
+ "@atlaskit/tokens": "^2.4.0",
57
57
  "@atlaskit/tooltip": "^18.9.0",
58
58
  "@babel/runtime": "^7.0.0",
59
59
  "@emotion/react": "^11.7.1",
@@ -124,6 +124,9 @@
124
124
  },
125
125
  "platform_editor_use_nested_table_pm_nodes": {
126
126
  "type": "boolean"
127
+ },
128
+ "platform_editor_set_alignment_when_resized": {
129
+ "type": "boolean"
127
130
  }
128
131
  }
129
132
  }
@@ -25,6 +25,7 @@ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/stat
25
25
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
26
26
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
27
27
  import { findTable } from '@atlaskit/editor-tables/utils';
28
+ import { fg } from '@atlaskit/platform-feature-flags';
28
29
  import { token } from '@atlaskit/tokens';
29
30
 
30
31
  import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
@@ -574,10 +575,21 @@ export const TableResizer = ({
574
575
  }
575
576
 
576
577
  if (typeof pos === 'number') {
577
- tr = tr.setNodeMarkup(pos, undefined, {
578
- ...node.attrs,
579
- width: newWidth,
580
- });
578
+ if (fg('platform_editor_set_alignment_when_resized')) {
579
+ tr = tr.setNodeMarkup(pos, undefined, {
580
+ ...node.attrs,
581
+ width: newWidth,
582
+ layout:
583
+ node.attrs.layout !== ALIGN_START && node.attrs.layout !== ALIGN_CENTER
584
+ ? ALIGN_CENTER
585
+ : node.attrs.layout,
586
+ });
587
+ } else {
588
+ tr = tr.setNodeMarkup(pos, undefined, {
589
+ ...node.attrs,
590
+ width: newWidth,
591
+ });
592
+ }
581
593
 
582
594
  const newNode = tr.doc.nodeAt(pos)!;
583
595
  tr = scaleTable(
@@ -636,23 +648,23 @@ export const TableResizer = ({
636
648
  return newWidth;
637
649
  },
638
650
  [
639
- displayGapCursor,
640
- updateWidth,
641
651
  editorView,
642
652
  getPos,
643
653
  node,
644
- tableRef,
645
- scheduleResize,
646
- displayGuideline,
647
- attachAnalyticsEvent,
654
+ isCommentEditor,
655
+ widthToWidest,
648
656
  endMeasure,
657
+ displayGapCursor,
658
+ displayGuideline,
659
+ updateWidth,
660
+ scheduleResize,
649
661
  onResizeStop,
662
+ attachAnalyticsEvent,
663
+ tableRef,
664
+ pluginInjectionApi,
650
665
  isTableScalingEnabled,
651
666
  shouldUseIncreasedScalingPercent,
652
- widthToWidest,
653
667
  formatMessage,
654
- pluginInjectionApi,
655
- isCommentEditor,
656
668
  ],
657
669
  );
658
670