@atlaskit/editor-plugin-media-insert 2.0.0 → 2.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,15 @@
1
1
  # @atlaskit/editor-plugin-media-insert
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#130061](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/130061)
8
+ [`bdad694cb2c24`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bdad694cb2c24) -
9
+ [ux] [ED-24566] **@atlaskit/editor-plugin-media-insert**: When user clicks "Cancel" button on
10
+ insert media popup the focus is returned to the editor **@atlaskit/editor-common**: Added event
11
+ type for media insert cancelled analytics
12
+
3
13
  ## 2.0.0
4
14
 
5
15
  ### Major Changes
@@ -13,6 +13,7 @@ var _react = _interopRequireDefault(require("react"));
13
13
  var _reactIntlNext = require("react-intl-next");
14
14
  var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
15
15
  var _new = _interopRequireDefault(require("@atlaskit/button/new"));
16
+ var _analytics = require("@atlaskit/editor-common/analytics");
16
17
  var _messages = require("@atlaskit/editor-common/messages");
17
18
  var _filePreview = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/file-preview"));
18
19
  var _mediaClientReact = require("@atlaskit/media-client-react");
@@ -81,7 +82,7 @@ function MediaFromURL(_ref) {
81
82
  onInsert = _ref.onInsert,
82
83
  onExternalInsert = _ref.onExternalInsert,
83
84
  dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
84
- onEscKeyPressed = _ref.onEscKeyPressed;
85
+ closeMediaInsertPicker = _ref.closeMediaInsertPicker;
85
86
  var intl = (0, _reactIntlNext.useIntl)();
86
87
  var strings = {
87
88
  loadPreview: intl.formatMessage(_messages.mediaInsertMessages.loadPreview),
@@ -212,9 +213,33 @@ function MediaFromURL(_ref) {
212
213
  }, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
213
214
  var onInputKeyPress = _react.default.useCallback(function (event) {
214
215
  if (event && event.key === 'Esc') {
215
- onEscKeyPressed();
216
+ if (dispatchAnalyticsEvent) {
217
+ var payload = {
218
+ action: _analytics.ACTION.CLOSED,
219
+ actionSubject: _analytics.ACTION_SUBJECT.PICKER,
220
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA,
221
+ eventType: _analytics.EVENT_TYPE.UI,
222
+ attributes: {
223
+ exitMethod: _analytics.INPUT_METHOD.KEYBOARD
224
+ }
225
+ };
226
+ dispatchAnalyticsEvent(payload);
227
+ }
228
+ closeMediaInsertPicker();
216
229
  }
217
- }, [onEscKeyPressed]);
230
+ }, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
231
+ var onCancel = _react.default.useCallback(function () {
232
+ if (dispatchAnalyticsEvent) {
233
+ var payload = {
234
+ action: _analytics.ACTION.CANCELLED,
235
+ actionSubject: _analytics.ACTION_SUBJECT.PICKER,
236
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA,
237
+ eventType: _analytics.EVENT_TYPE.UI
238
+ };
239
+ dispatchAnalyticsEvent(payload);
240
+ }
241
+ closeMediaInsertPicker();
242
+ }, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
218
243
  return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
219
244
  as: "form",
220
245
  onSubmit: function onSubmit(e) {
@@ -256,7 +281,8 @@ function MediaFromURL(_ref) {
256
281
  }, strings.loadPreview)), /*#__PURE__*/_react.default.createElement(_primitives.Box, {
257
282
  xcss: ButtonGroupStyles
258
283
  }, /*#__PURE__*/_react.default.createElement(_buttonGroup.default, null, /*#__PURE__*/_react.default.createElement(_new.default, {
259
- appearance: "subtle"
284
+ appearance: "subtle",
285
+ onClick: onCancel
260
286
  }, strings.cancel), /*#__PURE__*/_react.default.createElement(_new.default, {
261
287
  appearance: "primary",
262
288
  isDisabled: !previewState.previewInfo && !previewState.warning,
@@ -15,7 +15,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
15
15
  var MediaInsertContent = exports.MediaInsertContent = function MediaInsertContent(_ref) {
16
16
  var mediaProvider = _ref.mediaProvider,
17
17
  dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
18
- onEscKeyPressed = _ref.onEscKeyPressed;
18
+ closeMediaInsertPicker = _ref.closeMediaInsertPicker;
19
19
  return /*#__PURE__*/_react.default.createElement(_tabs.default, {
20
20
  id: "media-insert-tab-navigation"
21
21
  }, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
@@ -25,6 +25,6 @@ var MediaInsertContent = exports.MediaInsertContent = function MediaInsertConten
25
25
  onExternalInsert: function onExternalInsert() {},
26
26
  onInsert: function onInsert() {},
27
27
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
28
- onEscKeyPressed: onEscKeyPressed
28
+ closeMediaInsertPicker: closeMediaInsertPicker
29
29
  })));
30
30
  };
@@ -89,8 +89,6 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
89
89
  }, /*#__PURE__*/_react.default.createElement(_MediaInsertWrapper.MediaInsertWrapper, null, /*#__PURE__*/_react.default.createElement(_MediaInsertContent.MediaInsertContent, {
90
90
  mediaProvider: mediaProvider,
91
91
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
92
- onEscKeyPressed: function onEscKeyPressed() {
93
- return handleClose(_analytics.INPUT_METHOD.KEYBOARD);
94
- }
92
+ closeMediaInsertPicker: closeMediaInsertPicker
95
93
  })));
96
94
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import ButtonGroup from '@atlaskit/button/button-group';
4
4
  import Button from '@atlaskit/button/new';
5
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
6
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
6
7
  import EditorFilePreviewIcon from '@atlaskit/icon/glyph/editor/file-preview';
7
8
  import { getMediaClient } from '@atlaskit/media-client-react';
@@ -72,7 +73,7 @@ export function MediaFromURL({
72
73
  onInsert,
73
74
  onExternalInsert,
74
75
  dispatchAnalyticsEvent,
75
- onEscKeyPressed
76
+ closeMediaInsertPicker
76
77
  }) {
77
78
  const intl = useIntl();
78
79
  const strings = {
@@ -180,9 +181,33 @@ export function MediaFromURL({
180
181
  }, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
181
182
  const onInputKeyPress = React.useCallback(event => {
182
183
  if (event && event.key === 'Esc') {
183
- onEscKeyPressed();
184
+ if (dispatchAnalyticsEvent) {
185
+ const payload = {
186
+ action: ACTION.CLOSED,
187
+ actionSubject: ACTION_SUBJECT.PICKER,
188
+ actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
189
+ eventType: EVENT_TYPE.UI,
190
+ attributes: {
191
+ exitMethod: INPUT_METHOD.KEYBOARD
192
+ }
193
+ };
194
+ dispatchAnalyticsEvent(payload);
195
+ }
196
+ closeMediaInsertPicker();
197
+ }
198
+ }, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
199
+ const onCancel = React.useCallback(() => {
200
+ if (dispatchAnalyticsEvent) {
201
+ const payload = {
202
+ action: ACTION.CANCELLED,
203
+ actionSubject: ACTION_SUBJECT.PICKER,
204
+ actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
205
+ eventType: EVENT_TYPE.UI
206
+ };
207
+ dispatchAnalyticsEvent(payload);
184
208
  }
185
- }, [onEscKeyPressed]);
209
+ closeMediaInsertPicker();
210
+ }, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
186
211
  return /*#__PURE__*/React.createElement(Box, {
187
212
  as: "form",
188
213
  onSubmit: e => {
@@ -224,7 +249,8 @@ export function MediaFromURL({
224
249
  }, strings.loadPreview)), /*#__PURE__*/React.createElement(Box, {
225
250
  xcss: ButtonGroupStyles
226
251
  }, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
227
- appearance: "subtle"
252
+ appearance: "subtle",
253
+ onClick: onCancel
228
254
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
229
255
  appearance: "primary",
230
256
  isDisabled: !previewState.previewInfo && !previewState.warning,
@@ -5,7 +5,7 @@ import { MediaFromURL } from './FromURL';
5
5
  export const MediaInsertContent = ({
6
6
  mediaProvider,
7
7
  dispatchAnalyticsEvent,
8
- onEscKeyPressed
8
+ closeMediaInsertPicker
9
9
  }) => {
10
10
  return /*#__PURE__*/React.createElement(Tabs, {
11
11
  id: "media-insert-tab-navigation"
@@ -16,6 +16,6 @@ export const MediaInsertContent = ({
16
16
  onExternalInsert: () => {},
17
17
  onInsert: () => {},
18
18
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
19
- onEscKeyPressed: onEscKeyPressed
19
+ closeMediaInsertPicker: closeMediaInsertPicker
20
20
  })));
21
21
  };
@@ -81,6 +81,6 @@ export const MediaInsertPicker = ({
81
81
  }, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent, {
82
82
  mediaProvider: mediaProvider,
83
83
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
84
- onEscKeyPressed: () => handleClose(INPUT_METHOD.KEYBOARD)
84
+ closeMediaInsertPicker: closeMediaInsertPicker
85
85
  })));
86
86
  };
@@ -8,6 +8,7 @@ import React from 'react';
8
8
  import { useIntl } from 'react-intl-next';
9
9
  import ButtonGroup from '@atlaskit/button/button-group';
10
10
  import Button from '@atlaskit/button/new';
11
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
11
12
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
12
13
  import EditorFilePreviewIcon from '@atlaskit/icon/glyph/editor/file-preview';
13
14
  import { getMediaClient } from '@atlaskit/media-client-react';
@@ -74,7 +75,7 @@ export function MediaFromURL(_ref) {
74
75
  onInsert = _ref.onInsert,
75
76
  onExternalInsert = _ref.onExternalInsert,
76
77
  dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
77
- onEscKeyPressed = _ref.onEscKeyPressed;
78
+ closeMediaInsertPicker = _ref.closeMediaInsertPicker;
78
79
  var intl = useIntl();
79
80
  var strings = {
80
81
  loadPreview: intl.formatMessage(mediaInsertMessages.loadPreview),
@@ -205,9 +206,33 @@ export function MediaFromURL(_ref) {
205
206
  }, [onExternalInsert, onInsert, previewState.previewInfo, previewState.warning, inputUrl]);
206
207
  var onInputKeyPress = React.useCallback(function (event) {
207
208
  if (event && event.key === 'Esc') {
208
- onEscKeyPressed();
209
+ if (dispatchAnalyticsEvent) {
210
+ var payload = {
211
+ action: ACTION.CLOSED,
212
+ actionSubject: ACTION_SUBJECT.PICKER,
213
+ actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
214
+ eventType: EVENT_TYPE.UI,
215
+ attributes: {
216
+ exitMethod: INPUT_METHOD.KEYBOARD
217
+ }
218
+ };
219
+ dispatchAnalyticsEvent(payload);
220
+ }
221
+ closeMediaInsertPicker();
209
222
  }
210
- }, [onEscKeyPressed]);
223
+ }, [dispatchAnalyticsEvent, closeMediaInsertPicker]);
224
+ var onCancel = React.useCallback(function () {
225
+ if (dispatchAnalyticsEvent) {
226
+ var payload = {
227
+ action: ACTION.CANCELLED,
228
+ actionSubject: ACTION_SUBJECT.PICKER,
229
+ actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
230
+ eventType: EVENT_TYPE.UI
231
+ };
232
+ dispatchAnalyticsEvent(payload);
233
+ }
234
+ closeMediaInsertPicker();
235
+ }, [closeMediaInsertPicker, dispatchAnalyticsEvent]);
211
236
  return /*#__PURE__*/React.createElement(Box, {
212
237
  as: "form",
213
238
  onSubmit: function onSubmit(e) {
@@ -249,7 +274,8 @@ export function MediaFromURL(_ref) {
249
274
  }, strings.loadPreview)), /*#__PURE__*/React.createElement(Box, {
250
275
  xcss: ButtonGroupStyles
251
276
  }, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
252
- appearance: "subtle"
277
+ appearance: "subtle",
278
+ onClick: onCancel
253
279
  }, strings.cancel), /*#__PURE__*/React.createElement(Button, {
254
280
  appearance: "primary",
255
281
  isDisabled: !previewState.previewInfo && !previewState.warning,
@@ -5,7 +5,7 @@ import { MediaFromURL } from './FromURL';
5
5
  export var MediaInsertContent = function MediaInsertContent(_ref) {
6
6
  var mediaProvider = _ref.mediaProvider,
7
7
  dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
8
- onEscKeyPressed = _ref.onEscKeyPressed;
8
+ closeMediaInsertPicker = _ref.closeMediaInsertPicker;
9
9
  return /*#__PURE__*/React.createElement(Tabs, {
10
10
  id: "media-insert-tab-navigation"
11
11
  }, /*#__PURE__*/React.createElement(Box, {
@@ -15,6 +15,6 @@ export var MediaInsertContent = function MediaInsertContent(_ref) {
15
15
  onExternalInsert: function onExternalInsert() {},
16
16
  onInsert: function onInsert() {},
17
17
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
18
- onEscKeyPressed: onEscKeyPressed
18
+ closeMediaInsertPicker: closeMediaInsertPicker
19
19
  })));
20
20
  };
@@ -82,8 +82,6 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref) {
82
82
  }, /*#__PURE__*/React.createElement(MediaInsertWrapper, null, /*#__PURE__*/React.createElement(MediaInsertContent, {
83
83
  mediaProvider: mediaProvider,
84
84
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
85
- onEscKeyPressed: function onEscKeyPressed() {
86
- return handleClose(INPUT_METHOD.KEYBOARD);
87
- }
85
+ closeMediaInsertPicker: closeMediaInsertPicker
88
86
  })));
89
87
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
4
  import { type OnInsertAttrs } from './types';
5
5
  type Props = {
@@ -7,7 +7,7 @@ type Props = {
7
7
  onInsert: (attrs: OnInsertAttrs) => void;
8
8
  onExternalInsert: (url: string) => void;
9
9
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
10
- onEscKeyPressed: () => void;
10
+ closeMediaInsertPicker: () => void;
11
11
  };
12
- export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, onEscKeyPressed, }: Props): JSX.Element;
12
+ export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, closeMediaInsertPicker, }: Props): JSX.Element;
13
13
  export {};
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent, onEscKeyPressed, }: {
4
+ export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, }: {
5
5
  mediaProvider: MediaProvider;
6
6
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
7
- onEscKeyPressed: () => void;
7
+ closeMediaInsertPicker: () => void;
8
8
  }) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
4
  import { type OnInsertAttrs } from './types';
5
5
  type Props = {
@@ -7,7 +7,7 @@ type Props = {
7
7
  onInsert: (attrs: OnInsertAttrs) => void;
8
8
  onExternalInsert: (url: string) => void;
9
9
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
10
- onEscKeyPressed: () => void;
10
+ closeMediaInsertPicker: () => void;
11
11
  };
12
- export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, onEscKeyPressed, }: Props): JSX.Element;
12
+ export declare function MediaFromURL({ mediaProvider, onInsert, onExternalInsert, dispatchAnalyticsEvent, closeMediaInsertPicker, }: Props): JSX.Element;
13
13
  export {};
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
3
3
  import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
4
- export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent, onEscKeyPressed, }: {
4
+ export declare const MediaInsertContent: ({ mediaProvider, dispatchAnalyticsEvent, closeMediaInsertPicker, }: {
5
5
  mediaProvider: MediaProvider;
6
6
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
7
- onEscKeyPressed: () => void;
7
+ closeMediaInsertPicker: () => void;
8
8
  }) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media-insert",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Media Insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",