@atlaskit/editor-plugin-table 7.25.24 → 7.25.26

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 (60) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/afm-jira/tsconfig.json +3 -0
  3. package/dist/cjs/nodeviews/ExternalDropTargets.js +1 -1
  4. package/dist/cjs/nodeviews/TableCell.js +1 -1
  5. package/dist/cjs/nodeviews/TableComponent.js +6 -6
  6. package/dist/cjs/nodeviews/TableContainer.js +1 -1
  7. package/dist/cjs/nodeviews/TableResizer.js +4 -4
  8. package/dist/cjs/nodeviews/TableRow.js +1 -1
  9. package/dist/cjs/nodeviews/lazy-node-views.js +1 -1
  10. package/dist/cjs/nodeviews/table.js +1 -1
  11. package/dist/cjs/pm-plugins/main.js +6 -0
  12. package/dist/cjs/pm-plugins/table-local-id.js +3 -3
  13. package/dist/cjs/pm-plugins/table-resizing/commands.js +3 -3
  14. package/dist/cjs/pm-plugins/view-mode-sort/index.js +3 -3
  15. package/dist/cjs/toolbar.js +1 -1
  16. package/dist/cjs/transforms/fix-tables.js +6 -6
  17. package/dist/cjs/ui/DragHandle/index.js +1 -1
  18. package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +1 -1
  19. package/dist/cjs/ui/FloatingContextualButton/index.js +1 -1
  20. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
  21. package/dist/cjs/ui/FloatingDeleteButton/index.js +2 -2
  22. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +1 -1
  23. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +1 -1
  24. package/dist/cjs/ui/FloatingInsertButton/index.js +2 -2
  25. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -1
  26. package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +1 -1
  27. package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -1
  28. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -1
  29. package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +2 -2
  30. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +1 -1
  31. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +2 -2
  32. package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +2 -2
  33. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +1 -1
  34. package/dist/cjs/ui/TableFloatingControls/RowDropTarget/index.js +1 -1
  35. package/dist/cjs/ui/TableFloatingControls/index.js +1 -1
  36. package/dist/cjs/utils/paste.js +19 -2
  37. package/dist/es2019/pm-plugins/main.js +7 -1
  38. package/dist/es2019/utils/paste.js +19 -2
  39. package/dist/esm/nodeviews/TableCell.js +1 -1
  40. package/dist/esm/nodeviews/TableComponent.js +6 -6
  41. package/dist/esm/nodeviews/TableResizer.js +3 -3
  42. package/dist/esm/nodeviews/TableRow.js +1 -1
  43. package/dist/esm/nodeviews/table.js +1 -1
  44. package/dist/esm/pm-plugins/main.js +7 -1
  45. package/dist/esm/pm-plugins/table-local-id.js +3 -3
  46. package/dist/esm/pm-plugins/table-resizing/commands.js +3 -3
  47. package/dist/esm/pm-plugins/view-mode-sort/index.js +3 -3
  48. package/dist/esm/transforms/fix-tables.js +6 -6
  49. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
  50. package/dist/esm/ui/FloatingDeleteButton/index.js +1 -1
  51. package/dist/esm/ui/FloatingInsertButton/index.js +1 -1
  52. package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -1
  53. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -1
  54. package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +1 -1
  55. package/dist/esm/utils/paste.js +19 -2
  56. package/dist/types/utils/paste.d.ts +1 -0
  57. package/dist/types-ts4.5/utils/paste.d.ts +1 -0
  58. package/package.json +4 -4
  59. package/src/pm-plugins/main.ts +12 -1
  60. package/src/utils/paste.ts +17 -1
@@ -19,7 +19,7 @@ var _FloatingControlsWithSelection = require("./FloatingControlsWithSelection");
19
19
  var _NumberColumn = _interopRequireDefault(require("./NumberColumn"));
20
20
  var _RowControls = require("./RowControls");
21
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
23
  var TableFloatingControls = exports.TableFloatingControls = function TableFloatingControls(_ref) {
24
24
  var _findTable;
25
25
  var editorView = _ref.editorView,
@@ -5,12 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.isHeaderRowRequired = isHeaderRowRequired;
8
- exports.unwrapContentFromTable = exports.transformSliceToRemoveOpenTable = exports.transformSliceToFixHardBreakProblemOnCopyFromCell = exports.transformSliceToCorrectEmptyTableCells = exports.removeTableFromLastChild = exports.removeTableFromFirstChild = void 0;
8
+ exports.unwrapContentFromTable = exports.transformSliceToRemoveOpenTable = exports.transformSliceToFixHardBreakProblemOnCopyFromCell = exports.transformSliceToCorrectEmptyTableCells = exports.transformSliceTableLayoutDefaultToCenter = exports.removeTableFromLastChild = exports.removeTableFromFirstChild = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
11
  var _utils = require("@atlaskit/editor-common/utils");
11
12
  var _model = require("@atlaskit/editor-prosemirror/model");
12
13
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
13
14
  var _pluginFactory = require("../pm-plugins/plugin-factory");
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
17
  // lifts up the content of each cell, returning an array of nodes
15
18
  var unwrapContentFromTable = exports.unwrapContentFromTable = function unwrapContentFromTable(maybeTable) {
16
19
  var schema = maybeTable.type.schema;
@@ -113,4 +116,18 @@ var transformSliceToCorrectEmptyTableCells = exports.transformSliceToCorrectEmpt
113
116
  function isHeaderRowRequired(state) {
114
117
  var tableState = (0, _pluginFactory.getPluginState)(state);
115
118
  return tableState && tableState.pluginConfig.isHeaderRowRequired;
116
- }
119
+ }
120
+ var transformSliceTableLayoutDefaultToCenter = exports.transformSliceTableLayoutDefaultToCenter = function transformSliceTableLayoutDefaultToCenter(slice, schema) {
121
+ var table = schema.nodes.table;
122
+ var children = [];
123
+ (0, _utils.mapChildren)(slice.content, function (node) {
124
+ if (node.type === table && node.attrs.layout === 'default') {
125
+ children.push(table.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
126
+ layout: 'center'
127
+ }), node.content, node.marks));
128
+ } else {
129
+ children.push(node);
130
+ }
131
+ });
132
+ return new _model.Slice(_model.Fragment.fromArray(children), slice.openStart, slice.openEnd);
133
+ };
@@ -15,7 +15,7 @@ import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plu
15
15
  import { fixTables, replaceSelectedTable } from '../transforms';
16
16
  import { TableCssClassName as ClassName } from '../types';
17
17
  import { findControlsHoverDecoration, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable } from '../utils';
18
- import { isHeaderRowRequired } from '../utils/paste';
18
+ import { isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from '../utils/paste';
19
19
  import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
20
20
  import { createPluginState, getPluginState } from './plugin-factory';
21
21
  import { pluginKey } from './plugin-key';
@@ -165,6 +165,12 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
165
165
  if (!insideTable(editorState) && isHeaderRowRequired(editorState)) {
166
166
  slice = transformSliceToAddTableHeaders(slice, schema);
167
167
  }
168
+
169
+ // fix for when pasting a table with default layout into comment editor
170
+ // table lose width and expand to full width
171
+ if (!insideTable(editorState) && isCommentEditor && isTableAlignmentEnabled && isTableScalingEnabled) {
172
+ slice = transformSliceTableLayoutDefaultToCenter(slice, schema);
173
+ }
168
174
  slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
169
175
 
170
176
  // We do this separately, so it also applies to drag/drop events
@@ -1,4 +1,4 @@
1
- import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
1
+ import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
2
2
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import { flatten } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -108,4 +108,21 @@ export const transformSliceToCorrectEmptyTableCells = (slice, schema) => {
108
108
  export function isHeaderRowRequired(state) {
109
109
  const tableState = getPluginState(state);
110
110
  return tableState && tableState.pluginConfig.isHeaderRowRequired;
111
- }
111
+ }
112
+ export const transformSliceTableLayoutDefaultToCenter = (slice, schema) => {
113
+ const {
114
+ table
115
+ } = schema.nodes;
116
+ const children = [];
117
+ mapChildren(slice.content, node => {
118
+ if (node.type === table && node.attrs.layout === 'default') {
119
+ children.push(table.createChecked({
120
+ ...node.attrs,
121
+ layout: 'center'
122
+ }, node.content, node.marks));
123
+ } else {
124
+ children.push(node);
125
+ }
126
+ });
127
+ return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
128
+ };
@@ -6,7 +6,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
11
  import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
12
12
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
@@ -6,12 +6,12 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
10
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
10
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
11
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
12
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
15
15
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
16
16
  import React from 'react';
17
17
  import classnames from 'classnames';
@@ -254,12 +254,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
254
254
  getNode = _this$props4.getNode,
255
255
  getPos = _this$props4.getPos,
256
256
  containerWidth = _this$props4.containerWidth;
257
- var _node = getNode();
257
+ var node = getNode();
258
258
  var pos = getPos();
259
259
  if (!isValidPosition(pos, view.state)) {
260
260
  return;
261
261
  }
262
- autoSizeTable(view, _node, _this.table, pos, {
262
+ autoSizeTable(view, node, _this.table, pos, {
263
263
  containerWidth: containerWidth.width
264
264
  });
265
265
  }
@@ -203,15 +203,15 @@ export var TableResizer = function TableResizer(_ref) {
203
203
  // deleted this table
204
204
  if (isResizing.current) {
205
205
  var dispatch = editorView.dispatch,
206
- _tr = editorView.state.tr;
206
+ tr = editorView.state.tr;
207
207
  displayGapCursor(true);
208
208
  displayGuideline([]);
209
- _tr.setMeta(tableWidthPluginKey, {
209
+ tr.setMeta(tableWidthPluginKey, {
210
210
  resizing: false,
211
211
  tableLocalId: '',
212
212
  tableRef: null
213
213
  });
214
- dispatch(_tr);
214
+ dispatch(tr);
215
215
  }
216
216
  };
217
217
  }, [editorView, displayGuideline, displayGapCursor]);
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  import debounce from 'lodash/debounce';
11
11
  import throttle from 'lodash/throttle';
@@ -8,7 +8,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
10
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
11
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  import React from 'react';
14
14
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
@@ -18,7 +18,7 @@ import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plu
18
18
  import { fixTables, replaceSelectedTable } from '../transforms';
19
19
  import { TableCssClassName as ClassName } from '../types';
20
20
  import { findControlsHoverDecoration, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable } from '../utils';
21
- import { isHeaderRowRequired } from '../utils/paste';
21
+ import { isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from '../utils/paste';
22
22
  import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
23
23
  import { createPluginState, getPluginState } from './plugin-factory';
24
24
  import { pluginKey } from './plugin-key';
@@ -166,6 +166,12 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
166
166
  if (!insideTable(editorState) && isHeaderRowRequired(editorState)) {
167
167
  slice = transformSliceToAddTableHeaders(slice, schema);
168
168
  }
169
+
170
+ // fix for when pasting a table with default layout into comment editor
171
+ // table lose width and expand to full width
172
+ if (!insideTable(editorState) && isCommentEditor && isTableAlignmentEnabled && isTableScalingEnabled) {
173
+ slice = transformSliceTableLayoutDefaultToCenter(slice, schema);
174
+ }
169
175
  slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
170
176
 
171
177
  // We do this separately, so it also applies to drag/drop events
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
2
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  /**
@@ -38,11 +38,11 @@ export var evenColumns = function evenColumns(_ref) {
38
38
  export var distributeColumnsWidths = function distributeColumnsWidths(newResizeState, table, api) {
39
39
  return function (state, dispatch) {
40
40
  if (dispatch) {
41
- var _tr = updateColumnWidths(newResizeState, table.node, table.start, api)(state.tr);
42
- _tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
41
+ var tr = updateColumnWidths(newResizeState, table.node, table.start, api)(state.tr);
42
+ tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
43
43
  name: TABLE_OVERFLOW_CHANGE_TRIGGER.DISTRIBUTED_COLUMNS
44
44
  });
45
- stopResizing(_tr)(state, dispatch);
45
+ stopResizing(tr)(state, dispatch);
46
46
  }
47
47
  return true;
48
48
  };
@@ -1,9 +1,9 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
5
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
6
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
8
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
9
  /**
@@ -155,17 +155,17 @@ function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
155
155
  var replaceCells = function replaceCells(tr, table, tablePos, modifyCell) {
156
156
  var rows = [];
157
157
  var modifiedCells = 0;
158
- for (var _rowIndex2 = 0; _rowIndex2 < table.childCount; _rowIndex2++) {
159
- var row = table.child(_rowIndex2);
158
+ for (var rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
159
+ var row = table.child(rowIndex);
160
160
  var cells = [];
161
- for (var _colIndex = 0; _colIndex < row.childCount; _colIndex++) {
162
- var _cell = row.child(_colIndex);
161
+ for (var colIndex = 0; colIndex < row.childCount; colIndex++) {
162
+ var cell = row.child(colIndex);
163
163
 
164
164
  // FIXME
165
165
  // The rowIndex and colIndex are not accurate in a merged cell scenario
166
166
  // e.g. table with 5 columns might have only one cell in a row, colIndex will be 1, where it should be 4
167
- var node = modifyCell(_cell, _rowIndex2, _colIndex);
168
- if (node.sameMarkup(_cell) === false) {
167
+ var node = modifyCell(cell, rowIndex, colIndex);
168
+ if (node.sameMarkup(cell) === false) {
169
169
  modifiedCells++;
170
170
  }
171
171
  cells.push(node);
@@ -8,7 +8,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  /* eslint-disable @atlaskit/design-system/prefer-primitives */
14
14
  /**
@@ -8,7 +8,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  import React, { Component } from 'react';
14
14
  import { createPortal } from 'react-dom';
@@ -6,7 +6,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
11
  import React from 'react';
12
12
  import { injectIntl } from 'react-intl-next';
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  import React, { Component } from 'react';
11
11
  import classnames from 'classnames';
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  import React, { Component } from 'react';
11
11
  import classnames from 'classnames';
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  import React, { Component } from 'react';
11
11
  import { injectIntl } from 'react-intl-next';
@@ -1,5 +1,8 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
3
6
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
7
  import { flatten } from '@atlaskit/editor-prosemirror/utils';
5
8
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -106,4 +109,18 @@ export var transformSliceToCorrectEmptyTableCells = function transformSliceToCor
106
109
  export function isHeaderRowRequired(state) {
107
110
  var tableState = getPluginState(state);
108
111
  return tableState && tableState.pluginConfig.isHeaderRowRequired;
109
- }
112
+ }
113
+ export var transformSliceTableLayoutDefaultToCenter = function transformSliceTableLayoutDefaultToCenter(slice, schema) {
114
+ var table = schema.nodes.table;
115
+ var children = [];
116
+ mapChildren(slice.content, function (node) {
117
+ if (node.type === table && node.attrs.layout === 'default') {
118
+ children.push(table.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
119
+ layout: 'center'
120
+ }), node.content, node.marks));
121
+ } else {
122
+ children.push(node);
123
+ }
124
+ });
125
+ return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
126
+ };
@@ -13,3 +13,4 @@ export declare const transformSliceToFixHardBreakProblemOnCopyFromCell: (slice:
13
13
  export declare const transformSliceToRemoveOpenTable: (slice: Slice, schema: Schema) => Slice;
14
14
  export declare const transformSliceToCorrectEmptyTableCells: (slice: Slice, schema: Schema) => Slice;
15
15
  export declare function isHeaderRowRequired(state: EditorState): boolean | undefined;
16
+ export declare const transformSliceTableLayoutDefaultToCenter: (slice: Slice, schema: Schema) => Slice;
@@ -13,3 +13,4 @@ export declare const transformSliceToFixHardBreakProblemOnCopyFromCell: (slice:
13
13
  export declare const transformSliceToRemoveOpenTable: (slice: Slice, schema: Schema) => Slice;
14
14
  export declare const transformSliceToCorrectEmptyTableCells: (slice: Slice, schema: Schema) => Slice;
15
15
  export declare function isHeaderRowRequired(state: EditorState): boolean | undefined;
16
+ export declare const transformSliceTableLayoutDefaultToCenter: (slice: Slice, schema: Schema) => Slice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.25.24",
3
+ "version": "7.25.26",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,17 +30,17 @@
30
30
  "@atlaskit/adf-schema": "^40.9.0",
31
31
  "@atlaskit/button": "^20.1.0",
32
32
  "@atlaskit/custom-steps": "^0.7.0",
33
- "@atlaskit/editor-common": "^88.13.0",
33
+ "@atlaskit/editor-common": "^89.0.0",
34
34
  "@atlaskit/editor-palette": "1.6.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
37
- "@atlaskit/editor-plugin-batch-attribute-updates": "1.0.1",
37
+ "@atlaskit/editor-plugin-batch-attribute-updates": "1.0.3",
38
38
  "@atlaskit/editor-plugin-content-insertion": "^1.8.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
40
40
  "@atlaskit/editor-plugin-guideline": "^1.2.0",
41
41
  "@atlaskit/editor-plugin-selection": "^1.4.0",
42
42
  "@atlaskit/editor-plugin-width": "^1.3.0",
43
- "@atlaskit/editor-prosemirror": "5.0.1",
43
+ "@atlaskit/editor-prosemirror": "6.0.0",
44
44
  "@atlaskit/editor-shared-styles": "^2.13.0",
45
45
  "@atlaskit/editor-tables": "^2.8.0",
46
46
  "@atlaskit/icon": "^22.16.0",
@@ -69,7 +69,7 @@ import {
69
69
  transformSliceToFixHardBreakProblemOnCopyFromCell,
70
70
  transformSliceToRemoveOpenTable,
71
71
  } from '../utils';
72
- import { isHeaderRowRequired } from '../utils/paste';
72
+ import { isHeaderRowRequired, transformSliceTableLayoutDefaultToCenter } from '../utils/paste';
73
73
 
74
74
  import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
75
75
  import { createPluginState, getPluginState } from './plugin-factory';
@@ -262,6 +262,17 @@ export const createPlugin = (
262
262
  slice = transformSliceToAddTableHeaders(slice, schema);
263
263
  }
264
264
 
265
+ // fix for when pasting a table with default layout into comment editor
266
+ // table lose width and expand to full width
267
+ if (
268
+ !insideTable(editorState) &&
269
+ isCommentEditor &&
270
+ isTableAlignmentEnabled &&
271
+ isTableScalingEnabled
272
+ ) {
273
+ slice = transformSliceTableLayoutDefaultToCenter(slice, schema);
274
+ }
275
+
265
276
  slice = transformSliceToFixHardBreakProblemOnCopyFromCell(slice, schema);
266
277
 
267
278
  // We do this separately, so it also applies to drag/drop events
@@ -1,4 +1,4 @@
1
- import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
1
+ import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
2
2
  import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
3
3
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
@@ -148,3 +148,19 @@ export function isHeaderRowRequired(state: EditorState) {
148
148
  const tableState = getPluginState(state);
149
149
  return tableState && tableState.pluginConfig.isHeaderRowRequired;
150
150
  }
151
+
152
+ export const transformSliceTableLayoutDefaultToCenter = (slice: Slice, schema: Schema): Slice => {
153
+ const { table } = schema.nodes;
154
+ const children = [] as PMNode[];
155
+ mapChildren(slice.content, (node: PMNode) => {
156
+ if (node.type === table && node.attrs.layout === 'default') {
157
+ children.push(
158
+ table.createChecked({ ...node.attrs, layout: 'center' }, node.content, node.marks),
159
+ );
160
+ } else {
161
+ children.push(node);
162
+ }
163
+ });
164
+
165
+ return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
166
+ };