@atlaskit/editor-plugin-media-insert 6.2.3 → 6.2.5

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,23 @@
1
1
  # @atlaskit/editor-plugin-media-insert
2
2
 
3
+ ## 6.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#144658](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/144658)
8
+ [`e59e7f0ae0803`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e59e7f0ae0803) -
9
+ Change to use getDomRefFromSelection utility from editor-common
10
+ - Updated dependencies
11
+
12
+ ## 6.2.4
13
+
14
+ ### Patch Changes
15
+
16
+ - [#142352](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/142352)
17
+ [`05903fde6d94d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/05903fde6d94d) -
18
+ Internal change to use Compiled variant of `@atlaskit/primitives`.
19
+ - Updated dependencies
20
+
3
21
  ## 6.2.3
4
22
 
5
23
  ### Patch Changes
@@ -17,7 +17,7 @@ var _messages = require("@atlaskit/editor-common/messages");
17
17
  var _upload = _interopRequireDefault(require("@atlaskit/icon/core/upload"));
18
18
  var _upload2 = _interopRequireDefault(require("@atlaskit/icon/glyph/upload"));
19
19
  var _mediaPicker = require("@atlaskit/media-picker");
20
- var _primitives = require("@atlaskit/primitives");
20
+ var _compiled = require("@atlaskit/primitives/compiled");
21
21
  var _sectionMessage = _interopRequireDefault(require("@atlaskit/section-message"));
22
22
  var _useAnalyticsEvents2 = require("./useAnalyticsEvents");
23
23
  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); }
@@ -156,7 +156,7 @@ var LocalMedia = exports.LocalMedia = /*#__PURE__*/_react.default.forwardRef(fun
156
156
  });
157
157
  (_eventSubscribers$cur6 = eventSubscribers.current) === null || _eventSubscribers$cur6 === void 0 || delete _eventSubscribers$cur6[fileId];
158
158
  }, [erroredFileIds, onUploadFailureAnalytics]);
159
- return /*#__PURE__*/_react.default.createElement(_primitives.Stack, {
159
+ return /*#__PURE__*/_react.default.createElement(_compiled.Stack, {
160
160
  grow: "fill",
161
161
  space: "space.200"
162
162
  }, uploadState.error && /*#__PURE__*/_react.default.createElement(_sectionMessage.default, {
@@ -10,13 +10,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
  var _reactIntlNext = require("react-intl-next");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
+ var _getDomRefFromSelection = require("@atlaskit/editor-common/get-dom-ref-from-selection");
13
14
  var _hooks = require("@atlaskit/editor-common/hooks");
14
15
  var _messages = require("@atlaskit/editor-common/messages");
15
16
  var _ui = require("@atlaskit/editor-common/ui");
16
- var _utils = require("@atlaskit/editor-prosemirror/utils");
17
17
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
18
18
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
- var _primitives = require("@atlaskit/primitives");
19
+ var _compiled = require("@atlaskit/primitives/compiled");
20
20
  var _tabs = _interopRequireWildcard(require("@atlaskit/tabs"));
21
21
  var _useFocusEditor = require("./hooks/use-focus-editor");
22
22
  var _useUnholyAutofocus2 = require("./hooks/use-unholy-autofocus");
@@ -27,36 +27,6 @@ var _MediaInsertWrapper = require("./MediaInsertWrapper");
27
27
  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); }
28
28
  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; }
29
29
  var PopupWithListeners = (0, _ui.withOuterListeners)(_ui.Popup);
30
- var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
31
- try {
32
- var domRef = (0, _utils.findDomRefAtPos)(view.state.selection.from, view.domAtPos.bind(view));
33
- if (domRef instanceof HTMLElement) {
34
- // If element is not a paragraph, we need to find the closest paragraph parent
35
- if (domRef.nodeName !== 'P') {
36
- var paragraphRef = domRef.closest('p');
37
- if (paragraphRef) {
38
- return paragraphRef;
39
- }
40
- }
41
- return domRef;
42
- } else {
43
- throw new Error('Invalid DOM reference');
44
- }
45
- } catch (error) {
46
- if (dispatchAnalyticsEvent) {
47
- var payload = {
48
- action: _analytics.ACTION.ERRORED,
49
- actionSubject: _analytics.ACTION_SUBJECT.PICKER,
50
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA,
51
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
52
- attributes: {
53
- error: 'Error getting DOM reference from selection'
54
- }
55
- };
56
- dispatchAnalyticsEvent(payload);
57
- }
58
- }
59
- };
60
30
 
61
31
  /**
62
32
  * A custom TabPanel that is non-focusable.
@@ -68,7 +38,7 @@ var CustomTabPanel = function CustomTabPanel(_ref) {
68
38
  /*#__PURE__*/
69
39
  // Ignored via go/ees005
70
40
  // eslint-disable-next-line react/jsx-props-no-spreading
71
- _react.default.createElement(_primitives.Box, (0, _extends2.default)({
41
+ _react.default.createElement(_compiled.Box, (0, _extends2.default)({
72
42
  paddingBlockEnd: "space.150"
73
43
  }, tabPanelAttributes, {
74
44
  tabIndex: -1
@@ -96,8 +66,9 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
96
66
  targetRef = mountInfo.ref;
97
67
  mountPoint = mountInfo.mountPoint;
98
68
  } else {
69
+ var _api$analytics;
99
70
  // If targetRef is undefined, target the selection in the editor
100
- targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
71
+ targetRef = (0, _getDomRefFromSelection.getDomRefFromSelection)(editorView, _analytics.ACTION_SUBJECT_ID.PICKER_MEDIA, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
101
72
  mountPoint = popupsMountPoint;
102
73
  }
103
74
  var mediaProvider = (_useSharedPluginState3 = (0, _hooks.useSharedPluginState)(api, ['media'])) === null || _useSharedPluginState3 === void 0 || (_useSharedPluginState3 = _useSharedPluginState3.mediaState) === null || _useSharedPluginState3 === void 0 ? void 0 : _useSharedPluginState3.mediaProvider;
@@ -150,7 +121,7 @@ var MediaInsertPicker = exports.MediaInsertPicker = function MediaInsertPicker(_
150
121
  ref: setOutsideClickTargetRef
151
122
  }, /*#__PURE__*/_react.default.createElement(_tabs.default, {
152
123
  id: "media-insert-tab-navigation"
153
- }, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
124
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
154
125
  paddingBlockEnd: "space.150"
155
126
  }, /*#__PURE__*/_react.default.createElement(_tabs.TabList, null, /*#__PURE__*/_react.default.createElement(_tabs.Tab, null, intl.formatMessage(_messages.mediaInsertMessages.fileTabTitle)), /*#__PURE__*/_react.default.createElement(_tabs.Tab, null, intl.formatMessage(_messages.mediaInsertMessages.linkTabTitle)))), /*#__PURE__*/_react.default.createElement(CustomTabPanel, null, /*#__PURE__*/_react.default.createElement(_LocalMedia.LocalMedia, {
156
127
  ref: autofocusRef,
@@ -6,7 +6,7 @@ import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
6
6
  import UploadIcon from '@atlaskit/icon/core/upload';
7
7
  import { default as UploadIconLegacy } from '@atlaskit/icon/glyph/upload';
8
8
  import { Browser } from '@atlaskit/media-picker';
9
- import { Stack } from '@atlaskit/primitives';
9
+ import { Stack } from '@atlaskit/primitives/compiled';
10
10
  import SectionMessage from '@atlaskit/section-message';
11
11
  import { useAnalyticsEvents } from './useAnalyticsEvents';
12
12
  const INITIAL_UPLOAD_STATE = Object.freeze({
@@ -2,13 +2,13 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { useIntl } from 'react-intl-next';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
5
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
7
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
7
8
  import { PlainOutsideClickTargetRefContext, Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
8
- import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
- import { Box } from '@atlaskit/primitives';
11
+ import { Box } from '@atlaskit/primitives/compiled';
12
12
  import Tabs, { Tab, TabList, useTabPanel } from '@atlaskit/tabs';
13
13
  import { useFocusEditor } from './hooks/use-focus-editor';
14
14
  import { useUnholyAutofocus } from './hooks/use-unholy-autofocus';
@@ -17,36 +17,6 @@ import { MediaFromURL } from './MediaFromURL';
17
17
  import { MediaFromURLWithForm } from './MediaFromURLWithForm';
18
18
  import { MediaInsertWrapper } from './MediaInsertWrapper';
19
19
  const PopupWithListeners = withOuterListeners(Popup);
20
- const getDomRefFromSelection = (view, dispatchAnalyticsEvent) => {
21
- try {
22
- const domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
23
- if (domRef instanceof HTMLElement) {
24
- // If element is not a paragraph, we need to find the closest paragraph parent
25
- if (domRef.nodeName !== 'P') {
26
- const paragraphRef = domRef.closest('p');
27
- if (paragraphRef) {
28
- return paragraphRef;
29
- }
30
- }
31
- return domRef;
32
- } else {
33
- throw new Error('Invalid DOM reference');
34
- }
35
- } catch (error) {
36
- if (dispatchAnalyticsEvent) {
37
- const payload = {
38
- action: ACTION.ERRORED,
39
- actionSubject: ACTION_SUBJECT.PICKER,
40
- actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
41
- eventType: EVENT_TYPE.OPERATIONAL,
42
- attributes: {
43
- error: 'Error getting DOM reference from selection'
44
- }
45
- };
46
- dispatchAnalyticsEvent(payload);
47
- }
48
- }
49
- };
50
20
 
51
21
  /**
52
22
  * A custom TabPanel that is non-focusable.
@@ -89,8 +59,9 @@ export const MediaInsertPicker = ({
89
59
  targetRef = mountInfo.ref;
90
60
  mountPoint = mountInfo.mountPoint;
91
61
  } else {
62
+ var _api$analytics;
92
63
  // If targetRef is undefined, target the selection in the editor
93
- targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
64
+ targetRef = getDomRefFromSelection(editorView, ACTION_SUBJECT_ID.PICKER_MEDIA, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
94
65
  mountPoint = popupsMountPoint;
95
66
  }
96
67
  const mediaProvider = (_useSharedPluginState3 = useSharedPluginState(api, ['media'])) === null || _useSharedPluginState3 === void 0 ? void 0 : (_useSharedPluginState4 = _useSharedPluginState3.mediaState) === null || _useSharedPluginState4 === void 0 ? void 0 : _useSharedPluginState4.mediaProvider;
@@ -11,7 +11,7 @@ import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
11
11
  import UploadIcon from '@atlaskit/icon/core/upload';
12
12
  import { default as UploadIconLegacy } from '@atlaskit/icon/glyph/upload';
13
13
  import { Browser } from '@atlaskit/media-picker';
14
- import { Stack } from '@atlaskit/primitives';
14
+ import { Stack } from '@atlaskit/primitives/compiled';
15
15
  import SectionMessage from '@atlaskit/section-message';
16
16
  import { useAnalyticsEvents } from './useAnalyticsEvents';
17
17
  var INITIAL_UPLOAD_STATE = Object.freeze({
@@ -2,13 +2,13 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { useIntl } from 'react-intl-next';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { getDomRefFromSelection } from '@atlaskit/editor-common/get-dom-ref-from-selection';
5
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
7
  import { mediaInsertMessages } from '@atlaskit/editor-common/messages';
7
8
  import { PlainOutsideClickTargetRefContext, Popup, withOuterListeners } from '@atlaskit/editor-common/ui';
8
- import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
- import { Box } from '@atlaskit/primitives';
11
+ import { Box } from '@atlaskit/primitives/compiled';
12
12
  import Tabs, { Tab, TabList, useTabPanel } from '@atlaskit/tabs';
13
13
  import { useFocusEditor } from './hooks/use-focus-editor';
14
14
  import { useUnholyAutofocus } from './hooks/use-unholy-autofocus';
@@ -17,36 +17,6 @@ import { MediaFromURL } from './MediaFromURL';
17
17
  import { MediaFromURLWithForm } from './MediaFromURLWithForm';
18
18
  import { MediaInsertWrapper } from './MediaInsertWrapper';
19
19
  var PopupWithListeners = withOuterListeners(Popup);
20
- var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
21
- try {
22
- var domRef = findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
23
- if (domRef instanceof HTMLElement) {
24
- // If element is not a paragraph, we need to find the closest paragraph parent
25
- if (domRef.nodeName !== 'P') {
26
- var paragraphRef = domRef.closest('p');
27
- if (paragraphRef) {
28
- return paragraphRef;
29
- }
30
- }
31
- return domRef;
32
- } else {
33
- throw new Error('Invalid DOM reference');
34
- }
35
- } catch (error) {
36
- if (dispatchAnalyticsEvent) {
37
- var payload = {
38
- action: ACTION.ERRORED,
39
- actionSubject: ACTION_SUBJECT.PICKER,
40
- actionSubjectId: ACTION_SUBJECT_ID.PICKER_MEDIA,
41
- eventType: EVENT_TYPE.OPERATIONAL,
42
- attributes: {
43
- error: 'Error getting DOM reference from selection'
44
- }
45
- };
46
- dispatchAnalyticsEvent(payload);
47
- }
48
- }
49
- };
50
20
 
51
21
  /**
52
22
  * A custom TabPanel that is non-focusable.
@@ -86,8 +56,9 @@ export var MediaInsertPicker = function MediaInsertPicker(_ref2) {
86
56
  targetRef = mountInfo.ref;
87
57
  mountPoint = mountInfo.mountPoint;
88
58
  } else {
59
+ var _api$analytics;
89
60
  // If targetRef is undefined, target the selection in the editor
90
- targetRef = getDomRefFromSelection(editorView, dispatchAnalyticsEvent);
61
+ targetRef = getDomRefFromSelection(editorView, ACTION_SUBJECT_ID.PICKER_MEDIA, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
91
62
  mountPoint = popupsMountPoint;
92
63
  }
93
64
  var mediaProvider = (_useSharedPluginState3 = useSharedPluginState(api, ['media'])) === null || _useSharedPluginState3 === void 0 || (_useSharedPluginState3 = _useSharedPluginState3.mediaState) === null || _useSharedPluginState3 === void 0 ? void 0 : _useSharedPluginState3.mediaProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media-insert",
3
- "version": "6.2.3",
3
+ "version": "6.2.5",
4
4
  "description": "Media Insert plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,28 +27,28 @@
27
27
  "dependencies": {
28
28
  "@atlaskit/adf-schema": "^47.6.0",
29
29
  "@atlaskit/button": "^23.0.0",
30
- "@atlaskit/editor-common": "^103.0.0",
30
+ "@atlaskit/editor-common": "^103.19.0",
31
31
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
32
- "@atlaskit/editor-plugin-media": "^2.3.0",
32
+ "@atlaskit/editor-plugin-media": "^2.6.0",
33
33
  "@atlaskit/editor-prosemirror": "7.0.0",
34
34
  "@atlaskit/editor-shared-styles": "^3.4.0",
35
35
  "@atlaskit/form": "^12.0.0",
36
- "@atlaskit/icon": "^25.5.0",
37
- "@atlaskit/media-card": "^79.0.0",
36
+ "@atlaskit/icon": "^25.6.0",
37
+ "@atlaskit/media-card": "^79.2.0",
38
38
  "@atlaskit/media-client": "^32.0.0",
39
39
  "@atlaskit/media-client-react": "^4.0.0",
40
40
  "@atlaskit/media-picker": "^68.0.0",
41
41
  "@atlaskit/platform-feature-flags": "^1.1.0",
42
- "@atlaskit/primitives": "^14.3.0",
42
+ "@atlaskit/primitives": "^14.4.0",
43
43
  "@atlaskit/section-message": "^8.2.0",
44
44
  "@atlaskit/tabs": "^18.0.0",
45
45
  "@atlaskit/textfield": "^8.0.0",
46
- "@atlaskit/tmp-editor-statsig": "^4.6.0",
46
+ "@atlaskit/tmp-editor-statsig": "^4.15.0",
47
47
  "@babel/runtime": "^7.0.0",
48
48
  "react-intl-next": "npm:react-intl@^5.18.1"
49
49
  },
50
50
  "peerDependencies": {
51
- "@atlaskit/tokens": "^4.7.0",
51
+ "@atlaskit/tokens": "^4.8.0",
52
52
  "react": "^18.2.0",
53
53
  "react-dom": "^18.2.0"
54
54
  },