@atlaskit/editor-plugin-insert-block 1.0.0 → 1.0.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,11 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#72440](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72440) [`eee41a9f4bda`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/eee41a9f4bda) - [ux] Ensures that when a table is inserted via popup, the table has a blinking cursor.
8
+
3
9
  ## 1.0.0
4
10
 
5
11
  ### Major Changes
@@ -541,13 +541,25 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
541
541
  var _this$props13 = this.props,
542
542
  popupsMountPoint = _this$props13.popupsMountPoint,
543
543
  popupsBoundariesElement = _this$props13.popupsBoundariesElement,
544
- popupsScrollableElement = _this$props13.popupsScrollableElement;
544
+ popupsScrollableElement = _this$props13.popupsScrollableElement,
545
+ pluginInjectionApi = _this$props13.pluginInjectionApi;
545
546
  var ref = (_this$tableButtonRef$ = this.tableButtonRef.current) !== null && _this$tableButtonRef$ !== void 0 ? _this$tableButtonRef$ : undefined;
546
547
  if (!isTableSelectorOpen) {
547
548
  return null;
548
549
  }
550
+
551
+ // We use focusTrap in the Popup. When we insert a table via popup,
552
+ // the popup closes, focusTrap gets destroyed and the popup detaches.
553
+ // The focus gets set to the body element. onUnmount method sets focus on the editor right before the
554
+ // Popup will be unmounted to ensure that the new table has a selection with a blinking cursor.
555
+ // So we can start typing right away.
556
+ var onUnmount = function onUnmount() {
557
+ var _pluginInjectionApi$c7;
558
+ return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c7 = pluginInjectionApi.core) === null || _pluginInjectionApi$c7 === void 0 || (_pluginInjectionApi$c7 = _pluginInjectionApi$c7.actions) === null || _pluginInjectionApi$c7 === void 0 ? void 0 : _pluginInjectionApi$c7.focus();
559
+ };
549
560
  return (0, _react2.jsx)(_tableSelectorPopupWithListeners.default, {
550
561
  target: ref,
562
+ onUnmount: onUnmount,
551
563
  onSelection: this.handleSelectedTableSize,
552
564
  popupsMountPoint: popupsMountPoint,
553
565
  popupsBoundariesElement: popupsBoundariesElement,
@@ -232,6 +232,7 @@ var TableSelectorPopup = exports.TableSelectorPopup = function TableSelectorPopu
232
232
  boundariesElement: props.popupsBoundariesElement,
233
233
  scrollableElement: props.popupsScrollableElement,
234
234
  focusTrap: true,
235
+ onUnmount: props.onUnmount,
235
236
  zIndex: _editorSharedStyles.akEditorMenuZIndex
236
237
  }, (0, _react2.jsx)("div", {
237
238
  css: tableSelectorPopupWrapperStyles,
@@ -597,14 +597,26 @@ export class ToolbarInsertBlock extends React.PureComponent {
597
597
  const {
598
598
  popupsMountPoint,
599
599
  popupsBoundariesElement,
600
- popupsScrollableElement
600
+ popupsScrollableElement,
601
+ pluginInjectionApi
601
602
  } = this.props;
602
603
  const ref = (_this$tableButtonRef$ = this.tableButtonRef.current) !== null && _this$tableButtonRef$ !== void 0 ? _this$tableButtonRef$ : undefined;
603
604
  if (!isTableSelectorOpen) {
604
605
  return null;
605
606
  }
607
+
608
+ // We use focusTrap in the Popup. When we insert a table via popup,
609
+ // the popup closes, focusTrap gets destroyed and the popup detaches.
610
+ // The focus gets set to the body element. onUnmount method sets focus on the editor right before the
611
+ // Popup will be unmounted to ensure that the new table has a selection with a blinking cursor.
612
+ // So we can start typing right away.
613
+ const onUnmount = () => {
614
+ var _pluginInjectionApi$c7, _pluginInjectionApi$c8;
615
+ return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c7 = pluginInjectionApi.core) === null || _pluginInjectionApi$c7 === void 0 ? void 0 : (_pluginInjectionApi$c8 = _pluginInjectionApi$c7.actions) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : _pluginInjectionApi$c8.focus();
616
+ };
606
617
  return jsx(TableSelectorPopup, {
607
618
  target: ref,
619
+ onUnmount: onUnmount,
608
620
  onSelection: this.handleSelectedTableSize,
609
621
  popupsMountPoint: popupsMountPoint,
610
622
  popupsBoundariesElement: popupsBoundariesElement,
@@ -222,6 +222,7 @@ export const TableSelectorPopup = props => {
222
222
  boundariesElement: props.popupsBoundariesElement,
223
223
  scrollableElement: props.popupsScrollableElement,
224
224
  focusTrap: true,
225
+ onUnmount: props.onUnmount,
225
226
  zIndex: akEditorMenuZIndex
226
227
  }, jsx("div", {
227
228
  css: tableSelectorPopupWrapperStyles,
@@ -531,13 +531,25 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
531
531
  var _this$props13 = this.props,
532
532
  popupsMountPoint = _this$props13.popupsMountPoint,
533
533
  popupsBoundariesElement = _this$props13.popupsBoundariesElement,
534
- popupsScrollableElement = _this$props13.popupsScrollableElement;
534
+ popupsScrollableElement = _this$props13.popupsScrollableElement,
535
+ pluginInjectionApi = _this$props13.pluginInjectionApi;
535
536
  var ref = (_this$tableButtonRef$ = this.tableButtonRef.current) !== null && _this$tableButtonRef$ !== void 0 ? _this$tableButtonRef$ : undefined;
536
537
  if (!isTableSelectorOpen) {
537
538
  return null;
538
539
  }
540
+
541
+ // We use focusTrap in the Popup. When we insert a table via popup,
542
+ // the popup closes, focusTrap gets destroyed and the popup detaches.
543
+ // The focus gets set to the body element. onUnmount method sets focus on the editor right before the
544
+ // Popup will be unmounted to ensure that the new table has a selection with a blinking cursor.
545
+ // So we can start typing right away.
546
+ var onUnmount = function onUnmount() {
547
+ var _pluginInjectionApi$c7;
548
+ return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c7 = pluginInjectionApi.core) === null || _pluginInjectionApi$c7 === void 0 || (_pluginInjectionApi$c7 = _pluginInjectionApi$c7.actions) === null || _pluginInjectionApi$c7 === void 0 ? void 0 : _pluginInjectionApi$c7.focus();
549
+ };
539
550
  return jsx(TableSelectorPopup, {
540
551
  target: ref,
552
+ onUnmount: onUnmount,
541
553
  onSelection: this.handleSelectedTableSize,
542
554
  popupsMountPoint: popupsMountPoint,
543
555
  popupsBoundariesElement: popupsBoundariesElement,
@@ -224,6 +224,7 @@ export var TableSelectorPopup = function TableSelectorPopup(props) {
224
224
  boundariesElement: props.popupsBoundariesElement,
225
225
  scrollableElement: props.popupsScrollableElement,
226
226
  focusTrap: true,
227
+ onUnmount: props.onUnmount,
227
228
  zIndex: akEditorMenuZIndex
228
229
  }, jsx("div", {
229
230
  css: tableSelectorPopupWrapperStyles,
@@ -3,6 +3,7 @@ import { jsx } from '@emotion/react';
3
3
  import type { OnTableSizeSelection } from './table-selector-popup';
4
4
  type SimpleEventHandler<T> = (event: T) => void;
5
5
  export interface TableSelectorPopupProps {
6
+ onUnmount?: () => void;
6
7
  onSelection: OnTableSizeSelection;
7
8
  target?: HTMLElement;
8
9
  popupsMountPoint?: HTMLElement;
@@ -3,6 +3,7 @@ import { jsx } from '@emotion/react';
3
3
  import type { OnTableSizeSelection } from './table-selector-popup';
4
4
  type SimpleEventHandler<T> = (event: T) => void;
5
5
  export interface TableSelectorPopupProps {
6
+ onUnmount?: () => void;
6
7
  onSelection: OnTableSizeSelection;
7
8
  target?: HTMLElement;
8
9
  popupsMountPoint?: HTMLElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -61,7 +61,7 @@
61
61
  "@atlaskit/icon": "^22.0.0",
62
62
  "@atlaskit/primitives": "^2.0.0",
63
63
  "@atlaskit/theme": "^12.6.0",
64
- "@atlaskit/tokens": "^1.36.0",
64
+ "@atlaskit/tokens": "^1.37.0",
65
65
  "@babel/runtime": "^7.0.0",
66
66
  "@emotion/react": "^11.7.1",
67
67
  "bind-event-listener": "^2.1.1",