@atlaskit/editor-plugin-table 5.3.0 → 5.3.2

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 (186) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/table/commands/hover.js +17 -8
  3. package/dist/cjs/plugins/table/commands/index.js +6 -0
  4. package/dist/cjs/plugins/table/commands/misc.js +1 -7
  5. package/dist/cjs/plugins/table/event-handlers.js +29 -2
  6. package/dist/cjs/plugins/table/index.js +1 -1
  7. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -3
  8. package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
  9. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +7 -3
  10. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
  11. package/dist/cjs/plugins/table/pm-plugins/default-table-selection.js +14 -1
  12. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +36 -7
  13. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +69 -7
  14. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +2 -0
  15. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/utils/index.js +12 -0
  16. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +59 -0
  17. package/dist/cjs/plugins/table/pm-plugins/main.js +5 -5
  18. package/dist/cjs/plugins/table/reducer.js +2 -1
  19. package/dist/cjs/plugins/table/types.js +14 -1
  20. package/dist/cjs/plugins/table/ui/DragHandle/index.js +50 -0
  21. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +53 -14
  22. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +114 -0
  23. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +53 -0
  24. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +11 -106
  25. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +16 -6
  26. package/dist/cjs/plugins/table/ui/common-styles.js +9 -6
  27. package/dist/cjs/plugins/table/ui/consts.js +3 -1
  28. package/dist/cjs/plugins/table/ui/ui-styles.js +21 -9
  29. package/dist/cjs/plugins/table/utils/decoration.js +111 -19
  30. package/dist/cjs/plugins/table/utils/dom.js +7 -1
  31. package/dist/cjs/plugins/table/utils/index.js +38 -1
  32. package/dist/cjs/plugins/table/utils/merged-cells.js +66 -0
  33. package/dist/es2019/plugins/table/commands/hover.js +12 -8
  34. package/dist/es2019/plugins/table/commands/index.js +1 -1
  35. package/dist/es2019/plugins/table/commands/misc.js +1 -7
  36. package/dist/es2019/plugins/table/event-handlers.js +28 -2
  37. package/dist/es2019/plugins/table/index.js +1 -1
  38. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -3
  39. package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
  40. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +8 -6
  41. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
  42. package/dist/es2019/plugins/table/pm-plugins/default-table-selection.js +13 -0
  43. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +35 -7
  44. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +69 -4
  45. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +2 -0
  46. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/utils/index.js +1 -0
  47. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +56 -0
  48. package/dist/es2019/plugins/table/pm-plugins/main.js +6 -5
  49. package/dist/es2019/plugins/table/reducer.js +2 -1
  50. package/dist/es2019/plugins/table/types.js +14 -1
  51. package/dist/es2019/plugins/table/ui/DragHandle/index.js +41 -0
  52. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -10
  53. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +86 -0
  54. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +43 -0
  55. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -88
  56. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +17 -7
  57. package/dist/es2019/plugins/table/ui/common-styles.js +49 -13
  58. package/dist/es2019/plugins/table/ui/consts.js +2 -0
  59. package/dist/es2019/plugins/table/ui/ui-styles.js +171 -15
  60. package/dist/es2019/plugins/table/utils/decoration.js +106 -18
  61. package/dist/es2019/plugins/table/utils/dom.js +2 -0
  62. package/dist/es2019/plugins/table/utils/index.js +4 -3
  63. package/dist/es2019/plugins/table/utils/merged-cells.js +48 -0
  64. package/dist/esm/plugins/table/commands/hover.js +16 -8
  65. package/dist/esm/plugins/table/commands/index.js +1 -1
  66. package/dist/esm/plugins/table/commands/misc.js +1 -7
  67. package/dist/esm/plugins/table/event-handlers.js +29 -2
  68. package/dist/esm/plugins/table/index.js +1 -1
  69. package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -3
  70. package/dist/esm/plugins/table/nodeviews/table.js +4 -2
  71. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +8 -6
  72. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
  73. package/dist/esm/plugins/table/pm-plugins/default-table-selection.js +13 -0
  74. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +36 -7
  75. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +65 -4
  76. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +2 -0
  77. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/utils/index.js +1 -0
  78. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +53 -0
  79. package/dist/esm/plugins/table/pm-plugins/main.js +7 -7
  80. package/dist/esm/plugins/table/reducer.js +2 -1
  81. package/dist/esm/plugins/table/types.js +14 -1
  82. package/dist/esm/plugins/table/ui/DragHandle/index.js +41 -0
  83. package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -15
  84. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +104 -0
  85. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +46 -0
  86. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -104
  87. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +17 -7
  88. package/dist/esm/plugins/table/ui/common-styles.js +11 -8
  89. package/dist/esm/plugins/table/ui/consts.js +2 -0
  90. package/dist/esm/plugins/table/ui/ui-styles.js +21 -9
  91. package/dist/esm/plugins/table/utils/decoration.js +110 -18
  92. package/dist/esm/plugins/table/utils/dom.js +6 -0
  93. package/dist/esm/plugins/table/utils/index.js +4 -3
  94. package/dist/esm/plugins/table/utils/merged-cells.js +60 -0
  95. package/dist/types/plugins/table/commands/hover.d.ts +2 -1
  96. package/dist/types/plugins/table/commands/index.d.ts +1 -1
  97. package/dist/types/plugins/table/event-handlers.d.ts +1 -0
  98. package/dist/types/plugins/table/nodeviews/types.d.ts +4 -3
  99. package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
  100. package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
  101. package/dist/types/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
  102. package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +5 -1
  103. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +6 -1
  104. package/dist/types/plugins/table/pm-plugins/drag-and-drop/utils/index.d.ts +1 -0
  105. package/dist/types/plugins/table/pm-plugins/drag-and-drop/utils/monitor.d.ts +3 -0
  106. package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
  107. package/dist/types/plugins/table/types.d.ts +35 -2
  108. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +11 -0
  109. package/dist/types/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
  110. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
  111. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
  112. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
  113. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
  114. package/dist/types/plugins/table/ui/consts.d.ts +2 -0
  115. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
  116. package/dist/types/plugins/table/utils/decoration.d.ts +4 -2
  117. package/dist/types/plugins/table/utils/dom.d.ts +2 -0
  118. package/dist/types/plugins/table/utils/index.d.ts +3 -2
  119. package/dist/types/plugins/table/utils/merged-cells.d.ts +3 -0
  120. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
  121. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
  122. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -0
  123. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +4 -3
  124. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
  125. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
  126. package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
  127. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +5 -1
  128. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +6 -1
  129. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/utils/index.d.ts +1 -0
  130. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/utils/monitor.d.ts +3 -0
  131. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
  132. package/dist/types-ts4.5/plugins/table/types.d.ts +35 -2
  133. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +11 -0
  134. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
  135. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
  136. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
  137. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
  138. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
  139. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
  140. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
  141. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +4 -2
  142. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +2 -0
  143. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +3 -2
  144. package/dist/types-ts4.5/plugins/table/utils/merged-cells.d.ts +3 -0
  145. package/package.json +6 -2
  146. package/src/__tests__/unit/event-handlers.ts +74 -1
  147. package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +35 -15
  148. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +146 -42
  149. package/src/__tests__/unit/ui/NumberColumn.tsx +148 -0
  150. package/src/__tests__/unit/ui/RowControls.tsx +4 -4
  151. package/src/__tests__/unit/ui/RowDragControls.tsx +118 -0
  152. package/src/__tests__/unit/ui/TableFloatingControls.tsx +9 -5
  153. package/src/plugins/table/commands/hover.ts +16 -7
  154. package/src/plugins/table/commands/index.ts +1 -0
  155. package/src/plugins/table/commands/misc.ts +0 -5
  156. package/src/plugins/table/event-handlers.ts +49 -2
  157. package/src/plugins/table/index.tsx +1 -1
  158. package/src/plugins/table/nodeviews/TableComponent.tsx +3 -2
  159. package/src/plugins/table/nodeviews/table.tsx +2 -0
  160. package/src/plugins/table/nodeviews/types.ts +4 -3
  161. package/src/plugins/table/pm-plugins/decorations/plugin.ts +13 -4
  162. package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +10 -5
  163. package/src/plugins/table/pm-plugins/default-table-selection.ts +10 -0
  164. package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +6 -1
  165. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +58 -8
  166. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +77 -4
  167. package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +2 -0
  168. package/src/plugins/table/pm-plugins/drag-and-drop/utils/index.ts +1 -0
  169. package/src/plugins/table/pm-plugins/drag-and-drop/utils/monitor.ts +72 -0
  170. package/src/plugins/table/pm-plugins/main.ts +9 -4
  171. package/src/plugins/table/reducer.ts +2 -1
  172. package/src/plugins/table/types.ts +37 -3
  173. package/src/plugins/table/ui/DragHandle/index.tsx +57 -0
  174. package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +68 -30
  175. package/src/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.tsx +129 -0
  176. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +75 -0
  177. package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +2 -135
  178. package/src/plugins/table/ui/TableFloatingControls/index.tsx +43 -24
  179. package/src/plugins/table/ui/common-styles.ts +54 -11
  180. package/src/plugins/table/ui/consts.ts +2 -0
  181. package/src/plugins/table/ui/ui-styles.ts +173 -14
  182. package/src/plugins/table/utils/decoration.ts +176 -27
  183. package/src/plugins/table/utils/dom.ts +8 -0
  184. package/src/plugins/table/utils/index.ts +5 -0
  185. package/src/plugins/table/utils/merged-cells.ts +67 -0
  186. package/tsconfig.app.json +3 -0
@@ -48,10 +48,13 @@ var TableDecorations = exports.TableDecorations = /*#__PURE__*/function (TableDe
48
48
  TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
49
49
  TableDecorations["COLUMN_RESIZING_HANDLE_WIDGET"] = "COLUMN_RESIZING_HANDLE_WIDGET";
50
50
  TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
51
+ TableDecorations["COLUMN_INSERT_LINE"] = "COLUMN_INSERT_LINE";
52
+ TableDecorations["ROW_INSERT_LINE"] = "ROW_INSERT_LINE";
51
53
  TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
52
54
  return TableDecorations;
53
55
  }({});
54
56
  var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread({}, _styles.TableSharedCssClassName), {}, {
57
+ /** Classic controls */
55
58
  COLUMN_CONTROLS: "".concat(_adfSchema.tablePrefixSelector, "-column-controls"),
56
59
  COLUMN_CONTROLS_DECORATIONS: "".concat(_adfSchema.tablePrefixSelector, "-column-controls-decoration"),
57
60
  COLUMN_SELECTED: "".concat(_adfSchema.tablePrefixSelector, "-column__selected"),
@@ -82,8 +85,13 @@ var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread(
82
85
  CORNER_CONTROLS_INSERT_ROW_MARKER: "".concat(_adfSchema.tablePrefixSelector, "-corner-controls__insert-row-marker"),
83
86
  CORNER_CONTROLS_INSERT_COLUMN_MARKER: "".concat(_adfSchema.tablePrefixSelector, "-corner-controls__insert-column-marker"),
84
87
  CONTROLS_CORNER_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-corner-button"),
88
+ /** Controls with drag handle */
89
+ COLUMN_CONTROLS_DECORATIONS_WITH_DRAG: "".concat(_adfSchema.tablePrefixSelector, "-column-controls-decoration-with-drag"),
90
+ ROW_CONTROLS_WITH_DRAG: "".concat(_adfSchema.tablePrefixSelector, "-row-controls-with-drag"),
91
+ /** Other classes */
85
92
  NUMBERED_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-numbered-column"),
86
93
  NUMBERED_COLUMN_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-numbered-column__button"),
94
+ NUMBERED_COLUMN_BUTTON_DISABLED: "".concat(_adfSchema.tablePrefixSelector, "-numbered-column__button-disabled"),
87
95
  HOVERED_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-hovered-column"),
88
96
  HOVERED_ROW: "".concat(_adfSchema.tablePrefixSelector, "-hovered-row"),
89
97
  HOVERED_TABLE: "".concat(_adfSchema.tablePrefixSelector, "-hovered-table"),
@@ -114,8 +122,13 @@ var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread(
114
122
  TABLE_STICKY: "".concat(_adfSchema.tablePrefixSelector, "-sticky"),
115
123
  TOP_LEFT_CELL: 'table > tbody > tr:nth-child(2) > td:nth-child(1)',
116
124
  LAST_ITEM_IN_CELL: "".concat(_adfSchema.tablePrefixSelector, "-last-item-in-cell"),
125
+ WITH_COLUMN_INSERT_LINE: "".concat(_adfSchema.tablePrefixSelector, "-column-insert-line"),
126
+ WITH_FIRST_COLUMN_INSERT_LINE: "".concat(_adfSchema.tablePrefixSelector, "-first-column-insert-line"),
127
+ WITH_LAST_COLUMN_INSERT_LINE: "".concat(_adfSchema.tablePrefixSelector, "-last-column-insert-line"),
117
128
  WITH_RESIZE_LINE: "".concat(_adfSchema.tablePrefixSelector, "-column-resize-line"),
118
- WITH_RESIZE_LINE_LAST_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-column-resize-line-last-column")
129
+ WITH_RESIZE_LINE_LAST_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-column-resize-line-last-column"),
130
+ WITH_ROW_INSERT_LINE: "".concat(_adfSchema.tablePrefixSelector, "-row-insert-line"),
131
+ WITH_LAST_ROW_INSERT_LINE: "".concat(_adfSchema.tablePrefixSelector, "-last-row-insert-line")
119
132
  });
120
133
  var ShadowEvent = exports.ShadowEvent = /*#__PURE__*/function (ShadowEvent) {
121
134
  ShadowEvent["SHOW_BEFORE_SHADOW"] = "showBeforeShadow";
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DragHandle = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _dragHandleButton = require("@atlaskit/pragmatic-drag-and-drop-react-accessibility/drag-handle-button");
10
+ var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ // TODO: use for now, in future replace with custom @atlaskit/icon/glyph/drag-handler
14
+ // width is too large (24px), should be 16px
15
+ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
16
+ var tableLocalId = _ref.tableLocalId,
17
+ _ref$direction = _ref.direction,
18
+ direction = _ref$direction === void 0 ? 'row' : _ref$direction,
19
+ indexes = _ref.indexes,
20
+ onClick = _ref.onClick,
21
+ onMouseOver = _ref.onMouseOver,
22
+ onMouseOut = _ref.onMouseOut;
23
+ var dragHandleDivRef = (0, _react.useRef)(null);
24
+ (0, _react.useEffect)(function () {
25
+ var dragHandleDivRefCurrent = dragHandleDivRef.current;
26
+ if (dragHandleDivRefCurrent) {
27
+ return (0, _element.draggable)({
28
+ element: dragHandleDivRefCurrent,
29
+ getInitialData: function getInitialData() {
30
+ return {
31
+ localId: tableLocalId,
32
+ type: "table-".concat(direction),
33
+ indexes: indexes
34
+ };
35
+ }
36
+ });
37
+ }
38
+ }, [tableLocalId, direction, indexes]);
39
+ return /*#__PURE__*/_react.default.createElement("div", {
40
+ ref: dragHandleDivRef,
41
+ style: {
42
+ backgroundColor: "var(--ds-surface, white)",
43
+ borderRadius: '4px',
44
+ border: "2px solid ".concat("var(--ds-surface, white)"),
45
+ transform: direction === 'column' ? 'rotate(90deg)' : 'none'
46
+ }
47
+ }, /*#__PURE__*/_react.default.createElement(_dragHandleButton.DragHandleButton, {
48
+ label: "blah"
49
+ }));
50
+ };
@@ -14,11 +14,14 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
14
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
16
  var _react = _interopRequireWildcard(require("react"));
17
+ var _classnames2 = _interopRequireDefault(require("classnames"));
17
18
  var _state = require("@atlaskit/editor-prosemirror/state");
18
19
  var _utils = require("@atlaskit/editor-tables/utils");
19
20
  var _commands = require("../../../commands");
21
+ var _pluginFactory = require("../../../pm-plugins/plugin-factory");
20
22
  var _types = require("../../../types");
21
23
  var _utils2 = require("../../../utils");
24
+ var _consts = require("../../consts");
22
25
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
26
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
27
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
@@ -69,14 +72,42 @@ var NumberColumn = exports.default = /*#__PURE__*/function (_Component) {
69
72
  (0, _commands.clearHoverSelection)()(state, dispatch);
70
73
  }
71
74
  });
72
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getClassNames", function (index) {
75
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDragHandleLocation", function (rowIndex) {
73
76
  var _this$props3 = _this.props,
74
- hoveredRows = _this$props3.hoveredRows,
75
77
  editorView = _this$props3.editorView,
76
- isInDanger = _this$props3.isInDanger,
77
- isResizing = _this$props3.isResizing;
78
+ tableActive = _this$props3.tableActive;
79
+ var state = editorView.state,
80
+ dispatch = editorView.dispatch;
81
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
82
+ hoveredCell = _getPluginState.hoveredCell;
83
+ if (tableActive && hoveredCell.rowIndex !== rowIndex) {
84
+ (0, _commands.hoverCell)(rowIndex, hoveredCell.colIndex)(state, dispatch);
85
+ }
86
+ });
87
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getCellStyles", function (index, rowHeight) {
88
+ var _this$props4 = _this.props,
89
+ stickyTop = _this$props4.stickyTop,
90
+ hasHeaderRow = _this$props4.hasHeaderRow;
91
+ if (stickyTop && hasHeaderRow && index === 0) {
92
+ return {
93
+ height: rowHeight,
94
+ top: "".concat(stickyTop, "px")
95
+ };
96
+ }
97
+ return {
98
+ height: rowHeight
99
+ };
100
+ });
101
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getClassNames", function (index) {
102
+ var _classnames;
103
+ var isButtonDisabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
104
+ var _this$props5 = _this.props,
105
+ hoveredRows = _this$props5.hoveredRows,
106
+ editorView = _this$props5.editorView,
107
+ isInDanger = _this$props5.isInDanger,
108
+ isResizing = _this$props5.isResizing;
78
109
  var isActive = (0, _utils.isRowSelected)(index)(editorView.state.selection) || (hoveredRows || []).indexOf(index) !== -1 && !isResizing;
79
- return [_types.TableCssClassName.NUMBERED_COLUMN_BUTTON, isActive ? _types.TableCssClassName.HOVERED_CELL_ACTIVE : '', isActive && isInDanger ? _types.TableCssClassName.HOVERED_CELL_IN_DANGER : ''].join(' ');
110
+ return (0, _classnames2.default)(_types.TableCssClassName.NUMBERED_COLUMN_BUTTON, (_classnames = {}, (0, _defineProperty2.default)(_classnames, _types.TableCssClassName.NUMBERED_COLUMN_BUTTON_DISABLED, isButtonDisabled), (0, _defineProperty2.default)(_classnames, _types.TableCssClassName.HOVERED_CELL_IN_DANGER, isActive && isInDanger), (0, _defineProperty2.default)(_classnames, _types.TableCssClassName.HOVERED_CELL_ACTIVE, isActive), _classnames));
80
111
  });
81
112
  return _this;
82
113
  }
@@ -84,25 +115,33 @@ var NumberColumn = exports.default = /*#__PURE__*/function (_Component) {
84
115
  key: "render",
85
116
  value: function render() {
86
117
  var _this2 = this;
87
- var _this$props4 = this.props,
88
- tableRef = _this$props4.tableRef,
89
- hasHeaderRow = _this$props4.hasHeaderRow;
118
+ var _this$props6 = this.props,
119
+ tableRef = _this$props6.tableRef,
120
+ hasHeaderRow = _this$props6.hasHeaderRow,
121
+ isDragAndDropEnabled = _this$props6.isDragAndDropEnabled,
122
+ tableActive = _this$props6.tableActive;
90
123
  var rowHeights = (0, _utils2.getRowHeights)(tableRef);
91
124
  return /*#__PURE__*/_react.default.createElement("div", {
92
125
  className: _types.TableCssClassName.NUMBERED_COLUMN,
93
126
  style: {
94
- marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined
127
+ marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined,
128
+ borderLeft: isDragAndDropEnabled && tableActive ? "1px solid ".concat((0, _consts.tableBorderColor)()) : undefined
95
129
  },
96
130
  contentEditable: false
97
131
  }, rowHeights.map(function (rowHeight, index) {
98
- return /*#__PURE__*/_react.default.createElement("div", {
132
+ return isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement("div", {
133
+ key: "wrapper-".concat(index),
134
+ className: _this2.getClassNames(index, true),
135
+ "data-index": index,
136
+ style: _this2.getCellStyles(index, rowHeight),
137
+ onMouseOver: function onMouseOver() {
138
+ return _this2.updateDragHandleLocation(index);
139
+ }
140
+ }, hasHeaderRow ? index > 0 ? index : null : index + 1) : /*#__PURE__*/_react.default.createElement("div", {
99
141
  key: "wrapper-".concat(index),
100
142
  className: _this2.getClassNames(index),
101
143
  "data-index": index,
102
- style: {
103
- height: rowHeight,
104
- top: _this2.props.stickyTop !== undefined && hasHeaderRow && index === 0 ? "".concat(_this2.props.stickyTop, "px") : undefined
105
- },
144
+ style: _this2.getCellStyles(index, rowHeight),
106
145
  onClick: function onClick(event) {
107
146
  return _this2.selectRow(index, event);
108
147
  },
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.RowControls = void 0;
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _react = _interopRequireWildcard(require("react"));
17
+ var _reactIntlNext = require("react-intl-next");
18
+ var _commands = require("../../../commands");
19
+ var _types = require("../../../types");
20
+ var _utils = require("../../../utils");
21
+ var _consts = require("../../consts");
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
+ var messages = (0, _reactIntlNext.defineMessages)({
27
+ rowControl: {
28
+ id: 'fabric.editor.rowControl',
29
+ defaultMessage: 'Highlight row',
30
+ description: 'A button on the left of each row that shows up when the table is in focus. Clicking on it will select the entire row.'
31
+ }
32
+ });
33
+ var RowControlsComponent = /*#__PURE__*/function (_Component) {
34
+ (0, _inherits2.default)(RowControlsComponent, _Component);
35
+ var _super = _createSuper(RowControlsComponent);
36
+ function RowControlsComponent() {
37
+ var _this;
38
+ (0, _classCallCheck2.default)(this, RowControlsComponent);
39
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
+ args[_key] = arguments[_key];
41
+ }
42
+ _this = _super.call.apply(_super, [this].concat(args));
43
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clearHoverSelection", function () {
44
+ var _this$props$editorVie = _this.props.editorView,
45
+ state = _this$props$editorVie.state,
46
+ dispatch = _this$props$editorVie.dispatch;
47
+ (0, _commands.clearHoverSelection)()(state, dispatch);
48
+ });
49
+ return _this;
50
+ }
51
+ (0, _createClass2.default)(RowControlsComponent, [{
52
+ key: "render",
53
+ value: function render() {
54
+ var _this2 = this;
55
+ var _this$props = this.props,
56
+ editorView = _this$props.editorView,
57
+ tableRef = _this$props.tableRef,
58
+ hoveredRows = _this$props.hoveredRows,
59
+ isInDanger = _this$props.isInDanger,
60
+ isResizing = _this$props.isResizing,
61
+ formatMessage = _this$props.intl.formatMessage;
62
+ if (!tableRef) {
63
+ return null;
64
+ }
65
+ var selection = editorView.state.selection;
66
+ var rowHeights = (0, _utils.getRowHeights)(tableRef);
67
+ var rowsParams = (0, _utils.getRowsParams)(rowHeights);
68
+ var firstRow = tableRef.querySelector('tr');
69
+ var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
70
+ return /*#__PURE__*/_react.default.createElement("div", {
71
+ className: _types.TableCssClassName.ROW_CONTROLS
72
+ }, /*#__PURE__*/_react.default.createElement("div", {
73
+ className: _types.TableCssClassName.ROW_CONTROLS_INNER
74
+ }, rowsParams.map(function (_ref, index) {
75
+ var startIndex = _ref.startIndex,
76
+ endIndex = _ref.endIndex,
77
+ height = _ref.height;
78
+ // if previous row was header row, add its height to our margin
79
+ var marginTop = -1;
80
+ if (index === 1 && hasHeaderRow && _this2.props.stickyTop !== undefined) {
81
+ marginTop += rowHeights[index - 1] + _consts.tableToolbarSize;
82
+ }
83
+ var thisRowSticky = _this2.props.stickyTop !== undefined && index === 0 && hasHeaderRow;
84
+ return /*#__PURE__*/_react.default.createElement("div", {
85
+ className: "".concat(_types.TableCssClassName.ROW_CONTROLS_BUTTON_WRAP, " ").concat((0, _utils.getRowClassNames)(startIndex, selection, hoveredRows, isInDanger, isResizing), " ").concat(thisRowSticky ? 'sticky' : ''),
86
+ key: startIndex,
87
+ style: {
88
+ height: height,
89
+ marginTop: "".concat(marginTop, "px"),
90
+ top: thisRowSticky ? "".concat(_this2.props.stickyTop + 3, "px") : undefined,
91
+ paddingTop: thisRowSticky ? "".concat(_consts.tableControlsSpacing, "px") : undefined
92
+ }
93
+ }, /*#__PURE__*/_react.default.createElement("button", {
94
+ "aria-label": formatMessage(messages.rowControl),
95
+ type: "button",
96
+ className: "".concat(_types.TableCssClassName.ROW_CONTROLS_BUTTON, " ").concat(_types.TableCssClassName.CONTROLS_BUTTON),
97
+ onClick: function onClick(event) {
98
+ return _this2.props.selectRow(startIndex, event.shiftKey);
99
+ },
100
+ onMouseOver: function onMouseOver() {
101
+ return _this2.props.hoverRows([startIndex]);
102
+ },
103
+ onMouseOut: _this2.clearHoverSelection,
104
+ "data-start-index": startIndex,
105
+ "data-end-index": endIndex
106
+ }), /*#__PURE__*/_react.default.createElement("div", {
107
+ className: _types.TableCssClassName.CONTROLS_INSERT_MARKER
108
+ }));
109
+ })));
110
+ }
111
+ }]);
112
+ return RowControlsComponent;
113
+ }(_react.Component);
114
+ var RowControls = exports.RowControls = (0, _reactIntlNext.injectIntl)(RowControlsComponent);
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DragControls = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactIntlNext = require("react-intl-next");
10
+ var _utils = require("@atlaskit/editor-tables/utils");
11
+ var _types = require("../../../types");
12
+ var _utils2 = require("../../../utils");
13
+ var _DragHandle = require("../../DragHandle");
14
+ var DragControlsComponent = function DragControlsComponent(_ref) {
15
+ var tableRef = _ref.tableRef,
16
+ hoveredCell = _ref.hoveredCell,
17
+ hoverRows = _ref.hoverRows,
18
+ selectRow = _ref.selectRow,
19
+ tableActive = _ref.tableActive,
20
+ editorView = _ref.editorView;
21
+ var rowHeights = (0, _utils2.getRowHeights)(tableRef);
22
+ var heights = rowHeights.map(function (height) {
23
+ return "".concat(height - 1, "px");
24
+ }).join(' ');
25
+ var _onClick = function onClick(index, event) {};
26
+ var onMouseOver = function onMouseOver() {};
27
+ var onMouseOut = function onMouseOut() {};
28
+ var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
29
+ var getLocalId = function getLocalId() {
30
+ var _tableNode$node;
31
+ var tableNode = (0, _utils.findTable)(editorView.state.selection);
32
+ return (tableNode === null || tableNode === void 0 || (_tableNode$node = tableNode.node) === null || _tableNode$node === void 0 || (_tableNode$node = _tableNode$node.attrs) === null || _tableNode$node === void 0 ? void 0 : _tableNode$node.localId) || '';
33
+ };
34
+ return /*#__PURE__*/_react.default.createElement("div", {
35
+ className: _types.TableCssClassName.ROW_CONTROLS_WITH_DRAG,
36
+ style: {
37
+ gridTemplateRows: heights
38
+ }
39
+ }, Number.isFinite(rowIndex) && /*#__PURE__*/_react.default.createElement("div", {
40
+ style: {
41
+ gridRow: "".concat(rowIndex + 1, " / span 1")
42
+ }
43
+ }, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
44
+ onClick: function onClick(event) {
45
+ return _onClick(rowIndex, event);
46
+ },
47
+ onMouseOver: onMouseOver,
48
+ onMouseOut: onMouseOut,
49
+ tableLocalId: getLocalId(),
50
+ indexes: []
51
+ })));
52
+ };
53
+ var DragControls = exports.DragControls = (0, _reactIntlNext.injectIntl)(DragControlsComponent);
@@ -1,114 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- exports.RowControls = void 0;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _react = _interopRequireWildcard(require("react"));
17
- var _reactIntlNext = require("react-intl-next");
18
- var _commands = require("../../../commands");
19
- var _types = require("../../../types");
20
- var _utils = require("../../../utils");
21
- var _consts = require("../../consts");
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
- var messages = (0, _reactIntlNext.defineMessages)({
27
- rowControl: {
28
- id: 'fabric.editor.rowControl',
29
- defaultMessage: 'Highlight row',
30
- description: 'A button on the left of each row that shows up when the table is in focus. Clicking on it will select the entire row.'
6
+ Object.defineProperty(exports, "DragControls", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _DragControls.DragControls;
31
10
  }
32
11
  });
33
- var RowControlsComponent = /*#__PURE__*/function (_Component) {
34
- (0, _inherits2.default)(RowControlsComponent, _Component);
35
- var _super = _createSuper(RowControlsComponent);
36
- function RowControlsComponent() {
37
- var _this;
38
- (0, _classCallCheck2.default)(this, RowControlsComponent);
39
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
- args[_key] = arguments[_key];
41
- }
42
- _this = _super.call.apply(_super, [this].concat(args));
43
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clearHoverSelection", function () {
44
- var _this$props$editorVie = _this.props.editorView,
45
- state = _this$props$editorVie.state,
46
- dispatch = _this$props$editorVie.dispatch;
47
- (0, _commands.clearHoverSelection)()(state, dispatch);
48
- });
49
- return _this;
12
+ Object.defineProperty(exports, "RowControls", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _ClassicControls.RowControls;
50
16
  }
51
- (0, _createClass2.default)(RowControlsComponent, [{
52
- key: "render",
53
- value: function render() {
54
- var _this2 = this;
55
- var _this$props = this.props,
56
- editorView = _this$props.editorView,
57
- tableRef = _this$props.tableRef,
58
- hoveredRows = _this$props.hoveredRows,
59
- isInDanger = _this$props.isInDanger,
60
- isResizing = _this$props.isResizing,
61
- formatMessage = _this$props.intl.formatMessage;
62
- if (!tableRef) {
63
- return null;
64
- }
65
- var selection = editorView.state.selection;
66
- var rowHeights = (0, _utils.getRowHeights)(tableRef);
67
- var rowsParams = (0, _utils.getRowsParams)(rowHeights);
68
- var firstRow = tableRef.querySelector('tr');
69
- var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
70
- return /*#__PURE__*/_react.default.createElement("div", {
71
- className: _types.TableCssClassName.ROW_CONTROLS
72
- }, /*#__PURE__*/_react.default.createElement("div", {
73
- className: _types.TableCssClassName.ROW_CONTROLS_INNER
74
- }, rowsParams.map(function (_ref, index) {
75
- var startIndex = _ref.startIndex,
76
- endIndex = _ref.endIndex,
77
- height = _ref.height;
78
- // if previous row was header row, add its height to our margin
79
- var marginTop = -1;
80
- if (index === 1 && hasHeaderRow && _this2.props.stickyTop !== undefined) {
81
- marginTop += rowHeights[index - 1] + _consts.tableToolbarSize;
82
- }
83
- var thisRowSticky = _this2.props.stickyTop !== undefined && index === 0 && hasHeaderRow;
84
- return /*#__PURE__*/_react.default.createElement("div", {
85
- className: "".concat(_types.TableCssClassName.ROW_CONTROLS_BUTTON_WRAP, " ").concat((0, _utils.getRowClassNames)(startIndex, selection, hoveredRows, isInDanger, isResizing), " ").concat(thisRowSticky ? 'sticky' : ''),
86
- key: startIndex,
87
- style: {
88
- height: height,
89
- marginTop: "".concat(marginTop, "px"),
90
- top: thisRowSticky ? "".concat(_this2.props.stickyTop + 3, "px") : undefined,
91
- paddingTop: thisRowSticky ? "".concat(_consts.tableControlsSpacing, "px") : undefined
92
- }
93
- }, /*#__PURE__*/_react.default.createElement("button", {
94
- "aria-label": formatMessage(messages.rowControl),
95
- type: "button",
96
- className: "".concat(_types.TableCssClassName.ROW_CONTROLS_BUTTON, "\n ").concat(_types.TableCssClassName.CONTROLS_BUTTON, "\n "),
97
- onClick: function onClick(event) {
98
- return _this2.props.selectRow(startIndex, event.shiftKey);
99
- },
100
- onMouseOver: function onMouseOver() {
101
- return _this2.props.hoverRows([startIndex]);
102
- },
103
- onMouseOut: _this2.clearHoverSelection,
104
- "data-start-index": startIndex,
105
- "data-end-index": endIndex
106
- }), /*#__PURE__*/_react.default.createElement("div", {
107
- className: _types.TableCssClassName.CONTROLS_INSERT_MARKER
108
- }));
109
- })));
110
- }
111
- }]);
112
- return RowControlsComponent;
113
- }(_react.Component);
114
- var RowControls = exports.RowControls = (0, _reactIntlNext.injectIntl)(RowControlsComponent);
17
+ });
18
+ var _ClassicControls = require("./ClassicControls");
19
+ var _DragControls = require("./DragControls");
@@ -111,10 +111,11 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
111
111
  isHeaderColumnEnabled = _this$props.isHeaderColumnEnabled,
112
112
  ordering = _this$props.ordering,
113
113
  headerRowHeight = _this$props.headerRowHeight,
114
- stickyHeader = _this$props.stickyHeader;
114
+ stickyHeader = _this$props.stickyHeader,
115
+ hoveredCell = _this$props.hoveredCell;
115
116
  var tableHeight = (_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.tableHeight;
116
117
  var nextTableHeight = nextState === null || nextState === void 0 ? void 0 : nextState.tableHeight;
117
- return ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableHeight !== nextTableHeight || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || (0, _utils2.isSelectionUpdated)(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader;
118
+ return ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableHeight !== nextTableHeight || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || (0, _utils2.isSelectionUpdated)(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell;
118
119
  }
119
120
  }, {
120
121
  key: "componentWillUnmount",
@@ -137,7 +138,9 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
137
138
  tableActive = _this$props2.tableActive,
138
139
  hasHeaderRow = _this$props2.hasHeaderRow,
139
140
  hoveredRows = _this$props2.hoveredRows,
140
- stickyHeader = _this$props2.stickyHeader;
141
+ stickyHeader = _this$props2.stickyHeader,
142
+ isDragAndDropEnabled = _this$props2.isDragAndDropEnabled,
143
+ hoveredCell = _this$props2.hoveredCell;
141
144
  if (!tableRef) {
142
145
  return null;
143
146
  }
@@ -156,8 +159,15 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
156
159
  isInDanger: isInDanger,
157
160
  isResizing: isResizing,
158
161
  selectRow: this.selectRow,
159
- stickyTop: stickyTop
160
- }) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
162
+ stickyTop: stickyTop,
163
+ isDragAndDropEnabled: isDragAndDropEnabled
164
+ }) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement(_RowControls.DragControls, {
165
+ tableRef: tableRef,
166
+ hoveredCell: hoveredCell,
167
+ editorView: editorView,
168
+ hoverRows: this.hoverRows,
169
+ selectRow: this.selectRow
170
+ }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
161
171
  editorView: editorView,
162
172
  tableRef: tableRef,
163
173
  isInDanger: isInDanger,
@@ -175,7 +185,7 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
175
185
  isResizing: isResizing,
176
186
  selectRow: this.selectRow,
177
187
  stickyTop: tableActive ? stickyTop : undefined
178
- })));
188
+ }))));
179
189
  }
180
190
  }]);
181
191
  return TableFloatingControls;