@atlaskit/editor-plugin-table 7.25.22 → 7.25.23

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,13 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.25.23
4
+
5
+ ### Patch Changes
6
+
7
+ - [#139279](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/139279)
8
+ [`70db87daa2f22`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/70db87daa2f22) -
9
+ [ux] Fix for column resizing for table that were resized to full-width in comment editor.
10
+
3
11
  ## 7.25.22
4
12
 
5
13
  ### Patch Changes
@@ -636,7 +636,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
636
636
  if (isInDanger && !table) {
637
637
  (0, _commands.clearHoverSelection)()(view.state, view.dispatch);
638
638
  }
639
- if ((_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
639
+ if ((_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
640
640
  this.removeInlineTableWidth();
641
641
  }
642
642
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
@@ -294,6 +294,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
294
294
  var _node$attrs$localId2, _node$attrs2;
295
295
  isResizing.current = false;
296
296
  var newWidth = originalState.width + delta.width;
297
+ var originalNewWidth = newWidth;
297
298
  var state = editorView.state,
298
299
  dispatch = editorView.dispatch;
299
300
  var pos = getPos();
@@ -329,7 +330,10 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
329
330
  node: newNode,
330
331
  prevNode: node,
331
332
  start: pos + 1,
332
- parentWidth: newWidth
333
+ // We use originalNewWidth in comment editor, because in comment editor
334
+ // newWidth can be underined when table is resized to 'full-width'
335
+ // scaleTable function needs number value to work correctly.
336
+ parentWidth: isCommentEditor ? originalNewWidth : newWidth
333
337
  }, editorView.domAtPos.bind(editorView), pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent || false, isCommentEditor)(tr);
334
338
  var scaledNode = tr.doc.nodeAt(pos);
335
339
  (_attachAnalyticsEvent2 = attachAnalyticsEvent((0, _analytics2.generateResizedPayload)({
@@ -307,7 +307,6 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
307
307
  } else {
308
308
  var _table$attrs2;
309
309
  var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs2 = table.attrs) !== null && _table$attrs2 !== void 0 && _table$attrs2.width) ? (0, _misc2.getScalingPercentForTableWithoutWidth)(table, dom) : (0, _misc2.getTableScalingPercent)(originalTable, dom, shouldUseIncreasedScalingPercent);
310
- // This function is called for Full-page/Fixed-page tables and table that have width attr value in Comment editor
311
310
  (0, _utils3.resizeColumn)(resizeState, colIndex, resizedDelta, dom, table, undefined, shouldScale, scalePercent);
312
311
  }
313
312
  (0, _utils3.updateControls)()(state);
@@ -616,7 +616,7 @@ class TableComponent extends React.Component {
616
616
  if (isInDanger && !table) {
617
617
  clearHoverSelection()(view.state, view.dispatch);
618
618
  }
619
- if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
619
+ if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
620
620
  this.removeInlineTableWidth();
621
621
  }
622
622
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
@@ -287,6 +287,7 @@ export const TableResizer = ({
287
287
  var _node$attrs$localId2, _node$attrs2;
288
288
  isResizing.current = false;
289
289
  let newWidth = originalState.width + delta.width;
290
+ const originalNewWidth = newWidth;
290
291
  const {
291
292
  state,
292
293
  dispatch
@@ -325,7 +326,10 @@ export const TableResizer = ({
325
326
  node: newNode,
326
327
  prevNode: node,
327
328
  start: pos + 1,
328
- parentWidth: newWidth
329
+ // We use originalNewWidth in comment editor, because in comment editor
330
+ // newWidth can be underined when table is resized to 'full-width'
331
+ // scaleTable function needs number value to work correctly.
332
+ parentWidth: isCommentEditor ? originalNewWidth : newWidth
329
333
  }, editorView.domAtPos.bind(editorView), pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent || false, isCommentEditor)(tr);
330
334
  const scaledNode = tr.doc.nodeAt(pos);
331
335
  (_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
@@ -318,7 +318,6 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
318
318
  } else {
319
319
  var _table$attrs2;
320
320
  const scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs2 = table.attrs) !== null && _table$attrs2 !== void 0 && _table$attrs2.width) ? getScalingPercentForTableWithoutWidth(table, dom) : getTableScalingPercent(originalTable, dom, shouldUseIncreasedScalingPercent);
321
- // This function is called for Full-page/Fixed-page tables and table that have width attr value in Comment editor
322
321
  resizeColumn(resizeState, colIndex, resizedDelta, dom, table, undefined, shouldScale, scalePercent);
323
322
  }
324
323
  updateControls()(state);
@@ -629,7 +629,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
629
629
  if (isInDanger && !table) {
630
630
  clearHoverSelection()(view.state, view.dispatch);
631
631
  }
632
- if ((_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
632
+ if ((_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled && !(options !== null && options !== void 0 && options.isTableScalingEnabled)) {
633
633
  this.removeInlineTableWidth();
634
634
  }
635
635
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
@@ -284,6 +284,7 @@ export var TableResizer = function TableResizer(_ref) {
284
284
  var _node$attrs$localId2, _node$attrs2;
285
285
  isResizing.current = false;
286
286
  var newWidth = originalState.width + delta.width;
287
+ var originalNewWidth = newWidth;
287
288
  var state = editorView.state,
288
289
  dispatch = editorView.dispatch;
289
290
  var pos = getPos();
@@ -319,7 +320,10 @@ export var TableResizer = function TableResizer(_ref) {
319
320
  node: newNode,
320
321
  prevNode: node,
321
322
  start: pos + 1,
322
- parentWidth: newWidth
323
+ // We use originalNewWidth in comment editor, because in comment editor
324
+ // newWidth can be underined when table is resized to 'full-width'
325
+ // scaleTable function needs number value to work correctly.
326
+ parentWidth: isCommentEditor ? originalNewWidth : newWidth
323
327
  }, editorView.domAtPos.bind(editorView), pluginInjectionApi, isTableScalingEnabled, shouldUseIncreasedScalingPercent || false, isCommentEditor)(tr);
324
328
  var scaledNode = tr.doc.nodeAt(pos);
325
329
  (_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
@@ -300,7 +300,6 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
300
300
  } else {
301
301
  var _table$attrs2;
302
302
  var scalePercent = isTableScalingEnabled && isCommentEditor && !((_table$attrs2 = table.attrs) !== null && _table$attrs2 !== void 0 && _table$attrs2.width) ? getScalingPercentForTableWithoutWidth(table, dom) : getTableScalingPercent(originalTable, dom, shouldUseIncreasedScalingPercent);
303
- // This function is called for Full-page/Fixed-page tables and table that have width attr value in Comment editor
304
303
  resizeColumn(resizeState, colIndex, resizedDelta, dom, table, undefined, shouldScale, scalePercent);
305
304
  }
306
305
  updateControls()(state);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.25.22",
3
+ "version": "7.25.23",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -575,7 +575,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
575
575
  clearHoverSelection()(view.state, view.dispatch);
576
576
  }
577
577
 
578
- if (this.props.options?.isCommentEditor && options?.isTableResizingEnabled) {
578
+ if (
579
+ this.props.options?.isCommentEditor &&
580
+ options?.isTableResizingEnabled &&
581
+ !options?.isTableScalingEnabled
582
+ ) {
579
583
  this.removeInlineTableWidth();
580
584
  }
581
585
 
@@ -540,6 +540,7 @@ export const TableResizer = ({
540
540
  (originalState, delta) => {
541
541
  isResizing.current = false;
542
542
  let newWidth: number | undefined = originalState.width + delta.width;
543
+ const originalNewWidth = newWidth;
543
544
  const { state, dispatch } = editorView;
544
545
  const pos = getPos();
545
546
  const currentTableNodeLocalId = node?.attrs?.localId ?? '';
@@ -585,7 +586,10 @@ export const TableResizer = ({
585
586
  node: newNode,
586
587
  prevNode: node,
587
588
  start: pos + 1,
588
- parentWidth: newWidth,
589
+ // We use originalNewWidth in comment editor, because in comment editor
590
+ // newWidth can be underined when table is resized to 'full-width'
591
+ // scaleTable function needs number value to work correctly.
592
+ parentWidth: isCommentEditor ? originalNewWidth : newWidth,
589
593
  },
590
594
  editorView.domAtPos.bind(editorView),
591
595
  pluginInjectionApi,
@@ -397,7 +397,7 @@ export const handleMouseDown = (
397
397
  isTableScalingEnabled && isCommentEditor && !table.attrs?.width
398
398
  ? getScalingPercentForTableWithoutWidth(table, dom)
399
399
  : getTableScalingPercent(originalTable, dom, shouldUseIncreasedScalingPercent);
400
- // This function is called for Full-page/Fixed-page tables and table that have width attr value in Comment editor
400
+
401
401
  resizeColumn(
402
402
  resizeState,
403
403
  colIndex,