@atlaskit/editor-plugin-table 7.7.2 → 7.7.4

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 (72) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/commands/display-mode.js +23 -0
  3. package/dist/cjs/commands/index.js +8 -1
  4. package/dist/cjs/nodeviews/table.js +2 -1
  5. package/dist/cjs/plugin.js +3 -2
  6. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +1 -1
  7. package/dist/cjs/toolbar.js +43 -12
  8. package/dist/cjs/ui/FloatingContextualButton/styles.js +43 -5
  9. package/dist/cjs/ui/FloatingContextualMenu/styles.js +14 -5
  10. package/dist/cjs/ui/FloatingDragMenu/styles.js +29 -5
  11. package/dist/cjs/ui/icons/DisplayModeIcon.js +46 -0
  12. package/dist/cjs/ui/icons/index.js +7 -0
  13. package/dist/cjs/ui/ui-styles.js +1 -0
  14. package/dist/es2019/commands/display-mode.js +17 -0
  15. package/dist/es2019/commands/index.js +2 -1
  16. package/dist/es2019/nodeviews/table.js +2 -1
  17. package/dist/es2019/plugin.js +4 -3
  18. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -1
  19. package/dist/es2019/toolbar.js +41 -12
  20. package/dist/es2019/ui/FloatingContextualButton/styles.js +42 -42
  21. package/dist/es2019/ui/FloatingContextualMenu/styles.js +11 -9
  22. package/dist/es2019/ui/FloatingDragMenu/styles.js +24 -22
  23. package/dist/es2019/ui/icons/DisplayModeIcon.js +39 -0
  24. package/dist/es2019/ui/icons/index.js +1 -0
  25. package/dist/es2019/ui/ui-styles.js +1 -0
  26. package/dist/esm/commands/display-mode.js +16 -0
  27. package/dist/esm/commands/index.js +2 -1
  28. package/dist/esm/nodeviews/table.js +2 -1
  29. package/dist/esm/plugin.js +4 -3
  30. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -1
  31. package/dist/esm/toolbar.js +44 -13
  32. package/dist/esm/ui/FloatingContextualButton/styles.js +43 -4
  33. package/dist/esm/ui/FloatingContextualMenu/styles.js +14 -5
  34. package/dist/esm/ui/FloatingDragMenu/styles.js +29 -5
  35. package/dist/esm/ui/icons/DisplayModeIcon.js +39 -0
  36. package/dist/esm/ui/icons/index.js +1 -0
  37. package/dist/esm/ui/ui-styles.js +1 -0
  38. package/dist/types/commands/display-mode.d.ts +2 -0
  39. package/dist/types/commands/index.d.ts +1 -0
  40. package/dist/types/commands/toggle.d.ts +1 -1
  41. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
  42. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
  43. package/dist/types/toolbar.d.ts +2 -1
  44. package/dist/types/ui/icons/DisplayModeIcon.d.ts +4 -0
  45. package/dist/types/ui/icons/index.d.ts +1 -0
  46. package/dist/types-ts4.5/commands/display-mode.d.ts +2 -0
  47. package/dist/types-ts4.5/commands/index.d.ts +1 -0
  48. package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
  49. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
  50. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
  51. package/dist/types-ts4.5/toolbar.d.ts +2 -1
  52. package/dist/types-ts4.5/ui/icons/DisplayModeIcon.d.ts +4 -0
  53. package/dist/types-ts4.5/ui/icons/index.d.ts +1 -0
  54. package/package.json +6 -3
  55. package/src/commands/display-mode.ts +19 -0
  56. package/src/commands/index.ts +1 -0
  57. package/src/commands/toggle.ts +1 -1
  58. package/src/commands-with-analytics.ts +3 -2
  59. package/src/nodeviews/table.tsx +1 -0
  60. package/src/plugin.tsx +15 -2
  61. package/src/pm-plugins/table-resizing/event-handlers.ts +2 -1
  62. package/src/pm-plugins/table-resizing/utils/misc.ts +3 -3
  63. package/src/pm-plugins/table-resizing/utils/resize-state.ts +1 -4
  64. package/src/toolbar.tsx +56 -22
  65. package/src/transforms/fix-tables.ts +1 -2
  66. package/src/types.ts +5 -0
  67. package/src/ui/FloatingContextualButton/styles.ts +48 -46
  68. package/src/ui/FloatingContextualMenu/styles.ts +11 -9
  69. package/src/ui/FloatingDragMenu/styles.ts +27 -25
  70. package/src/ui/icons/DisplayModeIcon.tsx +41 -0
  71. package/src/ui/icons/index.ts +1 -0
  72. package/src/ui/ui-styles.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.7.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#92426](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92426) [`32c76c7c225c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/32c76c7c225c) - Bump adf-schema to 35.9.2 to support table alignment options
8
+ - [#90659](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90659) [`fc633861cff4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fc633861cff4) - [ux] Adds lock button on table's floating toolbar.
9
+ - Updated dependencies
10
+
11
+ ## 7.7.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#92977](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92977) [`402557920a06`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/402557920a06) - Use the start position during col resize to update table width
16
+
3
17
  ## 7.7.2
4
18
 
5
19
  ### Patch Changes
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.setTableDisplayMode = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _utils = require("@atlaskit/editor-tables/utils");
10
+ 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; }
11
+ 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; }
12
+ var setTableDisplayMode = exports.setTableDisplayMode = function setTableDisplayMode(_ref) {
13
+ var tr = _ref.tr;
14
+ var table = (0, _utils.findTable)(tr.selection);
15
+ if (!table) {
16
+ return null;
17
+ }
18
+ var displayMode = table.node.attrs.displayMode;
19
+ tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, _objectSpread(_objectSpread({}, table.node.attrs), {}, {
20
+ displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default'
21
+ }));
22
+ return tr.setMeta('scrollIntoView', false);
23
+ };
@@ -171,6 +171,12 @@ Object.defineProperty(exports, "setMultipleCellAttrs", {
171
171
  return _misc.setMultipleCellAttrs;
172
172
  }
173
173
  });
174
+ Object.defineProperty(exports, "setTableDisplayMode", {
175
+ enumerable: true,
176
+ get: function get() {
177
+ return _displayMode.setTableDisplayMode;
178
+ }
179
+ });
174
180
  Object.defineProperty(exports, "setTableHovered", {
175
181
  enumerable: true,
176
182
  get: function get() {
@@ -262,4 +268,5 @@ var _clear = require("./clear");
262
268
  var _misc = require("./misc");
263
269
  var _sort = require("./sort");
264
270
  var _goToNextCell = require("./go-to-next-cell");
265
- var _referentiality = require("./referentiality");
271
+ var _referentiality = require("./referentiality");
272
+ var _displayMode = require("./display-mode");
@@ -41,7 +41,8 @@ var tableAttributes = function tableAttributes(node) {
41
41
  'data-layout': node.attrs.layout,
42
42
  'data-autosize': node.attrs.__autoSize,
43
43
  'data-table-local-id': node.attrs.localId || '',
44
- 'data-table-width': node.attrs.width
44
+ 'data-table-width': node.attrs.width,
45
+ 'data-table-display-mode': node.attrs.displayMode
45
46
  };
46
47
  };
47
48
  var getInlineWidth = function getInlineWidth(node, options, state, pos) {
@@ -116,9 +116,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
116
116
  insertTableWithSize: (0, _insert.insertTableWithSize)(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
117
117
  },
118
118
  nodes: function nodes() {
119
+ var tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button') ? _adfSchema.tableStage0 : _adfSchema.table;
119
120
  return [{
120
121
  name: 'table',
121
- node: _adfSchema.table
122
+ node: tableNode
122
123
  }, {
123
124
  name: 'tableHeader',
124
125
  node: _adfSchema.tableHeader
@@ -428,7 +429,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
428
429
  },
429
430
  floatingToolbar: (0, _toolbar.getToolbarConfig)(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
430
431
  return editorViewRef.current;
431
- })((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
432
+ }, options)((0, _createPluginConfig.pluginConfig)(options === null || options === void 0 ? void 0 : options.tableOptions))
432
433
  }
433
434
  };
434
435
  };
@@ -142,7 +142,7 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
142
142
  var resizedDelta = clientX - startX;
143
143
  tr = (0, _transforms.updateColumnWidths)(newResizeState, table, start)(tr);
144
144
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.colum-resizing-improvements')) {
145
- tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
145
+ tr.setNodeAttribute(start - 1, 'width', newResizeState.tableWidth);
146
146
  }
147
147
  if (colIndex === map.width - 1) {
148
148
  var mouseUpTime = event.timeStamp;
@@ -12,6 +12,7 @@ var _customSteps = require("@atlaskit/custom-steps");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _keymaps = require("@atlaskit/editor-common/keymaps");
14
14
  var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
15
+ var _preset = require("@atlaskit/editor-common/preset");
15
16
  var _uiColor = require("@atlaskit/editor-common/ui-color");
16
17
  var _utils = require("@atlaskit/editor-common/utils");
17
18
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
@@ -31,6 +32,7 @@ var _resizeState = require("./pm-plugins/table-resizing/utils/resize-state");
31
32
  var _tableWidth = require("./pm-plugins/table-width");
32
33
  var _transforms = require("./transforms");
33
34
  var _types = require("./types");
35
+ var _icons = require("./ui/icons");
34
36
  var _TableFullWidthLabel = require("./ui/TableFullWidthLabel");
35
37
  var _utils4 = require("./utils");
36
38
  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); }
@@ -311,7 +313,7 @@ var getClosestSelectionOrTableRect = exports.getClosestSelectionOrTableRect = fu
311
313
  var tableRect = new _tableMap.Rect(0, 0, map.width, map.height);
312
314
  return (0, _utils3.isSelectionType)(selection, 'cell') ? (0, _utils3.getSelectionRect)(selection) : tableRect;
313
315
  };
314
- var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
316
+ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
315
317
  return function (config) {
316
318
  return function (state, intl) {
317
319
  var _tableObject$node$att, _tableObject$node;
@@ -325,7 +327,9 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
325
327
  var isTableScalingEnabled = pluginState.isTableScalingEnabled,
326
328
  widthToWidest = pluginState.widthToWidest;
327
329
  var currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 || (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 || (_tableObject$node = _tableObject$node.attrs) === null || _tableObject$node === void 0 ? void 0 : _tableObject$node.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
328
- if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
330
+ if (isTableScalingEnabled &&
331
+ // TODO ED-21670: check if need options.isTableScalingEnabled
332
+ isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
329
333
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
330
334
  stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
331
335
  var nodeType = state.schema.nodes.table;
@@ -373,11 +377,12 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
373
377
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
374
378
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
375
379
  _getPluginState2$isTa = _getPluginState2.isTableScalingEnabled,
376
- _isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa;
380
+ _isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa; // TODO ED-21670: check if we need options.isTableScalingEnabled and not an acutual state of displayNode attr on the table
381
+
377
382
  var cellItems;
378
383
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
379
384
  var columnSettingsItems;
380
- columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
385
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options, _isTableScalingEnabled) : [];
381
386
  var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
382
387
 
383
388
  // Check if we need to show confirm dialog for delete button
@@ -504,32 +509,58 @@ var getDistributeConfig = exports.getDistributeConfig = function getDistributeCo
504
509
 
505
510
  // this create the button group for distribute column and also fixed column width
506
511
  // fixed column button should be in this function call in the future
507
- var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI) {
512
+ var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI, options) {
508
513
  var _newResizeStateWithAn2, _pluginState$pluginCo3;
509
514
  var formatMessage = _ref4.formatMessage;
510
- var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
515
+ var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
511
516
  var pluginState = (0, _pluginFactory.getPluginState)(editorState);
512
517
  var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
513
518
  if (!selectionOrTableRect || !editorView) {
514
519
  return [];
515
520
  }
516
- var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
521
+ var newResizeStateWithAnalytics = (0, _resizeState.getNewResizeStateFromSelectedColumns)(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled // TODO ED-21670: Here should be actual state of tableNode's displayMode attr
522
+ );
517
523
  var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
524
+ var items = [];
525
+ var isTableScalingLockBtnEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.preserve-widths-with-lock-button');
526
+ if (isTableScalingLockBtnEnabled) {
527
+ var _pluginState$tableNod;
528
+ var areColumnWidthsLocked = (pluginState === null || pluginState === void 0 || (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
529
+ var title = areColumnWidthsLocked ? formatMessage(_messages.tableMessages.unlockColumnWidths) : formatMessage(_messages.tableMessages.lockColumnWidths);
530
+ items.push({
531
+ id: 'editor.table.lockColumns',
532
+ type: 'button',
533
+ title: title,
534
+ icon: function icon() {
535
+ return (0, _react.jsx)(_icons.DisplayModeIcon, {
536
+ size: "medium",
537
+ label: title
538
+ });
539
+ },
540
+ onClick: (0, _preset.editorCommandToPMCommand)(_commands.setTableDisplayMode),
541
+ selected: areColumnWidthsLocked,
542
+ testId: 'table-lock-column-widths-btn'
543
+ });
544
+ }
518
545
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
519
- return [{
546
+ items.push({
520
547
  id: 'editor.table.distributeColumns',
521
548
  type: 'button',
522
549
  title: formatMessage(_messages.tableMessages.distributeColumns),
523
550
  icon: _layoutThreeEqual.default,
524
551
  onClick: function onClick(state, dispatch, view) {
525
- return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view);
552
+ return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled // TODO ED-21670: Maybe here too we an actual state of tableNode's displayMode attr
553
+ )(state, dispatch, view);
526
554
  },
527
555
  disabled: !wouldChange
528
- }, {
556
+ });
557
+ }
558
+ if (items.length !== 0) {
559
+ items.push({
529
560
  type: 'separator'
530
- }];
561
+ });
531
562
  }
532
- return [];
563
+ return items;
533
564
  };
534
565
  var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI) {
535
566
  var _node$attrs;
@@ -1,18 +1,56 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.tableFloatingCellButtonStyles = exports.tableFloatingCellButtonSelectedStyles = void 0;
8
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
7
  var _react = require("@emotion/react");
10
8
  var _colors = require("@atlaskit/theme/colors");
11
9
  var _consts = require("../consts");
12
- var _templateObject, _templateObject2;
13
10
  var tableFloatingCellButtonStyles = exports.tableFloatingCellButtonStyles = function tableFloatingCellButtonStyles() {
14
- return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n > div {\n // Sits behind button to provide surface-color background\n background: ", ";\n border-radius: ", ";\n display: flex;\n height: ", "px;\n flex-direction: column;\n }\n && button {\n background: ", ";\n flex-direction: column;\n margin: ", ";\n outline: 2px solid ", ";\n border-radius: 1px;\n padding: 0;\n height: calc(100% - 4px);\n display: flex;\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n && button > span {\n margin: 0px ", ";\n }\n && span {\n pointer-events: none;\n }\n"])), "var(--ds-surface, ".concat(_colors.N20, ")"), "var(--ds-border-radius, 3px)", _consts.contextualMenuTriggerSize + 2, "var(--ds-background-neutral, none)", "var(--ds-space-025, 2px)", "var(--ds-surface, ".concat(_colors.N0, ")"), "var(--ds-background-neutral-hovered, ".concat(_colors.N30A, ")"), "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))", "var(--ds-space-negative-050, -4px)");
11
+ return (0, _react.css)({
12
+ '> div': {
13
+ // Sits behind button to provide surface-color background
14
+ background: "var(--ds-surface, ".concat(_colors.N20, ")"),
15
+ borderRadius: "var(--ds-border-radius, 3px)",
16
+ display: 'flex',
17
+ height: "".concat(_consts.contextualMenuTriggerSize + 2, "px"),
18
+ flexDirection: 'column'
19
+ },
20
+ '&& button': {
21
+ background: "var(--ds-background-neutral, none)",
22
+ flexDirection: 'column',
23
+ margin: "var(--ds-space-025, 2px)",
24
+ outline: "2px solid ".concat("var(--ds-surface, ".concat(_colors.N0, ")")),
25
+ borderRadius: '1px',
26
+ padding: 0,
27
+ height: 'calc(100% - 4px)',
28
+ display: 'flex'
29
+ },
30
+ '&& button:hover': {
31
+ background: "var(--ds-background-neutral-hovered, ".concat(_colors.N30A, ")")
32
+ },
33
+ '&& button:active': {
34
+ background: "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))"
35
+ },
36
+ '&& button > span': {
37
+ margin: "0px ".concat("var(--ds-space-negative-050, -4px)")
38
+ },
39
+ '&& span': {
40
+ pointerEvents: 'none'
41
+ }
42
+ });
15
43
  };
16
44
  var tableFloatingCellButtonSelectedStyles = exports.tableFloatingCellButtonSelectedStyles = function tableFloatingCellButtonSelectedStyles() {
17
- return (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n && button {\n background: ", ";\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n"])), "var(--ds-background-selected, ".concat(_colors.N700, ")"), "var(--ds-background-selected-hovered, ".concat(_colors.N700, ")"), "var(--ds-background-selected-pressed, ".concat(_colors.N700, ")"));
45
+ return (0, _react.css)({
46
+ '&& button': {
47
+ background: "var(--ds-background-selected, ".concat(_colors.N700, ")")
48
+ },
49
+ '&& button:hover': {
50
+ background: "var(--ds-background-selected-hovered, ".concat(_colors.N700, ")")
51
+ },
52
+ '&& button:active': {
53
+ background: "var(--ds-background-selected-pressed, ".concat(_colors.N700, ")")
54
+ }
55
+ });
18
56
  };
@@ -11,14 +11,23 @@ var _adfSchema = require("@atlaskit/adf-schema");
11
11
  var _colors = require("@atlaskit/theme/colors");
12
12
  var _types = require("../../types");
13
13
  var _consts = require("../consts");
14
- var _templateObject, _templateObject2, _templateObject3;
14
+ var _templateObject;
15
15
  var cellColourPreviewStyles = exports.cellColourPreviewStyles = function cellColourPreviewStyles(selectedColor) {
16
- return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n &::before {\n background: ", ";\n }\n"])), selectedColor);
16
+ return (0, _react.css)({
17
+ '&::before': {
18
+ background: selectedColor
19
+ }
20
+ });
17
21
  };
18
- var elementBeforeIconStyles = exports.elementBeforeIconStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-right: ", ";\n display: flex;\n"])), "var(--ds-space-negative-075, -6px)");
22
+ var elementBeforeIconStyles = exports.elementBeforeIconStyles = (0, _react.css)({
23
+ marginRight: "var(--ds-space-negative-075, -6px)",
24
+ display: 'flex'
25
+ });
19
26
 
20
27
  // TODO Delete this comment after verifying space token -> previous value `padding: 8px`
21
28
  // TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
22
- var tablePopupStyles = exports.tablePopupStyles = function tablePopupStyles(isDragAndDropEnabled) {
23
- return (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n border-radius: ", ";\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: ", ";\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 20px;\n height: 20px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 20px;\n color: ", ";\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 14px;\n height: 14px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 14px;\n color: ", ";\n }\n }\n"])), _types.TableCssClassName.CONTEXTUAL_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), isDragAndDropEnabled ? _consts.contextualMenuDropdownWidthDnD : _consts.contextualMenuDropdownWidth, "var(--ds-space-100, 8px)", _types.TableCssClassName.CONTEXTUAL_MENU_ICON, _adfSchema.tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(_colors.N90, ")"), _types.TableCssClassName.CONTEXTUAL_MENU_ICON_SMALL, _adfSchema.tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(_colors.N90, ")"));
29
+ var tablePopupStyles = exports.tablePopupStyles = function tablePopupStyles(isDragAndDropEnabled
30
+ // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
31
+ ) {
32
+ return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n border-radius: ", ";\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: ", ";\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 20px;\n height: 20px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 20px;\n color: ", ";\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 14px;\n height: 14px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 14px;\n color: ", ";\n }\n }\n"])), _types.TableCssClassName.CONTEXTUAL_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), isDragAndDropEnabled ? _consts.contextualMenuDropdownWidthDnD : _consts.contextualMenuDropdownWidth, "var(--ds-space-100, 8px)", _types.TableCssClassName.CONTEXTUAL_MENU_ICON, _adfSchema.tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(_colors.N90, ")"), _types.TableCssClassName.CONTEXTUAL_MENU_ICON_SMALL, _adfSchema.tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(_colors.N90, ")"));
24
33
  };
@@ -11,10 +11,34 @@ var _adfSchema = require("@atlaskit/adf-schema");
11
11
  var _colors = require("@atlaskit/theme/colors");
12
12
  var _types = require("../../types");
13
13
  var _consts = require("../consts");
14
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
14
+ var _templateObject;
15
15
  var cellColourPreviewStyles = exports.cellColourPreviewStyles = function cellColourPreviewStyles(selectedColor) {
16
- return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n &::before {\n background: ", ";\n }\n"])), selectedColor);
16
+ return (0, _react.css)({
17
+ '&::before': {
18
+ background: selectedColor
19
+ }
20
+ });
17
21
  };
18
- var elementBeforeIconStyles = exports.elementBeforeIconStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-right: ", ";\n display: flex;\n"])), "var(--ds-space-negative-075, -6px)");
19
- var dragMenuBackgroundColorStyles = exports.dragMenuBackgroundColorStyles = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n border-radius: ", ";\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: ", ";\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 14px;\n height: 14px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 14px;\n color: ", ";\n }\n }\n"])), _types.TableCssClassName.DRAG_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), _consts.dragMenuDropdownWidth, "var(--ds-space-100, 8px)", _types.TableCssClassName.DRAG_SUBMENU_ICON, _adfSchema.tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(_colors.N90, ")"));
20
- var toggleStyles = exports.toggleStyles = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n input[type='checkbox'] {\n width: 30px;\n height: 14px;\n pointer-events: initial;\n cursor: pointer;\n }\n > label {\n margin: 0px;\n pointer-events: none;\n > span {\n pointer-events: none;\n }\n }\n"])));
22
+ var elementBeforeIconStyles = exports.elementBeforeIconStyles = (0, _react.css)({
23
+ marginRight: "var(--ds-space-negative-075, -6px)",
24
+ display: 'flex'
25
+ });
26
+
27
+ // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
28
+ var dragMenuBackgroundColorStyles = exports.dragMenuBackgroundColorStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n border-radius: ", ";\n background: ", ";\n box-shadow: ", ";\n display: block;\n position: absolute;\n top: 0;\n left: ", "px;\n padding: ", ";\n\n > div {\n padding: 0;\n }\n }\n\n .", " {\n display: flex;\n\n &::before {\n content: '';\n display: block;\n border: 1px solid ", ";\n border-radius: ", ";\n width: 14px;\n height: 14px;\n }\n\n &::after {\n content: '\u203A';\n margin-left: ", ";\n line-height: 14px;\n color: ", ";\n }\n }\n"])), _types.TableCssClassName.DRAG_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N60A, ", 0 0 1px ").concat(_colors.N60A), ")"), _consts.dragMenuDropdownWidth, "var(--ds-space-100, 8px)", _types.TableCssClassName.DRAG_SUBMENU_ICON, _adfSchema.tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(_colors.N90, ")"));
29
+ var toggleStyles = exports.toggleStyles = (0, _react.css)({
30
+ display: 'flex',
31
+ "input[type='checkbox']": {
32
+ width: '30px',
33
+ height: '14px',
34
+ pointerEvents: 'initial',
35
+ cursor: 'pointer'
36
+ },
37
+ '> label': {
38
+ margin: '0px',
39
+ pointerEvents: 'none',
40
+ '> span': {
41
+ pointerEvents: 'none'
42
+ }
43
+ }
44
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DisplayModeIcon = exports.DisplayModeGlyth = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _icon = _interopRequireDefault(require("@atlaskit/icon"));
11
+ var DisplayModeGlyth = exports.DisplayModeGlyth = function DisplayModeGlyth(props) {
12
+ return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
13
+ width: "24",
14
+ height: "24",
15
+ viewBox: "0 0 24 24",
16
+ fill: "none",
17
+ xmlns: "http://www.w3.org/2000/svg"
18
+ }, props), /*#__PURE__*/_react.default.createElement("rect", {
19
+ x: "4",
20
+ y: "5",
21
+ width: "4",
22
+ height: "14",
23
+ rx: "1",
24
+ fill: "currentColor"
25
+ }), /*#__PURE__*/_react.default.createElement("path", {
26
+ fillRule: "evenodd",
27
+ clipRule: "evenodd",
28
+ d: "M11 5C10.4477 5 10 5.44772 10 6V9.10102C11.0503 8.02921 12.4424 7.29368 14 7.07089V6C14 5.44772 13.5523 5 13 5H11Z",
29
+ fill: "currentColor"
30
+ }), /*#__PURE__*/_react.default.createElement("path", {
31
+ fillRule: "evenodd",
32
+ clipRule: "evenodd",
33
+ d: "M17 5C16.4477 5 16 5.44772 16 6V7.07089C17.5576 7.29368 18.9497 8.02921 20 9.10102V6C20 5.44772 19.5523 5 19 5H17Z",
34
+ fill: "currentColor"
35
+ }), /*#__PURE__*/_react.default.createElement("path", {
36
+ fillRule: "evenodd",
37
+ clipRule: "evenodd",
38
+ d: "M21 14C21 17.3137 18.3137 20 15 20C11.6863 20 9 17.3137 9 14C9 10.6863 11.6863 8 15 8C18.3137 8 21 10.6863 21 14ZM12 15C12 14.4477 12.4477 14 13 14V12C13 10.8954 13.8954 10 15 10C16.1046 10 17 10.8954 17 12V14C17.5523 14 18 14.4477 18 15V17C18 17.5523 17.5523 18 17 18H13C12.4477 18 12 17.5523 12 17V15ZM16 14V12C16 11.4477 15.5523 11 15 11C14.4477 11 14 11.4477 14 12V14H16Z",
39
+ fill: "currentColor"
40
+ }));
41
+ };
42
+ var DisplayModeIcon = exports.DisplayModeIcon = function DisplayModeIcon(props) {
43
+ return /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({
44
+ glyph: DisplayModeGlyth
45
+ }, props));
46
+ };
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "AddRowBelowIcon", {
27
27
  return _AddRowBelowIcon.AddRowBelowIcon;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "DisplayModeIcon", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _DisplayModeIcon.DisplayModeIcon;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "DragHandleDisabledIcon", {
31
37
  enumerable: true,
32
38
  get: function get() {
@@ -66,6 +72,7 @@ Object.defineProperty(exports, "SplitCellIcon", {
66
72
  var _DragHandleIcon = require("./DragHandleIcon");
67
73
  var _DragInMotionIcon = require("./DragInMotionIcon");
68
74
  var _DragHandleDisabledIcon = require("./DragHandleDisabledIcon");
75
+ var _DisplayModeIcon = require("./DisplayModeIcon");
69
76
  var _MinimisedHandle = require("./MinimisedHandle");
70
77
  var _MergeCellsIcon = require("./MergeCellsIcon");
71
78
  var _SplitCellIcon = require("./SplitCellIcon");
@@ -14,6 +14,7 @@ var _colors = require("@atlaskit/theme/colors");
14
14
  var _types = require("../types");
15
15
  var _consts = require("./consts");
16
16
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26;
17
+ /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs mahual remediation */
17
18
  var InsertLine = function InsertLine(cssString) {
18
19
  return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n background: ", ";\n display: none;\n position: absolute;\n z-index: ", ";\n ", "\n }\n"])), _types.TableCssClassName.CONTROLS_INSERT_LINE, _consts.tableBorderSelectedColor, _editorSharedStyles.akEditorUnitZIndex, cssString);
19
20
  };
@@ -0,0 +1,17 @@
1
+ import { findTable } from '@atlaskit/editor-tables/utils';
2
+ export const setTableDisplayMode = ({
3
+ tr
4
+ }) => {
5
+ const table = findTable(tr.selection);
6
+ if (!table) {
7
+ return null;
8
+ }
9
+ const {
10
+ displayMode
11
+ } = table.node.attrs;
12
+ tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, {
13
+ ...table.node.attrs,
14
+ displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default'
15
+ });
16
+ return tr.setMeta('scrollIntoView', false);
17
+ };
@@ -5,4 +5,5 @@ export { clearMultipleCells } from './clear';
5
5
  export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest } from './misc';
6
6
  export { sortByColumn } from './sort';
7
7
  export { goToNextCell } from './go-to-next-cell';
8
- export { removeDescendantNodes } from './referentiality';
8
+ export { removeDescendantNodes } from './referentiality';
9
+ export { setTableDisplayMode } from './display-mode';
@@ -23,7 +23,8 @@ const tableAttributes = node => {
23
23
  'data-layout': node.attrs.layout,
24
24
  'data-autosize': node.attrs.__autoSize,
25
25
  'data-table-local-id': node.attrs.localId || '',
26
- 'data-table-width': node.attrs.width
26
+ 'data-table-width': node.attrs.width,
27
+ 'data-table-display-mode': node.attrs.displayMode
27
28
  };
28
29
  };
29
30
  const getInlineWidth = (node, options, state, pos) => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
2
+ import { table, tableCell, tableHeader, tableRow, tableStage0 } 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
4
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
5
5
  import { IconTable } from '@atlaskit/editor-common/icons';
@@ -106,9 +106,10 @@ const tablesPlugin = ({
106
106
  insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
107
107
  },
108
108
  nodes() {
109
+ const tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') ? tableStage0 : table;
109
110
  return [{
110
111
  name: 'table',
111
- node: table
112
+ node: tableNode
112
113
  }, {
113
114
  name: 'tableHeader',
114
115
  node: tableHeader
@@ -419,7 +420,7 @@ const tablesPlugin = ({
419
420
  return tr;
420
421
  }
421
422
  }],
422
- floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
423
+ floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
423
424
  }
424
425
  };
425
426
  };
@@ -149,7 +149,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
149
149
  const resizedDelta = clientX - startX;
150
150
  tr = updateColumnWidths(newResizeState, table, start)(tr);
151
151
  if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
152
- tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
152
+ tr.setNodeAttribute(start - 1, 'width', newResizeState.tableWidth);
153
153
  }
154
154
  if (colIndex === map.width - 1) {
155
155
  const mouseUpTime = event.timeStamp;