@atlaskit/editor-plugin-table 9.3.2 → 9.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 9.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
3
9
  ## 9.3.2
4
10
 
5
11
  ### Patch Changes
@@ -8,11 +8,13 @@ var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _styles = require("@atlaskit/editor-common/styles");
9
9
  var _tableMap = require("@atlaskit/editor-tables/table-map");
10
10
  var _utils = require("@atlaskit/editor-tables/utils");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var _columnResize = require("../commands/column-resize");
12
13
  var _misc = require("../commands/misc");
13
14
  var _pluginFactory = require("../plugin-factory");
14
15
  var _tableAnalytics = require("../table-analytics");
15
16
  var _columnWidth = require("../transforms/column-width");
17
+ var _nodes = require("../utils/nodes");
16
18
  var _selection = require("../utils/selection");
17
19
  var _commands = require("./commands");
18
20
  var _pluginFactory2 = require("./plugin-factory");
@@ -153,10 +155,13 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
153
155
  if (dragging) {
154
156
  var startX = dragging.startX;
155
157
 
156
- // If the table has changed (via collab for example) don't apply column widths
157
- // For example, if a table col is deleted we won't be able to reliably remap the new widths
158
- // There may be a more elegant solution to this, to avoid a jarring experience.
159
- if (table.eq(originalTable)) {
158
+ // If the dimensions of the table have changed through a remote modification by another
159
+ // person for example don't persist the new column widths as we couldn't reliably remap them
160
+ // For example, if a table col is deleted
161
+ // There may be a more elegant solution to this, to avoid a jarring experience. This used to
162
+ // be an equality check but that caused issues when a nested table would change (eg. when it
163
+ // dynamically updates its width on resize)
164
+ if ((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_resizing') ? !(0, _nodes.tablesHaveDifferentNoOfColumns)(originalTable, table) : table.eq(originalTable)) {
160
165
  var _table$attrs;
161
166
  var map = _tableMap.TableMap.get(table);
162
167
  var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
@@ -10,6 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
11
11
  var _styles = require("@atlaskit/editor-common/styles");
12
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _columnWidth = require("../../transforms/column-width");
14
15
  var _nodes = require("../../utils/nodes");
15
16
  var _misc = require("../utils/misc");
@@ -177,6 +178,11 @@ var scaleTable = exports.scaleTable = function scaleTable(tableRef, options, dom
177
178
  }
178
179
  if (resizeState) {
179
180
  tr = (0, _columnWidth.updateColumnWidths)(resizeState, node, start, api)(tr);
181
+ if ((0, _platformFeatureFlags.fg)('platform_editor_nested_tables_resizing')) {
182
+ // Avoid adding this transaction separately to the history as these are automatic updates
183
+ // as a consequence of another action
184
+ tr.setMeta('addToHistory', false);
185
+ }
180
186
  if (tr.docChanged) {
181
187
  tr.setMeta('scrollIntoView', false);
182
188
  // TODO: ED-8995
@@ -2,11 +2,13 @@ import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_
2
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
4
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { stopKeyboardColumnResizing } from '../commands/column-resize';
6
7
  import { updateResizeHandleDecorations } from '../commands/misc';
7
8
  import { getPluginState as getTablePluginState } from '../plugin-factory';
8
9
  import { META_KEYS } from '../table-analytics';
9
10
  import { updateColumnWidths } from '../transforms/column-width';
11
+ import { tablesHaveDifferentNoOfColumns } from '../utils/nodes';
10
12
  import { getSelectedColumnIndexes } from '../utils/selection';
11
13
  import { evenColumns, setDragging, stopResizing } from './commands';
12
14
  import { getPluginState } from './plugin-factory';
@@ -161,10 +163,13 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
161
163
  startX
162
164
  } = dragging;
163
165
 
164
- // If the table has changed (via collab for example) don't apply column widths
165
- // For example, if a table col is deleted we won't be able to reliably remap the new widths
166
- // There may be a more elegant solution to this, to avoid a jarring experience.
167
- if (table.eq(originalTable)) {
166
+ // If the dimensions of the table have changed through a remote modification by another
167
+ // person for example don't persist the new column widths as we couldn't reliably remap them
168
+ // For example, if a table col is deleted
169
+ // There may be a more elegant solution to this, to avoid a jarring experience. This used to
170
+ // be an equality check but that caused issues when a nested table would change (eg. when it
171
+ // dynamically updates its width on resize)
172
+ if (fg('platform_editor_nested_tables_resizing') ? !tablesHaveDifferentNoOfColumns(originalTable, table) : table.eq(originalTable)) {
168
173
  var _table$attrs;
169
174
  const map = TableMap.get(table);
170
175
  const colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
@@ -1,6 +1,7 @@
1
1
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
2
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { updateColumnWidths } from '../../transforms/column-width';
5
6
  import { getTableWidth } from '../../utils/nodes';
6
7
  import { getLayoutSize } from '../utils/misc';
@@ -163,6 +164,11 @@ export const scaleTable = (tableRef, options, domAtPos, api, isTableScalingEnabl
163
164
  }
164
165
  if (resizeState) {
165
166
  tr = updateColumnWidths(resizeState, node, start, api)(tr);
167
+ if (fg('platform_editor_nested_tables_resizing')) {
168
+ // Avoid adding this transaction separately to the history as these are automatic updates
169
+ // as a consequence of another action
170
+ tr.setMeta('addToHistory', false);
171
+ }
166
172
  if (tr.docChanged) {
167
173
  tr.setMeta('scrollIntoView', false);
168
174
  // TODO: ED-8995
@@ -2,11 +2,13 @@ import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_
2
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
4
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { stopKeyboardColumnResizing } from '../commands/column-resize';
6
7
  import { updateResizeHandleDecorations } from '../commands/misc';
7
8
  import { getPluginState as getTablePluginState } from '../plugin-factory';
8
9
  import { META_KEYS } from '../table-analytics';
9
10
  import { updateColumnWidths } from '../transforms/column-width';
11
+ import { tablesHaveDifferentNoOfColumns } from '../utils/nodes';
10
12
  import { getSelectedColumnIndexes } from '../utils/selection';
11
13
  import { evenColumns, setDragging, stopResizing } from './commands';
12
14
  import { getPluginState } from './plugin-factory';
@@ -147,10 +149,13 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
147
149
  if (dragging) {
148
150
  var startX = dragging.startX;
149
151
 
150
- // If the table has changed (via collab for example) don't apply column widths
151
- // For example, if a table col is deleted we won't be able to reliably remap the new widths
152
- // There may be a more elegant solution to this, to avoid a jarring experience.
153
- if (table.eq(originalTable)) {
152
+ // If the dimensions of the table have changed through a remote modification by another
153
+ // person for example don't persist the new column widths as we couldn't reliably remap them
154
+ // For example, if a table col is deleted
155
+ // There may be a more elegant solution to this, to avoid a jarring experience. This used to
156
+ // be an equality check but that caused issues when a nested table would change (eg. when it
157
+ // dynamically updates its width on resize)
158
+ if (fg('platform_editor_nested_tables_resizing') ? !tablesHaveDifferentNoOfColumns(originalTable, table) : table.eq(originalTable)) {
154
159
  var _table$attrs;
155
160
  var map = TableMap.get(table);
156
161
  var colIndex = map.colCount($cell.pos - start) + ($cell.nodeAfter ? $cell.nodeAfter.attrs.colspan : 1) - 1;
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
5
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { updateColumnWidths } from '../../transforms/column-width';
8
9
  import { getTableWidth } from '../../utils/nodes';
9
10
  import { getLayoutSize } from '../utils/misc';
@@ -169,6 +170,11 @@ export var scaleTable = function scaleTable(tableRef, options, domAtPos, api) {
169
170
  }
170
171
  if (resizeState) {
171
172
  tr = updateColumnWidths(resizeState, node, start, api)(tr);
173
+ if (fg('platform_editor_nested_tables_resizing')) {
174
+ // Avoid adding this transaction separately to the history as these are automatic updates
175
+ // as a consequence of another action
176
+ tr.setMeta('addToHistory', false);
177
+ }
172
178
  if (tr.docChanged) {
173
179
  tr.setMeta('scrollIntoView', false);
174
180
  // TODO: ED-8995
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "9.3.2",
3
+ "version": "9.3.3",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -43,9 +43,9 @@
43
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": "^23.5.0",
46
+ "@atlaskit/icon": "^23.6.0",
47
47
  "@atlaskit/menu": "^2.14.0",
48
- "@atlaskit/platform-feature-flags": "^0.3.0",
48
+ "@atlaskit/platform-feature-flags": "^1.0.0",
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.5.0",
50
50
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
51
51
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
@@ -140,6 +140,9 @@
140
140
  },
141
141
  "platform_editor_nested_tables_paste_dupe_fix": {
142
142
  "type": "boolean"
143
+ },
144
+ "platform_editor_nested_tables_resizing": {
145
+ "type": "boolean"
143
146
  }
144
147
  }
145
148
  }
@@ -136,16 +136,16 @@ export const tableNodeSpecWithFixedToDOM = (config: Config): NodeSpec => {
136
136
  {
137
137
  class: 'resizer-item display-handle',
138
138
  style: convertToInlineCss({
139
- position: 'relative',
140
- userSelect: 'auto',
141
- boxSizing: 'border-box',
142
- '--ak-editor-table-gutter-padding': `${gutterPadding}px`,
143
- '--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
144
- '--ak-editor-table-min-width': `${tableMinWidth}px`,
145
- minWidth: 'var(--ak-editor-table-min-width)',
146
- maxWidth: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
147
- width: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${node.attrs.width})`,
148
- })
139
+ position: 'relative',
140
+ userSelect: 'auto',
141
+ boxSizing: 'border-box',
142
+ '--ak-editor-table-gutter-padding': `${gutterPadding}px`,
143
+ '--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
144
+ '--ak-editor-table-min-width': `${tableMinWidth}px`,
145
+ minWidth: 'var(--ak-editor-table-min-width)',
146
+ maxWidth: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
147
+ width: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${node.attrs.width})`,
148
+ }),
149
149
  },
150
150
  [
151
151
  'span',
@@ -13,6 +13,7 @@ import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/e
13
13
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
14
14
  import { TableMap } from '@atlaskit/editor-tables/table-map';
15
15
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
16
+ import { fg } from '@atlaskit/platform-feature-flags';
16
17
 
17
18
  import type { PluginInjectionAPI } from '../../types';
18
19
  import { stopKeyboardColumnResizing } from '../commands/column-resize';
@@ -20,6 +21,7 @@ import { updateResizeHandleDecorations } from '../commands/misc';
20
21
  import { getPluginState as getTablePluginState } from '../plugin-factory';
21
22
  import { META_KEYS } from '../table-analytics';
22
23
  import { updateColumnWidths } from '../transforms/column-width';
24
+ import { tablesHaveDifferentNoOfColumns } from '../utils/nodes';
23
25
  import { getSelectedColumnIndexes } from '../utils/selection';
24
26
 
25
27
  import { evenColumns, setDragging, stopResizing } from './commands';
@@ -195,10 +197,17 @@ export const handleMouseDown = (
195
197
  if (dragging) {
196
198
  const { startX } = dragging;
197
199
 
198
- // If the table has changed (via collab for example) don't apply column widths
199
- // For example, if a table col is deleted we won't be able to reliably remap the new widths
200
- // There may be a more elegant solution to this, to avoid a jarring experience.
201
- if (table.eq(originalTable)) {
200
+ // If the dimensions of the table have changed through a remote modification by another
201
+ // person for example don't persist the new column widths as we couldn't reliably remap them
202
+ // For example, if a table col is deleted
203
+ // There may be a more elegant solution to this, to avoid a jarring experience. This used to
204
+ // be an equality check but that caused issues when a nested table would change (eg. when it
205
+ // dynamically updates its width on resize)
206
+ if (
207
+ fg('platform_editor_nested_tables_resizing')
208
+ ? !tablesHaveDifferentNoOfColumns(originalTable, table)
209
+ : table.eq(originalTable)
210
+ ) {
202
211
  const map = TableMap.get(table);
203
212
  const colIndex =
204
213
  map.colCount($cell.pos - start) +
@@ -4,6 +4,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { DomAtPos } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
 
8
9
  import type { PluginInjectionAPI } from '../../../types';
9
10
  import { updateColumnWidths } from '../../transforms/column-width';
@@ -267,6 +268,11 @@ export const scaleTable =
267
268
 
268
269
  if (resizeState) {
269
270
  tr = updateColumnWidths(resizeState, node, start, api)(tr);
271
+ if (fg('platform_editor_nested_tables_resizing')) {
272
+ // Avoid adding this transaction separately to the history as these are automatic updates
273
+ // as a consequence of another action
274
+ tr.setMeta('addToHistory', false);
275
+ }
270
276
 
271
277
  if (tr.docChanged) {
272
278
  tr.setMeta('scrollIntoView', false);
@@ -101,10 +101,7 @@ const TableFloatingColumnControls = ({
101
101
 
102
102
  if (stickyTop) {
103
103
  const columnControlTopOffsetFromParent = '-12px';
104
- containerRef?.current?.style.setProperty(
105
- 'top',
106
- columnControlTopOffsetFromParent
107
- );
104
+ containerRef?.current?.style.setProperty('top', columnControlTopOffsetFromParent);
108
105
  } else {
109
106
  containerRef?.current?.style.removeProperty('top');
110
107
  }
@@ -38,9 +38,7 @@ class CornerControlComponent extends Component<CornerControlProps & WrappedCompo
38
38
  })}
39
39
  style={{
40
40
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
41
- top: this.props.stickyTop !== undefined
42
- ? `0px`
43
- : undefined
41
+ top: this.props.stickyTop !== undefined ? `0px` : undefined,
44
42
  }}
45
43
  contentEditable={false}
46
44
  >
@@ -84,9 +84,7 @@ class RowControlsComponent extends Component<Props & WrappedComponentProps> {
84
84
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
85
85
  marginTop: `${marginTop}px`,
86
86
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
87
- top: thisRowSticky
88
- ? `3px`
89
- : undefined,
87
+ top: thisRowSticky ? `3px` : undefined,
90
88
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
91
89
  paddingTop: thisRowSticky ? `${tableControlsSpacing}px` : undefined,
92
90
  }}