@atlaskit/editor-plugin-table 2.1.7 → 2.2.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 (132) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/plugins/table/handlers.js +1 -0
  3. package/dist/cjs/plugins/table/index.js +1 -1
  4. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -2
  5. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +50 -47
  6. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +64 -28
  7. package/dist/cjs/plugins/table/nodeviews/table.js +5 -3
  8. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
  9. package/dist/cjs/plugins/table/pm-plugins/main.js +2 -2
  10. package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +1 -1
  11. package/dist/cjs/plugins/table/ui/consts.js +6 -2
  12. package/dist/cjs/plugins/table/utils/collapse.js +2 -0
  13. package/dist/cjs/plugins/table/utils/decoration.js +2 -0
  14. package/dist/cjs/plugins/table/utils/guidelines.js +12 -0
  15. package/dist/cjs/plugins/table/utils/snapping.js +37 -0
  16. package/dist/cjs/version.json +1 -1
  17. package/dist/es2019/plugins/table/handlers.js +1 -0
  18. package/dist/es2019/plugins/table/index.js +1 -1
  19. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -2
  20. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +25 -23
  21. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +59 -29
  22. package/dist/es2019/plugins/table/nodeviews/table.js +5 -3
  23. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +4 -1
  24. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
  25. package/dist/es2019/plugins/table/pm-plugins/main.js +2 -2
  26. package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
  27. package/dist/es2019/plugins/table/ui/consts.js +3 -1
  28. package/dist/es2019/plugins/table/utils/collapse.js +2 -0
  29. package/dist/es2019/plugins/table/utils/decoration.js +2 -0
  30. package/dist/es2019/plugins/table/utils/guidelines.js +4 -0
  31. package/dist/es2019/plugins/table/utils/snapping.js +27 -0
  32. package/dist/es2019/version.json +1 -1
  33. package/dist/esm/plugins/table/handlers.js +1 -0
  34. package/dist/esm/plugins/table/index.js +1 -1
  35. package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -2
  36. package/dist/esm/plugins/table/nodeviews/TableContainer.js +50 -47
  37. package/dist/esm/plugins/table/nodeviews/TableResizer.js +61 -28
  38. package/dist/esm/plugins/table/nodeviews/table.js +5 -3
  39. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +4 -1
  40. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
  41. package/dist/esm/plugins/table/pm-plugins/main.js +2 -2
  42. package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
  43. package/dist/esm/plugins/table/ui/consts.js +3 -1
  44. package/dist/esm/plugins/table/utils/collapse.js +2 -0
  45. package/dist/esm/plugins/table/utils/decoration.js +2 -0
  46. package/dist/esm/plugins/table/utils/guidelines.js +4 -0
  47. package/dist/esm/plugins/table/utils/snapping.js +30 -0
  48. package/dist/esm/version.json +1 -1
  49. package/dist/types/plugins/table/index.d.ts +3 -1
  50. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +2 -1
  51. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -2
  52. package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +3 -1
  53. package/dist/types/plugins/table/nodeviews/table.d.ts +2 -1
  54. package/dist/types/plugins/table/nodeviews/types.d.ts +2 -0
  55. package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
  56. package/dist/types/plugins/table/types.d.ts +3 -0
  57. package/dist/types/plugins/table/ui/consts.d.ts +2 -0
  58. package/dist/types/plugins/table/utils/guidelines.d.ts +3 -0
  59. package/dist/types/plugins/table/utils/snapping.d.ts +8 -0
  60. package/dist/types-ts4.5/plugins/table/index.d.ts +3 -1
  61. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +2 -1
  62. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -2
  63. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +3 -1
  64. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -1
  65. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +2 -0
  66. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +2 -1
  67. package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
  68. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
  69. package/dist/types-ts4.5/plugins/table/utils/guidelines.d.ts +3 -0
  70. package/dist/types-ts4.5/plugins/table/utils/snapping.d.ts +8 -0
  71. package/package.json +3 -2
  72. package/report.api.md +2 -0
  73. package/src/__tests__/unit/analytics.ts +2 -0
  74. package/src/__tests__/unit/collab.ts +2 -0
  75. package/src/__tests__/unit/commands/go-to-next-cell.ts +2 -0
  76. package/src/__tests__/unit/commands/insert.ts +2 -0
  77. package/src/__tests__/unit/commands/misc.ts +2 -0
  78. package/src/__tests__/unit/commands/sort.ts +4 -0
  79. package/src/__tests__/unit/commands.ts +2 -0
  80. package/src/__tests__/unit/copy-paste.ts +2 -0
  81. package/src/__tests__/unit/event-handlers/index.ts +3 -0
  82. package/src/__tests__/unit/event-handlers.ts +3 -0
  83. package/src/__tests__/unit/fix-tables.ts +2 -0
  84. package/src/__tests__/unit/get-toolbar-config.ts +2 -0
  85. package/src/__tests__/unit/handlers.ts +2 -0
  86. package/src/__tests__/unit/hover-selection.ts +2 -0
  87. package/src/__tests__/unit/index.ts +2 -0
  88. package/src/__tests__/unit/layout.ts +2 -0
  89. package/src/__tests__/unit/nodeviews/cell.ts +2 -0
  90. package/src/__tests__/unit/nodeviews/table.ts +2 -0
  91. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
  92. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +2 -0
  93. package/src/__tests__/unit/pm-plugins/main.ts +2 -0
  94. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -0
  95. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +3 -0
  96. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -0
  97. package/src/__tests__/unit/sort-column.ts +2 -0
  98. package/src/__tests__/unit/toolbar.ts +2 -0
  99. package/src/__tests__/unit/transforms/delete-columns.ts +2 -0
  100. package/src/__tests__/unit/transforms/delete-rows.ts +2 -0
  101. package/src/__tests__/unit/transforms/merging.ts +2 -0
  102. package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
  103. package/src/__tests__/unit/ui/CornerControls.tsx +2 -0
  104. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -0
  105. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +2 -0
  106. package/src/__tests__/unit/ui/RowControls.tsx +2 -0
  107. package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -0
  108. package/src/__tests__/unit/undo-redo.ts +2 -0
  109. package/src/__tests__/unit/utils/collapse.ts +2 -0
  110. package/src/__tests__/unit/utils/nodes.ts +2 -0
  111. package/src/__tests__/unit/utils/row-controls.ts +2 -0
  112. package/src/__tests__/unit/utils.ts +2 -0
  113. package/src/plugins/table/handlers.ts +1 -0
  114. package/src/plugins/table/index.tsx +3 -1
  115. package/src/plugins/table/nodeviews/TableComponent.tsx +4 -0
  116. package/src/plugins/table/nodeviews/TableContainer.tsx +31 -22
  117. package/src/plugins/table/nodeviews/TableResizer.tsx +100 -34
  118. package/src/plugins/table/nodeviews/table.tsx +4 -0
  119. package/src/plugins/table/nodeviews/types.ts +2 -0
  120. package/src/plugins/table/pm-plugins/decorations/plugin.ts +1 -0
  121. package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -0
  122. package/src/plugins/table/pm-plugins/decorations/utils/types.ts +1 -0
  123. package/src/plugins/table/pm-plugins/main.ts +3 -0
  124. package/src/plugins/table/pm-plugins/table-resizing/plugin-factory.ts +1 -0
  125. package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +1 -0
  126. package/src/plugins/table/types.ts +4 -0
  127. package/src/plugins/table/ui/consts.ts +3 -0
  128. package/src/plugins/table/utils/collapse.ts +1 -0
  129. package/src/plugins/table/utils/decoration.ts +1 -0
  130. package/src/plugins/table/utils/guidelines.ts +17 -0
  131. package/src/plugins/table/utils/snapping.ts +38 -0
  132. package/tmp/api-report-tmp.d.ts +3 -1
@@ -1,10 +1,15 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- import React from 'react';
5
+ import React, { useCallback, useRef, useMemo, useState } from 'react';
5
6
  import rafSchd from 'raf-schd';
6
7
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
8
+ import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
7
9
  import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH } from '../pm-plugins/table-resizing/utils';
10
+ import { defaultGuidelines, defaultGuidelineWidths } from '../utils/guidelines';
11
+ import { findClosestSnap } from '../utils/snapping';
12
+ import { TABLE_SNAP_GAP, TABLE_HIGHLIGHT_GAP } from '../ui/consts';
8
13
  var handles = {
9
14
  right: true
10
15
  };
@@ -17,7 +22,8 @@ export var TableResizer = function TableResizer(_ref) {
17
22
  editorView = _ref.editorView,
18
23
  getPos = _ref.getPos,
19
24
  node = _ref.node,
20
- tableRef = _ref.tableRef;
25
+ tableRef = _ref.tableRef,
26
+ displayGuideline = _ref.displayGuideline;
21
27
  var currentColumnCount = getColgroupChildrenLength(node);
22
28
  var minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * COLUMN_MIN_WIDTH : 3 * COLUMN_MIN_WIDTH;
23
29
  var tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
@@ -35,15 +41,60 @@ export var TableResizer = function TableResizer(_ref) {
35
41
  } else if (tableHeight && tableHeight >= 96) {
36
42
  handleHeightSize = 'large';
37
43
  }
44
+ var currentGap = useRef(0);
45
+ var _useState = useState(false),
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ snappingEnabled = _useState2[0],
48
+ setSnappingEnabled = _useState2[1];
49
+ var updateActiveGuidelines = useCallback(function (_ref2) {
50
+ var gap = _ref2.gap,
51
+ keys = _ref2.keys;
52
+ if (gap !== currentGap.current) {
53
+ currentGap.current = gap;
54
+ displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, defaultGuidelines));
55
+ }
56
+ }, [displayGuideline]);
57
+ var guidelineSnaps = useMemo(function () {
58
+ return snappingEnabled ? {
59
+ x: defaultGuidelineWidths
60
+ } : undefined;
61
+ }, [snappingEnabled]);
62
+ var handleResizeStart = useCallback(function () {
63
+ setSnappingEnabled(displayGuideline(defaultGuidelines));
64
+ return width;
65
+ }, [width, displayGuideline]);
66
+ var handleResizeStop = useCallback(function (originalState, delta) {
67
+ var newWidth = originalState.width + delta.width;
68
+ var state = editorView.state,
69
+ dispatch = editorView.dispatch;
70
+ var pos = getPos();
71
+ if (typeof pos !== 'number') {
72
+ return;
73
+ }
74
+ var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
75
+ width: newWidth
76
+ }));
77
+ var newNode = tr.doc.nodeAt(pos);
78
+ tr = scaleTable(tableRef, {
79
+ node: newNode,
80
+ prevNode: node,
81
+ start: pos + 1,
82
+ parentWidth: newWidth
83
+ }, editorView.domAtPos.bind(editorView))(tr);
84
+ dispatch(tr);
85
+
86
+ // Hide guidelines when resizing stops
87
+ displayGuideline([]);
88
+ updateWidth(newWidth);
89
+ return newWidth;
90
+ }, [updateWidth, editorView, getPos, node, tableRef, displayGuideline]);
38
91
  return /*#__PURE__*/React.createElement(ResizerNext, {
39
92
  enable: handles,
40
93
  width: width,
41
94
  handleAlignmentMethod: "sticky",
42
95
  handleHeightSize: handleHeightSize,
43
96
  handleMarginTop: tableHandleMarginTop,
44
- handleResizeStart: function handleResizeStart() {
45
- return width;
46
- },
97
+ handleResizeStart: handleResizeStart,
47
98
  handleResize: rafSchd(function (originalState, delta) {
48
99
  var newWidth = originalState.width + delta.width;
49
100
  var pos = getPos();
@@ -56,33 +107,15 @@ export var TableResizer = function TableResizer(_ref) {
56
107
  start: pos + 1,
57
108
  parentWidth: newWidth
58
109
  }, editorView.domAtPos.bind(editorView));
110
+ updateActiveGuidelines(findClosestSnap(newWidth, defaultGuidelineWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP));
59
111
  updateWidth(newWidth);
60
112
  return newWidth;
61
113
  }),
62
- handleResizeStop: function handleResizeStop(originalState, delta) {
63
- var newWidth = originalState.width + delta.width;
64
- var state = editorView.state,
65
- dispatch = editorView.dispatch;
66
- var pos = getPos();
67
- if (typeof pos !== 'number') {
68
- return;
69
- }
70
- var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
71
- width: newWidth
72
- }));
73
- var newNode = tr.doc.nodeAt(pos);
74
- tr = scaleTable(tableRef, {
75
- node: newNode,
76
- prevNode: node,
77
- start: pos + 1,
78
- parentWidth: newWidth
79
- }, editorView.domAtPos.bind(editorView))(tr);
80
- dispatch(tr);
81
- updateWidth(newWidth);
82
- return newWidth;
83
- },
114
+ handleResizeStop: handleResizeStop,
84
115
  resizeRatio: 2,
85
116
  minWidth: minColumnWidth,
86
- maxWidth: maxWidth
117
+ maxWidth: maxWidth,
118
+ snapGap: TABLE_SNAP_GAP,
119
+ snap: guidelineSnaps
87
120
  }, children);
88
121
  };
@@ -133,7 +133,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
133
133
  getNode: _this3.getNode,
134
134
  containerWidth: containerWidth,
135
135
  contentDOM: forwardRef,
136
- getEditorFeatureFlags: props.getEditorFeatureFlags
136
+ getEditorFeatureFlags: props.getEditorFeatureFlags,
137
+ pluginInjectionApi: props.pluginInjectionApi
137
138
  });
138
139
  }
139
140
  });
@@ -202,7 +203,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
202
203
  return TableView;
203
204
  }(ReactNodeView);
204
205
  export { TableView as default };
205
- export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags) {
206
+ export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) {
206
207
  var _getPluginState2 = getPluginState(view.state),
207
208
  pluginConfig = _getPluginState2.pluginConfig;
208
209
  var _getPluginConfig = getPluginConfig(pluginConfig),
@@ -221,6 +222,7 @@ export var createTableView = function createTableView(node, view, getPos, portal
221
222
  tableRenderOptimization: tableRenderOptimization,
222
223
  getEditorContainerWidth: getEditorContainerWidth,
223
224
  getEditorFeatureFlags: getEditorFeatureFlags,
224
- hasIntlContext: hasIntlContext
225
+ hasIntlContext: hasIntlContext,
226
+ pluginInjectionApi: pluginInjectionApi
225
227
  }).init();
226
228
  };
@@ -1,5 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from 'prosemirror-state';
2
+ import { PluginKey
3
+
4
+ // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
5
+ } from 'prosemirror-state';
3
6
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
7
  import { DecorationSet } from 'prosemirror-view';
5
8
  import { pluginKey as tablePluginKey } from '../plugin-key';
@@ -1,3 +1,5 @@
1
+ // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
2
+
1
3
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
2
4
  import { findTable } from '@atlaskit/editor-tables/utils';
3
5
  import { TableDecorations } from '../../../types';
@@ -27,7 +27,7 @@ import { isHeaderRowRequired } from '../utils/paste';
27
27
  var isBreakoutEnabled;
28
28
  var isFullWidthModeEnabled;
29
29
  var wasFullWidthModeEnabled;
30
- export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI) {
30
+ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
31
31
  var _window;
32
32
  isBreakoutEnabled = breakoutEnabled;
33
33
  isFullWidthModeEnabled = fullWidthModeEnabled;
@@ -232,7 +232,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
232
232
  isBreakoutEnabled: isBreakoutEnabled,
233
233
  isFullWidthModeEnabled: isFullWidthModeEnabled,
234
234
  wasFullWidthModeEnabled: wasFullWidthModeEnabled
235
- }, getEditorContainerWidth, getEditorFeatureFlags);
235
+ }, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
236
236
  }
237
237
  }),
238
238
  handleDOMEvents: {
@@ -1,6 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
5
+
4
6
  import { pluginFactory } from '@atlaskit/editor-common/utils';
5
7
  import { pluginKey } from './plugin-key';
6
8
  import reducer from './reducer';
@@ -62,4 +62,6 @@ export var contextualMenuTriggerSize = 16;
62
62
  export var contextualMenuDropdownWidth = 180;
63
63
  export var stickyRowZIndex = resizeHandlerZIndex + 2;
64
64
  export var stickyRowOffsetTop = 8;
65
- export var stickyHeaderBorderBottomWidth = 1;
65
+ export var stickyHeaderBorderBottomWidth = 1;
66
+ export var TABLE_SNAP_GAP = 5;
67
+ export var TABLE_HIGHLIGHT_GAP = 10;
@@ -1,4 +1,6 @@
1
1
  import { NodeRange } from 'prosemirror-model';
2
+ // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
3
+
2
4
  import { findWrapping } from 'prosemirror-transform';
3
5
  import { findTable } from '@atlaskit/editor-tables/utils';
4
6
  var bail = function bail() {
@@ -1,4 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
3
+
2
4
  import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
3
5
  import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
4
6
  import { Decoration } from 'prosemirror-view';
@@ -0,0 +1,4 @@
1
+ import { createFixedGuidelinesFromLengths } from '@atlaskit/editor-common/guideline';
2
+ import { akEditorDefaultLayoutWidth, akEditorWideLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
3
+ export var defaultGuidelineWidths = [akEditorDefaultLayoutWidth, akEditorWideLayoutWidth, akEditorFullWidthLayoutWidth];
4
+ export var defaultGuidelines = createFixedGuidelinesFromLengths(defaultGuidelineWidths);
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Returns keys of guidelines that are closest to the table and withthin the snapGap
3
+ */
4
+ export var findClosestSnap = function findClosestSnap(currentWidth, snapWidths, guidelines) {
5
+ var snapGap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
6
+ var closestGapIndex = snapWidths.reduce(function (prev, curr, index) {
7
+ return Math.abs(curr - currentWidth) < Math.abs(snapWidths[prev] - currentWidth) ? index : prev;
8
+ }, 0);
9
+ var gap = Math.abs(snapWidths[closestGapIndex] - currentWidth);
10
+ if (gap < snapGap) {
11
+ var snappingWidth = Math.round(snapWidths[closestGapIndex]);
12
+ var guidelineKeys = guidelines.reduce(function (acc, guideline) {
13
+ // NOTE: The snap points are based on the guidelines, however their formatted as a length value whereas the guidelines
14
+ // are point based. The point base x coords are calculated by halving the lengths. This means we can convert the
15
+ // point base position to length by simply multiplying by 2.
16
+ if (Math.round(Math.abs(guideline.position.x) * 2) === snappingWidth) {
17
+ acc.push(guideline.key);
18
+ }
19
+ return acc;
20
+ }, []);
21
+ return {
22
+ gap: gap,
23
+ keys: guidelineKeys
24
+ };
25
+ }
26
+ return {
27
+ gap: gap,
28
+ keys: []
29
+ };
30
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.1.7",
3
+ "version": "2.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -6,6 +6,7 @@ import type { GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-c
6
6
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
7
  import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
8
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
9
+ import type { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
9
10
  interface TablePluginOptions {
10
11
  tableOptions: PluginConfig;
11
12
  breakoutEnabled?: boolean;
@@ -24,7 +25,8 @@ declare const tablesPlugin: NextEditorPlugin<'table', {
24
25
  dependencies: [
25
26
  typeof analyticsPlugin,
26
27
  typeof contentInsertionPlugin,
27
- typeof widthPlugin
28
+ typeof widthPlugin,
29
+ typeof guidelinePlugin
28
30
  ];
29
31
  }>;
30
32
  export default tablesPlugin;
@@ -4,7 +4,7 @@ import { EditorView } from 'prosemirror-view';
4
4
  import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  import { RowStickyState, StickyPluginState } from '../pm-plugins/sticky-headers';
6
6
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
- import { ColumnResizingPluginState, ShadowEvent } from '../types';
7
+ import { ColumnResizingPluginState, ShadowEvent, PluginInjectionAPI } from '../types';
8
8
  import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
9
9
  import type { TableOptions } from './types';
10
10
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
@@ -25,6 +25,7 @@ export interface ComponentProps {
25
25
  ordering: TableColumnOrdering;
26
26
  tableResizingPluginState?: ColumnResizingPluginState;
27
27
  getEditorFeatureFlags: GetEditorFeatureFlags;
28
+ pluginInjectionApi?: PluginInjectionAPI;
28
29
  }
29
30
  interface TableState {
30
31
  scroll: number;
@@ -2,6 +2,7 @@ import React, { PropsWithChildren } from 'react';
2
2
  import { Node as PMNode } from 'prosemirror-model';
3
3
  import { EditorView } from 'prosemirror-view';
4
4
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
+ import { PluginInjectionAPI } from '../types';
5
6
  type InnerContainerProps = {
6
7
  className: string;
7
8
  style?: {
@@ -21,8 +22,9 @@ type ResizableTableContainerProps = {
21
22
  editorView: EditorView;
22
23
  getPos: () => number | undefined;
23
24
  tableRef: HTMLTableElement;
25
+ pluginInjectionApi?: PluginInjectionAPI;
24
26
  };
25
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
27
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
26
28
  type TableContainerProps = {
27
29
  node: PMNode;
28
30
  className: string;
@@ -33,6 +35,7 @@ type TableContainerProps = {
33
35
  getPos: () => number | undefined;
34
36
  tableRef: HTMLTableElement;
35
37
  isNested: boolean;
38
+ pluginInjectionApi?: PluginInjectionAPI;
36
39
  };
37
- export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isFullWidthModeEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
40
+ export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isFullWidthModeEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
38
41
  export {};
@@ -1,6 +1,7 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { EditorView } from 'prosemirror-view';
3
3
  import { Node as PMNode } from 'prosemirror-model';
4
+ import type { GuidelineConfig } from '@atlaskit/editor-plugin-guideline';
4
5
  interface TableResizerProps {
5
6
  width: number;
6
7
  maxWidth: number;
@@ -9,6 +10,7 @@ interface TableResizerProps {
9
10
  getPos: () => number | undefined;
10
11
  node: PMNode;
11
12
  tableRef: HTMLTableElement;
13
+ displayGuideline: (guideline: GuidelineConfig[]) => boolean;
12
14
  }
13
- export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
15
+ export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, displayGuideline, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
14
16
  export {};
@@ -7,6 +7,7 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
7
7
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
8
8
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
9
9
  import { Props, TableOptions } from './types';
10
+ import { PluginInjectionAPI } from '../types';
10
11
  type ForwardRef = (node: HTMLElement | null) => void;
11
12
  export default class TableView extends ReactNodeView<Props> {
12
13
  private table;
@@ -30,5 +31,5 @@ export default class TableView extends ReactNodeView<Props> {
30
31
  }): boolean;
31
32
  destroy(): void;
32
33
  }
33
- export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, options: TableOptions, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags) => NodeView;
34
+ export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, options: TableOptions, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
34
35
  export {};
@@ -3,6 +3,7 @@ import { EditorView } from 'prosemirror-view';
3
3
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
4
4
  import { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
6
+ import type { PluginInjectionAPI } from '../types';
6
7
  export type TableOptions = {
7
8
  isBreakoutEnabled?: boolean;
8
9
  isFullWidthModeEnabled?: boolean;
@@ -21,4 +22,5 @@ export interface Props {
21
22
  getEditorContainerWidth: GetEditorContainerWidth;
22
23
  getEditorFeatureFlags: GetEditorFeatureFlags;
23
24
  hasIntlContext: boolean;
25
+ pluginInjectionApi?: PluginInjectionAPI;
24
26
  }
@@ -5,4 +5,5 @@ import { PluginConfig } from '../types';
5
5
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
6
6
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
7
7
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
8
- export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI) => SafePlugin<import("../types").TablePluginState>;
8
+ import type { PluginInjectionAPI } from '../types';
9
+ export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
@@ -6,6 +6,8 @@ import { IntlShape } from 'react-intl-next';
6
6
  import { TableLayout } from '@atlaskit/adf-schema';
7
7
  import { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
8
8
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
9
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
10
+ import type tablePlugin from './index';
9
11
  export declare const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
10
12
  export type RowInsertPosition = 'TOP' | 'BOTTOM';
11
13
  export type PermittedLayoutsDescriptor = TableLayout[] | 'all';
@@ -19,6 +21,7 @@ export interface InsertRowOptions {
19
21
  index: number;
20
22
  moveCursorToInsertedRow: boolean;
21
23
  }
24
+ export type PluginInjectionAPI = ExtractInjectionAPI<typeof tablePlugin>;
22
25
  export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB;
23
26
  export interface PluginConfig {
24
27
  advanced?: boolean;
@@ -38,3 +38,5 @@ export declare const contextualMenuDropdownWidth = 180;
38
38
  export declare const stickyRowZIndex: number;
39
39
  export declare const stickyRowOffsetTop = 8;
40
40
  export declare const stickyHeaderBorderBottomWidth = 1;
41
+ export declare const TABLE_SNAP_GAP = 5;
42
+ export declare const TABLE_HIGHLIGHT_GAP = 10;
@@ -0,0 +1,3 @@
1
+ import type { GuidelineConfig } from '@atlaskit/editor-plugin-guideline';
2
+ export declare const defaultGuidelineWidths: number[];
3
+ export declare const defaultGuidelines: GuidelineConfig[];
@@ -0,0 +1,8 @@
1
+ import type { GuidelineConfig } from '@atlaskit/editor-plugin-guideline';
2
+ /**
3
+ * Returns keys of guidelines that are closest to the table and withthin the snapGap
4
+ */
5
+ export declare const findClosestSnap: (currentWidth: number, snapWidths: number[], guidelines: GuidelineConfig[], snapGap?: number) => {
6
+ gap: number;
7
+ keys: string[];
8
+ };
@@ -6,6 +6,7 @@ import type { GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-c
6
6
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
7
  import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
8
8
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
9
+ import type { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
9
10
  interface TablePluginOptions {
10
11
  tableOptions: PluginConfig;
11
12
  breakoutEnabled?: boolean;
@@ -24,7 +25,8 @@ declare const tablesPlugin: NextEditorPlugin<'table', {
24
25
  dependencies: [
25
26
  typeof analyticsPlugin,
26
27
  typeof contentInsertionPlugin,
27
- typeof widthPlugin
28
+ typeof widthPlugin,
29
+ typeof guidelinePlugin
28
30
  ];
29
31
  }>;
30
32
  export default tablesPlugin;
@@ -4,7 +4,7 @@ import { EditorView } from 'prosemirror-view';
4
4
  import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  import { RowStickyState, StickyPluginState } from '../pm-plugins/sticky-headers';
6
6
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
- import { ColumnResizingPluginState, ShadowEvent } from '../types';
7
+ import { ColumnResizingPluginState, ShadowEvent, PluginInjectionAPI } from '../types';
8
8
  import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
9
9
  import type { TableOptions } from './types';
10
10
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
@@ -25,6 +25,7 @@ export interface ComponentProps {
25
25
  ordering: TableColumnOrdering;
26
26
  tableResizingPluginState?: ColumnResizingPluginState;
27
27
  getEditorFeatureFlags: GetEditorFeatureFlags;
28
+ pluginInjectionApi?: PluginInjectionAPI;
28
29
  }
29
30
  interface TableState {
30
31
  scroll: number;
@@ -2,6 +2,7 @@ import React, { PropsWithChildren } from 'react';
2
2
  import { Node as PMNode } from 'prosemirror-model';
3
3
  import { EditorView } from 'prosemirror-view';
4
4
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
+ import { PluginInjectionAPI } from '../types';
5
6
  type InnerContainerProps = {
6
7
  className: string;
7
8
  style?: {
@@ -21,8 +22,9 @@ type ResizableTableContainerProps = {
21
22
  editorView: EditorView;
22
23
  getPos: () => number | undefined;
23
24
  tableRef: HTMLTableElement;
25
+ pluginInjectionApi?: PluginInjectionAPI;
24
26
  };
25
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
27
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
26
28
  type TableContainerProps = {
27
29
  node: PMNode;
28
30
  className: string;
@@ -33,6 +35,7 @@ type TableContainerProps = {
33
35
  getPos: () => number | undefined;
34
36
  tableRef: HTMLTableElement;
35
37
  isNested: boolean;
38
+ pluginInjectionApi?: PluginInjectionAPI;
36
39
  };
37
- export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isFullWidthModeEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
40
+ export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isFullWidthModeEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
38
41
  export {};
@@ -1,6 +1,7 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { EditorView } from 'prosemirror-view';
3
3
  import { Node as PMNode } from 'prosemirror-model';
4
+ import type { GuidelineConfig } from '@atlaskit/editor-plugin-guideline';
4
5
  interface TableResizerProps {
5
6
  width: number;
6
7
  maxWidth: number;
@@ -9,6 +10,7 @@ interface TableResizerProps {
9
10
  getPos: () => number | undefined;
10
11
  node: PMNode;
11
12
  tableRef: HTMLTableElement;
13
+ displayGuideline: (guideline: GuidelineConfig[]) => boolean;
12
14
  }
13
- export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
15
+ export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, displayGuideline, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
14
16
  export {};
@@ -7,6 +7,7 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
7
7
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
8
8
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
9
9
  import { Props, TableOptions } from './types';
10
+ import { PluginInjectionAPI } from '../types';
10
11
  type ForwardRef = (node: HTMLElement | null) => void;
11
12
  export default class TableView extends ReactNodeView<Props> {
12
13
  private table;
@@ -30,5 +31,5 @@ export default class TableView extends ReactNodeView<Props> {
30
31
  }): boolean;
31
32
  destroy(): void;
32
33
  }
33
- export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, options: TableOptions, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags) => NodeView;
34
+ export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, options: TableOptions, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
34
35
  export {};
@@ -3,6 +3,7 @@ import { EditorView } from 'prosemirror-view';
3
3
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
4
4
  import { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
6
+ import type { PluginInjectionAPI } from '../types';
6
7
  export type TableOptions = {
7
8
  isBreakoutEnabled?: boolean;
8
9
  isFullWidthModeEnabled?: boolean;
@@ -21,4 +22,5 @@ export interface Props {
21
22
  getEditorContainerWidth: GetEditorContainerWidth;
22
23
  getEditorFeatureFlags: GetEditorFeatureFlags;
23
24
  hasIntlContext: boolean;
25
+ pluginInjectionApi?: PluginInjectionAPI;
24
26
  }
@@ -5,4 +5,5 @@ import { PluginConfig } from '../types';
5
5
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
6
6
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
7
7
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
8
- export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI) => SafePlugin<import("../types").TablePluginState>;
8
+ import type { PluginInjectionAPI } from '../types';
9
+ export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
@@ -6,6 +6,8 @@ import { IntlShape } from 'react-intl-next';
6
6
  import { TableLayout } from '@atlaskit/adf-schema';
7
7
  import { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
8
8
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
9
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
10
+ import type tablePlugin from './index';
9
11
  export declare const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
10
12
  export type RowInsertPosition = 'TOP' | 'BOTTOM';
11
13
  export type PermittedLayoutsDescriptor = TableLayout[] | 'all';
@@ -19,6 +21,7 @@ export interface InsertRowOptions {
19
21
  index: number;
20
22
  moveCursorToInsertedRow: boolean;
21
23
  }
24
+ export type PluginInjectionAPI = ExtractInjectionAPI<typeof tablePlugin>;
22
25
  export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB;
23
26
  export interface PluginConfig {
24
27
  advanced?: boolean;
@@ -38,3 +38,5 @@ export declare const contextualMenuDropdownWidth = 180;
38
38
  export declare const stickyRowZIndex: number;
39
39
  export declare const stickyRowOffsetTop = 8;
40
40
  export declare const stickyHeaderBorderBottomWidth = 1;
41
+ export declare const TABLE_SNAP_GAP = 5;
42
+ export declare const TABLE_HIGHLIGHT_GAP = 10;
@@ -0,0 +1,3 @@
1
+ import type { GuidelineConfig } from '@atlaskit/editor-plugin-guideline';
2
+ export declare const defaultGuidelineWidths: number[];
3
+ export declare const defaultGuidelines: GuidelineConfig[];
@@ -0,0 +1,8 @@
1
+ import type { GuidelineConfig } from '@atlaskit/editor-plugin-guideline';
2
+ /**
3
+ * Returns keys of guidelines that are closest to the table and withthin the snapGap
4
+ */
5
+ export declare const findClosestSnap: (currentWidth: number, snapWidths: number[], guidelines: GuidelineConfig[], snapGap?: number) => {
6
+ gap: number;
7
+ keys: string[];
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.1.7",
3
+ "version": "2.2.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": "^26.2.0",
31
- "@atlaskit/editor-common": "^74.21.0",
31
+ "@atlaskit/editor-common": "^74.22.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.6",
@@ -64,6 +64,7 @@
64
64
  "@atlaskit/editor-plugin-decorations": "^0.1.0",
65
65
  "@atlaskit/editor-plugin-feature-flags": "^0.1.0",
66
66
  "@atlaskit/editor-plugin-grid": "^0.1.0",
67
+ "@atlaskit/editor-plugin-guideline": "^0.3.4",
67
68
  "@atlaskit/editor-plugin-hyperlink": "^0.1.0",
68
69
  "@atlaskit/editor-plugin-width": "^0.1.0",
69
70
  "@atlaskit/editor-test-helpers": "^18.10.0",