@atlaskit/editor-plugin-table 7.7.3 → 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 (52) hide show
  1. package/CHANGELOG.md +8 -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/toolbar.js +43 -12
  7. package/dist/cjs/ui/icons/DisplayModeIcon.js +46 -0
  8. package/dist/cjs/ui/icons/index.js +7 -0
  9. package/dist/es2019/commands/display-mode.js +17 -0
  10. package/dist/es2019/commands/index.js +2 -1
  11. package/dist/es2019/nodeviews/table.js +2 -1
  12. package/dist/es2019/plugin.js +4 -3
  13. package/dist/es2019/toolbar.js +41 -12
  14. package/dist/es2019/ui/icons/DisplayModeIcon.js +39 -0
  15. package/dist/es2019/ui/icons/index.js +1 -0
  16. package/dist/esm/commands/display-mode.js +16 -0
  17. package/dist/esm/commands/index.js +2 -1
  18. package/dist/esm/nodeviews/table.js +2 -1
  19. package/dist/esm/plugin.js +4 -3
  20. package/dist/esm/toolbar.js +44 -13
  21. package/dist/esm/ui/icons/DisplayModeIcon.js +39 -0
  22. package/dist/esm/ui/icons/index.js +1 -0
  23. package/dist/types/commands/display-mode.d.ts +2 -0
  24. package/dist/types/commands/index.d.ts +1 -0
  25. package/dist/types/commands/toggle.d.ts +1 -1
  26. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
  27. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
  28. package/dist/types/toolbar.d.ts +2 -1
  29. package/dist/types/ui/icons/DisplayModeIcon.d.ts +4 -0
  30. package/dist/types/ui/icons/index.d.ts +1 -0
  31. package/dist/types-ts4.5/commands/display-mode.d.ts +2 -0
  32. package/dist/types-ts4.5/commands/index.d.ts +1 -0
  33. package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
  34. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
  35. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
  36. package/dist/types-ts4.5/toolbar.d.ts +2 -1
  37. package/dist/types-ts4.5/ui/icons/DisplayModeIcon.d.ts +4 -0
  38. package/dist/types-ts4.5/ui/icons/index.d.ts +1 -0
  39. package/package.json +6 -3
  40. package/src/commands/display-mode.ts +19 -0
  41. package/src/commands/index.ts +1 -0
  42. package/src/commands/toggle.ts +1 -1
  43. package/src/commands-with-analytics.ts +3 -2
  44. package/src/nodeviews/table.tsx +1 -0
  45. package/src/plugin.tsx +15 -2
  46. package/src/pm-plugins/table-resizing/utils/misc.ts +3 -3
  47. package/src/pm-plugins/table-resizing/utils/resize-state.ts +1 -4
  48. package/src/toolbar.tsx +56 -22
  49. package/src/transforms/fix-tables.ts +1 -2
  50. package/src/types.ts +5 -0
  51. package/src/ui/icons/DisplayModeIcon.tsx +41 -0
  52. package/src/ui/icons/index.ts +1 -0
@@ -5,6 +5,7 @@ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
5
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
7
7
  import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
8
+ import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
8
9
  import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
9
10
  import { closestElement, getChildrenInfo as _getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
10
11
  import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
@@ -16,7 +17,7 @@ import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal
16
17
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
17
18
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
18
19
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
19
- import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
20
+ import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes, setTableDisplayMode } from './commands';
20
21
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
21
22
  import { getPluginState } from './pm-plugins/plugin-factory';
22
23
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
@@ -24,6 +25,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
24
25
  import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
25
26
  import { canMergeCells } from './transforms';
26
27
  import { TableCssClassName } from './types';
28
+ import { DisplayModeIcon } from './ui/icons';
27
29
  import { FullWidthDisplay } from './ui/TableFullWidthLabel';
28
30
  import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
29
31
  export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, editorAnalyticsAPI) {
@@ -300,7 +302,7 @@ export var getClosestSelectionOrTableRect = function getClosestSelectionOrTableR
300
302
  var tableRect = new Rect(0, 0, map.width, map.height);
301
303
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
302
304
  };
303
- export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
305
+ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
304
306
  return function (config) {
305
307
  return function (state, intl) {
306
308
  var _tableObject$node$att, _tableObject$node;
@@ -314,7 +316,9 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
314
316
  var isTableScalingEnabled = pluginState.isTableScalingEnabled,
315
317
  widthToWidest = pluginState.widthToWidest;
316
318
  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 : '';
317
- if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
319
+ if (isTableScalingEnabled &&
320
+ // TODO ED-21670: check if need options.isTableScalingEnabled
321
+ isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
318
322
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
319
323
  stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
320
324
  var nodeType = state.schema.nodes.table;
@@ -362,11 +366,12 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
362
366
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
363
367
  var _getPluginState2 = getPluginState(state),
364
368
  _getPluginState2$isTa = _getPluginState2.isTableScalingEnabled,
365
- _isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa;
369
+ _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
370
+
366
371
  var cellItems;
367
372
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
368
373
  var columnSettingsItems;
369
- columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
374
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options, _isTableScalingEnabled) : [];
370
375
  var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
371
376
 
372
377
  // Check if we need to show confirm dialog for delete button
@@ -493,32 +498,58 @@ export var getDistributeConfig = function getDistributeConfig(getEditorContainer
493
498
 
494
499
  // this create the button group for distribute column and also fixed column width
495
500
  // fixed column button should be in this function call in the future
496
- var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI) {
501
+ var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI, options) {
497
502
  var _newResizeStateWithAn2, _pluginState$pluginCo3;
498
503
  var formatMessage = _ref4.formatMessage;
499
- var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
504
+ var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
500
505
  var pluginState = getPluginState(editorState);
501
506
  var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
502
507
  if (!selectionOrTableRect || !editorView) {
503
508
  return [];
504
509
  }
505
- var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
510
+ var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled // TODO ED-21670: Here should be actual state of tableNode's displayMode attr
511
+ );
506
512
  var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
513
+ var items = [];
514
+ var isTableScalingLockBtnEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
515
+ if (isTableScalingLockBtnEnabled) {
516
+ var _pluginState$tableNod;
517
+ var areColumnWidthsLocked = (pluginState === null || pluginState === void 0 || (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
518
+ var title = areColumnWidthsLocked ? formatMessage(messages.unlockColumnWidths) : formatMessage(messages.lockColumnWidths);
519
+ items.push({
520
+ id: 'editor.table.lockColumns',
521
+ type: 'button',
522
+ title: title,
523
+ icon: function icon() {
524
+ return jsx(DisplayModeIcon, {
525
+ size: "medium",
526
+ label: title
527
+ });
528
+ },
529
+ onClick: editorCommandToPMCommand(setTableDisplayMode),
530
+ selected: areColumnWidthsLocked,
531
+ testId: 'table-lock-column-widths-btn'
532
+ });
533
+ }
507
534
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
508
- return [{
535
+ items.push({
509
536
  id: 'editor.table.distributeColumns',
510
537
  type: 'button',
511
538
  title: formatMessage(messages.distributeColumns),
512
539
  icon: DistributeColumnIcon,
513
540
  onClick: function onClick(state, dispatch, view) {
514
- return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view);
541
+ return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled // TODO ED-21670: Maybe here too we an actual state of tableNode's displayMode attr
542
+ )(state, dispatch, view);
515
543
  },
516
544
  disabled: !wouldChange
517
- }, {
545
+ });
546
+ }
547
+ if (items.length !== 0) {
548
+ items.push({
518
549
  type: 'separator'
519
- }];
550
+ });
520
551
  }
521
- return [];
552
+ return items;
522
553
  };
523
554
  var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI) {
524
555
  var _node$attrs;
@@ -0,0 +1,39 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Icon from '@atlaskit/icon';
4
+ export var DisplayModeGlyth = function DisplayModeGlyth(props) {
5
+ return /*#__PURE__*/React.createElement("svg", _extends({
6
+ width: "24",
7
+ height: "24",
8
+ viewBox: "0 0 24 24",
9
+ fill: "none",
10
+ xmlns: "http://www.w3.org/2000/svg"
11
+ }, props), /*#__PURE__*/React.createElement("rect", {
12
+ x: "4",
13
+ y: "5",
14
+ width: "4",
15
+ height: "14",
16
+ rx: "1",
17
+ fill: "currentColor"
18
+ }), /*#__PURE__*/React.createElement("path", {
19
+ fillRule: "evenodd",
20
+ clipRule: "evenodd",
21
+ 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",
22
+ fill: "currentColor"
23
+ }), /*#__PURE__*/React.createElement("path", {
24
+ fillRule: "evenodd",
25
+ clipRule: "evenodd",
26
+ 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",
27
+ fill: "currentColor"
28
+ }), /*#__PURE__*/React.createElement("path", {
29
+ fillRule: "evenodd",
30
+ clipRule: "evenodd",
31
+ 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",
32
+ fill: "currentColor"
33
+ }));
34
+ };
35
+ export var DisplayModeIcon = function DisplayModeIcon(props) {
36
+ return /*#__PURE__*/React.createElement(Icon, _extends({
37
+ glyph: DisplayModeGlyth
38
+ }, props));
39
+ };
@@ -1,6 +1,7 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
3
  export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
4
+ export { DisplayModeIcon } from './DisplayModeIcon';
4
5
  export { MinimisedHandleIcon } from './MinimisedHandle';
5
6
  export { MergeCellsIcon } from './MergeCellsIcon';
6
7
  export { SplitCellIcon } from './SplitCellIcon';
@@ -0,0 +1,2 @@
1
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
2
+ export declare const setTableDisplayMode: EditorCommand;
@@ -6,3 +6,4 @@ export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOr
6
6
  export { sortByColumn } from './sort';
7
7
  export { goToNextCell } from './go-to-next-cell';
8
8
  export { removeDescendantNodes } from './referentiality';
9
+ export { setTableDisplayMode } from './display-mode';
@@ -4,7 +4,7 @@ import type { Command } from '@atlaskit/editor-common/types';
4
4
  * Table layout toggle logic
5
5
  * default -> wide -> full-width -> default
6
6
  */
7
- export declare const getNextLayout: (currentLayout: TableLayout) => TableLayout;
7
+ export declare const getNextLayout: (currentLayout: TableLayout) => "default" | "wide" | "full-width";
8
8
  export declare const toggleHeaderRow: Command;
9
9
  export declare const toggleHeaderColumn: Command;
10
10
  export declare const toggleNumberColumn: Command;
@@ -1,10 +1,10 @@
1
- import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
1
+ import type { CellAttributes } from '@atlaskit/adf-schema';
2
2
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { TableOptions } from '../../../nodeviews/types';
7
- export declare function getLayoutSize(tableLayout: TableLayout, containerWidth: number | undefined, options: TableOptions): number;
7
+ export declare function getLayoutSize(tableLayout: 'default' | 'wide' | 'full-width', containerWidth: number | undefined, options: TableOptions): number;
8
8
  export declare function getDefaultLayoutMaxWidth(containerWidth?: number): number;
9
9
  export declare function pointsAtCell($pos: ResolvedPos): false | PMNode | null;
10
10
  export declare function currentColWidth(view: EditorView, cellPos: number, { colspan, colwidth }: CellAttributes): number;
@@ -13,7 +13,7 @@ interface getTableMaxWidthProps {
13
13
  table: PMNode;
14
14
  tableStart: number;
15
15
  state: EditorState;
16
- layout: TableLayout;
16
+ layout: 'default' | 'wide' | 'full-width';
17
17
  getEditorContainerWidth: GetEditorContainerWidth;
18
18
  }
19
19
  export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getEditorContainerWidth, }: getTableMaxWidthProps) => number;
@@ -1,4 +1,3 @@
1
- import type { TableLayout } from '@atlaskit/adf-schema';
2
1
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
@@ -23,7 +22,7 @@ export declare const evenAllColumnsWidths: (resizeState: ResizeState) => ResizeS
23
22
  export declare const evenSelectedColumnsWidths: (resizeState: ResizeState, rect: Rect) => ResizeState;
24
23
  export declare const bulkColumnsResize: (resizeState: ResizeState, columnsIndexes: number[], sourceColumnIndex: number) => ResizeState;
25
24
  export declare const areColumnsEven: (resizeState: ResizeState) => boolean;
26
- export declare const normaliseTableLayout: (input: string | undefined | null) => TableLayout;
25
+ export declare const normaliseTableLayout: (input: string | undefined | null) => "default" | "wide" | "full-width";
27
26
  export declare const getNewResizeStateFromSelectedColumns: (rect: Rect, state: EditorState, domAtPos: (pos: number) => {
28
27
  node: Node;
29
28
  offset: number;
@@ -3,10 +3,11 @@ import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, Floating
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import { Rect } from '@atlaskit/editor-tables/table-map';
6
+ import type { TablePluginOptions } from './plugin';
6
7
  import type { PluginConfig, ToolbarMenuConfig, ToolbarMenuContext, ToolbarMenuState } from './types';
7
8
  export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => FloatingToolbarItem<Command>;
8
9
  export declare const getToolbarCellOptionsConfig: (editorState: EditorState, editorView: EditorView | undefined | null, initialSelectionRect: Rect, { formatMessage }: ToolbarMenuContext, getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => FloatingToolbarDropdown<Command>;
9
10
  export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
10
11
  export declare const getClosestSelectionOrTableRect: (state: EditorState) => Rect | undefined;
11
- export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null) => (config: PluginConfig) => FloatingToolbarHandler;
12
+ export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions) => (config: PluginConfig) => FloatingToolbarHandler;
12
13
  export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { CustomGlyphProps, GlyphProps } from '@atlaskit/icon/types';
3
+ export declare const DisplayModeGlyth: (props: CustomGlyphProps) => JSX.Element;
4
+ export declare const DisplayModeIcon: (props: GlyphProps) => JSX.Element;
@@ -1,6 +1,7 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
3
  export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
4
+ export { DisplayModeIcon } from './DisplayModeIcon';
4
5
  export { MinimisedHandleIcon } from './MinimisedHandle';
5
6
  export { MergeCellsIcon } from './MergeCellsIcon';
6
7
  export { SplitCellIcon } from './SplitCellIcon';
@@ -0,0 +1,2 @@
1
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
2
+ export declare const setTableDisplayMode: EditorCommand;
@@ -6,3 +6,4 @@ export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOr
6
6
  export { sortByColumn } from './sort';
7
7
  export { goToNextCell } from './go-to-next-cell';
8
8
  export { removeDescendantNodes } from './referentiality';
9
+ export { setTableDisplayMode } from './display-mode';
@@ -4,7 +4,7 @@ import type { Command } from '@atlaskit/editor-common/types';
4
4
  * Table layout toggle logic
5
5
  * default -> wide -> full-width -> default
6
6
  */
7
- export declare const getNextLayout: (currentLayout: TableLayout) => TableLayout;
7
+ export declare const getNextLayout: (currentLayout: TableLayout) => "default" | "wide" | "full-width";
8
8
  export declare const toggleHeaderRow: Command;
9
9
  export declare const toggleHeaderColumn: Command;
10
10
  export declare const toggleNumberColumn: Command;
@@ -1,10 +1,10 @@
1
- import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
1
+ import type { CellAttributes } from '@atlaskit/adf-schema';
2
2
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
3
  import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { TableOptions } from '../../../nodeviews/types';
7
- export declare function getLayoutSize(tableLayout: TableLayout, containerWidth: number | undefined, options: TableOptions): number;
7
+ export declare function getLayoutSize(tableLayout: 'default' | 'wide' | 'full-width', containerWidth: number | undefined, options: TableOptions): number;
8
8
  export declare function getDefaultLayoutMaxWidth(containerWidth?: number): number;
9
9
  export declare function pointsAtCell($pos: ResolvedPos): false | PMNode | null;
10
10
  export declare function currentColWidth(view: EditorView, cellPos: number, { colspan, colwidth }: CellAttributes): number;
@@ -13,7 +13,7 @@ interface getTableMaxWidthProps {
13
13
  table: PMNode;
14
14
  tableStart: number;
15
15
  state: EditorState;
16
- layout: TableLayout;
16
+ layout: 'default' | 'wide' | 'full-width';
17
17
  getEditorContainerWidth: GetEditorContainerWidth;
18
18
  }
19
19
  export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getEditorContainerWidth, }: getTableMaxWidthProps) => number;
@@ -1,4 +1,3 @@
1
- import type { TableLayout } from '@atlaskit/adf-schema';
2
1
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
2
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
@@ -23,7 +22,7 @@ export declare const evenAllColumnsWidths: (resizeState: ResizeState) => ResizeS
23
22
  export declare const evenSelectedColumnsWidths: (resizeState: ResizeState, rect: Rect) => ResizeState;
24
23
  export declare const bulkColumnsResize: (resizeState: ResizeState, columnsIndexes: number[], sourceColumnIndex: number) => ResizeState;
25
24
  export declare const areColumnsEven: (resizeState: ResizeState) => boolean;
26
- export declare const normaliseTableLayout: (input: string | undefined | null) => TableLayout;
25
+ export declare const normaliseTableLayout: (input: string | undefined | null) => "default" | "wide" | "full-width";
27
26
  export declare const getNewResizeStateFromSelectedColumns: (rect: Rect, state: EditorState, domAtPos: (pos: number) => {
28
27
  node: Node;
29
28
  offset: number;
@@ -3,10 +3,11 @@ import type { Command, FloatingToolbarDropdown, FloatingToolbarHandler, Floating
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import { Rect } from '@atlaskit/editor-tables/table-map';
6
+ import type { TablePluginOptions } from './plugin';
6
7
  import type { PluginConfig, ToolbarMenuConfig, ToolbarMenuContext, ToolbarMenuState } from './types';
7
8
  export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => FloatingToolbarItem<Command>;
8
9
  export declare const getToolbarCellOptionsConfig: (editorState: EditorState, editorView: EditorView | undefined | null, initialSelectionRect: Rect, { formatMessage }: ToolbarMenuContext, getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => FloatingToolbarDropdown<Command>;
9
10
  export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
10
11
  export declare const getClosestSelectionOrTableRect: (state: EditorState) => Rect | undefined;
11
- export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null) => (config: PluginConfig) => FloatingToolbarHandler;
12
+ export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions) => (config: PluginConfig) => FloatingToolbarHandler;
12
13
  export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { CustomGlyphProps, GlyphProps } from '@atlaskit/icon/types';
3
+ export declare const DisplayModeGlyth: (props: CustomGlyphProps) => JSX.Element;
4
+ export declare const DisplayModeIcon: (props: GlyphProps) => JSX.Element;
@@ -1,6 +1,7 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
3
  export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
4
+ export { DisplayModeIcon } from './DisplayModeIcon';
4
5
  export { MinimisedHandleIcon } from './MinimisedHandle';
5
6
  export { MergeCellsIcon } from './MergeCellsIcon';
6
7
  export { SplitCellIcon } from './SplitCellIcon';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.7.3",
3
+ "version": "7.7.4",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,8 +28,8 @@
28
28
  "runReact18": false
29
29
  },
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^35.9.0",
32
- "@atlaskit/custom-steps": "^0.0.18",
31
+ "@atlaskit/adf-schema": "^35.9.2",
32
+ "@atlaskit/custom-steps": "^0.0.19",
33
33
  "@atlaskit/editor-common": "^78.30.0",
34
34
  "@atlaskit/editor-palette": "1.5.3",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.0.0",
@@ -136,6 +136,9 @@
136
136
  "platform.editor.table.cmd-a-select-table": {
137
137
  "type": "boolean"
138
138
  },
139
+ "platform.editor.table.preserve-widths-with-lock-button": {
140
+ "type": "boolean"
141
+ },
139
142
  "platform.editor.table.use-shared-state-hook": {
140
143
  "type": "boolean"
141
144
  },
@@ -0,0 +1,19 @@
1
+ import type { EditorCommand } from '@atlaskit/editor-common/types';
2
+ import { findTable } from '@atlaskit/editor-tables/utils';
3
+
4
+ export const setTableDisplayMode: EditorCommand = ({ tr }) => {
5
+ const table = findTable(tr.selection);
6
+ if (!table) {
7
+ return null;
8
+ }
9
+
10
+ const { displayMode } = table.node.attrs;
11
+
12
+ tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, {
13
+ ...table.node.attrs,
14
+ displayMode:
15
+ !displayMode || displayMode === 'default' ? 'fixed' : 'default',
16
+ });
17
+
18
+ return tr.setMeta('scrollIntoView', false);
19
+ };
@@ -44,3 +44,4 @@ export {
44
44
  export { sortByColumn } from './sort';
45
45
  export { goToNextCell } from './go-to-next-cell';
46
46
  export { removeDescendantNodes } from './referentiality';
47
+ export { setTableDisplayMode } from './display-mode';
@@ -15,7 +15,7 @@ import { META_KEYS } from '../pm-plugins/table-analytics';
15
15
  * Table layout toggle logic
16
16
  * default -> wide -> full-width -> default
17
17
  */
18
- export const getNextLayout = (currentLayout: TableLayout): TableLayout => {
18
+ export const getNextLayout = (currentLayout: TableLayout) => {
19
19
  switch (currentLayout) {
20
20
  case 'default':
21
21
  return 'wide';
@@ -1,6 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl-next/src/types';
2
2
 
3
- import type { TableLayout } from '@atlaskit/adf-schema';
4
3
  import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
5
4
  import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
6
5
  import {
@@ -535,7 +534,9 @@ export const toggleTableLayoutWithAnalytics = (
535
534
  );
536
535
 
537
536
  if (table) {
538
- const { layout } = table.node.attrs as { layout: TableLayout };
537
+ const { layout } = table.node.attrs as {
538
+ layout: 'default' | 'wide' | 'full-width';
539
+ };
539
540
  return {
540
541
  action: TABLE_ACTION.CHANGED_BREAKOUT_MODE,
541
542
  actionSubject: ACTION_SUBJECT.TABLE,
@@ -50,6 +50,7 @@ const tableAttributes = (node: PmNode) => {
50
50
  'data-autosize': node.attrs.__autoSize,
51
51
  'data-table-local-id': node.attrs.localId || '',
52
52
  'data-table-width': node.attrs.width,
53
+ 'data-table-display-mode': node.attrs.displayMode,
53
54
  };
54
55
  };
55
56
 
package/src/plugin.tsx CHANGED
@@ -1,6 +1,12 @@
1
1
  import React from 'react';
2
2
 
3
- import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
3
+ import {
4
+ table,
5
+ tableCell,
6
+ tableHeader,
7
+ tableRow,
8
+ tableStage0,
9
+ } from '@atlaskit/adf-schema';
4
10
  import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
5
11
  import {
6
12
  ACTION,
@@ -223,8 +229,14 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
223
229
  },
224
230
 
225
231
  nodes() {
232
+ const tableNode =
233
+ options?.isTableScalingEnabled &&
234
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button')
235
+ ? tableStage0
236
+ : table;
237
+
226
238
  return [
227
- { name: 'table', node: table },
239
+ { name: 'table', node: tableNode },
228
240
  { name: 'tableHeader', node: tableHeader },
229
241
  { name: 'tableRow', node: tableRow },
230
242
  { name: 'tableCell', node: tableCell },
@@ -610,6 +622,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
610
622
  editorAnalyticsAPI,
611
623
  options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
612
624
  () => editorViewRef.current,
625
+ options,
613
626
  )(pluginConfig(options?.tableOptions)),
614
627
  },
615
628
  };
@@ -1,4 +1,4 @@
1
- import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
1
+ import type { CellAttributes } from '@atlaskit/adf-schema';
2
2
  import {
3
3
  getParentNodeWidth,
4
4
  getTableContainerWidth,
@@ -34,7 +34,7 @@ import { MAX_SCALING_PERCENT } from './consts';
34
34
 
35
35
  // Translates named layouts in number values.
36
36
  export function getLayoutSize(
37
- tableLayout: TableLayout,
37
+ tableLayout: 'default' | 'wide' | 'full-width',
38
38
  containerWidth: number = 0,
39
39
  options: TableOptions,
40
40
  ): number {
@@ -112,7 +112,7 @@ interface getTableMaxWidthProps {
112
112
  table: PMNode;
113
113
  tableStart: number;
114
114
  state: EditorState;
115
- layout: TableLayout;
115
+ layout: 'default' | 'wide' | 'full-width';
116
116
  getEditorContainerWidth: GetEditorContainerWidth;
117
117
  }
118
118
 
@@ -1,4 +1,3 @@
1
- import type { TableLayout } from '@atlaskit/adf-schema';
2
1
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
3
2
  import {
4
3
  tableCellMinWidth,
@@ -321,9 +320,7 @@ export const areColumnsEven = (resizeState: ResizeState): boolean => {
321
320
  };
322
321
 
323
322
  // Get the layout
324
- export const normaliseTableLayout = (
325
- input: string | undefined | null,
326
- ): TableLayout => {
323
+ export const normaliseTableLayout = (input: string | undefined | null) => {
327
324
  switch (input) {
328
325
  case 'wide':
329
326
  return input;