@atlaskit/editor-plugin-table 2.10.8 → 2.11.0

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 (86) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/plugins/table/commands/misc.js +58 -5
  3. package/dist/cjs/plugins/table/event-handlers.js +3 -6
  4. package/dist/cjs/plugins/table/index.js +3 -2
  5. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +13 -19
  6. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-resizing.js +18 -5
  7. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/index.js +6 -0
  8. package/dist/cjs/plugins/table/pm-plugins/main.js +7 -3
  9. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
  10. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
  11. package/dist/cjs/plugins/table/reducer.js +26 -2
  12. package/dist/cjs/plugins/table/types.js +1 -0
  13. package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +44 -0
  14. package/dist/cjs/plugins/table/ui/messages.js +5 -0
  15. package/dist/cjs/plugins/table/utils/decoration.js +17 -4
  16. package/dist/es2019/plugins/table/commands/misc.js +49 -5
  17. package/dist/es2019/plugins/table/event-handlers.js +3 -6
  18. package/dist/es2019/plugins/table/index.js +3 -2
  19. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +14 -17
  20. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-resizing.js +12 -2
  21. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/index.js +1 -1
  22. package/dist/es2019/plugins/table/pm-plugins/main.js +6 -3
  23. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
  24. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
  25. package/dist/es2019/plugins/table/reducer.js +29 -2
  26. package/dist/es2019/plugins/table/types.js +1 -0
  27. package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +35 -0
  28. package/dist/es2019/plugins/table/ui/messages.js +5 -0
  29. package/dist/es2019/plugins/table/utils/decoration.js +16 -5
  30. package/dist/esm/plugins/table/commands/misc.js +56 -5
  31. package/dist/esm/plugins/table/event-handlers.js +3 -6
  32. package/dist/esm/plugins/table/index.js +3 -2
  33. package/dist/esm/plugins/table/nodeviews/TableResizer.js +13 -19
  34. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-resizing.js +15 -3
  35. package/dist/esm/plugins/table/pm-plugins/decorations/utils/index.js +1 -1
  36. package/dist/esm/plugins/table/pm-plugins/main.js +8 -4
  37. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -0
  38. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +2 -0
  39. package/dist/esm/plugins/table/reducer.js +26 -2
  40. package/dist/esm/plugins/table/types.js +1 -0
  41. package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +35 -0
  42. package/dist/esm/plugins/table/ui/messages.js +5 -0
  43. package/dist/esm/plugins/table/utils/decoration.js +17 -4
  44. package/dist/types/plugins/table/commands/misc.d.ts +8 -6
  45. package/dist/types/plugins/table/event-handlers.d.ts +3 -3
  46. package/dist/types/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -2
  47. package/dist/types/plugins/table/pm-plugins/decorations/utils/index.d.ts +1 -1
  48. package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
  49. package/dist/types/plugins/table/pm-plugins/table-resizing/plugin.d.ts +2 -2
  50. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
  51. package/dist/types/plugins/table/reducer.d.ts +1 -1
  52. package/dist/types/plugins/table/types.d.ts +18 -0
  53. package/dist/types/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
  54. package/dist/types/plugins/table/ui/messages.d.ts +5 -0
  55. package/dist/types/plugins/table/utils/decoration.d.ts +2 -1
  56. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +8 -6
  57. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +3 -3
  58. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +4 -2
  59. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/index.d.ts +1 -1
  60. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +2 -1
  61. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +2 -2
  62. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +3 -3
  63. package/dist/types-ts4.5/plugins/table/reducer.d.ts +1 -1
  64. package/dist/types-ts4.5/plugins/table/types.d.ts +18 -0
  65. package/dist/types-ts4.5/plugins/table/ui/ColumnResizeWidget/index.d.ts +9 -0
  66. package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +5 -0
  67. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +2 -1
  68. package/package.json +2 -2
  69. package/src/__tests__/unit/event-handlers.ts +1 -1
  70. package/src/__tests__/unit/nodeviews/TableContainer.tsx +17 -8
  71. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
  72. package/src/plugins/table/commands/misc.ts +84 -7
  73. package/src/plugins/table/event-handlers.ts +11 -16
  74. package/src/plugins/table/index.tsx +2 -0
  75. package/src/plugins/table/nodeviews/TableResizer.tsx +12 -20
  76. package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +34 -7
  77. package/src/plugins/table/pm-plugins/decorations/utils/index.ts +4 -1
  78. package/src/plugins/table/pm-plugins/main.ts +7 -1
  79. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +5 -0
  80. package/src/plugins/table/pm-plugins/table-resizing/plugin.ts +3 -5
  81. package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +5 -3
  82. package/src/plugins/table/reducer.ts +51 -3
  83. package/src/plugins/table/types.ts +19 -0
  84. package/src/plugins/table/ui/ColumnResizeWidget/index.tsx +53 -0
  85. package/src/plugins/table/ui/messages.ts +5 -0
  86. package/src/plugins/table/utils/decoration.ts +27 -5
@@ -5,6 +5,7 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
5
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
6
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
7
7
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
+ import { updateResizeHandleDecorations } from '../../commands/misc';
8
9
  import { updateColumnWidths } from '../../transforms';
9
10
  import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
10
11
  import { evenColumns, setDragging, stopResizing } from './commands';
@@ -58,6 +59,10 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
58
59
  startX: event.clientX,
59
60
  startWidth: width
60
61
  })(state, dispatch);
62
+
63
+ // When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
64
+ // unnecessary tooltips being displayed during drag.
65
+ updateResizeHandleDecorations(undefined, undefined, false)(state, dispatch);
61
66
  function finish(event) {
62
67
  window.removeEventListener('mouseup', finish);
63
68
  window.removeEventListener('mousemove', move);
@@ -10,6 +10,7 @@ import { getLayoutSize } from '../utils/misc';
10
10
  import { reduceSpace } from '../utils/resize-logic';
11
11
  import { adjustColumnsWidths, getResizeState, getTotalWidth, updateColgroup } from '../utils/resize-state';
12
12
  import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
13
+ import { syncStickyRowToTable } from './dom';
13
14
  // Base function to trigger the actual scale on a table node.
14
15
  // Will only resize/scale if a table has been previously resized.
15
16
  export var scale = function scale(tableRef, options, domAtPos) {
@@ -112,6 +113,7 @@ export var previewScaleTable = function previewScaleTable(tableRef, options, dom
112
113
  tableRef.style.width = "".concat(width, "px");
113
114
  }
114
115
  if (!hasTableBeenResized(node)) {
116
+ syncStickyRowToTable(tableRef);
115
117
  return;
116
118
  }
117
119
  var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
@@ -58,10 +58,34 @@ export default (function (pluginState, action) {
58
58
  resizeHandleRowIndex: undefined
59
59
  });
60
60
  case 'ADD_RESIZE_HANDLE_DECORATIONS':
61
- if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex) {
61
+ if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip) {
62
62
  return pluginState;
63
63
  }
64
- return _objectSpread(_objectSpread({}, pluginState), action.data);
64
+ return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
65
+ isResizeHandleWidgetAdded: true
66
+ });
67
+ case 'UPDATE_RESIZE_HANDLE_DECORATIONS':
68
+ var _action$data = action.data,
69
+ resizeHandleColumnIndex = _action$data.resizeHandleColumnIndex,
70
+ resizeHandleRowIndex = _action$data.resizeHandleRowIndex,
71
+ resizeHandleIncludeTooltip = _action$data.resizeHandleIncludeTooltip;
72
+ if ((resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex || !Number.isFinite(resizeHandleColumnIndex)) && (resizeHandleRowIndex === pluginState.resizeHandleRowIndex || !Number.isFinite(resizeHandleRowIndex)) && (resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip || resizeHandleIncludeTooltip === undefined)) {
73
+ return pluginState;
74
+ }
75
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
76
+ resizeHandleColumnIndex: resizeHandleColumnIndex !== null && resizeHandleColumnIndex !== void 0 ? resizeHandleColumnIndex : pluginState.resizeHandleColumnIndex,
77
+ resizeHandleRowIndex: resizeHandleRowIndex !== null && resizeHandleRowIndex !== void 0 ? resizeHandleRowIndex : pluginState.resizeHandleRowIndex,
78
+ resizeHandleIncludeTooltip: resizeHandleIncludeTooltip !== null && resizeHandleIncludeTooltip !== void 0 ? resizeHandleIncludeTooltip : pluginState.resizeHandleIncludeTooltip
79
+ });
80
+ case 'REMOVE_RESIZE_HANDLE_DECORATIONS':
81
+ if (!pluginState.isResizeHandleWidgetAdded) {
82
+ return pluginState;
83
+ }
84
+ return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
85
+ resizeHandleColumnIndex: undefined,
86
+ resizeHandleRowIndex: undefined,
87
+ isResizeHandleWidgetAdded: false
88
+ });
65
89
  case 'SET_TABLE_REF':
66
90
  case 'HOVER_ROWS':
67
91
  case 'HOVER_COLUMNS':
@@ -39,6 +39,7 @@ export var TableDecorations = /*#__PURE__*/function (TableDecorations) {
39
39
  TableDecorations["COLUMN_CONTROLS_DECORATIONS"] = "COLUMN_CONTROLS_DECORATIONS";
40
40
  TableDecorations["COLUMN_SELECTED"] = "COLUMN_SELECTED";
41
41
  TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
42
+ TableDecorations["COLUMN_RESIZING_HANDLE_WIDGET"] = "COLUMN_RESIZING_HANDLE_WIDGET";
42
43
  TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
43
44
  TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
44
45
  return TableDecorations;
@@ -0,0 +1,35 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /** @jsx jsx */
3
+ import React from 'react';
4
+ import { jsx } from '@emotion/react';
5
+ import { useIntl } from 'react-intl-next';
6
+ import Tooltip from '@atlaskit/tooltip';
7
+ import { TableCssClassName } from '../../types';
8
+ import messages from '../messages';
9
+ export var ColumnResizeWidget = function ColumnResizeWidget(_ref) {
10
+ var startIndex = _ref.startIndex,
11
+ endIndex = _ref.endIndex,
12
+ includeTooltip = _ref.includeTooltip;
13
+ var _useIntl = useIntl(),
14
+ formatMessage = _useIntl.formatMessage;
15
+ if (!includeTooltip) {
16
+ return jsx("div", {
17
+ className: TableCssClassName.RESIZE_HANDLE_DECORATION,
18
+ "data-start-index": startIndex,
19
+ "data-end-index": endIndex
20
+ });
21
+ }
22
+ return jsx(Tooltip, {
23
+ content: formatMessage(messages.adjustColumns),
24
+ hideTooltipOnClick: true,
25
+ hideTooltipOnMouseDown: true,
26
+ position: "mouse",
27
+ mousePosition: "auto-start"
28
+ }, function (tooltipProps) {
29
+ return jsx("div", _extends({
30
+ className: TableCssClassName.RESIZE_HANDLE_DECORATION,
31
+ "data-start-index": startIndex,
32
+ "data-end-index": endIndex
33
+ }, tooltipProps));
34
+ });
35
+ };
@@ -54,5 +54,10 @@ export default defineMessages({
54
54
  id: 'fabric.editor.extension.sourceNoTitledName',
55
55
  defaultMessage: 'this element',
56
56
  description: 'The current element without preset name been selected'
57
+ },
58
+ adjustColumns: {
59
+ id: 'fabric.editor.tables.adjustColumn',
60
+ defaultMessage: 'Adjust column',
61
+ description: 'Tooltip displayed on table column resize handle'
57
62
  }
58
63
  });
@@ -1,4 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { createElement } from 'react';
3
+ import ReactDOM from 'react-dom';
4
+ import { RawIntlProvider } from 'react-intl-next';
2
5
  import { nonNullable } from '@atlaskit/editor-common/utils';
3
6
 
4
7
  // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
@@ -7,6 +10,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
10
  import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
8
11
  import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
9
12
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
13
+ import { ColumnResizeWidget } from '../ui/ColumnResizeWidget';
10
14
  var filterDecorationByKey = function filterDecorationByKey(key, decorationSet) {
11
15
  return decorationSet.find(undefined, undefined, function (spec) {
12
16
  return spec.key.indexOf(key) > -1;
@@ -257,6 +261,8 @@ var makeArray = function makeArray(n) {
257
261
  * hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
258
262
  */
259
263
  export var createResizeHandleDecoration = function createResizeHandleDecoration(tr, rowIndexTarget, columnEndIndexTarget) {
264
+ var includeTooltip = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
265
+ var getIntl = arguments.length > 4 ? arguments[4] : undefined;
260
266
  var emptyResult = [[], []];
261
267
  var table = findTable(tr.selection);
262
268
  if (!table || !table.node) {
@@ -270,12 +276,19 @@ export var createResizeHandleDecoration = function createResizeHandleDecoration(
270
276
  var position = cellPos + cellNode.nodeSize - 1;
271
277
  return Decoration.widget(position, function () {
272
278
  var element = document.createElement('div');
273
- element.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
274
- element.dataset.startIndex = "".concat(cellColumnPositioning.left);
275
- element.dataset.endIndex = "".concat(cellColumnPositioning.right);
279
+ ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
280
+ value: getIntl()
281
+ }, /*#__PURE__*/createElement(ColumnResizeWidget, {
282
+ startIndex: cellColumnPositioning.left,
283
+ endIndex: cellColumnPositioning.right,
284
+ includeTooltip: includeTooltip
285
+ })), element);
276
286
  return element;
277
287
  }, {
278
- key: "".concat(TableDecorations.COLUMN_RESIZING_HANDLE, "_").concat(rowIndex, "_").concat(columnIndex)
288
+ key: "".concat(TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET, "_").concat(rowIndex, "_").concat(columnIndex, "_").concat(includeTooltip ? 'with' : 'no', "-tooltip"),
289
+ destroy: function destroy(node) {
290
+ ReactDOM.unmountComponentAtNode(node);
291
+ }
279
292
  });
280
293
  };
281
294
  var createLastCellElementDecoration = function createLastCellElementDecoration(cellColumnPositioning, cellPos, cellNode) {
@@ -1,8 +1,8 @@
1
- import { Command } from '@atlaskit/editor-common/types';
2
- import { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
3
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  export declare const setEditorFocus: (editorHasFocus: boolean) => Command;
7
7
  export declare const setTableRef: (ref?: HTMLTableElement) => Command;
8
8
  export declare const setCellAttr: (name: string, value: any) => Command;
@@ -20,7 +20,9 @@ export declare const selectRow: (row: number, expand?: boolean) => Command;
20
20
  export declare const showInsertColumnButton: (columnIndex: number) => Command;
21
21
  export declare const showInsertRowButton: (rowIndex: number) => Command;
22
22
  export declare const hideInsertColumnOrRowButton: () => Command;
23
- export declare const addResizeHandleDecorations: (rowIndex: number, columnIndex: number) => Command;
23
+ export declare const addResizeHandleDecorations: (rowIndex: number, columnIndex: number, includeTooltip: boolean) => Command;
24
+ export declare const updateResizeHandleDecorations: (rowIndex?: number, columnIndex?: number, includeTooltip?: boolean) => Command;
25
+ export declare const removeResizeHandleDecorations: () => Command;
24
26
  export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTMLTableElement, basePos: number | undefined, opts: {
25
27
  containerWidth: number;
26
28
  }) => boolean;
@@ -1,7 +1,7 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import { ElementContentRects } from './types';
2
+ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { ElementContentRects } from './types';
5
5
  export declare const handleBlur: (view: EditorView, event: Event) => boolean;
6
6
  export declare const handleFocus: (view: EditorView, event: Event) => boolean;
7
7
  export declare const handleClick: (view: EditorView, event: Event) => boolean;
@@ -1,2 +1,4 @@
1
- import { DecorationTransformer } from './types';
2
- export declare const buildColumnResizingDecorations: (rowEndIndex: number, columnEndIndex: number) => DecorationTransformer;
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { DecorationTransformer } from './types';
3
+ export declare const buildColumnResizingDecorations: (rowEndIndex: number, columnEndIndex: number, includeTooltip: boolean, getIntl: () => IntlShape) => DecorationTransformer;
4
+ export declare const clearColumnResizingDecorations: () => DecorationTransformer;
@@ -1,3 +1,3 @@
1
1
  export { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecoration, } from './column-controls';
2
- export { buildColumnResizingDecorations } from './column-resizing';
2
+ export { buildColumnResizingDecorations, clearColumnResizingDecorations, } from './column-resizing';
3
3
  export { composeDecorations } from './compose-decorations';
@@ -1,7 +1,8 @@
1
+ import type { IntlShape } from 'react-intl-next';
1
2
  import type { DispatchAnalyticsEvent, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
4
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
4
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
6
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
6
7
  import type { PluginConfig, PluginInjectionAPI } from '../types';
7
- export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, tableResizingEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
8
+ export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, tableResizingEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
@@ -1,6 +1,6 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
2
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
- import { ColumnResizingPluginState } from '../../types';
5
+ import type { ColumnResizingPluginState } from '../../types';
6
6
  export declare function createPlugin(dispatch: Dispatch<ColumnResizingPluginState>, { lastColumnResizable }: ColumnResizingPluginState, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, editorAnalyticsAPI?: EditorAnalyticsAPI): SafePlugin<ColumnResizingPluginState>;
@@ -1,7 +1,7 @@
1
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { DomAtPos } from '@atlaskit/editor-prosemirror/utils';
4
- import { ResizeState } from '../utils/types';
4
+ import type { ResizeState } from '../utils/types';
5
5
  export interface ScaleOptions {
6
6
  node: PMNode;
7
7
  prevNode: PMNode;
@@ -1,3 +1,3 @@
1
- import { TablePluginAction, TablePluginState } from './types';
1
+ import type { TablePluginAction, TablePluginState } from './types';
2
2
  declare const _default: (pluginState: TablePluginState, action: TablePluginAction) => TablePluginState;
3
3
  export default _default;
@@ -69,10 +69,13 @@ export interface TablePluginState {
69
69
  isFullWidthModeEnabled?: boolean;
70
70
  layout?: TableLayout;
71
71
  ordering?: TableColumnOrdering;
72
+ isResizeHandleWidgetAdded?: boolean;
72
73
  resizeHandleRowIndex?: number;
73
74
  resizeHandleColumnIndex?: number;
75
+ resizeHandleIncludeTooltip?: boolean;
74
76
  isTableCollapsed?: boolean;
75
77
  canCollapseTable?: boolean;
78
+ getIntl: () => IntlShape;
76
79
  }
77
80
  export type TablePluginAction = {
78
81
  type: 'SET_EDITOR_FOCUS';
@@ -131,6 +134,20 @@ export type TablePluginAction = {
131
134
  decorationSet: DecorationSet;
132
135
  resizeHandleRowIndex: number;
133
136
  resizeHandleColumnIndex: number;
137
+ resizeHandleIncludeTooltip: boolean;
138
+ };
139
+ } | {
140
+ type: 'UPDATE_RESIZE_HANDLE_DECORATIONS';
141
+ data: {
142
+ decorationSet: DecorationSet;
143
+ resizeHandleRowIndex: number | undefined;
144
+ resizeHandleColumnIndex: number | undefined;
145
+ resizeHandleIncludeTooltip: boolean | undefined;
146
+ };
147
+ } | {
148
+ type: 'REMOVE_RESIZE_HANDLE_DECORATIONS';
149
+ data: {
150
+ decorationSet: DecorationSet;
134
151
  };
135
152
  } | {
136
153
  type: 'CLEAR_HOVER_SELECTION';
@@ -212,6 +229,7 @@ export declare enum TableDecorations {
212
229
  COLUMN_CONTROLS_DECORATIONS = "COLUMN_CONTROLS_DECORATIONS",
213
230
  COLUMN_SELECTED = "COLUMN_SELECTED",
214
231
  COLUMN_RESIZING_HANDLE = "COLUMN_RESIZING_HANDLE",
232
+ COLUMN_RESIZING_HANDLE_WIDGET = "COLUMN_RESIZING_HANDLE_WIDGET",
215
233
  COLUMN_RESIZING_HANDLE_LINE = "COLUMN_RESIZING_HANDLE_LINE",
216
234
  LAST_CELL_ELEMENT = "LAST_CELL_ELEMENT"
217
235
  }
@@ -0,0 +1,9 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ type Props = {
4
+ startIndex: number;
5
+ endIndex: number;
6
+ includeTooltip?: boolean;
7
+ };
8
+ export declare const ColumnResizeWidget: React.FC<Props>;
9
+ export {};
@@ -54,5 +54,10 @@ declare const _default: {
54
54
  defaultMessage: string;
55
55
  description: string;
56
56
  };
57
+ adjustColumns: {
58
+ id: string;
59
+ defaultMessage: string;
60
+ description: string;
61
+ };
57
62
  };
58
63
  export default _default;
@@ -1,3 +1,4 @@
1
+ import type { IntlShape } from 'react-intl-next';
1
2
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
@@ -11,5 +12,5 @@ export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row'
11
12
  export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
12
13
  export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
13
14
  export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
14
- export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>) => [Decoration[], Decoration[]];
15
+ export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>, includeTooltip: boolean | undefined, getIntl: () => IntlShape) => [Decoration[], Decoration[]];
15
16
  export declare const createColumnLineResize: (selection: Selection, cellColumnPositioning: Omit<CellColumnPositioning, 'left'>) => Decoration[];
@@ -1,8 +1,8 @@
1
- import { Command } from '@atlaskit/editor-common/types';
2
- import { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
3
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  export declare const setEditorFocus: (editorHasFocus: boolean) => Command;
7
7
  export declare const setTableRef: (ref?: HTMLTableElement) => Command;
8
8
  export declare const setCellAttr: (name: string, value: any) => Command;
@@ -20,7 +20,9 @@ export declare const selectRow: (row: number, expand?: boolean) => Command;
20
20
  export declare const showInsertColumnButton: (columnIndex: number) => Command;
21
21
  export declare const showInsertRowButton: (rowIndex: number) => Command;
22
22
  export declare const hideInsertColumnOrRowButton: () => Command;
23
- export declare const addResizeHandleDecorations: (rowIndex: number, columnIndex: number) => Command;
23
+ export declare const addResizeHandleDecorations: (rowIndex: number, columnIndex: number, includeTooltip: boolean) => Command;
24
+ export declare const updateResizeHandleDecorations: (rowIndex?: number, columnIndex?: number, includeTooltip?: boolean) => Command;
25
+ export declare const removeResizeHandleDecorations: () => Command;
24
26
  export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTMLTableElement, basePos: number | undefined, opts: {
25
27
  containerWidth: number;
26
28
  }) => boolean;
@@ -1,7 +1,7 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import { ElementContentRects } from './types';
2
+ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { ElementContentRects } from './types';
5
5
  export declare const handleBlur: (view: EditorView, event: Event) => boolean;
6
6
  export declare const handleFocus: (view: EditorView, event: Event) => boolean;
7
7
  export declare const handleClick: (view: EditorView, event: Event) => boolean;
@@ -1,2 +1,4 @@
1
- import { DecorationTransformer } from './types';
2
- export declare const buildColumnResizingDecorations: (rowEndIndex: number, columnEndIndex: number) => DecorationTransformer;
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { DecorationTransformer } from './types';
3
+ export declare const buildColumnResizingDecorations: (rowEndIndex: number, columnEndIndex: number, includeTooltip: boolean, getIntl: () => IntlShape) => DecorationTransformer;
4
+ export declare const clearColumnResizingDecorations: () => DecorationTransformer;
@@ -1,3 +1,3 @@
1
1
  export { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecoration, } from './column-controls';
2
- export { buildColumnResizingDecorations } from './column-resizing';
2
+ export { buildColumnResizingDecorations, clearColumnResizingDecorations, } from './column-resizing';
3
3
  export { composeDecorations } from './compose-decorations';
@@ -1,7 +1,8 @@
1
+ import type { IntlShape } from 'react-intl-next';
1
2
  import type { DispatchAnalyticsEvent, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
4
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
4
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
6
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
6
7
  import type { PluginConfig, PluginInjectionAPI } from '../types';
7
- export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, tableResizingEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
8
+ export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, tableResizingEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
@@ -1,6 +1,6 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
2
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
- import { ColumnResizingPluginState } from '../../types';
5
+ import type { ColumnResizingPluginState } from '../../types';
6
6
  export declare function createPlugin(dispatch: Dispatch<ColumnResizingPluginState>, { lastColumnResizable }: ColumnResizingPluginState, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, editorAnalyticsAPI?: EditorAnalyticsAPI): SafePlugin<ColumnResizingPluginState>;
@@ -1,7 +1,7 @@
1
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { DomAtPos } from '@atlaskit/editor-prosemirror/utils';
4
- import { ResizeState } from '../utils/types';
4
+ import type { ResizeState } from '../utils/types';
5
5
  export interface ScaleOptions {
6
6
  node: PMNode;
7
7
  prevNode: PMNode;
@@ -1,3 +1,3 @@
1
- import { TablePluginAction, TablePluginState } from './types';
1
+ import type { TablePluginAction, TablePluginState } from './types';
2
2
  declare const _default: (pluginState: TablePluginState, action: TablePluginAction) => TablePluginState;
3
3
  export default _default;
@@ -69,10 +69,13 @@ export interface TablePluginState {
69
69
  isFullWidthModeEnabled?: boolean;
70
70
  layout?: TableLayout;
71
71
  ordering?: TableColumnOrdering;
72
+ isResizeHandleWidgetAdded?: boolean;
72
73
  resizeHandleRowIndex?: number;
73
74
  resizeHandleColumnIndex?: number;
75
+ resizeHandleIncludeTooltip?: boolean;
74
76
  isTableCollapsed?: boolean;
75
77
  canCollapseTable?: boolean;
78
+ getIntl: () => IntlShape;
76
79
  }
77
80
  export type TablePluginAction = {
78
81
  type: 'SET_EDITOR_FOCUS';
@@ -131,6 +134,20 @@ export type TablePluginAction = {
131
134
  decorationSet: DecorationSet;
132
135
  resizeHandleRowIndex: number;
133
136
  resizeHandleColumnIndex: number;
137
+ resizeHandleIncludeTooltip: boolean;
138
+ };
139
+ } | {
140
+ type: 'UPDATE_RESIZE_HANDLE_DECORATIONS';
141
+ data: {
142
+ decorationSet: DecorationSet;
143
+ resizeHandleRowIndex: number | undefined;
144
+ resizeHandleColumnIndex: number | undefined;
145
+ resizeHandleIncludeTooltip: boolean | undefined;
146
+ };
147
+ } | {
148
+ type: 'REMOVE_RESIZE_HANDLE_DECORATIONS';
149
+ data: {
150
+ decorationSet: DecorationSet;
134
151
  };
135
152
  } | {
136
153
  type: 'CLEAR_HOVER_SELECTION';
@@ -212,6 +229,7 @@ export declare enum TableDecorations {
212
229
  COLUMN_CONTROLS_DECORATIONS = "COLUMN_CONTROLS_DECORATIONS",
213
230
  COLUMN_SELECTED = "COLUMN_SELECTED",
214
231
  COLUMN_RESIZING_HANDLE = "COLUMN_RESIZING_HANDLE",
232
+ COLUMN_RESIZING_HANDLE_WIDGET = "COLUMN_RESIZING_HANDLE_WIDGET",
215
233
  COLUMN_RESIZING_HANDLE_LINE = "COLUMN_RESIZING_HANDLE_LINE",
216
234
  LAST_CELL_ELEMENT = "LAST_CELL_ELEMENT"
217
235
  }
@@ -0,0 +1,9 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ type Props = {
4
+ startIndex: number;
5
+ endIndex: number;
6
+ includeTooltip?: boolean;
7
+ };
8
+ export declare const ColumnResizeWidget: React.FC<Props>;
9
+ export {};
@@ -54,5 +54,10 @@ declare const _default: {
54
54
  defaultMessage: string;
55
55
  description: string;
56
56
  };
57
+ adjustColumns: {
58
+ id: string;
59
+ defaultMessage: string;
60
+ description: string;
61
+ };
57
62
  };
58
63
  export default _default;
@@ -1,3 +1,4 @@
1
+ import type { IntlShape } from 'react-intl-next';
1
2
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
3
  import type { ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
@@ -11,7 +12,7 @@ export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row'
11
12
  export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
12
13
  export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
13
14
  export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
14
- export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>) => [
15
+ export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>, includeTooltip: boolean | undefined, getIntl: () => IntlShape) => [
15
16
  Decoration[],
16
17
  Decoration[]
17
18
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.10.8",
3
+ "version": "2.11.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "28.1.2",
31
- "@atlaskit/editor-common": "^74.53.0",
31
+ "@atlaskit/editor-common": "^74.54.0",
32
32
  "@atlaskit/editor-palette": "1.5.1",
33
33
  "@atlaskit/editor-plugin-analytics": "^0.1.0",
34
34
  "@atlaskit/editor-plugin-content-insertion": "^0.0.11",
@@ -215,7 +215,7 @@ describe('table event handlers', () => {
215
215
  );
216
216
  const { state, dispatch } = editorView;
217
217
 
218
- addResizeHandleDecorations(0, 0)(state, dispatch);
218
+ addResizeHandleDecorations(0, 0, false)(state, dispatch);
219
219
 
220
220
  const firstCell = editorView.domAtPos(refs['<>']);
221
221
  const event = {
@@ -46,6 +46,15 @@ jest.mock('../../../plugins/table/utils/analytics', () => ({
46
46
  },
47
47
  }));
48
48
 
49
+ jest.mock('react-intl-next', () => {
50
+ return {
51
+ ...(jest.requireActual('react-intl-next') as any),
52
+ useIntl: jest.fn().mockReturnValue({
53
+ formatMessage: (descriptor: any) => descriptor.defaultMessage,
54
+ }),
55
+ };
56
+ });
57
+
49
58
  describe('table -> nodeviews -> TableContainer.tsx', () => {
50
59
  const createEditor = createEditorFactory<TablePluginState>();
51
60
  const editor = (
@@ -211,11 +220,11 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
211
220
  test('fires when resizing is finished', async () => {
212
221
  const { container, analyticsMock } = buildContainer({ layout: 'wide' });
213
222
 
214
- fireEvent.mouseDown(container.querySelector('.resizer-handle-right')!);
215
- fireEvent.mouseMove(container.querySelector('.resizer-handle-right')!);
216
- fireEvent.mouseMove(container.querySelector('.resizer-handle-right')!);
217
- fireEvent.mouseMove(container.querySelector('.resizer-handle-right')!);
218
- fireEvent.mouseUp(container.querySelector('.resizer-handle-right')!);
223
+ fireEvent.mouseDown(container.querySelector('.resizer-handle.right')!);
224
+ fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
225
+ fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
226
+ fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
227
+ fireEvent.mouseUp(container.querySelector('.resizer-handle.right')!);
219
228
 
220
229
  expect(analyticsMock).toHaveBeenCalledWith({
221
230
  action: TABLE_ACTION.RESIZED,
@@ -261,11 +270,11 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
261
270
  test('calls useMeasureFramerate handlers', async () => {
262
271
  const { container } = buildContainer({ layout: 'wide' });
263
272
 
264
- fireEvent.mouseDown(container.querySelector('.resizer-handle-right')!);
265
- fireEvent.mouseMove(container.querySelector('.resizer-handle-right')!, {
273
+ fireEvent.mouseDown(container.querySelector('.resizer-handle.right')!);
274
+ fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!, {
266
275
  clientX: 100,
267
276
  });
268
- fireEvent.mouseUp(container.querySelector('.resizer-handle-right')!);
277
+ fireEvent.mouseUp(container.querySelector('.resizer-handle.right')!);
269
278
 
270
279
  expect(mockStartMeasure).toHaveBeenCalled();
271
280
  expect(mockEndMeasure).toHaveBeenCalled();
@@ -91,6 +91,8 @@ describe('tables: column resizing decorations', () => {
91
91
  const nextDecorationSet = buildColumnResizingDecorations(
92
92
  rowEndIndex,
93
93
  columnEndIndex,
94
+ false,
95
+ () => ({} as any),
94
96
  )({
95
97
  decorationSet: DecorationSet.empty,
96
98
  tr: state.tr,