@atlaskit/editor-plugin-insert-block 3.2.0 → 3.2.1

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 3.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#142852](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/142852)
8
+ [`ca0f841e860ab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ca0f841e860ab) -
9
+ [ux] [ED-27466] When table option in quick insert typeahead is selected, shows table size picker
10
+ allow user selecting the table size before inserting
11
+ - Updated dependencies
12
+
3
13
  ## 3.2.0
4
14
 
5
15
  ### Minor Changes
@@ -18,6 +18,7 @@ var _elementBrowser = require("@atlaskit/editor-common/element-browser");
18
18
  var _hooks = require("@atlaskit/editor-common/hooks");
19
19
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
20
20
  var _uiReact = require("@atlaskit/editor-common/ui-react");
21
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
22
  var _theme = require("@atlaskit/theme");
22
23
  var _colors = require("@atlaskit/theme/colors");
23
24
  var _excluded = ["children"];
@@ -144,7 +145,7 @@ var InsertMenu = function InsertMenu(_ref) {
144
145
  }, (0, _react2.jsx)(ElementBrowserWrapper, {
145
146
  handleClickOutside: toggleVisiblity,
146
147
  handleEscapeKeydown: toggleVisiblity,
147
- closeOnTab: true
148
+ closeOnTab: !(0, _platformFeatureFlags.fg)('editor_a11y_tab_does_not_close_menus')
148
149
  }, (0, _react2.jsx)(_elementBrowser.ElementBrowser, {
149
150
  mode: "inline",
150
151
  getItems: getItems,
@@ -29,7 +29,6 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
29
29
  var _colors = require("@atlaskit/theme/colors");
30
30
  var _blockInsertMenu = require("./block-insert-menu");
31
31
  var _createItems3 = require("./create-items");
32
- var _tableSelectorPopupWithListeners = _interopRequireDefault(require("./table-selector-popup-with-listeners"));
33
32
  var _templateObject;
34
33
  /* eslint-disable @atlaskit/ui-styling-standard/no-imported-style-values */
35
34
  /**
@@ -39,8 +38,6 @@ var _templateObject;
39
38
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
40
39
  // Ignored via go/ees005
41
40
  // eslint-disable-next-line import/no-namespace
42
- // Ignored via go/ees005
43
- // eslint-disable-next-line import/no-named-as-default
44
41
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
45
42
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
46
43
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
@@ -48,6 +45,9 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
48
45
  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; }
49
46
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
50
47
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
48
+ // Ignored via go/ees005
49
+ // eslint-disable-next-line import/no-named-as-default
50
+
51
51
  /**
52
52
  * Checks if an element is detached (i.e. not in the current document)
53
53
  */
@@ -630,7 +630,8 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
630
630
  var _pluginInjectionApi$c8;
631
631
  return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c8 = pluginInjectionApi.core) === null || _pluginInjectionApi$c8 === void 0 || (_pluginInjectionApi$c8 = _pluginInjectionApi$c8.actions) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : _pluginInjectionApi$c8.focus();
632
632
  };
633
- return (0, _react2.jsx)(_tableSelectorPopupWithListeners.default, {
633
+ return (0, _react2.jsx)(_ui.TableSelectorPopup, {
634
+ allowOutsideSelection: true,
634
635
  target: ref,
635
636
  onUnmount: onUnmount,
636
637
  onSelection: this.handleSelectedTableSize,
@@ -16,6 +16,7 @@ import { IconCode, IconDate, IconDecision, IconDivider, IconExpand, IconPanel, I
16
16
  import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
17
17
  // AFP-2532 TODO: Fix automatic suppressions below
18
18
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
19
+ import { fg } from '@atlaskit/platform-feature-flags';
19
20
  import { borderRadius } from '@atlaskit/theme';
20
21
  import { N0, N30A, N60A } from '@atlaskit/theme/colors';
21
22
  export const DEFAULT_HEIGHT = 560;
@@ -120,7 +121,7 @@ const InsertMenu = ({
120
121
  }, jsx(ElementBrowserWrapper, {
121
122
  handleClickOutside: toggleVisiblity,
122
123
  handleEscapeKeydown: toggleVisiblity,
123
- closeOnTab: true
124
+ closeOnTab: !fg('editor_a11y_tab_does_not_close_menus')
124
125
  }, jsx(ElementBrowser, {
125
126
  mode: "inline",
126
127
  getItems: getItems,
@@ -13,7 +13,7 @@ import { injectIntl } from 'react-intl-next';
13
13
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
14
14
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
15
15
  import { buttonGroupStyle, buttonGroupStyleBeforeVisualRefresh, separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
16
- import { Popup } from '@atlaskit/editor-common/ui';
16
+ import { Popup, TableSelectorPopup } from '@atlaskit/editor-common/ui';
17
17
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
18
18
  import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
19
19
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
@@ -26,7 +26,7 @@ import { BlockInsertMenu } from './block-insert-menu';
26
26
  import { createItems } from './create-items';
27
27
  // Ignored via go/ees005
28
28
  // eslint-disable-next-line import/no-named-as-default
29
- import TableSelectorPopup from './table-selector-popup-with-listeners';
29
+
30
30
  /**
31
31
  * Checks if an element is detached (i.e. not in the current document)
32
32
  */
@@ -696,6 +696,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
696
696
  return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c8 = pluginInjectionApi.core) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : (_pluginInjectionApi$c9 = _pluginInjectionApi$c8.actions) === null || _pluginInjectionApi$c9 === void 0 ? void 0 : _pluginInjectionApi$c9.focus();
697
697
  };
698
698
  return jsx(TableSelectorPopup, {
699
+ allowOutsideSelection: true,
699
700
  target: ref,
700
701
  onUnmount: onUnmount,
701
702
  onSelection: this.handleSelectedTableSize,
@@ -23,6 +23,7 @@ import { IconCode, IconDate, IconDecision, IconDivider, IconExpand, IconPanel, I
23
23
  import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
24
24
  // AFP-2532 TODO: Fix automatic suppressions below
25
25
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
26
+ import { fg } from '@atlaskit/platform-feature-flags';
26
27
  import { borderRadius } from '@atlaskit/theme';
27
28
  import { N0, N30A, N60A } from '@atlaskit/theme/colors';
28
29
  export var DEFAULT_HEIGHT = 560;
@@ -141,7 +142,7 @@ var InsertMenu = function InsertMenu(_ref) {
141
142
  }, jsx(ElementBrowserWrapper, {
142
143
  handleClickOutside: toggleVisiblity,
143
144
  handleEscapeKeydown: toggleVisiblity,
144
- closeOnTab: true
145
+ closeOnTab: !fg('editor_a11y_tab_does_not_close_menus')
145
146
  }, jsx(ElementBrowser, {
146
147
  mode: "inline",
147
148
  getItems: getItems,
@@ -28,7 +28,7 @@ import { injectIntl } from 'react-intl-next';
28
28
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
29
29
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
30
30
  import { buttonGroupStyle, buttonGroupStyleBeforeVisualRefresh, separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
31
- import { Popup } from '@atlaskit/editor-common/ui';
31
+ import { Popup, TableSelectorPopup } from '@atlaskit/editor-common/ui';
32
32
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
33
33
  import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
34
34
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
@@ -41,7 +41,7 @@ import { BlockInsertMenu } from './block-insert-menu';
41
41
  import { createItems } from './create-items';
42
42
  // Ignored via go/ees005
43
43
  // eslint-disable-next-line import/no-named-as-default
44
- import TableSelectorPopup from './table-selector-popup-with-listeners';
44
+
45
45
  /**
46
46
  * Checks if an element is detached (i.e. not in the current document)
47
47
  */
@@ -625,6 +625,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
625
625
  return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c8 = pluginInjectionApi.core) === null || _pluginInjectionApi$c8 === void 0 || (_pluginInjectionApi$c8 = _pluginInjectionApi$c8.actions) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : _pluginInjectionApi$c8.focus();
626
626
  };
627
627
  return jsx(TableSelectorPopup, {
628
+ allowOutsideSelection: true,
628
629
  target: ref,
629
630
  onUnmount: onUnmount,
630
631
  onSelection: this.handleSelectedTableSize,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,43 +34,43 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/button": "^23.0.0",
37
- "@atlaskit/editor-common": "^103.4.0",
37
+ "@atlaskit/editor-common": "^103.12.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
39
39
  "@atlaskit/editor-plugin-block-type": "^5.1.0",
40
- "@atlaskit/editor-plugin-code-block": "^4.3.0",
40
+ "@atlaskit/editor-plugin-code-block": "^4.4.0",
41
41
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
42
42
  "@atlaskit/editor-plugin-date": "^4.2.0",
43
- "@atlaskit/editor-plugin-emoji": "^3.5.0",
43
+ "@atlaskit/editor-plugin-emoji": "^3.6.0",
44
44
  "@atlaskit/editor-plugin-expand": "^3.2.0",
45
45
  "@atlaskit/editor-plugin-extension": "^5.2.0",
46
46
  "@atlaskit/editor-plugin-feature-flags": "^1.4.0",
47
47
  "@atlaskit/editor-plugin-hyperlink": "^4.4.0",
48
48
  "@atlaskit/editor-plugin-image-upload": "^2.0.0",
49
- "@atlaskit/editor-plugin-layout": "^2.4.0",
50
- "@atlaskit/editor-plugin-media": "^2.4.0",
49
+ "@atlaskit/editor-plugin-layout": "^2.5.0",
50
+ "@atlaskit/editor-plugin-media": "^2.6.0",
51
51
  "@atlaskit/editor-plugin-media-insert": "^6.2.0",
52
52
  "@atlaskit/editor-plugin-mentions": "^4.4.0",
53
53
  "@atlaskit/editor-plugin-metrics": "^3.4.0",
54
54
  "@atlaskit/editor-plugin-panel": "^4.3.0",
55
55
  "@atlaskit/editor-plugin-placeholder-text": "^2.2.0",
56
56
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
57
- "@atlaskit/editor-plugin-quick-insert": "^2.3.0",
57
+ "@atlaskit/editor-plugin-quick-insert": "^2.4.0",
58
58
  "@atlaskit/editor-plugin-rule": "^2.1.0",
59
59
  "@atlaskit/editor-plugin-status": "^3.1.0",
60
- "@atlaskit/editor-plugin-table": "^10.7.0",
60
+ "@atlaskit/editor-plugin-table": "^10.8.0",
61
61
  "@atlaskit/editor-plugin-tasks-and-decisions": "^5.1.0",
62
- "@atlaskit/editor-plugin-type-ahead": "^2.3.0",
62
+ "@atlaskit/editor-plugin-type-ahead": "^2.5.0",
63
63
  "@atlaskit/editor-prosemirror": "7.0.0",
64
64
  "@atlaskit/editor-shared-styles": "^3.4.0",
65
65
  "@atlaskit/emoji": "^69.0.0",
66
66
  "@atlaskit/heading": "^5.2.0",
67
- "@atlaskit/icon": "^25.5.0",
68
- "@atlaskit/icon-lab": "^4.6.0",
67
+ "@atlaskit/icon": "^25.6.0",
68
+ "@atlaskit/icon-lab": "^4.9.0",
69
69
  "@atlaskit/platform-feature-flags": "^1.1.0",
70
70
  "@atlaskit/primitives": "^14.4.0",
71
71
  "@atlaskit/theme": "^18.0.0",
72
- "@atlaskit/tmp-editor-statsig": "^4.6.0",
73
- "@atlaskit/tokens": "^4.7.0",
72
+ "@atlaskit/tmp-editor-statsig": "^4.12.0",
73
+ "@atlaskit/tokens": "^4.8.0",
74
74
  "@atlaskit/tooltip": "^20.0.0",
75
75
  "@babel/runtime": "^7.0.0",
76
76
  "@emotion/react": "^11.7.1",
@@ -133,6 +133,9 @@
133
133
  "platform_editor_toolbar_responsive_fixes": {
134
134
  "type": "boolean"
135
135
  },
136
+ "editor_a11y_tab_does_not_close_menus": {
137
+ "type": "boolean"
138
+ },
136
139
  "platform_editor_ease_of_use_metrics": {
137
140
  "type": "boolean"
138
141
  },
@@ -1,258 +0,0 @@
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.default = exports.TableSelectorPopup = void 0;
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _react = require("react");
12
- var _react2 = require("@emotion/react");
13
- var _bindEventListener = require("bind-event-listener");
14
- var _ui = require("@atlaskit/editor-common/ui");
15
- var _uiReact = require("@atlaskit/editor-common/ui-react");
16
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
17
- var _colors = require("@atlaskit/theme/colors");
18
- var _tableSelectorPopup = _interopRequireWildcard(require("./table-selector-popup"));
19
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
- 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; }
22
- 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; } /**
23
- * @jsxRuntime classic
24
- * @jsx jsx
25
- */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
- var TABLE_SELECTOR_PADDING_TOP = 8;
27
- var TABLE_SELECTOR_PADDING_SIDE = 10;
28
- var DEFAULT_TABLE_SELECTOR_ROWS = 5;
29
- var DEFAULT_TABLE_SELECTOR_COLS = 10;
30
- var DEFAULT_TABLE_SELECTOR_SELECTION_SIZE = 1;
31
- var DEFAULT_MAX_TABLE_SELECTOR_ROWS = 10;
32
- var TableSelectorWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(_tableSelectorPopup.default);
33
- var initialSizeState = {
34
- col: DEFAULT_TABLE_SELECTOR_SELECTION_SIZE,
35
- row: DEFAULT_TABLE_SELECTOR_SELECTION_SIZE,
36
- maxCol: DEFAULT_TABLE_SELECTOR_COLS,
37
- maxRow: DEFAULT_TABLE_SELECTOR_ROWS
38
- };
39
- var tableSelectorPopupWrapperStyles = (0, _react2.css)({
40
- borderRadius: "var(--ds-border-radius, 3px)",
41
- backgroundColor: "var(--ds-surface-overlay, ".concat(_colors.N0, ")"),
42
- boxShadow: "var(--ds-shadow-overlay, ".concat("0 0 0 1px ".concat(_colors.N30A, ", 0 2px 1px ").concat(_colors.N30A, ", 0 0 20px -6px ").concat(_colors.N60A), ")"),
43
- padding: "".concat("var(--ds-space-100, ".concat("".concat(TABLE_SELECTOR_PADDING_TOP, "px"), ")"), " ", TABLE_SELECTOR_PADDING_SIDE, "px")
44
- });
45
- var TableSelectorPopup = exports.TableSelectorPopup = function TableSelectorPopup(props) {
46
- var _useState = (0, _react.useState)(initialSizeState),
47
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
48
- size = _useState2[0],
49
- setSize = _useState2[1];
50
- var tablePopupRef = (0, _react.useRef)(null);
51
- // If popup opened by keyboard enable keyboard mode
52
- var isKeyboardMode = (0, _react.useRef)(props.isOpenedByKeyboard);
53
- var enableKeyboardMode = (0, _react.useCallback)(function () {
54
- if (!isKeyboardMode.current) {
55
- isKeyboardMode.current = true;
56
- }
57
- }, [isKeyboardMode]);
58
- var disableKeyboardMode = (0, _react.useCallback)(function () {
59
- if (isKeyboardMode.current) {
60
- isKeyboardMode.current = false;
61
- }
62
- }, [isKeyboardMode]);
63
-
64
- // Mouse move is used to allow selection changes outside of the popup and is more reactive to changes.
65
- var handleMouseMove = (0, _react.useCallback)(function (e) {
66
- if (!tablePopupRef.current) {
67
- return;
68
- }
69
- disableKeyboardMode();
70
- var tablePopup = tablePopupRef.current;
71
- var _tablePopup$getBoundi = tablePopup.getBoundingClientRect(),
72
- left = _tablePopup$getBoundi.left,
73
- top = _tablePopup$getBoundi.top;
74
-
75
- // Mouse position on popup
76
- var selectedWidth = e.clientX - left;
77
- var selectedHeight = e.clientY - top;
78
-
79
- // Calculate number grid cells selected
80
- var selectedGridCols = Math.ceil((selectedWidth - TABLE_SELECTOR_PADDING_SIDE + _tableSelectorPopup.TABLE_SELECTOR_BUTTON_GAP) / (_tableSelectorPopup.TABLE_SELECTOR_BUTTON_GAP + _tableSelectorPopup.TABLE_SELECTOR_BUTTON_SIZE));
81
- var selectedGridRows = Math.ceil((selectedHeight - TABLE_SELECTOR_PADDING_TOP + _tableSelectorPopup.TABLE_SELECTOR_BUTTON_GAP) / (_tableSelectorPopup.TABLE_SELECTOR_BUTTON_GAP + _tableSelectorPopup.TABLE_SELECTOR_BUTTON_SIZE));
82
- // Keep the selected rows and columns within the defined bounds
83
- var gridRows = DEFAULT_TABLE_SELECTOR_ROWS;
84
- if (selectedGridCols < 1) {
85
- selectedGridCols = 1;
86
- }
87
- if (selectedGridCols > size.maxCol) {
88
- selectedGridCols = size.maxCol;
89
- }
90
- if (selectedGridRows < 1) {
91
- selectedGridRows = 1;
92
- }
93
-
94
- // Expand grid when row selection is greater than the default grid size
95
- if (selectedGridRows >= DEFAULT_TABLE_SELECTOR_ROWS && selectedGridRows < DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
96
- gridRows = selectedGridRows + 1;
97
- }
98
- if (selectedGridRows >= DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
99
- selectedGridRows = DEFAULT_MAX_TABLE_SELECTOR_ROWS;
100
- gridRows = DEFAULT_MAX_TABLE_SELECTOR_ROWS;
101
- }
102
- if (selectedGridCols !== size.col || selectedGridRows !== size.row) {
103
- setSize({
104
- col: selectedGridCols,
105
- row: selectedGridRows,
106
- maxCol: DEFAULT_TABLE_SELECTOR_COLS,
107
- maxRow: gridRows
108
- });
109
- }
110
- }, [disableKeyboardMode, size, setSize]);
111
- var decreasingSequence = function decreasingSequence(maxNumber, prevNumber) {
112
- var nextNumber = prevNumber - 1;
113
- if (prevNumber === 1) {
114
- nextNumber = maxNumber;
115
- }
116
- return nextNumber;
117
- };
118
- var getMaxRow = function getMaxRow(prevSize, eventKey) {
119
- switch (eventKey) {
120
- case 'ArrowDown':
121
- // Expand the grid size when last row selected
122
- if (prevSize.maxRow < DEFAULT_MAX_TABLE_SELECTOR_ROWS && prevSize.row >= DEFAULT_TABLE_SELECTOR_ROWS - 1) {
123
- return prevSize.maxRow + 1;
124
- }
125
- if (prevSize.row === DEFAULT_MAX_TABLE_SELECTOR_ROWS) {
126
- return DEFAULT_TABLE_SELECTOR_ROWS;
127
- }
128
- return prevSize.maxRow;
129
- case 'ArrowLeft':
130
- var moveToPrevRow = prevSize.col === 1 && prevSize.row > 1;
131
- var moveToLastRow = prevSize.row === 1 && prevSize.col === 1;
132
- // Expand the popup to max size when selected row wraps around to last row
133
- if (moveToLastRow) {
134
- return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
135
- }
136
- // Decrease the popup when decreased row selection
137
- if (prevSize.maxRow > DEFAULT_TABLE_SELECTOR_ROWS && moveToPrevRow) {
138
- return prevSize.row;
139
- }
140
- return prevSize.maxRow;
141
- case 'ArrowUp':
142
- if (prevSize.row === 1) {
143
- return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
144
- // Decrease the popup size when decreased row selection
145
- } else if (prevSize.maxRow > DEFAULT_TABLE_SELECTOR_ROWS) {
146
- return prevSize.row;
147
- }
148
- return prevSize.maxRow;
149
- case 'ArrowRight':
150
- var moveToNextRow = prevSize.col === DEFAULT_TABLE_SELECTOR_COLS;
151
- var increaseMaxRow = prevSize.maxRow < DEFAULT_MAX_TABLE_SELECTOR_ROWS && moveToNextRow && prevSize.row + 1 === prevSize.maxRow;
152
-
153
- // Decrease popup size for wrap around to selection 1 x 1
154
- if (prevSize.row === DEFAULT_MAX_TABLE_SELECTOR_ROWS && prevSize.col === DEFAULT_TABLE_SELECTOR_COLS) {
155
- return DEFAULT_TABLE_SELECTOR_ROWS;
156
- // Decrease the popup size when decreased row selection
157
- } else if (increaseMaxRow) {
158
- return prevSize.maxRow + 1;
159
- }
160
- return prevSize.maxRow;
161
- default:
162
- return prevSize.maxRow;
163
- }
164
- };
165
- var handleInitialButtonFocus = (0, _react.useCallback)(function () {
166
- if (isKeyboardMode.current !== true) {
167
- enableKeyboardMode();
168
- setSize(initialSizeState);
169
- }
170
- }, [enableKeyboardMode, setSize]);
171
- var handleKeyDown = (0, _react.useCallback)(
172
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
173
- function (event) {
174
- if (event.key === 'ArrowDown') {
175
- enableKeyboardMode();
176
- setSize(function (prevSize) {
177
- return _objectSpread(_objectSpread({}, prevSize), {}, {
178
- row: prevSize.row % prevSize.maxRow + 1,
179
- maxRow: getMaxRow(prevSize, event.key)
180
- });
181
- });
182
- }
183
- if (event.key === 'ArrowRight') {
184
- enableKeyboardMode();
185
- setSize(function (prevSize) {
186
- var moveToNextRow = prevSize.col === DEFAULT_TABLE_SELECTOR_COLS;
187
- return _objectSpread(_objectSpread({}, prevSize), {}, {
188
- col: prevSize.col % DEFAULT_TABLE_SELECTOR_COLS + 1,
189
- row: moveToNextRow ? prevSize.row % prevSize.maxRow + 1 : prevSize.row,
190
- maxRow: getMaxRow(prevSize, event.key)
191
- });
192
- });
193
- }
194
- if (event.key === 'ArrowLeft') {
195
- enableKeyboardMode();
196
- setSize(function (prevSize) {
197
- var getRow = function getRow(prevRow, prevCol) {
198
- var row = prevRow;
199
- // Move to previous row for wrap around
200
- if (prevSize.col === 1 && prevSize.row > 1) {
201
- return prevRow - 1;
202
- // Increase the selection to max size when selected row and column wraps around
203
- } else if (prevRow === 1 && prevCol === 1) {
204
- return DEFAULT_MAX_TABLE_SELECTOR_ROWS;
205
- }
206
- return row;
207
- };
208
- return _objectSpread(_objectSpread({}, prevSize), {}, {
209
- col: decreasingSequence(prevSize.maxCol, prevSize.col),
210
- row: getRow(prevSize.row, prevSize.col),
211
- maxRow: getMaxRow(prevSize, event.key)
212
- });
213
- });
214
- }
215
- if (event.key === 'ArrowUp') {
216
- enableKeyboardMode();
217
- setSize(function (prevSize) {
218
- var moveToLastRow = prevSize.row === 1;
219
- return _objectSpread(_objectSpread({}, prevSize), {}, {
220
- row: moveToLastRow ? DEFAULT_MAX_TABLE_SELECTOR_ROWS : decreasingSequence(prevSize.maxRow, prevSize.row),
221
- maxRow: getMaxRow(prevSize, event.key)
222
- });
223
- });
224
- }
225
- }, [enableKeyboardMode, setSize]);
226
- (0, _react.useEffect)(function () {
227
- var unbind = (0, _bindEventListener.bind)(window, {
228
- type: 'mousemove',
229
- listener: handleMouseMove
230
- });
231
- return unbind;
232
- }, [handleMouseMove]);
233
- return (0, _react2.jsx)(_ui.Popup, {
234
- target: props.target,
235
- offset: [0, 3],
236
- mountTo: props.popupsMountPoint,
237
- boundariesElement: props.popupsBoundariesElement,
238
- scrollableElement: props.popupsScrollableElement,
239
- focusTrap: true,
240
- onUnmount: props.onUnmount,
241
- zIndex: _editorSharedStyles.akEditorMenuZIndex
242
- }, (0, _react2.jsx)("div", {
243
- css: tableSelectorPopupWrapperStyles,
244
- ref: tablePopupRef
245
- }, (0, _react2.jsx)(TableSelectorWithListeners, {
246
- handleClickOutside: props.handleClickOutside,
247
- handleEscapeKeydown: props.handleEscapeKeydown,
248
- maxCols: size.maxCol,
249
- maxRows: size.maxRow,
250
- onSelection: props.onSelection,
251
- selectedCol: size.col,
252
- selectedRow: size.row,
253
- onKeyDown: handleKeyDown,
254
- isFocused: isKeyboardMode.current,
255
- handleInitialButtonFocus: handleInitialButtonFocus
256
- })));
257
- };
258
- var _default = exports.default = TableSelectorPopup;
@@ -1,158 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.TABLE_SELECTOR_BUTTON_SIZE = exports.TABLE_SELECTOR_BUTTON_GAP = void 0;
7
- var _react = require("react");
8
- var _react2 = require("@emotion/react");
9
- var _reactIntlNext = require("react-intl-next");
10
- var _messages = require("@atlaskit/editor-common/messages");
11
- var _uiReact = require("@atlaskit/editor-common/ui-react");
12
- var _primitives = require("@atlaskit/primitives");
13
- var _colors = require("@atlaskit/theme/colors");
14
- /**
15
- * @jsxRuntime classic
16
- * @jsx jsx
17
- */
18
-
19
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
20
-
21
- var TABLE_SELECTOR_BUTTON_GAP = exports.TABLE_SELECTOR_BUTTON_GAP = 2;
22
- var TABLE_SELECTOR_BUTTON_SIZE = exports.TABLE_SELECTOR_BUTTON_SIZE = 17;
23
- var selectedButtonStyles = (0, _react2.css)({
24
- backgroundColor: "var(--ds-background-accent-blue-subtlest, #579DFF)",
25
- border: "1px solid ".concat("var(--ds-background-accent-blue-subtle, #579DFF)")
26
- });
27
- var buttonStyles = (0, _react2.css)({
28
- height: "".concat(TABLE_SELECTOR_BUTTON_SIZE, "px"),
29
- width: "".concat(TABLE_SELECTOR_BUTTON_SIZE, "px"),
30
- border: "1px solid ".concat("var(--ds-border, #091e4224)"),
31
- backgroundColor: "var(--ds-background-input, #ffffff)",
32
- borderRadius: '3px',
33
- cursor: 'pointer',
34
- display: 'block',
35
- '&:focus': {
36
- outline: 'none',
37
- border: "1px solid ".concat("var(--ds-border-focused, ".concat(_colors.B100, ")")),
38
- boxShadow: "0 0 0 0.5px ".concat("var(--ds-border-focused, ".concat(_colors.B100, ")"))
39
- }
40
- });
41
- var selectionSizeTextStyles = (0, _react2.css)({
42
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
43
- lineHeight: '14px',
44
- display: 'flex',
45
- justifyContent: 'center',
46
- marginTop: "var(--ds-space-075, 5px)",
47
- padding: "var(--ds-space-075, 10px)"
48
- });
49
- var TableSelectorButton = function TableSelectorButton(_ref) {
50
- var row = _ref.row,
51
- col = _ref.col,
52
- isActive = _ref.isActive,
53
- _onClick = _ref.onClick,
54
- label = _ref.label,
55
- onKeyDown = _ref.onKeyDown,
56
- isFocused = _ref.isFocused,
57
- handleInitialButtonFocus = _ref.handleInitialButtonFocus;
58
- var btnRef = (0, _react.useRef)(null);
59
- (0, _react.useEffect)(function () {
60
- if (btnRef.current) {
61
- if (isFocused) {
62
- btnRef.current.focus();
63
- } else {
64
- btnRef.current.blur();
65
- }
66
- }
67
- }, [isFocused, btnRef]);
68
- var handleFocus = col === 1 && row === 1 ? function () {
69
- return handleInitialButtonFocus();
70
- } : undefined;
71
- return (0, _react2.jsx)("button", {
72
- type: "button",
73
- css: [buttonStyles, isActive ? selectedButtonStyles : undefined],
74
- onClick: function onClick() {
75
- return _onClick(row, col);
76
- },
77
- "aria-label": label,
78
- onKeyDown: onKeyDown,
79
- ref: btnRef,
80
- onFocus: handleFocus
81
- });
82
- };
83
- var createArray = function createArray(maxCols, maxRows) {
84
- var arr = [];
85
- for (var i = 1; i < maxRows + 1; i++) {
86
- for (var j = 1; j < maxCols + 1; j++) {
87
- arr.push({
88
- col: j,
89
- row: i
90
- });
91
- }
92
- }
93
- return arr;
94
- };
95
- var gridWrapperStyles = function gridWrapperStyles(_ref2) {
96
- var maxCols = _ref2.maxCols,
97
- maxRows = _ref2.maxRows;
98
- return (0, _react2.css)({
99
- display: 'grid',
100
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
101
- gridTemplateColumns: "repeat(".concat(maxCols, ", 1fr)"),
102
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
103
- gridTemplateRows: "repeat(".concat(maxRows, ", 1fr)"),
104
- gap: "".concat("var(--ds-space-025, ".concat("".concat(TABLE_SELECTOR_BUTTON_GAP, "px"), ")"))
105
- });
106
- };
107
- var TableSelectorPopup = function TableSelectorPopup(_ref3) {
108
- var maxCols = _ref3.maxCols,
109
- maxRows = _ref3.maxRows,
110
- onSelection = _ref3.onSelection,
111
- selectedCol = _ref3.selectedCol,
112
- selectedRow = _ref3.selectedRow,
113
- onKeyDown = _ref3.onKeyDown,
114
- isFocused = _ref3.isFocused,
115
- handleInitialButtonFocus = _ref3.handleInitialButtonFocus,
116
- formatMessage = _ref3.intl.formatMessage;
117
- var buttons = (0, _react.useMemo)(function () {
118
- return createArray(maxCols, maxRows);
119
- }, [maxCols, maxRows]);
120
- var setOutsideClickTargetRef = (0, _react.useContext)(_uiReact.OutsideClickTargetRefContext);
121
- return (0, _react2.jsx)(_primitives.Stack, {
122
- ref: setOutsideClickTargetRef
123
- }, (0, _react2.jsx)("div", {
124
- "aria-label": "".concat(formatMessage(_messages.toolbarInsertBlockMessages.tableSizeSelectorPopup)),
125
- css:
126
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
127
- gridWrapperStyles({
128
- maxCols: maxCols,
129
- maxRows: maxRows
130
- })
131
- }, buttons.map(function (_ref4, index) {
132
- var col = _ref4.col,
133
- row = _ref4.row;
134
- var isCurrentFocused = isFocused && selectedCol === col && selectedRow === row;
135
- var isActive = selectedCol >= col && selectedRow >= row ? true : false;
136
- return (0, _react2.jsx)(TableSelectorButton
137
- // Ignored via go/ees005
138
- // eslint-disable-next-line react/no-array-index-key
139
- , {
140
- key: index,
141
- isActive: isActive,
142
- col: col,
143
- row: row,
144
- onClick: onSelection,
145
- label: "".concat(formatMessage(_messages.toolbarInsertBlockMessages.tableSizeSelectorButton, {
146
- numberOfColumns: col,
147
- numberOfRows: row
148
- })),
149
- onKeyDown: onKeyDown,
150
- isFocused: isCurrentFocused,
151
- handleInitialButtonFocus: handleInitialButtonFocus
152
- });
153
- })), (0, _react2.jsx)("span", {
154
- css: selectionSizeTextStyles,
155
- "aria-hidden": true
156
- }, "".concat(selectedCol, " x ").concat(selectedRow)));
157
- };
158
- var _default = exports.default = (0, _reactIntlNext.injectIntl)(TableSelectorPopup);