@atlaskit/editor-plugin-table 5.4.14 → 5.4.15
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.
- package/CHANGELOG.md +10 -0
- package/afm-cc/tsconfig.json +70 -0
- package/dist/cjs/plugins/table/commands/hover.js +26 -6
- package/dist/cjs/plugins/table/commands/index.js +6 -0
- package/dist/cjs/plugins/table/commands/misc.js +8 -3
- package/dist/cjs/plugins/table/event-handlers.js +56 -34
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +39 -7
- package/dist/cjs/plugins/table/pm-plugins/main.js +5 -3
- package/dist/cjs/plugins/table/reducer.js +1 -0
- package/dist/cjs/plugins/table/toolbar.js +6 -3
- package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +6 -3
- package/dist/cjs/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -7
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -10
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +7 -4
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -8
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +12 -8
- package/dist/cjs/plugins/table/utils/dom.js +16 -1
- package/dist/cjs/plugins/table/utils/index.js +6 -0
- package/dist/es2019/plugins/table/commands/hover.js +22 -5
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +8 -3
- package/dist/es2019/plugins/table/event-handlers.js +45 -20
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +36 -3
- package/dist/es2019/plugins/table/pm-plugins/main.js +6 -4
- package/dist/es2019/plugins/table/reducer.js +1 -0
- package/dist/es2019/plugins/table/toolbar.js +5 -3
- package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
- package/dist/es2019/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +9 -7
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -8
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +12 -9
- package/dist/es2019/plugins/table/utils/dom.js +13 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/commands/hover.js +25 -5
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +8 -3
- package/dist/esm/plugins/table/event-handlers.js +55 -33
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +35 -3
- package/dist/esm/plugins/table/pm-plugins/main.js +6 -4
- package/dist/esm/plugins/table/reducer.js +1 -0
- package/dist/esm/plugins/table/toolbar.js +5 -3
- package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
- package/dist/esm/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +9 -7
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -8
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -8
- package/dist/esm/plugins/table/utils/dom.js +15 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +1 -1
- package/dist/types/plugins/table/event-handlers.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +6 -2
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +4 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +6 -2
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/unit/event-handlers.ts +2 -2
- package/src/__tests__/unit/ui/RowDragControls.tsx +1 -0
- package/src/plugins/table/commands/hover.ts +37 -7
- package/src/plugins/table/commands/index.ts +1 -0
- package/src/plugins/table/commands/misc.ts +9 -3
- package/src/plugins/table/event-handlers.ts +47 -29
- package/src/plugins/table/nodeviews/TableComponent.tsx +4 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +7 -5
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +37 -2
- package/src/plugins/table/pm-plugins/main.ts +6 -3
- package/src/plugins/table/reducer.ts +1 -0
- package/src/plugins/table/types.ts +7 -2
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +14 -5
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +3 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +3 -1
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -5
- package/src/plugins/table/utils/dom.ts +22 -0
- package/src/plugins/table/utils/index.ts +1 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* index.tsx generated by @compiled/babel-plugin v0.26.1 */
|
|
2
1
|
"use strict";
|
|
3
2
|
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -6,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.DragPreview = void 0;
|
|
9
|
-
var _runtime = require("@compiled/react/runtime");
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
var _primitives = require("@atlaskit/primitives");
|
|
12
10
|
var _DragInMotionIcon = require("../icons/DragInMotionIcon");
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = _default;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _react2 = require("@emotion/react");
|
|
9
10
|
var _reactIntlNext = require("react-intl-next");
|
|
10
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
12
|
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
@@ -19,6 +20,8 @@ var _commands = require("../../commands");
|
|
|
19
20
|
var _types = require("../../types");
|
|
20
21
|
var _FixedButton = _interopRequireDefault(require("./FixedButton"));
|
|
21
22
|
var _styles = require("./styles");
|
|
23
|
+
/** @jsx jsx */
|
|
24
|
+
|
|
22
25
|
var BUTTON_OFFSET = 3;
|
|
23
26
|
var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (props) {
|
|
24
27
|
var editorView = props.editorView,
|
|
@@ -49,7 +52,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
49
52
|
return null;
|
|
50
53
|
}
|
|
51
54
|
var labelCellOptions = formatMessage(_messages.tableMessages.cellOptions);
|
|
52
|
-
var button =
|
|
55
|
+
var button = (0, _react2.jsx)("div", {
|
|
53
56
|
css: function css(theme) {
|
|
54
57
|
return [(0, _styles.tableFloatingCellButtonStyles)({
|
|
55
58
|
theme: theme
|
|
@@ -57,19 +60,19 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
57
60
|
theme: theme
|
|
58
61
|
})];
|
|
59
62
|
}
|
|
60
|
-
},
|
|
63
|
+
}, (0, _react2.jsx)(_uiMenu.ToolbarButton, {
|
|
61
64
|
className: _types.TableCssClassName.CONTEXTUAL_MENU_BUTTON,
|
|
62
65
|
selected: isContextualMenuOpen,
|
|
63
66
|
title: labelCellOptions,
|
|
64
67
|
onClick: handleClick,
|
|
65
|
-
iconBefore:
|
|
68
|
+
iconBefore: (0, _react2.jsx)(_chevronDown.default, {
|
|
66
69
|
label: ""
|
|
67
70
|
}),
|
|
68
71
|
"aria-label": labelCellOptions
|
|
69
72
|
}));
|
|
70
73
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
71
74
|
if (stickyHeader && parentSticky && tableWrapper) {
|
|
72
|
-
return
|
|
75
|
+
return (0, _react2.jsx)(_FixedButton.default, {
|
|
73
76
|
offset: BUTTON_OFFSET,
|
|
74
77
|
stickyHeader: stickyHeader,
|
|
75
78
|
tableWrapper: tableWrapper,
|
|
@@ -79,7 +82,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
79
82
|
isContextualMenuOpen: isContextualMenuOpen
|
|
80
83
|
}, button);
|
|
81
84
|
}
|
|
82
|
-
return
|
|
85
|
+
return (0, _react2.jsx)(_ui.Popup, {
|
|
83
86
|
alignX: "right",
|
|
84
87
|
alignY: "start",
|
|
85
88
|
target: targetCellRef,
|
|
@@ -94,9 +97,9 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
94
97
|
});
|
|
95
98
|
var FloatingContextualButton = (0, _reactIntlNext.injectIntl)(FloatingContextualButtonInner);
|
|
96
99
|
function _default(props) {
|
|
97
|
-
return
|
|
100
|
+
return (0, _react2.jsx)(_errorBoundary.ErrorBoundary, {
|
|
98
101
|
component: _analytics.ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON,
|
|
99
102
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
100
103
|
fallbackComponent: null
|
|
101
|
-
},
|
|
104
|
+
}, (0, _react2.jsx)(FloatingContextualButton, props));
|
|
102
105
|
}
|
|
@@ -13,6 +13,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
13
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
15
|
var _react = require("react");
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
16
17
|
var _reactIntlNext = require("react-intl-next");
|
|
17
18
|
var _customSteps = require("@atlaskit/custom-steps");
|
|
18
19
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -37,7 +38,7 @@ var _styles2 = require("./styles");
|
|
|
37
38
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
38
39
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
39
40
|
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); }; }
|
|
40
|
-
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; } }
|
|
41
|
+
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; } } /** @jsx jsx */
|
|
41
42
|
var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
42
43
|
(0, _inherits2.default)(ContextualMenu, _Component);
|
|
43
44
|
var _super = _createSuper(ContextualMenu);
|
|
@@ -87,15 +88,15 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
87
88
|
value: {
|
|
88
89
|
name: 'background'
|
|
89
90
|
},
|
|
90
|
-
elemAfter:
|
|
91
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
91
92
|
className: _styles.DropdownMenuSharedCssClassName.SUBMENU
|
|
92
|
-
},
|
|
93
|
+
}, (0, _react2.jsx)("div", {
|
|
93
94
|
css: (0, _styles2.cellColourPreviewStyles)(background),
|
|
94
95
|
className: _types.TableCssClassName.CONTEXTUAL_MENU_ICON
|
|
95
|
-
}), isSubmenuOpen &&
|
|
96
|
+
}), isSubmenuOpen && (0, _react2.jsx)("div", {
|
|
96
97
|
className: _types.TableCssClassName.CONTEXTUAL_SUBMENU,
|
|
97
98
|
ref: _this.handleSubMenuRef
|
|
98
|
-
},
|
|
99
|
+
}, (0, _react2.jsx)(_uiColor.ColorPalette, {
|
|
99
100
|
cols: 7,
|
|
100
101
|
onClick: _this.setColor,
|
|
101
102
|
selectedColor: background,
|
|
@@ -112,7 +113,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
112
113
|
value: {
|
|
113
114
|
name: 'insert_column'
|
|
114
115
|
},
|
|
115
|
-
elemAfter:
|
|
116
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
116
117
|
css: _shortcut.shortcutStyle
|
|
117
118
|
}, (0, _keymaps.tooltip)(_keymaps.addColumnAfter))
|
|
118
119
|
});
|
|
@@ -121,7 +122,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
121
122
|
value: {
|
|
122
123
|
name: 'insert_row'
|
|
123
124
|
},
|
|
124
|
-
elemAfter:
|
|
125
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
125
126
|
css: _shortcut.shortcutStyle
|
|
126
127
|
}, (0, _keymaps.tooltip)(_keymaps.addRowAfter))
|
|
127
128
|
});
|
|
@@ -201,7 +202,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
201
202
|
value: {
|
|
202
203
|
name: 'clear'
|
|
203
204
|
},
|
|
204
|
-
elemAfter:
|
|
205
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
205
206
|
css: _shortcut.shortcutStyle
|
|
206
207
|
}, (0, _keymaps.tooltip)(_keymaps.backspace))
|
|
207
208
|
});
|
|
@@ -363,10 +364,10 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
363
364
|
if (!items) {
|
|
364
365
|
return null;
|
|
365
366
|
}
|
|
366
|
-
return
|
|
367
|
+
return (0, _react2.jsx)("div", {
|
|
367
368
|
"data-testid": "table-cell-contextual-menu",
|
|
368
369
|
onMouseLeave: this.closeSubmenu
|
|
369
|
-
},
|
|
370
|
+
}, (0, _react2.jsx)(_uiMenu.DropdownMenu, {
|
|
370
371
|
mountTo: mountPoint
|
|
371
372
|
//This needs be removed when the a11y is completely handled
|
|
372
373
|
//Disabling key navigation now as it works only partially
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _react = require("@emotion/react");
|
|
8
9
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
9
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
11
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -13,6 +14,8 @@ var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
|
13
14
|
var _consts = require("../consts");
|
|
14
15
|
var _ContextualMenu = _interopRequireDefault(require("./ContextualMenu"));
|
|
15
16
|
var _styles = require("./styles");
|
|
17
|
+
/** @jsx jsx */
|
|
18
|
+
|
|
16
19
|
var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
17
20
|
var mountPoint = _ref.mountPoint,
|
|
18
21
|
boundariesElement = _ref.boundariesElement,
|
|
@@ -39,7 +42,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
39
42
|
return null;
|
|
40
43
|
}
|
|
41
44
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
42
|
-
return
|
|
45
|
+
return (0, _react.jsx)(_ui.Popup, {
|
|
43
46
|
alignX: "right",
|
|
44
47
|
alignY: "top",
|
|
45
48
|
target: targetCellRef,
|
|
@@ -55,9 +58,9 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
55
58
|
forcePlacement: true,
|
|
56
59
|
offset: [-7, 0],
|
|
57
60
|
stick: true
|
|
58
|
-
},
|
|
61
|
+
}, (0, _react.jsx)("div", {
|
|
59
62
|
css: _styles.tablePopupStyles
|
|
60
|
-
},
|
|
63
|
+
}, (0, _react.jsx)(_ContextualMenu.default, {
|
|
61
64
|
editorView: editorView,
|
|
62
65
|
offset: [_consts.contextualMenuTriggerSize / 2, -_consts.contextualMenuTriggerSize],
|
|
63
66
|
isOpen: isOpen,
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.DragMenu = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _react = require("@emotion/react");
|
|
9
10
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
10
11
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
11
12
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
@@ -16,6 +17,8 @@ var _pluginFactory = require("../../pm-plugins/drag-and-drop/plugin-factory");
|
|
|
16
17
|
var _utils2 = require("../../utils");
|
|
17
18
|
var _dragMenu = require("../../utils/drag-menu");
|
|
18
19
|
var _consts = require("../consts");
|
|
20
|
+
/** @jsx jsx */
|
|
21
|
+
|
|
19
22
|
var groupedDragMenuConfig = [['add_row_above', 'add_row_below', 'add_column_left', 'add_column_right', 'distribute_columns', 'clear_cells', 'delete_row', 'delete_column'], ['move_column_left', 'move_column_right', 'move_row_up', 'move_row_down'], ['sort_column_asc', 'sort_column_desc']];
|
|
20
23
|
var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
21
24
|
var menuItemsArr = (0, _toConsumableArray2.default)(Array(groupedDragMenuConfig.length)).map(function () {
|
|
@@ -36,15 +39,15 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
|
36
39
|
name: item.id
|
|
37
40
|
},
|
|
38
41
|
isDisabled: item.disabled,
|
|
39
|
-
elemBefore: item.icon ?
|
|
42
|
+
elemBefore: item.icon ? (0, _react.jsx)("div", {
|
|
40
43
|
style: {
|
|
41
44
|
marginRight: "var(--ds-space-negative-075, -6px)",
|
|
42
45
|
display: 'flex'
|
|
43
46
|
}
|
|
44
|
-
},
|
|
47
|
+
}, (0, _react.jsx)(item.icon, {
|
|
45
48
|
label: item.title
|
|
46
49
|
})) : undefined,
|
|
47
|
-
elemAfter: item.keymap ?
|
|
50
|
+
elemAfter: item.keymap ? (0, _react.jsx)("div", {
|
|
48
51
|
css: _shortcut.shortcutStyle
|
|
49
52
|
}, item.keymap) : undefined
|
|
50
53
|
});
|
|
@@ -136,7 +139,7 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
136
139
|
if (!menuItems) {
|
|
137
140
|
return null;
|
|
138
141
|
}
|
|
139
|
-
return
|
|
142
|
+
return (0, _react.jsx)(_uiMenu.DropdownMenu, {
|
|
140
143
|
mountTo: mountPoint
|
|
141
144
|
//This needs be removed when the a11y is completely handled
|
|
142
145
|
//Disabling key navigation now as it works only partially
|
|
@@ -26,7 +26,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
|
|
|
26
26
|
return [];
|
|
27
27
|
};
|
|
28
28
|
var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
29
|
-
var _colWidths$map$join, _rowHeights
|
|
29
|
+
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce, _colWidths;
|
|
30
30
|
var editorView = _ref.editorView,
|
|
31
31
|
tableActive = _ref.tableActive,
|
|
32
32
|
tableRef = _ref.tableRef,
|
|
@@ -37,7 +37,8 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
37
37
|
isInDanger = _ref.isInDanger,
|
|
38
38
|
rowHeights = _ref.rowHeights,
|
|
39
39
|
colWidths = _ref.colWidths,
|
|
40
|
-
hasHeaderColumn = _ref.hasHeaderColumn
|
|
40
|
+
hasHeaderColumn = _ref.hasHeaderColumn,
|
|
41
|
+
isTableHovered = _ref.isTableHovered;
|
|
41
42
|
var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
|
|
42
43
|
return width ? "".concat(width - 1, "px") : '0px';
|
|
43
44
|
}).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
@@ -77,10 +78,14 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
77
78
|
// update hovered cell location
|
|
78
79
|
var state = editorView.state,
|
|
79
80
|
dispatch = editorView.dispatch;
|
|
80
|
-
if (tableActive
|
|
81
|
-
|
|
81
|
+
if (tableActive) {
|
|
82
|
+
// For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
|
|
83
|
+
// of the opposite dimension. For example; here when we mouse over the column drag handle then we're technically
|
|
84
|
+
// also hovering over row 0 index. And vice-versa with rows. This means we don't need to worry about knowing the
|
|
85
|
+
// current row index. We can just force it to 0.
|
|
86
|
+
(0, _commands.hoverCell)(0, Number(colIndex))(state, dispatch);
|
|
82
87
|
}
|
|
83
|
-
}, [editorView,
|
|
88
|
+
}, [editorView, tableActive]);
|
|
84
89
|
var handleMouseOut = (0, _react.useCallback)(function () {
|
|
85
90
|
if (tableActive) {
|
|
86
91
|
var state = editorView.state,
|
|
@@ -96,6 +101,9 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
96
101
|
var colIndexes = (0, _react.useMemo)(function () {
|
|
97
102
|
return [colIndex];
|
|
98
103
|
}, [colIndex]);
|
|
104
|
+
var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
|
|
105
|
+
return sum + cur;
|
|
106
|
+
}, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
99
107
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
100
108
|
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS,
|
|
101
109
|
onMouseMove: handleMouseMove
|
|
@@ -124,7 +132,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
124
132
|
right: '0'
|
|
125
133
|
} : {}
|
|
126
134
|
}));
|
|
127
|
-
}), tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/_react.default.createElement("div", {
|
|
135
|
+
}), tableActive && !isResizing && isTableHovered && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/_react.default.createElement("div", {
|
|
128
136
|
style: {
|
|
129
137
|
gridColumn: gridColumnPosition,
|
|
130
138
|
display: 'flex',
|
|
@@ -140,8 +148,8 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
140
148
|
direction: "column",
|
|
141
149
|
tableLocalId: localId || '',
|
|
142
150
|
indexes: colIndexes,
|
|
143
|
-
previewWidth:
|
|
144
|
-
previewHeight:
|
|
151
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
152
|
+
previewHeight: previewHeight,
|
|
145
153
|
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
146
154
|
onClick: handleClick,
|
|
147
155
|
onMouseOver: handleMouseOver,
|
|
@@ -28,7 +28,8 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
28
28
|
isResizing = _ref.isResizing,
|
|
29
29
|
stickyHeader = _ref.stickyHeader,
|
|
30
30
|
selection = _ref.selection,
|
|
31
|
-
isInDanger = _ref.isInDanger
|
|
31
|
+
isInDanger = _ref.isInDanger,
|
|
32
|
+
isTableHovered = _ref.isTableHovered;
|
|
32
33
|
var _useState = (0, _react.useState)({
|
|
33
34
|
width: 0,
|
|
34
35
|
height: 0
|
|
@@ -113,6 +114,7 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
113
114
|
tableRef: tableRef,
|
|
114
115
|
isResizing: isResizing,
|
|
115
116
|
tableActive: tableActive,
|
|
117
|
+
isTableHovered: isTableHovered,
|
|
116
118
|
stickyTop: tableActive ? stickyTop : undefined,
|
|
117
119
|
localId: currentNodeLocalId,
|
|
118
120
|
isInDanger: isInDanger,
|
|
@@ -42,6 +42,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
42
42
|
editorView = _ref.editorView,
|
|
43
43
|
isInDanger = _ref.isInDanger,
|
|
44
44
|
isResizing = _ref.isResizing,
|
|
45
|
+
isTableHovered = _ref.isTableHovered,
|
|
45
46
|
hoverRows = _ref.hoverRows,
|
|
46
47
|
selectRow = _ref.selectRow,
|
|
47
48
|
updateCellHoverLocation = _ref.updateCellHoverLocation;
|
|
@@ -157,7 +158,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
157
158
|
left: "var(--ds-space-negative-100, -8px)"
|
|
158
159
|
}
|
|
159
160
|
}));
|
|
160
|
-
}), !isResizing && Number.isFinite(rowIndex) && /*#__PURE__*/_react.default.createElement("div", {
|
|
161
|
+
}), !isResizing && isTableHovered && Number.isFinite(rowIndex) && /*#__PURE__*/_react.default.createElement("div", {
|
|
161
162
|
style: {
|
|
162
163
|
gridRow: gridRowPosition,
|
|
163
164
|
gridColumn: '2',
|
|
@@ -16,7 +16,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
18
|
var _commands = require("../../commands");
|
|
19
|
-
var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
20
19
|
var _types = require("../../types");
|
|
21
20
|
var _utils2 = require("../../utils");
|
|
22
21
|
var _CornerControls = require("./CornerControls");
|
|
@@ -59,10 +58,12 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
59
58
|
tableActive = _this$props.tableActive;
|
|
60
59
|
var state = editorView.state,
|
|
61
60
|
dispatch = editorView.dispatch;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
if (tableActive) {
|
|
62
|
+
// For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
|
|
63
|
+
// of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
|
|
64
|
+
// also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
|
|
65
|
+
// current column index. We can just force it to 0.
|
|
66
|
+
(0, _commands.hoverCell)(rowIndex, 0)(state, dispatch);
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
_this.state = {
|
|
@@ -134,8 +135,9 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
134
135
|
ordering = _this$props2.ordering,
|
|
135
136
|
headerRowHeight = _this$props2.headerRowHeight,
|
|
136
137
|
stickyHeader = _this$props2.stickyHeader,
|
|
137
|
-
hoveredCell = _this$props2.hoveredCell
|
|
138
|
-
|
|
138
|
+
hoveredCell = _this$props2.hoveredCell,
|
|
139
|
+
isTableHovered = _this$props2.isTableHovered;
|
|
140
|
+
return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || 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 || isTableHovered !== nextProps.isTableHovered;
|
|
139
141
|
}
|
|
140
142
|
}, {
|
|
141
143
|
key: "componentWillUnmount",
|
|
@@ -161,7 +163,8 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
161
163
|
hoveredRows = _this$props3.hoveredRows,
|
|
162
164
|
stickyHeader = _this$props3.stickyHeader,
|
|
163
165
|
isDragAndDropEnabled = _this$props3.isDragAndDropEnabled,
|
|
164
|
-
hoveredCell = _this$props3.hoveredCell
|
|
166
|
+
hoveredCell = _this$props3.hoveredCell,
|
|
167
|
+
isTableHovered = _this$props3.isTableHovered;
|
|
165
168
|
if (!tableRef) {
|
|
166
169
|
return null;
|
|
167
170
|
}
|
|
@@ -195,6 +198,7 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
195
198
|
tableRef: tableRef,
|
|
196
199
|
tableNode: tableNode,
|
|
197
200
|
hoveredCell: hoveredCell,
|
|
201
|
+
isTableHovered: isTableHovered,
|
|
198
202
|
editorView: editorView,
|
|
199
203
|
tableActive: tableActive,
|
|
200
204
|
isInDanger: isInDanger,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.updateResizeHandles = exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isDragRowFloatingInsertDot = exports.isDragRowControlsButton = exports.isDragCornerButton = exports.isDragColumnFloatingInsertDot = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = void 0;
|
|
6
|
+
exports.updateResizeHandles = exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isDragRowFloatingInsertDot = exports.isDragRowControlsButton = exports.isDragCornerButton = exports.isDragColumnFloatingInsertDot = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = exports.findNearestCellIndexToPoint = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
8
|
var _types = require("../types");
|
|
9
9
|
var _consts = require("../ui/consts");
|
|
@@ -206,4 +206,19 @@ var getTop = exports.getTop = function getTop(element) {
|
|
|
206
206
|
return 0;
|
|
207
207
|
}
|
|
208
208
|
return (_element$getBoundingC = element === null || element === void 0 || (_element$getBoundingC2 = element.getBoundingClientRect) === null || _element$getBoundingC2 === void 0 || (_element$getBoundingC2 = _element$getBoundingC2.call(element)) === null || _element$getBoundingC2 === void 0 ? void 0 : _element$getBoundingC2.top) !== null && _element$getBoundingC !== void 0 ? _element$getBoundingC : 0;
|
|
209
|
+
};
|
|
210
|
+
var findNearestCellIndexToPoint = exports.findNearestCellIndexToPoint = function findNearestCellIndexToPoint(x, y) {
|
|
211
|
+
var _cell$parentElement;
|
|
212
|
+
var elements = document.elementsFromPoint(x, y);
|
|
213
|
+
var cell = elements.find(function (el) {
|
|
214
|
+
return el.nodeName.toUpperCase() === 'TD' || el.nodeName.toUpperCase() === 'TH';
|
|
215
|
+
});
|
|
216
|
+
var row = (_cell$parentElement = cell === null || cell === void 0 ? void 0 : cell.parentElement) !== null && _cell$parentElement !== void 0 ? _cell$parentElement : undefined;
|
|
217
|
+
if (!Number.isFinite(row === null || row === void 0 ? void 0 : row.rowIndex) || !Number.isFinite(cell === null || cell === void 0 ? void 0 : cell.cellIndex)) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
row: row.rowIndex,
|
|
222
|
+
col: cell.cellIndex
|
|
223
|
+
};
|
|
209
224
|
};
|
|
@@ -105,6 +105,12 @@ Object.defineProperty(exports, "findControlsHoverDecoration", {
|
|
|
105
105
|
return _decoration.findControlsHoverDecoration;
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
|
+
Object.defineProperty(exports, "findNearestCellIndexToPoint", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function get() {
|
|
111
|
+
return _dom.findNearestCellIndexToPoint;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
108
114
|
Object.defineProperty(exports, "getColumnClassNames", {
|
|
109
115
|
enumerable: true,
|
|
110
116
|
get: function get() {
|
|
@@ -108,15 +108,32 @@ export const hideResizeHandleLine = () => createCommand(state => ({
|
|
|
108
108
|
decorationSet: updatePluginStateDecorations(state, [], TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
|
|
109
109
|
}
|
|
110
110
|
}));
|
|
111
|
-
export const
|
|
111
|
+
export const setTableHovered = hovered => createCommand(() => {
|
|
112
|
+
return {
|
|
113
|
+
type: 'TABLE_HOVERED',
|
|
114
|
+
data: {
|
|
115
|
+
isTableHovered: hovered
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
119
|
+
export const hoverCell = (rowIndex, colIndex) => createCommand(state => {
|
|
120
|
+
const {
|
|
121
|
+
hoveredCell: prevHoveredCell
|
|
122
|
+
} = getPluginState(state);
|
|
123
|
+
|
|
124
|
+
// If no arguments have been passed then the intention it to reset the hover cell data
|
|
125
|
+
const clear = rowIndex === undefined && colIndex === undefined;
|
|
126
|
+
const nextRowIndex = clear ? undefined : rowIndex !== null && rowIndex !== void 0 ? rowIndex : prevHoveredCell.rowIndex;
|
|
127
|
+
const nextColIndex = clear ? undefined : colIndex !== null && colIndex !== void 0 ? colIndex : prevHoveredCell.colIndex;
|
|
128
|
+
if (nextRowIndex === prevHoveredCell.rowIndex && nextColIndex === prevHoveredCell.colIndex) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
112
131
|
return {
|
|
113
132
|
type: 'HOVER_CELL',
|
|
114
133
|
data: {
|
|
115
134
|
hoveredCell: {
|
|
116
|
-
rowIndex,
|
|
117
|
-
colIndex
|
|
118
|
-
colWidth,
|
|
119
|
-
colHeight
|
|
135
|
+
rowIndex: nextRowIndex,
|
|
136
|
+
colIndex: nextColIndex
|
|
120
137
|
}
|
|
121
138
|
}
|
|
122
139
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine } from './hover';
|
|
1
|
+
export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, setTableHovered } from './hover';
|
|
2
2
|
export { insertColumn, insertRow, createTable } from './insert';
|
|
3
3
|
export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './toggle';
|
|
4
4
|
export { clearMultipleCells } from './clear';
|
|
@@ -209,11 +209,16 @@ export const getTableElementMoveTypeBySlice = (slice, state) => {
|
|
|
209
209
|
export const isInsideFirstCellOfRowOrColumn = (selection, type) => {
|
|
210
210
|
const table = findTable(selection);
|
|
211
211
|
if (!table || !type) {
|
|
212
|
-
return;
|
|
212
|
+
return false;
|
|
213
213
|
}
|
|
214
214
|
const map = TableMap.get(table.node);
|
|
215
|
-
const cell =
|
|
216
|
-
|
|
215
|
+
const cell = findCellClosestToPos(selection.$anchor);
|
|
216
|
+
if (!cell) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
const pos = cell.pos - table.pos - 1;
|
|
220
|
+
// cell positions in table map always start at 1, as they're offsets not positions
|
|
221
|
+
const index = map.map.findIndex(value => value === pos);
|
|
217
222
|
return type === 'row' ? index % map.width === 0 : index < map.width;
|
|
218
223
|
};
|
|
219
224
|
export const deleteTable = (state, dispatch) => {
|
|
@@ -4,7 +4,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
-
import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
|
|
7
|
+
import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, setTableHovered, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
|
|
8
8
|
import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-drop/plugin-factory';
|
|
9
9
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
10
10
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
@@ -102,7 +102,8 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
102
102
|
const target = mouseEvent.target;
|
|
103
103
|
const {
|
|
104
104
|
insertColumnButtonIndex,
|
|
105
|
-
insertRowButtonIndex
|
|
105
|
+
insertRowButtonIndex,
|
|
106
|
+
isTableHovered
|
|
106
107
|
} = getPluginState(state);
|
|
107
108
|
if (isInsertRowButton(target)) {
|
|
108
109
|
const [startIndex, endIndex] = getColumnOrRowIndex(target);
|
|
@@ -127,6 +128,9 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
127
128
|
right: endIndex
|
|
128
129
|
})(state, dispatch);
|
|
129
130
|
}
|
|
131
|
+
if (!isTableHovered) {
|
|
132
|
+
return setTableHovered(true)(state, dispatch);
|
|
133
|
+
}
|
|
130
134
|
return false;
|
|
131
135
|
};
|
|
132
136
|
|
|
@@ -163,6 +167,19 @@ export const handleMouseOut = (view, mouseEvent) => {
|
|
|
163
167
|
}
|
|
164
168
|
return false;
|
|
165
169
|
};
|
|
170
|
+
export const handleMouseEnter = (view, mouseEvent) => {
|
|
171
|
+
const {
|
|
172
|
+
state,
|
|
173
|
+
dispatch
|
|
174
|
+
} = view;
|
|
175
|
+
const {
|
|
176
|
+
isTableHovered
|
|
177
|
+
} = getPluginState(state);
|
|
178
|
+
if (!isTableHovered) {
|
|
179
|
+
return setTableHovered(true)(state, dispatch);
|
|
180
|
+
}
|
|
181
|
+
return false;
|
|
182
|
+
};
|
|
166
183
|
export const handleMouseLeave = (view, event) => {
|
|
167
184
|
if (!(event.target instanceof HTMLElement)) {
|
|
168
185
|
return false;
|
|
@@ -174,19 +191,29 @@ export const handleMouseLeave = (view, event) => {
|
|
|
174
191
|
const {
|
|
175
192
|
insertColumnButtonIndex,
|
|
176
193
|
insertRowButtonIndex,
|
|
177
|
-
isDragAndDropEnabled
|
|
194
|
+
isDragAndDropEnabled,
|
|
195
|
+
isTableHovered
|
|
178
196
|
} = getPluginState(state);
|
|
197
|
+
if (isTableHovered) {
|
|
198
|
+
if (isDragAndDropEnabled) {
|
|
199
|
+
const {
|
|
200
|
+
isDragMenuOpen
|
|
201
|
+
} = getDragDropPluginState(state);
|
|
202
|
+
!isDragMenuOpen && setTableHovered(false)(state, dispatch);
|
|
203
|
+
} else {
|
|
204
|
+
setTableHovered(false)(state, dispatch);
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// If this table doesn't have focus then we want to skip everything after this.
|
|
210
|
+
if (!isTableInFocus(view)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
179
213
|
const target = event.target;
|
|
180
214
|
if (isTableControlsButton(target)) {
|
|
181
215
|
return true;
|
|
182
216
|
}
|
|
183
|
-
if (isDragAndDropEnabled) {
|
|
184
|
-
const {
|
|
185
|
-
isDragMenuOpen
|
|
186
|
-
} = getDragDropPluginState(state);
|
|
187
|
-
// Only set hoveredCell colIndex and rowIndex to undefined if the drag menu is not open
|
|
188
|
-
!isDragMenuOpen && hoverCell()(state, dispatch);
|
|
189
|
-
}
|
|
190
217
|
if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
|
|
191
218
|
return true;
|
|
192
219
|
}
|
|
@@ -331,9 +358,12 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorV
|
|
|
331
358
|
}
|
|
332
359
|
return tr;
|
|
333
360
|
};
|
|
334
|
-
export const
|
|
361
|
+
export const isTableInFocus = view => {
|
|
335
362
|
var _getPluginState, _getResizePluginState;
|
|
336
|
-
|
|
363
|
+
return !!((_getPluginState = getPluginState(view.state)) !== null && _getPluginState !== void 0 && _getPluginState.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
364
|
+
};
|
|
365
|
+
export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mouseEvent) => {
|
|
366
|
+
if (!isTableInFocus(view)) {
|
|
337
367
|
return false;
|
|
338
368
|
}
|
|
339
369
|
return eventHandler(view, mouseEvent, elementContentRects);
|
|
@@ -342,10 +372,9 @@ const trackCellLocation = (view, mouseEvent) => {
|
|
|
342
372
|
var _tableElement$dataset;
|
|
343
373
|
const target = mouseEvent.target;
|
|
344
374
|
const maybeTableCell = isElementInTableCell(target);
|
|
345
|
-
const tableRef = getPluginState(view.state).tableRef;
|
|
346
375
|
const {
|
|
347
|
-
|
|
348
|
-
|
|
376
|
+
tableNode,
|
|
377
|
+
tableRef
|
|
349
378
|
} = getPluginState(view.state);
|
|
350
379
|
const tableElement = closestElement(target, 'table');
|
|
351
380
|
|
|
@@ -359,17 +388,13 @@ const trackCellLocation = (view, mouseEvent) => {
|
|
|
359
388
|
const htmlColIndex = maybeTableCell.cellIndex;
|
|
360
389
|
const rowElement = closestElement(target, 'tr');
|
|
361
390
|
const htmlRowIndex = rowElement && rowElement.rowIndex;
|
|
362
|
-
const colHeight = tableRef.offsetHeight;
|
|
363
|
-
const colWidth = maybeTableCell.offsetWidth;
|
|
364
391
|
const tableMap = tableNode && TableMap.get(tableNode);
|
|
365
392
|
let colIndex = htmlColIndex;
|
|
366
393
|
if (tableMap) {
|
|
367
394
|
const convertedColIndex = convertHTMLCellIndexToColumnIndex(htmlColIndex, htmlRowIndex, tableMap);
|
|
368
395
|
colIndex = getColumnIndexMappedToColumnIndexInFirstRow(convertedColIndex, htmlRowIndex, tableMap);
|
|
369
396
|
}
|
|
370
|
-
|
|
371
|
-
hoverCell(htmlRowIndex, colIndex, colWidth, colHeight)(view.state, view.dispatch);
|
|
372
|
-
}
|
|
397
|
+
hoverCell(htmlRowIndex, colIndex)(view.state, view.dispatch);
|
|
373
398
|
};
|
|
374
399
|
export const withCellTracking = (eventHandler, elementContentRects) => (view, mouseEvent) => {
|
|
375
400
|
if (getPluginState(view.state).isDragAndDropEnabled && !getDragDropPluginState(view.state).isDragging) {
|