@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
@@ -1,17 +1,26 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3;
2
+ var _templateObject;
3
3
  import { css } from '@emotion/react';
4
4
  import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
5
5
  import { N60A, N90 } from '@atlaskit/theme/colors';
6
6
  import { TableCssClassName as ClassName } from '../../types';
7
7
  import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD } from '../consts';
8
8
  export var cellColourPreviewStyles = function cellColourPreviewStyles(selectedColor) {
9
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &::before {\n background: ", ";\n }\n"])), selectedColor);
9
+ return css({
10
+ '&::before': {
11
+ background: selectedColor
12
+ }
13
+ });
10
14
  };
11
- export var elementBeforeIconStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-right: ", ";\n display: flex;\n"])), "var(--ds-space-negative-075, -6px)");
15
+ export var elementBeforeIconStyles = css({
16
+ marginRight: "var(--ds-space-negative-075, -6px)",
17
+ display: 'flex'
18
+ });
12
19
 
13
20
  // TODO Delete this comment after verifying space token -> previous value `padding: 8px`
14
21
  // TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
15
- export var tablePopupStyles = function tablePopupStyles(isDragAndDropEnabled) {
16
- return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\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"])), ClassName.CONTEXTUAL_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A), ")"), isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth, "var(--ds-space-100, 8px)", ClassName.CONTEXTUAL_MENU_ICON, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"), ClassName.CONTEXTUAL_MENU_ICON_SMALL, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"));
22
+ export var tablePopupStyles = function tablePopupStyles(isDragAndDropEnabled
23
+ // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
24
+ ) {
25
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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"])), ClassName.CONTEXTUAL_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A), ")"), isDragAndDropEnabled ? contextualMenuDropdownWidthDnD : contextualMenuDropdownWidth, "var(--ds-space-100, 8px)", ClassName.CONTEXTUAL_MENU_ICON, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"), ClassName.CONTEXTUAL_MENU_ICON_SMALL, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"));
17
26
  };
@@ -1,13 +1,37 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
2
+ var _templateObject;
3
3
  import { css } from '@emotion/react';
4
4
  import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
5
5
  import { N60A, N90 } from '@atlaskit/theme/colors';
6
6
  import { TableCssClassName as ClassName } from '../../types';
7
7
  import { dragMenuDropdownWidth } from '../consts';
8
8
  export var cellColourPreviewStyles = function cellColourPreviewStyles(selectedColor) {
9
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &::before {\n background: ", ";\n }\n"])), selectedColor);
9
+ return css({
10
+ '&::before': {
11
+ background: selectedColor
12
+ }
13
+ });
10
14
  };
11
- export var elementBeforeIconStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-right: ", ";\n display: flex;\n"])), "var(--ds-space-negative-075, -6px)");
12
- export var dragMenuBackgroundColorStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\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"])), ClassName.DRAG_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A), ")"), dragMenuDropdownWidth, "var(--ds-space-100, 8px)", ClassName.DRAG_SUBMENU_ICON, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"));
13
- export var toggleStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\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"])));
15
+ export var elementBeforeIconStyles = css({
16
+ marginRight: "var(--ds-space-negative-075, -6px)",
17
+ display: 'flex'
18
+ });
19
+
20
+ // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
21
+ export var dragMenuBackgroundColorStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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"])), ClassName.DRAG_SUBMENU, "var(--ds-border-radius, 3px)", "var(--ds-surface-overlay, white)", "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N60A, ", 0 0 1px ").concat(N60A), ")"), dragMenuDropdownWidth, "var(--ds-space-100, 8px)", ClassName.DRAG_SUBMENU_ICON, tableBackgroundBorderColor, "var(--ds-border-radius, 3px)", "var(--ds-space-050, 4px)", "var(--ds-icon, ".concat(N90, ")"));
22
+ export var toggleStyles = css({
23
+ display: 'flex',
24
+ "input[type='checkbox']": {
25
+ width: '30px',
26
+ height: '14px',
27
+ pointerEvents: 'initial',
28
+ cursor: 'pointer'
29
+ },
30
+ '> label': {
31
+ margin: '0px',
32
+ pointerEvents: 'none',
33
+ '> span': {
34
+ pointerEvents: 'none'
35
+ }
36
+ }
37
+ });
@@ -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';
@@ -1,5 +1,6 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
  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;
3
+ /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs mahual remediation */
3
4
  import { css } from '@emotion/react';
4
5
  import { tableCellBorderWidth, tableMarginTop, tableMarginTopWithControl } from '@atlaskit/editor-common/styles';
5
6
  import { akEditorShadowZIndex, akEditorTableBorder, akEditorTableNumberColumnWidth, akEditorUnitZIndex } from '@atlaskit/editor-shared-styles';
@@ -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.2",
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
  };
@@ -197,8 +197,9 @@ export const handleMouseDown = (
197
197
  tr = updateColumnWidths(newResizeState, table, start)(tr);
198
198
 
199
199
  if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
200
- tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
200
+ tr.setNodeAttribute(start - 1, 'width', newResizeState.tableWidth);
201
201
  }
202
+
202
203
  if (colIndex === map.width - 1) {
203
204
  const mouseUpTime = event.timeStamp;
204
205
 
@@ -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;