@atlaskit/editor-core 185.2.16 → 185.2.19

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-core
2
2
 
3
+ ## 185.2.19
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6d852a003e4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6d852a003e4) - Fixes link picker not returning focus on close when `lp-link-picker-focus-trap` feature flag is enabled
8
+
3
9
  ## 185.2.16
4
10
 
5
11
  ### Patch Changes
@@ -84,7 +84,7 @@ var getToolbarConfig = function getToolbarConfig(options, featureFlags, editorAn
84
84
  var lpLinkPicker = featureFlags.lpLinkPicker,
85
85
  lpLinkPickerFocusTrap = featureFlags.lpLinkPickerFocusTrap,
86
86
  preventPopupOverflow = featureFlags.preventPopupOverflow;
87
- var shouldEnableFocusTrap = lpLinkPicker && lpLinkPickerFocusTrap;
87
+ var shouldEnableFocusTrap = Boolean(lpLinkPicker && lpLinkPickerFocusTrap);
88
88
  if (linkState && linkState.activeLinkMark) {
89
89
  var activeLinkMark = linkState.activeLinkMark;
90
90
  var hyperLinkToolbar = {
@@ -220,6 +220,9 @@ var getToolbarConfig = function getToolbarConfig(options, featureFlags, editorAn
220
220
  onCancel: function onCancel() {
221
221
  return view.focus();
222
222
  },
223
+ onClose: lpLinkPickerFocusTrap ? function () {
224
+ return view.focus();
225
+ } : undefined,
223
226
  onSubmit: function onSubmit(href) {
224
227
  var _options$cardOptions;
225
228
  var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
@@ -233,7 +236,9 @@ var getToolbarConfig = function getToolbarConfig(options, featureFlags, editorAn
233
236
  sourceEvent: analytic
234
237
  }) : (0, _commands.insertLinkWithAnalytics)(inputMethod, activeLinkMark.from, activeLinkMark.to, href, title, displayText, !!(options !== null && options !== void 0 && (_options$cardOptions = options.cardOptions) !== null && _options$cardOptions !== void 0 && _options$cardOptions.provider), analytic);
235
238
  command(view.state, view.dispatch, view);
236
- view.focus();
239
+ if (!lpLinkPickerFocusTrap) {
240
+ view.focus();
241
+ }
237
242
  }
238
243
  });
239
244
  }
@@ -15,7 +15,7 @@ var _commands = require("../../commands");
15
15
  var _useEscapeClickaway = require("./useEscapeClickaway");
16
16
  var _analyticsNext = require("@atlaskit/analytics-next");
17
17
  var _utils = require("@atlaskit/editor-common/utils");
18
- var _excluded = ["view", "onCancel", "invokeMethod", "editorAppearance"];
18
+ var _excluded = ["view", "onCancel", "invokeMethod", "editorAppearance", "onClose"];
19
19
  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); }
20
20
  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; }
21
21
  /**
@@ -28,7 +28,29 @@ var EditorLinkPicker = function EditorLinkPicker(_ref) {
28
28
  _ref$invokeMethod = _ref.invokeMethod,
29
29
  invokeMethod = _ref$invokeMethod === void 0 ? '_unknown' : _ref$invokeMethod,
30
30
  editorAppearance = _ref.editorAppearance,
31
+ onClose = _ref.onClose,
31
32
  restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
33
+ /**
34
+ * Track onClose handler in a
35
+ * ref so that we void needing it in the dependency array
36
+ * below
37
+ */
38
+ var onCloseRef = (0, _react.useRef)(onClose);
39
+ (0, _react.useEffect)(function () {
40
+ onCloseRef.current = onClose;
41
+ });
42
+
43
+ /**
44
+ * Call onClose on mount, usefull to provide
45
+ * a handler for performing an action after the component has been
46
+ * unmounted (e.g. return focus to the editors)
47
+ */
48
+ (0, _react.useEffect)(function () {
49
+ return function () {
50
+ var _onCloseRef$current;
51
+ return (_onCloseRef$current = onCloseRef.current) === null || _onCloseRef$current === void 0 ? void 0 : _onCloseRef$current.call(onCloseRef);
52
+ };
53
+ }, []);
32
54
  var onEscape = (0, _react.useCallback)(function () {
33
55
  (0, _commands.hideLinkToolbar)()(view.state, view.dispatch);
34
56
  view.dispatch((0, _actions.hideLinkToolbar)(view.state.tr));
@@ -53,7 +53,8 @@ var HyperlinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
53
53
  view = _this$props.view,
54
54
  onCancel = _this$props.onCancel,
55
55
  invokeMethod = _this$props.invokeMethod,
56
- featureFlags = _this$props.featureFlags;
56
+ featureFlags = _this$props.featureFlags,
57
+ onClose = _this$props.onClose;
57
58
  return /*#__PURE__*/_react.default.createElement(_providerFactory.WithProviders, {
58
59
  providers: ['activityProvider', 'searchProvider'],
59
60
  providerFactory: providerFactory,
@@ -79,7 +80,8 @@ var HyperlinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
79
80
  url: displayUrl,
80
81
  displayText: displayText,
81
82
  onSubmit: onSubmitInterface(onSubmit),
82
- onCancel: onCancel
83
+ onCancel: onCancel,
84
+ onClose: onClose
83
85
  }));
84
86
  }
85
87
  return /*#__PURE__*/_react.default.createElement(_HyperlinkAddToolbar.default, {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "185.2.16";
9
+ var version = "185.2.19";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.2.16",
3
+ "version": "185.2.19",
4
4
  "sideEffects": false
5
5
  }
@@ -72,7 +72,7 @@ export const getToolbarConfig = (options, featureFlags, editorAnalyticsApi) => (
72
72
  lpLinkPickerFocusTrap,
73
73
  preventPopupOverflow
74
74
  } = featureFlags;
75
- const shouldEnableFocusTrap = lpLinkPicker && lpLinkPickerFocusTrap;
75
+ const shouldEnableFocusTrap = Boolean(lpLinkPicker && lpLinkPickerFocusTrap);
76
76
  if (linkState && linkState.activeLinkMark) {
77
77
  const {
78
78
  activeLinkMark
@@ -206,6 +206,7 @@ export const getToolbarConfig = (options, featureFlags, editorAnalyticsApi) => (
206
206
  displayText: displayText || '',
207
207
  providerFactory: providerFactory,
208
208
  onCancel: () => view.focus(),
209
+ onClose: lpLinkPickerFocusTrap ? () => view.focus() : undefined,
209
210
  onSubmit: (href, title = '', displayText, inputMethod, analytic) => {
210
211
  var _options$cardOptions;
211
212
  const isEdit = isEditLink(activeLinkMark);
@@ -215,7 +216,9 @@ export const getToolbarConfig = (options, featureFlags, editorAnalyticsApi) => (
215
216
  sourceEvent: analytic
216
217
  }) : insertLinkWithAnalytics(inputMethod, activeLinkMark.from, activeLinkMark.to, href, title, displayText, !!(options !== null && options !== void 0 && (_options$cardOptions = options.cardOptions) !== null && _options$cardOptions !== void 0 && _options$cardOptions.provider), analytic);
217
218
  command(view.state, view.dispatch, view);
218
- view.focus();
219
+ if (!lpLinkPickerFocusTrap) {
220
+ view.focus();
221
+ }
219
222
  }
220
223
  });
221
224
  }
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useCallback, useMemo } from 'react';
2
+ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import { LinkPicker } from '@atlaskit/link-picker';
4
4
  import { hideLinkToolbar as cardHideLinkToolbar } from '../../../card/pm-plugins/actions';
5
5
  import { hideLinkToolbar } from '../../commands';
@@ -16,8 +16,28 @@ export const EditorLinkPicker = ({
16
16
  onCancel,
17
17
  invokeMethod = '_unknown',
18
18
  editorAppearance,
19
+ onClose,
19
20
  ...restProps
20
21
  }) => {
22
+ /**
23
+ * Track onClose handler in a
24
+ * ref so that we void needing it in the dependency array
25
+ * below
26
+ */
27
+ const onCloseRef = useRef(onClose);
28
+ useEffect(() => {
29
+ onCloseRef.current = onClose;
30
+ });
31
+
32
+ /**
33
+ * Call onClose on mount, usefull to provide
34
+ * a handler for performing an action after the component has been
35
+ * unmounted (e.g. return focus to the editors)
36
+ */
37
+ useEffect(() => () => {
38
+ var _onCloseRef$current;
39
+ return (_onCloseRef$current = onCloseRef.current) === null || _onCloseRef$current === void 0 ? void 0 : _onCloseRef$current.call(onCloseRef);
40
+ }, []);
21
41
  const onEscape = useCallback(() => {
22
42
  hideLinkToolbar()(view.state, view.dispatch);
23
43
  view.dispatch(cardHideLinkToolbar(view.state.tr));
@@ -29,7 +29,8 @@ export default class HyperlinkAddToolbar extends React.PureComponent {
29
29
  view,
30
30
  onCancel,
31
31
  invokeMethod,
32
- featureFlags
32
+ featureFlags,
33
+ onClose
33
34
  } = this.props;
34
35
  return /*#__PURE__*/React.createElement(WithProviders, {
35
36
  providers: ['activityProvider', 'searchProvider'],
@@ -59,7 +60,8 @@ export default class HyperlinkAddToolbar extends React.PureComponent {
59
60
  url: displayUrl,
60
61
  displayText: displayText,
61
62
  onSubmit: onSubmitInterface(onSubmit),
62
- onCancel: onCancel
63
+ onCancel: onCancel,
64
+ onClose: onClose
63
65
  }));
64
66
  }
65
67
  return /*#__PURE__*/React.createElement(HyperlinkAddToolbarComp, {
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "185.2.16";
2
+ export const version = "185.2.19";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.2.16",
3
+ "version": "185.2.19",
4
4
  "sideEffects": false
5
5
  }
@@ -77,7 +77,7 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags, e
77
77
  var lpLinkPicker = featureFlags.lpLinkPicker,
78
78
  lpLinkPickerFocusTrap = featureFlags.lpLinkPickerFocusTrap,
79
79
  preventPopupOverflow = featureFlags.preventPopupOverflow;
80
- var shouldEnableFocusTrap = lpLinkPicker && lpLinkPickerFocusTrap;
80
+ var shouldEnableFocusTrap = Boolean(lpLinkPicker && lpLinkPickerFocusTrap);
81
81
  if (linkState && linkState.activeLinkMark) {
82
82
  var activeLinkMark = linkState.activeLinkMark;
83
83
  var hyperLinkToolbar = {
@@ -213,6 +213,9 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags, e
213
213
  onCancel: function onCancel() {
214
214
  return view.focus();
215
215
  },
216
+ onClose: lpLinkPickerFocusTrap ? function () {
217
+ return view.focus();
218
+ } : undefined,
216
219
  onSubmit: function onSubmit(href) {
217
220
  var _options$cardOptions;
218
221
  var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
@@ -226,7 +229,9 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags, e
226
229
  sourceEvent: analytic
227
230
  }) : insertLinkWithAnalytics(inputMethod, activeLinkMark.from, activeLinkMark.to, href, title, displayText, !!(options !== null && options !== void 0 && (_options$cardOptions = options.cardOptions) !== null && _options$cardOptions !== void 0 && _options$cardOptions.provider), analytic);
228
231
  command(view.state, view.dispatch, view);
229
- view.focus();
232
+ if (!lpLinkPickerFocusTrap) {
233
+ view.focus();
234
+ }
230
235
  }
231
236
  });
232
237
  }
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["view", "onCancel", "invokeMethod", "editorAppearance"];
4
- import React, { useCallback, useMemo } from 'react';
3
+ var _excluded = ["view", "onCancel", "invokeMethod", "editorAppearance", "onClose"];
4
+ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
5
5
  import { LinkPicker } from '@atlaskit/link-picker';
6
6
  import { hideLinkToolbar as cardHideLinkToolbar } from '../../../card/pm-plugins/actions';
7
7
  import { hideLinkToolbar } from '../../commands';
@@ -19,7 +19,29 @@ export var EditorLinkPicker = function EditorLinkPicker(_ref) {
19
19
  _ref$invokeMethod = _ref.invokeMethod,
20
20
  invokeMethod = _ref$invokeMethod === void 0 ? '_unknown' : _ref$invokeMethod,
21
21
  editorAppearance = _ref.editorAppearance,
22
+ onClose = _ref.onClose,
22
23
  restProps = _objectWithoutProperties(_ref, _excluded);
24
+ /**
25
+ * Track onClose handler in a
26
+ * ref so that we void needing it in the dependency array
27
+ * below
28
+ */
29
+ var onCloseRef = useRef(onClose);
30
+ useEffect(function () {
31
+ onCloseRef.current = onClose;
32
+ });
33
+
34
+ /**
35
+ * Call onClose on mount, usefull to provide
36
+ * a handler for performing an action after the component has been
37
+ * unmounted (e.g. return focus to the editors)
38
+ */
39
+ useEffect(function () {
40
+ return function () {
41
+ var _onCloseRef$current;
42
+ return (_onCloseRef$current = onCloseRef.current) === null || _onCloseRef$current === void 0 ? void 0 : _onCloseRef$current.call(onCloseRef);
43
+ };
44
+ }, []);
23
45
  var onEscape = useCallback(function () {
24
46
  hideLinkToolbar()(view.state, view.dispatch);
25
47
  view.dispatch(cardHideLinkToolbar(view.state.tr));
@@ -46,7 +46,8 @@ var HyperlinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
46
46
  view = _this$props.view,
47
47
  onCancel = _this$props.onCancel,
48
48
  invokeMethod = _this$props.invokeMethod,
49
- featureFlags = _this$props.featureFlags;
49
+ featureFlags = _this$props.featureFlags,
50
+ onClose = _this$props.onClose;
50
51
  return /*#__PURE__*/React.createElement(WithProviders, {
51
52
  providers: ['activityProvider', 'searchProvider'],
52
53
  providerFactory: providerFactory,
@@ -72,7 +73,8 @@ var HyperlinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
72
73
  url: displayUrl,
73
74
  displayText: displayText,
74
75
  onSubmit: onSubmitInterface(onSubmit),
75
- onCancel: onCancel
76
+ onCancel: onCancel,
77
+ onClose: onClose
76
78
  }));
77
79
  }
78
80
  return /*#__PURE__*/React.createElement(HyperlinkAddToolbarComp, {
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "185.2.16";
2
+ export var version = "185.2.19";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.2.16",
3
+ "version": "185.2.19",
4
4
  "sideEffects": false
5
5
  }
@@ -14,6 +14,8 @@ export interface EditorLinkPickerProps extends OptionalKeys<LinkPickerProps, 'on
14
14
  */
15
15
  invokeMethod?: string;
16
16
  editorAppearance?: EditorAppearance;
17
+ /** Callback to execute on unmount */
18
+ onClose?: () => void;
17
19
  }
18
- export declare const EditorLinkPicker: ({ view, onCancel, invokeMethod, editorAppearance, ...restProps }: EditorLinkPickerProps) => JSX.Element;
20
+ export declare const EditorLinkPicker: ({ view, onCancel, invokeMethod, editorAppearance, onClose, ...restProps }: EditorLinkPickerProps) => JSX.Element;
19
21
  export {};
@@ -5,7 +5,7 @@ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
5
5
  import type { LinkInputType, LinkPickerOptions } from '@atlaskit/editor-common/types';
6
6
  import { EditorLinkPickerProps } from '../EditorLinkPicker';
7
7
  import { FeatureFlags } from '@atlaskit/editor-common/types';
8
- export interface Props extends Pick<EditorLinkPickerProps, 'onCancel' | 'invokeMethod'> {
8
+ export interface Props extends Pick<EditorLinkPickerProps, 'onCancel' | 'invokeMethod' | 'onClose'> {
9
9
  view: EditorView;
10
10
  providerFactory: ProviderFactory;
11
11
  onSubmit: (href: string, title: string | undefined, displayText: string | undefined, inputMethod: LinkInputType, analytic?: UIAnalyticsEvent | null | undefined) => void;
@@ -14,6 +14,8 @@ export interface EditorLinkPickerProps extends OptionalKeys<LinkPickerProps, 'on
14
14
  */
15
15
  invokeMethod?: string;
16
16
  editorAppearance?: EditorAppearance;
17
+ /** Callback to execute on unmount */
18
+ onClose?: () => void;
17
19
  }
18
- export declare const EditorLinkPicker: ({ view, onCancel, invokeMethod, editorAppearance, ...restProps }: EditorLinkPickerProps) => JSX.Element;
20
+ export declare const EditorLinkPicker: ({ view, onCancel, invokeMethod, editorAppearance, onClose, ...restProps }: EditorLinkPickerProps) => JSX.Element;
19
21
  export {};
@@ -5,7 +5,7 @@ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
5
5
  import type { LinkInputType, LinkPickerOptions } from '@atlaskit/editor-common/types';
6
6
  import { EditorLinkPickerProps } from '../EditorLinkPicker';
7
7
  import { FeatureFlags } from '@atlaskit/editor-common/types';
8
- export interface Props extends Pick<EditorLinkPickerProps, 'onCancel' | 'invokeMethod'> {
8
+ export interface Props extends Pick<EditorLinkPickerProps, 'onCancel' | 'invokeMethod' | 'onClose'> {
9
9
  view: EditorView;
10
10
  providerFactory: ProviderFactory;
11
11
  onSubmit: (href: string, title: string | undefined, displayText: string | undefined, inputMethod: LinkInputType, analytic?: UIAnalyticsEvent | null | undefined) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.2.16",
3
+ "version": "185.2.19",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -69,7 +69,7 @@
69
69
  "@atlaskit/icon": "^21.12.0",
70
70
  "@atlaskit/icon-object": "^6.3.0",
71
71
  "@atlaskit/link-analytics": "^8.0.0",
72
- "@atlaskit/link-picker": "^1.24.0",
72
+ "@atlaskit/link-picker": "^1.25.0",
73
73
  "@atlaskit/locale": "^2.5.0",
74
74
  "@atlaskit/logo": "^13.14.0",
75
75
  "@atlaskit/media-card": "^76.0.0",
@@ -167,7 +167,7 @@
167
167
  "@atlaskit/media-integration-test-helpers": "^3.0.0",
168
168
  "@atlaskit/media-test-helpers": "^33.0.0",
169
169
  "@atlaskit/menu": "^1.7.0",
170
- "@atlaskit/page-layout": "^1.6.0",
170
+ "@atlaskit/page-layout": "^1.7.0",
171
171
  "@atlaskit/platform-feature-flags": "^0.2.0",
172
172
  "@atlaskit/renderer": "^108.2.0",
173
173
  "@atlaskit/section-message": "^6.4.0",
@@ -181,7 +181,7 @@
181
181
  "@atlaskit/visual-regression": "*",
182
182
  "@atlaskit/webdriver-runner": "*",
183
183
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
184
- "@atlassian/link-picker-plugins": "^22.3.0",
184
+ "@atlassian/link-picker-plugins": "^23.0.0",
185
185
  "@atlassian/search-provider": "2.4.6",
186
186
  "@atlassian/ufo": "^0.2.0",
187
187
  "@emotion/jest": "^11.8.0",